简体   繁体   English

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

[英]typescript angular2.d.ts error “Expecting new line or semicolon”

my latest WebStorm10.0.2 raise Error about "angular2.d.ts" that "Expecting new line or semicolon."我最新的WebStorm10.0.2引发了关于"angular2.d.ts"错误,即“需要换行或分号”。 in line 15-19 and line 32-37.在第 15-19 行和第 32-37 行。

Angular2 team make a mistake at the 5min start example? Angular2 团队在 5 分钟启动示例中犯了错误? I can't believe, it must be my mistake.我不敢相信,这一定是我的错。

So:所以:

I clone step by step follow the "5min quick start of angular2"( https://angular.io/ ).我按照“angular2的5分钟快速入门”( https://angular.io/ )一步一步克隆。

I have already move 'index.html' and 'app.ts' from 'complete' to the Base-Path.我已经将 'index.html' 和 'app.ts' 从 'complete' 移动到 Base-Path。

I have also change my WebStorm10.0.2 Compiler version to custom directory which contains typescriptService.js.我还将我的WebStorm10.0.2编译器版本更改为包含WebStorm10.0.2自定义目录。

Still not work...还是不行...

My typescript version is 1.5Beta.我的打字稿版本是 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();
}

Check your tsc version through tsc -v on the command line and see if the result is 1.5.0-beta .通过命令行上的tsc -v检查您的tsc版本,看看结果是否为1.5.0-beta Chances are that you are using an earlier version because you have more than one installed in your system (one through npm, other probably when you installed a version of Visual Studio).很有可能您使用的是早期版本,因为您的系统中安装了多个版本(一个通过 npm,另一个可能是当您安装了 Visual Studio 的某个版本时)。

To check the installed versions of tsc (if you are on a windows environment) use the command line and type where tsc , the results will be a list of directories if you have more directories than the npm ones just go to your Path system variable and remove them.要检查已安装的tsc版本(如果您在 Windows 环境中),请使用命令行并键入where tsc ,如果您的目录比 npm 多,则结果将是目录列表,只需转到您的 Path 系统变量和删除它们。

Be sure to open a new command line in order to test tsc again, because the old path variables don't refresh for the already open command lines.一定要打开一个新的命令行,以便再次测试tsc ,因为旧的路径变量不会为已经打开的命令行刷新。

I'm using WebStorm 10.0.4, which is configured with TypeScript 1.4 by default.我使用的是 WebStorm 10.0.4,默认配置为 TypeScript 1.4。 It was giving me "missing semicolons" type errors until I've reconfigured WebStorm to use TypeScript 1.5 beta.在我重新配置 WebStorm 以使用 TypeScript 1.5 beta 之前,它给了我“缺少分号”类型错误。 It's in Preferences -> Languages and Frameworks -> TypeScript -> Compiler version.它在首选项 -> 语言和框架 -> TypeScript -> 编译器版本中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 更新angular2.d.ts和router.d.ts以匹配angular2版本 - Update angular2.d.ts and router.d.ts to match the angular2 version 我看到在angular2 / angular2.d.ts中定义了angular2的“绑定”函数-曾经在&#39;angular2 / di.d.ts中使用吗? - I see an angular2 'bind' function defined in angular2/angular2.d.ts - did it used to be in 'angular2/di.d.ts? Angular 2 Typescript在moment.d.ts中使用momentjs构建错误 - Angular 2 Typescript building error with momentjs for moment.d.ts "node_modules\/@angular\/material\/table\/cell.d.ts 中的错误 -Typescript 版本问题 angular" - ERROR in node_modules/@angular/material/table/cell.d.ts -Typescript version problem angular Angular 2 Typescript编译错误TS2304? - Angular 2 Typescript compilation error TS2304? 在 typescript (Angular) 中添加新行 - Add new line in typescript (Angular) Angular 11.2.6 或 Typescript TS2345 错误 - Angular 11.2.6 or Typescript TS2345 error d3v4 + Typescript + angular2 错误使用 d3.line().x((d) =&gt; {function}) - d3v4 + Typescript + angular2 error using d3.line().x((d) => {function}) WebStorm HTML格式错误-预期换行或分号 - WebStorm HTML formatting error - Expecting newline or semicolon 将 Angular 8 升级到 Angular 9 错误:TypeScript 编译中缺少 .ts - Upgrading Angular 8 to Angular 9 Error: .ts is missing from the TypeScript compilation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM