---
title: Introduction
url: "https://scriptc.dev/docs"
docs_index: /llms.txt
lastUpdated: 2026-10-02
---

> For an index of all documentation, see [/llms.txt](/llms.txt).

scriptc compiles TypeScript and JavaScript to native executables and WebAssembly. It uses TypeScript's type information to compile supported code directly to native instructions. Static builds run without Node.js or a JavaScript engine.

For npm dependencies and `any`-typed code, enable `--dynamic` to include an embedded JavaScript engine. Use [coverage reports](/docs/coverage) to check which parts of a program compile statically, require the engine, or are unsupported.

## Compile a program

Create a TypeScript file:

```ts title="fib.ts"
function fib(n: number): number {
  return n < 2 ? n : fib(n - 1) + fib(n - 2);
}
console.log(fib(30));
```

Compile and run it:

```console
$ scriptc run fib.ts
832040
```

To create an executable you can run separately, use `scriptc build`:

```console
$ scriptc build fib.ts -o fib >/dev/null
$ ./fib
832040
```

See [Quickstart](/docs/quickstart) for installation and platform requirements.

## Compilation modes

scriptc classifies operations into three tiers:

<table>
  <thead>
    <tr>
      <th>
        Tier
      </th>

      <th>
        Behavior
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        Static
      </td>

      <td>
        Compiles to native code. This is the default mode.
      </td>
    </tr>

    <tr>
      <td>
        Dynamic
      </td>

      <td>
        Runs in the embedded quickjs-ng engine when

        <code>--dynamic</code>

        is enabled. This includes npm packages' shipped JavaScript and supported uses of

        <code>any</code>

        .
      </td>
    </tr>

    <tr>
      <td>
        Rejected
      </td>

      <td>
        Produces a compilation diagnostic with an

        <code>SC</code>

        code, source location, and rewrite hint where available.
      </td>
    </tr>
  </tbody>
</table>

Enabling `--dynamic` does not add support for unsupported statically typed calls. The [npm dependencies guide](/docs/dependencies) explains package execution and the boundary between static and dynamic code.

## Language and API support

Static compilation includes supported forms of:

- Classes, inheritance, closures, generics, discriminated unions, destructuring, and spread.
- `async`/`await`, promises, exceptions, iterators, and resource disposal.
- Strings, BigInts, arrays, Maps, Sets, JSON, Math, typed arrays, and Buffers.
- Node.js filesystem, path, process, child-process, crypto, timer, and networking APIs.

These features have API-specific restrictions. The [Node.js compatibility reference](/compatibility) lists static and dynamic API support, and [Limitations](/docs/limitations) describes compilation restrictions and runtime differences from Node.js.

Programs are checked against the `es2025` standard library and scriptc's ambient declarations. Project declarations such as `@types/node` participate when available, and `tsconfig.json` controls checker strictness.

## Runtime type checks

Conversions from dynamic values to static types validate the data at runtime. For example, a JSON value must match the target type before it can be used as that type:

```ts title="cast.ts"
type Config = { port: number };

try {
  const config = JSON.parse('{"port": "eighty"}') as Config;
  console.log(config.port);
} catch (error) {
  if (error instanceof Error) console.log(error.message);
}
```

```console
$ scriptc run cast.ts
expected number at $.port, got string
```

This validation differs from TypeScript assertions under Node.js. See [runtime type checks](/docs/limitations#runtime-type-checks) for details.

## Build-time evaluation

`comptime(() => ...)` evaluates a TypeScript function in an isolated VM during compilation and embeds its result as a literal:

```ts title="label.ts"
const label = comptime(() => "hello".toUpperCase());
console.log(label);
```

```console
$ scriptc run label.ts
HELLO
```

## Next steps

- [Quickstart](/docs/quickstart): install the CLI and build an executable.
- [CLI Reference](/docs/cli): commands and compiler options.
- [Coverage Reports](/docs/coverage): identify dynamic operations and compilation blockers.
- [npm Dependencies](/docs/dependencies): use packages in compiled programs.
- [How It Works](/docs/how-it-works): compiler stages, runtime, and testing.

---

For a semantic overview of all documentation, see [/sitemap.md](/sitemap.md)

For an index of all available documentation, see [/llms.txt](/llms.txt)

For agent-facing discovery, including API and MCP surfaces, see [/agents.md](/agents.md)