Skip to main content

@readonly

Syntax

@readonly

Overview

@readonly documents that a symbol's value should not be modified after it is set. It does not enforce immutability at runtime — it is purely a documentation signal.

TypeScript Supported

TypeScript recognises @readonly and uses it to prevent reassignment of properties in JavaScript files.

TypeScript docs →

Example

/**
* The library version. Do not modify.
* @readonly
* @type {string}
*/
export const VERSION = '2.0.0';
class Config {
/**
* @readonly
* @type {string}
*/
get locale() {
return this._locale;
}
}

See also

Official reference: jsdoc.app/tags-readonly