Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export interface RenderOptions<
* @see {@link https://react.dev/reference/react-dom/client/createRoot#parameters createRoot#options}
*/
onCaughtError?: ReactDOMClient.RootOptions extends {
onCaughtError: infer OnCaughtError
onCaughtError?: infer OnCaughtError
}
? OnCaughtError
: never
Expand Down
14 changes: 11 additions & 3 deletions types/test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,17 @@ export function testContainer() {
export function testErrorHandlers() {
// React 19 types are not used in tests. Verify manually if this works with `"@types/react": "npm:types-react@rc"`
render(null, {
// Should work with React 19 types
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
// Should work with React 19 types but intentionally fails with React 18 types.
//
// > Why use `@ts-ignore` instead of `@ts-expect-error`?
// > By default, React 19 types run without errors,
// > causing the TS compiler to report `@ts-expect-error` as unused,
// > so this TS directive must be removed.
// > However, to maintain compatibility with React 18 types during CI testing,
// > we had to instead use `@ts-ignore`.
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error
// @ts-ignore
onCaughtError: () => {},
})
render(null, {
Expand Down