File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed
Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ export interface RenderOptions<
127127 * @see {@link https://react.dev/reference/react-dom/client/createRoot#parameters createRoot#options }
128128 */
129129 onCaughtError ?: ReactDOMClient . RootOptions extends {
130- onCaughtError : infer OnCaughtError
130+ onCaughtError ? : infer OnCaughtError
131131 }
132132 ? OnCaughtError
133133 : never
Original file line number Diff line number Diff line change @@ -264,11 +264,22 @@ export function testContainer() {
264264}
265265
266266export function testErrorHandlers ( ) {
267- // React 19 types are not used in tests. Verify manually if this works with `"@types/react": "npm:types-react@rc"`
267+ // This test runs under both React 18 and React 19 types. For React 19, verify that this works with `"@types/react": "npm:types-react@rc"`.
268268 render ( null , {
269- // Should work with React 19 types
270- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
271- // @ts -expect-error
269+ // This option is intended to type-check successfully with React 19 types
270+ // but to fail (produce a type error) with React 18 types.
271+ //
272+ // > Why use `@ts-ignore` instead of `@ts-expect-error`?
273+ // > Semantically, `@ts-expect-error` would be the right choice here:
274+ // > it would fail under React 18 types and be unused under React 19 types.
275+ // > However, when running with React 19 types, TypeScript reports that
276+ // > `@ts-expect-error` is unused, which causes unwanted noise in CI.
277+ // > To avoid those unused-directive diagnostics while still supporting
278+ // > both React 18 and React 19 typings, we pragmatically use `@ts-ignore`,
279+ // > acknowledging that it suppresses any real type errors at this site.
280+ //
281+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error
282+ // @ts -ignore
272283 onCaughtError : ( ) => { } ,
273284 } )
274285 render ( null , {
You can’t perform that action at this time.
0 commit comments