@@ -909,6 +909,10 @@ module.exports = function(ast, extra) {
909
909
}
910
910
}
911
911
912
+ if ( ! node . body ) {
913
+ functionDeclarationType = "TSEmptyBodyFunctionDeclaration" ;
914
+ }
915
+
912
916
/**
913
917
* Prefix FunctionDeclarations within TypeScript namespaces with "TS"
914
918
*/
@@ -1106,6 +1110,7 @@ module.exports = function(ast, extra) {
1106
1110
var methodLoc = ast . getLineAndCharacterOfPosition ( node . name . end + 1 ) ,
1107
1111
nodeIsMethod = ( node . kind === SyntaxKind . MethodDeclaration ) ,
1108
1112
isAmbient = ts . isInAmbientContext ( node ) ,
1113
+ isEmptyBody = ! ( node . body ) ,
1109
1114
method = {
1110
1115
type : "FunctionExpression" ,
1111
1116
id : null ,
@@ -1159,9 +1164,10 @@ module.exports = function(ast, extra) {
1159
1164
/**
1160
1165
* TypeScript class methods can be defined as "abstract"
1161
1166
*/
1162
- var methodDefinitionType = "MethodDefinition" ;
1167
+ var methodDefinitionType = "MethodDefinition" ,
1168
+ isAbstractMethod = false ;
1163
1169
if ( node . modifiers && node . modifiers . length ) {
1164
- var isAbstractMethod = node . modifiers . some ( function ( modifier ) {
1170
+ isAbstractMethod = node . modifiers . some ( function ( modifier ) {
1165
1171
return modifier . kind === ts . SyntaxKind . AbstractKeyword ;
1166
1172
} ) ;
1167
1173
if ( isAbstractMethod ) {
@@ -1173,6 +1179,13 @@ module.exports = function(ast, extra) {
1173
1179
method . type = "TSAmbientFunctionExpression" ;
1174
1180
}
1175
1181
1182
+ if ( isEmptyBody ) {
1183
+ if ( ! isAbstractMethod ) {
1184
+ methodDefinitionType = "TSEmptyBodyMethodDefinition" ;
1185
+ }
1186
+ method . type = "TSEmptyBodyFunctionExpression" ;
1187
+ }
1188
+
1176
1189
assign ( result , {
1177
1190
type : methodDefinitionType ,
1178
1191
key : convertChild ( node . name ) ,
@@ -1204,6 +1217,7 @@ module.exports = function(ast, extra) {
1204
1217
firstConstructorToken = constructorIsStatic ? ts . findNextToken ( node . getFirstToken ( ) , ast ) : node . getFirstToken ( ) ,
1205
1218
constructorLoc = ast . getLineAndCharacterOfPosition ( node . parameters . pos - 1 ) ,
1206
1219
constructorIsAmbient = ts . isInAmbientContext ( node ) ,
1220
+ constructorIsEmptyBody = ! ( node . body ) ,
1207
1221
constructor = {
1208
1222
type : "FunctionExpression" ,
1209
1223
id : null ,
@@ -1288,6 +1302,9 @@ module.exports = function(ast, extra) {
1288
1302
if ( constructorIsAmbient ) {
1289
1303
constructorMethodDefinitionType = "TSAmbientMethodDefinition" ;
1290
1304
constructor . type = "TSAmbientFunctionExpression" ;
1305
+ } else if ( constructorIsEmptyBody ) {
1306
+ constructorMethodDefinitionType = "TSEmptyBodyMethodDefinition" ;
1307
+ constructor . type = "TSEmptyBodyFunctionExpression" ;
1291
1308
}
1292
1309
1293
1310
assign ( result , {
0 commit comments