Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Commit b813564

Browse files
committed
Allow enums with only one element
1 parent 27925f8 commit b813564

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ func (g *generator) genEnum(name string, v cue.Value) []ts.Decl {
288288
// We restrict the expression of TS enums to CUE disjunctions (sum types) of strings.
289289
allowed := cue.StringKind | cue.NumberKind | cue.NumberKind
290290
ik := v.IncompleteKind()
291-
if op != cue.OrOp || ik&allowed != ik {
291+
if ik&allowed != ik {
292292
g.addErr(valError(v, "typescript enums may only be generated from a disjunction of concrete int with memberNames attribute or strings"))
293293
return nil
294294
}

testdata/enum_with_one_item.txtar

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- cue --
2+
3+
#Enum: "a" @cuetsy(kind="enum",memberNames="First")
4+
5+
-- ts --
6+
7+
export enum Enum {
8+
First = 'a',
9+
}

0 commit comments

Comments
 (0)