2016-09-28 75 views
7

我剛剛克隆了github中的angular2-seed項目並按照步驟操作,但是我將這個警告寫入VS代碼 [ts]修飾器的實驗支持是該功能在未來版本中可能會發生變化。 設置'Exxperimentaldecorators'選項以消除此警告。修飾器的實驗支持是一個功能,可能會在未來的版本中發生變化

+0

這是一個問答網站...有什麼問題嗎? – charlietfl

+0

有些東西不能用我的VS代碼和打字稿 –

+0

我用[js]而不是[ts]得到這個錯誤。 WTF? –

回答

0

這是由於使用舊版本的打字稿。您必須升級您的打字稿才能刪除此訊息。

npm install -g [email protected] 

此外,您還需要將您的npm升級到最新版本。

+1

我已經有打字稿(2.0.3)的最新版本,我只是升級npm,但沒有任何改變 –

11

轉到文件/偏好/在vscode用戶設置,把這段代碼

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

哪裏是文件/首選項/用戶設置? – nuander

+0

Visual Studio代碼菜單 –

3

在你tsconfig.json文件,添加到include財產這樣的項目的路徑:

"include": [ 
    "app/**/*" 
] 

或可替代您可以將單個文件添加到files屬性中。這裏是我的tsconfig.json看起來像爲例(爲Angular2應用程序):

{ 
    "compileOnSave": false, 
    "buildOnSave": false, 
    "compilerOptions": { 
     "target": "es5", 
     "module": "commonjs", 
     "moduleResolution": "node", 
     "removeComments": true, 
     "emitDecoratorMetadata": true, 
     "experimentalDecorators": true, 
     "noEmitHelpers": true, 
     "sourceMap": true, 
     "types": [ 
      "node" 
     ], 
     "typeRoots": [ 
      "../node_modules/@types" 
     ], 
     "lib": [ 
      "es2015", 
      "dom" 
     ] 
    }, 
    "files": [ 
     "app/main.ts", 
     "app/app.module.ts" 
    ], 
    "include": [ 
     "app/**/*.ts" 
    ], 
    "exclude": [ 
     "node_modules", 
     "dist", 
     "build", 
     "app/main.aot.ts" 
    ] 
} 
+1

「include」:[ 「app/**/*」 ] –

+0

'exclude'選項幫助了我 – Zanecat

2

我對我創建了一個新的服務使用@Injectable()時,有這樣的問題。 我從VS代碼的打字稿編譯器得到了這個警告。

當我將新服務作爲供應商添加到我打算使用它的模塊時,該警告消失。

希望這可以解決您的問題。

相關問題