Skip to content

Commit f7173f1

Browse files
committed
Transform updates to support Flow this annotation syntax (#25918)
Flow introduced a new syntax to annotated the context type of a function, this tries to update the rest and add 1 example usage. - 2b1fb91 already added the changes required for eslint. - Jest transform is updated to use the recommended `hermes-parser` which can parse current and Flow syntax and will be updated in the future. - Rollup uses a new plugin to strip the flow types. This isn't ideal as the npm module is deprecated in favor of using `hermes-parser`, but I couldn't figure out how to integrate that with Rollup. DiffTrain build for [b83baf6](b83baf6) [View git log for this commit](https://github.com/facebook/react/commits/b83baf63f71669ca7bf222afec305b7a6fd782b7)
1 parent 3d02074 commit f7173f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+658
-579
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2619886ac0f1d41c9b361d82f069f9ed682321ff
1+
b83baf63f71669ca7bf222afec305b7a6fd782b7
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2619886ac0f1d41c9b361d82f069f9ed682321ff
1+
b83baf63f71669ca7bf222afec305b7a6fd782b7

compiled/facebook-www/React-dev.classic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (
2727
}
2828
"use strict";
2929

30-
var ReactVersion = "18.3.0-www-classic-2619886ac-20230105";
30+
var ReactVersion = "18.3.0-www-classic-b83baf63f-20230105";
3131

3232
// ATTENTION
3333
// When adding new symbols to this file,
@@ -1252,7 +1252,6 @@ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
12521252

12531253
return subtreeCount;
12541254
}
1255-
12561255
/**
12571256
* Maps children that are typically specified as `props.children`.
12581257
*
@@ -1266,6 +1265,7 @@ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
12661265
* @param {*} context Context for mapFunction.
12671266
* @return {object} Object containing the ordered map of results.
12681267
*/
1268+
12691269
function mapChildren(children, func, context) {
12701270
if (children == null) {
12711271
return children;
@@ -1295,7 +1295,6 @@ function countChildren(children) {
12951295
});
12961296
return n;
12971297
}
1298-
12991298
/**
13001299
* Iterates through children that are typically specified as `props.children`.
13011300
*
@@ -1308,6 +1307,7 @@ function countChildren(children) {
13081307
* @param {function(*, int)} forEachFunc
13091308
* @param {*} forEachContext Context for forEachContext.
13101309
*/
1310+
13111311
function forEachChildren(children, forEachFunc, forEachContext) {
13121312
mapChildren(
13131313
children,

compiled/facebook-www/React-dev.modern.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (
2727
}
2828
"use strict";
2929

30-
var ReactVersion = "18.3.0-www-modern-2619886ac-20230105";
30+
var ReactVersion = "18.3.0-www-modern-b83baf63f-20230105";
3131

3232
// ATTENTION
3333
// When adding new symbols to this file,
@@ -1252,7 +1252,6 @@ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
12521252

12531253
return subtreeCount;
12541254
}
1255-
12561255
/**
12571256
* Maps children that are typically specified as `props.children`.
12581257
*
@@ -1266,6 +1265,7 @@ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
12661265
* @param {*} context Context for mapFunction.
12671266
* @return {object} Object containing the ordered map of results.
12681267
*/
1268+
12691269
function mapChildren(children, func, context) {
12701270
if (children == null) {
12711271
return children;
@@ -1295,7 +1295,6 @@ function countChildren(children) {
12951295
});
12961296
return n;
12971297
}
1298-
12991298
/**
13001299
* Iterates through children that are typically specified as `props.children`.
13011300
*
@@ -1308,6 +1307,7 @@ function countChildren(children) {
13081307
* @param {function(*, int)} forEachFunc
13091308
* @param {*} forEachContext Context for forEachContext.
13101309
*/
1310+
13111311
function forEachChildren(children, forEachFunc, forEachContext) {
13121312
mapChildren(
13131313
children,

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,4 +643,4 @@ exports.useSyncExternalStore = function(
643643
);
644644
};
645645
exports.useTransition = useTransition;
646-
exports.version = "18.3.0-www-classic-2619886ac-20230105";
646+
exports.version = "18.3.0-www-classic-b83baf63f-20230105";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,4 +635,4 @@ exports.useSyncExternalStore = function(
635635
);
636636
};
637637
exports.useTransition = useTransition;
638-
exports.version = "18.3.0-www-modern-2619886ac-20230105";
638+
exports.version = "18.3.0-www-modern-b83baf63f-20230105";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ exports.useSyncExternalStore = function(
654654
);
655655
};
656656
exports.useTransition = useTransition;
657-
exports.version = "18.3.0-www-classic-2619886ac-20230105";
657+
exports.version = "18.3.0-www-classic-b83baf63f-20230105";
658658

659659
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
660660
if (

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ exports.useSyncExternalStore = function(
646646
);
647647
};
648648
exports.useTransition = useTransition;
649-
exports.version = "18.3.0-www-modern-2619886ac-20230105";
649+
exports.version = "18.3.0-www-modern-b83baf63f-20230105";
650650

651651
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
652652
if (

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
6969
return self;
7070
}
7171

72-
var ReactVersion = "18.3.0-www-classic-2619886ac-20230105";
72+
var ReactVersion = "18.3.0-www-classic-b83baf63f-20230105";
7373

7474
var LegacyRoot = 0;
7575
var ConcurrentRoot = 1;
@@ -505,7 +505,6 @@ function getComponentNameFromFiber(fiber) {
505505
return null;
506506
}
507507

508-
// Don't change these values. They're used by React Dev Tools.
509508
var NoFlags =
510509
/* */
511510
0;
@@ -968,9 +967,9 @@ var now = Scheduler.unstable_now;
968967
var ImmediatePriority = Scheduler.unstable_ImmediatePriority;
969968
var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority;
970969
var NormalPriority = Scheduler.unstable_NormalPriority;
971-
var IdlePriority = Scheduler.unstable_IdlePriority;
972-
// this doesn't actually exist on the scheduler, but it *does*
970+
var IdlePriority = Scheduler.unstable_IdlePriority; // this doesn't actually exist on the scheduler, but it *does*
973971
// on scheduler/unstable_mock, which we'll need for internal testing
972+
974973
var unstable_yieldValue = Scheduler.unstable_yieldValue;
975974
var unstable_setDisableYieldValue = Scheduler.unstable_setDisableYieldValue;
976975

@@ -3930,10 +3929,10 @@ function isRootDehydrated(root) {
39303929
return currentState.isDehydrated;
39313930
}
39323931

3933-
// TODO: Use the unified fiber stack module instead of this local one?
39343932
// Intentionally not using it yet to derisk the initial implementation, because
39353933
// the way we push/pop these values is a bit unusual. If there's a mistake, I'd
39363934
// rather the ids be wrong than crash the whole reconciler.
3935+
39373936
var forkStack = [];
39383937
var forkStackIndex = 0;
39393938
var treeForkProvider = null;
@@ -4121,10 +4120,10 @@ function queueHydrationError(error) {
41214120
}
41224121
}
41234122

