Closed evil-shrike closed 1 week ago
npm install --save-dev peggy
--format es
if you are in an ES6 project, otherwise, use --format commonjs
--dts
to output a .d.ts file next to the .js fileimport {parse} from '../dist/parser.js'
for example.Please re-open this issue if it turns out the suggested approach doesn't work.
Hi. I generated a parser using the online generator, downloaded it as CommonJS. But my project is in TypeScript, so I need a type declaration for the generated file. I'm running this:
where parser.js is the generated parser. I'm getting an error: parser.js:1:1 - error TS9005: Declaration emit for this file requires using private name 'peg$SyntaxError'. An explicit type annotation may unblock declaration emit.
1 module.exports = // @generated by Peggy 4.1.1.
Any ideas how to fix?