IMO constant should be constant. const FOO = 'FOO'; const BAR = 'BAR'; const f = (x: FOO | BAR) => whatever; The function accepts only "one of" to pattern match later, not a generic string. btw should be possible with third variant too
-
-
-
I'm a bit annoyed to type `const FOO: 'FOO' = 'FOO';`
- 1 more reply
New conversation -
-
-
goodness, type intersections make me have soo many opinions here.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Why FOO?
- 1 more reply
New conversation -
-
What behavior would you want? Would you want something different for this? let x = ‘FOO’;
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
I think it should be just FOO with FOO inheriting from string and so if you what to use the type FOO you can and if you want to use this variable in a function that only allows strings, you can too
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
he/him 