File tree Expand file tree Collapse file tree 1 file changed +1
-1
lines changed Expand file tree Collapse file tree 1 file changed +1
-1
lines changed Original file line number Diff line number Diff line change @@ -243,7 +243,7 @@ This is a useful way of telling TypeScript what the real type of an expression i
243
243
244
244
The reason we need to do so in this case is that ` getElementById ` 's return type is ` HTMLElement | null ` .
245
245
Put simply, ` getElementById ` returns ` null ` when it can't find an element with a given ` id ` .
246
- We're assuming that ` getElementById ` will actually succeed, so we need convince TypeScript of that using the ` as ` syntax.
246
+ We're assuming that ` getElementById ` will actually succeed, so we need to convince TypeScript of that using the ` as ` syntax.
247
247
248
248
TypeScript also has a trailing "bang" syntax (` ! ` ), which removes ` null ` and ` undefined ` from the prior expression.
249
249
So we * could* have written ` document.getElementById('root')! ` , but in this case we wanted to be a bit more explicit.
You can’t perform that action at this time.
0 commit comments