Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitde71002

Browse files
authored
Merge pull requestmicrosoft#13946 from Microsoft/AddTestFor13925
Add test formicrosoft#13925
2 parentsbb71dcd +f4080a4 commitde71002

File tree

4 files changed

+181
-0
lines changed

4 files changed

+181
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//// [capturedLetConstInLoop13.ts]
2+
classMain{
3+
4+
constructor(){
5+
this.register("a","b","c");
6+
}
7+
8+
privateregister(...names:string[]):void{
9+
for(letnameofnames){
10+
11+
this.bar({
12+
[name+".a"]:()=>{this.foo(name);},
13+
});
14+
}
15+
}
16+
17+
privatebar(a:any):void{}
18+
19+
privatefoo(name:string):void{}
20+
21+
}
22+
23+
newMain();
24+
25+
//// [capturedLetConstInLoop13.js]
26+
varMain=(function(){
27+
functionMain(){
28+
this.register("a","b","c");
29+
}
30+
Main.prototype.register=function(){
31+
var_this=this;
32+
varnames=[];
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+
varthis_1=this;
43+
for(var_a=0,names_1=names;_a<names_1.length;_a++){
44+
varname=names_1[_a];
45+
_loop_1(name);
46+
}
47+
};
48+
Main.prototype.bar=function(a){};
49+
Main.prototype.foo=function(name){};
50+
returnMain;
51+
}());
52+
newMain();
Lines 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+
Lines 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+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
classMain{
2+
3+
constructor(){
4+
this.register("a","b","c");
5+
}
6+
7+
privateregister(...names:string[]):void{
8+
for(letnameofnames){
9+
10+
this.bar({
11+
[name+".a"]:()=>{this.foo(name);},
12+
});
13+
}
14+
}
15+
16+
privatebar(a:any):void{}
17+
18+
privatefoo(name:string):void{}
19+
20+
}
21+
22+
newMain();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp