Skip to content

Commit 854128c

Browse files
authored
Support methods without names in interfaces (#2169)
1 parent 24c0ae0 commit 854128c

File tree

3 files changed

+10
-26
lines changed

3 files changed

+10
-26
lines changed

inputfiles/addedTypes.jsonc

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -340,27 +340,6 @@
340340
"extends": "DOMRect",
341341
"noInterfaceObject": true
342342
},
343-
/*
344-
Keeping EventListener and EventListenerObject isn't the most elegant way to handle
345-
the event listeners, but we need to keep the EventListener as an extendable interface
346-
for libraries like angular.
347-
*/
348-
"EventListener": {
349-
"name": "EventListener",
350-
"noInterfaceObject": true,
351-
"methods": {
352-
"method": {
353-
// This is a hack to add a call signature, but I think it's reasonable
354-
// as it means we don't have to add a call signatures section to the
355-
// emitter for this one case.
356-
"callable": {
357-
"overrideSignatures": [
358-
"(evt: Event): void"
359-
]
360-
}
361-
}
362-
}
363-
},
364343
"EventListenerObject": {
365344
"name": "EventListenerObject",
366345
"noInterfaceObject": true,

inputfiles/patches/dom.kdl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// Keeping EventListener and EventListenerObject isn't the most elegant way to handle the event listeners, but we need to keep the EventListener as an extendable interface for libraries like angular.
2+
interface EventListener noInterfaceObject=#true {
3+
method "" returns=void {
4+
param evt type=Event
5+
}
6+
}
7+
18
enum InsertPosition {
29
beforebegin
310
beforeend

src/build/patches.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,12 @@ function handleMethod(child: Node): Partial<Method> {
244244
}
245245
}
246246

247-
if (!typeNode) {
248-
throw new Error(`Method "${name}" is missing a return type`);
249-
}
250-
251247
const signature: Method["signature"] = [
252248
{
253249
param: params,
254-
...handleTyped(typeNode),
250+
...(typeNode
251+
? handleTyped(typeNode)
252+
: { type: string(child.properties?.returns) }),
255253
},
256254
];
257255
return { name, signature };

0 commit comments

Comments
 (0)