question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

__spread does not work in IE11

See original GitHub issue

This TypeScript code (a Jasmine test):

describe("array spread operator", function() {
    it('should be able to spread arguments', function() {
        let argumentsArray;
        function testFunction() {
            argumentsArray = [...arguments];
        }
        (testFunction as any)(1, 2, 3);
        expect(argumentsArray).toEqual([1, 2, 3]);
    });
});

runs successfully in browsers but IE. In IE11, it fails with:

Expected $.length = 1 to equal 3.
Expected $[0] = [object Arguments] to equal 1.
Expected $[1] = undefined to equal 2.
Expected $[2] = undefined to equal 3.

I can see the ... array spread operator gets built into a call for helper __spread, thus submitting the issue here.

Browsers I tried:

  • Chrome 76.0.3809.100 64bit
  • Opera 62.0.3331.116
  • Firefox Quantum 68.0.1 64-bit
  • Internet Explorer 11.309.16299.0
  • Microsoft Edge 41.16299.248.0

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
anton-botcommented, Jun 22, 2020

The solution is to polyfill the Symbol.

import 'core-js/features/symbol';

Source: https://www.leereamsnyder.com/blog/new-skool-uniq-in-internet-explorer

0reactions
nvirthcommented, Nov 9, 2021

We recently updated TSC from 4.1.2 to 4.4.4, where we could see diffing the built JS before and after the TSC upgrade, that lot of __spread usages have been replaced with __spreadArray. After the upgrade, the above initial test case successfully runs in IE11.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to achieve the spread operator in IE 11? - Stack Overflow
Spread properties is a part of ECMAScript 2018 which is not supported by IE. You can use Babel to transpile it ...
Read more >
How can replace the spread expression in IE11 - Reddit
I have something like this in my code : const classesList = myElement.classList;. const arr = [...classesList ].filter(item => item.
Read more >
Fix web compatibility issues using document modes and the ...
Go to a site having compatibility problems, press F12 to open the F12 Developer Tools, and go to the Emulation tool. Emulation tool...
Read more >
IE 11 Select Change Not Supported
I get an error when I try to subscribe to the onchange function of the select. The error I get is SCRIPT445: Object...
Read more >
"spread" | Can I use... Support tables for HTML5, CSS3, etc
JavaScript operator: Spread syntax (...) ... Known issues (0) ... 1 Notable partial support in IE11 includes (at least some) support for const ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found