我嘗試了一些 bable 設定,tsconfig 中的不同目標/lib 設定,什么都沒有。不知道我還能做什么...
錯誤如下所示:
let test:object[] = [{}];
test.flatMap();
Property 'flatMap' does not exist on type 'object[]'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2019' or later.ts(2550)
& 我的 tsconfig
{
"compilerOptions": {
"target": "es5",
"lib": [
"es2020"
],
"esModuleInterop": true,
"jsx": "react",
"module": "commonjs",
"moduleResolution": "node",
"noEmit": true,
"noUnusedLocals": true,
"outDir": "public",
"resolveJsonModule": true,
"rootDir": "src",
"sourceMap": false,
"strict": true,
"strictNullChecks": true,
"allowJs": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
},
"include": ["src/**/*"],
"exclude": ["node_modules", "public"]
}
uj5u.com熱心網友回復:
tsconfig有時不反映在 IDE 中的更改。根據您的 IDE,您應該能夠找到一種方法來重新啟動 TypeScript 服務器。如果找不到,則可以重新啟動 IDE 本身。
如何在 VSCode 上執行此操作:鏈接
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/349965.html
標籤:打字稿
