import type { Code } from "./code.js"; import type { SourceLocation } from "../../types/base.js"; /** * Recording where a piece of generated code came from, so errors can name * it, plus the one table that says what shape of code fits where. * * Two features generate code: filling a hole in a template (`fill.ts`) and * expanding a compile-time splice (`expandSplices.ts`). They run at * different times against different node types, but they answer the same * two questions, and the answers must not drift apart. * * Without the origin stamp, a type error inside generated code points at * the user's file at code they never wrote, with nothing saying where it * came from. */ /** Who a grafted node came from. */ export type CodeOrigin = NonNullable; /** Which fragment kinds may fill each syntactic position. A hole's `sort` * and a splice's position both ask what shape of code fits here. */ export declare const KINDS_FOR_SORT: Record; /** Does this fragment fit that position? */ export declare function kindFitsSort(code: Code, sort: string): boolean; /** * Stamp `origin` onto every node of a grafted fragment, not just the top. * * Inner nodes carry positions into a source that no longer exists, so an * error there must still say where the code came from. Deep-clones as it * recurses, which also avoids aliasing the caller's value. */ export declare function stampOrigin(node: T, origin: CodeOrigin): T;