loading...

re: Getting my feet wet with TypeScript VIEW POST

FULL DISCUSSION
 

I'm curious as to how the code looks that consumes your string union vs an enum, because I love enums lol

 

Sorry I didn't see this earlier! It looks something like this (with other stuff):

import SomeComponent from "../some-component";

const component = () => <SomeComponent size="small" />;
 

Dang, so it is a magic string :(

I don't know that I would call it a magic string, since it still autocompletes and gets checked to make sure it's in the union... but from what I could tell it's down to personal preference at that point.

Code of Conduct Report abuse