Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading typescript-config module version to esnext #48230

Conversation

mateoguzmana
Copy link
Contributor

Summary:

Fixes #45810

Upgrading typescript-config module version from es2015 to esnext, in order to support dynamic imports.

Changelog:

[GENERAL] [CHANGED] - Upgrading typescript-config module version to esnext

Test Plan:

Create a new React Native project:

npx @react-native-community/cli@latest init AwesomeProject

Copy the changes in the reproducer from the linked issue and add a lazy import:

const LazyAssetExample = React.lazy(() => import('./components/AssetExample'));

See the error when running yarn tsc:

image

To fix the error, apply the following patch:

diff --git a/node_modules/@react-native/typescript-config/tsconfig.json b/node_modules/@react-native/typescript-config/tsconfig.json
index d5e1bce..51f54c1 100644
--- a/node_modules/@react-native/typescript-config/tsconfig.json
+++ b/node_modules/@react-native/typescript-config/tsconfig.json
@@ -3,7 +3,7 @@
     "display": "React Native",
     "compilerOptions": {
       "target": "esnext",
-      "module": "es2015",
+      "module": "esnext",
       "types": ["react-native", "jest"],
       "lib": [
         "es2019",

Verify it is fix by running yarn tsc again

@facebook-github-bot facebook-github-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 Dec 12, 2024
@mateoguzmana mateoguzmana changed the title chore(typescript): upgrading module version to esnext Upgrading typescript-config module version to esnext Dec 12, 2024
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Dec 12, 2024
@NickGerleman
Copy link
Contributor

@huntie, to sanity check, is this supported by Metro out of the box?

An aside, we're probably overdue for an update on ES lib support in the config as well (last time it was updated was a couple years ago, and I wouldn't be surprised if Hermes has added support for more things).

@NickGerleman
Copy link
Contributor

Looks like yes https://metrobundler.dev/docs/module-api/#import-dynamic-import

@facebook-github-bot
Copy link
Contributor

@NickGerleman has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Dec 17, 2024
@facebook-github-bot
Copy link
Contributor

@NickGerleman merged this pull request in 5370347.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @mateoguzmana in 5370347

When will my fix make it into a release? | How to file a pick request?

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. Merged This PR has been merged. 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.

TypeScript config does not support dynamic imports
4 participants