DEV Community

Discussion on: Getting my feet wet with TypeScript

Collapse
 
thatzacdavis profile image
Zachary Davis

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

Collapse
 
jnielson94 profile image
Jordan Nielson

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" />;
Collapse
 
thatzacdavis profile image
Zachary Davis

Dang, so it is a magic string :(

Thread Thread
 
jnielson94 profile image
Jordan Nielson

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.