简体   繁体   中英

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." in line 15-19 and line 32-37.

Angular2 team make a mistake at the 5min start example? 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/ ).

I have already move 'index.html' and 'app.ts' from 'complete' to the Base-Path.

I have also change my WebStorm10.0.2 Compiler version to custom directory which contains typescriptService.js.

Still not work...

My typescript version is 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 . 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).

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.

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.

I'm using WebStorm 10.0.4, which is configured with TypeScript 1.4 by default. It was giving me "missing semicolons" type errors until I've reconfigured WebStorm to use TypeScript 1.5 beta. It's in Preferences -> Languages and Frameworks -> TypeScript -> Compiler version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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