Skip to content

Commit aae6749

Browse files
committed
Merge pull request #5840 from Microsoft/fixExtraAwaiter
Fixes #5564.
2 parents 266600d + 6d15954 commit aae6749

File tree

5 files changed

+50
-2
lines changed

5 files changed

+50
-2
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12119,8 +12119,8 @@ namespace ts {
1211912119
const symbol = getSymbolOfNode(node);
1212012120
const localSymbol = node.localSymbol || symbol;
1212112121

12122-
// Since the javascript won't do semantic analysis like typescript,
12123-
// if the javascript file comes before the typescript file and both contain same name functions,
12122+
// Since the javascript won't do semantic analysis like typescript,
12123+
// if the javascript file comes before the typescript file and both contain same name functions,
1212412124
// checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function.
1212512125
const firstDeclaration = forEach(localSymbol.declarations,
1212612126
// Get first non javascript function declaration
@@ -14370,6 +14370,7 @@ namespace ts {
1437014370
emitExtends = false;
1437114371
emitDecorate = false;
1437214372
emitParam = false;
14373+
emitAwaiter = false;
1437314374
potentialThisCollisions.length = 0;
1437414375

1437514376
forEach(node.statements, checkSourceElement);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//// [tests/cases/conformance/async/es6/asyncMultiFile.ts] ////
2+
3+
//// [a.ts]
4+
async function f() {}
5+
//// [b.ts]
6+
function g() { }
7+
8+
//// [a.js]
9+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {
10+
return new Promise(function (resolve, reject) {
11+
generator = generator.call(thisArg, _arguments);
12+
function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }
13+
function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } }
14+
function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } }
15+
function step(verb, value) {
16+
var result = generator[verb](value);
17+
result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);
18+
}
19+
step("next", void 0);
20+
});
21+
};
22+
function f() {
23+
return __awaiter(this, void 0, Promise, function* () { });
24+
}
25+
//// [b.js]
26+
function g() { }
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== tests/cases/conformance/async/es6/a.ts ===
2+
async function f() {}
3+
>f : Symbol(f, Decl(a.ts, 0, 0))
4+
5+
=== tests/cases/conformance/async/es6/b.ts ===
6+
function g() { }
7+
>g : Symbol(g, Decl(b.ts, 0, 0))
8+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== tests/cases/conformance/async/es6/a.ts ===
2+
async function f() {}
3+
>f : () => Promise<void>
4+
5+
=== tests/cases/conformance/async/es6/b.ts ===
6+
function g() { }
7+
>g : () => void
8+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @target: es6
2+
// @filename: a.ts
3+
async function f() {}
4+
// @filename: b.ts
5+
function g() { }

0 commit comments

Comments
 (0)