@@ -1978,7 +1978,7 @@ namespace ts {
19781978 }
19791979
19801980 function transformAsyncFunctionBody ( node : FunctionLikeDeclaration ) : ConciseBody | FunctionBody {
1981- const promiseConstructor = getEntityNameFromTypeNode ( node . type ) ;
1981+ const promiseConstructor = languageVersion < ScriptTarget . ES6 ? getEntityNameFromTypeNode ( node . type ) : undefined ;
19821982 const isArrowFunction = node . kind === SyntaxKind . ArrowFunction ;
19831983 const hasLexicalArguments = ( resolver . getNodeCheckFlags ( node ) & NodeCheckFlags . CaptureArguments ) !== 0 ;
19841984
@@ -1987,77 +1987,12 @@ namespace ts {
19871987 // `this` and `arguments` objects to `__awaiter`. The generator function
19881988 // passed to `__awaiter` is executed inside of the callback to the
19891989 // promise constructor.
1990- //
1991- // The emit for an async arrow without a lexical `arguments` binding might be:
1992- //
1993- // // input
1994- // let a = async (b) => { await b; }
1995- //
1996- // // output
1997- // let a = (b) => __awaiter(this, void 0, void 0, function* () {
1998- // yield b;
1999- // });
2000- //
2001- // The emit for an async arrow with a lexical `arguments` binding might be:
2002- //
2003- // // input
2004- // let a = async (b) => { await arguments[0]; }
2005- //
2006- // // output
2007- // let a = (b) => __awaiter(this, arguments, void 0, function* (arguments) {
2008- // yield arguments[0];
2009- // });
2010- //
2011- // The emit for an async function expression without a lexical `arguments` binding
2012- // might be:
2013- //
2014- // // input
2015- // let a = async function (b) {
2016- // await b;
2017- // }
2018- //
2019- // // output
2020- // let a = function (b) {
2021- // return __awaiter(this, void 0, void 0, function* () {
2022- // yield b;
2023- // });
2024- // }
2025- //
2026- // The emit for an async function expression with a lexical `arguments` binding
2027- // might be:
2028- //
2029- // // input
2030- // let a = async function (b) {
2031- // await arguments[0];
2032- // }
2033- //
2034- // // output
2035- // let a = function (b) {
2036- // return __awaiter(this, arguments, void 0, function* (_arguments) {
2037- // yield _arguments[0];
2038- // });
2039- // }
2040- //
2041- // The emit for an async function expression with a lexical `arguments` binding
2042- // and a return type annotation might be:
2043- //
2044- // // input
2045- // let a = async function (b): MyPromise<any> {
2046- // await arguments[0];
2047- // }
2048- //
2049- // // output
2050- // let a = function (b) {
2051- // return __awaiter(this, arguments, MyPromise, function* (_arguments) {
2052- // yield _arguments[0];
2053- // });
2054- // }
2055- //
1990+
20561991
20571992 if ( ! isArrowFunction ) {
20581993 const statements : Statement [ ] = [ ] ;
20591994
2060- addNode ( statements ,
1995+ statements . push (
20611996 createReturn (
20621997 createAwaiterHelper (
20631998 hasLexicalArguments ,
0 commit comments