tcmts.core.program

Types

CheckProfile type
Checked type
A compiled program, and the checker that answers questions about it.
Compile type
`overlay`: files' unsaved text (an editor's open buffers), read instead of the disk; `packages`: see PackageResolver
CompilerOptions type
Compiler options, as TypeScript 7 takes them (enums as numbers, `lib` by name).
Diagnostic type
NodeTypes type
Where the compiler finds @types/node: a type root, and the directory in it to load (`node`, or a cache alias).
PackageResolver type
Where a bare package import in a scratch file resolves when tcm provides the package: the cache's directory for the version chosen for that file. Undefined leaves the import to ordinary resolution (the project's own node_modules).

Server

compilerOptions () => CompilerOptions
createProgram (rootFiles: string[], options?: CompilerOptions, overlay?: ReadonlyMap<string, string> | undefined,…
A one-off compilation (`overlay`: files' text, read instead of the disk).
currentDirectory () => string
Where tcm runs, as it was reached: the shell's `PWD` when it's this directory (through a link, say), so paths shown from here are from where the files are named, not from where they really are.
fileDiagnostics (program: Program<ProjectId>, sf: SourceFile, ignore?: number[], includeGlobal?: boolean, skip?: ((…
formatHost { getCanonicalFileName: (f: string) => string; getCurrentDirectory: () => string; getNewLine: () =>…
incrementalCompiler (keep?: number) => Compile
Compile files: a snapshot of them (overlay text over the disk) in the compiler process. Snapshots read the disk afresh, and the compiler keeps what it parsed (the standard library, @types/node) between them, so a new one is quick. A compilation stays usable until the same files are compiled again (an editor's open files each keep theirs), or until it's one of more than `keep` others since.
packageNameOf (specifier: string) => string | undefined
The package an import names: `react/jsx-runtime` → `react`, `@scope/pkg/sub` → `@scope/pkg`.
projectCompilerOptions (tsconfig: string | undefined, mode?: "import" | "scratch") => { options: CompilerOptions; warnings…
Compiler options for a project: its `tsconfig.json` if there is one (lib, strictness, types, ... are the project's choice), with the options tcm requires forced on top. Warnings name the settings that were overridden.
providedPaths (rootFiles: string[], options: CompilerOptions, overlay: ReadonlyMap<string, string> | undefined, p…
Provided packages as `paths`: each import of one in the root files (and a .tsx file's JSX runtime) mapped to the file it resolves to as the package's cache alias (`react/jsx-runtime` → `npm__react__19/jsx-runtime`, resolved from the cache, where its DefinitelyTyped types are found as usual).
tcmNodeTypes () => NodeTypes | undefined
tcm's @types/node: installed next to tcm (an npm package; or, running from a codebase, provided in its cache beside tcm's own modules), else in the project tcm runs in, else the one a codebase there uses (`.tcm/cache/node-types.json`, written by the CLI: code running from the codebase, like its tests, may be far from any). Undefined when none has it, as when tcm runs from a codebase somewhere else that hasn't provided it yet.
transpileForNode (source: string, fileName: string) => string
The TypeScript runtime tcm uses, for compiling generated modules that use non-erasable syntax (JSX, enums). The output keeps the module's own source map, composed through the compilation, so it still leads to the definition (or scratch file) the code came from.
transpileModule () => { url: string; export: string; transpile: (source: string, fileName: string) => string; }
Where transpileForNode can be imported from, for processes that load the same compilation through a module hook: this module and the export to import (by name from source; by hash when tcm runs from a codebase, where a function carries its hash).
useNodeTypes (dir: string) => void
Check against the @types/node installed at `dir` (a package directory, e.g. in a codebase's cache).

Shared

B64 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
ENUM_NAMES Record<string, Record<number, string>>
INLINE_MAP RegExp
NODE_TYPES_RANGE "24"
The @types/node tcm checks code against, so projects typecheck without installing it: tcm's own dependency.
PROFILE_KEYS readonly ["strict", "noImplicitAny", "strictNullChecks", "strictFunctionTypes", "strictBindCallAppl…
The options that decide whether code typechecks (strictness, lib, target). A definition is valid under the options it was checked with, so it records these and is re-checked with them later (verify, update, receive).
REQUIRED CompilerOptions
Options tcm's model depends on: NodeNext resolution (import classification and `#codebase` go through it), the syntax Node's type stripping can run, and no emit.
REQUIRED_FOR_IMPORT CompilerOptions
For importing existing code: tcm renders its own imports (by hash, with `import type` decided by tcm), so the project's resolution style doesn't matter, and most projects are written for bundler resolution: every file is ESM and relative imports can omit extensions. Only what Node's type stripping needs to run the code is forced.
TS_VERSION string
checkProfile (options: CompilerOptions) => Partial<Record<"alwaysStrict" | "exactOptionalPropertyTypes" | "lib" …
decodeMappings (mappings: string) => number[][][]
A source map's mappings, decoded: per generated line, segments of [column, source, line, column] (absolute).
encodeMappings (lines: number[][][]) => string
nodeTypes NodeTypes | undefined