Skip to content

Syntax cheatsheet

Everything valid in TypeScript is valid in a .tsi file. This page lists only the additions, one line each, with a link to the page that explains it.

Construct Example Page
infer function infer function f(.text: string) { … } infer functions
exported export infer function f(.text: string) { … } infer functions
with an instruction marker export infer function f`triage like a support lead`(.ticket: string) { … } infer functions
annotated return type export infer function f(.m: string): Intent<User> { … } — never Promise<T> infer functions
Construct Example Page
contextual parameter (value shown to the model) .message: string Contextual parameters
plain parameter (name and type only) userId: string Contextual parameters
Construct Example Page
typed ask ..`the ticket id`<string> Extractors
untyped (free text, static any) ask ..`think step by step` Extractors
interpolation ask ..`the person described in: ${text}`<Person> Extractors
constructed, not yet resolved export const nameIntent = ..`the user's full name`<string>; Extractors
Construct Example Page
resolve an askable const x = ask intent; The ask operator
another infer function const r = ask otherFn(arg); The ask operator
pin a provider ask with fast ..`a rough summary`<string> The ask operator
chain a method (precedence like await) ask (..`x`<string>).withRetry(2) Intent methods
from plain TS const v = await f("…"); — never bare-await a raw extractor The ask operator
Construct Example Page
sigil-less ask createTicket(..`a short title`<string>, 2) Call intents
empty marker ask createTicket(“title”, 3) `` Call intents
hint marker ask createTicket`file the ticket`(..`a short title`<string>, ..`priority 1-5`<number>) Call intents
Construct Example Page
reshape the CONTEXT block infer function f`${.default}\nRules: …`(.t: string) Prompt templates
reshape the TASK block ask ..`ticket id, comply with ${.type}`<string> Prompt templates
Method On Page
.withRetry(n) · .withProvider(nameOrProvider) · .withParams({…}) every intent Intent methods
.withTimeout(ms) · .detached() the intent an infer function returns Intent methods
Construct Example Page
.ts importing .tsi import { f } from "./x.tsi"; — literal extension TypeScript interop
.tsi importing plain TS import { g } from "./y.js"; — NodeNext specifier, file is y.ts TypeScript interop
types from another file import type { Person } from "./models.js"; TypeScript interop
cheatsheet.tsi
import { createTicket } from "./tickets.js";
export type Severity = "low" | "medium" | "high";
export interface Person {
name: string;
/** age in years */
age: number;
}
export const nameIntent = ..`the user's full name`<string>;
export infer function triage`${.default}
Rules: never invent ticket ids.`(.ticket: string, fallback: Severity) {
const person = ask ..`the person described in the ticket`<Person>;
const severity = ask with careful ..`the severity of the ticket`<Severity>;
const id = ask createTicket(..`a short ticket title for ${person.name}`<string>, 2);
const name = ask nameIntent;
return { person, severity: severity || fallback, id, name };
}
tickets.ts
export async function createTicket(title: string, priority: number): Promise<string> {
return `${title}:${priority}`;
}

async infer function, export default infer function, infer on methods or arrows, fn(..), const .x = …, ..name on a parameter, __nola* identifiers, ask as an identifier — see Restrictions.

Next: Intent API