@@ -623,12 +623,13 @@ namespace ts {
623
623
function emitModuleElementDeclarationFlags ( node : Node ) {
624
624
// If the node is parented in the current source file we need to emit export declare or just export
625
625
if ( node . parent . kind === SyntaxKind . SourceFile ) {
626
+ const modifiers = getModifierFlags ( node ) ;
626
627
// If the node is exported
627
- if ( node . flags & NodeFlags . Export ) {
628
+ if ( modifiers & ModifierFlags . Export ) {
628
629
write ( "export " ) ;
629
630
}
630
631
631
- if ( node . flags & NodeFlags . Default ) {
632
+ if ( modifiers & ModifierFlags . Default ) {
632
633
write ( "default " ) ;
633
634
}
634
635
else if ( node . kind !== SyntaxKind . InterfaceDeclaration && ! noDeclare ) {
@@ -637,21 +638,21 @@ namespace ts {
637
638
}
638
639
}
639
640
640
- function emitClassMemberDeclarationFlags ( flags : NodeFlags ) {
641
- if ( flags & NodeFlags . Private ) {
641
+ function emitClassMemberDeclarationFlags ( flags : ModifierFlags ) {
642
+ if ( flags & ModifierFlags . Private ) {
642
643
write ( "private " ) ;
643
644
}
644
- else if ( flags & NodeFlags . Protected ) {
645
+ else if ( flags & ModifierFlags . Protected ) {
645
646
write ( "protected " ) ;
646
647
}
647
648
648
- if ( flags & NodeFlags . Static ) {
649
+ if ( flags & ModifierFlags . Static ) {
649
650
write ( "static " ) ;
650
651
}
651
- if ( flags & NodeFlags . Readonly ) {
652
+ if ( flags & ModifierFlags . Readonly ) {
652
653
write ( "readonly " ) ;
653
654
}
654
- if ( flags & NodeFlags . Abstract ) {
655
+ if ( flags & ModifierFlags . Abstract ) {
655
656
write ( "abstract " ) ;
656
657
}
657
658
}
@@ -660,7 +661,7 @@ namespace ts {
660
661
// note usage of writer. methods instead of aliases created, just to make sure we are using
661
662
// correct writer especially to handle asynchronous alias writing
662
663
emitJsDocComments ( node ) ;
663
- if ( node . flags & NodeFlags . Export ) {
664
+ if ( hasModifier ( node , ModifierFlags . Export ) ) {
664
665
write ( "export " ) ;
665
666
}
666
667
write ( "import " ) ;
@@ -698,12 +699,12 @@ namespace ts {
698
699
}
699
700
700
701
function writeImportDeclaration ( node : ImportDeclaration ) {
701
- if ( ! node . importClause && ! ( node . flags & NodeFlags . Export ) ) {
702
+ if ( ! node . importClause && ! hasModifier ( node , ModifierFlags . Export ) ) {
702
703
// do not write non-exported import declarations that don't have import clauses
703
704
return ;
704
705
}
705
706
emitJsDocComments ( node ) ;
706
- if ( node . flags & NodeFlags . Export ) {
707
+ if ( hasModifier ( node , ModifierFlags . Export ) ) {
707
708
write ( "export " ) ;
708
709
}
709
710
write ( "import " ) ;
@@ -893,7 +894,7 @@ namespace ts {
893
894
}
894
895
895
896
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 ) ;
897
898
}
898
899
899
900
function emitTypeParameters ( typeParameters : TypeParameterDeclaration [ ] ) {
@@ -943,7 +944,7 @@ namespace ts {
943
944
944
945
case SyntaxKind . MethodDeclaration :
945
946
case SyntaxKind . MethodSignature :
946
- if ( node . parent . flags & NodeFlags . Static ) {
947
+ if ( hasModifier ( node . parent , ModifierFlags . Static ) ) {
947
948
diagnosticMessage = Diagnostics . Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1 ;
948
949
}
949
950
else if ( node . parent . parent . kind === SyntaxKind . ClassDeclaration ) {
@@ -1018,7 +1019,7 @@ namespace ts {
1018
1019
function emitParameterProperties ( constructorDeclaration : ConstructorDeclaration ) {
1019
1020
if ( constructorDeclaration ) {
1020
1021
forEach ( constructorDeclaration . parameters , param => {
1021
- if ( param . flags & NodeFlags . AccessibilityModifier ) {
1022
+ if ( hasModifier ( param , ModifierFlags . AccessibilityModifier ) ) {
1022
1023
emitPropertyDeclaration ( param ) ;
1023
1024
}
1024
1025
} ) ;
@@ -1027,7 +1028,7 @@ namespace ts {
1027
1028
1028
1029
emitJsDocComments ( node ) ;
1029
1030
emitModuleElementDeclarationFlags ( node ) ;
1030
- if ( node . flags & NodeFlags . Abstract ) {
1031
+ if ( hasModifier ( node , ModifierFlags . Abstract ) ) {
1031
1032
write ( "abstract " ) ;
1032
1033
}
1033
1034
@@ -1077,7 +1078,7 @@ namespace ts {
1077
1078
}
1078
1079
1079
1080
emitJsDocComments ( node ) ;
1080
- emitClassMemberDeclarationFlags ( node . flags ) ;
1081
+ emitClassMemberDeclarationFlags ( getModifierFlags ( node ) ) ;
1081
1082
emitVariableDeclaration ( < VariableDeclaration > node ) ;
1082
1083
write ( ";" ) ;
1083
1084
writeLine ( ) ;
@@ -1102,7 +1103,7 @@ namespace ts {
1102
1103
if ( ( node . kind === SyntaxKind . PropertyDeclaration || node . kind === SyntaxKind . PropertySignature ) && node . parent . kind === SyntaxKind . TypeLiteral ) {
1103
1104
emitTypeOfVariableDeclarationFromTypeLiteral ( node ) ;
1104
1105
}
1105
- else if ( ! ( node . flags & NodeFlags . Private ) ) {
1106
+ else if ( ! hasModifier ( node , ModifierFlags . Private ) ) {
1106
1107
writeTypeOfDeclaration ( node , node . type , getVariableDeclarationTypeVisibilityError ) ;
1107
1108
}
1108
1109
}
@@ -1119,7 +1120,7 @@ namespace ts {
1119
1120
// This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit
1120
1121
else if ( node . kind === SyntaxKind . PropertyDeclaration || node . kind === SyntaxKind . PropertySignature ) {
1121
1122
// TODO(jfreeman): Deal with computed properties in error reporting.
1122
- if ( node . flags & NodeFlags . Static ) {
1123
+ if ( hasModifier ( node , ModifierFlags . Static ) ) {
1123
1124
return symbolAccesibilityResult . errorModuleName ?
1124
1125
symbolAccesibilityResult . accessibility === SymbolAccessibility . CannotBeNamed ?
1125
1126
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 {
1230
1231
if ( node === accessors . firstAccessor ) {
1231
1232
emitJsDocComments ( accessors . getAccessor ) ;
1232
1233
emitJsDocComments ( accessors . setAccessor ) ;
1233
- emitClassMemberDeclarationFlags ( node . flags | ( accessors . setAccessor ? 0 : NodeFlags . Readonly ) ) ;
1234
+ emitClassMemberDeclarationFlags ( getModifierFlags ( node ) | ( accessors . setAccessor ? 0 : ModifierFlags . Readonly ) ) ;
1234
1235
writeTextOfNode ( currentText , node . name ) ;
1235
- if ( ! ( node . flags & NodeFlags . Private ) ) {
1236
+ if ( ! hasModifier ( node , ModifierFlags . Private ) ) {
1236
1237
accessorWithTypeAnnotation = node ;
1237
1238
let type = getTypeAnnotationFromAccessor ( node ) ;
1238
1239
if ( ! type ) {
@@ -1263,7 +1264,7 @@ namespace ts {
1263
1264
let diagnosticMessage : DiagnosticMessage ;
1264
1265
if ( accessorWithTypeAnnotation . kind === SyntaxKind . SetAccessor ) {
1265
1266
// 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 ) ) {
1267
1268
diagnosticMessage = symbolAccesibilityResult . errorModuleName ?
1268
1269
Diagnostics . Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
1269
1270
Diagnostics . Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1 ;
@@ -1281,7 +1282,7 @@ namespace ts {
1281
1282
} ;
1282
1283
}
1283
1284
else {
1284
- if ( accessorWithTypeAnnotation . flags & NodeFlags . Static ) {
1285
+ if ( hasModifier ( accessorWithTypeAnnotation , ModifierFlags . Static ) ) {
1285
1286
diagnosticMessage = symbolAccesibilityResult . errorModuleName ?
1286
1287
symbolAccesibilityResult . accessibility === SymbolAccessibility . CannotBeNamed ?
1287
1288
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 {
1317
1318
emitModuleElementDeclarationFlags ( node ) ;
1318
1319
}
1319
1320
else if ( node . kind === SyntaxKind . MethodDeclaration ) {
1320
- emitClassMemberDeclarationFlags ( node . flags ) ;
1321
+ emitClassMemberDeclarationFlags ( getModifierFlags ( node ) ) ;
1321
1322
}
1322
1323
if ( node . kind === SyntaxKind . FunctionDeclaration ) {
1323
1324
write ( "function " ) ;
@@ -1347,7 +1348,7 @@ namespace ts {
1347
1348
1348
1349
if ( node . kind === SyntaxKind . IndexSignature ) {
1349
1350
// Index signature can have readonly modifier
1350
- emitClassMemberDeclarationFlags ( node . flags ) ;
1351
+ emitClassMemberDeclarationFlags ( getModifierFlags ( node ) ) ;
1351
1352
write ( "[" ) ;
1352
1353
}
1353
1354
else {
@@ -1378,7 +1379,7 @@ namespace ts {
1378
1379
emitType ( node . type ) ;
1379
1380
}
1380
1381
}
1381
- else if ( node . kind !== SyntaxKind . Constructor && ! ( node . flags & NodeFlags . Private ) ) {
1382
+ else if ( node . kind !== SyntaxKind . Constructor && ! hasModifier ( node , ModifierFlags . Private ) ) {
1382
1383
writeReturnTypeAtSignature ( node , getReturnTypeVisibilityError ) ;
1383
1384
}
1384
1385
@@ -1415,7 +1416,7 @@ namespace ts {
1415
1416
1416
1417
case SyntaxKind . MethodDeclaration :
1417
1418
case SyntaxKind . MethodSignature :
1418
- if ( node . flags & NodeFlags . Static ) {
1419
+ if ( hasModifier ( node , ModifierFlags . Static ) ) {
1419
1420
diagnosticMessage = symbolAccesibilityResult . errorModuleName ?
1420
1421
symbolAccesibilityResult . accessibility === SymbolAccessibility . CannotBeNamed ?
1421
1422
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 {
1481
1482
node . parent . parent . kind === SyntaxKind . TypeLiteral ) {
1482
1483
emitTypeOfVariableDeclarationFromTypeLiteral ( node ) ;
1483
1484
}
1484
- else if ( ! ( node . parent . flags & NodeFlags . Private ) ) {
1485
+ else if ( ! hasModifier ( node . parent , ModifierFlags . Private ) ) {
1485
1486
writeTypeOfDeclaration ( node , node . type , getParameterDeclarationTypeVisibilityError ) ;
1486
1487
}
1487
1488
@@ -1517,7 +1518,7 @@ namespace ts {
1517
1518
1518
1519
case SyntaxKind . MethodDeclaration :
1519
1520
case SyntaxKind . MethodSignature :
1520
- if ( node . parent . flags & NodeFlags . Static ) {
1521
+ if ( hasModifier ( node . parent , ModifierFlags . Static ) ) {
1521
1522
return symbolAccesibilityResult . errorModuleName ?
1522
1523
symbolAccesibilityResult . accessibility === SymbolAccessibility . CannotBeNamed ?
1523
1524
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