microsoft / microsoft/TypeScript
Support `proposal-json-parse-with-source` (`JSON.rawJSON()`, `JSON.isRawJSON()`, `context` parameter of `reviver` function, etc...)
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
⚙ 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.
Sample Code
// 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 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.
Additionally, it appears to have been implemented in V8 and in webkit.
Testing experimentally, it is available in node 22+ and in the latest Chromium as well:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the ESNext library definitions and comparing their JSON APIs with the proposal-json-parse-with-source specification. Use the TypeScript sample in the issue to check the missing declarations, including JSON.rawJSON(), JSON.isRawJSON(), and the reviver context parameter, then verify the ESNext target accepts them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100