Package Exports
- acorn-typescript
- acorn-typescript/lib/index.esm.js
- acorn-typescript/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (acorn-typescript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
acorn-typescript
This is plugin for Acorn - a tiny, fast JavaScript parser, written completely in JavaScript.
It was created as an experimental alternative, faster TypeScript parser. It will help you to parse typescript script into typeScript AST.
Usage
Requiring this module provides you with an Acorn plugin that you can use like this:
import * as acorn from 'acorn'
import tsPlugin from 'acorn-typescript'
/*
*
* */
const node = acorn.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).
import * as acorn from 'acorn'
import tsPlugin from 'acorn-typescript'
/*
*
* */
const node = acorn.Parser.extend(tsPlugin({ dts: true })).parse(`
const a = 1
type A = number
export {
a,
type A as B
}
`, {
sourceType: 'module',
ecmaVersion: 'latest',
locations: true
})CHANGELOG
RoadMap
- Support to parse JSX & TSX in the future.
- Support to parse TypeScript Decorators