GitShow/sveltejs/acorn-typescript
sveltejs

acorn-typescript

Acorn plugin that parses TypeScript

by sveltejs
Star on GitHubForkWebsitenpm

TypeScript

51 stars16 forks20 contributorsActive · 1d agoSince 2025@sveltejs/acorn-typescript@1.0.13MIT

Meet the team

See all 20 on GitHub →
TyrealHu
TyrealHu172 contributions
dummdidumm
dummdidumm40 contributions
ota-meshi
ota-meshi21 contributions
magic-akari
magic-akari16 contributions
github-actions[bot]Bot
github-actions[bot]13 contributions
ryanatkn
ryanatkn6 contributions
baseballyama
baseballyama2 contributions
Rich-Harris
Rich-Harris2 contributions

Languages

View on GitHub →
TypeScript98.3%
JavaScript1.7%

Commit activity

Last 12 weeks · 26 commits

Full graph →

Community health

2 of 6 standards met

Community profile →
50
✓README✓License○Contributing○Code of Conduct○Issue Template○PR Template

Recent PRs & issues

Active · Last activity 1d ago
See all on GitHub →
leonidaz
A type assertion in a `for await` head fails to parseOpenIssue

A type assertion without parentheses in the head of a loop fails with at , while the same head without gets as far as the assignment target check (#148): Expected: the first two parse, with the assertion as the loop's left side. TypeScript 5.9.3 reports no parse or checker diagnostic for them (apart from the undeclared names), and typescript-estree 8.56.1 and @babel/parser 7.29.3 parse them. The third is #148. Cause. acorn's reads the head of a loop with , which is right for JavaScript's . acorn-typescript reads and only in , which doesn't reach, so the head ends before , no follows, and acorn fails at (L341). TypeScript's parser reads the head of every loop as an expression ( with disallowed), and works here because acorn-typescript reads as a subscript. Fix direction. In a head, read an or after the expression, as does (a or around it), before checking for . With #148 fixed, the assertion is kept as the assignment target. #110 doesn't change this. Found through TSRX, which uses this parser.

leonidaz · 1h ago
leonidaz
`export default @dec declare class A {}` fails to parseOpenIssue

A decorated after fails to parse, with or without , though the same class parses at the start of a statement: Expected, as TypeScript 5.9 and typescript-estree parse them: an of a with (and ) and the decorators, whose name is optional (). After , TypeScript reads as the start of a declaration (), and and after the decorators as its modifiers, in either order. It reports nothing for them. Without the decorators, is a syntax error in TypeScript too (TS1005), since is then the exported value. Cause. reads and , and leaves the rest to acorn, which reads the decorators as the start of a class expression (#124), and after them as the exported expression. Fix direction. After decorators, read , and before or after it on the same line, as the modifiers of an ambient class with an optional name, as is read at the start of a statement. This goes with #124. #110 doesn't change this. Found through TSRX, which uses this parser.

leonidaz · 1h ago
leonidaz
A class member modifier, or a repeated or misplaced modifier, before a declaration fails to parseOpenIssue

A modifier that only a class member takes, or a repeated or misplaced modifier, before a declaration fails to parse, where TypeScript's parser reads the declaration and its checker reports the modifier. One of them parses without an error: Expected, as TypeScript 5.9 reads them: its takes , , , , , , and before a declaration on the same line, on any line, and , and reads them all, repeated or not, as modifiers of the declaration. Its checker () then reports the first one the declaration can't take, which typescript-estree reports for most of these too: Inside a block (a function's body), any of them but on a class or on a function is TS1184 at the first one. A second is TypeScript's parser error TS1146 (), as reads only one . Cause. acorn reads these words at the start of a statement as names (, and the other strict-mode reserved words as reserved ones), and this parser reads only and as modifiers there (, , ), each once and only before a class or an interface (#143). After , takes none of the other words for the start of a declaration, and reads after without checking it. Fix direction. Where TypeScript's reads modifiers before a declaration, read them all, parse the declaration with the ones the tree keeps (, , on a class, on a function), and raise the error TypeScript's checker reports, as typescript-estree does. This goes with #143, which covers before a declaration other than a class. #110 doesn't change this. Found through TSRX, which uses this parser.

leonidaz · 1h ago
Structured data for AI agents

Repository: sveltejs/acorn-typescript. Description: Acorn plugin that parses TypeScript Stars: 51, Forks: 16. Primary language: TypeScript. Languages: TypeScript (98.3%), JavaScript (1.7%). License: MIT. Homepage: https://www.npmjs.com/package/@sveltejs/acorn-typescript?activeTab=readme Latest release: @sveltejs/acorn-typescript@1.0.13 (1mo ago). Open PRs: 8, open issues: 47. Last activity: 1d ago. Community health: 50%. Top contributors: TyrealHu, dummdidumm, ota-meshi, magic-akari, github-actions[bot], ryanatkn, baseballyama, Rich-Harris, leonidaz, 43081j and others.

·@ofershap

Replace github.com with gitshow.dev