Skip to content

tsconfig.json can't be parsed if it contains comments #13455

@CSchulz

Description

@CSchulz

Bug Report or Feature Request (mark with an x)

- [X] bug report
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [x] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Will also effect other commands.

Versions

Angular CLI: 7.2.2
Node: 10.12.0
OS: darwin x64
Angular: 7.1.4
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.11.4
@angular-devkit/build-angular      0.11.4
@angular-devkit/build-ng-packagr   0.11.4
@angular-devkit/build-optimizer    0.11.4
@angular-devkit/build-webpack      0.11.4
@angular-devkit/core               7.1.4
@angular-devkit/schematics         7.2.2
@angular/cli                       7.2.2
@ngtools/json-schema               1.1.0
@ngtools/webpack                   7.1.4
@schematics/angular                7.2.2
@schematics/update                 0.12.2
ng-packagr                         4.4.5
rxjs                               6.3.3
typescript                         3.1.6
webpack                            4.23.1

Repro steps

Add some comments to the tsconfig.json file:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "importHelpers": true,
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noUnusedParameters": true,
    "noUnusedLocals": true,
    "strict": true,
    "strictPropertyInitialization": false,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "target": "es5",
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2017", "dom"],
    "paths": {
      // use public_api instead of dist folder for recompile on library changes
      "commons": ["projects/commons/src/public_api-dev.ts"]
    }
  }
}

The log given by the failure

$ npx ng generate library
? What name would you like to use for the library? test
Invalid JSON character: "u" at 21:8.

Desired functionality

Should allow comments in tsconfig.json.

Mention any other details that might be useful

Could be related to #5216

/cc @ajafff

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions