mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 07:13:45 -05:00
Merge pull request #16505 from Microsoft/decl-emit-parenthesize-keyof
Add parentheses around keyof in declaration emit when needed
This commit is contained in:
@@ -3233,9 +3233,15 @@ namespace ts {
|
||||
writer.writeStringLiteral(literalTypeToString(<LiteralType>type));
|
||||
}
|
||||
else if (type.flags & TypeFlags.Index) {
|
||||
if (flags & TypeFormatFlags.InElementType) {
|
||||
writePunctuation(writer, SyntaxKind.OpenParenToken);
|
||||
}
|
||||
writer.writeKeyword("keyof");
|
||||
writeSpace(writer);
|
||||
writeType((<IndexType>type).type, TypeFormatFlags.InElementType);
|
||||
if (flags & TypeFormatFlags.InElementType) {
|
||||
writePunctuation(writer, SyntaxKind.CloseParenToken);
|
||||
}
|
||||
}
|
||||
else if (type.flags & TypeFlags.IndexedAccess) {
|
||||
writeType((<IndexedAccessType>type).objectType, TypeFormatFlags.InElementType);
|
||||
|
||||
Reference in New Issue
Block a user