Files
react-native/packages/typescript-config/tsconfig.json
T
Mateo Guzmán 5370347f54 Upgrading typescript-config module version to esnext (#48230)
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
2024-12-17 06:08:43 -08:00

44 lines
1.2 KiB
JSON

{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "React Native",
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"types": ["react-native", "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"
],
"allowJs": true,
"jsx": "react-native",
"noEmit": true,
"isolatedModules": true,
"strict": true,
"moduleResolution": "bundler",
"customConditions": ["react-native"],
"allowImportingTsExtensions": true,
"allowArbitraryExtensions": true,
"resolveJsonModule": true,
"resolvePackageJsonImports": false,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true,
// Causes issues with package.json "exports"
"forceConsistentCasingInFileNames": false
},
"exclude": [
"**/Pods/**"
]
}