![](/img/trans.png)
[英]Update angular2.d.ts and router.d.ts to match the angular2 version
[英]typescript angular2.d.ts error “Expecting new line or semicolon”
我最新的WebStorm10.0.2
引發了關於"angular2.d.ts"
錯誤,即“需要換行或分號”。 在第 15-19 行和第 32-37 行。
Angular2 團隊在 5 分鍾啟動示例中犯了錯誤? 我不敢相信,這一定是我的錯。
所以:
我按照“angular2的5分鍾快速入門”( https://angular.io/ )一步一步克隆。
我已經將 'index.html' 和 'app.ts' 從 'complete' 移動到 Base-Path。
我還將我的WebStorm10.0.2
編譯器版本更改為包含WebStorm10.0.2
自定義目錄。
還是不行...
我的打字稿版本是 1.5Beta。
interface List<T> extends Array<T> {
}
interface Type {}
declare module "angular2/angular2" {
function bootstrap(appComponentType: any): void;
function Component({
selector,
properties,
hostListeners,
injectables,
lifecycle,
changeDetection
}:{
selector:string,
properties?:Object,
hostListeners?:Object,
injectables?:List<any>,
lifecycle?:List<any>,
changeDetection?:string
});
function View({
templateUrl,
template,
directives,
formatters,
source,
locale,
device
}: {
templateUrl?: string,
template?: string,
directives?: List<Type>,
formatters?: List<Type>,
source?: List<any>,
locale?: string,
device?: string
});
function For();
function If();
}
通過命令行上的tsc -v
檢查您的tsc
版本,看看結果是否為1.5.0-beta
。 很有可能您使用的是早期版本,因為您的系統中安裝了多個版本(一個通過 npm,另一個可能是當您安裝了 Visual Studio 的某個版本時)。
要檢查已安裝的tsc
版本(如果您在 Windows 環境中),請使用命令行並鍵入where tsc
,如果您的目錄比 npm 多,則結果將是目錄列表,只需轉到您的 Path 系統變量和刪除它們。
一定要打開一個新的命令行,以便再次測試tsc
,因為舊的路徑變量不會為已經打開的命令行刷新。
我使用的是 WebStorm 10.0.4,默認配置為 TypeScript 1.4。 在我重新配置 WebStorm 以使用 TypeScript 1.5 beta 之前,它給了我“缺少分號”類型錯誤。 它在首選項 -> 語言和框架 -> TypeScript -> 編譯器版本中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.