tests/cases/compiler/inKeywordTypeguard.ts(6,11): error TS2339: Property 'b' does not exist on type 'A'.
tests/cases/compiler/inKeywordTypeguard.ts(8,11): error TS2339: Property 'a' does not exist on type 'B'.
tests/cases/compiler/inKeywordTypeguard.ts(14,11): error TS2339: Property 'b' does not exist on type 'A'.
tests/cases/compiler/inKeywordTypeguard.ts(16,11): error TS2339: Property 'a' does not exist on type 'B'.
tests/cases/compiler/inKeywordTypeguard.ts(27,11): error TS2339: Property 'b' does not exist on type 'AWithOptionalProp | BWithOptionalProp'.
  Property 'b' does not exist on type 'AWithOptionalProp'.
tests/cases/compiler/inKeywordTypeguard.ts(42,11): error TS2339: Property 'b' does not exist on type 'AWithMethod'.
tests/cases/compiler/inKeywordTypeguard.ts(49,11): error TS2339: Property 'a' does not exist on type '(AWithMethod | BWithMethod) & Record<"c", unknown>'.
  Property 'a' does not exist on type 'BWithMethod & Record<"c", unknown>'.
tests/cases/compiler/inKeywordTypeguard.ts(50,11): error TS2339: Property 'b' does not exist on type '(AWithMethod | BWithMethod) & Record<"c", unknown>'.
  Property 'b' does not exist on type 'AWithMethod & Record<"c", unknown>'.
tests/cases/compiler/inKeywordTypeguard.ts(52,11): error TS2339: Property 'a' does not exist on type 'AWithMethod | BWithMethod'.
  Property 'a' does not exist on type 'BWithMethod'.
tests/cases/compiler/inKeywordTypeguard.ts(53,11): error TS2339: Property 'b' does not exist on type 'AWithMethod | BWithMethod'.
  Property 'b' does not exist on type 'AWithMethod'.
tests/cases/compiler/inKeywordTypeguard.ts(62,11): error TS2339: Property 'b' does not exist on type 'A | C | D'.
  Property 'b' does not exist on type 'A'.
tests/cases/compiler/inKeywordTypeguard.ts(64,11): error TS2339: Property 'a' does not exist on type 'B'.
tests/cases/compiler/inKeywordTypeguard.ts(72,32): error TS2339: Property 'b' does not exist on type 'A'.
tests/cases/compiler/inKeywordTypeguard.ts(74,32): error TS2339: Property 'a' does not exist on type 'B'.
tests/cases/compiler/inKeywordTypeguard.ts(82,39): error TS2339: Property 'b' does not exist on type 'A'.
tests/cases/compiler/inKeywordTypeguard.ts(84,39): error TS2339: Property 'a' does not exist on type 'B'.
tests/cases/compiler/inKeywordTypeguard.ts(94,26): error TS2339: Property 'a' does not exist on type 'never'.
tests/cases/compiler/inKeywordTypeguard.ts(155,16): error TS2322: Type 'unknown' is not assignable to type 'object'.
tests/cases/compiler/inKeywordTypeguard.ts(158,21): error TS2322: Type 'unknown' is not assignable to type 'object'.
tests/cases/compiler/inKeywordTypeguard.ts(183,16): error TS2322: Type 'T' is not assignable to type 'object'.
tests/cases/compiler/inKeywordTypeguard.ts(186,21): error TS2322: Type 'T' is not assignable to type 'object'.


