Skip to content

Commit 1c26502

Browse files
committed
Support records in KDL
1 parent 7aa85ee commit 1c26502

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

inputfiles/addedTypes.jsonc

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -425,19 +425,6 @@
425425
"legacyNamespace": "WebAssembly",
426426
"overrideType": "Function | Global | Memory | Table"
427427
},
428-
{
429-
"name": "Exports",
430-
"legacyNamespace": "WebAssembly",
431-
"type": "record",
432-
"subtype": [
433-
{
434-
"type": "DOMString"
435-
},
436-
{
437-
"type": "ExportValue"
438-
}
439-
]
440-
},
441428
{
442429
"name": "ModuleImports",
443430
"legacyNamespace": "WebAssembly",

inputfiles/patches/wasm-js-api.kdl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
typedef Exports legacyNamespace=WebAssembly {
2+
type record {
3+
type DOMString
4+
type ExportValue
5+
}
6+
}

src/build/patches.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,15 @@ function handleSingleTypeNode(type: Node): DeepPartial<Typed> {
5959
if (!isTyped) {
6060
throw new Error("Expected a type node");
6161
}
62+
const typeValue = type.values[0];
6263
const subType =
6364
type.children.length > 0 ? handleTyped(type.children) : undefined;
6465
return {
65-
...optionalMember("type", "string", type.values[0]),
66-
subtype: subType,
66+
...optionalMember("type", "string", typeValue),
67+
subtype:
68+
typeValue == "record" && typeof subType?.type !== "string"
69+
? subType?.type
70+
: subType,
6771
...optionalMember("nullable", "boolean", type.properties?.nullable),
6872
};
6973
}

0 commit comments

Comments
 (0)