37. Compiler options
Options never affect hashes, only what typechecks.
37.1 The compiler
tcm checks code with TypeScript 7 (typescript@7.1, the Go compiler), through its API: one compiler process
per tcm process, which keeps what it has parsed (the standard library, @types/node) from one check to the next.
TCM_TYPESCRIPT picks another compiler that speaks the same API:
TCM_TYPESCRIPT=tsrsuses tsrs, TypeScript 7 ported to Rust. Install it in the project (npm install --save-dev tsrs) or next to tcm.TCM_TYPESCRIPT=/path/to/binaryuses that binary (a local build of either).
The compiler doesn't affect hashes: pnpm compare-compilers re-hashes tcm's own source with tsrs and gets the same
hashes (hashing).
37.2 Scratch files
Options come from the project's tsconfig.json: lib, strictness, types and so on are the project's
choice. A few are forced, with a warning when the project sets them otherwise:
module/moduleResolutionNodeNext, which import classification and#codebaserely on;verbatimModuleSyntaxanderasableSyntaxOnly, which Node's type stripping needs;allowImportingTsExtensionsandnoEmit;jsx=react-jsx: JSX compiles to the automatic runtime (react/jsx-runtime, or yourjsxImportSource), which generated modules import at its pinned version (React).
Without its own types, a project gets tcm's @types/node, so scratch files typecheck without installing it: the
copy installed with tcm, or, when tcm runs from a codebase with none nearby, one the codebase installs into its
cache like any package (and records in .tcm/cache/node-types.json, for tests and watch expressions running from
there). tcm init writes where that is into the codebase's tsconfig.json; if it isn't there any more (the
codebase, or the tcm it was made with, moved), the next command points it at this tcm's.
37.3 Imported projects
tcm import <dir> uses the tsconfig nearest that directory, with:
- bundler resolution, so extensionless and directory imports work;
- no stripping requirements (
verbatimModuleSyntax,erasableSyntaxOnlyoff), since tcm renders imports itself and compiles what Node can't strip; - emit options (
declaration,isolatedDeclarations,composite,outDir, …) dropped; moduleESNext andmoduleResolutionBundler, whatever the project sets (no warning: tcm renders the imports).
37.4 Check profiles
Each definition records the options that decide whether it typechecks: the strict family,
noUncheckedIndexedAccess, exactOptionalPropertyTypes and similar, lib and target. Later re-checks
(verify, update propagation, merging a contribution) use the recorded profile, so a library imported
with strict: false isn't suddenly checked as strict.