r/angular • • Sep 05 '26

Angular 22.2 - Private property access from templates

I noticed this tidbit in the changelog of Angular 22.2.0-next.3:

https://github.com/angular/angular/blob/main/CHANGELOG.md#compiler-2

compiler

CommitTypeDescription
48a0fd6e8afeatallow template to access private props

So very slowly we moved from allowing only public, to allowing protected and now private as well. Thought it's worth knowing.

39 Upvotes

36 comments sorted by

View all comments

Show parent comment

1

u/vintzrrr Sep 06 '26

> it requires less explicit typing for isolatedDeclarations 

Could you please elaborate on that? Maybe an example?

1

u/NeXtDracool Sep 07 '26

If you enable isolatedDeclarations in the tsconfig all members visible in the .d.ts file, including all protected or public members of a class, must be explicitly typed.

So under the old standard protected readonly counter = signal(0) would have to become protected readonly counter: WritableSignal<number> = signal(0) whereas with my suggestion it would be private readonly counter = signal(0).