deeleman / learning-angular2

Code samples repository for the examples provided in "Learning Angular 2", published by Packt Publishing - THE BOOK COVERS UP TO RC.1 and hence is severely OUTDATED. PLEASE REFER TO THE LATEST EDITIONS INSTEAD.
https://www.packtpub.com/web-development/learning-angular-2
108 stars 59 forks source link

No commonjs target available #1

Closed sabas closed 8 years ago

sabas commented 8 years ago

tsc --init --experimentalDecorators --target commonjs gives error error TS6047: Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'.

Ref: page 4

Using ES6 the tsconfig becomes

{
    "compilerOptions": {
        "experimentalDecorators": true,
        "target": "es2015",
        "module": "commonjs",
        "noImplicitAny": false,
        "outDir": "built",
        "rootDir": ".",
        "sourceMap": false
    },
    "exclude": [
        "node_modules"
    ]
}
deeleman commented 8 years ago

The TypeScript compiler has evolved since chapter 1 was originally written back in 2015 and hence its CLI basic syntax.

However bear in mind that targeting ES2016 will make the code to be transpiled into ES6 JavaScript which is still not supported by the vast majority of browsers out there.

A new tsconfig.json file has been posted for your convenience. You may use it with the following command:

$ tsc --watch

The --watchoption will watch typescript files for changes, reissuing the transpilation upon changes. Feel free to use it or remove it for compiling typescript files in one go.