Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript error TS5023: Unknown compiler option 'strict'

Tags:

typescript

When using the option "strict" in tsconfig.json file, I get the error:

error TS5023: Unknown compiler option 'strict'

But this compiler option is clearly allowed in the official documentation:

Reference: https://www.typescriptlang.org/docs/handbook/compiler-options.html

And also my Visual Studio Code editor.

Does anyone know what I did wrong? Here is my tsconfig.json file:

{
  "compilerOptions": {
    "strict": true,
    "sourceMap":  true
  }
}
like image 402
benjaminz Avatar asked May 06 '17 00:05

benjaminz


1 Answers

You need the latest version.

Specifically, you need TypeScript@>=2.3

For project level installation (recommended)

npm install --dev typescript@latest

If you use tsc via the global command line

npm install --global typescript@latest

To override the version used by VS Code to use your global installation

  1. Open user settings

  2. Change it as follows (replace my name with yours)

    // Place your settings in this file to overwrite the default settings
    {
      "typescript.tsdk": "C:/Users/Aluan/AppData/Roaming/npm/node_modules/typescript/lib",
       //..
    
  3. If you are running Linux or OSX the path will be something like

    "~/npm/node_modules/typescript/lib"
    

That said, the latest VS Code should ship with TypesScript@>3 so you shouldn't need to do anything except update it...

Other package managers:

JSPM:

command line:

jspm install --dev typescript@latest

VS Code project level settings:

{
  "typescript.tsdk": "./jspm_packages/npm/typescript@latest/lib"
}

Yarn:

command line:

yarn add --dev typescript@latest

VS Code project level settings:

{
  "typescript.tsdk": "./node_modules/typescript/lib"
}
like image 78
Aluan Haddad Avatar answered Sep 21 '22 13:09

Aluan Haddad