microsoft / microsoft/TypeScript

Support import of jsonc file to infer type

Offen
#54,137 5 Kommentare 23 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

In Discussion Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der Überprüfung der bestehenden TypeScript-Unterstützung für den Import von JSON und vergleiche sie mit dem angeforderten JSONC-Importszenario. Lege das erwartete Typing- und Typinferenzverhalten für das Beispiel fest und ermittle anschließend die erforderlichen Tests, um unterstützte JSONC-Importe zu demonstrieren; im Issue werden keine Dateien oder bestehenden Tests genannt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, typescript
Bereich
compilers
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.