runCheck

tcmts.cli.checkers.runCheck · #q7rgqylo · term · runs on the server

uses tcmts.core.analyze.analyzeProject, which uses tcmts.core.analyze.analyzeWith, which uses tcmts.core.program.compilerOptions, which uses tcmts.core.program.tcmNodeTypes, which uses node:path

Analyze a CheckRequest: what a checker process does with each, and its compilation let go after.

import type { CheckRequest, CheckResult } from "#codebase/tcmts/cli/checkers";
import { analyzeProject } from "#codebase/tcmts/core/analyze";

export function runCheck(req: CheckRequest): CheckResult {
  const a = analyzeProject(req.files, {
    cacheDir: req.cacheDir,
    ignoreDiagnostics: req.ignore,
    compilerOptions: req.options,
    typecheck: req.typecheck,
    shapes: req.shapes,
    saltFor: (file, name) => req.salts[file]?.[name],
    wasTable: (file, name) => req.tables?.[file]?.includes(name) ?? false,
    // (rendered modules import what they use by hash: there are no codebase names to look up)
    resolveName: (name) => {
      throw new Error(`'${name}' is not in the codebase`);
    },
  });
  try {
    return { problems: [...a.errors, ...a.diagnostics.map((d) => d.formatted)], defs: a.defs };
  } finally {
    a.dispose?.();
  }
}

uses

used by