kach / nearley

📜🔜🌲 Simple, fast, powerful parser toolkit for JavaScript.
https://nearley.js.org
MIT License
3.57k stars 231 forks source link

Fix for TypeScript preprocessor token type incompatibility #560

Closed bandaloo closed 3 years ago

bandaloo commented 3 years ago

This is a much less invasive fix that resolves #527

kach commented 3 years ago

Thanks for proactively submitting this PR! See my comments.

kach commented 3 years ago

Looks good! Last request: Is there a test you can add that passes after this change but fails before this change?

bandaloo commented 3 years ago

I added a test that only passes with the never change to the generator, which I learned is only needed with the --strict compilation mode (but I think that's how most people use TypeScript anyways). In doing so, I also realized that the original typescript test does not fail if there are type errors! That's because tsc has no problem handing you a js file even if there were type errors, and the type errors get logged to stdout. I fixed this too. (That's how I made the mistake of lopping off the NearleyToken interface and felt confident because the tests still passed, because type errors weren't caught in the tests.)

kach commented 3 years ago

Merged! Thanks so much!

Let's watch out for any TS-related issues reported in the next few days… I'm always super paranoid about changes like this. But I think we - really, you - did a great job here. :)