Skip to content

tsconfig generated by create-vite includes comments #19697

@fernandoacorreia

Description

@fernandoacorreia

Describe the bug

When running npm create vite, it creates files with .json extension which are not valid JSON files. These files will be rejected by pre-commit checkers and won't work with standard JSON tools. They will be flagged as invalid JSON on GitHub: https://github.com/fernandoacorreia/vite-invalid-json-repro/blob/main/tsconfig.app.json

Suggestion: create tsconfig.app.jsonc and tsconfig.node.jsonc with a jsonc extension and include them in tsconfig.json:

{
  "files": [],
  "references": [
    { "path": "./tsconfig.app.jsonc" },
    { "path": "./tsconfig.node.jsonc" }
  ]
}

Reproduction

https://github.com/fernandoacorreia/vite-invalid-json-repro

Steps to reproduce

❯ npm create vite@latest -- -t react-swc-ts test

❯ jq < test/tsconfig.app.json
jq: parse error: Invalid numeric literal at line 10, column 7

❯ jq < test/tsconfig.node.json
jq: parse error: Invalid numeric literal at line 9, column 7

System Info

System:
    OS: macOS 15.3.2
    CPU: (8) arm64 Apple M1
    Memory: 112.89 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.10.0 - ~/.local/state/fnm_multishells/33599_1742751260877/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.9.2 - ~/.local/state/fnm_multishells/33599_1742751260877/bin/npm
  Browsers:
    Chrome: 134.0.6998.118
    Safari: 18.3.1

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions