-
Notifications
You must be signed in to change notification settings - Fork 1k
[labs/react] Update react versions used for testing and add type as peer dependency #4000
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
Conversation
🦋 Changeset detectedLatest commit: f9fc913 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📊 Tachometer Benchmark ResultsSummarynop-update
render
update
update-reflect
Resultslit-element-list
render
update
update-reflect
lit-html-kitchen-sink
render
update
nop-update
lit-html-repeat
render
update
lit-html-template-heavy
render
update
reactive-element-list
render
update
update-reflect
|
|
This ended up needing a lot of additional changes, particularly this: b4ef3c2 This arguably could be its own PR, but it's really only a problem because of the react types so unsure if it really should be separated out. |
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| await renderReactComponent({id: null as any}); |
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'm not sure that these should explicitly be expecting TS error which implies that we're testing that the typing of the created component should not be allowed to take null as the value of these HTML attributes.
My thought is we're only concerned with testing runtime behavior of what happens if null is somehow provided.
|
Also resolve #3560 |
AndrewJakubowicz
left a comment
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.
Nice! Thanks for splitting out the other changes. It made this much easier to review!
| "jsx": "react", | ||
| "noImplicitOverride": true, | ||
| "types": ["mocha", "react", "react-dom"] | ||
| "skipLibCheck": true, |
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.
Why was this needed? Is there an issue with the react, and react-dom types being checked as they've been removed from the types array?
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.
react and react-dom could be removed from types as we're not relying on them being available as UMD globals.
skipLibCheck was needed because some React internal typings after updating to 18.2 were causing errors, possibly incompatible with our other tsconfig options.
Fixes #3149
The version of React we use for testing has been bumped to 18. To make this work:
This was needed as React added package exports preventing module resolution into the actual umd dist files we used to have but still only exports cjs.
This also feels more realistic and the code more idiomatic to write.
ReactDOM.render()calls to usecreateRoot()fromreact-dom/client.We also reuse the render root across multiple renders within the same test.
render()calls were no longer synchronous (likely to support React's new ability to batch multiple setState calls) so to make sure we do DOM assertions after React has finished rendering, useact()fromreact-dom/test-utilswhere needed.https://legacy.reactjs.org/docs/testing-recipes.html#act
This also required adding a global flag up top as described here: https://react.dev/blog/2022/03/08/react-18-upgrade-guide#configuring-your-testing-environment
useControllertest required a bit of tweak as React 18 strict mode also reruns effects.Additionally, we already had direct usage of typings from
@types/reactin consumer facing code likelit/packages/labs/react/src/create-component.ts
Lines 53 to 58 in 012e8bc
But we only had
@types/reactlisted in dev dependencies. This was moved as a peer dependency.I do want to revisit dropping this all-together to use generic types that can accept both React and Preact types.