refactor(compiler-cli): exclude private computed properties from class member extractions (#57596)

This will exclude properties like `[ɵWRITABLE_SIGNAL]` from the `WritableSignal` interface.

PR Close #57596
This commit is contained in:
Matthieu Riegler 2024-08-21 01:07:13 +02:00 committed by Paul Gschwendtner
parent c15ec36bd1
commit ab91f0371b

View file

@ -110,7 +110,10 @@ class ClassExtractor {
protected extractClassMember(memberDeclaration: MemberElement): MemberEntry | undefined {
if (this.isMethod(memberDeclaration)) {
return this.extractMethod(memberDeclaration);
} else if (this.isProperty(memberDeclaration)) {
} else if (
this.isProperty(memberDeclaration) &&
!this.hasPrivateComputedProperty(memberDeclaration)
) {
return this.extractClassProperty(memberDeclaration);
} else if (ts.isAccessor(memberDeclaration)) {
return this.extractGetterSetter(memberDeclaration);
@ -375,6 +378,17 @@ class ClassExtractor {
const modifiers = this.declaration.modifiers ?? [];
return modifiers.some((mod) => mod.kind === ts.SyntaxKind.AbstractKeyword);
}
/**
* Check wether a member has a private computed property name like [ɵWRITABLE_SIGNAL]
*
* This will prevent exposing private computed properties in the docs.
*/
private hasPrivateComputedProperty(property: PropertyLike) {
return (
ts.isComputedPropertyName(property.name) && property.name.expression.getText().startsWith('ɵ')
);
}
}
/** Extractor to pull info for API reference documentation for an Angular directive. */