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

fix TS error: Deduplicate @types/react #1586

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

ChristopherChudzicki
Copy link
Contributor

@ChristopherChudzicki ChristopherChudzicki commented Sep 19, 2024

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 (after yarn install).

@ChristopherChudzicki ChristopherChudzicki changed the base branch from main to nextjs September 19, 2024 19:43
Copy link
Contributor Author

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"

Comment on lines +28 to +30
"resolutions": {
"@types/react": "^18",
"@types/react-dom": "^18"
Copy link
Contributor Author

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.

@ChristopherChudzicki ChristopherChudzicki changed the title Cc/pin react types fix TS error: Deduplicate @types/react Sep 19, 2024
@ChristopherChudzicki ChristopherChudzicki marked this pull request as ready for review September 19, 2024 19:52
@shanbady shanbady self-requested a review September 19, 2024 20:03
@shanbady shanbady self-assigned this Sep 19, 2024
@ChristopherChudzicki ChristopherChudzicki merged commit bf9adfb into nextjs Sep 19, 2024
12 checks passed
shanbady pushed a commit that referenced this pull request Sep 19, 2024
shanbady added a commit that referenced this pull request Sep 20, 2024
* 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]>
jonkafton pushed a commit that referenced this pull request Sep 23, 2024
jonkafton pushed a commit that referenced this pull request Sep 23, 2024
* 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]>
jonkafton pushed a commit that referenced this pull request Sep 23, 2024
jonkafton pushed a commit that referenced this pull request Sep 23, 2024
* 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]>
jonkafton pushed a commit that referenced this pull request Sep 24, 2024
jonkafton pushed a commit that referenced this pull request Sep 24, 2024
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants