@@ -1027,13 +1027,26 @@ module.exports = function(ast, extra) {
1027
1027
return convertedParam ;
1028
1028
} ) ;
1029
1029
1030
- var methodNameIsComputed = ( node . name . kind === SyntaxKind . ComputedPropertyName ) ;
1030
+ var isMethodNameComputed = ( node . name . kind === SyntaxKind . ComputedPropertyName ) ;
1031
+
1032
+ /**
1033
+ * TypeScript class methods can be defined as "abstract"
1034
+ */
1035
+ var methodDefinitionType = "MethodDefinition" ;
1036
+ if ( node . modifiers && node . modifiers . length ) {
1037
+ var isAbstractMethod = node . modifiers . some ( function ( modifier ) {
1038
+ return modifier . kind === ts . SyntaxKind . AbstractKeyword ;
1039
+ } ) ;
1040
+ if ( isAbstractMethod ) {
1041
+ methodDefinitionType = "TSAbstractMethodDefinition" ;
1042
+ }
1043
+ }
1031
1044
1032
1045
assign ( result , {
1033
- type : "MethodDefinition" ,
1046
+ type : methodDefinitionType ,
1034
1047
key : convertChild ( node . name ) ,
1035
1048
value : method ,
1036
- computed : methodNameIsComputed ,
1049
+ computed : isMethodNameComputed ,
1037
1050
static : Boolean ( node . flags & ts . NodeFlags . Static ) ,
1038
1051
kind : "method" ,
1039
1052
decorators : ( node . decorators ) ? node . decorators . map ( function ( d ) {
@@ -1330,15 +1343,32 @@ module.exports = function(ast, extra) {
1330
1343
1331
1344
case SyntaxKind . ClassDeclaration :
1332
1345
case SyntaxKind . ClassExpression :
1346
+
1333
1347
var heritageClauses = node . heritageClauses || [ ] ;
1334
1348
var lastClassToken = heritageClauses . length ? heritageClauses [ heritageClauses . length - 1 ] : node . name ;
1335
- /**
1336
- * We need check for modifiers, and use the last one, as there
1337
- * could be multiple before the open brace
1338
- */
1349
+ var classNodeType = SyntaxKind [ node . kind ] ;
1350
+
1339
1351
if ( node . modifiers && node . modifiers . length ) {
1352
+
1353
+ /**
1354
+ * TypeScript class declarations can be defined as "abstract"
1355
+ */
1356
+ if ( node . kind === SyntaxKind . ClassDeclaration ) {
1357
+ var isAbstractClass = node . modifiers . some ( function ( modifier ) {
1358
+ return modifier . kind === ts . SyntaxKind . AbstractKeyword ;
1359
+ } ) ;
1360
+ if ( isAbstractClass ) {
1361
+ classNodeType = "TSAbstract" + classNodeType ;
1362
+ }
1363
+ }
1364
+
1365
+ /**
1366
+ * We need check for modifiers, and use the last one, as there
1367
+ * could be multiple before the open brace
1368
+ */
1340
1369
var lastModifier = node . modifiers [ node . modifiers . length - 1 ] ;
1341
1370
lastClassToken = ts . findNextToken ( lastModifier , ast ) ;
1371
+
1342
1372
} else if ( ! lastClassToken ) { // no name
1343
1373
lastClassToken = node . getFirstToken ( ) ;
1344
1374
}
@@ -1355,7 +1385,7 @@ module.exports = function(ast, extra) {
1355
1385
hasImplements = heritageClauses . length > 0 ;
1356
1386
1357
1387
assign ( result , {
1358
- type : SyntaxKind [ node . kind ] ,
1388
+ type : classNodeType ,
1359
1389
id : convertChild ( node . name ) ,
1360
1390
body : {
1361
1391
type : "ClassBody" ,
0 commit comments