feat: [TypeScript] Add missing methods types Promise.try + Promise.withResolvers (#57215)

Summary:
New methods `Promise.try` and `Promise.withResolvers` were added to the Hermes V1 branch, see: https://github.com/facebook/hermes/pull/2020

I tested them on the latest RN 0.86.0, and they are working:
```tsx
console.log({
  'ReactNativeVersion.getVersionString()':ReactNativeVersion.getVersionString(),
  'Promise.try': Promise.try,
  'Promise.withResolvers': Promise.withResolvers,
});
//{
//  "Promise.try": [Function anonymous],
//  "Promise.withResolvers": [Function anonymous],
//  "ReactNativeVersion.getVersionString()": "0.86.0"
// }
```

- `es2024.promise` - includes `Promise.withResolvers`
- `esnext.promise` - includes `Promise.try`

## Changelog:

[GENERAL] [ADDED] - Add `Promise.try` + `Promise.withResolvers` typescript types

Pull Request resolved: https://github.com/react/react-native/pull/57215

Test Plan:
```
edit `node_modules/react-native/typescript-config/tsconfig.json`
add `es2024.promise` `esnext.promise`
try to use new methods in ts files

// no error expected
```

Reviewed By: robhogan

Differential Revision: D108745447

Pulled By: fabriziocucci

fbshipit-source-id: dfebe404ab45bc4cb9071692d2f13c42b2816e51
This commit is contained in:
D N authored and meta-codesync[bot] committed 2026-06-16 06:16:40 -07:00
1 parent 097dbc288b
commit b99ddaf606
1 file changed
+3 -1
+3 -1
View File
@@ -19,7 +19,9 @@
"es2022.array",
"es2022.error",
"es2022.object",
"es2022.string"
"es2022.string",
"es2024.promise",
"esnext.promise"
],
"allowJs": true,
"jsx": "react-native",