2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithOptionalProperties.ts ===
|
|
|
|
// subtyping is not transitive due to optional properties but the subtyping algorithm assumes it is for the 99% case
|
|
|
|
|
|
|
|
// returns { s?: number; }
|
|
|
|
function f<T>(a: T) {
|
|
|
|
>f : <T>(a: T) => { s?: number; }
|
|
|
|
>T : T
|
|
|
|
>a : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
var b: { s?: number } = a;
|
|
|
|
>b : { s?: number; }
|
|
|
|
>s : number
|
|
|
|
>a : T
|
|
|
|
|
|
|
|
return b;
|
|
|
|
>b : { s?: number; }
|
|
|
|
}
|
|
|
|
|
|
|
|
var r = f({ s: new Object() }); // ok
|
|
|
|
>r : { s?: number; }
|
|
|
|
>f({ s: new Object() }) : { s?: number; }
|
|
|
|
>f : <T>(a: T) => { s?: number; }
|
|
|
|
>{ s: new Object() } : { s: Object; }
|
|
|
|
>s : Object
|
|
|
|
>new Object() : Object
|
2014-10-29 05:21:47 +01:00
|
|
|
>Object : ObjectConstructor
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
r.s && r.s.toFixed(); // would blow up at runtime
|
|
|
|
>r.s && r.s.toFixed() : string
|
|
|
|
>r.s : number
|
|
|
|
>r : { s?: number; }
|
|
|
|
>s : number
|
|
|
|
>r.s.toFixed() : string
|
|
|
|
>r.s.toFixed : (fractionDigits?: number) => string
|
|
|
|
>r.s : number
|
|
|
|
>r : { s?: number; }
|
|
|
|
>s : number
|
|
|
|
>toFixed : (fractionDigits?: number) => string
|
|
|
|
|