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 ea2c5b2 commit 8d80d81
Show file tree
Hide file tree
Showing 23 changed files with 101 additions and 139 deletions.
2 changes: 1 addition & 1 deletion compiled-rn/VERSION_NATIVE_FB
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19.1.0-native-fb-cd90a4d8-20250210
19.1.0-native-fb-899e3d12-20250211
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<b85aed506feb2e3b86e92b70d0bdd422>>
* @generated SignedSource<<4d5eab0aae301fbdfd3163e7f76beedf>>
*/

"use strict";
Expand Down Expand Up @@ -428,5 +428,5 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.1.0-native-fb-cd90a4d8-20250210";
exports.version = "19.1.0-native-fb-899e3d12-20250211";
})();
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<a77ee5d5bcac5405162f03772b4c0164>>
* @generated SignedSource<<7b223b23d0fa8467a58be2169fe7740d>>
*/

"use strict";
Expand Down Expand Up @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.1.0-native-fb-cd90a4d8-20250210";
exports.version = "19.1.0-native-fb-899e3d12-20250211";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<a77ee5d5bcac5405162f03772b4c0164>>
* @generated SignedSource<<7b223b23d0fa8467a58be2169fe7740d>>
*/

"use strict";
Expand Down Expand Up @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.1.0-native-fb-cd90a4d8-20250210";
exports.version = "19.1.0-native-fb-899e3d12-20250211";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<5ea84f48b670a960c55ddb28fdb2f05a>>
* @generated SignedSource<<c1f359240fa459f07017c0b9d6825895>>
*/

/*
Expand Down Expand Up @@ -11228,11 +11228,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 @@ -26039,11 +26035,11 @@ __DEV__ &&
};
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.1.0-native-fb-cd90a4d8-20250210" !== isomorphicReactPackageVersion)
if ("19.1.0-native-fb-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-native-fb-cd90a4d8-20250210\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.1.0-native-fb-899e3d12-20250211\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
Expand Down Expand Up @@ -26080,10 +26076,10 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.1.0-native-fb-cd90a4d8-20250210",
version: "19.1.0-native-fb-899e3d12-20250211",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-native-fb-cd90a4d8-20250210"
reconcilerVersion: "19.1.0-native-fb-899e3d12-20250211"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -26227,5 +26223,5 @@ __DEV__ &&
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.1.0-native-fb-cd90a4d8-20250210";
exports.version = "19.1.0-native-fb-899e3d12-20250211";
})();
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<1564f6f4d214e47e4d331939c4f48758>>
* @generated SignedSource<<b779385d565ae6160e3bdd822322c603>>
*/

/*
Expand Down Expand Up @@ -7821,9 +7821,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 @@ -16018,14 +16016,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1802 = React.version;
if (
"19.1.0-native-fb-cd90a4d8-20250210" !==
"19.1.0-native-fb-899e3d12-20250211" !==
isomorphicReactPackageVersion$jscomp$inline_1802
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1802,
"19.1.0-native-fb-cd90a4d8-20250210"
"19.1.0-native-fb-899e3d12-20250211"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -16047,10 +16045,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2262 = {
bundleType: 0,
version: "19.1.0-native-fb-cd90a4d8-20250210",
version: "19.1.0-native-fb-899e3d12-20250211",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-native-fb-cd90a4d8-20250210"
reconcilerVersion: "19.1.0-native-fb-899e3d12-20250211"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2263 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -16154,4 +16152,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.1.0-native-fb-cd90a4d8-20250210";
exports.version = "19.1.0-native-fb-899e3d12-20250211";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<5202b9e27c05bcbc804d9718c27fa755>>
* @generated SignedSource<<cb31d915a8c9f43af76666e9c20be4f2>>
*/

