-
Notifications
You must be signed in to change notification settings - Fork 2
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 TS error: Deduplicate @types/react
#1586
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest expanding this diff. In particular, you'll notice that yarn used to resolve two different versions of @types/react
, but now it only resolves one.
Before:
resolution: "@types/react@npm:18.3.3"
resolution: "@types/react@npm:18.3.7"
now
resolution: "@types/react@npm:18.3.8"
"resolutions": { | ||
"@types/react": "^18", | ||
"@types/react-dom": "^18" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://yarnpkg.com/configuration/manifest#resolutions
We were getting multiple versions of @types/react
resolved by yarn. This can cause typescript problems. In particular, it was causing the error
[ol-components]: Process started
[ol-components]: src/components/Carousel/Carousel.tsx(34,28): error TS2769: No overload matches this call.
[ol-components]: Overload 1 of 6, '(component: ComponentClass<Settings, any>, options?: StyledOptions<Settings> | undefined): CreateStyledComponent<Settings & { ...; }, {}, { ...; }>', gave the following error.
[ol-components]: Argument of type 'typeof Slider' is not assignable to parameter of type 'ComponentClass<Settings, any>'.
[ol-components]: Types of property 'contextType' are incompatible.
[ol-components]: Type 'import("/Users/cchudzicki/dev/mit-open/node_modules/@types/react-transition-group/node_modules/@types/react/index").Context<any> | undefined' is not assignable to type 'React.Context<any> | undefined'.
[ol-components]: Type 'import("/Users/cchudzicki/dev/mit-open/node_modules/@types/react-transition-group/node_modules/@types/react/index").Context<any>' is not assignable to type 'React.Context<any>'.
[ol-components]: Types of property 'Provider' are incompatible.
[ol-components]: Type 'import("/Users/cchudzicki/dev/mit-open/node_modules/@types/react-transition-group/node_modules/@types/react/index").Provider<any>' is not assignable to type 'React.Provider<any>'.
[ol-components]: Types of parameters 'props' and 'props' are incompatible.
[ol-components]: Type 'React.ProviderProps<any>' is not assignable to type 'import("/Users/cchudzicki/dev/mit-open/node_modules/@types/react-transition-group/node_modules/@types/react/index").ProviderProps<any>'.
[ol-components]: Types of property 'children' are incompatible.
[ol-components]: Type 'React.ReactNode' is not assignable to type 'import("/Users/cchudzicki/dev/mit-open/node_modules/@types/react-transition-group/node_modules/@types/react/index").ReactNode'.
[ol-components]: Type 'bigint' is not assignable to type 'ReactNode'.
A similar issue cropped up in mitxonline a while ago. See
for more details.
Note:
You can fix this temporarily with yarn dedupe @types/react
, but subsequent updates to yarn.lock
might get you two different versions again.
This should fix it permanently (or at least until React 19 comes out, when we'll need to update the type verion).
I added a resolution for @types/react-dom
, too, since the two go hand in hand.
@types/react
* adding metadata to channel details page * refactor * refactor * switching to using site name * switching to using site name * adding site name * adding site name * removing comment * using getMetadataAsync for open resource drawer * switching to getMetaData * import missing var * fixing search page title and edit channel details title * removing unused attr * removing redundant metatag call * removing comment * fixing regression with settings tabs * adding more titles and fixing regression on search page * fixing missing import * missing import * adding site name * adding site name * removing conditional * moving addition of site name to getMetaData * adding docstrings * refactoring metatag method * switching to standardizeMetadata and refactoring all views to use async method * removign wrapper fragment * set single react types resolution (#1586) * switching to standardizeMetadata method * fixing typechecks --------- Co-authored-by: Chris Chudzicki <[email protected]>
* adding metadata to channel details page * refactor * refactor * switching to using site name * switching to using site name * adding site name * adding site name * removing comment * using getMetadataAsync for open resource drawer * switching to getMetaData * import missing var * fixing search page title and edit channel details title * removing unused attr * removing redundant metatag call * removing comment * fixing regression with settings tabs * adding more titles and fixing regression on search page * fixing missing import * missing import * adding site name * adding site name * removing conditional * moving addition of site name to getMetaData * adding docstrings * refactoring metatag method * switching to standardizeMetadata and refactoring all views to use async method * removign wrapper fragment * set single react types resolution (#1586) * switching to standardizeMetadata method * fixing typechecks --------- Co-authored-by: Chris Chudzicki <[email protected]>
* adding metadata to channel details page * refactor * refactor * switching to using site name * switching to using site name * adding site name * adding site name * removing comment * using getMetadataAsync for open resource drawer * switching to getMetaData * import missing var * fixing search page title and edit channel details title * removing unused attr * removing redundant metatag call * removing comment * fixing regression with settings tabs * adding more titles and fixing regression on search page * fixing missing import * missing import * adding site name * adding site name * removing conditional * moving addition of site name to getMetaData * adding docstrings * refactoring metatag method * switching to standardizeMetadata and refactoring all views to use async method * removign wrapper fragment * set single react types resolution (#1586) * switching to standardizeMetadata method * fixing typechecks --------- Co-authored-by: Chris Chudzicki <[email protected]>
* adding metadata to channel details page * refactor * refactor * switching to using site name * switching to using site name * adding site name * adding site name * removing comment * using getMetadataAsync for open resource drawer * switching to getMetaData * import missing var * fixing search page title and edit channel details title * removing unused attr * removing redundant metatag call * removing comment * fixing regression with settings tabs * adding more titles and fixing regression on search page * fixing missing import * missing import * adding site name * adding site name * removing conditional * moving addition of site name to getMetaData * adding docstrings * refactoring metatag method * switching to standardizeMetadata and refactoring all views to use async method * removign wrapper fragment * set single react types resolution (#1586) * switching to standardizeMetadata method * fixing typechecks --------- Co-authored-by: Chris Chudzicki <[email protected]>
What are the relevant tickets?
None
Description (What does it do?)
Fixes typescript error currently happening on NextJS branch
How can this be tested?
Since only
@types/
packages are affected, there should be absolutely zero runtime consequences.CI should pass. You could run
yarn typecheck
locally, too (afteryarn install
).