Function Overloads 8 exercises

Solving an Inference Mystery

This exercise presents an inference mystery.

Here's the code:

Loading exercise


0:00 In this exercise, we have a bit of a murder mystery, or an inference mystery, should we say. Document.querySelector, when we pass in div here, is returning HTMLDivElement, or . On the spanElement, we're getting HTMLSpanElement, so we're getting nice specific types when we pass in div and when we pass in span.

0:20 When we pass in something that's not that, then this should be a div, but we're actually just getting element, or . Your job here is to figure out why document.querySelector is behaving in this way.

0:34 You're going to need to dive into some of these types. The first spot you're going to have to look at is you can basically hover over this Go To Definition, and it will take you to the spot where it's declared.

0:51 You're going to be looking at some scary-looking types. Try not to get lost. If you do get lost, then jump back to the solution, and I'll walk you through all of it.