Skip to content

Commit 542a2b6

Browse files
author
Max Heiber
committed
emit private names for esnext
1 parent ab44d8d commit 542a2b6

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/compiler/emitter.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,10 @@ namespace ts {
603603
case SyntaxKind.Identifier:
604604
return emitIdentifier(<Identifier>node);
605605

606+
// PrivateNames
607+
case SyntaxKind.PrivateName:
608+
return emitPrivateName(node as PrivateName);
609+
606610
// Parse tree nodes
607611

608612
// Names
@@ -872,6 +876,10 @@ namespace ts {
872876
case SyntaxKind.Identifier:
873877
return emitIdentifier(<Identifier>node);
874878

879+
// Private Names
880+
case SyntaxKind.PrivateName:
881+
return emitPrivateName(node as PrivateName);
882+
875883
// Reserved words
876884
case SyntaxKind.FalseKeyword:
877885
case SyntaxKind.NullKeyword:
@@ -1061,6 +1069,12 @@ namespace ts {
10611069
emitList(node, node.typeArguments, ListFormat.TypeParameters); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments
10621070
}
10631071

1072+
function emitPrivateName(node: PrivateName) {
1073+
const writeText = node.symbol ? writeSymbol : write;
1074+
writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol);
1075+
emitList(node, /*typeArguments*/undefined, ListFormat.TypeParameters); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments
1076+
}
1077+
10641078
//
10651079
// Names
10661080
//

src/compiler/factory.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ namespace ts {
138138
: node;
139139
}
140140

141+
export function updatePrivateName(node: PrivateName): PrivateName {
142+
return node;
143+
};
144+
141145
let nextAutoGenerateId = 0;
142146

143147
/** Create a unique temporary variable. */

src/compiler/visitor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ namespace ts {
221221

222222
case SyntaxKind.Identifier:
223223
return updateIdentifier(<Identifier>node, nodesVisitor((<Identifier>node).typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration));
224+
case SyntaxKind.PrivateName:
225+
return updatePrivateName(node as PrivateName);
224226

225227
case SyntaxKind.QualifiedName:
226228
return updateQualifiedName(<QualifiedName>node,

0 commit comments

Comments
 (0)