Also, as part of the migration… why are you gettin...
# random
a
Also, as part of the migration… why are you getting rid of enums, in favor of strings?
Copy code
fields: type TableFieldType ⇒ string
t
in TS there's no reason to use an enum
a
It’s cleaner?
You can get easily who is using the value?
Easier to do a refactor?
t
all of that is still true with a typescript string union
autocomplete should show you a list of valid options
this is true with modern editors whether you're using ts or js
and the issue with enums is you have to first figure out what to import to even see the options
a
That’s true.
t
enums were a way to provide pseudo typesafety in JS before TS string unions were a thing
a
Ok, makes sense.
And what about Duration… same?
😛
t
CDK uses them heavily because they cross compile into several languages and enums are common in all of them
a
I like enums, hate strings 😞
Will need to get used to it.
Yeah.
t
Duration is a bit interesting, we use something called a template literal type
Copy code
export declare type Duration = `${number} ${"second" | "seconds" | "minute" | "minutes" | "hour" | "hours" | "day" | "days"}`;
it will only accept "12 seconds" for example
a
Yeah.
I already modified 24 lambdas.
Hahaha.
t
haha oh
a
Actually, more.
t
this one is a bit worse because TS autocomplete doesn't do a great job when there's a dynamic part of a string template
but I imagine this will get better