You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/spec.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -265,7 +265,7 @@ function f() {
265
265
266
266
To benefit from this inference, a programmer can use the TypeScript language service. For example, a code editor can incorporate the TypeScript language service and use the service to find the members of a string object as in the following screen shot.
267
267
268
-
  
268
+
  
269
269
270
270
In this example, the programmer benefits from type inference without providing type annotations. Some beneficial tools, however, do require the programmer to provide type annotations. In TypeScript, we can express a parameter requirement as in the following code fragment.
271
271
@@ -413,7 +413,7 @@ This signature denotes that a function may be passed as the parameter of the '$'
413
413
414
414
A typical client would not need to add any additional typing but could just use a community-supplied typing to discover (through statement completion with documentation tips) and verify (through static checking) correct use of the library, as in the following screen shot.
415
415
416
-
  
416
+
  
417
417
418
418
Section [3.3](#3.3) provides additional information about object types.
419
419
@@ -630,7 +630,7 @@ An important goal of TypeScript is to provide accurate and straightforward types
630
630
631
631
JavaScript programming interfaces often include functions whose behavior is discriminated by a string constant passed to the function. The Document Object Model makes heavy use of this pattern. For example, the following screen shot shows that the 'createElement' method of the 'document' object has multiple signatures, some of which identify the types returned when specific strings are passed into the method.
632
632
633
-
  
633
+
  
634
634
635
635
The following code fragment uses this feature. Because the 'span' variable is inferred to have the type 'HTMLSpanElement', the code can reference without static error the 'isMultiline' property of 'span'.
In the following screen shot, a programming tool combines information from overloading on string parameters with contextual typing to infer that the type of the variable 'e' is 'MouseEvent' and that therefore 'e' has a 'clientX' property.
643
643
644
-
  
644
+
  
645
645
646
646
Section [3.9.2.4](#3.9.2.4) provides details on how to use string literals in function signatures.
647
647
@@ -2630,7 +2630,7 @@ Each element expression in a non-empty array literal is processed as follows:
2630
2630
2631
2631
The resulting type an array literal expression is determined as follows:
2632
2632
2633
-
* If the array literal is empty, the resulting type is an array type with the element type Undefined.
2633
+
* If the array literal is empty, the resulting type is an empty tuple type in `granularConst` mode, otherwise an array type with the element type Undefined.
2634
2634
* Otherwise, if the array literal contains no spread elements and is contextually typed by a tuple-like type (section [3.3.3](#3.3.3)), the resulting type is a tuple type constructed from the types of the element expressions.
2635
2635
* Otherwise, if the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section [4.21.1](#4.21.1)), the resulting type is a tuple type constructed from the types of the element expressions.
2636
2636
* Otherwise, the resulting type is an array type with an element type that is the union of the types of the non-spread element expressions and the numeric index signature types of the spread element expressions.
0 commit comments