mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
5370347f54
Summary: Fixes https://github.com/facebook/react-native/issues/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` Pull Request resolved: https://github.com/facebook/react-native/pull/48230 Test Plan: Create a new React Native project: ```bash npx react-native-community/cli@latest init AwesomeProject ``` Copy the changes in the reproducer from the linked issue and add a lazy import: ```tsx const LazyAssetExample = React.lazy(() => import('./components/AssetExample')); ``` See the error when running `yarn tsc`: <img width="739" alt="image" src="https://github.com/user-attachments/assets/99989cd1-e11a-4b23-b178-f221d8cdd8ca" /> --- To fix the error, apply the following patch: ```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 Reviewed By: cipolleschi Differential Revision: D67334277 Pulled By: NickGerleman fbshipit-source-id: d26525023ff6fcfff651d1e4cee48ab2854b8d83
@react-native/typescript-config
This package provides the default tsconfig.json used by newly built React Native apps.
This template is customized for specific versions of React Native, and should be updated in sync with the rest of your app.