Projections and snippets

CLASS

TsSnippet

@skmtc/lang-typescript 0.19.1

The TypeScript snippet base - where the TypeScript language enters the SKMTC DSL class hierarchy.

@skmtc/core's SnippetBase is language-blind and needs no generatorKey to register - the key stays an optional constructor arg used for attribution (gen-maps) only. TsSnippet extends it and carries the TypeScript Lang as a static only: Drivers read it off the projection class (projection.lang), pre-construction, inherited through every class built on this base (including projection classes from this package's toTsModelProjectionBase). No instance slot - the register methods delegate to this package's register functions, which name the TypeScript classes directly.

destinationPath is always explicit on snippets: a snippet has no file or settings of its own, so the parent passes the target path through the constructor. Own-file defaulting exists only on projections, in the projection-base veneers.

Signature

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

class TsSnippet extends SnippetBase

Properties

TsSnippet.lang, Lang

The language every class built on this base renders into. The neutral Lang - the engine reads it language-blind; TypeScript's fixed type vocabulary lives on this package's concrete types, not here.

Methods

register

register(args: TsRegisterArgs & { destinationPath: string }): void

Register imports / definitions into the file at destinationPath, typed by TypeScript's concise vocabulary - keyless: no generatorId resolution, no generatorKey requirement.

defineAndRegister

defineAndRegister<Value extends GeneratedValue>(
  args: TsDefineAndRegisterArgs<Value>
): TsDefinition<Value>

Build a TsDefinition from value and register it at destinationPath.