1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts(10,11): error TS2430: Interface 'S' incorrectly extends interface 'T'.
Property 'Foo' is optional in type 'S' but required in type 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts(18,11): error TS2430: Interface 'S2' incorrectly extends interface 'T2'.
Property '1' is optional in type 'S2' but required in type 'T2'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts(26,11): error TS2430: Interface 'S3' incorrectly extends interface 'T3'.
Property ''1'' is optional in type 'S3' but required in type 'T3'.
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts (3 errors) ====
// 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 {
~
!!! error TS2430: Interface 'S' incorrectly extends interface 'T'.
!!! error TS2430: Property 'Foo' is optional in type 'S' but required in type 'T'.
Foo?: Derived // error
}
interface T2 {
1: Base;
}
interface S2 extends T2 {
~~
!!! error TS2430: Interface 'S2' incorrectly extends interface 'T2'.
!!! error TS2430: Property '1' is optional in type 'S2' but required in type 'T2'.
1?: Derived; // error
}
interface T3 {
'1': Base;
}
interface S3 extends T3 {
~~
!!! error TS2430: Interface 'S3' incorrectly extends interface 'T3'.
!!! error TS2430: Property ''1'' is optional in type 'S3' but required in type 'T3'.
'1'?: Derived; // error
}
// object literal case
var a: { Foo: Base; }
var b: { Foo?: Derived; }
var r = true ? a : b; // ok
|