Skip to content

Commit 60693fc

Browse files
committed
Formatting fixes
1 parent 7a2701b commit 60693fc

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed
-4.46 KB
Binary file not shown.

doc/spec.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# TypeScript Language Specification
22

3-
Version 1.3
3+
Version 1.4
44

55
October, 2014
66

@@ -2928,17 +2928,17 @@ function foo(x: number | string) {
29282928
29292929
The type of a variable or parameter is narrowed in the following situations:
29302930
2931-
* 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 true branch statement contains no assignments to the variable or parameter.
2932-
* 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 false branch statement contains no assignments to the variable or parameter.
2933-
* 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 true expression contains no assignments to the variable or parameter.
2934-
* 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 false expression contains no assignments to the variable or parameter.
2935-
* 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.
2936-
* 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.
2931+
* 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 true branch statement contains no assignments to the variable or parameter.
2932+
* 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 false branch statement contains no assignments to the variable or parameter.
2933+
* 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 true expression contains no assignments to the variable or parameter.
2934+
* 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 false expression contains no assignments to the variable or parameter.
2935+
* 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.
2936+
* 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.
29372937
29382938
A type guard is simply an expression that follows a particular pattern. The process of narrowing the type of a variable *x* by a type guard *when true* or *when false* depends on the type guard as follows:
29392939
29402940
* 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’
2941-
* *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
2941+
* *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
29422942
* *when false*, has no effect on the type of *x*.
29432943
* A type guard of the form `typeof x === s`, where *s* is a string literal with the value ‘string’, ‘number’, or ‘boolean’,
29442944
* *when true*, narrows the type of *x* to the given primitive type, or
@@ -2962,7 +2962,7 @@ A type guard is simply an expression that follows a particular pattern. The proc
29622962
29632963
A primitive type *P* is removed from a type *T* as follows:
29642964
2965-
* If *T* is a union type *P* | *T<sub>1</sub>* | *T<sub>2</sub>* | … | *T<sub>n</sub>*, the result is the type* T<sub>1</sub>* | *T<sub>2</sub>* | … | *T<sub>n</sub>*.
2965+
* If *T* is a union type *P* | *T<sub>1</sub>* | *T<sub>2</sub>* | … | *T<sub>n</sub>*, the result is the type *T<sub>1</sub>* | *T<sub>2</sub>* | … | *T<sub>n</sub>*.
29662966
* Otherwise, the result is *T*.
29672967
29682968
Note that type guards affect types of variables and parameters only and have no effect on members of objects such as properties. Also note that it is possible to defeat a type guard by calling a function that changes the type of the guarded variable.

0 commit comments

Comments
 (0)