-
Notifications
You must be signed in to change notification settings - Fork 725
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
fix: type errors with latest three types #1382
fix: type errors with latest three types #1382
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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 8ad22e0:
|
@CodyJasonBennett this looks great, what do you think? |
ff344d4
to
5589205
Compare
I went ahead and implemented this for all usages of
|
Hey guys, is there anything that prevents this PR from being merged? |
Is there news on the merging of this PR ? |
I'm happy to resolve merge conflicts whenever there's a signal from the maintainers that they're open to merging this. |
Sorry I missed this. I'm happy to accept these changes, although I worry this is a deeper issue with our configuration and/or TypeScript itself. It's not intended nor intuitive for our dev dependencies to influence consumer code whatsoever, and I foresee this continuing to affect future projects and be a routine issue. Is this a known issue or pitfall that has tracking? I'm admittedly a bit disappointed in the stability of types across our ecosystem and want to stem the bleeding if I can. |
I think it has to do with using the types in Ideally, it would be good if typescript understood that the types comes not from your dev dependencies, but the actual It doesn't seem like a conceptual problem to me, simply that towers of dependencies can get complicated when typescript is involved. This problem should only occur when |
It is absolutely a bug if TypeScript diverges from Node resolution as per consumers' configurations, thus |
TypeScript does not pay attention to whether a package is a I also don't think there's a blessed way to control type expansion in the emitted types. microsoft/TypeScript#35654 (which is closed, but I'm not sure it should be), microsoft/TypeScript#47205, microsoft/TypeScript#34778, and microsoft/TypeScript#31940 seem like some related issues to watch on that front. |
Yeah, @Methuselah96 explained it way better than I did. I wasn't aware that it was a well known thing that people are requesting. |
It's unfortunate microsoft/TypeScript#35654 doesn't cover this case, but I better understand the motivations for this PR. Thanks. |
5589205
to
8ad22e0
Compare
Merge conflicts resolved. |
🎉 This PR is included in version 9.80.8 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Why
Resolves #1381.
This PR avoids expanding the types used as part of
React.forwardRef
. This is important because the types might differ depending on which version of three.js is being used. If the types are expanded at compile-time (as they are now), they are using the version of@types/three
that@react-three/drei
depends on as a devDependency, which might cause issues with the consumer's version of@types/three
.I think it would make sense to apply this change to most of the drei components that are using
forawrdRef
, so I'm opening this as a draft PR before updating the ~70 components that this new approach would be applied to.What
Introduce
ForwardRefComponent
type that every component that usesforwardRef
can use in order to avoid expanding types at compile-time of the@react-three/drei
declaration files.As an example, before this PR, the
Detailed
component declaration types look like this:After this PR, the
Detailed
component declaration types look like this:Checklist