Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions inputfiles/addedTypes.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -425,19 +425,6 @@
"legacyNamespace": "WebAssembly",
"overrideType": "Function | Global | Memory | Table"
},
{
"name": "Exports",
"legacyNamespace": "WebAssembly",
"type": "record",
"subtype": [
{
"type": "DOMString"
},
{
"type": "ExportValue"
}
]
},
{
"name": "ModuleImports",
"legacyNamespace": "WebAssembly",
Expand Down
6 changes: 6 additions & 0 deletions inputfiles/patches/wasm-js-api.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
typedef Exports legacyNamespace=WebAssembly {
type record union=#true {
type DOMString
type ExportValue
}
}
7 changes: 5 additions & 2 deletions src/build/patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,14 @@ function handleSingleTypeNode(type: Node): DeepPartial<Typed> {
if (!isTyped) {
throw new Error("Expected a type node");
}
const typeValue = type.values[0];
const subType =
type.children.length > 0 ? handleTyped(type.children) : undefined;
const isUnion = typeof type.properties.union == "boolean";
return {
...optionalMember("type", "string", type.values[0]),
subtype: subType,
...optionalMember("type", "string", typeValue),
subtype:
isUnion && typeof subType?.type !== "string" ? subType?.type : subType,
...optionalMember("nullable", "boolean", type.properties?.nullable),
};
}
Expand Down