Skip to content

Commit ab91f03

Browse files
JeanMechedevversion
authored andcommitted
refactor(compiler-cli): exclude private computed properties from class member extractions (angular#57596)
This will exclude properties like `[ɵWRITABLE_SIGNAL]` from the `WritableSignal` interface. PR Close angular#57596
1 parent c15ec36 commit ab91f03

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/compiler-cli/src/ngtsc/docs/src/class_extractor.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ class ClassExtractor {
110110
protected extractClassMember(memberDeclaration: MemberElement): MemberEntry | undefined {
111111
if (this.isMethod(memberDeclaration)) {
112112
return this.extractMethod(memberDeclaration);
113-
} else if (this.isProperty(memberDeclaration)) {
113+
} else if (
114+
this.isProperty(memberDeclaration) &&
115+
!this.hasPrivateComputedProperty(memberDeclaration)
116+
) {
114117
return this.extractClassProperty(memberDeclaration);
115118
} else if (ts.isAccessor(memberDeclaration)) {
116119
return this.extractGetterSetter(memberDeclaration);
@@ -375,6 +378,17 @@ class ClassExtractor {
375378
const modifiers = this.declaration.modifiers ?? [];
376379
return modifiers.some((mod) => mod.kind === ts.SyntaxKind.AbstractKeyword);
377380
}
381+
382+
/**
383+
* Check wether a member has a private computed property name like [ɵWRITABLE_SIGNAL]
384+
*
385+
* This will prevent exposing private computed properties in the docs.
386+
*/
387+
private hasPrivateComputedProperty(property: PropertyLike) {
388+
return (
389+
ts.isComputedPropertyName(property.name) && property.name.expression.getText().startsWith('ɵ')
390+
);
391+
}
378392
}
379393

380394
/** Extractor to pull info for API reference documentation for an Angular directive. */

0 commit comments

Comments
 (0)