Merge pull request #5840 from Microsoft/fixExtraAwaiter

Fixes #5564.
This commit is contained in:
Ron Buckton 2015-11-30 15:45:13 -08:00
commit aae67497b9
5 changed files with 50 additions and 2 deletions

View file

@ -12119,8 +12119,8 @@ namespace ts {
const symbol = getSymbolOfNode(node);
const localSymbol = node.localSymbol || symbol;
// Since the javascript won't do semantic analysis like typescript,
// if the javascript file comes before the typescript file and both contain same name functions,
// Since the javascript won't do semantic analysis like typescript,
// if the javascript file comes before the typescript file and both contain same name functions,
// checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function.
const firstDeclaration = forEach(localSymbol.declarations,
// Get first non javascript function declaration
@ -14370,6 +14370,7 @@ namespace ts {
emitExtends = false;
emitDecorate = false;
emitParam = false;
emitAwaiter = false;
potentialThisCollisions.length = 0;
forEach(node.statements, checkSourceElement);

View file

@ -0,0 +1,26 @@
//// [tests/cases/conformance/async/es6/asyncMultiFile.ts] ////
//// [a.ts]
async function f() {}
//// [b.ts]
function g() { }
//// [a.js]
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);
});
};
function f() {
return __awaiter(this, void 0, Promise, function* () { });
}
//// [b.js]
function g() { }

View file

@ -0,0 +1,8 @@
=== tests/cases/conformance/async/es6/a.ts ===
async function f() {}
>f : Symbol(f, Decl(a.ts, 0, 0))
=== tests/cases/conformance/async/es6/b.ts ===
function g() { }
>g : Symbol(g, Decl(b.ts, 0, 0))

View file

@ -0,0 +1,8 @@
=== tests/cases/conformance/async/es6/a.ts ===
async function f() {}
>f : () => Promise<void>
=== tests/cases/conformance/async/es6/b.ts ===
function g() { }
>g : () => void

View file

@ -0,0 +1,5 @@
// @target: es6
// @filename: a.ts
async function f() {}
// @filename: b.ts
function g() { }