Skip to content

refactor: migrate polyfill module to TS - #1335

Merged
jaissica12 merged 2 commits into
developmentfrom
refactor/SDKE-1195-migrate-polyfill-to-TS
Aug 19, 2026
Merged

refactor: migrate polyfill module to TS#1335
jaissica12 merged 2 commits into
developmentfrom
refactor/SDKE-1195-migrate-polyfill-to-TS

Conversation

@jaissica12

Copy link
Copy Markdown
Contributor

Background

  • Continuing the effort to migrate remaining JavaScript modules in the mParticle Web SDK to TypeScript for improved type safety and developer experience. polyfill.js (Base64/UTF8 helpers and Array polyfills) was one of the remaining JS modules.

What Has Changed

  • Converted src/polyfill.js to src/polyfill.ts with type annotations
  • Consumers (mparticle-instance-manager.ts, persistence.js) continue to import ./polyfill unchanged
  • No intentional runtime behavior, public API, or functional changes

Screenshots/Video

  • N/A

Checklist

  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have tested this locally.

Additional Notes

  • No dedicated unit/integration tests exist specifically for this module
  • Mechanical JS → TS migration only

Reference Issue (For employees only. Ignore if you are an outside contributor)

@jaissica12
jaissica12 requested a review from a team as a code owner August 19, 2026 00:44
@cursor

cursor Bot commented Aug 19, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Type-only and style changes in a legacy polyfill module; consumers and public API are unchanged.

Overview
Renames polyfill.js to polyfill.ts and adds TypeScript types without changing runtime behavior or the default export shape.

Base64 and UTF8 helpers get explicit string parameters and return types; isArray is typed as (arg: unknown) => boolean. Internal var declarations become const / let where appropriate. Array polyfill methods (forEach, map, filter) keep the same signatures and logic—only typing and declaration style change.

Imports from ./polyfill in mparticle-instance-manager.ts and persistence.js stay the same.

Reviewed by Cursor Bugbot for commit 02a8a14. Bugbot is set up for automated code reviews on this repo. Configure here.

@jaissica12
jaissica12 force-pushed the refactor/SDKE-1195-migrate-polyfill-to-TS branch from c49f9e3 to 1f44de1 Compare August 19, 2026 01:29

@rmi22186 rmi22186 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The amount of changes to forEach, map, and filter is a little scary since there aren't unit tests for them. These were all originally copied and pasted from the links provided. Can you edit them to just make them do let/const, etc instead of doing a larger refactor?

Per review, the array polyfills are verbatim copies from the es5.github.io
references and have no unit test coverage, so revert them to their original
object-literal form and limit the change to let/const. The extracted
functions and Array.prototype casts were not needed: noImplicitAny is off,
so the original signatures compile and assign unchanged.
@sonarqubecloud

Copy link
Copy Markdown

@jaissica12
jaissica12 requested a review from rmi22186 August 19, 2026 01:45
@jaissica12 jaissica12 self-assigned this Aug 19, 2026
@jaissica12
jaissica12 merged commit ace86ff into development Aug 19, 2026
29 of 33 checks passed
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.

4 participants