Chevrotain / chevrotain

Parser Building Toolkit for JavaScript
https://chevrotain.io
Apache License 2.0
2.44k stars 199 forks source link

Update api.d.ts to properly define `input` #1978

Closed matthew-dean closed 10 months ago

matthew-dean commented 10 months ago

Explanation

Because api.d.ts incorrectly defines input as a data property instead of an accessor property (as it's defined in code), then TypeScript will throw compilation errors if you try to override the parser's input accessor.

If you attempt to augment the Chevrotain types (with declare module 'chevrotain' and altering the interface), TypeScript will still fail, because the name exists, it's just incorrectly defined. The only workaround is to add a @ts-ignore. (Even @ts-expect-error will cause problems, because extensions like Volar cannot correctly determine that tsc will error in this case.)

bd82 commented 10 months ago

Thanks @matthew-dean 👍