@@ -498,6 +498,32 @@ module.exports = function(ast, extra) {
498
498
} ;
499
499
}
500
500
501
+ /**
502
+ * Gets a TSNode's accessibility level
503
+ * @param {TSNode } tsNode The TSNode
504
+ * @returns {string | null } accessibility "public", "protected", "private", or null
505
+ */
506
+ function getTSNodeAccessibility ( tsNode ) {
507
+ var modifiers = tsNode . modifiers ;
508
+ if ( ! modifiers ) {
509
+ return null ;
510
+ }
511
+ for ( var i = 0 ; i < modifiers . length ; i ++ ) {
512
+ var modifier = modifiers [ i ] ;
513
+ switch ( modifier . kind ) {
514
+ case SyntaxKind . PublicKeyword :
515
+ return "public" ;
516
+ case SyntaxKind . ProtectedKeyword :
517
+ return "protected" ;
518
+ case SyntaxKind . PrivateKeyword :
519
+ return "private" ;
520
+ default :
521
+ continue ;
522
+ }
523
+ }
524
+ return null ;
525
+ }
526
+
501
527
/**
502
528
* Converts a TSNode's typeParameters array to a flow-like TypeParameterDeclaration node
503
529
* @param {TSNode[] } typeParameters TSNode typeParameters
@@ -984,6 +1010,7 @@ module.exports = function(ast, extra) {
984
1010
value : convertChild ( node . initializer ) ,
985
1011
computed : ( node . name . kind === SyntaxKind . ComputedPropertyName ) ,
986
1012
static : Boolean ( node . flags & ts . NodeFlags . Static ) ,
1013
+ accessibility : getTSNodeAccessibility ( node ) ,
987
1014
decorators : ( node . decorators ) ? node . decorators . map ( function ( d ) {
988
1015
return convertChild ( d . expression ) ;
989
1016
} ) : [ ]
@@ -1066,6 +1093,7 @@ module.exports = function(ast, extra) {
1066
1093
computed : isMethodNameComputed ,
1067
1094
static : Boolean ( node . flags & ts . NodeFlags . Static ) ,
1068
1095
kind : "method" ,
1096
+ accessibility : getTSNodeAccessibility ( node ) ,
1069
1097
decorators : ( node . decorators ) ? node . decorators . map ( function ( d ) {
1070
1098
return convertChild ( d . expression ) ;
1071
1099
} ) : [ ]
@@ -1157,6 +1185,7 @@ module.exports = function(ast, extra) {
1157
1185
key : constructorKey ,
1158
1186
value : constructor ,
1159
1187
computed : constructorIsComputed ,
1188
+ accessibility : getTSNodeAccessibility ( node ) ,
1160
1189
static : constructorIsStatic ,
1161
1190
kind : ( constructorIsStatic || constructorIsComputed ) ? "method" : "constructor"
1162
1191
} ) ;
0 commit comments