tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(15,12): error TS2322: Type 'string' is not assignable to type 'boolean'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(22,33): error TS2304: Cannot find name 'x'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(26,33): error TS1225: Cannot find parameter 'x'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(30,10): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(31,5): error TS1131: Property or signature expected.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(32,1): error TS1128: Declaration or statement expected.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(34,38): error TS1225: Cannot find parameter 'x'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(38,51): error TS2322: Type 'B' is not assignable to type 'A'.
  Property 'propA' is missing in type 'B'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(42,56): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(46,56): error TS2322: Type 'T[]' is not assignable to type 'string'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(60,7): error TS2339: Property 'propB' does not exist on type 'A'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(65,7): error TS2339: Property 'propB' does not exist on type 'A'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(70,7): error TS2339: Property 'propB' does not exist on type 'A'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(75,46): error TS2345: Argument of type '(p1: any) => p1 is C' is not assignable to parameter of type '(p1: any) => p1 is B'.
  Type predicate 'p1 is C' is not assignable to 'p1 is B'.
    Type 'C' is not assignable to type 'B'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(79,1): error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => p1 is A'.
  Signature '(p1: any, p2: any): boolean' must have a type predicate.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(85,1): error TS2322: Type '(p1: any, p2: any) => p2 is A' is not assignable to type '(p1: any, p2: any) => p1 is A'.
  Type predicate 'p2 is A' is not assignable to 'p1 is A'.
    Parameter 'p2' is not in the same position as parameter 'p1'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(91,1): error TS2322: Type '(p1: any, p2: any, p3: any) => p1 is A' is not assignable to type '(p1: any, p2: any) => p1 is A'.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,9): error TS1228: A type predicate is only allowed in return type position for functions and methods.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,16): error TS1228: A type predicate is only allowed in return type position for functions and methods.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,20): error TS1228: A type predicate is only allowed in return type position for functions and methods.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(104,25): error TS1228: A type predicate is only allowed in return type position for functions and methods.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(107,20): error TS1228: A type predicate is only allowed in return type position for functions and methods.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(110,20): error TS1228: A type predicate is only allowed in return type position for functions and methods.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(111,16): error TS2408: Setters cannot return a value.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(116,18): error TS1228: A type predicate is only allowed in return type position for functions and methods.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,22): error TS1228: A type predicate is only allowed in return type position for functions and methods.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(124,20): error TS1229: A type predicate cannot reference a rest parameter.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(129,34): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(133,34): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern.
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern.


==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (31 errors) ====
    
    class A {
        propA: number;
    }
    
    class B {
        propB: number;
    }
    
    class C extends A {
        propC: number;
    }
    
    function hasANonBooleanReturnStatement(x): x is A {
        return '';
               ~~
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
    }
    
    function hasTypeGuardTypeInsideTypeGuardType(x): x is x is A {
        return true;
    }
    
    function hasMissingIsKeyword(): x {
                                    ~
!!! error TS2304: Cannot find name 'x'.
        return true;
    }
    
    function hasMissingParameter(): x is A {
                                    ~
!!! error TS1225: Cannot find parameter 'x'.
        return true;
    }
    
    function hasMissingTypeInTypeGuardType(x): x is {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
        return true;
        ~~~~~~
!!! error TS1131: Property or signature expected.
    }
    ~
!!! error TS1128: Declaration or statement expected.
    
    function hasNonMatchingParameter(y): x is A {
                                         ~
!!! error TS1225: Cannot find parameter 'x'.
        return true;
    }
    
    function hasNonMatchingParameterType1(x: A): x is B {
                                                      ~
!!! error TS2322: Type 'B' is not assignable to type 'A'.
!!! error TS2322:   Property 'propA' is missing in type 'B'.
        return true;
    }
    
    function hasNonMatchingParameterType2(x: string): x is number {
                                                           ~~~~~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
        return true;
    }
    
    function hasNonMathcingGenericType<T>(a: string): a is T[] {
                                                           ~~~
!!! error TS2322: Type 'T[]' is not assignable to type 'string'.
        return true;
    }
    
    let a: A;
    let b: B;
    
    declare function isB(p1): p1 is B;
    declare function isC(p1): p1 is C;
    declare function funA(p1: any, p2: any): p1 is B;
    declare function hasNoTypeGuard(x);
    
    // Passed argument is not the same as the one being guarded.
    if (isB(b)) {
        a.propB;
          ~~~~~
!!! error TS2339: Property 'propB' does not exist on type 'A'.
    }
    
    // Parameter index and argument index for the type guard target is not matching.
    if (funA(0, a)) {
        a.propB; // Error
          ~~~~~
!!! error TS2339: Property 'propB' does not exist on type 'A'.
    }
    
    // No type guard in if statement
    if (hasNoTypeGuard(a)) {
        a.propB; 
          ~~~~~
!!! error TS2339: Property 'propB' does not exist on type 'A'.
    }
    
    // Type predicate type is not assignable
    declare function acceptingDifferentSignatureTypeGuardFunction(p1: (p1) => p1 is B);
    acceptingDifferentSignatureTypeGuardFunction(isC);
                                                 ~~~
