TypeScript Syntax

private — class member accessibility

A private declaration restricts ordinary typed access to the declaring class. It also affects compatibility when private members originate from different declarations. TypeScript private is not a runtime access-control mechanism; use ECMAScript # fields when runtime privacy is needed. Observed output: '2'. 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 { private value: T; }

Working Example

Example Snippettypescript
class Counter { private count = 2; read() { return this.count; } }console.log(new Counter().read());
TypeScript Reference