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
+4-4
Original file line number
Diff line number
Diff line change
@@ -262,7 +262,7 @@ function f() {
262
262
263
263
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.
264
264
265
-
   
265
+
  
266
266
267
267
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.
268
268
@@ -410,7 +410,7 @@ This signature denotes that a function may be passed as the parameter of the '$'
410
410
411
411
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.
412
412
413
-
   
413
+
  
414
414
415
415
Section [3.3](#3.3) provides additional information about object types.
416
416
@@ -627,7 +627,7 @@ An important goal of TypeScript is to provide accurate and straightforward types
627
627
628
628
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.
629
629
630
-
   
630
+
  
631
631
632
632
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.
640
640
641
-
   
641
+
  
642
642
643
643
Section [3.9.2.4](#3.9.2.4) provides details on how to use string literals in function signatures.
0 commit comments