Skip to content

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

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

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__"] in createModuleTextFromProgram so own __proto__ data properties are preserved instead of acting as prototype setters, with behavioral tests executing generated modules for string, object, and null values alongside interpreter parity checks.

Keep value synchronized with the filtered array in stripNulls before recursing so nulls inside nested arrays are removed in the returned structure, with regression tests using createTypeScriptJsonValidator (attemptRepair = false, closed in finally).
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.

1 participant