tests/cases/conformance/types/spread/spreadUnion3.ts(2,5): error TS2322: Type '{ y: number; } | { y: string; }' is not assignable to type '{ y: string; }'.
  Type '{ y: number; }' is not assignable to type '{ y: string; }'.
    Types of property 'y' are incompatible.
      Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/spread/spreadUnion3.ts(9,23): error TS2339: Property 'a' does not exist on type '{}'.
tests/cases/conformance/types/spread/spreadUnion3.ts(17,11): error TS2698: Spread types may only be created from object types.
tests/cases/conformance/types/spread/spreadUnion3.ts(18,11): error TS2698: Spread types may only be created from object types.


==== tests/cases/conformance/types/spread/spreadUnion3.ts (4 errors) ====
    function f(x: { y: string } | undefined): { y: string } {
        return { y: 123, ...x } // y: string | number
        ~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type '{ y: number; } | { y: string; }' is not assignable to type '{ y: string; }'.
!!! error TS2322:   Type '{ y: number; }' is not assignable to type '{ y: string; }'.
!!! error TS2322:     Types of property 'y' are incompatible.
!!! error TS2322:       Type 'number' is not assignable to type 'string'.
    }
    f(undefined)
    
    
    function g(t?: { a: number } | null): void {
        let b = { ...t };
        let c: number = b.a;  // might not have 'a'
                          ~
!!! error TS2339: Property 'a' does not exist on type '{}'.
    }
    g()
    g(undefined)
    g(null)
    
    // spreading nothing but null and undefined is not allowed
    declare const nullAndUndefinedUnion: null | undefined;
    var x = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion };
              ~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2698: Spread types may only be created from object types.
    var y = { ...nullAndUndefinedUnion };
              ~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2698: Spread types may only be created from object types.
    