New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(tsconfig): support tsconfig.json files with comments #826
Conversation
It would probably be a good idea to add a test for this as well. |
What does tsc use to parse its tsconfig.json file? It might be a good idea to use the same thing if possible |
tsc uses |
Fair enough, could you just add a comment in this file saying what you just said, kinda explaining why we are using a different lib than TS. For our future selves and people coming here are reading the code :) |
Sure, good idea :) I'll do it |
Built-in JSON.parse() doesn't allow json with comments, but `tsconfig.json` files support comments. By using `json5` instead of native JSON we prevent errors when trying to parse such json files with comments Even though Typescript uses 'jsonc-parser' [here](https://github.com/microsoft/TypeScript/blob/5439c8111de50fa6ea239f95fc23c76dc868fc07/scripts/build/utils.mjs#L78-L81), we can use json5, because it is a superset of jsonc syntax.
b79b2d6
to
7fa650a
Compare
@rumpl updated both the code and commit body with a comment about jsonc-parser |
Duplicate with #806 |
I'll merge this one @znarf, I like the comment explaining what's going on :) |
Built-in JSON.parse() doesn't allow json with comments, but
tsconfig.json
files support comments. By usingjson5
instead of native JSON we prevent errors when trying to parse such json files with comments