@@ -623,12 +623,13 @@ namespace ts {
623623 function emitModuleElementDeclarationFlags ( node : Node ) {
624624 // If the node is parented in the current source file we need to emit export declare or just export
625625 if ( node . parent . kind === SyntaxKind . SourceFile ) {
626+ const modifiers = getModifierFlags ( node ) ;
626627 // If the node is exported
627- if ( node . flags & NodeFlags . Export ) {
628+ if ( modifiers & ModifierFlags . Export ) {
628629 write ( "export " ) ;
629630 }
630631
631- if ( node . flags & NodeFlags . Default ) {
632+ if ( modifiers & ModifierFlags . Default ) {
632633 write ( "default " ) ;
633634 }
634635 else if ( node . kind !== SyntaxKind . InterfaceDeclaration && ! noDeclare ) {
@@ -637,21 +638,21 @@ namespace ts {
637638 }
638639 }
639640
640- function emitClassMemberDeclarationFlags ( flags : NodeFlags ) {
641- if ( flags & NodeFlags . Private ) {
641+ function emitClassMemberDeclarationFlags ( flags : ModifierFlags ) {
642+ if ( flags & ModifierFlags . Private ) {
642643 write ( "private " ) ;
643644 }
644- else if ( flags & NodeFlags . Protected ) {
645+ else if ( flags & ModifierFlags . Protected ) {
645646 write ( "protected " ) ;
646647 }
647648
648- if ( flags & NodeFlags . Static ) {
649+ if ( flags & ModifierFlags . Static ) {
649650 write ( "static " ) ;
650651 }
651- if ( flags & NodeFlags . Readonly ) {
652+ if ( flags & ModifierFlags . Readonly ) {
652653 write ( "readonly " ) ;
653654 }
654- if ( flags & NodeFlags . Abstract ) {
655+ if ( flags & ModifierFlags . Abstract ) {
655656 write ( "abstract " ) ;
656657 }
657658 }
@@ -660,7 +661,7 @@ namespace ts {
660661 // note usage of writer. methods instead of aliases created, just to make sure we are using
661662 // correct writer especially to handle asynchronous alias writing
662663 emitJsDocComments ( node ) ;
663- if ( node . flags & NodeFlags . Export ) {
664+ if ( hasModifier ( node , ModifierFlags . Export ) ) {
664665 write ( "export " ) ;
665666 }
666667 write ( "import " ) ;
@@ -698,12 +699,12 @@ namespace ts {
698699 }
699700
700701 function writeImportDeclaration ( node : ImportDeclaration ) {
701- if ( ! node . importClause && ! ( node . flags & NodeFlags . Export ) ) {
702+ if ( ! node . importClause && ! hasModifier ( node , ModifierFlags . Export ) ) {
702703 // do not write non-exported import declarations that don't have import clauses
703704 return ;
704705 }
705706 emitJsDocComments ( node ) ;
706- if ( node . flags & NodeFlags . Export ) {
707+ if ( hasModifier ( node , ModifierFlags . Export ) ) {
707708 write ( "export " ) ;
708709 }
709710 write ( "import " ) ;
@@ -893,7 +894,7 @@ namespace ts {
893894 }
894895
895896 function isPrivateMethodTypeParameter ( node : TypeParameterDeclaration ) {
896- return node . parent . kind === SyntaxKind . MethodDeclaration && ( node . parent . flags & NodeFlags . Private ) ;
897+ return node . parent . kind === SyntaxKind . MethodDeclaration && hasModifier ( node . parent , ModifierFlags . Private ) ;
897898 }
898899
899900 function emitTypeParameters ( typeParameters : TypeParameterDeclaration [ ] ) {
@@ -943,7 +944,7 @@ namespace ts {
943944
944945 case SyntaxKind . MethodDeclaration :
945946 case SyntaxKind . MethodSignature :
946- if ( node . parent . flags & NodeFlags . Static ) {
947+ if ( hasModifier ( node . parent , ModifierFlags . Static ) ) {
947948 diagnosticMessage = Diagnostics . Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1 ;
948949 }
949950 else if ( node . parent . parent . kind === SyntaxKind . ClassDeclaration ) {
@@ -1018,7 +1019,7 @@ namespace ts {
10181019 function emitParameterProperties ( constructorDeclaration : ConstructorDeclaration ) {
10191020 if ( constructorDeclaration ) {
10201021 forEach ( constructorDeclaration . parameters , param => {
1021- if ( param . flags & NodeFlags . AccessibilityModifier ) {
1022+ if ( hasModifier ( param , ModifierFlags . AccessibilityModifier ) ) {
10221023 emitPropertyDeclaration ( param ) ;
10231024 }
10241025 } ) ;
@@ -1027,7 +1028,7 @@ namespace ts {
10271028
10281029 emitJsDocComments ( node ) ;
10291030 emitModuleElementDeclarationFlags ( node ) ;
1030- if ( node . flags & NodeFlags . Abstract ) {
1031+ if ( hasModifier ( node , ModifierFlags . Abstract ) ) {
10311032 write ( "abstract " ) ;
10321033 }
10331034
@@ -1077,7 +1078,7 @@ namespace ts {
10771078 }
10781079
10791080 emitJsDocComments ( node ) ;
1080- emitClassMemberDeclarationFlags ( node . flags ) ;
1081+ emitClassMemberDeclarationFlags ( getModifierFlags ( node ) ) ;
10811082 emitVariableDeclaration ( < VariableDeclaration > node ) ;
10821083 write ( ";" ) ;
10831084 writeLine ( ) ;
@@ -1102,7 +1103,7 @@ namespace ts {
11021103 if ( ( node . kind === SyntaxKind . PropertyDeclaration || node . kind === SyntaxKind . PropertySignature ) && node . parent . kind === SyntaxKind . TypeLiteral ) {
11031104 emitTypeOfVariableDeclarationFromTypeLiteral ( node ) ;
11041105 }
1105- else if ( ! ( node . flags & NodeFlags . Private ) ) {
1106+ else if ( ! hasModifier ( node , ModifierFlags . Private ) ) {
11061107 writeTypeOfDeclaration ( node , node . type , getVariableDeclarationTypeVisibilityError ) ;
11071108 }
11081109 }
@@ -1119,7 +1120,7 @@ namespace ts {
11191120 // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit
11201121 else if ( node . kind === SyntaxKind . PropertyDeclaration || node . kind === SyntaxKind . PropertySignature ) {
11211122 // TODO(jfreeman): Deal with computed properties in error reporting.
1122- if ( node . flags & NodeFlags . Static ) {
1123+ if ( hasModifier ( node , ModifierFlags . Static ) ) {
11231124 return symbolAccesibilityResult . errorModuleName ?
11241125 symbolAccesibilityResult . accessibility === SymbolAccessibility . CannotBeNamed ?
11251126 Diagnostics . Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
@@ -1230,9 +1231,9 @@ namespace ts {
12301231 if ( node === accessors . firstAccessor ) {
12311232 emitJsDocComments ( accessors . getAccessor ) ;
12321233 emitJsDocComments ( accessors . setAccessor ) ;
1233- emitClassMemberDeclarationFlags ( node . flags | ( accessors . setAccessor ? 0 : NodeFlags . Readonly ) ) ;
1234+ emitClassMemberDeclarationFlags ( getModifierFlags ( node ) | ( accessors . setAccessor ? 0 : ModifierFlags . Readonly ) ) ;
12341235 writeTextOfNode ( currentText , node . name ) ;
1235- if ( ! ( node . flags & NodeFlags . Private ) ) {
1236+ if ( ! hasModifier ( node , ModifierFlags . Private ) ) {
12361237 accessorWithTypeAnnotation = node ;
12371238 let type = getTypeAnnotationFromAccessor ( node ) ;
12381239 if ( ! type ) {
@@ -1263,7 +1264,7 @@ namespace ts {
12631264 let diagnosticMessage : DiagnosticMessage ;
12641265 if ( accessorWithTypeAnnotation . kind === SyntaxKind . SetAccessor ) {
12651266 // Setters have to have type named and cannot infer it so, the type should always be named
1266- if ( accessorWithTypeAnnotation . parent . flags & NodeFlags . Static ) {
1267+ if ( hasModifier ( accessorWithTypeAnnotation . parent , ModifierFlags . Static ) ) {
12671268 diagnosticMessage = symbolAccesibilityResult . errorModuleName ?
12681269 Diagnostics . Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
12691270 Diagnostics . Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1 ;
@@ -1281,7 +1282,7 @@ namespace ts {
12811282 } ;
12821283 }
12831284 else {
1284- if ( accessorWithTypeAnnotation . flags & NodeFlags . Static ) {
1285+ if ( hasModifier ( accessorWithTypeAnnotation , ModifierFlags . Static ) ) {
12851286 diagnosticMessage = symbolAccesibilityResult . errorModuleName ?
12861287 symbolAccesibilityResult . accessibility === SymbolAccessibility . CannotBeNamed ?
12871288 Diagnostics . Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
@@ -1317,7 +1318,7 @@ namespace ts {
13171318 emitModuleElementDeclarationFlags ( node ) ;
13181319 }
13191320 else if ( node . kind === SyntaxKind . MethodDeclaration ) {
1320- emitClassMemberDeclarationFlags ( node . flags ) ;
1321+ emitClassMemberDeclarationFlags ( getModifierFlags ( node ) ) ;
13211322 }
13221323 if ( node . kind === SyntaxKind . FunctionDeclaration ) {
13231324 write ( "function " ) ;
@@ -1347,7 +1348,7 @@ namespace ts {
13471348
13481349 if ( node . kind === SyntaxKind . IndexSignature ) {
13491350 // Index signature can have readonly modifier
1350- emitClassMemberDeclarationFlags ( node . flags ) ;
1351+ emitClassMemberDeclarationFlags ( getModifierFlags ( node ) ) ;
13511352 write ( "[" ) ;
13521353 }
13531354 else {
@@ -1378,7 +1379,7 @@ namespace ts {
13781379 emitType ( node . type ) ;
13791380 }
13801381 }
1381- else if ( node . kind !== SyntaxKind . Constructor && ! ( node . flags & NodeFlags . Private ) ) {
1382+ else if ( node . kind !== SyntaxKind . Constructor && ! hasModifier ( node , ModifierFlags . Private ) ) {
13821383 writeReturnTypeAtSignature ( node , getReturnTypeVisibilityError ) ;
13831384 }
13841385
@@ -1415,7 +1416,7 @@ namespace ts {
14151416
14161417 case SyntaxKind . MethodDeclaration :
14171418 case SyntaxKind . MethodSignature :
1418- if ( node . flags & NodeFlags . Static ) {
1419+ if ( hasModifier ( node , ModifierFlags . Static ) ) {
14191420 diagnosticMessage = symbolAccesibilityResult . errorModuleName ?
14201421 symbolAccesibilityResult . accessibility === SymbolAccessibility . CannotBeNamed ?
14211422 Diagnostics . Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
@@ -1481,7 +1482,7 @@ namespace ts {
14811482 node . parent . parent . kind === SyntaxKind . TypeLiteral ) {
14821483 emitTypeOfVariableDeclarationFromTypeLiteral ( node ) ;
14831484 }
1484- else if ( ! ( node . parent . flags & NodeFlags . Private ) ) {
1485+ else if ( ! hasModifier ( node . parent , ModifierFlags . Private ) ) {
14851486 writeTypeOfDeclaration ( node , node . type , getParameterDeclarationTypeVisibilityError ) ;
14861487 }
14871488
@@ -1517,7 +1518,7 @@ namespace ts {
15171518
15181519 case SyntaxKind . MethodDeclaration :
15191520 case SyntaxKind . MethodSignature :
1520- if ( node . parent . flags & NodeFlags . Static ) {
1521+ if ( hasModifier ( node . parent , ModifierFlags . Static ) ) {
15211522 return symbolAccesibilityResult . errorModuleName ?
15221523 symbolAccesibilityResult . accessibility === SymbolAccessibility . CannotBeNamed ?
15231524 Diagnostics . Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
0 commit comments