/*
Expand Down Expand Up @@ -8067,9 +8067,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 @@ -16667,14 +16665,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1897 = React.version;
if (
"19.1.0-native-fb-cd90a4d8-20250210" !==
"19.1.0-native-fb-899e3d12-20250211" !==
isomorphicReactPackageVersion$jscomp$inline_1897
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1897,
"19.1.0-native-fb-cd90a4d8-20250210"
"19.1.0-native-fb-899e3d12-20250211"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -16696,10 +16694,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_1904 = {
bundleType: 0,
version: "19.1.0-native-fb-cd90a4d8-20250210",
version: "19.1.0-native-fb-899e3d12-20250211",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-native-fb-cd90a4d8-20250210",
reconcilerVersion: "19.1.0-native-fb-899e3d12-20250211",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$294 = 0;
Expand Down Expand Up @@ -16818,4 +16816,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.1.0-native-fb-cd90a4d8-20250210";
exports.version = "19.1.0-native-fb-899e3d12-20250211";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<7d766414b273732e4a3a24f84100791e>>
* @generated SignedSource<<781f3f60512393dfda17b4a9f04cb5ae>>
*/

/*
Expand Down Expand Up @@ -11236,11 +11236,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 @@ -26100,11 +26096,11 @@ __DEV__ &&
};
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.1.0-native-fb-cd90a4d8-20250210" !== isomorphicReactPackageVersion)
if ("19.1.0-native-fb-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-native-fb-cd90a4d8-20250210\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.1.0-native-fb-899e3d12-20250211\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
Expand Down Expand Up @@ -26141,10 +26137,10 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.1.0-native-fb-cd90a4d8-20250210",
version: "19.1.0-native-fb-899e3d12-20250211",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-native-fb-cd90a4d8-20250210"
reconcilerVersion: "19.1.0-native-fb-899e3d12-20250211"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -26604,7 +26600,7 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.1.0-native-fb-cd90a4d8-20250210";
exports.version = "19.1.0-native-fb-899e3d12-20250211";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<4d6413e9020c1a88850d554159892060>>
* @generated SignedSource<<9040b9d5240817444d50f94bed608ad1>>
*/

/*
Expand Down Expand Up @@ -7821,9 +7821,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 @@ -16029,14 +16027,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1803 = React.version;
if (
"19.1.0-native-fb-cd90a4d8-20250210" !==
"19.1.0-native-fb-899e3d12-20250211" !==
isomorphicReactPackageVersion$jscomp$inline_1803
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1803,
"19.1.0-native-fb-cd90a4d8-20250210"
"19.1.0-native-fb-899e3d12-20250211"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -16058,10 +16056,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2265 = {
bundleType: 0,
version: "19.1.0-native-fb-cd90a4d8-20250210",
version: "19.1.0-native-fb-899e3d12-20250211",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-native-fb-cd90a4d8-20250210"
reconcilerVersion: "19.1.0-native-fb-899e3d12-20250211"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2266 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -16319,4 +16317,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.1.0-native-fb-cd90a4d8-20250210";
exports.version = "19.1.0-native-fb-899e3d12-20250211";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<f6f287ef9aeeeabbf9a95100b67b9680>>
* @generated SignedSource<<4ee6a26294e56139ad47dd9437f765f8>>
*/

/*
Expand Down Expand Up @@ -8071,9 +8071,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 @@ -16682,14 +16680,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1898 = React.version;
if (
"19.1.0-native-fb-cd90a4d8-20250210" !==
"19.1.0-native-fb-899e3d12-20250211" !==
isomorphicReactPackageVersion$jscomp$inline_1898
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1898,
"19.1.0-native-fb-cd90a4d8-20250210"
"19.1.0-native-fb-899e3d12-20250211"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -16711,10 +16709,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_1905 = {
bundleType: 0,
version: "19.1.0-native-fb-cd90a4d8-20250210",
version: "19.1.0-native-fb-899e3d12-20250211",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-native-fb-cd90a4d8-20250210",
reconcilerVersion: "19.1.0-native-fb-899e3d12-20250211",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$294 = 0;
Expand Down Expand Up @@ -16987,7 +16985,7 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.1.0-native-fb-cd90a4d8-20250210";
exports.version = "19.1.0-native-fb-899e3d12-20250211";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Loading

0 comments on commit 8d80d81

Please sign in to comment.