CanonContext

tcmts.core.canonicalize.CanonContext · #bgs55le5 · type

import type { Meaning, Resolved, SymbolLookup } from "#codebase/tcmts/core/canonicalize";
import type { DefKind, ExtRef } from "#codebase/tcmts/core/types";
import type {
  ImportClause as ts_ImportClause, ImportSpecifier as ts_ImportSpecifier, NamespaceImport as ts_NamespaceImport,
  Node as ts_Node, SourceFile as ts_SourceFile,
} from "typescript/ast";
import type { NodeHandle as ts_NodeHandle } from "typescript/sync";

export interface CanonContext {
  checker: SymbolLookup;
  /** import mode: enums, namespaces and parameter properties are allowed (compiled when run) */
  allowTransformed: boolean;
  kindOf(def: number): DefKind;
  /** whether a definition is a top-level `let` (imported code only) */
  isLet(def: number): boolean;
  /** files being analyzed together (by path); references between them resolve to definitions */
  projectFiles: Set<string>;
  /** a file's name, by path */
  fileName(path: string): string;
  /** a declaration in a project file, as a node */
  nodeOf(handle: ts_NodeHandle): ts_Node | undefined;
  warn(message: string, node: ts_Node): void;
  /** definitions by declaration (see declKey) */
  declToDef: Map<string, number>;
  classifyImport(
    decl: ts_ImportSpecifier | ts_ImportClause | ts_NamespaceImport,
    meaning: Meaning,
  ): Resolved;
  classifyDynamicImport(spec: string, at: ts_Node): ExtRef;
  /** what a project module re-exports from a package as `name` (`export * from "pkg"`, `export { x } from "pkg"`,
   * `export * as name from "pkg"`, whose namespace it is: export `*`) */
  classifyReexport(file: ts_SourceFile, name: string, at: ts_Node): ExtRef | undefined;
  /** the hash a codebase path names, if it names one (a type, or else a value) */
  resolvePath?(path: string): string | undefined;
  /** the package JSX compiles to calls of (`<jsxImportSource>/jsx-runtime`), as resolved from `at` */
  jsxRuntime(at: ts_Node): ExtRef;
}

uses

used by