Use external aliases in quickinfo and signature help return types (#24391) (#24395)

* Dont include import types in quick info type names

* Add UseAliasDefinedOutsideCurrentScope flag to LS operations which were missing it
This commit is contained in:
Wesley Wigham
2018-05-24 18:35:15 -07:00
committed by GitHub
parent 30415cd4f4
commit 4369d54c6b
3 changed files with 22 additions and 3 deletions
+2 -2
View File
@@ -2980,7 +2980,7 @@ namespace ts {
}
}
function typeToString(type: Type, enclosingDeclaration?: Node, flags: TypeFormatFlags = TypeFormatFlags.AllowUniqueESSymbolType, writer: EmitTextWriter = createTextWriter("")): string {
function typeToString(type: Type, enclosingDeclaration?: Node, flags: TypeFormatFlags = TypeFormatFlags.AllowUniqueESSymbolType | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, writer: EmitTextWriter = createTextWriter("")): string {
const typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors, writer);
Debug.assert(typeNode !== undefined, "should always get typenode");
const options = { removeComments: true };
@@ -3927,7 +3927,7 @@ namespace ts {
}
}
function typePredicateToString(typePredicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string {
function typePredicateToString(typePredicate: TypePredicate, enclosingDeclaration?: Node, flags: TypeFormatFlags = TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, writer?: EmitTextWriter): string {
return writer ? typePredicateToStringWorker(writer).getText() : usingSingleLineStringWriter(typePredicateToStringWorker);
function typePredicateToStringWorker(writer: EmitTextWriter) {
+1 -1
View File
@@ -1461,7 +1461,7 @@ namespace ts {
export function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[] {
return mapToDisplayParts(writer => {
typechecker.writeType(type, enclosingDeclaration, flags | TypeFormatFlags.MultilineObjectLiterals, writer);
typechecker.writeType(type, enclosingDeclaration, flags | TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, writer);
});
}
@@ -0,0 +1,19 @@
/// <reference path="fourslash.ts" />
// @Filename: b.ts
////export interface B {}
////export function foob(): {
//// x: B,
//// y: B
////} {
//// return null as any;
////}
// @Filename: a.ts
////import { foob } from "./b";
////const thing/*1*/ = foob(/*2*/);
verify.quickInfoAt("1", "const thing: {\n x: B;\n y: B;\n}");
verify.signatureHelp({
marker: "2",
text: "foob(): { x: B; y: B; }"
});