Mutability 12 exercises
Problem

Fixing a Type Assignment Inference Error

Here we have an interface ButtonAttributes which has one property type that can be of three possible values: button, submit, or reset.

We have a let declaration for a variable type that is assigned the value "button".

Then we create an object buttonAttributes of type `ButtonAttri

Loading exercise

Transcript

00:00 In this exercise, we have a const here called ButtonAttributes. And this is an object that basically just has a single property. It's being typed as a ButtonAttributeType. And that type has a type property, which is either button or submit or reset. Those are the three possibilities.

00:18 And you might have seen this, this is kind of like a kind of dummy version of what happens in the DOM. If you want to edit the type of a button element in the DOM, it can either be of type button, submit or reset. Now we have a let here, which is saying let type equals button. And then we're assigning that into the ButtonAttributes object,

00:37 but we're getting an error in there. Your job is to work out why that error is occurring, what's happening to cause that error and how we might fix it. And you're only allowed to change this line of code with let type equals button, but you can change the runtime thing of the code, like behavior of the code, if you like.

00:57 And you can change, you can give it a type if you like. So good luck.