# A TypeScript starter for SuiteScript

A working reference for TypeScript in SuiteCloud projects and a step toward official support in the CLI.

**Published:** September 29, 2026 | **Author:** [Joaquín Gatica](https://www.linkedin.com/in/joaquingatica/) | **Categories:** SuiteCloud, NetSuite, Open-Source

Too many SuiteScript bugs are found the expensive way: deploy to an account, run
the script, read the execution log, fix, and deploy again. The SuiteCloud CLI
already ships a solid testing framework with Jest, but type checking, linting,
and formatting are left to each developer. We built
[`suitecloud-ts`](https://github.com/anagram-dev/suitecloud-ts), an
open-source starter project based on TypeScript 7 or later that sets up all
three. It hooks into the SuiteCloud CLI commands you use today and is optimized
for AI coding agents.

## Toward official support

TypeScript for SuiteScript is not a new idea. Many teams already run their own
setup, and every one of them solves similar problems in slightly different
ways. We don't want to add
[another competing standard](https://xkcd.com/927/) to the pile, so we're
sharing this as a working reference for an
[active proposal](https://github.com/oracle/netsuite-suitecloud-sdk/issues/976)
to bring TypeScript support to the SuiteCloud CLI.

The proposal grew out of conversations with members of the SuiteCloud team at
SuiteWorld 2025, both after their sessions and at DevLand. It compares three
folder layouts, and `suitecloud-ts` follows Option 3, which keeps TypeScript
sources outside `FileCabinet/`. Rather than argue for it in the abstract, we
wanted something people can actually run.

For a service provider, there's a less obvious reason to want official
TypeScript support: **what we build should be maintainable by any NetSuite
developer, not just us.**

We can't assume that developer will know TypeScript. Without a setup
recommended by Oracle, choosing TypeScript for a customer's account can make
their scripts harder to support later. With TypeScript scaffolded during
`project:create`, the same way the CLI already offers Jest, our customers would
have a documented setup to learn and official support behind it.

This is also why the starter begins with Account Customization Projects (ACPs),
since a SuiteApp is usually maintained by the company that publishes it. Most of
the setup still applies to SuiteApps, and we plan to support them as well.

## Enabling gradual adoption

NetSuite runs SuiteScript as AMD modules from the account's File Cabinet, which
the CLI updates from the local `FileCabinet/` folder. The starter keeps all your
script sources, TypeScript and JavaScript alike, outside that folder and builds
them into it:

```text
src/                 # defaultProjectFolder for the SuiteCloud CLI
├ FileCabinet/
│ ├ SuiteScripts/    # build output, deployed but not in Git
│ └ ...              # other File Cabinet folders (e.g. Templates/)
├ Objects/           # SuiteCloud XML objects, unchanged
├ SuiteScripts/      # TS and JS sources, in Git but not deployed
├ deploy.xml
└ manifest.xml
```

Plain JavaScript lives in the same `src/SuiteScripts/` folder as TypeScript, and
TypeScript can import it, so an existing project can **adopt TypeScript one file
at a time**. Jest tests can be written in TypeScript too, and they're
type-checked like the sources.

## The CLI keeps working as usual

The starter hooks into the CLI's `beforeExecuting` lifecycle through
`suitecloud.config.js`, so there is no extra command to remember. Commands such
as `project:deploy` build the project first, so **a type error stops the
deployment** before anything reaches the account.

## A two-step build for TypeScript 7+

TypeScript 7 is a ground-up rebuild of the compiler that runs considerably
faster, but it also
[dropped support for compiling to AMD](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/#updates-since-5x-and-new-behaviors-from-60).
Staying on an older compiler would have been the easy way out, but we chose to
handle the migration once, so projects built on the starter get the new compiler
today and can keep upgrading to future TypeScript versions.

The build therefore runs in two steps:

1. `tsc` compiles `src/SuiteScripts/**/*.ts` into ES modules in an intermediate
   `build/` folder.
2. Rollup transforms that output into AMD modules under
   `src/FileCabinet/SuiteScripts/`, keeping the original module structure.

Since `tsc` already runs to check types, we let it emit the JavaScript too.
Rollup only changes the module format and handles a few NetSuite quirks, such as
keeping the `@NApiVersion` and `@NScriptType` annotations at the top of each
file. Neither step minifies the code. The deployed files read like the source
without its types, so stack traces in the execution log are still easy to
follow.

## Ready for AI coding agents

Type checking, linting, formatting, and tests help everyone on a project, and
that includes AI coding agents. An agent works best when it can verify its own
change quickly and deterministically. With all four checks in place, it finds
out whether a script compiles and passes its tests before anyone deploys it.

Agents also need context, so the starter includes two things for them:

- `AGENTS.md` tells an agent where to make changes, which checks to run for
  small and large changes, and how to write TypeScript and JavaScript
  SuiteScripts in this project. It also tells the agent never to deploy to an
  account unless asked.
- `.agents/skills/` includes a selection of the
  [NetSuite agent skills](https://github.com/oracle/netsuite-suitecloud-sdk/tree/master/packages/agent-skills)
  that Oracle publishes. They cover the best practices in the
  [SAFE Guide](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/chapter_1529088392.html#subsect_1568818300),
  record field IDs, role permissions, secure coding, and SuiteScript 2.1
  upgrades, among others.

## Using npm packages in SuiteScript

SuiteScript can't load npm packages directly, since NetSuite only runs AMD
modules from the File Cabinet. The starter solves this with a library bundler
that reuses the build's Rollup setup to turn each package into a self-contained
AMD module with its types, which scripts import like any other file.

The build and linter reject direct package imports, so a script can't reach an
account with an import NetSuite won't resolve. The
[docs](https://github.com/anagram-dev/suitecloud-ts/blob/main/docs/library-bundler.md)
explain how to add a package, and Zod v4 is included as a working example.

## A sample TypeScript RESTlet

Here is a simplified version of the repository's
[sample TypeScript RESTlet](https://github.com/anagram-dev/suitecloud-ts/blob/ceae423a3d93c04648cb3d92860f85688d09cc26/src/SuiteScripts/RL_Echo.ts),
which uses Zod to validate the request body:

```ts
/**
 * @NApiVersion 2.1
 * @NScriptType Restlet
 */

import type { EntryPoints } from 'N/types'
import type { Response } from './utils/response'
import z from './lib/zod'

type Data = Record<string, unknown>

const PayloadSchema = z.object({
  echo: z.literal(true),
})

type Payload = z.infer<typeof PayloadSchema>

export const post: EntryPoints.RESTlet.post<Data, Response<Payload>> = (
  body,
) => {
  const result = PayloadSchema.safeParse(body)
  if (!result.success) {
    return {
      status: 'bad_request',
      message: z.prettifyError(result.error),
    }
  }
  return {
    status: 'success',
    data: result.data,
  }
}
```

The `EntryPoints` type and the rest of the `N/*` types come from
[`@hitc/netsuite-types`](https://www.npmjs.com/package/@hitc/netsuite-types).
Thanks to [Head in the Cloud Development](https://github.com/headintheclouddev)
for maintaining them. We're proud to have contributed to the package, even if
it was a
[minor fix](https://github.com/headintheclouddev/typings-suitescript-2.0/pull/361).

## Developer experience extras

Beyond the build, the starter includes a set of optional quality-of-life
features:

- ESLint with TypeScript support and `requirejs` rules for plain JavaScript.
- Prettier formatting.
- Git hooks for linting, formatting, and Conventional Commits.
- A GitHub Actions workflow for pull request validation.
- An `.nvmrc` and a Nix flake with `direnv` support.

None of them is part of the build, so you can remove any of them, and the
[docs](https://github.com/anagram-dev/suitecloud-ts/blob/main/docs/disabling-features.md)
explain how.

## Getting started

The starter is released under
[MIT-0](https://github.com/anagram-dev/suitecloud-ts/blob/main/LICENSE), so you
can copy it into your own projects without keeping any notice or attribution.

To start a new project, click **Use this template** on the repository page, or
create one with the [GitHub CLI](https://cli.github.com/):

```bash
gh repo create my-project --template anagram-dev/suitecloud-ts --private --clone
cd my-project
```

Either way, the new repository starts with a fresh history. Then follow the
remaining steps in the README's
[Getting Started](https://github.com/anagram-dev/suitecloud-ts#getting-started)
section, which also explains how to clone the starter without GitHub. From
there, write your scripts in `src/SuiteScripts/` and use the CLI as you always
have.

## Feedback and contributions

This is the first public release of `suitecloud-ts`, and we'd like it to work
for more projects than ours.

Since SuiteWorld 2025, we've met with the SuiteCloud team, and they've been open
to contributions from the community. If this project's approach holds up, we'd
like to contribute some version of it as scaffolding that `project:create` can
offer, and at that point this repository will have done its job.

Until the CLI supports TypeScript, using it in a customer's account remains a
trade-off to weigh case by case, and we'd like to hear what would make
TypeScript scripts easier for other developers to maintain. If official support
comes, we'll do our best to provide instructions or helpers that projects built
on the starter can use to adopt it.

If you try the starter, issues and pull requests are welcome on
[GitHub](https://github.com/anagram-dev/suitecloud-ts). If you already have a
TypeScript setup for SuiteScript, we'd especially like to hear how yours
differs. Open an issue on the repository or comment on
[issue #976](https://github.com/oracle/netsuite-suitecloud-sdk/issues/976), and
link your setup if it's public.

One shared answer, ideally in the CLI itself, beats everyone maintaining their
own.
