I’m working on a React Native project and encountering a strange error related to the lib
setting in my tsconfig.json
. Here is the content of my tsconfig.json
:
{
"extends": "@react-native/typescript-config/tsconfig.json",
"compilerOptions": {
"lib": ["ES2020", "DOM"],
"typeRoots": ["./types", "./node_modules/@types"],
"types": ["react", "react-native", "jest"]
}
}
I keep getting this error:
'compilerOptions/lib/2' must be equal to one of the allowed values 'ES5, ES6, ES2015, ES2015.Collection, ... Value found 'es2020.date' Or 'compilerOptions/lib/2' must match pattern ...
The error seems to indicate that I chose es2020.date
, but I didn’t – I selected "ES2020"
. I’ve tried different values like "ES6"
, but the compiler always thinks I chose es2020.date
.
Has anyone encountered this issue before? How can I fix this?
Additional Info:
- React Native version: 0.75.1
- React version: 18.3.1
- TypeScript version: 5.0.4
@react-native/typescript-config
: 0.75.1- Node version: >=18
- Package manager: Yarn 3.6.4
- VS Code version: 1.79.2
- Operating System: Windows 11
- I’ve tried clearing cache, re-installing dependencies, and making various changes to
tsconfig.json
.
Thanks in advance!
2