Skip to content

Commit 54802c4

Browse files
committed
chore: adjust readme, update license, acknowledge original author
1 parent 8956dc5 commit 54802c4

File tree

3 files changed

+38
-48
lines changed

3 files changed

+38
-48
lines changed

LICENSE renamed to LICENSE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

33
Copyright (c) 2022 Tyreal Hu
4+
Copyright (c) 2025 The Svelte Team
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,62 @@
11
# acorn-typescript
2-
[![npm version](https://img.shields.io/npm/v/acorn-typescript.svg?style=flat)](https://www.npmjs.com/package/acorn-typescript)[![Coverage Status](https://codecov.io/gh/TyrealHu/acorn-typescript/branch/master/graph/badge.svg)](https://codecov.io/gh/TyrealHu/acorn-typescript)
3-
---
42

5-
This is plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript.
3+
[![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)
4+
5+
This is a plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript.
66

77
It was created as an experimental alternative, faster [TypeScript](https://www.typescriptlang.org/) parser. It will help you to parse
8-
typescript script into typeScript AST.
8+
TypeScript using Acorn.
99

1010
## Usage
1111

12-
Requiring this module provides you with an Acorn plugin that you can use like this:
12+
To get started, import the plugin and use Acorn's extension mechanism to register it. You have to enable `options.locations` while using `acorn-typescript`.
1313

1414
```typescript
15-
import * as acorn from 'acorn'
16-
import tsPlugin from 'acorn-typescript'
15+
import * as acorn from "acorn";
16+
import tsPlugin from "acorn-typescript";
1717

18-
/*
19-
*
20-
* */
21-
const node = acorn.Parser.extend(tsPlugin()).parse(`
18+
const node = acorn.Parser.extend(tsPlugin()).parse(
19+
`
2220
const a = 1
2321
type A = number
2422
export {
2523
a,
2624
type A as B
2725
}
28-
`, {
29-
sourceType: 'module',
30-
ecmaVersion: 'latest',
31-
locations: true
32-
})
26+
`,
27+
{
28+
sourceType: "module",
29+
ecmaVersion: "latest",
30+
locations: true,
31+
}
32+
);
3333
```
3434

35-
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)).
35+
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)):
36+
3637
```typescript
37-
import * as acorn from 'acorn'
38-
import tsPlugin from 'acorn-typescript'
38+
import * as acorn from "acorn";
39+
import tsPlugin from "acorn-typescript";
3940

40-
/*
41-
*
42-
* */
43-
const node = acorn.Parser.extend(tsPlugin({ dts: true })).parse(`
41+
const node = acorn.Parser.extend(tsPlugin({ dts: true })).parse(
42+
`
4443
const a = 1
4544
type A = number
4645
export {
4746
a,
4847
type A as B
4948
}
50-
`, {
51-
sourceType: 'module',
52-
ecmaVersion: 'latest',
53-
locations: true
54-
})
55-
```
56-
57-
## Notice
58-
- You have to enable options.locations while using acorn-typescript
59-
```ts
60-
acorn.parse(input, {
61-
sourceType: 'module',
62-
ecmaVersion: 'latest',
63-
// here
64-
locations: true
65-
})
49+
`,
50+
{
51+
sourceType: "module",
52+
ecmaVersion: "latest",
53+
locations: true,
54+
}
55+
);
6656
```
6757

6858
## SUPPORTED
59+
6960
- Typescript normal syntax
7061
- Support to parse TypeScript [Decorators](https://www.typescriptlang.org/docs/handbook/decorators.html)
7162
- Support to parse JSX & TSX
@@ -74,8 +65,6 @@ acorn.parse(input, {
7465

7566
[click](./CHANGELOG.md)
7667

77-
## RoadMap
78-
- support import-assertions
68+
## Acknowledgments
7969

80-
## License
81-
[MIT](https://couto.mit-license.org/)
70+
We want to thank [TyrealHu](https://github.com/TyrealHu) for his original work on this project. He maintained `acorn-typescript` until early 2024.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "acorn-typescript",
33
"version": "1.4.13",
4-
"description": "Alternative, TypeScript parser",
4+
"description": "Acorn plugin that parses TypeScript",
55
"source": "src/index.ts",
66
"main": "lib/index.js",
77
"module": "lib/index.mjs",
@@ -26,14 +26,14 @@
2626
},
2727
"repository": {
2828
"type": "git",
29-
"url": "git+https://github.com/TyrealHu/acorn-typescript.git"
29+
"url": "git+https://github.com/sveltejs/acorn-typescript.git"
3030
},
31-
"author": "tyrealhu",
31+
"author": "tyrealhu and the Svelte team",
3232
"license": "MIT",
3333
"bugs": {
34-
"url": "https://github.com/TyrealHu/acorn-typescript/issues"
34+
"url": "https://github.com/sveltejs/acorn-typescript/issues"
3535
},
36-
"homepage": "https://github.com/TyrealHu/acorn-typescript#readme",
36+
"homepage": "https://github.com/sveltejs/acorn-typescript#readme",
3737
"devDependencies": {
3838
"@types/jest": "^24.1.0",
3939
"acorn": "^8.9.0",

0 commit comments

Comments
 (0)