You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using string enums a lot. The following example is what gets pretty close:
/** * Allowed directions. */exportdeclaretypeFlexDirection="row"|"column";exportnamespaceFlexDirection{/** * Align items in a row. */exportconstROW: "row"="row";/** * Align items in a column. */exportconstCOLUMN: "column"="column";}declarefunctiongo(direction: FlexDirection);// Hover "FlexDirection to see docs.go(FlexDirection.ROW);// Hover "ROW" to see docs.go("row");
Is there a better way to add documentation to a string literal type? Sometimes the meaning of the values is not all that visible, or requires examples. The only thing I miss in a literal type such as "row" | "column" at the moment is I can not easily associate docs with the 2 values.
Does it sound feasible to add a shorthand syntax for this similar to:
/** * Allowed directions. */exportliteral/* whatever the keywords */enumFlexDirection{/** * Align items in a row. */ROW="row",/** * Align items in a column. */COLUMN="column"}
Activity
mhegazy commentedon Aug 30, 2016
Duplicate of #3192
kitsonk commentedon Aug 30, 2016
You mean #7642 right (of which #9407 resolved it)? #3192 was string literals.
mhegazy commentedon Aug 30, 2016
my bad, it should be #1206.
#7642 does handle some of the cases, but there still a need for a string/symbol enum.