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

New version of @types/react causing type errors with a new yarn.lock #153

Closed
ericfrank-stripe opened this issue Apr 8, 2022 · 6 comments

Comments

@ericfrank-stripe
Copy link
Contributor

Hey remote-ui team 👋. This issue is going to look very similar to #151, but it's brand new as of last night.

TL;DR: Type checking is broken in this repository with a fresh yarn.lock file because of a new version of @types/react.

Steps to reproduce:

  1. Check out a clean copy of the main branch
  2. Delete yarn.lock
  3. Run yarn install
  4. Run yarn type-check

tsc reports many errors of this type:

'RemoteImage' cannot be used as a JSX component.
  Its element type 'ReactElement<any, any> | Component<ReactPropsFromRemoteComponentType<RemoteComponentType<"Image", { src: string; }, true>>, any, any> | null' is not a valid JSX element.

Yesterday (April 7) version 18.0.0 of @react/types was published to NPM. The @types/react-reconciler package (for all versions) requests "@types/react": "*", so as soon as the new version came out it started pulling it in for new installs. Here's what the dependency tree looks like:

% npm list @types/react
@remote-ui/[email protected] /Users/ericfrank/stripe/remote-ui/packages/react
├── @types/[email protected] 
├─┬ @types/[email protected]
│ └── @types/[email protected]  deduped
└─┬ @types/[email protected]
  └── @types/[email protected]

You can see that react-reconciler has it's own version of @types/react pinned to version 18. remote-ui does not support React 18 yet, so the mismatch in types causes the errors. I'm not familiar with how those type libraries get generated on DefinitelyTyped and I don't have a great solution to this at the moment. We're advising our developers to add a resolutions property to their package.json files as a workaround:

{
  "resolutions": {
    "@types/react": "17.0.2"
  }
}

I'm continuing my research, but let me know if you have an idea how we can solve this one. Thanks!

@ericfrank-stripe
Copy link
Contributor Author

ericfrank-stripe commented Apr 8, 2022

Looks like this is the issue: facebook/react#24304

@kumar303
Copy link
Contributor

I ran into this the other day, too

@kumar303
Copy link
Contributor

This is a good explainer of what's going on facebook/react#24304 (comment)

@ericfrank-stripe
Copy link
Contributor Author

Closing—we're going with the resolutions fix for our users.

@lemonmade
Copy link
Member

Yeah, sorry we can't offer anything better, I think resolutions are the best any kind of project generator can do if they want to output a React 17-supporting TypeScript project :(

@ericfrank-stripe
Copy link
Contributor Author

@lemonmade No worries, I don't think this issue is fixable from within @remote-ui which is why I closed it.

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

No branches or pull requests

3 participants