Skip to content

Commit 071e078

Browse files
committed
Need to beat into Flow that bigint is a thing
1 parent aaa4d38 commit 071e078

File tree

8 files changed

+35
-5
lines changed

8 files changed

+35
-5
lines changed

packages/react-dom/src/client/ReactDOMComponent.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,11 @@ function setInitialDOMProperties(
317317
if (canSetTextContent) {
318318
setTextContent(domElement, nextProp);
319319
}
320-
} else if (typeof nextProp === 'number' || typeof nextProp === 'bigint') {
320+
} else if (
321+
typeof nextProp === 'number' ||
322+
// $FlowFixMe - flow is not aware of `bigint`
323+
typeof nextProp === 'bigint'
324+
) {
321325
setTextContent(domElement, '' + nextProp);
322326
}
323327
} else if (

packages/react-dom/src/client/ReactDOMHostConfig.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,13 @@ export function createInstance(
255255
if (
256256
typeof props.children === 'string' ||
257257
typeof props.children === 'number' ||
258+
// $FlowFixMe - flow is not aware of `bigint`
258259
typeof props.children === 'bigint'
259260
) {
260-
const string = '' + props.children;
261+
// Flow thinks `children` is still mixed so we need to type-cast
262+
// But now the ESLint plugin thinks `children` is mixed as well.
263+
// eslint-disable-next-line react-internal/safe-string-coercion
264+
const string = '' + ((props.children: any): number | string);
261265
const ownAncestorInfo = updatedAncestorInfo(
262266
hostContextDev.ancestorInfo,
263267
type,

packages/react-dom/src/server/ReactPartialRenderer.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ function getNonChildrenInnerMarkup(props) {
297297
if (
298298
typeof content === 'string' ||
299299
typeof content === 'number' ||
300+
// $FlowFixMe - flow is not aware of `bigint`
300301
typeof content === 'bigint'
301302
) {
302303
return escapeTextForBrowser(content);
@@ -1008,9 +1009,13 @@ class ReactDOMServerRenderer {
10081009
if (
10091010
typeof child === 'string' ||
10101011
typeof child === 'number' ||
1012+
// $FlowFixMe - flow is not aware of `bigint`
10111013
typeof child === 'bigint'
10121014
) {
1013-
const text = '' + child;
1015+
// Flow thinks `child` is still mixed so we need to type-cast
1016+
// But now the ESLint plugin thinks `children` is mixed as well.
1017+
// eslint-disable-next-line react-internal/safe-string-coercion
1018+
const text = '' + ((child: any): number | string);
10141019
if (text === '') {
10151020
return '';
10161021
}

packages/react-reconciler/src/ReactChildFiber.new.js

+4
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ function ChildReconciler(shouldTrackSideEffects) {
491491
if (
492492
(typeof newChild === 'string' && newChild !== '') ||
493493
typeof newChild === 'number' ||
494+
// $FlowFixMe - flow is not aware of `bigint`
494495
typeof newChild === 'bigint'
495496
) {
496497
// Text nodes don't have keys. If the previous node is implicitly keyed
@@ -569,6 +570,7 @@ function ChildReconciler(shouldTrackSideEffects) {
569570
if (
570571
(typeof newChild === 'string' && newChild !== '') ||
571572
typeof newChild === 'number' ||
573+
// $FlowFixMe - flow is not aware of `bigint`
572574
typeof newChild === 'bigint'
573575
) {
574576
// Text nodes don't have keys. If the previous node is implicitly keyed
@@ -633,6 +635,7 @@ function ChildReconciler(shouldTrackSideEffects) {
633635
if (
634636
(typeof newChild === 'string' && newChild !== '') ||
635637
typeof newChild === 'number' ||
638+
// $FlowFixMe - flow is not aware of `bigint`
636639
typeof newChild === 'bigint'
637640
) {
638641
// Text nodes don't have keys, so we neither have to check the old nor
@@ -1325,6 +1328,7 @@ function ChildReconciler(shouldTrackSideEffects) {
13251328
if (
13261329
(typeof newChild === 'string' && newChild !== '') ||
13271330
typeof newChild === 'number' ||
1331+
// $FlowFixMe - flow is not aware of `bigint`
13281332
typeof newChild === 'bigint'
13291333
) {
13301334
return placeSingleChild(

packages/react-reconciler/src/ReactChildFiber.old.js

+4
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ function ChildReconciler(shouldTrackSideEffects) {
491491
if (
492492
(typeof newChild === 'string' && newChild !== '') ||
493493
typeof newChild === 'number' ||
494+
// $FlowFixMe - flow is not aware of `bigint`
494495
typeof newChild === 'bigint'
495496
) {
496497
// Text nodes don't have keys. If the previous node is implicitly keyed
@@ -569,6 +570,7 @@ function ChildReconciler(shouldTrackSideEffects) {
569570
if (
570571
(typeof newChild === 'string' && newChild !== '') ||
571572
typeof newChild === 'number' ||
573+
// $FlowFixMe - flow is not aware of `bigint`
572574
typeof newChild === 'bigint'
573575
) {
574576
// Text nodes don't have keys. If the previous node is implicitly keyed
@@ -633,6 +635,7 @@ function ChildReconciler(shouldTrackSideEffects) {
633635
if (
634636
(typeof newChild === 'string' && newChild !== '') ||
635637
typeof newChild === 'number' ||
638+
// $FlowFixMe - flow is not aware of `bigint`
636639
typeof newChild === 'bigint'
637640
) {
638641
// Text nodes don't have keys, so we neither have to check the old nor
@@ -1325,6 +1328,7 @@ function ChildReconciler(shouldTrackSideEffects) {
13251328
if (
13261329
(typeof newChild === 'string' && newChild !== '') ||
13271330
typeof newChild === 'number' ||
1331+
// $FlowFixMe - flow is not aware of `bigint`
13281332
typeof newChild === 'bigint'
13291333
) {
13301334
return placeSingleChild(

packages/react-server/src/ReactFizzServer.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1352,11 +1352,18 @@ function renderNodeDestructiveImpl(
13521352
return;
13531353
}
13541354

1355-
if (typeof node === 'number' || typeof node === 'bigint') {
1355+
if (
1356+
typeof node === 'number' ||
1357+
// $FlowFixMe - flow is not aware of `bigint`
1358+
typeof node === 'bigint'
1359+
) {
13561360
const segment = task.blockedSegment;
13571361
segment.lastPushedText = pushTextInstance(
13581362
task.blockedSegment.chunks,
1359-
'' + node,
1363+
// Flow thinks `children` is still mixed so we need to type-cast
1364+
// But now the ESLint plugin thinks `children` is mixed as well.
1365+
// eslint-disable-next-line react-internal/safe-string-coercion
1366+
'' + ((node: any): number),
13601367
request.responseState,
13611368
segment.lastPushedText,
13621369
);

packages/react-server/src/ReactFlightServer.js

+1
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ export function resolveModelToJSON(
667667
if (
668668
typeof value === 'boolean' ||
669669
typeof value === 'number' ||
670+
// $FlowFixMe - flow is not aware of `bigint`
670671
typeof value === 'bigint' ||
671672
typeof value === 'undefined'
672673
) {

packages/shared/ReactTypes.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type ReactFragment = ReactEmpty | Iterable<React$Node>;
2121

2222
export type ReactNodeList = ReactEmpty | React$Node;
2323

24+
// TODO: Add ` | bigint` once its supported by the used version of Flow.
2425
export type ReactText = string | number;
2526

2627
export type ReactProvider<T> = {

0 commit comments

Comments
 (0)