TypeScript classes: fields, visibility, implements
Short answer
TypeScript classes add types and visibility (public/protected/private) on top of JavaScript classes. implements only checks the shape; it does not change runtime code. [S1]
Points
readonlyfields can be set in the constructor, not reassigned later. [S1]protectedmembers are visible in subclasses only. [S1]- TypeScript does not analyze methods you call from the constructor for definite assignment the way some expect. [S1]
- Declaration merging can join multiple interface declarations with the same name into one. [S2]
Claims
- id: C1 claim: readonly fields cannot be assigned outside the constructor. source: S1 evidence: "This prevents assignments to the field outside of the constructor"
- id: C2 claim: protected members are only visible to subclasses. source: S1 evidence: "protected members are only visible to subclasses"
- id: C3 claim: implements is only a static check. source: S1 evidence: "implements clause is only a check"
- id: C4 claim: Basic declaration merging joins members into one interface. source: S2 evidence: "the merge mechanically joins the members of both declarations into a single interface"
Sources
- [S1] TypeScript Handbook: Classes. TypeScript (Microsoft). https://www.typescriptlang.org/docs/handbook/2/classes.html . License: CC BY 4.0 (microsoft/TypeScript-Website). Accessed 2026-11-05.
- [S2] Declaration Merging. TypeScript (Microsoft). https://www.typescriptlang.org/docs/handbook/declaration-merging.html . License: CC BY 4.0 (microsoft/TypeScript-Website). Accessed 2026-11-05.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
Source notice: TypeScript Handbook / Website docs © Microsoft. Licensed under Creative Commons Attribution 4.0 International (https://github.com/microsoft/TypeScript-Website/blob/v2/LICENSE).
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: TypeScript (Microsoft), TypeScript Handbook: Classes, CC BY 4.0 (microsoft/TypeScript-Website); TypeScript (Microsoft), Declaration Merging, CC BY 4.0 (microsoft/TypeScript-Website).
Cite this
iinventedlight. 2026. "TypeScript classes: fields, readonly, visibility, implements." iinventedlight Library, iil:note:zrh5655z, version of 2026-11-04. https://iinventedlight.com/library/notes/typescript-classes/. License: CC-BY-4.0.
@misc{iil_note_zrh5655z,
author = {{iinventedlight}},
title = {{TypeScript classes: fields, readonly, visibility, implements}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-04},
url = {https://iinventedlight.com/library/notes/typescript-classes/},
note = {Permanent ID iil:note:zrh5655z. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/typescript-classes.md.