API / @aihu/tsc

@aihu/tsc

Compiler & tooling

aihu-tsc — `tsc` for projects containing .aihu Single File Components. Type-checks .aihu sources as virtual TypeScript, with no .aihu.ts files written to disk.

version
0.3.3
exports
10
values
7
types
3
01

buildMappings

functionagent
function buildMappings(source: string, generated: string): CodeMapping[]

Map the generated surface back onto the source, line by line.

02

createAihuLanguagePlugin

function
function createAihuLanguagePlugin<T = string>( tsModule: typeof ts, options?: AihuLanguagePluginOptions, ): LanguagePlugin<T, AihuVirtualCode>
03

getUncompilableFiles

function
function getUncompilableFiles(): ReadonlySet<string>
04

keepDiagnosticCode

function
function keepDiagnosticCode( code: number | string | undefined, fileName: string | undefined, strictTemplates: boolean, ): boolean

The one diagnostic-suppression policy, shared with the language server (step 5): an editor squiggle and a CI failure must apply the SAME filter, or the split-brain this unification removes would creep back in as editor-only implicit-any noise.

05

loadTscProjectConfig

function
async function loadTscProjectConfig( root: string, ): Promise<{ target?: 'client' | 'server' | 'universal'; strictTemplates?: boolean }>

Load `{ target, strictTemplates }` from `root`'s `vite.config.ts`.

06

run

function
function run(options: RunOptions = {}): number
07

IMPLICIT_ANY_CODES

const
const IMPLICIT_ANY_CODES

Implicit-`any` diagnostics, suppressed for `.aihu` files only.

08

AihuLanguagePluginOptions

interface
interface AihuLanguagePluginOptions {
  /**
   * #486 step 4 — switch the sidecar's attribute/component-prop type layer on
   * (`aihu-tsc --strict-templates`). Default off: the virtual code is
   * byte-identical to the pre-#486 surface.
   */
  strictTemplates?: boolean
  /**
   * Build target threaded to `compileSidecar` (`--target`) — see its own doc
   * comment in `@aihu/compiler` for why this affects type-check accuracy.
   * Sourced from the project's `vite.config.ts` (`AihuConfig.compiler.target`)
   * by `run()`/the language server's project-config loader; a caller with no
   * config to read leaves this unset and gets the binary's own default
   * (`universal`).
   */
  target?: 'client' | 'server' | 'universal'
}
09

AihuVirtualCode

interface
interface AihuVirtualCode extends VirtualCode {
  id: 'main'
  languageId: 'typescript'
}
10

RunOptions

interface
interface RunOptions {
  /** Path to a tsconfig.json, or a directory containing one. Defaults to cwd. */
  project?: string
  /** Report implicit-`any` inside .aihu files too. */
  strictTemplates?: boolean
  cwd?: string
  /**
   * Build target threaded to `compileSidecar` (`--target`) — sourced from the
   * project's `vite.config.ts` (`AihuConfig.compiler.target`) by the CLI
   * entry (`bin/aihu-tsc.mjs`) via `loadTscProjectConfig()`, since `run()`
   * itself is synchronous. See `compileSidecar`'s doc comment in
   * `@aihu/compiler` for why this affects type-check accuracy.
   */
  target?: 'client' | 'server' | 'universal'
}