From 6d159542cd07d7d557cd7418790f8940e84a0e87 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 30 Nov 2015 13:12:41 -0800 Subject: [PATCH] Fixes #5564. --- src/compiler/checker.ts | 9 ++++--- tests/baselines/reference/asyncMultiFile.js | 26 +++++++++++++++++++ .../reference/asyncMultiFile.symbols | 8 ++++++ .../baselines/reference/asyncMultiFile.types | 8 ++++++ .../conformance/async/es6/asyncMultiFile.ts | 5 ++++ 5 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/asyncMultiFile.js create mode 100644 tests/baselines/reference/asyncMultiFile.symbols create mode 100644 tests/baselines/reference/asyncMultiFile.types create mode 100644 tests/cases/conformance/async/es6/asyncMultiFile.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1b6b31f958..daa5231ad9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -532,7 +532,7 @@ namespace ts { } // Because of module/namespace merging, a module's exports are in scope, - // yet we never want to treat an export specifier as putting a member in scope. + // yet we never want to treat an export specifier as putting a member in scope. // Therefore, if the name we find is purely an export specifier, it is not actually considered in scope. // Two things to note about this: // 1. We have to check this without calling getSymbol. The problem with calling getSymbol @@ -11398,7 +11398,7 @@ namespace ts { // we can get here in two cases // 1. mixed static and instance class members // 2. something with the same name was defined before the set of overloads that prevents them from merging - // here we'll report error only for the first case since for second we should already report error in binder + // here we'll report error only for the first case since for second we should already report error in binder if (reportError) { const diagnostic = node.flags & NodeFlags.Static ? Diagnostics.Function_overload_must_be_static : Diagnostics.Function_overload_must_not_be_static; error(errorNode, diagnostic); @@ -12065,8 +12065,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 @@ -14321,6 +14321,7 @@ namespace ts { emitExtends = false; emitDecorate = false; emitParam = false; + emitAwaiter = false; potentialThisCollisions.length = 0; forEach(node.statements, checkSourceElement); diff --git a/tests/baselines/reference/asyncMultiFile.js b/tests/baselines/reference/asyncMultiFile.js new file mode 100644 index 0000000000..e93dc58625 --- /dev/null +++ b/tests/baselines/reference/asyncMultiFile.js @@ -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() { } diff --git a/tests/baselines/reference/asyncMultiFile.symbols b/tests/baselines/reference/asyncMultiFile.symbols new file mode 100644 index 0000000000..790ceafef8 --- /dev/null +++ b/tests/baselines/reference/asyncMultiFile.symbols @@ -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)) + diff --git a/tests/baselines/reference/asyncMultiFile.types b/tests/baselines/reference/asyncMultiFile.types new file mode 100644 index 0000000000..70eebc0577 --- /dev/null +++ b/tests/baselines/reference/asyncMultiFile.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es6/a.ts === +async function f() {} +>f : () => Promise + +=== tests/cases/conformance/async/es6/b.ts === +function g() { } +>g : () => void + diff --git a/tests/cases/conformance/async/es6/asyncMultiFile.ts b/tests/cases/conformance/async/es6/asyncMultiFile.ts new file mode 100644 index 0000000000..55f5e4b9e9 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncMultiFile.ts @@ -0,0 +1,5 @@ +// @target: es6 +// @filename: a.ts +async function f() {} +// @filename: b.ts +function g() { } \ No newline at end of file