Reputation: 1018
The goal: Find a d.ts file that'll teach TypeScript the changes in ES2015/ES6.
TypeScript 1.5 ES6 modules & .d.ts files from DefinitelyTyped seem incompatible (Jul 2015) references using es6.lib.d.ts.
error TS2339: Property 'endsWith' does not exist on type 'string' (Dec 2015) points to https://github.com/Microsoft/TypeScript/blob/master/lib/lib.es6.d.ts.
Note the difference between the file titles!
I looked on typings
and found neither es6.lib.d.ts
nor lib.es6.d.ts
.
I copied the lib.es6.d.ts
cited above and cited it in my programs (/// <reference path="./typings/lib.es6.d.ts" />
); the compiler tilts when processing that file. Line 132 there is
readonly prototype: Object;
Line 132 is the first occurrence of readonly
in the file. The compiler points at readonly
and reports
error TS1131: Property or signature expected.
Anyone know how to teach ES6 to TypeScript? Or to work around teaching it? (I'd love to use ES6 features, of course!) Thanks in advance!
Upvotes: 0
Views: 1318
Reputation: 5490
Just set ES6
as you target and you have taught ES6 to typescript.
// tsconfig.json
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"sourceMap": true,
"noImplicitAny": true
}
}
Upvotes: 0
Reputation: 275819
Anyone know how to teach ES6 to TypeScript
With the latest compiler (and you really should use that https://basarat.gitbooks.io/typescript/content/docs/getting-started.html#nightly-typescript) you can use the --lib es6
option.
More on lib
option : https://github.com/Microsoft/TypeScript/issues/6974
(PS: its supported in alm https://github.com/alm-tools/alm/)
Upvotes: 2