From 88db17e549319df59e8756714f2ace1744b245df Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Thu, 5 Nov 2026 10:58:10 -0800 Subject: [PATCH] Drop `PropertyDescriptor` type arguments that the upcoming non-generic builtin rejects Summary: Flow's builtin `PropertyDescriptor` is becoming non-generic, as in TypeScript's `lib.es5.d.ts`: its `value`, `get` and `set` use `any`, and `Object.getOwnPropertyDescriptor` no longer takes a type argument. The new builtins reject `PropertyDescriptor` annotations and `Object.getOwnPropertyDescriptor(...)` calls. Remove those type arguments. Today's Flow accepts all of these sites without them. Nothing changes at runtime. Changelog: [Internal] Drop `PropertyDescriptor` type arguments. Differential Revision: D129956546 --- packages/react-native/Libraries/Utilities/PolyfillFunctions.js | 2 +- .../private/webapis/dom/oldstylecollections/HTMLCollection.js | 2 +- .../src/private/webapis/dom/oldstylecollections/NodeList.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native/Libraries/Utilities/PolyfillFunctions.js b/packages/react-native/Libraries/Utilities/PolyfillFunctions.js index 5731a3f4c49f..4904cca0fbfb 100644 --- a/packages/react-native/Libraries/Utilities/PolyfillFunctions.js +++ b/packages/react-native/Libraries/Utilities/PolyfillFunctions.js @@ -30,7 +30,7 @@ export function polyfillObjectProperty( name: string, getValue: () => T, ): void { - const descriptor = Object.getOwnPropertyDescriptor<$FlowFixMe>(object, name); + const descriptor = Object.getOwnPropertyDescriptor(object, name); if (__DEV__ && descriptor) { const backupName = `original${name[0].toUpperCase()}${name.slice(1)}`; Object.defineProperty(object, backupName, descriptor); diff --git a/packages/react-native/src/private/webapis/dom/oldstylecollections/HTMLCollection.js b/packages/react-native/src/private/webapis/dom/oldstylecollections/HTMLCollection.js index 4295da55838d..a3b3d0ec215e 100644 --- a/packages/react-native/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +++ b/packages/react-native/src/private/webapis/dom/oldstylecollections/HTMLCollection.js @@ -18,7 +18,7 @@ import {setPlatformObject} from '../../webidl/PlatformObjects'; // IMPORTANT: The type definition for this module is defined in `HTMLCollection.js.flow` // because Flow only supports indexers in classes in declaration files. -const REUSABLE_PROPERTY_DESCRIPTOR: {...PropertyDescriptor, ...} = { +const REUSABLE_PROPERTY_DESCRIPTOR: {...PropertyDescriptor, ...} = { value: {}, enumerable: true, configurable: false, diff --git a/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js b/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js index 31eee8b52ad7..7a54461eda9d 100644 --- a/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js +++ b/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js @@ -22,7 +22,7 @@ import {setPlatformObject} from '../../webidl/PlatformObjects'; // IMPORTANT: The Flow type definition for this module is defined in `NodeList.js.flow` // because Flow only supports indexers in classes in declaration files. -const REUSABLE_PROPERTY_DESCRIPTOR: {...PropertyDescriptor, ...} = { +const REUSABLE_PROPERTY_DESCRIPTOR: {...PropertyDescriptor, ...} = { value: {}, writable: false, };