VSCode无法识别打字稿3.7.2功能

我正在使用VS Code 1.40.0,并且具有以下package.json

{
  "name": "test","version": "0.0.1","description": "test","main": "./src/main.ts","sideEffects": false,"author": "","license": "ISC","devDependencies": {
    "@typescript-eslint/eslint-plugin": "^2.6.1","@typescript-eslint/parser": "^2.6.1","eslint": "^6.5.1","typescript": "^3.7.2"
  },"dependencies": {
  }
}

以及以下tsconfig.json

{
    "compilerOptions": {
        "lib": [
            "es2019","dom","es2019.array"
        ],"target": "es6","module": "es6","strict": true,"strictBindCallApply": true,"strictFunctionTypes": true,"strictPropertyInitialization": true,"moduleResolution": "node","noImplicitAny": true,"noImplicitReturns": true,"noImplicitThis": true,"forceConsistentCasingInFileNames": true,"noFallthroughCasesInSwitch": true,"strictNullChecks": true,"removeComments": true,"preserveConstEnums": true,"sourceMap": true,"alwaysStrict": true,"esModuleInterop": true,"allowSyntheticDefaultImports": true,"noUnusedLocals": true,"noUnusedParameters": true
    }
}

但是在编写以下代码const a = null ?? 0;时,vscode抱怨,但是在按预期方式编译时,是否需要更改某些设置才能使vscode正确解析Typescript 3.7?

lan_o_han 回答:VSCode无法识别打字稿3.7.2功能

您可以将以下内容添加到设置中,以便它在您的node_modules中使用TypeScript而不是其内置的(可能仍在3.6上):

"typescript.tsdk": "node_modules/typescript/lib"
,

安装JavaScript and TypeScript Nightly解决了我的问题。

本文链接:https://www.f2er.com/3110748.html

大家都在问