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.

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.`

It is possible to import TypeScript source file.

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

Yes and No.

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

You can also run a TypeScript compilation using the scripts compile command.

Terminal window
genaiscript scripts compile

However, at runtime, GenAIScript converts TypeScript to JavaScript without type checks through tsx.