繁体   English   中英

打字稿angular2.d.ts错误“期望换行或分号”

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM