@@ -637,18 +637,21 @@ namespace ts {
637637 }
638638 }
639639
640- function emitClassMemberDeclarationFlags ( node : Declaration ) {
641- if ( node . flags & NodeFlags . Private ) {
640+ function emitClassMemberDeclarationFlags ( flags : NodeFlags ) {
641+ if ( flags & NodeFlags . Private ) {
642642 write ( "private " ) ;
643643 }
644- else if ( node . flags & NodeFlags . Protected ) {
644+ else if ( flags & NodeFlags . Protected ) {
645645 write ( "protected " ) ;
646646 }
647647
648- if ( node . flags & NodeFlags . Static ) {
648+ if ( flags & NodeFlags . Static ) {
649649 write ( "static " ) ;
650650 }
651- if ( node . flags & NodeFlags . Abstract ) {
651+ if ( flags & NodeFlags . Readonly ) {
652+ write ( "readonly " ) ;
653+ }
654+ if ( flags & NodeFlags . Abstract ) {
652655 write ( "abstract " ) ;
653656 }
654657 }
@@ -1074,7 +1077,7 @@ namespace ts {
10741077 }
10751078
10761079 emitJsDocComments ( node ) ;
1077- emitClassMemberDeclarationFlags ( node ) ;
1080+ emitClassMemberDeclarationFlags ( node . flags ) ;
10781081 emitVariableDeclaration ( < VariableDeclaration > node ) ;
10791082 write ( ";" ) ;
10801083 writeLine ( ) ;
@@ -1227,7 +1230,7 @@ namespace ts {
12271230 if ( node === accessors . firstAccessor ) {
12281231 emitJsDocComments ( accessors . getAccessor ) ;
12291232 emitJsDocComments ( accessors . setAccessor ) ;
1230- emitClassMemberDeclarationFlags ( node ) ;
1233+ emitClassMemberDeclarationFlags ( node . flags | ( accessors . setAccessor ? 0 : NodeFlags . Readonly ) ) ;
12311234 writeTextOfNode ( currentText , node . name ) ;
12321235 if ( ! ( node . flags & NodeFlags . Private ) ) {
12331236 accessorWithTypeAnnotation = node ;
@@ -1314,7 +1317,7 @@ namespace ts {
13141317 emitModuleElementDeclarationFlags ( node ) ;
13151318 }
13161319 else if ( node . kind === SyntaxKind . MethodDeclaration ) {
1317- emitClassMemberDeclarationFlags ( node ) ;
1320+ emitClassMemberDeclarationFlags ( node . flags ) ;
13181321 }
13191322 if ( node . kind === SyntaxKind . FunctionDeclaration ) {
13201323 write ( "function " ) ;
@@ -1342,15 +1345,17 @@ namespace ts {
13421345 const prevEnclosingDeclaration = enclosingDeclaration ;
13431346 enclosingDeclaration = node ;
13441347
1345- // Construct signature or constructor type write new Signature
1346- if ( node . kind === SyntaxKind . ConstructSignature || node . kind === SyntaxKind . ConstructorType ) {
1347- write ( "new " ) ;
1348- }
1349- emitTypeParameters ( node . typeParameters ) ;
13501348 if ( node . kind === SyntaxKind . IndexSignature ) {
1349+ // Index signature can have readonly modifier
1350+ emitClassMemberDeclarationFlags ( node . flags ) ;
13511351 write ( "[" ) ;
13521352 }
13531353 else {
1354+ // Construct signature or constructor type write new Signature
1355+ if ( node . kind === SyntaxKind . ConstructSignature || node . kind === SyntaxKind . ConstructorType ) {
1356+ write ( "new " ) ;
1357+ }
1358+ emitTypeParameters ( node . typeParameters ) ;
13541359 write ( "(" ) ;
13551360 }
13561361
0 commit comments