TypeScript Syntax
protected — subclass member access
Protected members can be used in the declaring class and derived classes, subject to receiver restrictions in subclasses. Ordinary outside callers cannot access them. Protection is checked statically, not enforced as a JavaScript runtime boundary. Observed output: '3'. Local verification: TypeScript 5.8.3, strict mode, ES2022, CommonJS, Node.js 22.16.0. Disposable library declarations are enabled for the fixture suite.
Formal Syntax & Structure
typescript syntaxtypescript
class C { protected value: T; }Working Example
Example Snippettypescript
class Base { protected count = 3; }class Child extends Base { read() { return this.count; } }console.log(new Child().read());