Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] move stories to TS #223

Merged
merged 26 commits into from
Jan 15, 2021
Merged

[Feature] move stories to TS #223

merged 26 commits into from
Jan 15, 2021

Conversation

joshuaellis
Copy link
Member

@joshuaellis joshuaellis commented Jan 9, 2021

What

Move the storybook stories files to Typescript.

Why

This will help us catch errors such as the import wasn't put in the index file. It'll also help us check our TS errors when using the library practically since there are no tests.

This will probably end up closing the following issues

Other

I think this would compliment #222 well, so ideally this could be merged into a beta too and both launched together. This is still WIP, hence the draft, but thought it would be useful to track for the wider team since it's a large change and there might be some suggestions to the TS writing of the stories.

@@ -16,7 +16,7 @@ declare global {
}
}

type Props = ReflectorOptions & { children: React.ReactElement<any> }
type Props = ReflectorOptions & Omit<JSX.IntrinsicElements['mesh'], 'args'> & { children: React.ReactElement<any> }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The THREE class Reflector extends Mesh so the story failed, although I find the TS for R3F confusing (becuase im no master) so this might be wrong?

@@ -4,7 +4,8 @@ import { useFrame } from 'react-three-fiber'

type WobbleMaterialType = JSX.IntrinsicElements['meshStandardMaterial'] & {
time?: number
factor: number
factor?: number
speed?: number
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Ref example was proof that these args are optional in the props.

distort: number
radius: number
distort?: number
radius?: number
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Ref example was proof that these args are optional in the props.

@joshuaellis
Copy link
Member Author

will resolve #226

@joshuaellis
Copy link
Member Author

will resolve #176

@joshuaellis joshuaellis requested a review from gsimone January 12, 2021 17:53
@joshuaellis
Copy link
Member Author

Hi @gsimone,

So there are a few changes left:

useGLTF needs this PR to merged to R3F although im not sure it's the best solution so I put in a temp fix for now.

useCamera is throwing TS errors in relation to this issue pmndrs/react-three-fiber#925 (comment) which i'm going to start looking at now.

But I thought it might be good to get the review process started whilst those to issues are going on.

@joshuaellis joshuaellis changed the base branch from master to beta January 12, 2021 18:08
@gsimone
Copy link
Member

gsimone commented Jan 12, 2021

Fixed a couple of minor things in useNormalTexture and useMatcapTexture, and removed js and jsx linting, since we are not going to have those anymore (and it was giving me error when running the linting script 🤷 )

@joshuaellis
Copy link
Member Author

Fixed a couple of minor things in useNormalTexture and useMatcapTexture

Ah yeah, thank you! hopefully we won't need to declare Texture anymore as it should be fixed in pmndrs/react-three-fiber#930

@joshuaellis joshuaellis marked this pull request as ready for review January 14, 2021 18:10
@joshuaellis
Copy link
Member Author

This is ready for merge, codebox CI is complaining because of pkg being private? Had to make tweeks to src files as I was going in regards to the TS impl, just to make you aware.

@vercel
Copy link

vercel bot commented Jan 15, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pmndrs/drei/9q1f4wccv
✅ Preview: https://drei-git-fork-joshuaellis-feature-ts-stories-drei220.pmndrs.vercel.app

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 48c8e2a:

Sandbox Source
currying-butterfly-1r76i Configuration

@gsimone gsimone merged commit e61d0e9 into pmndrs:beta Jan 15, 2021
gsimone added a commit that referenced this pull request Jan 15, 2021
* feat: setup TS for stories

* fix: eslint was ignore .storybook

* feat: add TS to storybook

* refactor: move stories to TS (WIP)

* refactor: move more stories to TS (WIP)

* refactor: src changes for TS move over

I think these were TS problems that were missed.

* fix: ContactShadows story

* refactor: move more stories to TS

* refactor: add MapControls.tsx after raising issues in three

Two errors linked to three.js:
mrdoob/three.js#21058
mrdoob/three.js#21059

* fix: TS errors for passing refs & children

* refactor: add more stories (WIP)

* fix: useContextBridge TS to accept array of children

fixed using DefinitelyTyped/DefinitelyTyped#44572 (comment) because microsoft/TypeScript#14729

* refactor: convert more stories to TS

also useGLTF does not need to declare it's type

* chore: update storybook

* fix: revert useTexture

accidentally committed a WIP change

* refactor: move stories to TS (WIP)

* refactor: revert useGLTF story

* Minor type fixes

* chore: update react-three-fiber to latest

Required for Types

* refactor: move stories to TS

* fix: shaderMaterial on init returns void, not null

* refactor: remove unnecessary type in useFBX

* refactor: type Environment stronger

there was issues with useAsset not understanding it's types....

* Fixes CSB CI (#230)

Co-authored-by: Gianmarco Simone <[email protected]>

Co-authored-by: Josh <[email protected]>
@joshuaellis joshuaellis deleted the feature/TS-Stories-DREI220 branch January 15, 2021 10:08
joshuaellis added a commit that referenced this pull request Jan 18, 2021
* change: move components into core folder

* feat: add import types web & native

index points to web to avoid breaking changes(?) but also cause that's a good default.

* refactor: rollup so it looks for ts not tsx

* refactor: move Html & Loader to web folder, make folders for native & web

index points to web

* Fixes CSB CI (#230)

* [Feature] move stories to TS (#223) (#231)

* feat: setup TS for stories

* fix: eslint was ignore .storybook

* feat: add TS to storybook

* refactor: move stories to TS (WIP)

* refactor: move more stories to TS (WIP)

* refactor: src changes for TS move over

I think these were TS problems that were missed.

* fix: ContactShadows story

* refactor: move more stories to TS

* refactor: add MapControls.tsx after raising issues in three

Two errors linked to three.js:
mrdoob/three.js#21058
mrdoob/three.js#21059

* fix: TS errors for passing refs & children

* refactor: add more stories (WIP)

* fix: useContextBridge TS to accept array of children

fixed using DefinitelyTyped/DefinitelyTyped#44572 (comment) because microsoft/TypeScript#14729

* refactor: convert more stories to TS

also useGLTF does not need to declare it's type

* chore: update storybook

* fix: revert useTexture

accidentally committed a WIP change

* refactor: move stories to TS (WIP)

* refactor: revert useGLTF story

* Minor type fixes

* chore: update react-three-fiber to latest

Required for Types

* refactor: move stories to TS

* fix: shaderMaterial on init returns void, not null

* refactor: remove unnecessary type in useFBX

* refactor: type Environment stronger

there was issues with useAsset not understanding it's types....

* Fixes CSB CI (#230)

Co-authored-by: Gianmarco Simone <[email protected]>

Co-authored-by: Josh <[email protected]>

* 2.2.16

* chore: add templates (#232)

* chore: add react-dom as optional peer depency

if you're using react-native you don't need it.

* docs: update readme

* fix: fix storybook imports that should have been done before

my bad.

Co-authored-by: Gianmarco <[email protected]>
joshuaellis added a commit that referenced this pull request Jan 28, 2021
* [Feature] move stories to TS (#223) (#231)

* feat: setup TS for stories

* fix: eslint was ignore .storybook

* feat: add TS to storybook

* refactor: move stories to TS (WIP)

* refactor: move more stories to TS (WIP)

* refactor: src changes for TS move over

I think these were TS problems that were missed.

* fix: ContactShadows story

* refactor: move more stories to TS

* refactor: add MapControls.tsx after raising issues in three

Two errors linked to three.js:
mrdoob/three.js#21058
mrdoob/three.js#21059

* fix: TS errors for passing refs & children

* refactor: add more stories (WIP)

* fix: useContextBridge TS to accept array of children

fixed using DefinitelyTyped/DefinitelyTyped#44572 (comment) because microsoft/TypeScript#14729

* refactor: convert more stories to TS

also useGLTF does not need to declare it's type

* chore: update storybook

* fix: revert useTexture

accidentally committed a WIP change

* refactor: move stories to TS (WIP)

* refactor: revert useGLTF story

* Minor type fixes

* chore: update react-three-fiber to latest

Required for Types

* refactor: move stories to TS

* fix: shaderMaterial on init returns void, not null

* refactor: remove unnecessary type in useFBX

* refactor: type Environment stronger

there was issues with useAsset not understanding it's types....

* Fixes CSB CI (#230)

Co-authored-by: Gianmarco Simone <[email protected]>

Co-authored-by: Josh <[email protected]>

* 2.2.16

* chore: add templates (#232)

* chore: add react-dom as optional peer depency

if you're using react-native you don't need it.

* docs: update readme

* fix: fix storybook imports that should have been done before

* BREAKING CHANGE: refactor internal to solve react-native imports

my bad.

Co-authored-by: Gianmarco <[email protected]>

* 2.3.0-beta.0

* fix: edit transformOutputPath to remove .ts from files

* 2.3.0-beta.1

* fix: useAnimations ref type & chore: add storybook entry for useAnimations

* Added THREE.Group to useAnimations types

* Small refactor

* Added useAnimations story

* Clean up storybook

* Fix null ref typing on useAnimations

* Forgot to change typing on useAnimations api

* chore: add storybook entry to README

Co-authored-by: Josh Ellis <[email protected]>

* [fix] Blob is undefined when using SSR (#239)

* fix: #233 Blob is undefined in SSR

* refactor: it appears Billboard is fixed

Looks like Typescript does not suck.

* 2.3.0-beta.2

* fix: create polyfill for atob

* 2.3.0-beta.3

* chore: update readme in response to #240

* fix: #242 Frustum has incorrect spelling in softshadows (#243)

* fix: suggestion for fixing #242

* refactor: default should be other way round

* chore: update readme with correct spelling

* 2.3.0-beta.4

* feat: Add MeshoptDecoder support to useGLTF (#246)

* Add MeshoptDecoder support to useGLTF

* chore: move center

Co-authored-by: Josh Ellis <[email protected]>

* 2.3.0-beta.5

* feat: #181 – adding points to line (#247)

* feat: re-create geometry on new points

* refactor: useMemo the geometry instead of useEffect

* 2.3.0-beta.6

* 3.0.0-beta.1

* 3.0.0-beta.2

* feat: update troika with new features (#255)

* 3.0.0-beta.3

* feat: add ability to add custom scene as prop (#256)

* feat: add ability to add custom scene as prop

* docs: update Environment with new feats

* 3.0.0-beta.4

* refactor: shuffle imports for beta

* 3.0.0-beta.5

* docs: clearly specify name of package & old has been deprecated

* BREAKING CHANGE: Upgrade Three.js to r125 (#262)

* chore: update Three.js dependency

* refactor: remove subdivision modifier

* fix: remove use of FaceNormalsHelper as it no longer exists in Three

* fix: update typings for THREE

* fix: update modifiers to work without THREE.Geometry

* docs: update README

* chore: add Three.js peer dependency

* fix: change install instructions to use yarn instead of npm (#265)

* repurpose reflector, make it capable to blur (#260)

* repurpose reflector, make it capable to blur

* refactor: move materials out to reduce noise & fix types

* refactor: merge beta

* fix: add child propType

* refactor: update reflector story & fix children type

* changes

* fix: shuffle types so reflectorProps come from what the material expects

* docs

Co-authored-by: Josh Ellis <[email protected]>

* chore: add workflows to beta release

* BREAKING CHANGE force build

* 3.0.0-beta.6

Co-authored-by: Gianmarco Simone <[email protected]>
Co-authored-by: Tanner Hartwig <[email protected]>
Co-authored-by: Matt Rossman <[email protected]>
Co-authored-by: Renaud Rohlinger <[email protected]>
Co-authored-by: Jure Triglav <[email protected]>
Co-authored-by: Jason Bixon <[email protected]>
Co-authored-by: Paul Henschel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Contact shadows example is broken [Idea] Stories should be written in TS Type for useTexture
2 participants