-
Notifications
You must be signed in to change notification settings - Fork 13.3k
tsconfig should support suffix .jsoncΒ #43121
Copy link
Copy link
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Module ResolutionHow to turn an import specifier into a .d.ts, .ts, or .js file on diskHow to turn an import specifier into a .d.ts, .ts, or .js file on diskEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do this
Milestone
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Module ResolutionHow to turn an import specifier into a .d.ts, .ts, or .js file on diskHow to turn an import specifier into a .d.ts, .ts, or .js file on diskEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do this
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.jsonand 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
.jsonfiles.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.jsonasjsonc, and some tools also special-case variants liketsconfig*.json, but this is awkwardly inconsistent.Supporting the suffix
.jsoncwill 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
.jsoncsuffix.π» Use Cases