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
Matt Bierner (mjbvz) merged 1 commit into
microsoft:masterfrom
dtinth:patch-1
Jan 30, 2019

Conversation

@dtinth

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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

@mjbvz

Copy link
Copy Markdown
Contributor

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