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 @@
"@types/jest": "29.5.5",
"@types/node": "20.17.6",
"@types/node-fetch": "2.6.1",
"@types/react": "19.1.1",
"@types/react-dom": "19.1.2",
"@types/react": "19.1.8",
"@types/react-dom": "19.1.6",
"@types/relay-runtime": "14.1.13",
"@types/string-hash": "1.1.1",
"@types/trusted-types": "2.0.3",
......@@ -293,8 +293,8 @@
"@babel/parser": "7.27.0",
"@babel/types": "7.27.0",
"@babel/traverse": "7.27.0",
"@types/react": "^19.1.1",
"@types/react-dom": "19.1.2",
"@types/react": "19.1.8",
"@types/react-dom": "19.1.6",
"@types/retry": "0.12.0",
"jest-snapshot": "30.0.0-alpha.6",
"react": "19.2.0-canary-97cdd5d3-20250710",
......
......@@ -213,7 +213,6 @@ function onDefaultTransitionIndicator() {
}
const reactRootOptions: ReactDOMClient.RootOptions = {
// @ts-expect-error: Should pass on `@types/react` bump.
onDefaultTransitionIndicator: onDefaultTransitionIndicator,
onRecoverableError,
onCaughtError,
......
......@@ -21,6 +21,5 @@ export const routeModule = new PagesRouteModule({
App,
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,
})
declare module 'react-dom/server.edge' {
export { renderToReadableStream } from 'react-dom/server'
}
import type { JSX } from 'react'
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`.
*
......@@ -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
*/
export type Options = {
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
export interface RenderToReadableStreamOptions {
onPostpone?: (reason: string) => void
unstable_externalRuntimeSrc?: string | BootstrapScriptDescriptor
importMap?: {
......@@ -66,45 +42,15 @@ declare module 'react-dom/server' {
onHeaders?: (headers: Headers) => void
maxHeadersLength?: number
}
export function renderToReadableStream(
children: JSX.Element,
options?: Options
): Promise<
ReadableStream<Uint8Array> & {
allReady: Promise<void>
}
>
}
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`.
*
* https://github.com/facebook/react/blob/aec521a96d3f1bebc2ba38553d14f4989c6e88e0/packages/react-dom/src/server/ReactDOMFizzStaticEdge.js#L35-L49
*/
export type Options = {
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
export interface PrerenderOptions {
onPostpone?: (reason: string) => void
unstable_externalRuntimeSrc?: string | BootstrapScriptDescriptor
importMap?: {
......@@ -121,11 +67,7 @@ declare module 'react-dom/static' {
maxHeadersLength?: number
}
export function prerender(
children: JSX.Element,
options?: Options
): Promise<{
prelude: ReadableStream<Uint8Array>
interface PrerenderResult {
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