Typescript: EDGE problem with async/await when targeting ES6: "out of stack space"

Created on 9 Jan 2019  路  2Comments  路  Source: microsoft/TypeScript


TypeScript Version: 3.2.0


Search Terms:
EDGE out of stack space async await ES6

Code

// tsconfig.json
{
   "compilerOptions": {
    "module": "es6",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es6",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}
// main.ts
const appDiv: HTMLElement = document.getElementById('app');
appDiv.innerHTML = `<h1>TypeScript async/await transpile problem in EDGE whe targeting ES6</h1><button id="test">Open console and click me!</button>`;

abstract class TestBase {
  public async FunctionBase() {
    return true;
  }
}

class TestDerived extends TestBase {
  public async FunctionBase() {
    let result = await super.FunctionBase();
    return result || true;
  }
}

var x = new TestDerived();

appDiv.querySelector("#test").addEventListener("click", () => {
  x.FunctionBase().then(v => {
    alert("ok!");
  }).catch(err => {
    alert("error!");
  });  
});

Expected behavior:
No problem.

Actual behavior:
Compiling this code with target set to ES5 works well in all tested browsers (Chrome, Firefox, EDGE 18)
Compiling this code with target set to ES6 I have this behaviour:

  • [x] Chrome OK!
  • [x] Firefox OK!
  • [ ] EDGE error: "out of stack space"

Playground Link:

StackBlitz test

Related Issues:
not found

External

Most helpful comment

We don't own the Edge runtime

All 2 comments

It's probably an Edge bug, but very annoying. The generated code:

foobar () {
    const _super = Object.create(null, {
        foobar: { get: () => super.foobar }
    });
}

works well in Chrome and Firefox. However, in Edge 18 (latest classic Edge), _super.foobar is the same as this.foobar. This causes recursive calls and eventually Out of stack space error.

If you set a breakpoint at const _super = ... and inpsect super.foobar in console, it correctly points to the base class's foobar method.

We don't own the Edge runtime

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manekinekko picture manekinekko  路  3Comments

weswigham picture weswigham  路  3Comments

kyasbal-1994 picture kyasbal-1994  路  3Comments

Zlatkovsky picture Zlatkovsky  路  3Comments

jbondc picture jbondc  路  3Comments