diff --git a/tests/baselines/reference/classExpressionWithStaticProperties1.js b/tests/baselines/reference/classExpressionWithStaticProperties1.js index 23d18d76766..205f59367cc 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties1.js +++ b/tests/baselines/reference/classExpressionWithStaticProperties1.js @@ -1,5 +1,9 @@ //// [classExpressionWithStaticProperties1.ts] -var v = class C { static a = 1; static b = 2 }; +var v = class C { + static a = 1; + static b = 2; + static c = C.a + C.b; +}; //// [classExpressionWithStaticProperties1.js] var v = (_a = (function () { @@ -9,5 +13,6 @@ var v = (_a = (function () { }()), _a.a = 1, _a.b = 2, + _a.c = _a.a + _a.b, _a); var _a; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties1.symbols b/tests/baselines/reference/classExpressionWithStaticProperties1.symbols index d4c811daebe..f8b3c270ea9 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties1.symbols +++ b/tests/baselines/reference/classExpressionWithStaticProperties1.symbols @@ -1,7 +1,21 @@ === tests/cases/compiler/classExpressionWithStaticProperties1.ts === -var v = class C { static a = 1; static b = 2 }; +var v = class C { >v : Symbol(v, Decl(classExpressionWithStaticProperties1.ts, 0, 3)) >C : Symbol(C, Decl(classExpressionWithStaticProperties1.ts, 0, 7)) ->a : Symbol(C.a, Decl(classExpressionWithStaticProperties1.ts, 0, 17)) ->b : Symbol(C.b, Decl(classExpressionWithStaticProperties1.ts, 0, 31)) + static a = 1; +>a : Symbol(C.a, Decl(classExpressionWithStaticProperties1.ts, 0, 17)) + + static b = 2; +>b : Symbol(C.b, Decl(classExpressionWithStaticProperties1.ts, 1, 17)) + + static c = C.a + C.b; +>c : Symbol(C.c, Decl(classExpressionWithStaticProperties1.ts, 2, 17)) +>C.a : Symbol(C.a, Decl(classExpressionWithStaticProperties1.ts, 0, 17)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties1.ts, 0, 7)) +>a : Symbol(C.a, Decl(classExpressionWithStaticProperties1.ts, 0, 17)) +>C.b : Symbol(C.b, Decl(classExpressionWithStaticProperties1.ts, 1, 17)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties1.ts, 0, 7)) +>b : Symbol(C.b, Decl(classExpressionWithStaticProperties1.ts, 1, 17)) + +}; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties1.types b/tests/baselines/reference/classExpressionWithStaticProperties1.types index b014f78abf7..168bb028474 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties1.types +++ b/tests/baselines/reference/classExpressionWithStaticProperties1.types @@ -1,10 +1,25 @@ === tests/cases/compiler/classExpressionWithStaticProperties1.ts === -var v = class C { static a = 1; static b = 2 }; +var v = class C { >v : typeof C ->class C { static a = 1; static b = 2 } : typeof C +>class C { static a = 1; static b = 2; static c = C.a + C.b;} : typeof C >C : typeof C + + static a = 1; >a : number >1 : number + + static b = 2; >b : number >2 : number + static c = C.a + C.b; +>c : number +>C.a + C.b : number +>C.a : number +>C : typeof C +>a : number +>C.b : number +>C : typeof C +>b : number + +}; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties2.js b/tests/baselines/reference/classExpressionWithStaticProperties2.js index b9fc0345591..eb1c2da2e21 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties2.js +++ b/tests/baselines/reference/classExpressionWithStaticProperties2.js @@ -1,5 +1,12 @@ //// [classExpressionWithStaticProperties2.ts] -var v = class C { static a = 1; static b }; +var v = class C { + static a = 1; + static b + static c = { + x: "hi" + } + static d = C.c.x + " world"; + }; //// [classExpressionWithStaticProperties2.js] var v = (_a = (function () { @@ -8,5 +15,9 @@ var v = (_a = (function () { return C; }()), _a.a = 1, + _a.c = { + x: "hi" + }, + _a.d = _a.c.x + " world", _a); var _a; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties2.symbols b/tests/baselines/reference/classExpressionWithStaticProperties2.symbols index 480123a1c3b..981e1e258c7 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties2.symbols +++ b/tests/baselines/reference/classExpressionWithStaticProperties2.symbols @@ -1,7 +1,26 @@ === tests/cases/compiler/classExpressionWithStaticProperties2.ts === -var v = class C { static a = 1; static b }; +var v = class C { >v : Symbol(v, Decl(classExpressionWithStaticProperties2.ts, 0, 3)) >C : Symbol(C, Decl(classExpressionWithStaticProperties2.ts, 0, 7)) ->a : Symbol(C.a, Decl(classExpressionWithStaticProperties2.ts, 0, 17)) ->b : Symbol(C.b, Decl(classExpressionWithStaticProperties2.ts, 0, 31)) + static a = 1; +>a : Symbol(C.a, Decl(classExpressionWithStaticProperties2.ts, 0, 17)) + + static b +>b : Symbol(C.b, Decl(classExpressionWithStaticProperties2.ts, 1, 17)) + + static c = { +>c : Symbol(C.c, Decl(classExpressionWithStaticProperties2.ts, 2, 12)) + + x: "hi" +>x : Symbol(x, Decl(classExpressionWithStaticProperties2.ts, 3, 16)) + } + static d = C.c.x + " world"; +>d : Symbol(C.d, Decl(classExpressionWithStaticProperties2.ts, 5, 5)) +>C.c.x : Symbol(x, Decl(classExpressionWithStaticProperties2.ts, 3, 16)) +>C.c : Symbol(C.c, Decl(classExpressionWithStaticProperties2.ts, 2, 12)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties2.ts, 0, 7)) +>c : Symbol(C.c, Decl(classExpressionWithStaticProperties2.ts, 2, 12)) +>x : Symbol(x, Decl(classExpressionWithStaticProperties2.ts, 3, 16)) + + }; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties2.types b/tests/baselines/reference/classExpressionWithStaticProperties2.types index 9bfd6732350..221b4794111 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties2.types +++ b/tests/baselines/reference/classExpressionWithStaticProperties2.types @@ -1,9 +1,32 @@ === tests/cases/compiler/classExpressionWithStaticProperties2.ts === -var v = class C { static a = 1; static b }; +var v = class C { >v : typeof C ->class C { static a = 1; static b } : typeof C +>class C { static a = 1; static b static c = { x: "hi" } static d = C.c.x + " world"; } : typeof C >C : typeof C + + static a = 1; >a : number >1 : number + + static b >b : any + static c = { +>c : { x: string; } +>{ x: "hi" } : { x: string; } + + x: "hi" +>x : string +>"hi" : string + } + static d = C.c.x + " world"; +>d : string +>C.c.x + " world" : string +>C.c.x : string +>C.c : { x: string; } +>C : typeof C +>c : { x: string; } +>x : string +>" world" : string + + }; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties3.js b/tests/baselines/reference/classExpressionWithStaticProperties3.js new file mode 100644 index 00000000000..7bec5fca167 --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticProperties3.js @@ -0,0 +1,29 @@ +//// [classExpressionWithStaticProperties3.ts] + +declare var console: any; +const arr: {y(): number}[] = []; +for (let i = 0; i < 3; i++) { + arr.push(class C { + static x = i; + static y = () => C.x * 2; + }); +} +arr.forEach(C => console.log(C.y())); + +//// [classExpressionWithStaticProperties3.js] +var arr = []; +var _loop_1 = function (i) { + arr.push((_a = (function () { + function C() { + } + return C; + }()), + _a.x = i, + _a.y = function () { return _a.x * 2; }, + _a)); +}; +for (var i = 0; i < 3; i++) { + _loop_1(i); +} +arr.forEach(function (C) { return console.log(C.y()); }); +var _a; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties3.symbols b/tests/baselines/reference/classExpressionWithStaticProperties3.symbols new file mode 100644 index 00000000000..ff9b7b0d311 --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticProperties3.symbols @@ -0,0 +1,42 @@ +=== tests/cases/compiler/classExpressionWithStaticProperties3.ts === + +declare var console: any; +>console : Symbol(console, Decl(classExpressionWithStaticProperties3.ts, 1, 11)) + +const arr: {y(): number}[] = []; +>arr : Symbol(arr, Decl(classExpressionWithStaticProperties3.ts, 2, 5)) +>y : Symbol(y, Decl(classExpressionWithStaticProperties3.ts, 2, 12)) + +for (let i = 0; i < 3; i++) { +>i : Symbol(i, Decl(classExpressionWithStaticProperties3.ts, 3, 8)) +>i : Symbol(i, Decl(classExpressionWithStaticProperties3.ts, 3, 8)) +>i : Symbol(i, Decl(classExpressionWithStaticProperties3.ts, 3, 8)) + + arr.push(class C { +>arr.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>arr : Symbol(arr, Decl(classExpressionWithStaticProperties3.ts, 2, 5)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties3.ts, 4, 13)) + + static x = i; +>x : Symbol(C.x, Decl(classExpressionWithStaticProperties3.ts, 4, 22)) +>i : Symbol(i, Decl(classExpressionWithStaticProperties3.ts, 3, 8)) + + static y = () => C.x * 2; +>y : Symbol(C.y, Decl(classExpressionWithStaticProperties3.ts, 5, 21)) +>C.x : Symbol(C.x, Decl(classExpressionWithStaticProperties3.ts, 4, 22)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties3.ts, 4, 13)) +>x : Symbol(C.x, Decl(classExpressionWithStaticProperties3.ts, 4, 22)) + + }); +} +arr.forEach(C => console.log(C.y())); +>arr.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>arr : Symbol(arr, Decl(classExpressionWithStaticProperties3.ts, 2, 5)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties3.ts, 9, 12)) +>console : Symbol(console, Decl(classExpressionWithStaticProperties3.ts, 1, 11)) +>C.y : Symbol(y, Decl(classExpressionWithStaticProperties3.ts, 2, 12)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties3.ts, 9, 12)) +>y : Symbol(y, Decl(classExpressionWithStaticProperties3.ts, 2, 12)) + diff --git a/tests/baselines/reference/classExpressionWithStaticProperties3.types b/tests/baselines/reference/classExpressionWithStaticProperties3.types new file mode 100644 index 00000000000..c6ff6d1b56b --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticProperties3.types @@ -0,0 +1,58 @@ +=== tests/cases/compiler/classExpressionWithStaticProperties3.ts === + +declare var console: any; +>console : any + +const arr: {y(): number}[] = []; +>arr : { y(): number; }[] +>y : () => number +>[] : undefined[] + +for (let i = 0; i < 3; i++) { +>i : number +>0 : number +>i < 3 : boolean +>i : number +>3 : number +>i++ : number +>i : number + + arr.push(class C { +>arr.push(class C { static x = i; static y = () => C.x * 2; }) : number +>arr.push : (...items: { y(): number; }[]) => number +>arr : { y(): number; }[] +>push : (...items: { y(): number; }[]) => number +>class C { static x = i; static y = () => C.x * 2; } : typeof C +>C : typeof C + + static x = i; +>x : number +>i : number + + static y = () => C.x * 2; +>y : () => number +>() => C.x * 2 : () => number +>C.x * 2 : number +>C.x : number +>C : typeof C +>x : number +>2 : number + + }); +} +arr.forEach(C => console.log(C.y())); +>arr.forEach(C => console.log(C.y())) : void +>arr.forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void +>arr : { y(): number; }[] +>forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void +>C => console.log(C.y()) : (C: { y(): number; }) => any +>C : { y(): number; } +>console.log(C.y()) : any +>console.log : any +>console : any +>log : any +>C.y() : number +>C.y : () => number +>C : { y(): number; } +>y : () => number + diff --git a/tests/cases/compiler/classExpressionWithStaticProperties1.ts b/tests/cases/compiler/classExpressionWithStaticProperties1.ts index 19fe035e6a7..79c669c32a9 100644 --- a/tests/cases/compiler/classExpressionWithStaticProperties1.ts +++ b/tests/cases/compiler/classExpressionWithStaticProperties1.ts @@ -1 +1,5 @@ -var v = class C { static a = 1; static b = 2 }; \ No newline at end of file +var v = class C { + static a = 1; + static b = 2; + static c = C.a + C.b; +}; \ No newline at end of file diff --git a/tests/cases/compiler/classExpressionWithStaticProperties2.ts b/tests/cases/compiler/classExpressionWithStaticProperties2.ts index f7b9606b6e0..353926e7abd 100644 --- a/tests/cases/compiler/classExpressionWithStaticProperties2.ts +++ b/tests/cases/compiler/classExpressionWithStaticProperties2.ts @@ -1 +1,9 @@ -var v = class C { static a = 1; static b }; \ No newline at end of file +//@target: es5 +var v = class C { + static a = 1; + static b + static c = { + x: "hi" + } + static d = C.c.x + " world"; + }; \ No newline at end of file diff --git a/tests/cases/compiler/classExpressionWithStaticProperties3.ts b/tests/cases/compiler/classExpressionWithStaticProperties3.ts new file mode 100644 index 00000000000..7c733c458be --- /dev/null +++ b/tests/cases/compiler/classExpressionWithStaticProperties3.ts @@ -0,0 +1,11 @@ +//@target: es5 + +declare var console: any; +const arr: {y(): number}[] = []; +for (let i = 0; i < 3; i++) { + arr.push(class C { + static x = i; + static y = () => C.x * 2; + }); +} +arr.forEach(C => console.log(C.y())); \ No newline at end of file