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 #13

Open
js3692 opened this issue Apr 22, 2019 · 3 comments
Open

Allow comments in tsconfig.json #13

js3692 opened this issue Apr 22, 2019 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@js3692
Copy link

js3692 commented Apr 22, 2019

It seems like comments cannot be used currently (i.e. input is expected to be a "valid" JSON), looking at (in this file):

function convertCompilerOptionsOrThrow(options) {
  if (!options) return null;

  var result = ts.convertCompilerOptionsFromJson(options, '');

  if (result.errors && result.errors.length) {
    throw new Error(result.errors[0].messageText);
  }

  return result.options;
}

Looking at this example, I think the parseConfigFileTextToJson function might be useful here to allow comments inside tsconfig.json.

Do you have any advice on how to enable comments in the config file? Happy to open a PR in the compiler repo.

@yorrd
Copy link
Member

yorrd commented Apr 23, 2019

you could just regex the comments out before handing it over to the typescript API. Feel free to open a PR, will gladly accept

@yorrd yorrd added the help wanted Extra attention is needed label Apr 23, 2019
@nicu-chiciuc
Copy link

I don't think allowing comments inside JSON files is a good idea, even though it might be helpful. Ditching the official standard just so that we have some local improvements is usually a bad idea.

@colelawrence
Copy link

colelawrence commented Jul 4, 2019

@nicu-chiciuc the official tsc is tolerant of comments.
So, jsonc support is the standard for tsconfig.json files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants