@@ -498,6 +498,32 @@ module.exports = function(ast, extra) {
498498 } ;
499499 }
500500
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+
501527 /**
502528 * Converts a TSNode's typeParameters array to a flow-like TypeParameterDeclaration node
503529 * @param {TSNode[] } typeParameters TSNode typeParameters
@@ -984,6 +1010,7 @@ module.exports = function(ast, extra) {
9841010 value : convertChild ( node . initializer ) ,
9851011 computed : ( node . name . kind === SyntaxKind . ComputedPropertyName ) ,
9861012 static : Boolean ( node . flags & ts . NodeFlags . Static ) ,
1013+ accessibility : getTSNodeAccessibility ( node ) ,
9871014 decorators : ( node . decorators ) ? node . decorators . map ( function ( d ) {
9881015 return convertChild ( d . expression ) ;
9891016 } ) : [ ]
@@ -1066,6 +1093,7 @@ module.exports = function(ast, extra) {
10661093 computed : isMethodNameComputed ,
10671094 static : Boolean ( node . flags & ts . NodeFlags . Static ) ,
10681095 kind : "method" ,
1096+ accessibility : getTSNodeAccessibility ( node ) ,
10691097 decorators : ( node . decorators ) ? node . decorators . map ( function ( d ) {
10701098 return convertChild ( d . expression ) ;
10711099 } ) : [ ]
@@ -1157,6 +1185,7 @@ module.exports = function(ast, extra) {
11571185 key : constructorKey ,
11581186 value : constructor ,
11591187 computed : constructorIsComputed ,
1188+ accessibility : getTSNodeAccessibility ( node ) ,
11601189 static : constructorIsStatic ,
11611190 kind : ( constructorIsStatic || constructorIsComputed ) ? "method" : "constructor"
11621191 } ) ;
0 commit comments