Why does Typescript ignore my tsconfig.json inside Visual Studio code?

I got my project setup like this

project/
|
+---src/
|   |
|   +---app/
|       |
|       sample.ts
|
+---typings/
+---tsconfig.json

and here is my tsconfig.json

{
    "compilerOptions": {
        "rootDir": "src",
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": true,
        "sourceMap": true,
        "noImplicitAny": false,
        "outDir": "dist"
    },
    "exclude": [
        "node_modules",
        "src/assets",
        "src/lib"
    ]
}

What interests me is why VSC indicates errors like

Highlight errors in VSC

when there is clearly no error at all ( "experimentalDecorators": truegiven in tsconfig.json), and the application broadcasts just fine? And these are not only decorators, Promiseand the like also stand out (I made sure that tsconfig.jsonin the same folder as typings, and I set the typing for es6-shim).

Not sure if that matters, but I'm on now typescript@2.0.0-dev.20160707.

+4
source share
2 answers

typescript ​​ npm, :

C:\Users\<username>\AppData\Roaming\npm\node_modules\typescript\\lib

:

lib.d.ts
tsserver.js

. :

File -> Preferences -> User Settings/Workspace Settings

settings.json, :

{
    "typescript.tsdk": "C:\\Users\\<username>\\AppData\\Roaming\\npm\\node_modules\\typescript\\lib"
}

( \\), - - Visual Studio Code. .

+2

VS tsconfig.json, TypeScript, , VS Code .

TypeScript 2.0.0-dev.20160707, , , , .

TypeScript VS

, TypeScript node_modules. .

npm install typescript --save-dev // stable
npm install typescript@next --save-dev // nightly

, lib settings.json. , settings.json VS Code File > Settings > User Settings .

{
  "typescript.tsdk": "node_modules/typescript/lib"
}

, TypeScript (-g) node_modules, typescript.tsdk.

, , tsconfig.json. .

{
    "compileOnSave": false,
    "compilerOptions": {
        "sourceMap": true,
        "target": "es5",
        "experimentalDecorators": true,
        "noImplicitAny": false
    },
    "exclude": [
        "node_modules"
    ],
    "filesGlob": [
        "src/**/*.ts",
        "test/**/*.ts",
        "typings/index.d.ts"
    ]
}

VS Code TypeScript . TypeScript,, typescript.tsdk( > > / ), , TypeScript tsserver.js lib. *.d.ts. . , TypeScript (npm install typescript @next). , typescript. ( ).

: https://blogs.msdn.microsoft.com/typescript/2016/01/28/announcing-typescript-1-8-beta/

+5

All Articles