Preface |
|
xvii | |
|
|
|
1 From JavaScript to TypeScript |
|
|
3 | (14) |
|
|
3 | (1) |
|
Vanilla JavaScript's Pitfalls |
|
|
4 | (1) |
|
|
4 | (1) |
|
|
4 | (1) |
|
|
5 | (1) |
|
|
6 | (1) |
|
Getting Started in the TypeScript Playground |
|
|
6 | (1) |
|
|
6 | (1) |
|
Freedom Through Restriction |
|
|
7 | (1) |
|
|
8 | (1) |
|
Stronger Developer Tooling |
|
|
8 | (2) |
|
|
10 | (1) |
|
|
10 | (1) |
|
|
11 | (1) |
|
|
12 | (1) |
|
|
12 | (1) |
|
|
12 | (1) |
|
Extensions to JavaScript (Mostly) |
|
|
13 | (1) |
|
|
13 | (1) |
|
|
14 | (1) |
|
|
14 | (3) |
|
|
17 | (12) |
|
|
17 | (2) |
|
|
19 | (1) |
|
|
20 | (1) |
|
|
21 | (1) |
|
Understanding Assignability Errors |
|
|
22 | (1) |
|
|
22 | (2) |
|
Unnecessary Type Annotations |
|
|
24 | (1) |
|
|
24 | (1) |
|
|
25 | (2) |
|
|
27 | (2) |
|
|
29 | (14) |
|
|
29 | (1) |
|
|
30 | (1) |
|
|
30 | (1) |
|
|
31 | (1) |
|
|
31 | (1) |
|
|
32 | (1) |
|
|
33 | (1) |
|
|
33 | (2) |
|
|
35 | (1) |
|
|
36 | (1) |
|
The Billion-Dollar Mistake |
|
|
36 | (1) |
|
|
37 | (1) |
|
Variables Without Initial Values |
|
|
38 | (1) |
|
|
39 | (1) |
|
Type Aliases Are Not JavaScript |
|
|
39 | (1) |
|
|
40 | (1) |
|
|
40 | (3) |
|
|
43 | (18) |
|
|
43 | (1) |
|
|
44 | (1) |
|
|
45 | (1) |
|
|
45 | (1) |
|
|
46 | (1) |
|
|
47 | (1) |
|
|
48 | (2) |
|
|
50 | (1) |
|
|
51 | (1) |
|
Inferred Object-Type Unions |
|
|
51 | (1) |
|
Explicit Object-Type Unions |
|
|
52 | (1) |
|
|
53 | (1) |
|
|
53 | (1) |
|
|
54 | (1) |
|
Dangers of Intersection Types |
|
|
55 | (2) |
|
|
57 | (4) |
|
|
|
|
61 | (14) |
|
|
61 | (1) |
|
|
62 | (1) |
|
|
63 | (1) |
|
|
64 | (1) |
|
|
64 | (1) |
|
|
65 | (1) |
|
|
66 | (1) |
|
|
67 | (1) |
|
Function Type Parentheses |
|
|
68 | (1) |
|
Parameter Type Inferences |
|
|
69 | (1) |
|
|
69 | (1) |
|
|
70 | (1) |
|
|
70 | (2) |
|
|
72 | (1) |
|
|
72 | (1) |
|
Call-Signature Compatibility |
|
|
73 | (1) |
|
|
74 | (1) |
|
|
75 | (12) |
|
|
76 | (1) |
|
|
76 | (1) |
|
|
76 | (1) |
|
|
77 | (1) |
|
|
78 | (1) |
|
|
78 | (1) |
|
|
79 | (1) |
|
|
79 | (1) |
|
|
79 | (1) |
|
Spreading Rest Parameters |
|
|
80 | (1) |
|
|
80 | (1) |
|
|
81 | (2) |
|
|
83 | (2) |
|
|
85 | (2) |
|
|
87 | (16) |
|
Type Aliases Versus Interfaces |
|
|
87 | (2) |
|
|
89 | (1) |
|
|
89 | (1) |
|
|
90 | (1) |
|
|
91 | (1) |
|
|
92 | (1) |
|
|
93 | (3) |
|
|
96 | (1) |
|
|
97 | (1) |
|
|
98 | (1) |
|
Extending Multiple Interfaces |
|
|
99 | (1) |
|
|
99 | (1) |
|
|
100 | (1) |
|
|
101 | (2) |
|
|
103 | (22) |
|
|
103 | (1) |
|
|
104 | (1) |
|
|
105 | (1) |
|
|
106 | (2) |
|
|
108 | (1) |
|
|
108 | (1) |
|
|
109 | (2) |
|
|
111 | (1) |
|
Implementing Multiple Interfaces |
|
|
112 | (2) |
|
|
114 | (1) |
|
|
114 | (2) |
|
|
116 | (1) |
|
|
117 | (1) |
|
|
118 | (1) |
|
|
119 | (1) |
|
|
120 | (2) |
|
|
122 | (1) |
|
|
123 | (2) |
|
|
125 | (16) |
|
|
125 | (1) |
|
|
125 | (1) |
|
|
126 | (1) |
|
|
127 | (2) |
|
|
129 | (1) |
|
|
129 | (2) |
|
|
131 | (1) |
|
|
132 | (1) |
|
Asserting Caught Error Types |
|
|
133 | (1) |
|
|
134 | (1) |
|
|
135 | (2) |
|
|
137 | (1) |
|
|
137 | (2) |
|
|
139 | (1) |
|
|
140 | (1) |
|
|
141 | (24) |
|
|
142 | (1) |
|
Explicit Generic Call Types |
|
|
143 | (1) |
|
Multiple Function Type Parameters |
|
|
144 | (1) |
|
|
145 | (1) |
|
Inferred Generic Interface Types |
|
|
146 | (1) |
|
|
147 | (1) |
|
Explicit Generic Class Types |
|
|
148 | (1) |
|
Extending Generic Classes |
|
|
149 | (1) |
|
Implementing Generic Interfaces |
|
|
150 | (1) |
|
|
151 | (1) |
|
|
152 | (1) |
|
|
152 | (1) |
|
Generic Discriminated Unions |
|
|
153 | (1) |
|
|
154 | (1) |
|
|
154 | (1) |
|
Constrained Generic Types |
|
|
155 | (1) |
|
Keyof and Constrained Type Parameters |
|
|
156 | (1) |
|
|
157 | (1) |
|
|
157 | (1) |
|
|
158 | (1) |
|
|
159 | (1) |
|
The Golden Rule of Generics |
|
|
159 | (1) |
|
Generic Naming Conventions |
|
|
160 | (1) |
|
|
161 | (4) |
|
|
|
|
165 | (16) |
|
|
165 | (1) |
|
|
166 | (2) |
|
|
168 | (1) |
|
|
168 | (1) |
|
|
169 | (1) |
|
|
170 | (1) |
|
|
170 | (2) |
|
|
172 | (1) |
|
|
173 | (1) |
|
Wildcard Module Declarations |
|
|
174 | (1) |
|
|
174 | (1) |
|
|
174 | (1) |
|
|
175 | (1) |
|
|
176 | (1) |
|
|
177 | (1) |
|
|
178 | (1) |
|
|
179 | (2) |
|
|
181 | (18) |
|
|
182 | (1) |
|
|
183 | (1) |
|
|
184 | (1) |
|
|
185 | (1) |
|
|
186 | (1) |
|
|
186 | (1) |
|
|
187 | (1) |
|
|
188 | (3) |
|
Working Effectively with Errors |
|
|
191 | (1) |
|
|
192 | (5) |
|
|
197 | (2) |
|
|
199 | (36) |
|
|
199 | (1) |
|
|
200 | (1) |
|
|
200 | (1) |
|
|
201 | (1) |
|
|
202 | (1) |
|
|
202 | (1) |
|
|
203 | (1) |
|
|
203 | (1) |
|
|
204 | (1) |
|
|
204 | (1) |
|
|
204 | (2) |
|
|
206 | (1) |
|
|
207 | (1) |
|
|
207 | (1) |
|
|
208 | (1) |
|
|
209 | (1) |
|
|
210 | (2) |
|
|
212 | (1) |
|
|
212 | (1) |
|
|
212 | (1) |
|
|
213 | (1) |
|
|
213 | (5) |
|
|
218 | (1) |
|
|
219 | (1) |
|
|
219 | (1) |
|
Interoperability with Common JS |
|
|
220 | (1) |
|
|
221 | (1) |
|
|
222 | (1) |
|
|
222 | (1) |
|
|
223 | (1) |
|
|
224 | (1) |
|
|
225 | (1) |
|
|
225 | (2) |
|
|
227 | (1) |
|
|
227 | (1) |
|
|
228 | (1) |
|
|
229 | (1) |
|
|
229 | (2) |
|
|
231 | (4) |
|
|
|
|
235 | (18) |
|
Class Parameter Properties |
|
|
236 | (2) |
|
|
238 | (1) |
|
|
239 | (2) |
|
|
241 | (1) |
|
|
242 | (1) |
|
|
243 | (1) |
|
|
244 | (1) |
|
|
245 | (2) |
|
|
247 | (1) |
|
Namespaces in Type Definitions |
|
|
248 | (1) |
|
Prefer Modules Over Namespaces |
|
|
248 | (1) |
|
Type-Only Imports and Exports |
|
|
249 | (2) |
|
|
251 | (2) |
|
|
253 | (20) |
|
|
253 | (1) |
|
|
254 | (2) |
|
|
256 | (2) |
|
|
258 | (1) |
|
|
259 | (1) |
|
Generic Conditional Types |
|
|
260 | (1) |
|
|
261 | (1) |
|
|
262 | (1) |
|
|
263 | (1) |
|
|
263 | (1) |
|
Never and Intersections and Unions |
|
|
263 | (1) |
|
Never and Conditional Types |
|
|
264 | (1) |
|
|
264 | (1) |
|
|
265 | (2) |
|
Intrinsic String Manipulation Types |
|
|
267 | (1) |
|
|
267 | (1) |
|
Remapping Mapped Type Keys |
|
|
268 | (2) |
|
Type Operations and Complexity |
|
|
270 | (1) |
|
|
271 | (2) |
Glossary |
|
273 | (8) |
Index |
|
281 | |