Fix #24826: Add mapping for ES2018 target to library

This commit is contained in:
Mohamed Hegazy 2018-06-11 12:46:13 -07:00
parent 7df81311ac
commit b33d5e3f19
6 changed files with 67 additions and 0 deletions

View file

@ -4177,6 +4177,8 @@ namespace ts {
switch (options.target) {
case ScriptTarget.ESNext:
return "lib.esnext.full.d.ts";
case ScriptTarget.ES2018:
return "lib.es2018.full.d.ts";
case ScriptTarget.ES2017:
return "lib.es2017.full.d.ts";
case ScriptTarget.ES2016:

View file

@ -0,0 +1,10 @@
tests/cases/compiler/es2018ObjectAssign.ts(3,7): error TS1155: 'const' declarations must be initialized.
==== tests/cases/compiler/es2018ObjectAssign.ts (1 errors) ====
const test = Object.assign({}, { test: true });
const p: Promise<number>;
~
!!! error TS1155: 'const' declarations must be initialized.
p.finally();

View file

@ -0,0 +1,10 @@
//// [es2018ObjectAssign.ts]
const test = Object.assign({}, { test: true });
const p: Promise<number>;
p.finally();
//// [es2018ObjectAssign.js]
const test = Object.assign({}, { test: true });
const p;
p.finally();

View file

@ -0,0 +1,17 @@
=== tests/cases/compiler/es2018ObjectAssign.ts ===
const test = Object.assign({}, { test: true });
>test : Symbol(test, Decl(es2018ObjectAssign.ts, 0, 5))
>Object.assign : Symbol(ObjectConstructor.assign, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>assign : Symbol(ObjectConstructor.assign, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>test : Symbol(test, Decl(es2018ObjectAssign.ts, 0, 32))
const p: Promise<number>;
>p : Symbol(p, Decl(es2018ObjectAssign.ts, 2, 5))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
p.finally();
>p.finally : Symbol(Promise.finally, Decl(lib.es2018.promise.d.ts, --, --))
>p : Symbol(p, Decl(es2018ObjectAssign.ts, 2, 5))
>finally : Symbol(Promise.finally, Decl(lib.es2018.promise.d.ts, --, --))

View file

@ -0,0 +1,22 @@
=== tests/cases/compiler/es2018ObjectAssign.ts ===
const test = Object.assign({}, { test: true });
>test : { test: boolean; }
>Object.assign({}, { test: true }) : { test: boolean; }
>Object.assign : { <T, U>(target: T, source: U): T & U; <T, U, V>(target: T, source1: U, source2: V): T & U & V; <T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; }
>Object : ObjectConstructor
>assign : { <T, U>(target: T, source: U): T & U; <T, U, V>(target: T, source1: U, source2: V): T & U & V; <T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; }
>{} : {}
>{ test: true } : { test: true; }
>test : true
>true : true
const p: Promise<number>;
>p : Promise<number>
>Promise : Promise<T>
p.finally();
>p.finally() : Promise<number>
>p.finally : (onfinally?: () => void) => Promise<number>
>p : Promise<number>
>finally : (onfinally?: () => void) => Promise<number>

View file

@ -0,0 +1,6 @@
// @target: es2018
const test = Object.assign({}, { test: true });
const p: Promise<number>;
p.finally();