Compile Angular2 ts file

前端 未结 4 431
一向
一向 2021-01-21 01:16

I\'m trying Angular2 using Typescript, but I have a problem with tsc.

This is my tsconfig.json file:

{
\"compilerOptions\": {
    \"module\": \"commonjs\         


        
4条回答
  •  不知归路
    2021-01-21 01:45

    This is the usual behaviour of Typescript, as you are defining commonjs (-m commonjs/ "module":"commonjs"). With the latest version of Typescript and angular2 alpha27+Systemjs 0.18.1 there seems to be an issue with module importing

    https://github.com/systemjs/systemjs/issues/434

    To avoid this error add .js to any other module that you import, such as custom directives, controllers, and services that you might create in angular2. Angular2 is still in beta and the one that is publicly available from code.angular.io is in ES5. Wait for an ES6 version to land or compile it yourself to avoid this scenarios.

提交回复
热议问题