typeGuardsInGlobal.ts(7,12): error TS2454: Variable 'var1' is used before being assigned.
typeGuardsInGlobal.ts(11,5): error TS2322: Type 'string | number' is not assignable to type 'number'.
  Type 'string' is not assignable to type 'number'.
typeGuardsInGlobal.ts(11,11): error TS2454: Variable 'var1' is used before being assigned.


==== typeGuardsInGlobal.ts (3 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;
    if (typeof var1 === "string") {
               ~~~~
!!! error TS2454: Variable 'var1' is used before being assigned.
        num = var1.length; // string
    }
    else {
        num = var1; // number
        ~~~
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
!!! error TS2322:   Type 'string' is not assignable to type 'number'.
              ~~~~
!!! error TS2454: Variable 'var1' is used before being assigned.
    }
    