[react] React 18 types#56210
Merged
typescript-bot merged 29 commits intoDefinitelyTyped:masterfrom Apr 7, 2022
Merged
Conversation
This was referenced Oct 5, 2021
This was referenced Apr 14, 2023
5 tasks
|
Still, if your component doesn't use |
8 tasks
5 tasks
8 tasks
4 tasks
2 tasks
3 tasks
2 tasks
2 tasks
13 tasks
This was referenced Sep 4, 2024
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Overwhelmed by compile errors after upgrading to
@types/react@^18.0.0? Check out https://github.com/eps1lon/types-react-codemod.Upgrading to React 18 with TypeScript
Breaking Changes
Removal of implicit children
For components that do implement
childrenbut relied on their implicit declaration fromReact.FunctionComponentorReact.Component:interface Props { + children?: React.ReactNode; } class SomeClassComponents React.Component<Props> { render() { return <div>{this.props.children}</div> } } const SomeFunctionComponent: React.FunctionComponent<Props> = props => <div>{props.children}</div>Please check Removal Of Implicit Children for the rationale.
I may have a solution to bring these back on-demand without patching the published types (watch #59751)
Remove
{}fromReactFragmentThis was never correct and mostly required to interop with implicit
children.this.contextbecomesunknownWas
anybefore. The community mostly prefersunknownby default (anywould silently be unsound).Restore old behavior:
class Component extends React.Component { + context: any; render() { return this.context.value; } } ### `noImplicitAny` and `useCallback` Enabling `noImplicitAny` in `tsconfig` (on by default with `strict: true`) will not type-check if an explicit type is omitted in `useCallback`. ```diff + // @ts-expect-error -- `event` as implicitly type 'any' useCallback((event) => {})Remove deprecated types
Bringing the terminology more in line with how they're called in the React docs and repository.
Issues
Closes #46691
Closes #34237
Closes #56026
Closes #52873
Follow-up:
react-dom/node-streamentrypoint from v17 since that no longer exists there either ([react-dom] Remove /node-stream entrypoint #59747)createMutableSourcefrom/experimental([react] Remove unstable_createMutableSource #59746)react-dom/serveras mentioned in [react] React 18 types #56210 (comment) ([react-dom] AddrenderToPipeableStreamandrenderToReadableStream#59748)react-test-rendererfor React 18 ([react-test-renderer] Publish as v18 #59813