@@ -321,7 +321,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
321321 const awaiterHelper = `
322322var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {
323323 return new Promise(function (resolve, reject) {
324- generator = generator.call (thisArg, _arguments);
324+ generator = generator.apply (thisArg, _arguments);
325325 function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }
326326 function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } }
327327 function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } }
@@ -1496,11 +1496,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
14961496 }
14971497
14981498 function emitExpressionIdentifier ( node : Identifier ) {
1499- if ( resolver . getNodeCheckFlags ( node ) & NodeCheckFlags . LexicalArguments ) {
1500- write ( "_arguments" ) ;
1501- return ;
1502- }
1503-
15041499 const container = resolver . getReferencedExportContainer ( node ) ;
15051500 if ( container ) {
15061501 if ( container . kind === SyntaxKind . SourceFile ) {
@@ -2287,23 +2282,72 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
22872282 write ( ")" ) ;
22882283 }
22892284
2285+ function isSuperPropertyAccess ( node : Expression ) : node is PropertyAccessExpression {
2286+ return node . kind === SyntaxKind . PropertyAccessExpression
2287+ && ( < PropertyAccessExpression > node ) . expression . kind === SyntaxKind . SuperKeyword ;
2288+ }
2289+
2290+ function isSuperElementAccess ( node : Expression ) : node is ElementAccessExpression {
2291+ return node . kind === SyntaxKind . ElementAccessExpression
2292+ && ( < ElementAccessExpression > node ) . expression . kind === SyntaxKind . SuperKeyword ;
2293+ }
2294+
2295+ function isInAsyncMethodWithSuperInES6 ( node : CallExpression ) {
2296+ if ( languageVersion === ScriptTarget . ES6 ) {
2297+ const container = getSuperContainer ( node , /*includeFunctions*/ false ) ;
2298+ if ( container && resolver . getNodeCheckFlags ( container ) & NodeCheckFlags . AsyncMethodWithSuper ) {
2299+ return true ;
2300+ }
2301+ }
2302+
2303+ return false ;
2304+ }
2305+
2306+ function emitSuperAccessInAsyncMethod ( node : Expression ) {
2307+ write ( "_super(" ) ;
2308+ emit ( node ) ;
2309+ write ( ")" ) ;
2310+ }
2311+
22902312 function emitCallExpression ( node : CallExpression ) {
22912313 if ( languageVersion < ScriptTarget . ES6 && hasSpreadElement ( node . arguments ) ) {
22922314 emitCallWithSpread ( node ) ;
22932315 return ;
22942316 }
2317+
2318+ const expression = node . expression ;
22952319 let superCall = false ;
2296- if ( node . expression . kind === SyntaxKind . SuperKeyword ) {
2297- emitSuper ( node . expression ) ;
2320+ let isAsyncMethodWithSuper = false ;
2321+ if ( expression . kind === SyntaxKind . SuperKeyword ) {
2322+ emitSuper ( expression ) ;
22982323 superCall = true ;
22992324 }
23002325 else {
2301- emit ( node . expression ) ;
2302- superCall = node . expression . kind === SyntaxKind . PropertyAccessExpression && ( < PropertyAccessExpression > node . expression ) . expression . kind === SyntaxKind . SuperKeyword ;
2326+ if ( isSuperPropertyAccess ( expression ) ) {
2327+ superCall = true ;
2328+ if ( isInAsyncMethodWithSuperInES6 ( node ) ) {
2329+ isAsyncMethodWithSuper = true ;
2330+ const name = < StringLiteral > createSynthesizedNode ( SyntaxKind . StringLiteral ) ;
2331+ name . text = expression . name . text ;
2332+ emitSuperAccessInAsyncMethod ( name ) ;
2333+ }
2334+ }
2335+ else if ( isSuperElementAccess ( expression ) ) {
2336+ superCall = true ;
2337+ if ( isInAsyncMethodWithSuperInES6 ( node ) ) {
2338+ isAsyncMethodWithSuper = true ;
2339+ emitSuperAccessInAsyncMethod ( expression . argumentExpression ) ;
2340+ }
2341+ }
2342+
2343+ if ( ! isAsyncMethodWithSuper ) {
2344+ emit ( expression ) ;
2345+ }
23032346 }
2304- if ( superCall && languageVersion < ScriptTarget . ES6 ) {
2347+
2348+ if ( superCall && ( languageVersion < ScriptTarget . ES6 || isAsyncMethodWithSuper ) ) {
23052349 write ( ".call(" ) ;
2306- emitThis ( node . expression ) ;
2350+ emitThis ( expression ) ;
23072351 if ( node . arguments . length ) {
23082352 write ( ", " ) ;
23092353 emitCommaList ( node . arguments ) ;
@@ -2980,7 +3024,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
29803024 }
29813025 else {
29823026 // this is top level converted loop so we need to create an alias for 'this' here
2983- // NOTE:
3027+ // NOTE:
29843028 // if converted loops were all nested in arrow function then we'll always emit '_this' so convertedLoopState.thisName will not be set.
29853029 // If it is set this means that all nested loops are not nested in arrow function and it is safe to capture 'this'.
29863030 write ( `var ${ convertedLoopState . thisName } = this;` ) ;
@@ -4452,6 +4496,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
44524496 write ( " {" ) ;
44534497 increaseIndent ( ) ;
44544498 writeLine ( ) ;
4499+
4500+ if ( resolver . getNodeCheckFlags ( node ) & NodeCheckFlags . AsyncMethodWithSuper ) {
4501+ write ( "const _super = name => super[name];" ) ;
4502+ writeLine ( ) ;
4503+ }
4504+
44554505 write ( "return" ) ;
44564506 }
44574507
@@ -4472,12 +4522,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
44724522 }
44734523
44744524 // Emit the call to __awaiter.
4475- if ( hasLexicalArguments ) {
4476- write ( ", function* (_arguments)" ) ;
4477- }
4478- else {
4479- write ( ", function* ()" ) ;
4480- }
4525+ write ( ", function* ()" ) ;
44814526
44824527 // Emit the signature and body for the inner generator function.
44834528 emitFunctionBody ( node ) ;
0 commit comments