Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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 {
type DOMString
type ExportValue
}
}
8 changes: 6 additions & 2 deletions src/build/patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,15 @@ 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;
return {
...optionalMember("type", "string", type.values[0]),
subtype: subType,
...optionalMember("type", "string", typeValue),
subtype:
typeValue == "record" && typeof subType?.type !== "string"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this shouldn't check the type name. We could use this for any parameterized type, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should, when I removed that check, it broke the output to be:

 readonly links: HTMLCollectionOf<HTMLAnchorElement, HTMLAreaElement>;

Instead of the original:

readonly links: HTMLCollectionOf<HTMLAnchorElement | HTMLAreaElement>;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no, ambiguate way to pass second type vs union. We need to disambiguate it rather than using the same way here then.

? subType?.type
: subType,
...optionalMember("nullable", "boolean", type.properties?.nullable),
};
}
Expand Down