mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
94 lines
2.0 KiB
TypeScript
94 lines
2.0 KiB
TypeScript
//// [tests/cases/compiler/capturedLetConstInLoop10.ts] ////
|
|
|
|
//// [capturedLetConstInLoop10.ts]
|
|
class A {
|
|
foo() {
|
|
for (let x of [0]) {
|
|
let f = function() { return x; };
|
|
this.bar(f());
|
|
}
|
|
}
|
|
bar(a: number) {
|
|
}
|
|
|
|
baz() {
|
|
for (let x of [1]) {
|
|
let a = function() { return x; };
|
|
for (let y of [1]) {
|
|
let b = function() { return y; };
|
|
this.bar(b());
|
|
}
|
|
this.bar(a());
|
|
}
|
|
}
|
|
baz2() {
|
|
for (let x of [1]) {
|
|
let a = function() { return x; };
|
|
this.bar(a());
|
|
for (let y of [1]) {
|
|
let b = function() { return y; };
|
|
this.bar(b());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class B {
|
|
foo() {
|
|
let a =
|
|
() => {
|
|
for (let x of [0]) {
|
|
let f = () => x;
|
|
this.bar(f());
|
|
}
|
|
}
|
|
}
|
|
bar(a: number) {
|
|
}
|
|
}
|
|
|
|
//// [capturedLetConstInLoop10.js]
|
|
"use strict";
|
|
class A {
|
|
foo() {
|
|
for (let x of [0]) {
|
|
let f = function () { return x; };
|
|
this.bar(f());
|
|
}
|
|
}
|
|
bar(a) {
|
|
}
|
|
baz() {
|
|
for (let x of [1]) {
|
|
let a = function () { return x; };
|
|
for (let y of [1]) {
|
|
let b = function () { return y; };
|
|
this.bar(b());
|
|
}
|
|
this.bar(a());
|
|
}
|
|
}
|
|
baz2() {
|
|
for (let x of [1]) {
|
|
let a = function () { return x; };
|
|
this.bar(a());
|
|
for (let y of [1]) {
|
|
let b = function () { return y; };
|
|
this.bar(b());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
class B {
|
|
foo() {
|
|
let a = () => {
|
|
for (let x of [0]) {
|
|
let f = () => x;
|
|
this.bar(f());
|
|
}
|
|
};
|
|
}
|
|
bar(a) {
|
|
}
|
|
}
|