AnalyzeHost

tcmts.core.analyze.AnalyzeHost · #yc5grajt · type

import type { Compile, CompilerOptions } from "#codebase/tcmts/core/program";
import type { Diagnostic as ts_Diagnostic } from "typescript/sync";

export interface AnalyzeHost {
  /** absolute path of `.tcm/cache`; relative imports into it address definitions by hash */
  cacheDir: string;
  /**
   * Resolve a dotted codebase name (from `#codebase/...` imports) to a definition hash; throw if unknown.
   * `meaning` picks between a type and a value sharing the name.
   */
  resolveName(name: string, meaning: "type" | "value"): string;
  ignoreDiagnostics?: number[];
  /**
   * false: no type errors are asked for, only syntax errors count. For code whose types aren't this analysis's to
   * judge: definitions received are re-derived and re-hashed to check they're what they claim, and typechecked where
   * they're merged.
   */
  typecheck?: boolean;
  /**
   * false: no type shapes are worked out (`DefRecord.shape`, what search by type matches): what's received is mostly
   * what only history names, so a shape is worked out when a search needs it.
   */
  shapes?: boolean;
  /** builds the program instead of a fresh `createProgram` (the watcher's incremental compiler) */
  compile?: Compile;
  /** the project's compiler options (see projectCompilerOptions); tcm's defaults otherwise */
  compilerOptions?: CompilerOptions;
  /**
   * Lineage salt for a term or class declared as `name` in `file`. JavaScript gives every declaration its own
   * identity (`new Map()` twice is two maps; two identical classes fail each other's `instanceof`), so without
   * a salt identical code at two places would wrongly become one definition. Return undefined for none.
   */
  saltFor?(file: string, name: string, targetPath?: string): string | undefined;
  /** diagnostics that don't count (beyond `ignoreDiagnostics`' codes) */
  skipDiagnostic?(d: ts_Diagnostic): boolean;
  /**
   * The role a codebase definition plays (`table`, `every`: as its package's manifest says, by its hash), if any: a
   * top-level call of a `table` with a row type is a table.
   */
  roleOf?(hash: string): string | undefined;
  /**
   * Whether the definition declared as `name` in `file` was a table: code analyzed again (re-derived, received) has
   * no names to read roles from, so it stays what it was, its schema worked out here all the same.
   */
  wasTable?(file: string, name: string): boolean;
  /** where package `name` is for imports in `file`, when tcm provides it (see PackageResolver) */
  packageDir?(name: string, file: string): string | undefined;
}

uses

used by