diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 953c97e8ead..b2afb0dd5c7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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" : (type).intrinsicName, SymbolDisplayPartKind.keyword); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 82e91487ad1..9da3bffd167 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -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 { diff --git a/src/services/services.ts b/src/services/services.ts index 46dd05a1698..6876b4bbb98 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -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(type, writer, enclosingDeclaration, TypeFormatFlags.WriteUndefinedAndNullAsAny); + typeResolver.writeTypeParameter(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); } diff --git a/tests/cases/fourslash/contextualTyping.ts b/tests/cases/fourslash/contextualTyping.ts index 503e931b60c..dad6ee8b587 100644 --- a/tests/cases/fourslash/contextualTyping.ts +++ b/tests/cases/fourslash/contextualTyping.ts @@ -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');