refactor: convert shared/lib/object.utils to TypeScript#41329
Conversation
Agent-Logs-Url: https://github.com/MetaMask/metamask-extension/sessions/5cc5fdbd-5198-444f-ac08-e647d092b45d Co-authored-by: DDDDDanica <12678455+DDDDDanica@users.noreply.github.com>
…t-utils-to-typescript
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Builds ready [83ee7e8]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs
|
Builds ready [6ccd2da]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs
|
Builds ready [0205fa1]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs
|
Builds ready [8ee4ef6]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs
|
|
Builds ready [0ab2e99]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs
|
gauthierpetetin
left a comment
There was a problem hiding this comment.
I added non-blocking comments, but looks good to me.
| * exclude it. A sub-mask implies the property should be further masked | ||
| * according to that sub-mask. The "AllProperties" symbol is used for objects | ||
| * with dynamic keys, and applies a rule (either `true`, `false`, or a | ||
| * sub-mask`) to every property in that object. |
There was a problem hiding this comment.
Nit: extra ` to remove
| state[key] = obj[key]; | ||
| } else if (Array.isArray(maskKey)) { | ||
| // Array masks (e.g. empty `[]` in Sentry state) — surface typeof only, like `false`. | ||
| state[key] = obj[key] === null ? null : typeof obj[key]; |
There was a problem hiding this comment.
Since we've changed the behavior of maskObject function here, maybe we we can reflect it in unit tests?



[skip-e2e]
Converts
shared/lib/object.utils.jsto TypeScript as part of the ongoing TS migration effort. Removes the file fromdevelopment/ts-migration-dashboard/files-to-convert.json.Changes
shared/lib/object.utils.ts— Replaces the.jsfile with proper TypeScript types:AllPropertiesdeclared asunique symbolObjectMaskintersection type combining a string index signature with an optionalAllPropertiessymbol keymaskObjecttyped as(object: unknown, mask: ObjectMask) => Record<string, unknown> | string | null{type}annotations in favour of TypeScript-native types; fixed a pre-existing backtick inconsistency in the JSDocdevelopment/ts-migration-dashboard/files-to-convert.json— Removed"shared/lib/object.utils.js"entryThe existing
.test.tsfile required no changes; its imports resolve to the new.tsfile automatically.🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.
Note
Medium Risk
Updates
maskObjectmask semantics (treating array-valued mask entries likefalse) and refactors Sentry state mask typing, which can change what state is captured/sanitized in Sentry payloads. While mostly a TS-typing refactor, it touches error-report context generation and required snapshot updates.Overview
Converts
shared/lib/object.utilsto TypeScript by introducing a typedObjectMask(withAllPropertiesas aunique symbol) and adding explicit typings/return types formaskObject.Adjusts masking behavior so array-valued mask entries (e.g.
[]used in Sentry state masks) are treated like exclusions and replaced withtypeof/nullvalues, and improves error reporting for unsupported mask entries.Updates Sentry state mask definitions in
app/scripts/constants/sentry-state.tsto use the sharedObjectMasktypes (and clarifies intent via new docblock), removes the TS-migration dashboard entry for the old JS file, and refreshes metrics e2e snapshots/import ordering to match the new masking output.Written by Cursor Bugbot for commit 0ab2e99. This will update automatically on new commits. Configure here.