microsoft / microsoft/TypeScript

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

未关闭
#61,330 3 条评论 12 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Domain: lib.d.ts Help Wanted
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
132

描述

### ⚙ 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)

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先检查 ESNext 库定义,并将其 JSON API 与 proposal-json-parse-with-source 规范进行比较。使用 issue 中的 TypeScript 示例检查缺失的声明,包括 JSON.rawJSON()、JSON.isRawJSON() 和 reviver 上下文参数,然后验证 ESNext 目标接受这些声明。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, typescript
领域
compilers
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。