Skip to content

Commit 48b1420

Browse files
committed
Add isUnion
1 parent a5f38bb commit 48b1420

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

inputfiles/patches/wasm-js-api.kdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
typedef Exports legacyNamespace=WebAssembly {
2-
type record {
2+
type record union=#true {
33
type DOMString
44
type ExportValue
55
}

src/build/patches.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ function handleSingleTypeNode(type: Node): DeepPartial<Typed> {
6262
const typeValue = type.values[0];
6363
const subType =
6464
type.children.length > 0 ? handleTyped(type.children) : undefined;
65+
const isUnion = typeof type.properties.union == "boolean";
6566
return {
6667
...optionalMember("type", "string", typeValue),
6768
subtype:
68-
typeValue == "record" && typeof subType?.type !== "string"
69-
? subType?.type
70-
: subType,
69+
isUnion && typeof subType?.type !== "string" ? subType?.type : subType,
7170
...optionalMember("nullable", "boolean", type.properties?.nullable),
7271
};
7372
}

0 commit comments

Comments
 (0)