Skip to content
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

Allow comments in tsconfig.json files #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joshuacc
Copy link

@joshuacc joshuacc commented Mar 18, 2021

Previously, if your tsconfig.json file contained a comment (allowed by the
TS compiler) the ts-import-types-cli would throw the following error:

ts-import-types-cli --project /myproject/tsconfig.json is not a tsconfig.json file

This is because the node require function can only parse valid
(commentless) JSON.

This PR swaps out the use of require in favor of directly reading
the file contents, stripping all comments, and only then parsing it
to confirm that it is valid JSON.

Hopefully this will save other users some confusion!

@JamieMason
Copy link
Owner

Thanks a lot @joshuacc I'll get this merged and released as soon as I get some time

Previously, if your tsconfig.json file contained a comment (allowed by the
TS compiler) the ts-import-types-cli would throw the following error:

`ts-import-types-cli --project /myproject/tsconfig.json is not a tsconfig.json file`

This is because the node `require` function can only parse valid
(commentless) JSON.

This PR swaps out the use of `require` in favor of directly reading
the file contents, stripping all comments, and only then parsing it
to confirm that it is valid JSON.

Hopefully this will save other users some confusion!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants