Issue
I changed the target in tsconfig from es5 to es2022 and restarted VS Code multiple times, but Intellisense is still importing from es5. TS version is selected as use workspace's version (5.2.2). When I try to use new Error("", {cause: ""})
it doesn't recognize the cause
. When I click Go to Type Definition
it brings up the es5 version of the type. Am I doing something wrong? I have a monorepo setup with child configs inherit the base.
tsconfig.base.json
{
"compileOnSave": false,
"compilerOptions": {
"rootDir": ".",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"importHelpers": true,
"target": "ES2022",
"module": "commonjs",
"lib": ["es2017", "dom", "ES2021.String", "ESNext.String"],
"typeRoots": ["./node_modules/@types"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"strictNullChecks": true,
"baseUrl": ".",
"paths": {},
"exclude": ["tmp"]
}
tsconfig.json (this is an example for my next js project)
{
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"jsxImportSource": "@emotion/react"
},
"files": [],
"include": [],
"references": [],
"extends": "../../../../tsconfig.base.json"
}
index.ts
throw new Error("test", {
cause: "hi"
}); // Expected 0-1 arguments, but got 2. Go to Type Definition brings up lib.es5.d.ts
Solution
target
does set the corresponding default for lib
(see also What is the typescript compiler's default lib value?), but I guess if you specify lib
manually, there's no merging with that corresponding default, so you need to specify the corresponding lib
manually. Ex.
"target": "es2022",
"lib": ["es2022", "dom", ...],
Answered By - starball
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.