@@ -172,7 +172,8 @@ namespace ts.refactor.convertFunctionToES6Class {
172172 switch ( assignmentBinaryExpression . right . kind ) {
173173 case SyntaxKind . FunctionExpression : {
174174 const functionExpression = assignmentBinaryExpression . right as FunctionExpression ;
175- const method = createMethod ( /*decorators*/ undefined , modifiers , /*asteriskToken*/ undefined , memberDeclaration . name , /*questionToken*/ undefined ,
175+ const fullModifiers = concatenate ( modifiers , getModifierKindFromSource ( functionExpression , SyntaxKind . AsyncKeyword ) ) ;
176+ const method = createMethod ( /*decorators*/ undefined , fullModifiers , /*asteriskToken*/ undefined , memberDeclaration . name , /*questionToken*/ undefined ,
176177 /*typeParameters*/ undefined , functionExpression . parameters , /*type*/ undefined , functionExpression . body ) ;
177178 copyComments ( assignmentBinaryExpression , method ) ;
178179 return method ;
@@ -192,7 +193,8 @@ namespace ts.refactor.convertFunctionToES6Class {
192193 const expression = arrowFunctionBody as Expression ;
193194 bodyBlock = createBlock ( [ createReturn ( expression ) ] ) ;
194195 }
195- const method = createMethod ( /*decorators*/ undefined , modifiers , /*asteriskToken*/ undefined , memberDeclaration . name , /*questionToken*/ undefined ,
196+ const fullModifiers = concatenate ( modifiers , getModifierKindFromSource ( arrowFunction , SyntaxKind . AsyncKeyword ) ) ;
197+ const method = createMethod ( /*decorators*/ undefined , fullModifiers , /*asteriskToken*/ undefined , memberDeclaration . name , /*questionToken*/ undefined ,
196198 /*typeParameters*/ undefined , arrowFunction . parameters , /*type*/ undefined , bodyBlock ) ;
197199 copyComments ( assignmentBinaryExpression , method ) ;
198200 return method ;
@@ -243,7 +245,7 @@ namespace ts.refactor.convertFunctionToES6Class {
243245 memberElements . unshift ( createConstructor ( /*decorators*/ undefined , /*modifiers*/ undefined , initializer . parameters , initializer . body ) ) ;
244246 }
245247
246- const modifiers = getExportModifierFromSource ( precedingNode ) ;
248+ const modifiers = getModifierKindFromSource ( precedingNode , SyntaxKind . ExportKeyword ) ;
247249 const cls = createClassDeclaration ( /*decorators*/ undefined , modifiers , node . name ,
248250 /*typeParameters*/ undefined , /*heritageClauses*/ undefined , memberElements ) ;
249251 // Don't call copyComments here because we'll already leave them in place
@@ -256,15 +258,15 @@ namespace ts.refactor.convertFunctionToES6Class {
256258 memberElements . unshift ( createConstructor ( /*decorators*/ undefined , /*modifiers*/ undefined , node . parameters , node . body ) ) ;
257259 }
258260
259- const modifiers = getExportModifierFromSource ( node ) ;
261+ const modifiers = getModifierKindFromSource ( node , SyntaxKind . ExportKeyword ) ;
260262 const cls = createClassDeclaration ( /*decorators*/ undefined , modifiers , node . name ,
261263 /*typeParameters*/ undefined , /*heritageClauses*/ undefined , memberElements ) ;
262264 // Don't call copyComments here because we'll already leave them in place
263265 return cls ;
264266 }
265267
266- function getExportModifierFromSource ( source : Node ) {
267- return filter ( source . modifiers , modifier => modifier . kind === SyntaxKind . ExportKeyword ) ;
268+ function getModifierKindFromSource ( source : Node , kind : SyntaxKind ) {
269+ return filter ( source . modifiers , modifier => modifier . kind === kind ) ;
268270 }
269271 }
270272}
0 commit comments