Types Deep Dive 10 exercises
Problem

Add a New Global Element in TypeScript

Imagine that we're working with an external library that has a new global element available to us. We want to strongly type the element so that it can only be used with the correct attributes.

In this case, we want to create a <something> element and give it a required id attribute, which is a

Loading exercise

Transcript

00:00 In this exercise, I want you to imagine that we're working with an external library that has a new global element available to us. We want to strongly type this so that it can only be used with the correct attributes. In this case, we want to create a something element and give it a required ID attribute, which is a string.

00:17 We're going to need to declaration merge with something in the global namespace that we've seen before. I think you're getting the idea here. In fact, the error that we're getting here is property something does not exist on type JSX.IntrinsicElements. In this case, we're not wrong, it's the types that are wrong.

00:37 Learning what you've figured out so far, see if you can piece all that together and make this work. Good luck.