Expose signatureToString, addSupressAnyReturn Flag

This commit is contained in:
Arthur Ozga 2016-11-08 13:14:30 -08:00
parent 0ce53f0230
commit b26ba83db3
2 changed files with 10 additions and 3 deletions

View File

@ -94,6 +94,7 @@ namespace ts {
getExportSpecifierLocalTargetSymbol,
getTypeAtLocation: getTypeOfNode,
getPropertySymbolOfDestructuringAssignment,
signatureToString,
typeToString,
getSymbolDisplayBuilder,
symbolToString,
@ -2674,6 +2675,11 @@ namespace ts {
}
function buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
const returnType = getReturnTypeOfSignature(signature);
if (flags & TypeFormatFlags.supressAnyReturnType && isTypeAny(returnType)) {
return;
}
if (flags & TypeFormatFlags.WriteArrowStyleSignature) {
writeSpace(writer);
writePunctuation(writer, SyntaxKind.EqualsGreaterThanToken);
@ -2687,7 +2693,6 @@ namespace ts {
buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack);
}
else {
const returnType = getReturnTypeOfSignature(signature);
buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack);
}
}
@ -4136,7 +4141,7 @@ namespace ts {
return <InterfaceTypeWithDeclaredMembers>type;
}
function getTypeWithThisArgument(type: Type, thisArgument?: Type) {
function getTypeWithThisArgument(type: Type, thisArgument?: Type): Type {
if (getObjectFlags(type) & ObjectFlags.Reference) {
return createTypeReference((<TypeReference>type).target,
concatenate((<TypeReference>type).typeArguments, [thisArgument || (<TypeReference>type).target.thisType]));

View File

@ -2257,7 +2257,7 @@ namespace ts {
getNonNullableType(type: Type): Type;
getIntersectionType(types: Type[], aliasSymbol?: Symbol, aliasTypeArguments?: Type[]): Type;
getUnionType(types: Type[], subtypeReduction?: boolean, aliasSymbol?: Symbol, aliasTypeArguments?: Type[]): Type;
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
getSymbolOfNode(node: Node): Symbol;
getSymbolAtLocation(node: Node): Symbol;
@ -2267,6 +2267,7 @@ namespace ts {
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol;
getTypeAtLocation(node: Node): Type;
getTypeFromTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference): Type;
signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string;
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string;
getSymbolDisplayBuilder(): SymbolDisplayBuilder;
@ -2348,6 +2349,7 @@ namespace ts {
InFirstTypeArgument = 0x00000100, // Writing first type argument of the instantiated type
InTypeAlias = 0x00000200, // Writing type in type alias declaration
UseTypeAliasValue = 0x00000400, // Serialize the type instead of using type-alias. This is needed when we emit declaration file.
supressAnyReturnType = 0x00000800, // If the return type is any-like, don't offer a return type.
}
export const enum SymbolFormatFlags {