Skip to content

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

Open
retyui wants to merge 1 commit into
react:mainfrom
retyui:feat/retyui/add-promise-types
Open

feat: [TypeScript] Add missing methods types Promise.try + Promise.withResolvers#57215
retyui wants to merge 1 commit into
react:mainfrom
retyui:feat/retyui/add-promise-types

Conversation

@retyui

@retyui retyui commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary:

New methods Promise.try and Promise.withResolvers were added to the Hermes V1 branch, see: facebook/hermes#2020

I tested them on the latest RN 0.86.0, and they are working:

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

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 

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 16, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jun 16, 2026
@retyui

retyui commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

workaround:

devs can add on the project level:

// ./tsconfig.json
{
  "extends": "@react-native/typescript-config",
  "compilerOptions": {
    "types": ["jest"],
+    "lib": [
+      "es2019",
+      "es2020.bigint",
+      "es2020.date",
+      "es2020.number",
+      "es2020.promise",
+      "es2020.string",
+      "es2020.symbol.wellknown",
+      "es2021.promise",
+      "es2021.string",
+      "es2021.weakref",
+      "es2022.array",
+      "es2022.object",
+      "es2022.string",
+      "es2024.promise",
+      "esnext.promise"
+    ]
  },
  "include": ["**/*.ts", "**/*.tsx"],
  "exclude": ["**/node_modules", "**/Pods"]
}

@meta-codesync

meta-codesync Bot commented Jun 16, 2026

Copy link
Copy Markdown

@fabriziocucci has imported this pull request. If you are a Meta employee, you can view this in D108745447.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant