typeGuardsInFunction.ts(10,5): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(14,5): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(14,18): error TS2454: Variable 'var2' is used before being assigned.
typeGuardsInFunction.ts(17,5): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(24,9): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(27,9): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(30,9): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(34,9): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(34,22): error TS2454: Variable 'var3' is used before being assigned.
typeGuardsInFunction.ts(35,9): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(45,9): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(48,9): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(48,22): error TS2454: Variable 'var2' is used before being assigned.
typeGuardsInFunction.ts(51,9): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(55,9): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(55,22): error TS2454: Variable 'var3' is used before being assigned.
typeGuardsInFunction.ts(56,9): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(66,9): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(69,9): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(69,22): error TS2454: Variable 'var2' is used before being assigned.
typeGuardsInFunction.ts(72,9): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(76,9): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(76,22): error TS2454: Variable 'var3' is used before being assigned.
typeGuardsInFunction.ts(77,9): error TS2322: Type 'number | false' is not assignable to type 'number'.
  Type 'boolean' is not assignable to type 'number'.
typeGuardsInFunction.ts(87,1): error TS2322: Type 'string | number | false' is not assignable to type 'string | number'.
  Type 'boolean' is not assignable to type 'string | number'.


==== typeGuardsInFunction.ts (25 errors) ====
    // Note that type guards affect types of variables and parameters only and 
    // have no effect on members of objects such as properties. 
    
    // variables in global
    var num: number;
    var var1: string | number;
    // Inside function declaration
    function f(param: string | number) {
        // global vars in function declaration
        num =  typeof var1 === "string" && var1.length; // string
        ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
    
        // variables in function declaration
        var var2: string | number;
        num = typeof var2 === "string" && var2.length; // string
        ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
                     ~~~~
!!! error TS2454: Variable 'var2' is used before being assigned.
    
        // parameters in function declaration
        num = typeof param === "string" && param.length; // string
        ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
    }
    // local function declaration
    function f1(param: string | number) {
        var var2: string | number;
        function f2(param1: string | number) {
            // global vars in function declaration
            num = typeof var1 === "string" && var1.length; // string
            ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
    
            // variables from outer function declaration
            num = typeof var2 === "string" && var2.length; // string
            ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
    
            // parameters in outer declaration
            num = typeof param === "string" && param.length; // string
            ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
    
            // local
            var var3: string | number;
            num = typeof var3 === "string" && var3.length; // string
            ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
                         ~~~~
!!! error TS2454: Variable 'var3' is used before being assigned.
            num = typeof param1 === "string" && param1.length; // string
            ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
        }
    }
    // Function expression
    function f2(param: string | number) {
        // variables in function declaration
        var var2: string | number;
        // variables in function expressions
        var r = function (param1: string | number) {
            // global vars in function declaration
            num = typeof var1 === "string" && var1.length; // string
            ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
    
            // variables from outer function declaration
            num = typeof var2 === "string" && var2.length; // string
            ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
                         ~~~~
!!! error TS2454: Variable 'var2' is used before being assigned.
    
            // parameters in outer declaration
            num = typeof param === "string" && param.length; // string
            ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
    
            // local
            var var3: string | number;
            num = typeof var3 === "string" && var3.length; // string
            ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
                         ~~~~
!!! error TS2454: Variable 'var3' is used before being assigned.
            num = typeof param1 === "string" && param1.length; // string
            ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
        } (param);
    }
    // Arrow expression
    function f3(param: string | number) {
        // variables in function declaration
        var var2: string | number;
        // variables in function expressions
        var r = ((param1: string | number) => {
            // global vars in function declaration
            num = typeof var1 === "string" && var1.length; // string
            ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
    
            // variables from outer function declaration
            num = typeof var2 === "string" && var2.length; // string
            ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
                         ~~~~
!!! error TS2454: Variable 'var2' is used before being assigned.
    
            // parameters in outer declaration
            num = typeof param === "string" && param.length; // string
            ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
    
            // local
            var var3: string | number;
            num = typeof var3 === "string" && var3.length; // string
            ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
                         ~~~~
!!! error TS2454: Variable 'var3' is used before being assigned.
            num = typeof param1 === "string" && param1.length; // string
            ~~~
!!! error TS2322: Type 'number | false' is not assignable to type 'number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'number'.
        })(param);
    }
    // Return type of function
    // Inside function declaration
    var strOrNum: string | number;
    function f4() {
        var var2: string | number = strOrNum;
        return var2;
    }
    strOrNum = typeof f4() === "string" && f4(); // string | number 
    ~~~~~~~~
!!! error TS2322: Type 'string | number | false' is not assignable to type 'string | number'.
!!! error TS2322:   Type 'boolean' is not assignable to type 'string | number'.