Skip to content

Adopt object spread and polyfill Object.assign #8283

Closed

Description

@mourner

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 Start adopting Flow strict mode #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.

Activity

  1. asheemmamoowala commented on May 28, 2019

    @asheemmamoowala
    Contributor

    Isn't this already done automatically in our rollup configuration at :

    buble({transforms: {dangerousForOf: true}, objectAssign: "Object.assign"}),

  2. mourner commented on May 29, 2019

    @mourner
    MemberAuthor

    @asheemmamoowala what this does is tell Buble to transpile object spreads to Object.assign calls. But this will break IE11 because it doesn't have Object.assign. To make this work, we need to include a polyfill in the bundle.

  3. karimnaaji commented on Dec 8, 2020

    @karimnaaji
    Contributor

    Addressed as part of the IE11 deprecation in v2.

  4. ryanhamley commented on Jan 26, 2022

    @ryanhamley
    Contributor

    The issue here is no longer IE11 since GL JS no longer supports it, but some build systems fail when encountering the Object spread notation. See #11266 for an example. We probably don't need to polyfill Object.assign either.

  5. mourner commented on Oct 15, 2026

    @mourner
    MemberAuthor

    This was already done a while ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions