fix(36140): handle quotesPreference option in interface implementation (#36398)

This commit is contained in:
Alexander T
2020-01-27 22:25:31 +02:00
committed by Sheetal Nandi
parent 20e8eba143
commit c239626f23
6 changed files with 34 additions and 5 deletions

View File

@@ -3956,7 +3956,7 @@ namespace ts {
}
if (type.flags & TypeFlags.StringLiteral) {
context.approximateLength += ((<StringLiteralType>type).value.length + 2);
return createLiteralTypeNode(setEmitFlags(createLiteral((<StringLiteralType>type).value), EmitFlags.NoAsciiEscaping));
return createLiteralTypeNode(setEmitFlags(createLiteral((<StringLiteralType>type).value, !!(context.flags & NodeBuilderFlags.UseSingleQuotesForStringLiteralType)), EmitFlags.NoAsciiEscaping));
}
if (type.flags & TypeFlags.NumberLiteral) {
const value = (<NumberLiteralType>type).value;

View File

@@ -3630,6 +3630,7 @@ namespace ts {
UseTypeOfFunction = 1 << 12, // Build using typeof instead of function type literal
OmitParameterModifiers = 1 << 13, // Omit modifiers on parameters
UseAliasDefinedOutsideCurrentScope = 1 << 14, // Allow non-visible aliases
UseSingleQuotesForStringLiteralType = 1 << 28, // Use single quotes for string literal type
// Error handling
AllowThisInObjectLiteral = 1 << 15,
@@ -3672,6 +3673,7 @@ namespace ts {
OmitParameterModifiers = 1 << 13, // Omit modifiers on parameters
UseAliasDefinedOutsideCurrentScope = 1 << 14, // For a `type T = ... ` defined in a different file, write `T` instead of its value, even though `T` can't be accessed in the current scope.
UseSingleQuotesForStringLiteralType = 1 << 28, // Use single quotes for string literal type
// Error Handling
AllowUniqueESSymbolType = 1 << 20, // This is bit 20 to align with the same bit in `NodeBuilderFlags`
@@ -3690,7 +3692,8 @@ namespace ts {
NodeBuilderFlagsMask = NoTruncation | WriteArrayAsGenericType | UseStructuralFallback | WriteTypeArgumentsOfSignature |
UseFullyQualifiedType | SuppressAnyReturnType | MultilineObjectLiterals | WriteClassExpressionAsTypeLiteral |
UseTypeOfFunction | OmitParameterModifiers | UseAliasDefinedOutsideCurrentScope | AllowUniqueESSymbolType | InTypeAlias,
UseTypeOfFunction | OmitParameterModifiers | UseAliasDefinedOutsideCurrentScope | AllowUniqueESSymbolType | InTypeAlias |
UseSingleQuotesForStringLiteralType,
}
export const enum SymbolFormatFlags {