@@ -116,6 +116,17 @@ function isAsyncFunction(node) {
116
116
} ) ;
117
117
}
118
118
119
+ /**
120
+ * Returns true if the given TSNode has the AbstractKeyword modifier.
121
+ * @param {TSNode } node TypeScript AST node
122
+ * @returns {boolean } has abstract modifier
123
+ */
124
+ function isAbstract ( node ) {
125
+ return ! ! node . modifiers && node . modifiers . some ( function ( modifier ) {
126
+ return modifier . kind === ts . SyntaxKind . AbstractKeyword ;
127
+ } ) ;
128
+ }
129
+
119
130
/**
120
131
* Returns true if the given TSToken is a comma
121
132
* @param {TSToken } token the TypeScript token
@@ -1164,10 +1175,7 @@ module.exports = function(ast, extra) {
1164
1175
*/
1165
1176
var methodDefinitionType = "MethodDefinition" ;
1166
1177
if ( node . modifiers && node . modifiers . length ) {
1167
- var isAbstractMethod = node . modifiers . some ( function ( modifier ) {
1168
- return modifier . kind === ts . SyntaxKind . AbstractKeyword ;
1169
- } ) ;
1170
- if ( isAbstractMethod ) {
1178
+ if ( isAbstract ( node ) ) {
1171
1179
methodDefinitionType = "TSAbstractMethodDefinition" ;
1172
1180
}
1173
1181
}
@@ -1206,6 +1214,7 @@ module.exports = function(ast, extra) {
1206
1214
case SyntaxKind . Constructor :
1207
1215
1208
1216
var constructorIsStatic = Boolean ( ts . getModifierFlags ( node ) & ts . ModifierFlags . Static ) ,
1217
+ constructorIsAbstract = isAbstract ( node ) ,
1209
1218
firstConstructorToken = constructorIsStatic ? ts . findNextToken ( node . getFirstToken ( ) , ast ) : node . getFirstToken ( ) ,
1210
1219
constructorLoc = ast . getLineAndCharacterOfPosition ( node . parameters . pos - 1 ) ,
1211
1220
constructor = {
@@ -1275,7 +1284,7 @@ module.exports = function(ast, extra) {
1275
1284
}
1276
1285
1277
1286
assign ( result , {
1278
- type : "MethodDefinition" ,
1287
+ type : constructorIsAbstract ? "TSAbstractMethodDefinition" : "MethodDefinition" ,
1279
1288
key : constructorKey ,
1280
1289
value : constructor ,
1281
1290
computed : constructorIsComputed ,
@@ -1533,10 +1542,7 @@ module.exports = function(ast, extra) {
1533
1542
* TypeScript class declarations can be defined as "abstract"
1534
1543
*/
1535
1544
if ( node . kind === SyntaxKind . ClassDeclaration ) {
1536
- var isAbstractClass = node . modifiers . some ( function ( modifier ) {
1537
- return modifier . kind === ts . SyntaxKind . AbstractKeyword ;
1538
- } ) ;
1539
- if ( isAbstractClass ) {
1545
+ if ( isAbstract ( node ) ) {
1540
1546
classNodeType = "TSAbstract" + classNodeType ;
1541
1547
}
1542
1548
}
0 commit comments