TypeGuards narrow types in if statement works per spec:

The type of a variable or parameter is narrowed in the following situations:
•	In the true branch statement of an ‘if’ statement, the type of a variable or parameter is narrowed by any type guard in the ‘if’ condition when true, provided the if statement contains no assignments to the variable or parameter.
•	In the false branch statement of an ‘if’ statement, the type of a variable or parameter is narrowed by any type guard in the ‘if’ condition when false, provided the if statement contains no assignments to the variable or parameter.
Test cases to make sure typeguard is defeated in case of function calls
From spec:
Also note that it is possible to defeat a type guard by calling a function that changes the type of the guarded variable.
Test cases for typeguards are scoped at function /module block
Tests for conditional expression typeguards
•	In the true expression of a conditional expression, the type of a variable or parameter is narrowed by any type guard in the condition when true, provided the expression contains no assignments to the variable or parameter.
•	In the false expression of a conditional expression, the type of a variable or parameter is narrowed by any type guard in the condition when false, provided the expression contains no assignments to the variable or parameter.
TypeGuards in right operand of && operation
•	In the right operand of a && operation, the type of a variable or parameter is narrowed by any type guard in the left operand when true, provided the right operand contains no assignments to the variable or parameter.
Type guards in || operator
•	In the right operand of a || operation, the type of a variable or parameter is narrowed by any type guard in the left operand when false, provided the right operand contains no assignments to the variable or parameter.
Tests for typeguards allowed on variables and parameters only
From spec:
Note that type guards affect types of variables and parameters only and have no effect on members of objects such as properties
Test typeguard of form instance of
•	A type guard of the form x instanceof C, where C is of a subtype of the global type ‘Function’ and C has a property named ‘prototype’
o	when true, narrows the type of x to the type of the ‘prototype’ property in C provided it is a subtype of the type of x, or
o	when false, has no effect on the type of x.
Test cases for typeguards of form typeof x === s and typeof x !== s
•	A type guard of the form typeof x === s, where s is a string literal with the value ‘string’, ‘number’, or ‘boolean’,
o	when true, narrows the type of x to the given primitive type, or
o	when false, removes the primitive type from the type of x.
•	A type guard of the form typeof x === s, where s is a string literal with any value but ‘string’, ‘number’, or ‘boolean’,
o	when true, removes the primitive types string, number, and boolean from the type of x, or
o	when false, has no effect on the type of x.
•	A type guard of the form typeof x !== s, where s is a string literal,
o	when true, narrows the type of x by typeof x === s when false, or
o	when false, narrows the type of x by typeof x === s when true.
TypeGuard of for expr1 && expr2
•	A type guard of the form expr1 && expr2
o	when true, narrows the type of x by expr1 when true and then by expr2 when true, or
o	when false, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when false, and T2 is the type of x narrowed by expr1 when true and then by expr2 when false.
Typeguards of form expr1 || expr2
•	A type guard of the form expr1 || expr2
o	when true, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when true, and T2 is the type of x narrowed by expr1 when false and then by expr2 when true, or
o	when false, narrows the type of x by expr1 when false and then by expr2 when false.
Typeguards of form !expr
•	A type guard of the form !expr
o	when true, narrows the type of x by expr when false, or
o	when false, narrows the type of x by expr when true.
Merge branch 'master' into typeGuardConformance
Add test case for instance of type guard with interface with prototype property
Add test cases for typeof x == s and typeof x != s form of typeguard which has no effect on narrowing type
Merge pull request #1077 from Microsoft/typeGuardConformance

Type guard conformance