mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-12 01:48:33 -05:00
Code Review feedback: Quick info will show type of undefined as undefined instead of any
This commit is contained in:
@@ -1068,11 +1068,7 @@ module ts {
|
||||
|
||||
function writeType(type: Type, flags: TypeFormatFlags) {
|
||||
// Write undefined/null type as any
|
||||
if ((flags & TypeFormatFlags.WriteUndefinedAndNullAsAny) &&
|
||||
((type.flags & TypeFlags.Undefined) || (type.flags & TypeFlags.Null))) {
|
||||
writeKeyword(writer, SyntaxKind.AnyKeyword);
|
||||
}
|
||||
else if (type.flags & TypeFlags.Intrinsic) {
|
||||
if (type.flags & TypeFlags.Intrinsic) {
|
||||
// Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving
|
||||
writer.writeKind(!(flags & TypeFormatFlags.WriteOwnNameForAnyLike) &&
|
||||
(type.flags & TypeFlags.Any) ? "any" : (<IntrinsicType>type).intrinsicName, SymbolDisplayPartKind.keyword);
|
||||
|
||||
@@ -686,7 +686,6 @@ module ts {
|
||||
WriteArrowStyleSignature = 0x00000008, // Write arrow style signature
|
||||
WriteOwnNameForAnyLike = 0x00000010, // Write symbol's own name instead of 'any' for any like types (eg. unknown, __resolving__ etc)
|
||||
WriteTypeArgumentsOfSignature = 0x00000020, // Write the type arguments instead of type parameters of the signature
|
||||
WriteUndefinedAndNullAsAny = 0x00000040, // Write undefined and null as any
|
||||
}
|
||||
|
||||
export enum SymbolFormatFlags {
|
||||
|
||||
@@ -1412,7 +1412,7 @@ module ts {
|
||||
|
||||
export function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[] {
|
||||
return mapToDisplayParts(writer => {
|
||||
typechecker.writeType(type, writer, enclosingDeclaration, flags | TypeFormatFlags.WriteUndefinedAndNullAsAny);
|
||||
typechecker.writeType(type, writer, enclosingDeclaration, flags);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1424,7 +1424,7 @@ module ts {
|
||||
|
||||
function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]{
|
||||
return mapToDisplayParts(writer => {
|
||||
typechecker.writeSignature(signature, writer, enclosingDeclaration, flags | TypeFormatFlags.WriteUndefinedAndNullAsAny);
|
||||
typechecker.writeSignature(signature, writer, enclosingDeclaration, flags);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2881,7 +2881,7 @@ module ts {
|
||||
// If the type is type parameter, format it specially
|
||||
if (type.symbol && type.symbol.flags & SymbolFlags.TypeParameter) {
|
||||
var typeParameterParts = mapToDisplayParts(writer => {
|
||||
typeResolver.writeTypeParameter(<TypeParameter>type, writer, enclosingDeclaration, TypeFormatFlags.WriteUndefinedAndNullAsAny);
|
||||
typeResolver.writeTypeParameter(<TypeParameter>type, writer, enclosingDeclaration);
|
||||
});
|
||||
displayParts.push.apply(displayParts, typeParameterParts);
|
||||
}
|
||||
@@ -2944,7 +2944,7 @@ module ts {
|
||||
|
||||
function writeTypeParametersOfSymbol(symbol: Symbol, enclosingDeclaration: Node) {
|
||||
var typeParameterParts = mapToDisplayParts(writer => {
|
||||
typeResolver.writeTypeParametersOfSymbol(symbol, writer, enclosingDeclaration, TypeFormatFlags.WriteUndefinedAndNullAsAny);
|
||||
typeResolver.writeTypeParametersOfSymbol(symbol, writer, enclosingDeclaration);
|
||||
});
|
||||
displayParts.push.apply(displayParts, typeParameterParts);
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ verify.quickInfoIs("(parameter) s: any");
|
||||
goTo.marker('33');
|
||||
verify.quickInfoIs("(var) c3t14: IFoo");
|
||||
goTo.marker('34');
|
||||
verify.quickInfoIs("(property) a: any[]");
|
||||
verify.quickInfoIs("(property) a: undefined[]");
|
||||
goTo.marker('35');
|
||||
verify.quickInfoIs("(property) C4T5.foo: (i: number, s: string) => string");
|
||||
goTo.marker('36');
|
||||
@@ -334,7 +334,7 @@ verify.quickInfoIs("(parameter) s: any");
|
||||
goTo.marker('69');
|
||||
verify.quickInfoIs("(property) t14: IFoo");
|
||||
goTo.marker('70');
|
||||
verify.quickInfoIs("(property) a: any[]");
|
||||
verify.quickInfoIs("(property) a: undefined[]");
|
||||
goTo.marker('71');
|
||||
verify.quickInfoIs("(parameter) n: number");
|
||||
goTo.marker('72');
|
||||
@@ -394,7 +394,7 @@ verify.quickInfoIs("(parameter) s: any");
|
||||
goTo.marker('99');
|
||||
verify.quickInfoIs("(var) c12t14: IFoo");
|
||||
goTo.marker('100');
|
||||
verify.quickInfoIs("(property) a: any[]");
|
||||
verify.quickInfoIs("(property) a: undefined[]");
|
||||
goTo.marker('101');
|
||||
verify.quickInfoIs("(function) EF1(a: number, b: number): number");
|
||||
goTo.marker('102');
|
||||
|
||||
Reference in New Issue
Block a user