4124-
// If a render is in progress, and we receive an update from a concurrent event,
41254123
// we wait until the current render is over (either finished or interrupted)
41264124
// before adding it to the fiber/hook queue. Push to this array so we can
41274125
// access the queue, fiber, update, et al later.
4126+
41284127
var concurrentQueues = [];
41294128
var concurrentQueuesIndex = 0;
41304129
var concurrentlyUpdatedLanes = NoLanes;
@@ -5700,12 +5699,11 @@ function resolveLazy(lazyType) {
57005699
var payload = lazyType._payload;
57015700
var init = lazyType._init;
57025701
return init(payload);
5703-
}
5704-
5705-
// This wrapper function exists because I expect to clone the code in each path
5702+
} // This wrapper function exists because I expect to clone the code in each path
57065703
// to be able to optimize each path individually by branching early. This needs
57075704
// a compiler or we can do it manually. Helpers that don't need this branching
57085705
// live outside of this function.
5706+
57095707
function createChildReconciler(shouldTrackSideEffects) {
57105708
function deleteChild(returnFiber, childToDelete) {
57115709
if (!shouldTrackSideEffects) {
@@ -6829,6 +6827,7 @@ function resetChildFibers(workInProgress, lanes) {
68296827

68306828
// TODO: This isn't being used yet, but it's intended to replace the
68316829
// InvisibleParentContext that is currently managed by SuspenseContext.
6830+
68326831
var currentTreeHiddenStackCursor = createCursor(null);
68336832
var prevRenderLanesStackCursor = createCursor(NoLanes);
68346833
function pushHiddenContext(fiber, context) {
@@ -6996,6 +6995,13 @@ function popSuspenseListContext(fiber) {
69966995
pop(suspenseStackCursor, fiber);
69976996
}
69986997

6998+
// A non-null SuspenseState means that it is blocked for one reason or another.
6999+
// - A non-null dehydrated field means it's blocked pending hydration.
7000+
// - A non-null dehydrated field can use isSuspenseInstancePending or
7001+
// isSuspenseInstanceFallback to query the reason for being dehydrated.
7002+
// - A null dehydrated field means it's blocked by something suspending and
7003+
// we're currently showing a fallback instead.
7004+
69997005
function findFirstSuspended(row) {
70007006
var node = row;
70017007

@@ -7119,9 +7125,9 @@ function warnAboutMultipleRenderersDEV(mutableSource) {
71197125
}
71207126
} // Eager reads the version of a mutable source and stores it on the root.
71217127

7122-
var ReactCurrentActQueue = ReactSharedInternals.ReactCurrentActQueue;
7123-
// An error that is thrown (e.g. by `use`) to trigger Suspense. If we
7128+
var ReactCurrentActQueue = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we
71247129
// detect this is caught by userspace, we'll log a warning in development.
7130+
71257131
var SuspenseException = new Error(
71267132
"Suspense Exception: This is not a real error! It's an implementation " +
71277133
"detail of `use` to interrupt the current render. You must either " +
@@ -7279,9 +7285,8 @@ var didWarnAboutUseWrappedInTryCatch;
72797285
{
72807286
didWarnAboutMismatchedHooksForComponent = new Set();
72817287
didWarnAboutUseWrappedInTryCatch = new Set();
7282-
}
7288+
} // These are set right before calling the component.
72837289

7284-
// These are set right before calling the component.
72857290
var renderLanes = NoLanes; // The work-in-progress fiber. I've named it differently to distinguish it from
72867291
// the work-in-progress hook.
72877292

@@ -9011,10 +9016,8 @@ function updateLayoutEffect(create, deps) {
90119016
function imperativeHandleEffect(create, ref) {
90129017
if (typeof ref === "function") {
90139018
var refCallback = ref;
9014-
9015-
var _inst = create();
9016-
9017-
refCallback(_inst);
9019+
var inst = create();
9020+
refCallback(inst);
90189021
return function() {
90199022
refCallback(null);
90209023
};
@@ -9031,9 +9034,9 @@ function imperativeHandleEffect(create, ref) {
90319034
}
90329035
}
90339036

9034-
var _inst2 = create();
9037+
var _inst = create();
90359038

9036-
refObject.current = _inst2;
9039+
refObject.current = _inst;
90379040
return function() {
90389041
refObject.current = null;
90399042
};
@@ -11312,9 +11315,9 @@ function checkClassInstance(workInProgress, ctor, newProps) {
1131211315
);
1131311316
}
1131411317

11315-
var _state = instance.state;
11318+
var state = instance.state;
1131611319

11317-
if (_state && (typeof _state !== "object" || isArray(_state))) {
11320+
if (state && (typeof state !== "object" || isArray(state))) {
1131811321
error("%s.state: must be set to an object or null", name);
1131911322
}
1132011323

@@ -16968,9 +16971,9 @@ var AbortControllerLocal =
1696816971
return listener();
1696916972
});
1697016973
};
16971-
};
16972-
// Intentionally not named imports because Rollup would
16974+
}; // Intentionally not named imports because Rollup would
1697316975
// use dynamic dispatch for CommonJS interop named imports.
16976+
1697416977
var scheduleCallback$1 = Scheduler.unstable_scheduleCallback,
1697516978
NormalPriority$1 = Scheduler.unstable_NormalPriority;
1697616979
var CacheContext = {
@@ -24118,8 +24121,9 @@ function getExecutionContext() {
2411824121
}
2411924122
// Warning, this opts-out of checking the function body.
2412024123
// eslint-disable-next-line no-unused-vars
24121-
2412224124
// eslint-disable-next-line no-redeclare
24125+
// eslint-disable-next-line no-redeclare
24126+
2412324127
function flushSync(fn) {
2412424128
// In legacy mode, we flush pending passive effects at the beginning of the
2412524129
// next event, not at the end of the previous one.
@@ -25534,8 +25538,8 @@ function flushPassiveEffectsImpl() {
2553425538
pendingPassiveProfilerEffects = [];
2553525539

2553625540
for (var i = 0; i < profilerEffects.length; i++) {
25537-
var _fiber = profilerEffects[i];
25538-
commitPassiveEffectDurations(root, _fiber);
25541+
var fiber = profilerEffects[i];
25542+
commitPassiveEffectDurations(root, fiber);
2553925543
}
2554025544
}
2554125545

@@ -26314,6 +26318,8 @@ function setIsRunningInsertionEffect(isRunning) {
2631426318
}
2631526319

2631626320
/* eslint-disable react-internal/prod-error-codes */
26321+
// Used by React Refresh runtime through DevTools Global Hook.
26322+
2631726323
var resolveFamily = null;
2631826324
var failedBoundaries = null;
2631926325
var setRefreshHandler = function(handler) {
@@ -26579,10 +26585,10 @@ function scheduleFibersWithFamiliesRecursively(
2657926585
}
2658026586

2658126587
if (needsRemount || needsRender) {
26582-
var _root = enqueueConcurrentRenderForLane(fiber, SyncLane);
26588+
var root = enqueueConcurrentRenderForLane(fiber, SyncLane);
2658326589

26584-
if (_root !== null) {
26585-
scheduleUpdateOnFiber(_root, fiber, SyncLane, NoTimestamp);
26590+
if (root !== null) {
26591+
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
2658626592
}
2658726593
}
2658826594

@@ -27601,6 +27607,8 @@ function createFiberRoot(
2760127607
return root;
2760227608
}
2760327609

27610+
// Might add PROFILE later.
27611+
2760427612
var didWarnAboutNestedUpdates;
2760527613

2760627614
{

0 commit comments

Comments
 (0)