lezer-parser / lezer

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

Generated `specialized` field is not compatible with typescript strict mode #41

Closed berekuk closed 4 months ago

berekuk commented 1 year ago

From https://github.com/lezer-parser/lezer/issues/11#issuecomment-907630556:

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.

This seems to have changed at some point.

My generated parser includes this code:

  specialized: [{term: 102, get: value => spec_identifier[value] || -1}],

Which is not compatible with Typescript strict mode or "noImplicitAny": true:

Captura de pantalla 2023-08-17 a la(s) 12 43 12
marijnh commented 1 year ago

Does attached patch look like it would work for you?

berekuk commented 1 year ago

I think in my case the code was generated by a different branch that you need to update too, line 493 after your patch. (I see || -1 on the screenshot, not << 1).

marijnh commented 1 year ago

Oh, good point. Added another patch that makes the change there as well.

berekuk commented 1 year ago

Looks good now!