36 lines
1.7 KiB
Plaintext
36 lines
1.7 KiB
Plaintext
=== 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 : Symbol(f, Decl(subtypingWithOptionalProperties.ts, 0, 0))
|
|
>T : Symbol(T, Decl(subtypingWithOptionalProperties.ts, 3, 11))
|
|
>a : Symbol(a, Decl(subtypingWithOptionalProperties.ts, 3, 14))
|
|
>T : Symbol(T, Decl(subtypingWithOptionalProperties.ts, 3, 11))
|
|
|
|
var b: { s?: number } = a;
|
|
>b : Symbol(b, Decl(subtypingWithOptionalProperties.ts, 4, 7))
|
|
>s : Symbol(s, Decl(subtypingWithOptionalProperties.ts, 4, 12))
|
|
>a : Symbol(a, Decl(subtypingWithOptionalProperties.ts, 3, 14))
|
|
|
|
return b;
|
|
>b : Symbol(b, Decl(subtypingWithOptionalProperties.ts, 4, 7))
|
|
}
|
|
|
|
var r = f({ s: new Object() }); // ok
|
|
>r : Symbol(r, Decl(subtypingWithOptionalProperties.ts, 8, 3))
|
|
>f : Symbol(f, Decl(subtypingWithOptionalProperties.ts, 0, 0))
|
|
>s : Symbol(s, Decl(subtypingWithOptionalProperties.ts, 8, 11))
|
|
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
|
|
|
|
r.s && r.s.toFixed(); // would blow up at runtime
|
|
>r.s : Symbol(s, Decl(subtypingWithOptionalProperties.ts, 4, 12))
|
|
>r : Symbol(r, Decl(subtypingWithOptionalProperties.ts, 8, 3))
|
|
>s : Symbol(s, Decl(subtypingWithOptionalProperties.ts, 4, 12))
|
|
>r.s.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, 463, 37))
|
|
>r.s : Symbol(s, Decl(subtypingWithOptionalProperties.ts, 4, 12))
|
|
>r : Symbol(r, Decl(subtypingWithOptionalProperties.ts, 8, 3))
|
|
>s : Symbol(s, Decl(subtypingWithOptionalProperties.ts, 4, 12))
|
|
>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, 463, 37))
|
|
|