Unverified Commit 2368e1c3 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

Augment React types internally instead of overwriting them (#81561)

parent a7a42b38
...@@ -137,8 +137,8 @@ ...@@ -137,8 +137,8 @@
"@types/jest": "29.5.5", "@types/jest": "29.5.5",
"@types/node": "20.17.6", "@types/node": "20.17.6",
"@types/node-fetch": "2.6.1", "@types/node-fetch": "2.6.1",
"@types/react": "19.1.1", "@types/react": "19.1.8",
"@types/react-dom": "19.1.2", "@types/react-dom": "19.1.6",
"@types/relay-runtime": "14.1.13", "@types/relay-runtime": "14.1.13",
"@types/string-hash": "1.1.1", "@types/string-hash": "1.1.1",
"@types/trusted-types": "2.0.3", "@types/trusted-types": "2.0.3",
...@@ -293,8 +293,8 @@ ...@@ -293,8 +293,8 @@
"@babel/parser": "7.27.0", "@babel/parser": "7.27.0",
"@babel/types": "7.27.0", "@babel/types": "7.27.0",
"@babel/traverse": "7.27.0", "@babel/traverse": "7.27.0",
"@types/react": "^19.1.1", "@types/react": "19.1.8",
"@types/react-dom": "19.1.2", "@types/react-dom": "19.1.6",
"@types/retry": "0.12.0", "@types/retry": "0.12.0",
"jest-snapshot": "30.0.0-alpha.6", "jest-snapshot": "30.0.0-alpha.6",
"react": "19.2.0-canary-97cdd5d3-20250710", "react": "19.2.0-canary-97cdd5d3-20250710",
......
...@@ -213,7 +213,6 @@ function onDefaultTransitionIndicator() { ...@@ -213,7 +213,6 @@ function onDefaultTransitionIndicator() {
} }
const reactRootOptions: ReactDOMClient.RootOptions = { const reactRootOptions: ReactDOMClient.RootOptions = {
// @ts-expect-error: Should pass on `@types/react` bump.
onDefaultTransitionIndicator: onDefaultTransitionIndicator, onDefaultTransitionIndicator: onDefaultTransitionIndicator,
onRecoverableError, onRecoverableError,
onCaughtError, onCaughtError,
......
...@@ -21,6 +21,5 @@ export const routeModule = new PagesRouteModule({ ...@@ -21,6 +21,5 @@ export const routeModule = new PagesRouteModule({
App, App,
Document, Document,
}, },
// @ts-expect-error -- Types don't account for getInitialProps. `Error` requires to be instantiated with `statusCode` but the types currently don't guarantee that.
userland: moduleError, userland: moduleError,
}) })
declare module 'react-dom/server.edge' { import type { JSX } from 'react'
export { renderToReadableStream } from 'react-dom/server'
}
declare module 'react-dom/server' { declare module 'react-dom/server' {
import type { ErrorInfo, JSX } from 'react'
/**
* https://github.com/facebook/react/blob/aec521a96d3f1bebc2ba38553d14f4989c6e88e0/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js#L329-L333
*/
type BootstrapScriptDescriptor = {
src: string
integrity?: string
crossOrigin?: string
}
/** /**
* Options for `resume`. * Options for `resume`.
* *
...@@ -37,19 +25,7 @@ declare module 'react-dom/server' { ...@@ -37,19 +25,7 @@ declare module 'react-dom/server' {
* *
* https://github.com/facebook/react/blob/aec521a96d3f1bebc2ba38553d14f4989c6e88e0/packages/react-dom/src/server/ReactDOMFizzServerEdge.js#L36-L52 * https://github.com/facebook/react/blob/aec521a96d3f1bebc2ba38553d14f4989c6e88e0/packages/react-dom/src/server/ReactDOMFizzServerEdge.js#L36-L52
*/ */
export type Options = { export interface RenderToReadableStreamOptions {
identifierPrefix?: string
namespaceURI?: string
nonce?: string
bootstrapScriptContent?: string
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>
bootstrapModules?: Array<string | BootstrapScriptDescriptor>
progressiveChunkSize?: number
signal?: AbortSignal
onError?: (
error: unknown,
errorInfo: ErrorInfo
) => string | undefined | void
onPostpone?: (reason: string) => void onPostpone?: (reason: string) => void
unstable_externalRuntimeSrc?: string | BootstrapScriptDescriptor unstable_externalRuntimeSrc?: string | BootstrapScriptDescriptor
importMap?: { importMap?: {
...@@ -66,45 +42,15 @@ declare module 'react-dom/server' { ...@@ -66,45 +42,15 @@ declare module 'react-dom/server' {
onHeaders?: (headers: Headers) => void onHeaders?: (headers: Headers) => void
maxHeadersLength?: number maxHeadersLength?: number
} }
export function renderToReadableStream(
children: JSX.Element,
options?: Options
): Promise<
ReadableStream<Uint8Array> & {
allReady: Promise<void>
}
>
} }
declare module 'react-dom/static' { declare module 'react-dom/static' {
import type { ErrorInfo, JSX } from 'react'
/**
* https://github.com/facebook/react/blob/aec521a96d3f1bebc2ba38553d14f4989c6e88e0/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js#L329-L333
*/
type BootstrapScriptDescriptor = {
src: string
integrity?: string
crossOrigin?: string
}
/** /**
* Options for `prerender`. * Options for `prerender`.
* *
* https://github.com/facebook/react/blob/aec521a96d3f1bebc2ba38553d14f4989c6e88e0/packages/react-dom/src/server/ReactDOMFizzStaticEdge.js#L35-L49 * https://github.com/facebook/react/blob/aec521a96d3f1bebc2ba38553d14f4989c6e88e0/packages/react-dom/src/server/ReactDOMFizzStaticEdge.js#L35-L49
*/ */
export type Options = { export interface PrerenderOptions {
identifierPrefix?: string
namespaceURI?: string
bootstrapScriptContent?: string
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>
bootstrapModules?: Array<string | BootstrapScriptDescriptor>
progressiveChunkSize?: number
signal?: AbortSignal
onError?: (
error: unknown,
errorInfo: ErrorInfo
) => string | undefined | void
onPostpone?: (reason: string) => void onPostpone?: (reason: string) => void
unstable_externalRuntimeSrc?: string | BootstrapScriptDescriptor unstable_externalRuntimeSrc?: string | BootstrapScriptDescriptor
importMap?: { importMap?: {
...@@ -121,11 +67,7 @@ declare module 'react-dom/static' { ...@@ -121,11 +67,7 @@ declare module 'react-dom/static' {
maxHeadersLength?: number maxHeadersLength?: number
} }
export function prerender( interface PrerenderResult {
children: JSX.Element,
options?: Options
): Promise<{
prelude: ReadableStream<Uint8Array>
postponed: object | null postponed: object | null
}> }
} }
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment