Skip to content

Commit e4a7912

Browse files
fix: merge events with parent classes so that class type merging for event emitters works (#168)
1 parent e844013 commit e4a7912

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/module-declaration.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ export const generateModuleDeclaration = (
3535
index !== tIndex && tModule.name.toLowerCase() === module.name.toLowerCase(),
3636
);
3737
const isClass = module.type === 'Class' || isStaticVersion;
38+
const parentModules: ParsedDocumentationResult = [];
39+
let parentModule:
40+
| ModuleDocumentationContainer
41+
| ClassDocumentationContainer
42+
| StructureDocumentationContainer
43+
| ElementDocumentationContainer
44+
| undefined = module;
45+
while (parentModule && parentModule.extends) {
46+
parentModule = API.find(m => m.name === parentModule!.extends);
47+
if (parentModule) parentModules.push(parentModule);
48+
}
3849

3950
// Interface Declaration
4051
if (newModule) {
@@ -67,7 +78,14 @@ export const generateModuleDeclaration = (
6778

6879
// Event Declaration
6980
if (module.type !== 'Element') {
70-
_.concat([], module.instanceEvents || [], module.events || [])
81+
// To assist with declaration merging we define all parent events in this class too
82+
_.concat(
83+
[],
84+
module.instanceEvents || [],
85+
module.events || [],
86+
...parentModules.map(m => m.events || []),
87+
...parentModules.map(m => m.instanceEvents || []),
88+
)
7189
.sort((a, b) => a.name.localeCompare(b.name))
7290
.forEach(moduleEvent => {
7391
utils.extendArray(

0 commit comments

Comments
 (0)