35 lines
614 B
Text
35 lines
614 B
Text
=== tests/cases/compiler/genericObjectLitReturnType.ts ===
|
|
class X<T>
|
|
>X : X<T>
|
|
>T : T
|
|
{
|
|
f(t: T) { return { a: t }; }
|
|
>f : (t: T) => { a: T; }
|
|
>t : T
|
|
>T : T
|
|
>{ a: t } : { a: T; }
|
|
>a : T
|
|
>t : T
|
|
}
|
|
|
|
|
|
var x: X<number>;
|
|
>x : X<number>
|
|
>X : X<T>
|
|
|
|
var t1 = x.f(5);
|
|
>t1 : { a: number; }
|
|
>x.f(5) : { a: number; }
|
|
>x.f : (t: number) => { a: number; }
|
|
>x : X<number>
|
|
>f : (t: number) => { a: number; }
|
|
>5 : number
|
|
|
|
t1.a = 5; // Should not error: t1 should have type {a: number}, instead has type {a: T}
|
|
>t1.a = 5 : number
|
|
>t1.a : number
|
|
>t1 : { a: number; }
|
|
>a : number
|
|
>5 : number
|
|
|
|
|