mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-15 03:09:59 -05:00
Add parentheses around keyof in declaration emit
When needed. Use InElementType flag to determine this.
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