@mattpocockuk: Time to talk about one of the ...
@mattpocockuk
7 views
Aug 16, 2024
5
But there's an issue. We aren't getting `color` suggestions when we use the `Icon` component. If we try to autocomplete the `color` prop, we get no suggestions.
Ideally, we want `primary` and `secondary` to be part of that list. How do we manage that?
Ideally, we want `primary` and `secondary` to be part of that list. How do we manage that?
9
Now, when we use `Color`, TypeScript will remember that `"primary"` and `"secondary"` are part of the type - and it'll give us suggestions accordingly.
10
This might feel pretty fragile to you. This doesn't seem like intended behavior from TypeScript.
Well, the team actually know about this trick. They test against it.
And someday, they may make it so that a plain `string` type will just work. But until then, keep this in mind.
Well, the team actually know about this trick. They test against it.
And someday, they may make it so that a plain `string` type will just work. But until then, keep this in mind.
11
Less that 10% of folks get to the end of these threads.
You're a special bugger. Join the club:
totaltypescript.com/newsletter
You're a special bugger. Join the club:
totaltypescript.com/newsletter






