|
| 1 | +=== tests/cases/compiler/argumentsAsPropertyName.ts === |
| 2 | +// target: es5 |
| 3 | +type MyType = { |
| 4 | +>MyType : Symbol(MyType, Decl(argumentsAsPropertyName.ts, 0, 0)) |
| 5 | + |
| 6 | + arguments: Array<string> |
| 7 | +>arguments : Symbol(arguments, Decl(argumentsAsPropertyName.ts, 1, 15)) |
| 8 | +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) |
| 9 | +} |
| 10 | + |
| 11 | +declare function use(s: any); |
| 12 | +>use : Symbol(use, Decl(argumentsAsPropertyName.ts, 3, 1)) |
| 13 | +>s : Symbol(s, Decl(argumentsAsPropertyName.ts, 5, 21)) |
| 14 | + |
| 15 | +function myFunction(myType: MyType) { |
| 16 | +>myFunction : Symbol(myFunction, Decl(argumentsAsPropertyName.ts, 5, 29)) |
| 17 | +>myType : Symbol(myType, Decl(argumentsAsPropertyName.ts, 7, 20)) |
| 18 | +>MyType : Symbol(MyType, Decl(argumentsAsPropertyName.ts, 0, 0)) |
| 19 | + |
| 20 | + for (let i = 0; i < 10; i++) { |
| 21 | +>i : Symbol(i, Decl(argumentsAsPropertyName.ts, 8, 12)) |
| 22 | +>i : Symbol(i, Decl(argumentsAsPropertyName.ts, 8, 12)) |
| 23 | +>i : Symbol(i, Decl(argumentsAsPropertyName.ts, 8, 12)) |
| 24 | + |
| 25 | + use(myType.arguments[i]); |
| 26 | +>use : Symbol(use, Decl(argumentsAsPropertyName.ts, 3, 1)) |
| 27 | +>myType.arguments : Symbol(arguments, Decl(argumentsAsPropertyName.ts, 1, 15)) |
| 28 | +>myType : Symbol(myType, Decl(argumentsAsPropertyName.ts, 7, 20)) |
| 29 | +>arguments : Symbol(arguments, Decl(argumentsAsPropertyName.ts, 1, 15)) |
| 30 | +>i : Symbol(i, Decl(argumentsAsPropertyName.ts, 8, 12)) |
| 31 | + |
| 32 | + // create closure so that tsc will turn loop body into function |
| 33 | + const x = 5; |
| 34 | +>x : Symbol(x, Decl(argumentsAsPropertyName.ts, 11, 13)) |
| 35 | + |
| 36 | + [1, 2, 3].forEach(function(j) { use(x); }) |
| 37 | +>[1, 2, 3].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) |
| 38 | +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) |
| 39 | +>j : Symbol(j, Decl(argumentsAsPropertyName.ts, 12, 35)) |
| 40 | +>use : Symbol(use, Decl(argumentsAsPropertyName.ts, 3, 1)) |
| 41 | +>x : Symbol(x, Decl(argumentsAsPropertyName.ts, 11, 13)) |
| 42 | + } |
| 43 | +} |
0 commit comments