microsoft / microsoft/TypeScript

tsconfig should support suffix `.jsonc`

Aperta
#43,121 9 commenti 48 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug Domain: Module Resolution Effort: Moderate Help Wanted
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

Suggestion

🔍 Search Terms

  • json
  • jsonc
  • tsconfig

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ 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 as jsonc, and some tools also special-case variants like tsconfig*.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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia tracciando il percorso di risoluzione dei nodi utilizzato per il valore extends, concentrandoti su come pkg/foo.jsonc viene trasformato in un percorso. Verifica che le configurazioni .jsonc basate su pacchetti vengano risolte senza aggiungere .json, mentre il comportamento esistente di ./foo.jsonc relativo rimanga invariato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
build-system, tooling
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.