• 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.
• 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.
• 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.
• 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.
• 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.
• 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.
• 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.
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.