tcmts.core.canonicalize

Types

CanonContext type
Meaning type
RawSpan type
Resolved type
What an identifier denotes.
SiteResult type
SymbolLookup type
The checker questions canonicalization asks; analyze.ts answers them from a prefetched cache.

Shared

IDENT_NAME RegExp
NAMING_ASSIGNMENTS Set<SyntaxKind>
REJECTED Partial<Record<SyntaxKind, string>>
canonicalizeSite (site: DefSite, ctx: CanonContext) => SiteResult
declKey (x: Node | NodeHandle<Node>) => string
A declaration, by file and node index: what a checker's NodeHandle and a parsed node have in common.
invokedWhereWritten (fn: Node) => boolean
Whether a function expression is called where it's written (`(() => { … })()`, `(function () { … })()`): its body runs as the code around it does.
isAssignmentTarget (node: Node) => boolean
`x = …`, `x += …`, `x++`, `[x] = …`, `({ x } = …)`, `for (x of …)`
isCalled (id: Node) => boolean
Whether a reference is called where it's written: `f(…)`, `new f(…)`, `` f`…` ``, or `class C extends f` (making a `C` calls it). Calling a function runs its body, so what that uses is needed then too (see `initOrder`); a reference that's only read (`const alias = f`) doesn't run it.
isDeferred (id: Node, roots: readonly Node[]) => boolean
A reference is deferred when it is only evaluated later (inside a function body or instance field initializer). A function called where it's written (`(() => { … })()`) runs now: what it uses isn't deferred.
isIntrinsicTag (name: string) => boolean
TypeScript's rule: a lowercase or dashed tag is an intrinsic element (`div`, `my-widget`), anything else a value.
isJsxTag (n: Node) => boolean
`Counter` in `<Counter>`, `</Counter>`, `<Counter />`
isList (x: Node | NodeArray<Node>) => x is NodeArray<Node>
isNamingPosition (id: Identifier) => boolean
Identifiers whose text becomes a runtime name: declared function/class names, and bindings that name an anonymous function or class (`const f = () => {}`, `(cb = () => {}) =>`, `f = function () {}`). Renaming these is observable through `.name`, so their text is hashed; every other local stays alpha-renamable.
isSkippedModifier (n: Node) => boolean
isStructuralName (id: Identifier) => boolean
Identifiers that are structural names (property keys, labels), never renamed or resolved.
isTaggedTemplatePart (node: Node) => boolean
isTypePosition (id: Node) => boolean
Type positions are erased at runtime; references there need `import type` in generated modules.
jsxText (raw: string) => string
Text between JSX tags as React sees it: each line trimmed, blank lines dropped, lines joined with a space. So reformatting markup hashes the same, and whitespace React keeps (`a <b/>`) still counts.
kindName string[]
Stable names for syntax kinds. `ts.SyntaxKind` numbers shift between TypeScript releases, names don't. The enum has aliases (FirstToken, LastKeyword, ...); the first declared name for each value wins.
meaningAt (id: Node) => Meaning
Which meaning of a name an identifier uses. Usually that's its position, except that `typeof x` names a value even though it sits in a type, and so does a computed key (`readonly [evaluate]: …`, `evaluate` a unique symbol beside a type of that name).
slots (node: Node) => [string, Node | NodeArray<Node>][]
A node's children as the IR labels them: slot name, and the node or list there (see slots.ts).