mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
In particular: * the long comment was scrolling off side of screen on [npm.com](https://www.npmjs.com/package/oxc-parser). * the example is ESM, so can simplify it by using top level await. |
||
|---|---|---|
| .. | ||
| scripts | ||
| CHANGELOG.md | ||
| package.json | ||
| README.md | ||
The JavaScript Oxidation Compiler
See index.d.ts for parseSync and parseAsync API.
import assert from 'assert';
import oxc from 'oxc-parser';
const sourceText = "let foo: Foo = 'foo';";
// Filename extension is used to determine which
// dialect to parse source as
const options = { sourceFilename: 'text.tsx' };
test(oxc.parseSync(sourceText, options));
test(await oxc.parseAsync(sourceText, options));
function test(ret) {
const program = JSON.parse(ret.program);
assert(program.body.length == 1);
assert(ret.errors.length == 0);
}