unionAndIntersectionInference1.ts(4,12): error TS2352: Conversion of type 'undefined' to type 'Y' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
unionAndIntersectionInference1.ts(13,44): error TS2352: Conversion of type 'undefined' to type 'Y' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
unionAndIntersectionInference1.ts(20,5): error TS2322: Type 'undefined' is not assignable to type 'boolean'.
unionAndIntersectionInference1.ts(24,5): error TS2322: Type 'undefined' is not assignable to type 'boolean'.
unionAndIntersectionInference1.ts(48,4): error TS2322: Type 'null' is not assignable to type 'U'.
  'U' could be instantiated with an arbitrary type which could be unrelated to 'null'.
unionAndIntersectionInference1.ts(52,5): error TS2454: Variable 'foo' is used before being assigned.
unionAndIntersectionInference1.ts(95,52): error TS2769: No overload matches this call.
  Overload 1 of 4, '(target: {}, source: U): {} & U', gave the following error.
    Argument of type 'T' is not assignable to parameter of type '{}'.
  Overload 2 of 4, '(target: object, ...sources: any[]): any', gave the following error.
    Argument of type 'T' is not assignable to parameter of type 'object'.
unionAndIntersectionInference1.ts(96,7): error TS2322: Type '{ func: <T>() => void; }' is not assignable to type '(() => void) & { func: any; }'.
  Type '{ func: <T>() => void; }' is not assignable to type '() => void'.
    Type '{ func: <T>() => void; }' provides no match for the signature '(): void'.


==== unionAndIntersectionInference1.ts (8 errors) ====
    // Repro from #2264
    
    interface Y { 'i am a very certain type': Y }
    var y: Y = <Y>undefined;
               ~~~~~~~~~~~~
!!! error TS2352: Conversion of type 'undefined' to type 'Y' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
    function destructure<a, r>(
        something: a | Y,
        haveValue: (value: a) => r,
        haveY: (value: Y) => r
    ): r {
        return something === y ? haveY(y) : haveValue(<a>something);
    }
    
    var value = Math.random() > 0.5 ? 'hey!' : <Y>undefined;
                                               ~~~~~~~~~~~~
!!! error TS2352: Conversion of type 'undefined' to type 'Y' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
    
    var result = destructure(value, text => 'string', y => 'other one'); // text: string, y: Y
    
    // Repro from #4212
    
    function isVoid<a>(value: void | a): value is void {
        return undefined;
        ~~~~~~
!!! error TS2322: Type 'undefined' is not assignable to type 'boolean'.
    }
    
    function isNonVoid<a>(value: void | a) : value is a {
        return undefined;
        ~~~~~~
!!! error TS2322: Type 'undefined' is not assignable to type 'boolean'.
    }
    
    function foo1<a>(value: void|a): void {
        if (isVoid(value)) {
            value; // value is void
        } else {
            value; // value is a
        }
    }
    
    function baz1<a>(value: void|a): void {
          if (isNonVoid(value)) {
              value; // value is a
          } else {
              value; // value is void
          }
    }
    
    // Repro from #5417
    
    type Maybe<T> = T | void;
    
    function get<U>(x: U | void): U {
       return null; // just an example
       ~~~~~~
!!! error TS2322: Type 'null' is not assignable to type 'U'.
!!! error TS2322:   'U' could be instantiated with an arbitrary type which could be unrelated to 'null'.
    }
    
    let foo: Maybe<string>;
    get(foo).toUpperCase(); // Ok
        ~~~
!!! error TS2454: Variable 'foo' is used before being assigned.
    
    // Repro from #5456
    
    interface Man {
        walks: boolean;
    }
    
    interface Bear {
        roars: boolean;
    }
    
    interface Pig {
        oinks: boolean;
    }
    
    declare function pigify<T>(y: T & Bear): T & Pig;
    declare var mbp: Man & Bear;
    
    pigify(mbp).oinks; // OK, mbp is treated as Pig
    pigify(mbp).walks; // Ok, mbp is treated as Man
    
    // Repros from #29815
    
    interface ITest {
      name: 'test'
    }
    
    const createTestAsync = (): Promise<ITest> => Promise.resolve().then(() => ({ name: 'test' }))
    
    const createTest = (): ITest => {
      return { name: 'test' }
    }
    
    declare function f1<T, U>(x: T | U): T | U;
    declare function f2<T, U>(x: T, y: U): T | U;
    
    let x1: string = f1('a');
    let x2: string = f2('a', 'b');
    
    // Repro from #30442
    
    const func = <T>() => {};
    const assign = <T, U>(a: T, b: U) => Object.assign(a, b);
                                                       ~
!!! error TS2769: No overload matches this call.
!!! error TS2769:   Overload 1 of 4, '(target: {}, source: U): {} & U', gave the following error.
!!! error TS2769:     Argument of type 'T' is not assignable to parameter of type '{}'.
!!! error TS2769:   Overload 2 of 4, '(target: object, ...sources: any[]): any', gave the following error.
!!! error TS2769:     Argument of type 'T' is not assignable to parameter of type 'object'.
!!! related TS2208 unionAndIntersectionInference1.ts:95:17: This type parameter might need an `extends {}` constraint.
!!! related TS2208 unionAndIntersectionInference1.ts:95:17: This type parameter might need an `extends object` constraint.
    const res: (() => void) & { func: any } = assign(() => {}, { func });
          ~~~
!!! error TS2322: Type '{ func: <T>() => void; }' is not assignable to type '(() => void) & { func: any; }'.
!!! error TS2322:   Type '{ func: <T>() => void; }' is not assignable to type '() => void'.
!!! error TS2322:     Type '{ func: <T>() => void; }' provides no match for the signature '(): void'.
    