Writing code

CLASS

TsClass

@skmtc/lang-typescript 0.19.1

TypeScript's structured class value - what a class-kind TsDefinition wraps (export class Name <value>). It is to a class declaration what TsFile is to a file: a container of self-rendering members (TsProperty / TsConstructor / TsMethod) that it dedups (by member name, first-write-wins - the TsFile policy) and arranges (properties → constructor → methods, newline-joined, no indentation).

A pure Stringable: it owns the class structure only. Imports are not its concern - TsFile is the import authority (storage, dedup, merge). The heritage is a TsHeritage entity composing the extends / implements clauses, which each own their rendering and register the import of the symbol they name; the members' imports are registered by the generator through the normal register flow. So TsClass carries no context and never registers; toString() is a pure render of the accumulated members.

Signature

import { TsClass } from '@skmtc/lang-typescript'

class TsClass

Constructor

constructor

constructor(args?: TsClassArgs)

Properties

heritage, TsHeritage | undefined
properties, Map<string, TsProperty>

Properties keyed by name; first write for a name wins.

classConstructor, TsConstructor | undefined

The single constructor, supplied at construction.

methods, Map<string, TsMethod>

Methods keyed by name; first write for a name wins.

Methods

addProperty

addProperty(property: TsProperty): void

Add a property; a no-op if one of the same name is already present.

addMethod

addMethod(method: TsMethod): void

Add a method; a no-op if one of the same name is already present.

toString

toString(): string