Skip to content

Allow comments in tsconfig.json files#3

Open
joshuacc wants to merge 1 commit intoJamieMason:mainfrom
joshuacc:allow-comments-in-tsconfig
Open

Allow comments in tsconfig.json files#3
joshuacc wants to merge 1 commit intoJamieMason:mainfrom
joshuacc:allow-comments-in-tsconfig

Conversation

@joshuacc
Copy link
Copy Markdown

@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
Copy Markdown
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!
@joshuacc joshuacc force-pushed the allow-comments-in-tsconfig branch from 05436eb to 2e4dabb Compare March 18, 2021 13:32
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.

2 participants