Rush StackShopBlogEvents
Skip to main content

Home > @microsoft/api-extractor-model > ApiReadonlyMixin > isReadonly

ApiReadonlyMixin.isReadonly property

Indicates that the API item's value cannot be assigned by an external consumer.

Signature:

readonly isReadonly: boolean;

Remarks

Examples of API items that would be considered "read only" by API Extractor:

  • A class or interface's property that has the readonly modifier.

  • A variable that has the const modifier.

  • A property or variable whose TSDoc comment includes the @readonly tag.

  • A property declaration with a getter but no setter.

Note that if the readonly keyword appears in a type annotation, this does not guarantee that that the API item will be considered readonly. For example:

declare class C {
// isReadonly=false in this case, because C.x is assignable
public x: readonly string[];
}