A framework for building native applications using React
Export `@react-native/typescript-config/strict` shorthand (#53564)
Summary:
Extending a tsconfig seems simpler than adding `compilerOptions` with `customConditions`.
### Before
```jsonc
{
"extends": "react-native/typescript-config",
"compilerOptions": {
// ...
"customConditions": ["react-native-strict-api", "react-native"]
}
}
```
### After
```jsonc
{
"extends": "react-native/typescript-config/strict"
// ...
}
```
## Changelog:
[GENERAL] [ADDED] - Add `react-native/typescript-config/strict` export enabling the `react-native-strict-api` custom condition.
Pull Request resolved: https://github.com/facebook/react-native/pull/53564
Test Plan:
### `package.json`
```
{
"name": "react-native-ts-test",
"private": true,
"version": "0.1.0",
"scripts": {
"build": "tsc --noEmit"
},
"devDependencies": {
"react-native/typescript-config": "^0.81.1",
"typescript": "^5.9.2",
"jest": "^30.1.2"
},
"dependencies": {
"react-native": "^0.81.1"
}
}
```
### `tsconfig.json`
```
{
"extends": "react-native/typescript-config/strict",
"include": ["src/index.ts"]
}
```
### `src/index.ts`
```
import { View } from "react-native";
```
Run `npx resolution-explorer` and select "react-native from src/index.ts to node_modules/react-native/types_generated/index.d.ts" to verify the types are resolved correctly.
```
Explicitly specified module resolution kind: 'Bundler'.
Resolving in CJS mode with conditions 'import', 'types', 'react-native-strict-api'.
File '/Users/kraen.hansen/Repositories/react-native-ts-test/src/package.json' does not exist.
Found 'package.json' at '/Users/kraen.hansen/Repositories/react-native-ts-test/package.json'.
Loading module 'react-native' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Directory '/Users/kraen.hansen/Repositories/react-native-ts-test/src/node_modules' does not exist, skipping all lookups in it.
Found 'package.json' at '/Users/kraen.hansen/Repositories/react-native-ts-test/node_modules/react-native/package.json'.
Entering conditional exports.
Matched 'exports' condition 'react-native-strict-api'.
Using 'exports' subpath '.' with target './types_generated/index.d.ts'.
File '/Users/kraen.hansen/Repositories/react-native-ts-test/node_modules/react-native/types_generated/index.d.ts' exists - use it as a name resolution result.
'package.json' has a 'peerDependencies' field.
Resolving real path for '/Users/kraen.hansen/Repositories/react-native-ts-test/node_modules/react-native', result
'/Users/kraen.hansen/Repositories/react-native-ts-test/node_modules/react-native'.
Failed to find peerDependency 'types/react'.
Found 'package.json' at '/Users/kraen.hansen/Repositories/react-native-ts-test/node_modules/react/package.json'.
Found peerDependency 'react' with '19.1.1' version.
Resolved under condition 'react-native-strict-api'.
Exiting conditional exports.
Resolving real path for '/Users/kraen.hansen/Repositories/react-native-ts-test/node_modules/react-native/types_generated/index.d.ts', result
'/Users/kraen.hansen/Repositories/react-native-ts-test/node_modules/react-native/types_generated/index.d.ts'.
======== Module name 'react-native' was successfully resolved to
'/Users/kraen.hansen/Repositories/react-native-ts-test/node_modules/react-native/types_generated/index.d.ts' with Package ID
'react-native/types_generated/[email protected][email protected]'. ========
```
Reviewed By: robhogan
Differential Revision: D82791201
Pulled By: philIip
fbshipit-source-id: f58d3b8fcf3d7f18dd29eef18a3c8c0cb57d1d78 K
Kræn Hansen committed
0198c92c714cdfe48bb8d84771e5ef25c17fb47f
Parent: 34cd61f
Committed by Facebook GitHub Bot <[email protected]>
on 9/19/2025, 8:28:31 PM