Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 0 additions & 18 deletions inputfiles/overridingTypes.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -3663,24 +3663,6 @@
}
}
},
"UnderlyingSource": {
"typeParameters": [
{
"name": "R",
"default": "any"
}
],
"members": {
"member": {
"start": {
"overrideType": "UnderlyingSourceStartCallback<R>"
},
"pull": {
"overrideType": "UnderlyingSourcePullCallback<R>"
}
}
}
},
"UIEventInit": {
"members": {
"member": {
Expand Down
5 changes: 5 additions & 0 deletions inputfiles/patches/underlying.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dictionary UnderlyingSource {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move this content to a file named ReadableStream.kdl?
This is quite confusing otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, done

typeParameters R default = "any"
member start overrideType = "UnderlyingSourceStartCallback<R>"
member pull overrideType = "UnderlyingSourcePullCallback<R>"
}
21 changes: 19 additions & 2 deletions src/build/patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,25 @@ function handleTyped(type: Node): Typed {
};
}

function handleTypeParameters(value: Value) {
function handleTypeParameters(value: Value | Node) {
if (!value) {
return {};
}
if (typeof value === "string") {
return {
typeParameters: [
{
name: string(value),
},
],
};
}
const node = value as Node;
return {
typeParameters: [
{
name: string(value),
name: string(node.values[0]),
...optionalMember("default", "string", node.properties?.default),
},
],
};
Expand Down Expand Up @@ -318,6 +329,7 @@ function handleMethod(child: Node): DeepPartial<OverridableMethod> {
function handleDictionary(child: Node): DeepPartial<Dictionary> {
const name = string(child.values[0]);
const member: Record<string, Partial<Member>> = {};
let typeParameters = {};

for (const c of child.children) {
switch (c.name) {
Expand All @@ -326,6 +338,10 @@ function handleDictionary(child: Node): DeepPartial<Dictionary> {
member[memberName] = handleMember(c);
break;
}
case "typeParameters": {
typeParameters = handleTypeParameters(c);
break;
}
default:
throw new Error(`Unknown node name: ${c.name}`);
}
Expand All @@ -334,6 +350,7 @@ function handleDictionary(child: Node): DeepPartial<Dictionary> {
return {
name,
members: { member },
...typeParameters,
...handleTypeParameters(child.properties?.typeParameters),
...optionalMember(
"legacyNamespace",
Expand Down