Skip to content
Merged

Fix8256 #8292

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
switch (parent.kind) {
case SyntaxKind.ArrayLiteralExpression:
case SyntaxKind.AsExpression:
case SyntaxKind.AwaitExpression:
case SyntaxKind.BinaryExpression:
case SyntaxKind.CallExpression:
case SyntaxKind.CaseClause:
Expand Down
53 changes: 53 additions & 0 deletions tests/baselines/reference/defaultExportInAwaitExpression01.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//// [tests/cases/conformance/es6/modules/defaultExportInAwaitExpression01.ts] ////

//// [a.ts]
const x = new Promise( ( resolve, reject ) => { resolve( {} ); } );
export default x;

//// [b.ts]
import x from './a';

( async function() {
const value = await x;
}() );


//// [a.js]
(function (factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports); if (v !== undefined) module.exports = v;
}
else if (typeof define === 'function' && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
const x = new Promise((resolve, reject) => { resolve({}); });
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = x;
});
//// [b.js]
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments)).next());
});
};
(function (factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports); if (v !== undefined) module.exports = v;
}
else if (typeof define === 'function' && define.amd) {
define(["require", "exports", './a'], factory);
}
})(function (require, exports) {
"use strict";
const a_1 = require('./a');
(function () {
return __awaiter(this, void 0, void 0, function* () {
const value = yield a_1.default;
});
}());
});
22 changes: 22 additions & 0 deletions tests/baselines/reference/defaultExportInAwaitExpression01.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
=== tests/cases/conformance/es6/modules/a.ts ===
const x = new Promise( ( resolve, reject ) => { resolve( {} ); } );
>x : Symbol(x, Decl(a.ts, 0, 5))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>resolve : Symbol(resolve, Decl(a.ts, 0, 24))
>reject : Symbol(reject, Decl(a.ts, 0, 33))
>resolve : Symbol(resolve, Decl(a.ts, 0, 24))

export default x;
>x : Symbol(x, Decl(a.ts, 0, 5))

=== tests/cases/conformance/es6/modules/b.ts ===
import x from './a';
>x : Symbol(x, Decl(b.ts, 0, 6))

( async function() {
const value = await x;
>value : Symbol(value, Decl(b.ts, 3, 9))
>x : Symbol(x, Decl(b.ts, 0, 6))

}() );

31 changes: 31 additions & 0 deletions tests/baselines/reference/defaultExportInAwaitExpression01.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
=== tests/cases/conformance/es6/modules/a.ts ===
const x = new Promise( ( resolve, reject ) => { resolve( {} ); } );
>x : Promise<{}>
>new Promise( ( resolve, reject ) => { resolve( {} ); } ) : Promise<{}>
>Promise : PromiseConstructor
>( resolve, reject ) => { resolve( {} ); } : (resolve: (value?: {} | PromiseLike<{}>) => void, reject: (reason?: any) => void) => void
>resolve : (value?: {} | PromiseLike<{}>) => void
>reject : (reason?: any) => void
>resolve( {} ) : void
>resolve : (value?: {} | PromiseLike<{}>) => void
>{} : {}

export default x;
>x : Promise<{}>

=== tests/cases/conformance/es6/modules/b.ts ===
import x from './a';
>x : Promise<{}>

( async function() {
>( async function() { const value = await x;}() ) : Promise<void>
>async function() { const value = await x;}() : Promise<void>
>async function() { const value = await x;} : () => Promise<void>

const value = await x;
>value : {}
>await x : {}
>x : Promise<{}>

}() );

35 changes: 35 additions & 0 deletions tests/baselines/reference/defaultExportInAwaitExpression02.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//// [tests/cases/conformance/es6/modules/defaultExportInAwaitExpression02.ts] ////

//// [a.ts]
const x = new Promise( ( resolve, reject ) => { resolve( {} ); } );
export default x;

//// [b.ts]
import x from './a';

( async function() {
const value = await x;
}() );


//// [a.js]
"use strict";
const x = new Promise((resolve, reject) => { resolve({}); });
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = x;
//// [b.js]
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments)).next());
});
};
const a_1 = require('./a');
(function () {
return __awaiter(this, void 0, void 0, function* () {
const value = yield a_1.default;
});
}());
22 changes: 22 additions & 0 deletions tests/baselines/reference/defaultExportInAwaitExpression02.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
=== tests/cases/conformance/es6/modules/a.ts ===
const x = new Promise( ( resolve, reject ) => { resolve( {} ); } );
>x : Symbol(x, Decl(a.ts, 0, 5))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>resolve : Symbol(resolve, Decl(a.ts, 0, 24))
>reject : Symbol(reject, Decl(a.ts, 0, 33))
>resolve : Symbol(resolve, Decl(a.ts, 0, 24))

export default x;
>x : Symbol(x, Decl(a.ts, 0, 5))

=== tests/cases/conformance/es6/modules/b.ts ===
import x from './a';
>x : Symbol(x, Decl(b.ts, 0, 6))

( async function() {
const value = await x;
>value : Symbol(value, Decl(b.ts, 3, 9))
>x : Symbol(x, Decl(b.ts, 0, 6))

}() );

31 changes: 31 additions & 0 deletions tests/baselines/reference/defaultExportInAwaitExpression02.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
=== tests/cases/conformance/es6/modules/a.ts ===
const x = new Promise( ( resolve, reject ) => { resolve( {} ); } );
>x : Promise<{}>
>new Promise( ( resolve, reject ) => { resolve( {} ); } ) : Promise<{}>
>Promise : PromiseConstructor
>( resolve, reject ) => { resolve( {} ); } : (resolve: (value?: {} | PromiseLike<{}>) => void, reject: (reason?: any) => void) => void
>resolve : (value?: {} | PromiseLike<{}>) => void
>reject : (reason?: any) => void
>resolve( {} ) : void
>resolve : (value?: {} | PromiseLike<{}>) => void
>{} : {}

export default x;
>x : Promise<{}>

=== tests/cases/conformance/es6/modules/b.ts ===
import x from './a';
>x : Promise<{}>

( async function() {
>( async function() { const value = await x;}() ) : Promise<void>
>async function() { const value = await x;}() : Promise<void>
>async function() { const value = await x;} : () => Promise<void>

const value = await x;
>value : {}
>await x : {}
>x : Promise<{}>

}() );

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @target: ES6
// @module: umd
// @filename: a.ts
const x = new Promise( ( resolve, reject ) => { resolve( {} ); } );
export default x;

// @filename: b.ts
import x from './a';

( async function() {
const value = await x;
}() );
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @target: ES6
// @module: commonjs
// @filename: a.ts
const x = new Promise( ( resolve, reject ) => { resolve( {} ); } );
export default x;

// @filename: b.ts
import x from './a';

( async function() {
const value = await x;
}() );