microsoft / microsoft/TypeScript

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

Abierto
#61,330 3 comentarios 12 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Bug Domain: lib.d.ts Help Wanted
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
2 d 4 h
PR fusionados (30 d)
132

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza revisando las definiciones de la biblioteca ESNext y comparando sus API JSON con la especificación proposal-json-parse-with-source. Usa el ejemplo de TypeScript del issue para comprobar las declaraciones que faltan, incluidas JSON.rawJSON(), JSON.isRawJSON() y el parámetro de contexto del reviver, y verifica después que el destino ESNext las acepte.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, typescript
Área
compilers
Tipo de issue
Nueva funcionalidad
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.