microsoft / microsoft/TypeScript

Support import of jsonc file to infer type

Aperta
#54,137 5 commenti 23 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

In Discussion Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

Suggestion

🔍 Search Terms

typescript
jsonc

json jsonc

✅ 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

Enable supporting import of jsonc file to provide typing information.

import * as data from './test.jsonc';

type myType = typeof data;

The import statement for jsonc is not supported today.

📃 Motivating Example

import * as data from './test.jsonc';

type myType = typeof data;

💻 Use Cases

Our scenario auto generates UX based on declarative jsonc file.
We have a requirement to load and infer the type specified in the jsonc file to invoke some component in the UX.
There is no typing support currently and workaround is to manually construct the data.

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 esaminando il supporto esistente di TypeScript per l'importazione di JSON e confrontalo con lo scenario richiesto di importazione JSONC. Definisci il comportamento previsto del tipaggio e dell'inferenza dei tipi per l'esempio, quindi identifica i test necessari per dimostrare il supporto per le importazioni JSONC; l'issue non indica alcun file o test esistente.

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

Valutazione

Stack tecnologico
javascript, typescript
Ambito
compilers
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.