Skip to content

Commit 56f7ebf

Browse files
Bashamegasaschanaz
andauthored
Update src/build/utils/kdl.ts
Co-authored-by: Kagami Sascha Rosylight <[email protected]>
1 parent fc238c7 commit 56f7ebf

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/build/utils/kdl.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,10 @@ export function parseKDL(kdlText: string) {
4646
const values: string[] = [];
4747

4848
for (const child of node.children ?? []) {
49-
if (
50-
child.name === "value" &&
51-
child.values &&
52-
child.values[0] !== undefined
53-
) {
54-
values.push(child.values[0]!.toString());
55-
} else if (child.name === "name") {
56-
name = child.values?.[0]?.toString() ?? enumName;
49+
if (child.name !== "value" || typeof child.values[0] !== "string") {
50+
throw new Error("enum values should be in the form of `value {name}`");
5751
}
52+
values.push(child.values[0]);
5853
}
5954

6055
enums[enumName] = { name, value: values };

0 commit comments

Comments
 (0)