2016-10-28 75 views
9

我已經嘗試過包括分型線,但是,這並不解決這個問題對我來說凌打字稿插件無法找到名爲「描述」

enter image description here

這裏是我的tsconfig.json文件:

{ 
    "compilerOptions": { 
    "declaration": false, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "lib": ["es6", "dom"], 
    "mapRoot": "./", 
    "module": "es6", 
    "moduleResolution": "node", 
    "outDir": "../dist/out-tsc", 
    "sourceMap": true, 
    "target": "es5", 
    "typeRoots": [ 
     "../node_modules/@types" 
    ], 
    "types": [ 
     "jasmine" 
    ] 
    } 
} 

node_modules的路徑是正確的

+0

你使用的是什麼版本的typescrpt atom插件?什麼是插件的名稱? – prosti

+0

如果你認爲這是一個bug,最好在github上打開一個問題。同時添加所有可以讓某人重現的細節。 –

+0

@prosti原子和插件名稱的最新版本是atom-typescript –

回答

-1

我已經解決了同樣的問題。我也是Atom用戶。只需排除tsconfig.json中的spec.ts文件即可。我tsconfig.json現在看起來是這樣的:

{ 
    "compilerOptions": { 
    "declaration": false, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "lib": ["es6", "dom"], 
    "mapRoot": "./", 
    "module": "es6", 
    "moduleResolution": "node", 
    "outDir": "../dist/out-tsc", 
    "sourceMap": true, 
    "target": "es5", 
    "typeRoots": [ 
     "../node_modules/@types" 
    ] 
    }, 
    "exclude": [ 
     "./src/*.spec.ts",   
    ] 
} 

瞭解更多關於tsconfig這裏:https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

+5

這不是一個解決方案,你只是避免了這個問題 –

3

我使用這個臨時的解決方案 - 而我希望原子打字稿插件可以更好地解決這個問題。

安裝類型;

npm install @types/jasmine --save-dev 

將此行添加到我的src/app/app.component.spec.ts文件中;

import '../../node_modules/@types/jasmine'; 

不需要將其添加到任何其他spec文件,編輯只是這一個文件解決了我的問題。

另一個解決方法,我發現,工作,但不如上述對我來說,因此根據您的需要編輯「package.json」,通過將「devDependencies」中的茉莉參考移動到「依賴關係「部分;

"@types/jasmine": "^2.5.38" 
1

我遇到了同樣的問題。爲了解決這個問題,我刪除了typeRoots,並且只保留類型數組。

+0

嗯。任何想法*爲什麼*這有效?我正在使用'typeRoots'來爲沒有可用的通用'@type/whatever'類型定義模塊的模塊添加額外的類型定義庫。也許還有另一個簡單的方法來做到這一點,而不需要將定義與我自己的代碼混合? – Jules