Learning Angular2-typescript Compiling

Source: Internet
Author: User

The front end in this direction, the ability to accept new things and speed determines your position in the entire industry.

NG2 has not yet released the official stable version, but I think for me this time is the best time to store, so began to ng2 the road of learning.

Contact with Ng2 before also contact with a Avalon things, but do not know where the phase grams, is not smooth, and then think, are the same, and learn more reference to the NG2.

NG2 support Typescript and es5,6 development, of course, the official document currently only TS, in order to get started faster, have to use TS to write, so there is a problem is: compile.

Build Tools is gulp, so began to find gulp on the compiler TS Plug-ins, there are some, this thought will not go what fork, but this place was entangled for some time. It seems that I really need more discipline.

To get to the point:

The final selection of TS compiler plug-ins: Gulp-typescript.

The official explanation is very detailed, not much to repeat, the main details:

1: Define module loading mechanism

"Module": "Commonjs"

Gulp is the building tool under node, so the module loading mechanism also uses node mechanism, otherwise it will prompt the following error

Error Ts1148:cannot compile modules unless the '--module ' flag is provided.
 Error Ts2307:cannot find module ' angular2/angular2 '.
 Error Ts2307:cannot find module ' angular2/http '.

2: Define compilation target Type

"Target": "ES5"
To convert TS to ES5 standard files, node hints can be higher, but the actual operation of the experiment is not feasible.

3: Avoid warning

' Experimentaldecorators ': true
This item is not configured and prompts for warnings, causing the compilation to be unsuccessful

Error ts1219:experimental support for decorators is a feature this is subject to the change in a future release. Specify '--experimentaldecorators ' to remove this warning.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.