# @sveltejs/acorn-typescript

> Acorn plugin that parses TypeScript

Latest version **1.0.13** (published 2026-08-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sveltejs/acorn-typescript
pnpm add @sveltejs/acorn-typescript
yarn add @sveltejs/acorn-typescript
bun add @sveltejs/acorn-typescript
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.13 |
| Published | 2026-08-13 |
| First published | 2025-02-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 215.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 51 |
| Author | tyrealhu and the Svelte team |
| Maintainers | rich_harris, svelte-admin, conduitry |

## Links

- npm: https://www.npmjs.com/package/@sveltejs/acorn-typescript
- Repository: https://github.com/sveltejs/acorn-typescript
- Homepage: https://github.com/sveltejs/acorn-typescript#readme
- Issues: https://github.com/sveltejs/acorn-typescript/issues
- npm.io page: https://npm.io/package/@sveltejs/acorn-typescript

## Recent versions

- 1.0.13 (latest) — 2026-08-13
- 1.0.12 — 2026-08-05
- 1.0.11 — 2026-07-06
- 1.0.10 — 2026-05-20
- 1.0.9 — 2026-02-11
- 1.0.8 — 2025-11-29
- 1.0.7 — 2025-11-16
- 1.0.6 — 2025-09-26
- 1.0.5 — 2025-03-04
- 1.0.4 — 2025-02-27
- 1.0.3 — 2025-02-27
- 1.0.2 — 2025-02-26
- 1.0.1 — 2025-02-26

## README

# @sveltejs/acorn-typescript

[![License](https://img.shields.io/npm/l/svelte.svg)](LICENSE.md) [![Chat](https://img.shields.io/discord/457912077277855764?label=chat&logo=discord)](https://svelte.dev/chat)

This is a plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript.

It was created as an experimental alternative, faster [TypeScript](https://www.typescriptlang.org/) parser. It will help you to parse
TypeScript using Acorn.

## Usage

To get started, import the plugin and use Acorn's extension mechanism to register it. You have to enable `options.locations` while using `@sveltejs/acorn-typescript`.

```typescript
import { Parser } from 'acorn';
import { tsPlugin } from '@sveltejs/acorn-typescript';

const node = Parser.extend(tsPlugin()).parse(
	`
const a = 1
type A = number
export {
  a,
  type A as B
}
`,
	{
		sourceType: 'module',
		ecmaVersion: 'latest',
		locations: true
	}
);
```

If you want to enable parsing within a TypeScript ambient context, where certain syntax have different rules (like `.d.ts` files and inside [declare module blocks](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html)):

```typescript
import { Parser } from 'acorn';
import { tsPlugin } from '@sveltejs/acorn-typescript';

const node = Parser.extend(tsPlugin({ dts: true })).parse(
	`
const a = 1
type A = number
export {
  a,
  type A as B
}
`,
	{
		sourceType: 'module',
		ecmaVersion: 'latest',
		locations: true
	}
);
```

## SUPPORTED

- Typescript normal syntax
- Support to parse TypeScript [Decorators](https://www.typescriptlang.org/docs/handbook/decorators.html)
- Support to parse JSX & TSX

## CHANGELOG

[click](./CHANGELOG.md)

## Acknowledgments

We want to thank [TyrealHu](https://github.com/TyrealHu) for his original work on this project. He maintained [`acorn-typescript`](https://github.com/TyrealHu/acorn-typescript) until early 2024.

---
_Source: https://npm.io/package/@sveltejs/acorn-typescript · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
