2

我最近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编译器版本更改为包含 typescriptService.js 的自定义目录。

还是不行...

我的打字稿版本是 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();
}
4

2 回答 2

0

通过命令行检查您的tsc版本tsc -v,看看结果是否为1.5.0-beta. 您可能使用的是较早版本,因为您的系统中安装了多个(一个通过 npm,其他可能在您安装 Visual Studio 版本时)。

要检查tsc(如果您在 Windows 环境中)的已安装版本,请使用命令行并键入where tsc,如果您的目录比 npm 更多,则结果将是目录列表,只需转到您的 Path 系统变量并删除它们即可。

一定要打开一个新的命令行以便tsc再次测试,因为旧的路径变量不会刷新已经打开的命令行。

于 2015-05-14T15:57:49.553 回答
0

我使用的是 WebStorm 10.0.4,默认配置为 TypeScript 1.4。在我重新配置 WebStorm 以使用 TypeScript 1.5 beta 之前,它给了我“缺少分号”的类型错误。它位于首选项 -> 语言和框架 -> TypeScript -> 编译器版本中。

于 2015-06-22T15:18:09.643 回答