AngularJS 2.0 TypeScript Intellij idea (or webstorm) - ES6 import syntax

前端 未结 3 1981
滥情空心
滥情空心 2021-02-07 10:22

Trying to make these steps to make AngularJS 2.0 sample app running.

On that step, putting code in app.ts:

/// 

        
相关标签:
3条回答
  • 2021-02-07 10:46

    it look like you didn't specify the compiler arguments to tell which module loader to use, also you want to make sure you are using the latest TypeScript Compiler, to this date the latest was 1.5.0 beta.

    First

    You can download the bin of the TypeScript compiler tsc and all other related files on their GitHub Repository: https://github.com/Microsoft/TypeScript/tree/master/bin

    or you can also install it as a Node.js Package:

    npm install -g typescript
    

    Second

    You need to configure intelliJ properly by changing the Compiler version to custom and point to the location of the latest TypeScript bin folder

    in IntelliJ press Ctrl+Alt+S, search for TypeScript and under Languages & Frameworks select TypeScript, make sure your IntelliJ is up to date though.

    And to solve the problem you are asking here specify the following Command Line options:

    --module "amd" --target "es5"
    

    Screenshot:

    enter image description here

    Third

    It is worth mentioning that the TypeScript 1.5 compiler and Angular 2 are both in Beta so this answer could be irrelevant in the following weeks or month.

    Enjoy!

    Dany

    0 讨论(0)
  • 2021-02-07 10:59

    There is an option in IntelliJ where you can define a custom typescript version. Default is 1.4 but you can download 1.5 beta and assign that. The only problem with the sample I've seen is to activate 1.5 new argument to generate decorators metadata. IntelliJ always report that the TS process stopped.

    0 讨论(0)
  • 2021-02-07 11:00

    you need select javascript version in Preferences page.

    Languages & Frameworks -> JavaScript

    on the right page. JavaScript language version dropdown menu. on my idea it's has some item below.

    JavaScript 1.5 ECMAScript 5.1 JavaScript 1.6 JavaScript 1.7 JavaScript 1.8 JavaScript 1.8.6 ECMAScript 6 ...

    0 讨论(0)
提交回复
热议问题