subtypingWithObjectMembersOptionality2.ts(10,11): error TS2430: Interface 'S' incorrectly extends interface 'T'.
  Types of property 'Foo' are incompatible.
    Type 'Derived | undefined' is not assignable to type 'Base'.
      Type 'undefined' is not assignable to type 'Base'.
subtypingWithObjectMembersOptionality2.ts(18,11): error TS2430: Interface 'S2' incorrectly extends interface 'T2'.
  Types of property '1' are incompatible.
    Type 'Derived | undefined' is not assignable to type 'Base'.
      Type 'undefined' is not assignable to type 'Base'.
subtypingWithObjectMembersOptionality2.ts(26,11): error TS2430: Interface 'S3' incorrectly extends interface 'T3'.
  Types of property ''1'' are incompatible.
    Type 'Derived | undefined' is not assignable to type 'Base'.
      Type 'undefined' is not assignable to type 'Base'.


==== 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:   Types of property 'Foo' are incompatible.
!!! error TS2430:     Type 'Derived | undefined' is not assignable to type 'Base'.
!!! error TS2430:       Type 'undefined' is not assignable to type 'Base'.
        Foo?: Derived // error
    }
    
    interface T2 {
        1: Base;
    }
    
    interface S2 extends T2 {
              ~~
!!! error TS2430: Interface 'S2' incorrectly extends interface 'T2'.
!!! error TS2430:   Types of property '1' are incompatible.
!!! error TS2430:     Type 'Derived | undefined' is not assignable to type 'Base'.
!!! error TS2430:       Type 'undefined' is not assignable to type 'Base'.
        1?: Derived; // error
    }
    
    interface T3 {
        '1': Base;
    }
    
    interface S3 extends T3 {
              ~~
!!! error TS2430: Interface 'S3' incorrectly extends interface 'T3'.
!!! error TS2430:   Types of property ''1'' are incompatible.
!!! error TS2430:     Type 'Derived | undefined' is not assignable to type 'Base'.
!!! error TS2430:       Type 'undefined' is not assignable to type 'Base'.
        '1'?: Derived; // error
    }
    
    // object literal case
    declare var a: { Foo: Base; }
    declare var b: { Foo?: Derived; }
    var r = true ? a : b; // ok