Skip to content

Commit 3c892a3

Browse files
committed
Add support for type parameters and nullable property in handleMixinAndInterfaces
1 parent 8c87b07 commit 3c892a3

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

inputfiles/overridingTypes.jsonc

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,26 +1310,6 @@
13101310
}
13111311
}
13121312
},
1313-
"IDBRequest": {
1314-
"properties": {
1315-
"property": {
1316-
"source": {
1317-
"name": "source",
1318-
"nullable": false
1319-
},
1320-
"result": {
1321-
"name": "result",
1322-
"overrideType": "T"
1323-
}
1324-
}
1325-
},
1326-
"typeParameters": [
1327-
{
1328-
"name": "T",
1329-
"default": "any"
1330-
}
1331-
]
1332-
},
13331313
"ImageBitmapRenderingContext": {
13341314
"properties": {
13351315
"property": {

inputfiles/patches/indexeddb.kdl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface IDBRequest {
2+
property source nullable=#false
3+
property result overrideType=T
4+
typeParameters T default=any
5+
}

src/build/patches.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ function handleMixinAndInterfaces(
169169
const event: Event[] = [];
170170
const property: Record<string, Partial<Property>> = {};
171171
let method: Record<string, DeepPartial<OverridableMethod>> = {};
172+
let typeParameters = {}
172173

173174
for (const child of node.children) {
174175
switch (child.name) {
@@ -188,12 +189,17 @@ function handleMixinAndInterfaces(
188189
});
189190
break;
190191
}
192+
case "typeParameters": {
193+
typeParameters = handleTypeParameters(child);
194+
break;
195+
}
191196
default:
192197
throw new Error(`Unknown node name: ${child.name}`);
193198
}
194199
}
195200

196201
const interfaceObject = type === "interface" && {
202+
...typeParameters,
197203
...optionalMember("exposed", "string", node.properties?.exposed),
198204
...optionalMember("deprecated", "string", node.properties?.deprecated),
199205
...optionalMember(
@@ -259,6 +265,7 @@ function handleProperty(child: Node): Partial<Property> {
259265
: optionalMember("type", "string", child.properties?.type)),
260266
...optionalMember("readonly", "boolean", child.properties?.readonly),
261267
...optionalMember("deprecated", "string", child.properties?.deprecated),
268+
...optionalMember("nullable", "boolean", child.properties?.nullable),
262269
};
263270
}
264271

0 commit comments

Comments
 (0)