1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
=== tests/cases/compiler/argumentsAsPropertyName.ts ===
// target: es5
type MyType = {
>MyType : { arguments: Array<string>; }
arguments: Array<string>
>arguments : string[]
}
declare function use(s: any);
>use : (s: any) => any
>s : any
function myFunction(myType: MyType) {
>myFunction : (myType: MyType) => void
>myType : MyType
for (let i = 0; i < 10; i++) {
>i : number
>0 : 0
>i < 10 : boolean
>i : number
>10 : 10
>i++ : number
>i : number
use(myType.arguments[i]);
>use(myType.arguments[i]) : any
>use : (s: any) => any
>myType.arguments[i] : string
>myType.arguments : string[]
>myType : MyType
>arguments : string[]
>i : number
// create closure so that tsc will turn loop body into function
const x = 5;
>x : 5
>5 : 5
[1, 2, 3].forEach(function(j) { use(x); })
>[1, 2, 3].forEach(function(j) { use(x); }) : void
>[1, 2, 3].forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void
>[1, 2, 3] : number[]
>1 : 1
>2 : 2
>3 : 3
>forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void
>function(j) { use(x); } : (j: number) => void
>j : number
>use(x) : any
>use : (s: any) => any
>x : 5
}
}
|