57 lines
1 KiB
Text
57 lines
1 KiB
Text
=== tests/cases/compiler/cyclicTypeInstantiation.ts ===
|
|
function foo<T>() {
|
|
>foo : <T>() => { a: T; b: any; }
|
|
>T : T
|
|
|
|
var x: {
|
|
>x : { a: T; b: any; }
|
|
|
|
a: T;
|
|
>a : T
|
|
>T : T
|
|
|
|
b: typeof x;
|
|
>b : { a: T; b: any; }
|
|
>x : { a: T; b: any; }
|
|
|
|
};
|
|
return x;
|
|
>x : { a: T; b: any; }
|
|
}
|
|
|
|
function bar<T>() {
|
|
>bar : <T>() => { a: T; b: any; }
|
|
>T : T
|
|
|
|
var x: {
|
|
>x : { a: T; b: any; }
|
|
|
|
a: T;
|
|
>a : T
|
|
>T : T
|
|
|
|
b: typeof x;
|
|
>b : { a: T; b: any; }
|
|
>x : { a: T; b: any; }
|
|
|
|
};
|
|
return x;
|
|
>x : { a: T; b: any; }
|
|
}
|
|
|
|
var a = foo<string>();
|
|
>a : { a: string; b: any; }
|
|
>foo<string>() : { a: string; b: any; }
|
|
>foo : <T>() => { a: T; b: any; }
|
|
|
|
var b = bar<string>();
|
|
>b : { a: string; b: any; }
|
|
>bar<string>() : { a: string; b: any; }
|
|
>bar : <T>() => { a: T; b: any; }
|
|
|
|
// Relating types of a and b produces instantiations of the cyclic anonymous types in foo and bar
|
|
a = b;
|
|
>a = b : { a: string; b: any; }
|
|
>a : { a: string; b: any; }
|
|
>b : { a: string; b: any; }
|
|
|