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

tsconfig.json and jsconfig.json not allowing comments (parsed as pure JSON) #7195

Closed
kdmadej opened this issue Jun 10, 2019 · 1 comment
Closed

Comments

@kdmadej
Copy link

kdmadej commented Jun 10, 2019

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

JSON, parse, jsconfig

Environment

Environment Info:

  System:
    OS: macOS 10.14.5
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  Binaries:
    Node: 10.11.0 - ~/.nvm/versions/node/v10.11.0/bin/node
    Yarn: 1.16.0 - /usr/local/Cellar/yvm/3.3.0/shim/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.11.0/bin/npm
  Browsers:
    Chrome: 74.0.3729.169
    Firefox: Not Found
    Safari: 12.1.1
  npmPackages:
    react: ^16.8.0 => 16.8.6 
    react-dom: ^16.8.0 => 16.8.6 
    react-scripts: ^3.0.1 => 3.0.1 
  npmGlobalPackages:
    create-react-app: Not Found

Steps to Reproduce

  1. create an initial app
  2. add jsconfig.json or tsconfig.json
  3. use a comment or leave a trailing comma in an array or an object

Expected Behavior

Since VSCode treats both tsconfig.json and jsconfig.json as JSON with Comments by default, it does not report any issues when adding comments or leaving trailing commas inside those files. As such I would expect the files to be parsed correctly and comments to be allowed.

Actual Behavior

The build fails as the aforementioned additions, which is to be expected if the files are treaded as pure JSON. The following output is produced when comments are present in the config:

yarn run v1.16.0
$ react-scripts build
internal/modules/cjs/loader.js:711
    throw err;
    ^

SyntaxError: /.../app/jsconfig.json: Unexpected token / in JSON at position 3
    at JSON.parse (<anonymous>)

Reproducible Demo

It should be fairly easy to quickly reproduce this issue in an empty create-react-app project.

Additional info

This issue is connected to #4763 although I believe this to be a bug. If this is indeed intended (I understand this is an issue with how cjs parses the files) I'd ask to at least have this behaviour mentioned in the documentation as it seems to diverge from the way that {ts,js}config.json files are treated by default.

@heyimalex
Copy link
Contributor

heyimalex commented Jun 11, 2019

Duplicate of #6865.

EDIT: Or err... close enough to be a duplicate. I realize now this also applies to jsconfig.json.

@heyimalex heyimalex marked this as a duplicate of #6865 Jun 11, 2019
@lock lock bot locked and limited conversation to collaborators Jun 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants