-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tsconfig should support suffix .jsonc
#43121
Comments
You're already free to name this file whatever you like; |
No, I know that |
Thanks for clarifying, you're right |
@RyanCavanaugh this issue seems to be fixed because I just tested it with TypeScript 4.6.4 and it worked as expected π: base.jsonc {
// A config file with a comment
"compilerOptions": {
"outDir": "myOutput",
}
} tsconfig.json {
"extends": "./base.jsonc",
"compilerOptions": {
"lib": ["es2017"],
"module": "commonjs",
"moduleResolution": "node",
"rootDir": "src",
"strict": true,
"target": "es6"
}
} When running Further DX ImprovementsIt's great to see that you can feed the TypeScript compiler with JSON5 or JSONC files. I wish that WebStorm 2022.1.4 GitHub is also not a big fan of comments in JSON files and signals that in red: GitHub File View |
TSC allows comments in `tsconfig.json` files. Ideally the file should use the `jsonc` extension. TypeScript team seems rejecting the idea of this support. See [this issue](microsoft/TypeScript#43121). By the way, `jsonc` extension can be used for tsconfig that are used in `extends` of another _tsconfig_. This fact was observed in this following thread: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
TSC allows comments in `tsconfig.json` files. Ideally the file should use the `jsonc` extension. TypeScript team seems rejecting the idea of this support. See [this issue](microsoft/TypeScript#43121). By the way, `jsonc` extension can be used for tsconfig that are used in `extends` of another _tsconfig_. This fact was observed in this following thread: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
TSC allows comments in `tsconfig.json` files. Ideally the file should use the `jsonc` extension. TypeScript team seems rejecting the idea of this support. See [this issue](microsoft/TypeScript#43121). By the way, `jsonc` extension can be used for tsconfig that are used in `extends` of another _tsconfig_. This fact was observed in this following thread: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
@bennycode Unfortunately this issue is not fixed. This issue is about the problem that you cannot import a jsonc file from another package:
|
My 2c: Not normalizing the use of the filename Are we at risk of eroding the simplicity of 'JSON' here, in the entire ecosystem, because of things like this? Maybe an overblown statement, but still... the answer is yes IMO :) |
Suggestion
π Search Terms
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
tsconfig should support
"extends": "pkg/foo.jsonc"
Currently that will try to read
node_modules/pkg/foo.jsonc.json
and fail"extends": "./foo.jsonc"
works. It only fails when trying to load a config using the node-resolution codepath.π Motivating Example
Various dev tools complain about comments in
.json
files.Many json config files allow comments, so most dev tools also understand a "json-with-comments" format, and the conventional file suffix for that is
.jsonc
.Some dev tools special-case
tsconfig.json
asjsonc
, and some tools also special-case variants liketsconfig*.json
, but this is awkwardly inconsistent.Supporting the suffix
.jsonc
will let people ignore the special-case irregularities and gravitate toward the generic file suffix.Q: Why not some other json variant like
.json5
?A: Other json variants try to fix other "json as configuration" problems in different ways, and none of them seem particularly dominant yet. jsonc is a conservative extension to json that has a lot of support, and it's also a subset of most of the other json variants.
And the tsconfig parser is already a jsonc parser, it doesn't need to change. It just needs support for the
.jsonc
suffix.π» Use Cases
The text was updated successfully, but these errors were encountered: