microsoft / microsoft/TypeScript

Support `proposal-json-parse-with-source` (`JSON.rawJSON()`, `JSON.isRawJSON()`, `context` parameter of `reviver` function, etc...)

Offen
#61,330 3 Kommentare 12 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bug Domain: lib.d.ts Help Wanted
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

### ⚙ Compilation target

ESNext

### ⚙ Library

ESNext

### Missing / Incorrect Definition

`JSON.rawJSON()` appears to be missing. Apologies if I've missed something or if this is the wrong place to raise an issue. I searched through both PRs and issues in both this repo and https://github.com/microsoft/TypeScript-DOM-lib-generator but couldn't find any references for it.

![Image](https://github.com/user-attachments/assets/004929f6-4833-4818-8541-edb6f94571c5)

### Sample Code

```TypeScript
// https://www.typescriptlang.org/play/?target=99#code/MYewdgzgLgBAHjAvDAUgZQPIDkB0AnAQwHd1sAKAcgAYKBKIA
const x = JSON.rawJSON('0')
```

### Documentation Link

Per https://github.com/microsoft/TypeScript/issues/19044 it seems like TypeScript's policy is to support Stage 3+ features and [proposal-json-parse-with-source](https://github.com/tc39/proposal-json-parse-with-source) is stage 3. (If I misunderstood the typescript teams policy on experimental features it would be awesome to have this documented in https://github.com/Microsoft/TypeScript/wiki/FAQ)

MDN also documents this feature [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/rawJSON).

Additionally, it appears to have been implemented [in V8](https://github.com/v8/v8/commit/e2f909764780a62017788e69f85c89d915185f40) and [in webkit](https://github.com/WebKit/WebKit/pull/7057).

Testing experimentally, it is available in node 22+ and in the latest Chromium as well:

![Image](https://github.com/user-attachments/assets/25f556f0-9741-40e0-912b-854ac067fd8a)

![Image](https://github.com/user-attachments/assets/be88c1f7-3967-4913-af08-06d751c4f8bc)

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 damit, die ESNext-Bibliotheksdefinitionen zu überprüfen und ihre JSON-APIs mit der Spezifikation proposal-json-parse-with-source zu vergleichen. Verwende das TypeScript-Beispiel im Issue, um die fehlenden Deklarationen zu überprüfen, einschließlich JSON.rawJSON(), JSON.isRawJSON() und des Reviver-Kontextparameters, und verifiziere anschließend, dass das ESNext-Ziel diese akzeptiert.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, typescript
Bereich
compilers
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

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