question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do you export parser Typescript types along with the parser?

See original GitHub issue

I’m using peggy to generate a parser that I’m publishing to npm. The project the parser is in uses typescript.

I build the output file from peggy ./dist/parser.js. In my project, I also have ./parser.d.ts, where I give the parser generated by peggy its type:

export function parse(input: string): Program;

I compile typescript also the ./dist folder. My hope was that the parser.js from peggy and the parser.d.ts file from typescript would line up in the export.

However, after an npm publish of package, there is no parser.d.ts. And on import of package/dist/parser in my other project, it complains of no types for the parser.

I’m hoping this is a solved problem and I’m barking up the wrong tree.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
ghostcommented, Dec 29, 2021

I personally rolled back to pegjs@0.10.0, ts-pegjs@0.3.1 Output required a little tweaking (escaped JS code like imports must be moved to the appropriate place)

1reaction
klaas1979commented, Jan 10, 2022

thank you, did this as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

typescript-parser
Generates typescript code for a class property accessor. export. Parameters. accessor: AccessorDeclaration. __namedParameters: object. tabSize ...
Read more >
Typescript types should parse correctly · Issue #50 - GitHub
Since eslint-plugin-jsdoc is the now-recommended way to lint jsdoc, and it relies on jsdoctypeparser, jsdoctypeparser should parse Typescript types.
Read more >
Type-safely parsing JSON to a TypeScript Interface
In the box on the right, select TypeScript as the Language and make sure Verify JSON.parse results at runtime is turned-on. Quicktype will ......
Read more >
@types/accept-language-parser - npm
Details. Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/accept-language-parser.
Read more >
Typescript csv-parse - Stack Overflow
d.ts in @types/csv-parse from: export = parse;. to: export default ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found