mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
In the code base there are cases where there is, conceptually, a class
that is represented by a combination of an `interface`
(type declaration) and a `const` (value declaration).
For example:
```
export interface SomeClass {
count(a?: string): number;
}
export const: SomeClass = class {
someMethod(a: string = ''): number { ... }
};
```
These were being rendered as interfaces and also not
correctly showing the descriptions and default parameter
values.
In this commit such concepts are now rendered as classes.
The classes that are affected by this are:
* `DebugElement`
* `DebugNode`
* `Type`
* `EventEmitter`
* `TestBed`
Note that while decorators are also defined in this form
they have their own rendering type (`decorator`) and so
are not affecte by this.
PR Close #36989
27 lines
907 B
JavaScript
27 lines
907 B
JavaScript
module.exports = function processPseudoClasses(tsHost) {
|
|
return {
|
|
$runAfter: ['readTypeScriptModules'],
|
|
$runBefore: ['parsing-tags'],
|
|
$process(docs) {
|
|
docs.forEach(doc => {
|
|
if (doc.docType === 'interface' && doc.additionalDeclarations &&
|
|
doc.additionalDeclarations.length > 0) {
|
|
doc.docType = 'class';
|
|
const additionalContent = tsHost.getContent(doc.additionalDeclarations[0]);
|
|
if (!doc.content || doc.content === '@publicApi' && additionalContent) {
|
|
doc.content = additionalContent;
|
|
}
|
|
doc.members = doc.members && doc.members.filter(m => {
|
|
if (m.isNewMember) {
|
|
doc.constructorDoc = m;
|
|
doc.constructorDoc.name = 'constructor';
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
};
|
|
};
|