@@ -879,6 +879,10 @@ module.exports = function(ast, extra) {
879
879
}
880
880
}
881
881
882
+ if ( ! node . body ) {
883
+ functionDeclarationType = "TSEmptyBodyFunctionDeclaration" ;
884
+ }
885
+
882
886
/**
883
887
* Prefix FunctionDeclarations within TypeScript namespaces with "TS"
884
888
*/
@@ -1074,6 +1078,7 @@ module.exports = function(ast, extra) {
1074
1078
// TODO: double-check that these positions are correct
1075
1079
var methodLoc = ast . getLineAndCharacterOfPosition ( node . name . end + 1 ) ,
1076
1080
nodeIsMethod = ( node . kind === SyntaxKind . MethodDeclaration ) ,
1081
+ isEmptyBody = ! ( node . body ) ,
1077
1082
method = {
1078
1083
type : "FunctionExpression" ,
1079
1084
id : null ,
@@ -1127,16 +1132,24 @@ module.exports = function(ast, extra) {
1127
1132
/**
1128
1133
* TypeScript class methods can be defined as "abstract"
1129
1134
*/
1130
- var methodDefinitionType = "MethodDefinition" ;
1135
+ var methodDefinitionType = "MethodDefinition" ,
1136
+ isAbstractMethod = false ;
1131
1137
if ( node . modifiers && node . modifiers . length ) {
1132
- var isAbstractMethod = node . modifiers . some ( function ( modifier ) {
1138
+ isAbstractMethod = node . modifiers . some ( function ( modifier ) {
1133
1139
return modifier . kind === ts . SyntaxKind . AbstractKeyword ;
1134
1140
} ) ;
1135
1141
if ( isAbstractMethod ) {
1136
1142
methodDefinitionType = "TSAbstractMethodDefinition" ;
1137
1143
}
1138
1144
}
1139
1145
1146
+ if ( isEmptyBody ) {
1147
+ if ( ! isAbstractMethod ) {
1148
+ methodDefinitionType = "TSEmptyBodyMethodDefinition" ;
1149
+ }
1150
+ method . type = "TSEmptyBodyFunctionExpression" ;
1151
+ }
1152
+
1140
1153
assign ( result , {
1141
1154
type : methodDefinitionType ,
1142
1155
key : convertChild ( node . name ) ,
@@ -1167,6 +1180,7 @@ module.exports = function(ast, extra) {
1167
1180
var constructorIsStatic = Boolean ( node . flags & ts . NodeFlags . Static ) ,
1168
1181
firstConstructorToken = constructorIsStatic ? ts . findNextToken ( node . getFirstToken ( ) , ast ) : node . getFirstToken ( ) ,
1169
1182
constructorLoc = ast . getLineAndCharacterOfPosition ( node . parameters . pos - 1 ) ,
1183
+ constructorIsEmptyBody = ! ( node . body ) ,
1170
1184
constructor = {
1171
1185
type : "FunctionExpression" ,
1172
1186
id : null ,
@@ -1230,8 +1244,14 @@ module.exports = function(ast, extra) {
1230
1244
} ;
1231
1245
}
1232
1246
1247
+ var constructorMethodDefinitionType = "MethodDefinition" ;
1248
+ if ( constructorIsEmptyBody ) {
1249
+ constructorMethodDefinitionType = "TSEmptyBodyMethodDefinition" ;
1250
+ constructor . type = "TSEmptyBodyFunctionExpression" ;
1251
+ }
1252
+
1233
1253
assign ( result , {
1234
- type : "MethodDefinition" ,
1254
+ type : constructorMethodDefinitionType ,
1235
1255
key : constructorKey ,
1236
1256
value : constructor ,
1237
1257
computed : constructorIsComputed ,
0 commit comments