Skip to content

fix(ts): preserve literal __proto__ fields and strip nulls in nested arrays - #542

Open
Tejas Lamba (TejasLamba2006) wants to merge 1 commit into
microsoft:mainfrom
TejasLamba2006:consolidate-proto-and-stripnulls
Open

Tejas Lamba (TejasLamba2006) wants to merge 1 commit into
microsoft:mainfrom
TejasLamba2006:consolidate-proto-and-stripnulls

Conversation

@TejasLamba2006

Copy link
Copy Markdown

Consolidates the two TypeScript fixes discussed in #497 against current main.

Changes

  • typescript/src/ts/program.ts: Emit a computed property name (["__proto__"]) in createModuleTextFromProgram so literal __proto__ fields remain own data properties instead of invoking the prototype setter.
  • typescript/src/typechat.ts: Update value alongside obj[k] when filtering null entries in stripNulls so recursion cleans nested arrays as well.
  • typescript/test/program.test.ts: Execute the generated module (stripTypeScriptTypes + node:vm) for string, object, and null values, verifying computed key emission, own __proto__ preservation, JSON serialization, and parity with evaluateJsonProgram.
  • typescript/test/failure.test.ts: Exercise stripNulls through createTypeScriptJsonValidator (attemptRepair = false, closed in finally) for [null, [null, 1]], [[null, 1], null, [null, null]], and flat arrays.

References, Credit, and CLA Notes

Verification

  • npm run build-all in typescript/ passes.
  • npm test in typescript/ passes (428/428 tests across 70 suites).

…s in stripNulls

Emit a computed property name ["__proto__"] so an own data property is preserved. Test string, object, and null values against the JSON program interpreter.

Recurse into the filtered array in stripNulls. Cover nested and flat arrays through the TypeScript JSON validator.
@TejasLamba2006
Tejas Lamba (TejasLamba2006) force-pushed the consolidate-proto-and-stripnulls branch from 03cb801 to bf1a147 Compare December 2, 2026 06:09
@TejasLamba2006
Tejas Lamba (TejasLamba2006) marked this pull request as ready for review December 2, 2026 06:09
Copilot AI balanced review requested due to automatic review settings December 2, 2026 06:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants