mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 04:09:28 +00:00
Use jsonc parser to parse a config file
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.
This commit is contained in:
committed by
GitHub
parent
4aa8c83b54
commit
84424c84fd
@@ -7,6 +7,7 @@ import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import * as jsonc from 'jsonc-parser';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
import { Lazy } from '../utils/lazy';
|
||||
import { isImplicitProjectConfigFile } from '../utils/tsconfig';
|
||||
@@ -217,7 +218,7 @@ class TscTaskProvider implements vscode.TaskProvider {
|
||||
}
|
||||
|
||||
try {
|
||||
const tsconfig = JSON.parse(result.toString());
|
||||
const tsconfig = jsonc.parse(result.toString());
|
||||
if (tsconfig.references) {
|
||||
return resolve(['-b', project.path]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user