GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Add lib types for JSON.rawJSON, JSON.isRawJSON, and reviver context by VedantMadane · Pull Request #63248 · microsoft/TypeScript Conversation
|
It isn't, MDN is wrong on this one. It has stage 4 approval, but is not yet in the latest draft: tc39/ecma262#3714 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies). Next steps for PRs:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Reopening as this is still valid (minus commandlineParser.ts) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Adds an ES2025-by-feature lib file to type the now-standard JSON.rawJSON, JSON.isRawJSON, and the JSON.parse reviver “source context” capability, and wires it into the es2025 lib plus compiler test coverage.
Changes:
src/lib/es2025.json.d.ts defining RawJSON and augmenting JSON with rawJSON, isRawJSON, and a JSON.parse overload with a context parameter.src/lib/es2025.d.ts and registers es2025.json in src/lib/libs.json.jsonParseWithSource.ts) and accepted baselines covering all three APIs.Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/lib/es2025.json.d.ts |
Adds RawJSON and JSON API typings for the ES2025 JSON additions. |
src/lib/es2025.d.ts |
Includes the new es2025.json lib in the es2025 umbrella lib. |
src/lib/libs.json |
Registers es2025.json as an available by-feature lib. |
tests/cases/compiler/jsonParseWithSource.ts |
Compiler test exercising rawJSON, isRawJSON, and reviver context. |
tests/baselines/reference/jsonParseWithSource.types |
Baseline for type printing of the new APIs. |
tests/baselines/reference/jsonParseWithSource.symbols |
Baseline for symbol resolution including the new lib. |
tests/baselines/reference/jsonParseWithSource.js |
Baseline for JS emit. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Approach / Design (nits):
JSON.rawJSON(text: string): RawJSON — The JSDoc documents the happy path but doesn't mention @throws for invalid input. Per the spec, JSON.rawJSON throws a SyntaxError when text is not a valid JSON primitive (not a string, number, boolean, or null) or is an object/array. Adding @throws {SyntaxError} would align with the existing JSON.parse JSDoc and help consumers handle error cases.
Test coverage for reviver context — The test file has one reviver test using a plain object. It might be worth adding cases for:
"arr": [1, 2, 3]) — the context source for each elementThese are minor suggestions; the type definitions themselves look correct and match the Stage 4 proposal. The infrastructure changes (libs.json, commandLineParser.ts, es2025.d.ts) all look routine and correct.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Andrii Furmanets (@afurm) future automated comments will result in a block; any automated activity we want to occur in this repo we will set up ourselves or already have |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ryan Cavanaugh (@RyanCavanaugh) the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Per the ECMAScript spec, context.source is only present when the property is unmodified and its value is primitive. Update the es2025.json typings and compiler tests/baselines accordingly. Also re-add es2025.json to libMap so /// <reference lib="es2025.json" /> resolves (required for the es2025 umbrella lib to include the definitions). Addresses review feedback on microsoft#63248.
34237c8 to
38e8ed5
Compare
|
Even if this is a bot this is still something that needs to get implemented, its pretty annoying to have to vendor these types in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
38e8ed5 to
54dd28d
Compare
54dd28d to
c842877
Compare
c842877 to
edf7da4
Compare
Port proposal-json-parse-with-source (ES2025) lib typings onto the Go tree layout: - tsc/internal/bundled/source/es2025.json.d.ts (+ generated lib/embed) - reference from es2025 umbrella + libs.json + LibMap (enummaps.go) - compiler test and baselines Preserves RawJSON, JSON.rawJSON, JSON.isRawJSON, and optional context.source on JSON.parse reviver. Fixes microsoft#61330 Signed-off-by: Vedant Madane <[email protected]>
|
Rebased onto current New head: Conflict resolution
Regenerated
Feature kept
Note / remaining risk
Baselines for the new compiler test were carried from the prior PR tip (not re-run locally on Windows). CI should confirm. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Closing this PR as the feature has already landed upstream under lib.es2026.json.d.ts via #64096. Thank you! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Supportproposal-json-parse-with-source (JSON.rawJSON(), JSON.isRawJSON(), context parameter of reviver function, etc...)
There was an error while loading. Please reload this page.