2014-07-13 01:04:16 +02:00
|
|
|
//// [subtypingWithObjectMembersOptionality2.ts]
|
|
|
|
// Derived member is optional but base member is not, should be an error
|
|
|
|
|
|
|
|
interface Base { foo: string; }
|
|
|
|
interface Derived extends Base { bar: string; }
|
|
|
|
|
|
|
|
interface T {
|
|
|
|
Foo: Base;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface S extends T {
|
|
|
|
Foo?: Derived // error
|
|
|
|
}
|
|
|
|
|
|
|
|
interface T2 {
|
|
|
|
1: Base;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface S2 extends T2 {
|
|
|
|
1?: Derived; // error
|
|
|
|
}
|
|
|
|
|
|
|
|
interface T3 {
|
|
|
|
'1': Base;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface S3 extends T3 {
|
|
|
|
'1'?: Derived; // error
|
|
|
|
}
|
|
|
|
|
|
|
|
// object literal case
|
|
|
|
var a: { Foo: Base; }
|
|
|
|
var b: { Foo?: Derived; }
|
|
|
|
var r = true ? a : b; // error
|
|
|
|
|
|
|
|
//// [subtypingWithObjectMembersOptionality2.js]
|
2014-08-12 00:54:12 +02:00
|
|
|
// object literal case
|
2014-07-13 01:04:16 +02:00
|
|
|
var a;
|
|
|
|
var b;
|
2014-08-15 23:32:08 +02:00
|
|
|
var r = true ? a : b; // error
|