Skip to content

Commit b26ba83

Browse files
committed
Expose signatureToString, addSupressAnyReturn Flag
1 parent 0ce53f0 commit b26ba83

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/compiler/checker.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ namespace ts {
9494
getExportSpecifierLocalTargetSymbol,
9595
getTypeAtLocation: getTypeOfNode,
9696
getPropertySymbolOfDestructuringAssignment,
97+
signatureToString,
9798
typeToString,
9899
getSymbolDisplayBuilder,
99100
symbolToString,
@@ -2674,6 +2675,11 @@ namespace ts {
26742675
}
26752676

26762677
function buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
2678+
const returnType = getReturnTypeOfSignature(signature);
2679+
if (flags & TypeFormatFlags.supressAnyReturnType && isTypeAny(returnType)) {
2680+
return;
2681+
}
2682+
26772683
if (flags & TypeFormatFlags.WriteArrowStyleSignature) {
26782684
writeSpace(writer);
26792685
writePunctuation(writer, SyntaxKind.EqualsGreaterThanToken);
@@ -2687,7 +2693,6 @@ namespace ts {
26872693
buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack);
26882694
}
26892695
else {
2690-
const returnType = getReturnTypeOfSignature(signature);
26912696
buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack);
26922697
}
26932698
}
@@ -4136,7 +4141,7 @@ namespace ts {
41364141
return <InterfaceTypeWithDeclaredMembers>type;
41374142
}
41384143

4139-
function getTypeWithThisArgument(type: Type, thisArgument?: Type) {
4144+
function getTypeWithThisArgument(type: Type, thisArgument?: Type): Type {
41404145
if (getObjectFlags(type) & ObjectFlags.Reference) {
41414146
return createTypeReference((<TypeReference>type).target,
41424147
concatenate((<TypeReference>type).typeArguments, [thisArgument || (<TypeReference>type).target.thisType]));

src/compiler/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,7 @@ namespace ts {
22572257
getNonNullableType(type: Type): Type;
22582258
getIntersectionType(types: Type[], aliasSymbol?: Symbol, aliasTypeArguments?: Type[]): Type;
22592259
getUnionType(types: Type[], subtypeReduction?: boolean, aliasSymbol?: Symbol, aliasTypeArguments?: Type[]): Type;
2260-
2260+
22612261
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
22622262
getSymbolOfNode(node: Node): Symbol;
22632263
getSymbolAtLocation(node: Node): Symbol;
@@ -2267,6 +2267,7 @@ namespace ts {
22672267
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol;
22682268
getTypeAtLocation(node: Node): Type;
22692269
getTypeFromTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference): Type;
2270+
signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string;
22702271
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
22712272
symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string;
22722273
getSymbolDisplayBuilder(): SymbolDisplayBuilder;
@@ -2348,6 +2349,7 @@ namespace ts {
23482349
InFirstTypeArgument = 0x00000100, // Writing first type argument of the instantiated type
23492350
InTypeAlias = 0x00000200, // Writing type in type alias declaration
23502351
UseTypeAliasValue = 0x00000400, // Serialize the type instead of using type-alias. This is needed when we emit declaration file.
2352+
supressAnyReturnType = 0x00000800, // If the return type is any-like, don't offer a return type.
23512353
}
23522354

23532355
export const enum SymbolFormatFlags {

0 commit comments

Comments
 (0)