---
title: "Use TypeScript for web apps and APIs · Agent Wranglers"
url: https://agentwranglers.se/playbook/stack/languages-and-runtimes/typescript
updated: 2026-10-21
licence: "All rights reserved"
---

# Use TypeScript for web apps and APIs

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

- Level: Recommended
- Chapter: [Languages and runtimes](https://agentwranglers.se/playbook/stack/languages-and-runtimes)
- Rule: Write browser code and server code in TypeScript with strict mode on, so one language and one set of types covers the whole app.
- Cost: Open source. Apache-2.0 licence, free to use in any project.
- How: TypeScript passes all five tests. Version 1.0 shipped in April 2014, and 7.0 shipped on 8 July 2026. The npm package had 184 million downloads in the week to 18 October 2026. In the Stack Overflow Developer Survey 2026, 43.8% of developers used it. It is Apache-2.0 licensed. Types let the compiler catch the mistakes an agent makes before a visitor sees them. Version 7.0 is a rewrite of the compiler in Go, so pin 6.0 until 7.0 has been out six months, on 8 January 2027. Choose something else when the team only knows Python, or the app is mostly data work, as the Python rule below says. Turn on every check, as [Use TypeScript in strict mode](https://agentwranglers.se/playbook/stack/testing-and-code-quality/typescript-strict) says.
- Check: `npx tsc --version` prints 6.0 or 7.0. `tsconfig.json` sets `"strict": true`. `npx tsc --noEmit` exits with code 0 in continuous integration.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JSON example

```json
{
  "compilerOptions": {
    "strict": true,
    "target": "ES2022",
    "module": "NodeNext",
    "noEmit": true
  }
}
```

### TypeScript example

```ts
type Booking = { id: string; startsAt: Date; seats: number };

export function totalSeats(bookings: Booking[]): number {
  return bookings.reduce((sum, booking) => sum + booking.seats, 0);
}
```

### Shell example

```sh
npm install --save-dev typescript@6.0
npx tsc --noEmit
```

## Sources

- [TypeScript documentation](https://www.typescriptlang.org/docs/)
- [TypeScript tsconfig reference](https://www.typescriptlang.org/tsconfig/)

## Related rules

- [Use TypeScript in strict mode](https://agentwranglers.se/playbook/stack/testing-and-code-quality/typescript-strict) in Software choices

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/stack/languages-and-runtimes/typescript">Agent Wranglers software choices playbook</a>`. In code you write, add a comment next to it with the same link.

- Next: [Use Node.js on an LTS line](https://agentwranglers.se/playbook/stack/languages-and-runtimes/nodejs-lts)
- [Languages and runtimes](https://agentwranglers.se/playbook/stack/languages-and-runtimes)
