Skip to content

Update README.md #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -12,10 +12,10 @@ TypeScript using Acorn.
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 * as acorn from 'acorn';
import tsPlugin from '@sveltejs/acorn-typescript';
import { Parser } from 'acorn';
import { tsPlugin } from '@sveltejs/acorn-typescript';

const node = acorn.Parser.extend(tsPlugin()).parse(
const node = Parser.extend(tsPlugin()).parse(
`
const a = 1
type A = number
@@ -35,10 +35,10 @@ export {
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 * as acorn from 'acorn';
import tsPlugin from '@sveltejs/acorn-typescript';
import { Parser } from 'acorn';
import { tsPlugin } from '@sveltejs/acorn-typescript';

const node = acorn.Parser.extend(tsPlugin({ dts: true })).parse(
const node = Parser.extend(tsPlugin({ dts: true })).parse(
`
const a = 1
type A = number