diff --git a/packages/react-dom/src/client/ReactDOMComponent.js b/packages/react-dom/src/client/ReactDOMComponent.js index da2cba4b392ff..cb33fe70912c7 100644 --- a/packages/react-dom/src/client/ReactDOMComponent.js +++ b/packages/react-dom/src/client/ReactDOMComponent.js @@ -317,7 +317,11 @@ function setInitialDOMProperties( if (canSetTextContent) { setTextContent(domElement, nextProp); } - } else if (typeof nextProp === 'number' || typeof nextProp === 'bigint') { + } else if ( + typeof nextProp === 'number' || + // $FlowFixMe - flow is not aware of `bigint` + typeof nextProp === 'bigint' + ) { setTextContent(domElement, '' + nextProp); } } else if ( diff --git a/packages/react-dom/src/client/ReactDOMHostConfig.js b/packages/react-dom/src/client/ReactDOMHostConfig.js index f5912e55fbb50..86ba5c0d68796 100644 --- a/packages/react-dom/src/client/ReactDOMHostConfig.js +++ b/packages/react-dom/src/client/ReactDOMHostConfig.js @@ -255,9 +255,13 @@ export function createInstance( if ( typeof props.children === 'string' || typeof props.children === 'number' || + // $FlowFixMe - flow is not aware of `bigint` typeof props.children === 'bigint' ) { - const string = '' + props.children; + // Flow thinks `children` is still mixed so we need to type-cast + // But now the ESLint plugin thinks `children` is mixed as well. + // eslint-disable-next-line react-internal/safe-string-coercion + const string = '' + ((props.children: any): number | string); const ownAncestorInfo = updatedAncestorInfo( hostContextDev.ancestorInfo, type, diff --git a/packages/react-dom/src/server/ReactPartialRenderer.js b/packages/react-dom/src/server/ReactPartialRenderer.js index 60b32fe79533a..86356c06372b3 100644 --- a/packages/react-dom/src/server/ReactPartialRenderer.js +++ b/packages/react-dom/src/server/ReactPartialRenderer.js @@ -297,6 +297,7 @@ function getNonChildrenInnerMarkup(props) { if ( typeof content === 'string' || typeof content === 'number' || + // $FlowFixMe - flow is not aware of `bigint` typeof content === 'bigint' ) { return escapeTextForBrowser(content); @@ -1008,9 +1009,13 @@ class ReactDOMServerRenderer { if ( typeof child === 'string' || typeof child === 'number' || + // $FlowFixMe - flow is not aware of `bigint` typeof child === 'bigint' ) { - const text = '' + child; + // Flow thinks `child` is still mixed so we need to type-cast + // But now the ESLint plugin thinks `children` is mixed as well. + // eslint-disable-next-line react-internal/safe-string-coercion + const text = '' + ((child: any): number | string); if (text === '') { return ''; } diff --git a/packages/react-reconciler/src/ReactChildFiber.new.js b/packages/react-reconciler/src/ReactChildFiber.new.js index 410c7c4daa711..9d3f8064cd670 100644 --- a/packages/react-reconciler/src/ReactChildFiber.new.js +++ b/packages/react-reconciler/src/ReactChildFiber.new.js @@ -491,6 +491,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ( (typeof newChild === 'string' && newChild !== '') || typeof newChild === 'number' || + // $FlowFixMe - flow is not aware of `bigint` typeof newChild === 'bigint' ) { // Text nodes don't have keys. If the previous node is implicitly keyed @@ -569,6 +570,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ( (typeof newChild === 'string' && newChild !== '') || typeof newChild === 'number' || + // $FlowFixMe - flow is not aware of `bigint` typeof newChild === 'bigint' ) { // Text nodes don't have keys. If the previous node is implicitly keyed @@ -633,6 +635,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ( (typeof newChild === 'string' && newChild !== '') || typeof newChild === 'number' || + // $FlowFixMe - flow is not aware of `bigint` typeof newChild === 'bigint' ) { // Text nodes don't have keys, so we neither have to check the old nor @@ -1325,6 +1328,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ( (typeof newChild === 'string' && newChild !== '') || typeof newChild === 'number' || + // $FlowFixMe - flow is not aware of `bigint` typeof newChild === 'bigint' ) { return placeSingleChild( diff --git a/packages/react-reconciler/src/ReactChildFiber.old.js b/packages/react-reconciler/src/ReactChildFiber.old.js index f670d2df99a2e..687c8bdc76165 100644 --- a/packages/react-reconciler/src/ReactChildFiber.old.js +++ b/packages/react-reconciler/src/ReactChildFiber.old.js @@ -491,6 +491,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ( (typeof newChild === 'string' && newChild !== '') || typeof newChild === 'number' || + // $FlowFixMe - flow is not aware of `bigint` typeof newChild === 'bigint' ) { // Text nodes don't have keys. If the previous node is implicitly keyed @@ -569,6 +570,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ( (typeof newChild === 'string' && newChild !== '') || typeof newChild === 'number' || + // $FlowFixMe - flow is not aware of `bigint` typeof newChild === 'bigint' ) { // Text nodes don't have keys. If the previous node is implicitly keyed @@ -633,6 +635,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ( (typeof newChild === 'string' && newChild !== '') || typeof newChild === 'number' || + // $FlowFixMe - flow is not aware of `bigint` typeof newChild === 'bigint' ) { // Text nodes don't have keys, so we neither have to check the old nor @@ -1325,6 +1328,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ( (typeof newChild === 'string' && newChild !== '') || typeof newChild === 'number' || + // $FlowFixMe - flow is not aware of `bigint` typeof newChild === 'bigint' ) { return placeSingleChild( diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js index 8ba3f014cfb30..cc3bda40bb777 100644 --- a/packages/react-server/src/ReactFizzServer.js +++ b/packages/react-server/src/ReactFizzServer.js @@ -1220,10 +1220,17 @@ function renderNodeDestructive( return; } - if (typeof node === 'number' || typeof node === 'bigint') { + if ( + typeof node === 'number' || + // $FlowFixMe - flow is not aware of `bigint` + typeof node === 'bigint' + ) { pushTextInstance( task.blockedSegment.chunks, - '' + node, + // Flow thinks `children` is still mixed so we need to type-cast + // But now the ESLint plugin thinks `children` is mixed as well. + // eslint-disable-next-line react-internal/safe-string-coercion + '' + ((node: any): number), request.responseState, ); return; diff --git a/packages/react-server/src/ReactFlightServer.js b/packages/react-server/src/ReactFlightServer.js index 87c21dc2a32bf..f8eb5b036dc7f 100644 --- a/packages/react-server/src/ReactFlightServer.js +++ b/packages/react-server/src/ReactFlightServer.js @@ -642,6 +642,7 @@ export function resolveModelToJSON( if ( typeof value === 'boolean' || typeof value === 'number' || + // $FlowFixMe - flow is not aware of `bigint` typeof value === 'bigint' || typeof value === 'undefined' ) { diff --git a/packages/shared/ReactTypes.js b/packages/shared/ReactTypes.js index 17aa509e89eb9..52c896893d852 100644 --- a/packages/shared/ReactTypes.js +++ b/packages/shared/ReactTypes.js @@ -21,6 +21,7 @@ export type ReactFragment = ReactEmpty | Iterable; export type ReactNodeList = ReactEmpty | React$Node; +// TODO: Add ` | bigint` once its supported by the used version of Flow. export type ReactText = string | number; export type ReactProvider = {