# TypeScript

> Learn how to use TypeScript for better tooling and scalability in your GenAIScript projects.

[TypeScript](https://www.typescriptlang.org/) 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

[Section titled “From JavaScript to TypeScript”](#from-javascript-to-typescript)

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

summarizer.mts

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

Note

Make sure to use the **`.mts`** file extension - not `.ts` -, which forces Node.JS to use the [ESM](https://www.typescriptlang.org/docs/handbook/modules/guides/choosing-compiler-options.html) module system.

## Importing TypeScript source files

[Section titled “Importing TypeScript source files”](#importing-typescript-source-files)

It is possible to [import](/genaiscript/reference/scripts/imports) TypeScript source file.

summarizer.mts

```js
export function summarize(files: string[]) {
    def("FILE", files)
    $`Summarize each file. Be concise.`
}
```

* import

```js
import { summarize } from "./summarizer.mts"
summarize(env.generator, env.files)
```

## Does GenAIScript type-check prompts?

[Section titled “Does GenAIScript type-check prompts?”](#does-genaiscript-type-check-prompts)

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.

```sh
genaiscript scripts compile
```

However, at runtime, GenAIScript converts TypeScript to JavaScript **without type checks** through [tsx](https://tsx.is/usage#no-type-checking).