==== tests/cases/compiler/inKeywordTypeguard.ts (21 errors) ====
    class A { a: string; }
    class B { b: string; }
    
    function negativeClassesTest(x: A | B) {
        if ("a" in x) {
            x.b = "1";
              ~
!!! error TS2339: Property 'b' does not exist on type 'A'.
        } else {
            x.a = "1";
              ~
!!! error TS2339: Property 'a' does not exist on type 'B'.
        }
    }
    
    function positiveClassesTest(x: A | B) {
        if ("a" in x) {
            x.b = "1";
              ~
!!! error TS2339: Property 'b' does not exist on type 'A'.
        } else {
            x.a = "1";
              ~
!!! error TS2339: Property 'a' does not exist on type 'B'.
        }
    }
    
    class AWithOptionalProp { a?: string; }
    class BWithOptionalProp { b?: string; }
    
    function positiveTestClassesWithOptionalProperties(x: AWithOptionalProp | BWithOptionalProp) {
        if ("a" in x) {
            x.a = "1";
        } else {
            x.b = "1";
              ~
!!! error TS2339: Property 'b' does not exist on type 'AWithOptionalProp | BWithOptionalProp'.
!!! error TS2339:   Property 'b' does not exist on type 'AWithOptionalProp'.
        }
    }
    
    class AWithMethod {
        a(): string { return ""; }
    }
    
    class BWithMethod {
        b(): string { return ""; }
    }
    
    function negativeTestClassesWithMembers(x: AWithMethod | BWithMethod) {
        if ("a" in x) {
            x.a();
            x.b();
              ~
!!! error TS2339: Property 'b' does not exist on type 'AWithMethod'.
        } else {
        }
    }
    
    function negativeTestClassesWithMemberMissingInBothClasses(x: AWithMethod | BWithMethod) {
        if ("c" in x) {
            x.a();
              ~
!!! error TS2339: Property 'a' does not exist on type '(AWithMethod | BWithMethod) & Record<"c", unknown>'.
!!! error TS2339:   Property 'a' does not exist on type 'BWithMethod & Record<"c", unknown>'.
            x.b();
              ~
!!! error TS2339: Property 'b' does not exist on type '(AWithMethod | BWithMethod) & Record<"c", unknown>'.
!!! error TS2339:   Property 'b' does not exist on type 'AWithMethod & Record<"c", unknown>'.
        } else {
            x.a();
              ~
!!! error TS2339: Property 'a' does not exist on type 'AWithMethod | BWithMethod'.
!!! error TS2339:   Property 'a' does not exist on type 'BWithMethod'.
            x.b();
              ~
!!! error TS2339: Property 'b' does not exist on type 'AWithMethod | BWithMethod'.
!!! error TS2339:   Property 'b' does not exist on type 'AWithMethod'.
        }
    }
    
    class C { a: string; }
    class D { a: string; }
    
    function negativeMultipleClassesTest(x: A | B | C | D) {
        if ("a" in x) {
            x.b = "1";
              ~
!!! error TS2339: Property 'b' does not exist on type 'A | C | D'.
!!! error TS2339:   Property 'b' does not exist on type 'A'.
        } else {
            x.a = "1";
              ~
!!! error TS2339: Property 'a' does not exist on type 'B'.
        }
    }
    
    class ClassWithUnionProp { prop: A | B }
    
    function negativePropTest(x: ClassWithUnionProp) {
        if ("a" in x.prop) {
            let y: string = x.prop.b;
                                   ~
!!! error TS2339: Property 'b' does not exist on type 'A'.
        } else {
            let z: string = x.prop.a;
                                   ~
!!! error TS2339: Property 'a' does not exist on type 'B'.
        }
    }
    
    class NegativeClassTest {
        protected prop: A | B;
        inThis() {
            if ("a" in this.prop) {
                let z: number = this.prop.b;
                                          ~
!!! error TS2339: Property 'b' does not exist on type 'A'.
            } else {
                let y: string = this.prop.a;
                                          ~
!!! error TS2339: Property 'a' does not exist on type 'B'.
            }
        }
    }
    
    class UnreachableCodeDetection {
        a: string;
        inThis() {
            if ("a" in this) {
            } else {
                let y = this.a;
                             ~
!!! error TS2339: Property 'a' does not exist on type 'never'.
            }
        }
    }
    
    function positiveIntersectionTest(x: { a: string } & { b: string }) {
        if ("a" in x) {
            let s: string = x.a;
        } else {
            let n: never = x;
        }
    }
    
    // Repro from #38608
    declare const error: Error;
    if ('extra' in error) {
        error // Still Error
    } else {
        error // Error
    }
    
    function narrowsToNever(x: { l: number } | { r: number }) {
        let v: number;
        if ("l" in x) {
            v = x.l;
        }
        else if ("r" in x) {
            v = x.r;
        }
        else {
            v = x
        }
        return v;
    }
    
    type AOrB = { aProp: number } | { bProp: number };
    declare function isAOrB(x: unknown): x is AOrB;
    
    declare var x: unknown;
    if (isAOrB(x)) {
        if ("aProp" in x) {
            x.aProp;
        }
        else if ("bProp" in x) {
            x.bProp;
        }
        // x is never because of the type predicate from unknown
        else if ("cProp" in x) {
            const _never: never = x;
        }
    }
    
    function negativeIntersectionTest() {
        if ("ontouchstart" in window) {
            window.ontouchstart
        } else {
            window.ontouchstart
        }
    }
    
    function f1(x: unknown) {
        if ("a" in x) {
                   ~
!!! error TS2322: Type 'unknown' is not assignable to type 'object'.
            x.a;
        }
        if (x && "a" in x) {
                        ~
!!! error TS2322: Type 'unknown' is not assignable to type 'object'.
            x.a;
        }
        if (x && typeof x === "object" && "a" in x) {
            x.a;
        }
        if (x && typeof x === "object" && "a" in x && "b" in x && "c" in x) {
            x.a;
            x.b;
            x.c;
        }
    }
    
    function f2(x: object) {
        if ("a" in x) {
            x.a;
        }
        if ("a" in x && "b" in x && "c" in x) {
            x.a;
            x.b;
            x.c;
        }
    }
    
    function f3<T>(x: T) {
        if ("a" in x) {
                   ~
!!! error TS2322: Type 'T' is not assignable to type 'object'.
!!! related TS2208 tests/cases/compiler/inKeywordTypeguard.ts:182:13: This type parameter might need an `extends object` constraint.
            x.a;
        }
        if (x && "a" in x) {
                        ~
!!! error TS2322: Type 'T' is not assignable to type 'object'.
!!! related TS2208 tests/cases/compiler/inKeywordTypeguard.ts:182:13: This type parameter might need an `extends object` constraint.
            x.a;
        }
        if (x && typeof x === "object" && "a" in x) {
            x.a;
        }
        if (x && typeof x === "object" && "a" in x && "b" in x && "c" in x) {
            x.a;
            x.b;
            x.c;
        }
    }
    
    function f4(x: { a: string }) {
        if ("a" in x) {
            x.a;
        }
        if ("a" in x && "b" in x && "c" in x) {
            x.a;
            x.b;
            x.c;
        }
    }
    
    function f5(x: { a: string } | { b: string }) {
        if ("a" in x) {
            x;  // { a: string }
        }
        else if ("b" in x) {
            x;  // { b: string }
        }
        else {
            x;  // never
        }
    }
    
    function f6(x: { a: string } | { b: string }) {
        if ("a" in x) {
            x;  // { a: string }
        }
        else if ("a" in x) {
            x;  // { b: string } & Record<"a", unknown>
        }
        else {
            x;  // { b: string }
        }
    }
    
    // Object and corresponding intersection should narrow the same
    
    function f7(x: { a: string, b: number }, y: { a: string } & { b: number }) {
        if ("a" in x) {
            x;
        }
        else {
            x;  // never
        }
        if ("a" in y) {
            y;
        }
        else {
            y;  // never
        }
    }
    
    const sym = Symbol();
    
    function f8(x: object) {
        if ("a" in x && 1 in x && sym in x) {
            x.a;
            x["a"];
            x[1];
            x["1"];
            x[sym];
        }
    }
    
    function f9(x: object) {
        if ("a" in x && "1" in x && sym in x) {
            x.a;
            x["a"];
            x[1];
            x["1"];
            x[sym];
        }
    }
    
    function f10(x: { a: unknown }) {
        if ("a" in x) {
            x;
        }
        else {
            x;
        }
    }
    
    function f11(x: { a: any }) {
        if ("a" in x) {
            x;
        }
        else {
            x;
        }
    }
    
    function f12(x: { a: string }) {
        if ("a" in x) {
            x;
        }
        else {
            x;
        }
    }
    
    function f13(x: { a?: string }) {
        if ("a" in x) {
            x;
        }
        else {
            x;
        }
    }
    
    function f14(x: { a: string | undefined }) {
        if ("a" in x) {
            x;
        }
        else {
            x;
        }
    }
    
    function f15(x: { a?: string | undefined }) {
        if ("a" in x) {
            x;
        }
        else {
            x;
        }
    }
    
    function f16(x: typeof globalThis, y: Window & typeof globalThis) {
        x = y;
    }
    
    // Repro from #50639
    
    function foo<A>(value: A) {
        if (typeof value === "object" && value !== null && "prop" in value) {
            value;  // A & object & Record<"prop", unknown>
        }
    }
    
    // Repro from #50954
    
    const checkIsTouchDevice = () =>
        "ontouchstart" in window || "msMaxTouchPoints" in window.navigator;
    
    // Repro from #51501
    
    function isHTMLTable<T extends object | null>(table: T): boolean {
        return !!table && 'html' in table;
    }
    
    // Repro from #51549
    
    const f = <P extends object>(a: P & {}) => {
        "foo" in a;
    };
    