Types Deep Dive 10 exercises
Problem

Add Attributes to All Elements with Declaration Merging

This list of different HTML elements all have a testId attribute added, which can be useful for extracting elements from the DOM for testing:


<>
<div testId="123" />
<audio testId="123" />
<video testId="123" />
<a testId="123" />
<abbr testId="123" />
<address testId="1

Loading exercise

Transcript

00:00 Let's take everything that we've learned so far and put it into practice. Let's imagine that we wanted to add an optional attribute to all elements where we want to say, okay, we can pass this element a test ID. This test ID, it might just sort of like ping onto the DOM and it means that we can extract it out later and sort of pull it into our tests or things like that.

00:18 So your job is to make use of declaration merging in the global scope and try to find the right interface to add this on in order to add it onto all of these props down here. And we want this to be optional as well, just so we don't, you know, muck up our entire environment here. Good luck.