Skip to content

Commit 61ad493

Browse files
committed
Removed comments
1 parent 1da6bcc commit 61ad493

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

src/05-function-overloads/26-document.queryselector-example.solution.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,10 @@ import { Equal, Expect } from "../helpers/type-utils";
33
const divElement = document.querySelector("div");
44
const spanElement = document.querySelector("span");
55

6-
/**
7-
* The reason that divElement2 is not of type HTMLDivElement
8-
* is because the querySelector method has multiple
9-
* overloads.
10-
*
11-
* The first overload accepts keyof HTMLElementTagNameMap
12-
* as the first argument.
13-
*
14-
* The second overload accepts keyof SVGElementTagNameMap
15-
* as the first argument.
16-
*
17-
* The third overload accepts a string as the first argument.
18-
*
19-
* div.foo is not a valid key in HTMLElementTagNameMap or
20-
* SVGElementTagNameMap, so the third overload is used -
21-
* which returns an HTMLElement.
22-
*/
23-
24-
/**
25-
* Here, I've used a type argument to get it to return
26-
* the expected type
27-
*/
286
const divElement2 = document.querySelector<HTMLDivElement>("div.foo");
297

308
type tests = [
319
Expect<Equal<typeof divElement, HTMLDivElement | null>>,
3210
Expect<Equal<typeof spanElement, HTMLSpanElement | null>>,
33-
Expect<Equal<typeof divElement2, HTMLDivElement | null>>,
11+
Expect<Equal<typeof divElement2, HTMLDivElement | null>>
3412
];

0 commit comments

Comments
 (0)