An error I made when defining enums/generated as union types #720
goto40
started this conversation in
Show and tell
Replies: 1 comment
-
This could be improved in the type inference. The second variant could be generated as export type MyEnum = ON | OFF
export type ON = 'on'
export type OFF = 'off' |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Use:
This returns
'on'|'off'
.Don't:
Here MyEnum returns
string
.Reason for the first: type safety. In the second case a
string
is returned byMyEnum
. In the first it is'on'|'off'
.Beta Was this translation helpful? Give feedback.
All reactions