lezer-parser / lezer

Dev utils and issues for the Lezer core packages
33 stars 1 forks source link

Generator could generate ts file #11

Closed Nexucis closed 2 years ago

Nexucis commented 2 years ago

Hi,

Currently lezer-generator is generating the files in Javascript. Would it be possible to generate in Typescript when using a new flag like --format=ts where the default value would be js.

Why I would like that ?

I'm currently maintaining two repositories lezer-promql and codemirror-promql and I would like to move lezer-promql in codemirror-promql.

Since I wrote codemirror-promql in typescript, if the lezer-generator was able to generate the files in typescript, I could directly use the generated file in my code and then simply rely on tsc to generate the esm and cjs file.

It could even be interested when we still want to keep the lezer grammar in a separated npm package, because we could again simply use tsc to generate the CommonJS module and the ESM module instead of using rollup. It would also generated automatically the file d.ts.

Would it be something acceptable for you ? I could make the PR if you are interested.

marijnh commented 2 years ago

I believe there is currently nothing in the generated output that would require a type declaration, so you should be able to just treat it as typescript.

Nexucis commented 2 years ago

ah yeah it works just like that :o.

Thanks ! and sorry for the noise