!!! error TS2345: Argument of type '(p1: any) => p1 is C' is not assignable to parameter of type '(p1: any) => p1 is B'.
!!! error TS2345:   Type predicate 'p1 is C' is not assignable to 'p1 is B'.
!!! error TS2345:     Type 'C' is not assignable to type 'B'.
    
    // Boolean not assignable to type guard
    var assign1: (p1, p2) => p1 is A;
    assign1 = function(p1, p2): boolean {
    ~~~~~~~
!!! error TS2322: Type '(p1: any, p2: any) => boolean' is not assignable to type '(p1: any, p2: any) => p1 is A'.
!!! error TS2322:   Signature '(p1: any, p2: any): boolean' must have a type predicate.
        return true;
    };
    
    // Must have matching parameter index
    var assign2: (p1, p2) => p1 is A;
    assign2 = function(p1, p2): p2 is A {
    ~~~~~~~
!!! error TS2322: Type '(p1: any, p2: any) => p2 is A' is not assignable to type '(p1: any, p2: any) => p1 is A'.
!!! error TS2322:   Type predicate 'p2 is A' is not assignable to 'p1 is A'.
!!! error TS2322:     Parameter 'p2' is not in the same position as parameter 'p1'.
        return true;
    };
    
    // No matching signature 
    var assign3: (p1, p2) => p1 is A;
    assign3 = function(p1, p2, p3): p1 is A {
    ~~~~~~~
!!! error TS2322: Type '(p1: any, p2: any, p3: any) => p1 is A' is not assignable to type '(p1: any, p2: any) => p1 is A'.
        return true;
    };
    
    // Type predicates in non-return type positions
    var b1: b is A;
            ~~~~~~
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
    function b2(a: b is A) {};
                   ~~~~~~
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
    function b3(): A | b is A {
                       ~~~~~~
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
        return true;
    };
    
    // Non-compatiable type predicate positions for signature declarations
    class D {
        constructor(p1: A): p1 is C {
                            ~~~~~~~
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
            return true;
                   ~~~~
!!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class
        }
        get m1(p1: A): p1 is C {
                       ~~~~~~~
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
            return true;
        }
        set m2(p1: A): p1 is C {
                       ~~~~~~~
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
            return true;
                   ~~~~
!!! error TS2408: Setters cannot return a value.
        }
    }
    
    interface I1 {
        new (p1: A): p1 is C;
                     ~~~~~~~
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
    }
    
    interface I2 {
        [index: number]: p1 is C;
                         ~~~~~~~
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
    }
    
    // Reference to rest parameter
    function b4(...a): a is A {
                       ~
!!! error TS1229: A type predicate cannot reference a rest parameter.
        return true;
    }
    
    // Reference to binding pattern
    function b5({a, b, p1}, p2, p3): p1 is A {
                                     ~~
!!! error TS1230: A type predicate cannot reference element 'p1' in a binding pattern.
        return true;
    }
    
    function b6([a, b, p1], p2, p3): p1 is A {
                                     ~~
!!! error TS1230: A type predicate cannot reference element 'p1' in a binding pattern.
        return true;
    }
    
    function b7({a, b, c: {p1}}, p2, p3): p1 is A {
                                          ~~
!!! error TS1230: A type predicate cannot reference element 'p1' in a binding pattern.
        return true;
    }
    
    // Should not crash the compiler
    var x: A;
    if (hasMissingParameter()) {
        x.propA;
    }