Skip to content

Use jsonc.parse instead of JSON.parse when parsing tsconfig.json, fixing bug where -b flag is not activated when tsconfig.json contains comments.#67535

Merged
mjbvz merged 1 commit intomicrosoft:masterfrom
dtinth:patch-1
Jan 30, 2019

Conversation

@dtinth
Copy link
Contributor

@dtinth dtinth commented Jan 30, 2019

This fixes a problem where the typescript VSCode task runs tsc with -p
when it should run -b when tsconfig.json has the "references" property.

{
  "extends": "./tsconfig.app.json",
  // meow
  "references": [{ "path": "./tsconfig.lib.json" }]
}

This bug happens because while tsconfig.json file allows comment, the
parsing logic here uses vanilla JSON.parse which cannot parse comments.

This commit fixes it by using jsonc.parse instead.

This fixes a problem where the `typescript` VSCode task runs `tsc` with `-p`
when it should run `-b` when `tsconfig.json` has the `"references"` property.

```js
{
  "extends": "./tsconfig.app.json",
  // meow
  "references": [{ "path": "./tsconfig.lib.json" }]
}
```

This bug happens because while `tsconfig.json` file allows comment, the
parsing logic here uses vanilla `JSON.parse` which cannot parse comments.

This commit fixes it by using `jsonc.parse` instead.
@dtinth
Copy link
Contributor Author

dtinth commented Jan 30, 2019

Edit: It still doesn’t work because tsc requires -b to be passed before --watch,

@mjbvz mjbvz added this to the December/January 2019 milestone Jan 30, 2019
@mjbvz mjbvz merged commit ed8af3b into microsoft:master Jan 30, 2019
@mjbvz
Copy link
Collaborator

mjbvz commented Jan 30, 2019

Makes sense. Thanks

I think the argument ordering was just fixed by #67148

@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants