Skip to content

Commit

Permalink
[crud] Narrow resource type (#32203)
Browse files Browse the repository at this point in the history
Small refactor to the `resource` type to narrow it to an arbitrary
object or void/null instead of the top type. This makes the overload on
useEffect simpler since the return type of create is no longer widened
to the top type when we merge their definitions.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32203).
* #32206
* #32205
* #32204
* __->__ #32203

DiffTrain build for [899e3d1](899e3d1)
  • Loading branch information
poteto committed Feb 11, 2025
1 parent 19c804d commit 3574dcd
Show file tree
Hide file tree
Showing 34 changed files with 104 additions and 156 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a0fdb6306043b9f049106e58dcec107d8dbed2b1
899e3d1297ec15a5aa8d73e2f1bd478918090a12
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION_TRANSFORMS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a0fdb6306043b9f049106e58dcec107d8dbed2b1
899e3d1297ec15a5aa8d73e2f1bd478918090a12
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.1.0-www-classic-a0fdb630-20250206";
exports.version = "19.1.0-www-classic-899e3d12-20250211";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.1.0-www-modern-a0fdb630-20250206";
exports.version = "19.1.0-www-modern-899e3d12-20250211";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,4 +639,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-classic-a0fdb630-20250206";
exports.version = "19.1.0-www-classic-899e3d12-20250211";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,4 +639,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-modern-a0fdb630-20250206";
exports.version = "19.1.0-www-modern-899e3d12-20250211";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-classic-a0fdb630-20250206";
exports.version = "19.1.0-www-classic-899e3d12-20250211";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-modern-a0fdb630-20250206";
exports.version = "19.1.0-www-modern-899e3d12-20250211";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
12 changes: 4 additions & 8 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -9810,11 +9810,7 @@ __DEV__ &&
lastEffect = finishedWork;
var nearestMountedAncestor =
nearestMountedAncestor$jscomp$0,
resource = updateQueue.inst.resource,
destroy_ =
null == resource
? destroy
: destroy.bind(null, resource);
destroy_ = destroy.bind(null, updateQueue.inst.resource);
runWithFiberInDEV(
lastEffect,
callDestroyInDEV,
Expand Down Expand Up @@ -17417,10 +17413,10 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.1.0-www-classic-a0fdb630-20250206",
version: "19.1.0-www-classic-899e3d12-20250211",
rendererPackageName: "react-art",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-classic-a0fdb630-20250206"
reconcilerVersion: "19.1.0-www-classic-899e3d12-20250211"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -17454,7 +17450,7 @@ __DEV__ &&
exports.Shape = Shape;
exports.Surface = Surface;
exports.Text = Text;
exports.version = "19.1.0-www-classic-a0fdb630-20250206";
exports.version = "19.1.0-www-classic-899e3d12-20250211";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
12 changes: 4 additions & 8 deletions compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -9628,11 +9628,7 @@ __DEV__ &&
lastEffect = finishedWork;
var nearestMountedAncestor =
nearestMountedAncestor$jscomp$0,
resource = updateQueue.inst.resource,
destroy_ =
null == resource
? destroy
: destroy.bind(null, resource);
destroy_ = destroy.bind(null, updateQueue.inst.resource);
runWithFiberInDEV(
lastEffect,
callDestroyInDEV,
Expand Down Expand Up @@ -17189,10 +17185,10 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.1.0-www-modern-a0fdb630-20250206",
version: "19.1.0-www-modern-899e3d12-20250211",
rendererPackageName: "react-art",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-modern-a0fdb630-20250206"
reconcilerVersion: "19.1.0-www-modern-899e3d12-20250211"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -17226,7 +17222,7 @@ __DEV__ &&
exports.Shape = Shape;
exports.Surface = Surface;
exports.Text = Text;
exports.version = "19.1.0-www-modern-a0fdb630-20250206";
exports.version = "19.1.0-www-modern-899e3d12-20250211";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
10 changes: 4 additions & 6 deletions compiled/facebook-www/ReactART-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -7128,9 +7128,7 @@ function commitHookEffectListUnmount(
) {
lastEffect = finishedWork;
var nearestMountedAncestor = nearestMountedAncestor$jscomp$0,
resource = updateQueue.inst.resource,
destroy_ =
null == resource ? destroy : destroy.bind(null, resource);
destroy_ = destroy.bind(null, updateQueue.inst.resource);
try {
destroy_();
} catch (error) {
Expand Down Expand Up @@ -11275,10 +11273,10 @@ var slice = Array.prototype.slice,
})(React.Component);
var internals$jscomp$inline_1567 = {
bundleType: 0,
version: "19.1.0-www-classic-a0fdb630-20250206",
version: "19.1.0-www-classic-899e3d12-20250211",
rendererPackageName: "react-art",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-classic-a0fdb630-20250206"
reconcilerVersion: "19.1.0-www-classic-899e3d12-20250211"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1568 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand All @@ -11304,4 +11302,4 @@ exports.RadialGradient = RadialGradient;
exports.Shape = TYPES.SHAPE;
exports.Surface = Surface;
exports.Text = Text;
exports.version = "19.1.0-www-classic-a0fdb630-20250206";
exports.version = "19.1.0-www-classic-899e3d12-20250211";
10 changes: 4 additions & 6 deletions compiled/facebook-www/ReactART-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -6882,9 +6882,7 @@ function commitHookEffectListUnmount(
) {
lastEffect = finishedWork;
var nearestMountedAncestor = nearestMountedAncestor$jscomp$0,
resource = updateQueue.inst.resource,
destroy_ =
null == resource ? destroy : destroy.bind(null, resource);
destroy_ = destroy.bind(null, updateQueue.inst.resource);
try {
destroy_();
} catch (error) {
Expand Down Expand Up @@ -10990,10 +10988,10 @@ var slice = Array.prototype.slice,
})(React.Component);
var internals$jscomp$inline_1540 = {
bundleType: 0,
version: "19.1.0-www-modern-a0fdb630-20250206",
version: "19.1.0-www-modern-899e3d12-20250211",
rendererPackageName: "react-art",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-modern-a0fdb630-20250206"
reconcilerVersion: "19.1.0-www-modern-899e3d12-20250211"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1541 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand All @@ -11019,4 +11017,4 @@ exports.RadialGradient = RadialGradient;
exports.Shape = TYPES.SHAPE;
exports.Surface = Surface;
exports.Text = Text;
exports.version = "19.1.0-www-modern-a0fdb630-20250206";
exports.version = "19.1.0-www-modern-899e3d12-20250211";
16 changes: 6 additions & 10 deletions compiled/facebook-www/ReactDOM-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -12544,11 +12544,7 @@ __DEV__ &&
lastEffect = finishedWork;
var nearestMountedAncestor =
nearestMountedAncestor$jscomp$0,
resource = updateQueue.inst.resource,
destroy_ =
null == resource
? destroy
: destroy.bind(null, resource);
destroy_ = destroy.bind(null, updateQueue.inst.resource);
runWithFiberInDEV(
lastEffect,
callDestroyInDEV,
Expand Down Expand Up @@ -28653,11 +28649,11 @@ __DEV__ &&
return_targetInst = null;
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.1.0-www-classic-a0fdb630-20250206" !== isomorphicReactPackageVersion)
if ("19.1.0-www-classic-899e3d12-20250211" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-dom: 19.1.0-www-classic-a0fdb630-20250206\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.1.0-www-classic-899e3d12-20250211\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
Expand Down Expand Up @@ -28700,10 +28696,10 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.1.0-www-classic-a0fdb630-20250206",
version: "19.1.0-www-classic-899e3d12-20250211",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-classic-a0fdb630-20250206"
reconcilerVersion: "19.1.0-www-classic-899e3d12-20250211"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -29301,7 +29297,7 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.1.0-www-classic-a0fdb630-20250206";
exports.version = "19.1.0-www-classic-899e3d12-20250211";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
16 changes: 6 additions & 10 deletions compiled/facebook-www/ReactDOM-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -12343,11 +12343,7 @@ __DEV__ &&
lastEffect = finishedWork;
var nearestMountedAncestor =
nearestMountedAncestor$jscomp$0,
resource = updateQueue.inst.resource,
destroy_ =
null == resource
? destroy
: destroy.bind(null, resource);
destroy_ = destroy.bind(null, updateQueue.inst.resource);
runWithFiberInDEV(
lastEffect,
callDestroyInDEV,
Expand Down Expand Up @@ -28439,11 +28435,11 @@ __DEV__ &&
return_targetInst = null;
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.1.0-www-modern-a0fdb630-20250206" !== isomorphicReactPackageVersion)
if ("19.1.0-www-modern-899e3d12-20250211" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-dom: 19.1.0-www-modern-a0fdb630-20250206\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.1.0-www-modern-899e3d12-20250211\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
Expand Down Expand Up @@ -28486,10 +28482,10 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.1.0-www-modern-a0fdb630-20250206",
version: "19.1.0-www-modern-899e3d12-20250211",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-modern-a0fdb630-20250206"
reconcilerVersion: "19.1.0-www-modern-899e3d12-20250211"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -29087,7 +29083,7 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.1.0-www-modern-a0fdb630-20250206";
exports.version = "19.1.0-www-modern-899e3d12-20250211";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
14 changes: 6 additions & 8 deletions compiled/facebook-www/ReactDOM-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -8542,9 +8542,7 @@ function commitHookEffectListUnmount(
) {
lastEffect = finishedWork;
var nearestMountedAncestor = nearestMountedAncestor$jscomp$0,
resource = updateQueue.inst.resource,
destroy_ =
null == resource ? destroy : destroy.bind(null, resource);
destroy_ = destroy.bind(null, updateQueue.inst.resource);
try {
destroy_();
} catch (error) {
Expand Down Expand Up @@ -18442,14 +18440,14 @@ function getCrossOriginStringAs(as, input) {
}
var isomorphicReactPackageVersion$jscomp$inline_1871 = React.version;
if (
"19.1.0-www-classic-a0fdb630-20250206" !==
"19.1.0-www-classic-899e3d12-20250211" !==
isomorphicReactPackageVersion$jscomp$inline_1871
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1871,
"19.1.0-www-classic-a0fdb630-20250206"
"19.1.0-www-classic-899e3d12-20250211"
)
);
Internals.findDOMNode = function (componentOrElement) {
Expand All @@ -18467,10 +18465,10 @@ Internals.Events = [
];
var internals$jscomp$inline_2431 = {
bundleType: 0,
version: "19.1.0-www-classic-a0fdb630-20250206",
version: "19.1.0-www-classic-899e3d12-20250211",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-classic-a0fdb630-20250206"
reconcilerVersion: "19.1.0-www-classic-899e3d12-20250211"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2432 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -18834,4 +18832,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.1.0-www-classic-a0fdb630-20250206";
exports.version = "19.1.0-www-classic-899e3d12-20250211";
14 changes: 6 additions & 8 deletions compiled/facebook-www/ReactDOM-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -8288,9 +8288,7 @@ function commitHookEffectListUnmount(
) {
lastEffect = finishedWork;
var nearestMountedAncestor = nearestMountedAncestor$jscomp$0,
resource = updateQueue.inst.resource,
destroy_ =
null == resource ? destroy : destroy.bind(null, resource);
destroy_ = destroy.bind(null, updateQueue.inst.resource);
try {
destroy_();
} catch (error) {
Expand Down Expand Up @@ -18173,14 +18171,14 @@ function getCrossOriginStringAs(as, input) {
}
var isomorphicReactPackageVersion$jscomp$inline_1861 = React.version;
if (
"19.1.0-www-modern-a0fdb630-20250206" !==
"19.1.0-www-modern-899e3d12-20250211" !==
isomorphicReactPackageVersion$jscomp$inline_1861
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1861,
"19.1.0-www-modern-a0fdb630-20250206"
"19.1.0-www-modern-899e3d12-20250211"
)
);
Internals.findDOMNode = function (componentOrElement) {
Expand All @@ -18198,10 +18196,10 @@ Internals.Events = [
];
var internals$jscomp$inline_2413 = {
bundleType: 0,
version: "19.1.0-www-modern-a0fdb630-20250206",
version: "19.1.0-www-modern-899e3d12-20250211",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-modern-a0fdb630-20250206"
reconcilerVersion: "19.1.0-www-modern-899e3d12-20250211"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2414 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -18565,4 +18563,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.1.0-www-modern-a0fdb630-20250206";
exports.version = "19.1.0-www-modern-899e3d12-20250211";
Loading

0 comments on commit 3574dcd

Please sign in to comment.