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
[React] The 16.x.x types are not in npm as @next, so projects are getting them too soon #18708
Comments
Same issue, please fix this issue ASAP. 😥😥😥 |
This is an outcome of PR #18463. Seems like an issue where npm isn't coalescing the values on your system. I tried to replicate on my system but npm seemed to properly resolve the packages with npm 5.3.0. @kurtinatlanta Can you take a look and let me know how to replicate the problem you're seeing? |
@richseviora It's pretty easy to reproduce. I created an empty directory with a fresh package.json (nothing installed) and did this:
As you can see, it gets @types/react 16.0.2, not 15.6.x. This leads me to believe that @latest is getting set in npm to 16.0.2 instead of @next in npm. Which is proven by this:
If I do the same with react itself, I get this:
Which shows react using the @next tag for 16.0.x. My conclusion is that @types/react is getting published to npm either without any tag, so npm uses the default @latest, or explicitly with --tag latest in the npm publish command. |
@kurtinatlanta I thought the problem was that you were getting typescript compile errors b/c npm was returning two versions of I tried to replicate the former problem, and from a clean build I was not able to reproduce it (see the repository's I don't know that we have the ability to tag types packages as Assuming we don't have the ability tag a specific version as |
From over a year ago...
It seems to only make sense that types packages would be able to specify a |
@richseviora Thanks for your efforts. I'm sure this isn't what you wanted to spend your day on, so I appreciate the effort.. Did you do what I mentioned I did in my last post? Anyone doing I get that types-publisher may not provide a way to specify the npm tag (though it should). Part of my fun comes from transitive dependencies. We have Project A that depends on React, we have project B that depends on a set of components that depends on React. When these all get mixed together, the bad things start to happen. So it will take some time to pull together multiple packages that show interactions. |
@corydeppen - agreed it'd be ideal but it doesn't look like the capability exists today. single tear @kurtinatlanta :) hey, I'm happy to help where I can :) Re: trying to install new If you are still getting compile issues, can you reproduce the actual compile error in a test repo? I can't reproduce it myself in a clean repo, so I'm not sure that the issue is with the presence of V16 types with other repos that have a wildcard dependency on React so much. I think instead it is Otherwise, is it worth the effort to revert to V15? (assuming such a thing is supported) After all, the only change 16 made was to introduce an optional lifecycle method. Implementing it in components created under 15 would have no absolutely no effect. |
@richseviora I can try to find time to get a good test repo going. It does seem to happen more when I have multiple versions installed in node_modules like this:
With this error showing up for every React.DOM item (which usually means multiple versions installed):
This tends to happen after npm update, which goes and gets @types/react 16.0.x. |
Hi again! Apologies for the delay in getting back to this. Looking at this issue in I think we need a policy answer from the admins here. Should/can we revert a type definition if it's been published in advance of the package itself being released? Also, should definitions that depend on other definitions have those definitions be marked as a peer dependency? |
We updated all our projects to @types/react 16.0.2 and that has cleared things up for us, so it may have just been multiple versions in node_modules conflicting. I'm closing this for now. |
@types/react
package and had problems.Definitions by:
inindex.d.ts
) so they can respond.I am grateful to the team that maintains these - please keep up the good work.
The @types definitions for React 16 are getting into the wild too soon causing errors in TypeScript builds.
Even though I have projects that depend on "15.6.0" in order lock-in the version of @types/react, the "*" dependencies in projects like @types/react-dom and @types/react-virtualized seem to allow npm to resolve it all to 16.0.1, which causes builds to break.
React itself is pushing its @16.x.x builds to npm with the @next tag so that builds that want @latest don't inadvertently update to the React 16 betas. The matching @types should do the same.
Here is the resulting error (one for each React.DOM item):
ERROR in [at-loader] ./node_modules/@types/react/index.d.ts:3458:13
TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'DetailedHTMLProps<AnchorHTMLAttributes, HTMLAnchorElement>', but here has type 'DetailedHTMLProps<AnchorHTMLAttributes, HTMLAnchorElement>'.
If I hand-edit package-lock.json to make sure that the various dependencies don't resolve to @types/react 16.x.x, the errors go away.
The text was updated successfully, but these errors were encountered: