TypeScript Syntax

public — accessible class members

Public members are available to typed callers with an appropriate receiver. Public is the default accessibility for ordinary class members. The explicit modifier is useful for readability and constructor parameter properties; it does not make a readonly property writable. Observed output: 'ready'. 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 { public value: T; }

Working Example

Example Snippettypescript
class Label { constructor(public text: string) {} }console.log(new Label("ready").text);
TypeScript Reference