tcmts.core.extract

Types

DefSite type
One top-level binding found in a source file.
ExtractMode type
`scratch`: bare expressions are watch expressions. `import`: an existing module; re-export lists are plumbing and are skipped, side-effecting statements are errors.
Extracted type
Piece type
Source text is assembled from file ranges and literal strings (e.g. `const ` for one binding of a multi-binding list).
TcmError typeof TcmError

Shared

DOTTED RegExp
MERGED_TAGS string[]
The tags of declarations merged into one definition (see `extract`), weakest first: the strongest heads the definition's IR. A class stays a class, and a `declare const` keeps its salt (each is a distinct symbol).
MUTATORS Set<string>
The functions of `Object` and `Reflect` that change the object they're given first.
NON_ERASABLE_HINT "Node's type stripping cannot run it; use an `as const` object or plain functions instead"
PATH_PRAGMA RegExp
SIDE_EFFECT_HINT "tcm stores definitions, not module side effects: move this statement into a function (e.g. an expo…
directivePieces (node: Node, sf: SourceFile) => Piece[]
`// @ts-expect-error` / `// @ts-ignore` comments directly above a declaration, as source pieces. They're kept with the definition (they decide whether it typechecks; like other comments they aren't hashed).
extract (sf: SourceFile, mode?: ExtractMode, firstId?: number) => Extracted
isAnonymousFunction (e: ExpressionBase) => boolean
An anonymous function or class expression, after erasable wrappers. Binding one to a name gives it that name at runtime (`const f = () => 1` has `f.name === "f"`).
isInstantiated (ns: ModuleDeclaration) => boolean
Whether a namespace produces a runtime value (anything but types inside).
jsDocText (node: Node, sf: SourceFile) => string | undefined
location (node: Node) => string
modifierKinds (node: Node) => SyntaxKind[]
namespacePragma (node: Node, sf: SourceFile) => string | undefined
A `// tcm: namespace a.b` line among the comments before a statement: the namespace it names.
pathPragma (node: Node, sf: SourceFile) => string | undefined
setupTargets (st: Node) => Set<string>
What a top-level statement writes into, outside the functions in it: the root of what it assigns to (`codes[i] = …`, `Impl.prototype = …`, `delete x.k`), and what it hands to `Object`'s and `Reflect`'s mutators (`Object.defineProperty(Proto, …)`, `Object.freeze(types)`). Its own variables (`for (let i …)`) don't count; a write into something else than a name (`f().x = 1`) is `""`. A method call isn't a write: `server.listen()` is a side effect, not setting up.
strippedStart (node: Node, sf: SourceFile) => number
Start of a declaration with `export` / `default` modifiers removed.