Closed
Description
In the following example, running original.js
directly in MS Edge 25 / EdgeHTML 13 (with experimental JavaScript enabled) outputs "Get to the chopper!"
to the console.
downlevel.js
is produced by running typescript@next
(I used v1.8.0-dev.20151210) over original.js
with the --allowJs
option. Running downlevel.js
in MS Edge outputs an error SCRIPT445: Object doesn't support this action
.
// file: tsconfig.json
{
"compilerOptions": {
"target": "ES6",
"allowJs": true,
"outFile": "downlevel.js"
},
"files": ["original.js"]
}
// file: original.js
var Promise = "I promise not to kill anyone";
var foo = async () => "Get to the chopper!";
foo().then(console.log);
// file: downlevel.js (this one is output by tsc)
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {
return new Promise(function (resolve, reject) {
generator = generator.call(thisArg, _arguments);
function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }
function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } }
function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } }
function step(verb, value) {
var result = generator[verb](value);
result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);
}
step("next", void 0);
});
};
var Promise = "I promise not to kill anyone";
var foo = () => __awaiter(this, void 0, Promise, function* () { return "Get to the chopper!!"; });
foo().then(console.log);
It looks like the down-levelled code picks up the locally-scoped Promise
instead of using the native Promise
.