Skip to content

Commit b33d5e3

Browse files
committed
Fix #24826: Add mapping for ES2018 target to library
1 parent 7df8131 commit b33d5e3

File tree

6 files changed

+67
-0
lines changed

6 files changed

+67
-0
lines changed

src/compiler/utilities.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4177,6 +4177,8 @@ namespace ts {
41774177
switch (options.target) {
41784178
case ScriptTarget.ESNext:
41794179
return "lib.esnext.full.d.ts";
4180+
case ScriptTarget.ES2018:
4181+
return "lib.es2018.full.d.ts";
41804182
case ScriptTarget.ES2017:
41814183
return "lib.es2017.full.d.ts";
41824184
case ScriptTarget.ES2016:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests/cases/compiler/es2018ObjectAssign.ts(3,7): error TS1155: 'const' declarations must be initialized.
2+
3+
4+
==== tests/cases/compiler/es2018ObjectAssign.ts (1 errors) ====
5+
const test = Object.assign({}, { test: true });
6+
7+
const p: Promise<number>;
8+
~
9+
!!! error TS1155: 'const' declarations must be initialized.
10+
p.finally();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//// [es2018ObjectAssign.ts]
2+
const test = Object.assign({}, { test: true });
3+
4+
const p: Promise<number>;
5+
p.finally();
6+
7+
//// [es2018ObjectAssign.js]
8+
const test = Object.assign({}, { test: true });
9+
const p;
10+
p.finally();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
=== tests/cases/compiler/es2018ObjectAssign.ts ===
2+
const test = Object.assign({}, { test: true });
3+
>test : Symbol(test, Decl(es2018ObjectAssign.ts, 0, 5))
4+
>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, --, --))
5+
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
6+
>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, --, --))
7+
>test : Symbol(test, Decl(es2018ObjectAssign.ts, 0, 32))
8+
9+
const p: Promise<number>;
10+
>p : Symbol(p, Decl(es2018ObjectAssign.ts, 2, 5))
11+
>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, --, --))
12+
13+
p.finally();
14+
>p.finally : Symbol(Promise.finally, Decl(lib.es2018.promise.d.ts, --, --))
15+
>p : Symbol(p, Decl(es2018ObjectAssign.ts, 2, 5))
16+
>finally : Symbol(Promise.finally, Decl(lib.es2018.promise.d.ts, --, --))
17+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=== tests/cases/compiler/es2018ObjectAssign.ts ===
2+
const test = Object.assign({}, { test: true });
3+
>test : { test: boolean; }
4+
>Object.assign({}, { test: true }) : { test: boolean; }
5+
>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; }
6+
>Object : ObjectConstructor
7+
>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; }
8+
>{} : {}
9+
>{ test: true } : { test: true; }
10+
>test : true
11+
>true : true
12+
13+
const p: Promise<number>;
14+
>p : Promise<number>
15+
>Promise : Promise<T>
16+
17+
p.finally();
18+
>p.finally() : Promise<number>
19+
>p.finally : (onfinally?: () => void) => Promise<number>
20+
>p : Promise<number>
21+
>finally : (onfinally?: () => void) => Promise<number>
22+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @target: es2018
2+
3+
const test = Object.assign({}, { test: true });
4+
5+
const p: Promise<number>;
6+
p.finally();

0 commit comments

Comments
 (0)