Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit de71002

Browse filesBrowse files
authored
Merge pull request microsoft#13946 from Microsoft/AddTestFor13925
Add test for microsoft#13925
2 parents bb71dcd + f4080a4 commit de71002
Copy full SHA for de71002

4 files changed

+181Lines changed: 181 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+52Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//// [capturedLetConstInLoop13.ts]
2+
class Main {
3+
4+
constructor() {
5+
this.register("a", "b", "c");
6+
}
7+
8+
private register(...names: string[]): void {
9+
for (let name of names) {
10+
11+
this.bar({
12+
[name + ".a"]: () => { this.foo(name); },
13+
});
14+
}
15+
}
16+
17+
private bar(a: any): void { }
18+
19+
private foo(name: string): void { }
20+
21+
}
22+
23+
new Main();
24+
25+
//// [capturedLetConstInLoop13.js]
26+
var Main = (function () {
27+
function Main() {
28+
this.register("a", "b", "c");
29+
}
30+
Main.prototype.register = function () {
31+
var _this = this;
32+
var names = [];
33+
for (var _i = 0; _i < arguments.length; _i++) {
34+
names[_i] = arguments[_i];
35+
}
36+
var _loop_1 = function (name) {
37+
this_1.bar((_a = {},
38+
_a[name + ".a"] = function () { _this.foo(name); },
39+
_a));
40+
var _a;
41+
};
42+
var this_1 = this;
43+
for (var _a = 0, names_1 = names; _a < names_1.length; _a++) {
44+
var name = names_1[_a];
45+
_loop_1(name);
46+
}
47+
};
48+
Main.prototype.bar = function (a) { };
49+
Main.prototype.foo = function (name) { };
50+
return Main;
51+
}());
52+
new Main();
Collapse file
+48Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
=== tests/cases/compiler/capturedLetConstInLoop13.ts ===
2+
class Main {
3+
>Main : Symbol(Main, Decl(capturedLetConstInLoop13.ts, 0, 0))
4+
5+
constructor() {
6+
this.register("a", "b", "c");
7+
>this.register : Symbol(Main.register, Decl(capturedLetConstInLoop13.ts, 4, 5))
8+
>this : Symbol(Main, Decl(capturedLetConstInLoop13.ts, 0, 0))
9+
>register : Symbol(Main.register, Decl(capturedLetConstInLoop13.ts, 4, 5))
10+
}
11+
12+
private register(...names: string[]): void {
13+
>register : Symbol(Main.register, Decl(capturedLetConstInLoop13.ts, 4, 5))
14+
>names : Symbol(names, Decl(capturedLetConstInLoop13.ts, 6, 21))
15+
16+
for (let name of names) {
17+
>name : Symbol(name, Decl(capturedLetConstInLoop13.ts, 7, 16))
18+
>names : Symbol(names, Decl(capturedLetConstInLoop13.ts, 6, 21))
19+
20+
this.bar({
21+
>this.bar : Symbol(Main.bar, Decl(capturedLetConstInLoop13.ts, 13, 5))
22+
>this : Symbol(Main, Decl(capturedLetConstInLoop13.ts, 0, 0))
23+
>bar : Symbol(Main.bar, Decl(capturedLetConstInLoop13.ts, 13, 5))
24+
25+
[name + ".a"]: () => { this.foo(name); },
26+
>name : Symbol(name, Decl(capturedLetConstInLoop13.ts, 7, 16))
27+
>this.foo : Symbol(Main.foo, Decl(capturedLetConstInLoop13.ts, 15, 33))
28+
>this : Symbol(Main, Decl(capturedLetConstInLoop13.ts, 0, 0))
29+
>foo : Symbol(Main.foo, Decl(capturedLetConstInLoop13.ts, 15, 33))
30+
>name : Symbol(name, Decl(capturedLetConstInLoop13.ts, 7, 16))
31+
32+
});
33+
}
34+
}
35+
36+
private bar(a: any): void { }
37+
>bar : Symbol(Main.bar, Decl(capturedLetConstInLoop13.ts, 13, 5))
38+
>a : Symbol(a, Decl(capturedLetConstInLoop13.ts, 15, 16))
39+
40+
private foo(name: string): void { }
41+
>foo : Symbol(Main.foo, Decl(capturedLetConstInLoop13.ts, 15, 33))
42+
>name : Symbol(name, Decl(capturedLetConstInLoop13.ts, 17, 16))
43+
44+
}
45+
46+
new Main();
47+
>Main : Symbol(Main, Decl(capturedLetConstInLoop13.ts, 0, 0))
48+
Collapse file
+59Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
=== tests/cases/compiler/capturedLetConstInLoop13.ts ===
2+
class Main {
3+
>Main : Main
4+
5+
constructor() {
6+
this.register("a", "b", "c");
7+
>this.register("a", "b", "c") : void
8+
>this.register : (...names: string[]) => void
9+
>this : this
10+
>register : (...names: string[]) => void
11+
>"a" : "a"
12+
>"b" : "b"
13+
>"c" : "c"
14+
}
15+
16+
private register(...names: string[]): void {
17+
>register : (...names: string[]) => void
18+
>names : string[]
19+
20+
for (let name of names) {
21+
>name : string
22+
>names : string[]
23+
24+
this.bar({
25+
>this.bar({ [name + ".a"]: () => { this.foo(name); }, }) : void
26+
>this.bar : (a: any) => void
27+
>this : this
28+
>bar : (a: any) => void
29+
>{ [name + ".a"]: () => { this.foo(name); }, } : { [x: string]: () => void; }
30+
31+
[name + ".a"]: () => { this.foo(name); },
32+
>name + ".a" : string
33+
>name : string
34+
>".a" : ".a"
35+
>() => { this.foo(name); } : () => void
36+
>this.foo(name) : void
37+
>this.foo : (name: string) => void
38+
>this : this
39+
>foo : (name: string) => void
40+
>name : string
41+
42+
});
43+
}
44+
}
45+
46+
private bar(a: any): void { }
47+
>bar : (a: any) => void
48+
>a : any
49+
50+
private foo(name: string): void { }
51+
>foo : (name: string) => void
52+
>name : string
53+
54+
}
55+
56+
new Main();
57+
>new Main() : Main
58+
>Main : typeof Main
59+
Collapse file
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Main {
2+
3+
constructor() {
4+
this.register("a", "b", "c");
5+
}
6+
7+
private register(...names: string[]): void {
8+
for (let name of names) {
9+
10+
this.bar({
11+
[name + ".a"]: () => { this.foo(name); },
12+
});
13+
}
14+
}
15+
16+
private bar(a: any): void { }
17+
18+
private foo(name: string): void { }
19+
20+
}
21+
22+
new Main();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.