mapbox / mapbox/mapbox-gl-js

Adopt object spread and polyfill Object.assign

Open
#8,283 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

refactoring :building_construction:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Currently we use a custom extend utility function because Object.assign isn't supported in IE11.

However, if we polyfilled Object.assign in IE, we could switch to object spread ({...obj}) syntax across the code base, which provides many benefits:

  • An easier to read, more concise syntax.
  • When we ditch IE11 support in future and start providing an untranspiled build, we'll get better performance for free because native spreads are faster than Object.assign.
  • Strictly typing extend and all code that uses it in Flow is really hard, which I discovered while working on #8281. It's much easier with spreads because it syntactically indicates the full shape of an object from the start — no type conversions/refinements need to happen to transform an object through multiple extensions.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the custom extend utility in src/util/util.js and review how it is used across the code base. Determine where Object.assign must be polyfilled for IE11, then migrate the relevant extensions to object spread. Done means the code no longer depends on extend for these cases and IE11 remains supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend, web-dev
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.