Skip to content
A simple 8-bit style image shows a blue file icon marked ".mts" linked with dotted lines to two other file icons: a dark gray one representing JavaScript and a light gray one for TypeScript. All icons are arranged on a plain white background with a geometric arrow indicating import, using blue, gray, black, white, and yellow. The design is flat, highly simplified, without people or text, and measures 128 by 128 pixels.

TypeScript

TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. GenAIScript scripts can be authored in TypeScript.

From JavaScript to TypeScript

You can convert any existing script to typescript by changing the file name extension to .genai.mts.

summarizer.mts
def("FILE", files)
$`Summarize each file. Be concise.`

Importing TypeScript source files

It is possible to import TypeScript source file using dynamic imports.

summarizer.mts
export function summarize(files: string[]) {
def("FILE", files)
$`Summarize each file. Be concise.`
}
  • dynamic import (async import(...))
const { summarize } = await import("./summarizer.mts")
summarize(env.generator, env.files)

Does GenAIScript type-check prompts?

No.

GenAIScript converts TypeScript to JavaScript without type checks through tsx.

Most modern editors, like Visual Studio Code, will automatically type-check TypeScript sources.