mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
Remove SuppressAnyReturnType
Following a discussion with Ryan, it seems best to leave any `any`s in the generated code.
This commit is contained in:
@@ -4532,13 +4532,7 @@ namespace ts {
|
||||
const returnType = getReturnTypeOfSignature(signature);
|
||||
returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context);
|
||||
}
|
||||
if (context.flags & NodeBuilderFlags.SuppressAnyReturnType
|
||||
&& kind !== SyntaxKind.FunctionType && kind !== SyntaxKind.ConstructorType) {
|
||||
if (returnTypeNode && returnTypeNode.kind === SyntaxKind.AnyKeyword) {
|
||||
returnTypeNode = undefined;
|
||||
}
|
||||
}
|
||||
else if (!returnTypeNode) {
|
||||
if (!returnTypeNode) {
|
||||
returnTypeNode = createKeywordTypeNode(SyntaxKind.AnyKeyword);
|
||||
}
|
||||
context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum
|
||||
|
||||
@@ -3619,6 +3619,7 @@ namespace ts {
|
||||
WriteTypeArgumentsOfSignature = 1 << 5, // Write the type arguments instead of type parameters of the signature
|
||||
UseFullyQualifiedType = 1 << 6, // Write out the fully qualified type name (eg. Module.Type, instead of Type)
|
||||
UseOnlyExternalAliasing = 1 << 7, // Only use external aliases for a symbol
|
||||
/** @deprecated Ignored */
|
||||
SuppressAnyReturnType = 1 << 8, // If the return type is any-like, don't offer a return type.
|
||||
WriteTypeParametersInQualifiedName = 1 << 9,
|
||||
MultilineObjectLiterals = 1 << 10, // Always write object literals across multiple lines
|
||||
@@ -3660,6 +3661,7 @@ namespace ts {
|
||||
WriteTypeArgumentsOfSignature = 1 << 5, // Write the type arguments instead of type parameters of the signature
|
||||
UseFullyQualifiedType = 1 << 6, // Write out the fully qualified type name (eg. Module.Type, instead of Type)
|
||||
// hole because `UseOnlyExternalAliasing` is here in node builder flags, but functions which take old flags use `SymbolFormatFlags` instead
|
||||
/** @deprecated Ignored */
|
||||
SuppressAnyReturnType = 1 << 8, // If the return type is any-like, don't offer a return type.
|
||||
// hole because `WriteTypeParametersInQualifiedName` is here in node builder flags, but functions which take old flags use `SymbolFormatFlags` for this instead
|
||||
MultilineObjectLiterals = 1 << 10, // Always print object literals across multiple lines (only used to map into node builder flags)
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace ts.codefix {
|
||||
body: Block | undefined,
|
||||
): MethodDeclaration | undefined {
|
||||
const program = context.program;
|
||||
const signatureDeclaration = <MethodDeclaration>program.getTypeChecker().signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration, NodeBuilderFlags.NoTruncation | NodeBuilderFlags.SuppressAnyReturnType, getNoopSymbolTrackerWithResolver(context));
|
||||
const signatureDeclaration = <MethodDeclaration>program.getTypeChecker().signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration, NodeBuilderFlags.NoTruncation, getNoopSymbolTrackerWithResolver(context));
|
||||
if (!signatureDeclaration) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user