File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
@plotly/dash-generator-test-component-typescript/src Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ export type TypescriptComponentProps = {
2525 array_obj ?: { a : string } [ ] ;
2626 array_any ?: any [ ] ;
2727 enum_string ?: 'one' | 'two' ;
28+ enum_number ?: 2 | 3 | 4 | 5 | 6 ;
2829 union ?: number | string ;
2930 union_shape ?: { a : string } | string ;
3031 array_union_shape ?: ( { a : string } | string ) [ ] ;
Original file line number Diff line number Diff line change @@ -103,18 +103,17 @@ def _get_literal_value(value):
103103 if value is None :
104104 return "None"
105105
106+ if isinstance (value , str ):
107+ value = json .loads (value .replace ("'" , '"' ))
108+
106109 if isinstance (value , bool ):
107110 return str (value )
108111
109112 return json .dumps (value )
110113
111114
112115def generate_enum (type_info , * _ ):
113- values = [
114- _get_literal_value (json .loads (v ["value" ].replace ("'" , '"' )))
115- for v in type_info ["value" ]
116- if v
117- ]
116+ values = [_get_literal_value (v ["value" ]) for v in type_info ["value" ] if v ]
118117 return f"Literal[{ ', ' .join (values )} ]"
119118
120119
You can’t perform that action at this time.
0 commit comments