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:
Playground Link:
Related Issues:
not found
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
Most helpful comment
We don't own the Edge runtime