2014-07-13 01:04:16 +02:00
|
|
|
//// [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) {
|
|
|
|
var b: { s?: number } = a;
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
var r = f({ s: new Object() }); // ok
|
|
|
|
r.s && r.s.toFixed(); // would blow up at runtime
|
|
|
|
|
|
|
|
//// [subtypingWithOptionalProperties.js]
|
2014-08-14 15:21:30 +02:00
|
|
|
// subtyping is not transitive due to optional properties but the subtyping algorithm assumes it is for the 99% case
|
|
|
|
// returns { s?: number; }
|
2014-07-13 01:04:16 +02:00
|
|
|
function f(a) {
|
|
|
|
var b = a;
|
|
|
|
return b;
|
|
|
|
}
|
2014-08-15 22:18:54 +02:00
|
|
|
var r = f({ s: new Object() }); // ok
|
2014-08-16 00:49:09 +02:00
|
|
|
r.s && r.s.toFixed(); // would blow up at runtime
|