Repository navigation
fix(ts): preserve literal __proto__ fields and strip nulls in nested arrays - #542
Draft
Tejas Lamba (TejasLamba2006) wants to merge 1 commit into
Draft
Tejas Lamba (TejasLamba2006) wants to merge 1 commit into
Tejas Lamba (TejasLamba2006) wants to merge 1 commit into
Conversation
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consolidates the two TypeScript fixes discussed in #497 against current
main.Changes
typescript/src/ts/program.ts: Emit a computed property name (["__proto__"]) increateModuleTextFromProgramso literal__proto__fields remain own data properties instead of invoking the prototype setter.typescript/src/typechat.ts: Updatevaluealongsideobj[k]when filteringnullentries instripNullsso recursion cleans nested arrays as well.typescript/test/program.test.ts: Execute the generated module (stripTypeScriptTypes+node:vm) for string, object, andnullvalues, verifying computed key emission, own__proto__preservation, JSON serialization, and parity withevaluateJsonProgram.typescript/test/failure.test.ts: ExercisestripNullsthroughcreateTypeScriptJsonValidator(attemptRepair = false, closed infinally) for[null, [null, 1]],[[null, 1], null, [null, null]], and flat arrays.References, Credit, and CLA Notes
createTypeScriptJsonValidatorcoverage in fix: normalize nested arrays after filtering null values #496 and executing the generated module in fix(program): preserve literal __proto__ fields in generated modules #497); Tejas Lamba (@TejasLamba2006) independently submitted Fix nested array null filtering with stripNulls #525 and Emit computed property name for __proto__ in generated object literals #526 and put together this consolidated branch.cbf79d6on this branch was written cleanly on top ofmainby Tejas Lamba (@TejasLamba2006) (no commits cherry-picked or copied from fix: normalize nested arrays after filtering null values #496/fix(program): preserve literal __proto__ fields in generated modules #497), re-implementing the test scenarios requested during review while crediting JOJO (@moneymaker26754-crypto) for the original test ideas and fixes.Verification
npm run build-allintypescript/passes.npm testintypescript/passes (428/428 tests across 70 suites).