From 91af0ce2b9154dad64016f81c7c9512649bd328e Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 7 Mar 2025 08:48:48 -0800 Subject: [PATCH 01/31] Reapply "Proposed expandable hover API" (#61132) This reverts commit 34ea32f8ce2771fb3b063f66ec0bc7b0c017d9e4. --- src/compiler/checker.ts | 137 +- src/compiler/types.ts | 8 +- src/harness/client.ts | 5 +- src/harness/fourslashImpl.ts | 25 +- src/harness/fourslashInterfaceImpl.ts | 4 +- src/server/protocol.ts | 10 + src/server/session.ts | 5 +- src/services/services.ts | 20 +- src/services/symbolDisplay.ts | 59 +- src/services/types.ts | 3 + src/services/utilities.ts | 5 +- tests/baselines/reference/api/typescript.d.ts | 9 + .../reference/quickinfoVerbosity1.baseline | 326 +++ .../reference/quickinfoVerbosity2.baseline | 431 +++ .../quickinfoVerbosityClass1.baseline | 1908 +++++++++++++ .../quickinfoVerbosityInterface1.baseline | 2383 +++++++++++++++++ .../quickinfoVerbosityIntersection1.baseline | 357 +++ .../quickinfoVerbosityObjectType1.baseline | 1299 +++++++++ .../quickinfoVerbosityServer.baseline | 79 + .../quickinfoVerbosityTruncation.baseline | 706 +++++ .../quickinfoVerbosityServer.js | 199 ++ tests/cases/fourslash/fourslash.ts | 5 +- tests/cases/fourslash/quickinfoVerbosity1.ts | 10 + tests/cases/fourslash/quickinfoVerbosity2.ts | 11 + .../fourslash/quickinfoVerbosityClass1.ts | 71 + .../fourslash/quickinfoVerbosityInterface1.ts | 79 + .../quickinfoVerbosityIntersection1.ts | 22 + .../quickinfoVerbosityObjectType1.ts | 13 + .../fourslash/quickinfoVerbosityTruncation.ts | 31 + .../server/quickinfoVerbosityServer.ts | 6 + 30 files changed, 8169 insertions(+), 57 deletions(-) create mode 100644 tests/baselines/reference/quickinfoVerbosity1.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosity2.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityClass1.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityInterface1.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityIntersection1.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityObjectType1.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityServer.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityTruncation.baseline create mode 100644 tests/baselines/reference/tsserver/fourslashServer/quickinfoVerbosityServer.js create mode 100644 tests/cases/fourslash/quickinfoVerbosity1.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosity2.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityClass1.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityInterface1.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityIntersection1.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityObjectType1.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityTruncation.ts create mode 100644 tests/cases/fourslash/server/quickinfoVerbosityServer.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index caab75c99fa8a..2ff3708e03128 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1132,6 +1132,7 @@ import { WhileStatement, WideningContext, WithStatement, + WriterContextOut, YieldExpression, } from "./_namespaces/ts.js"; import * as moduleSpecifiers from "./_namespaces/ts.moduleSpecifiers.js"; @@ -1719,8 +1720,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { writeSignature: (signature, enclosingDeclaration, flags, kind, writer) => { return signatureToString(signature, getParseTreeNode(enclosingDeclaration), flags, kind, writer); }, - writeType: (type, enclosingDeclaration, flags, writer) => { - return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer); + writeType: (type, enclosingDeclaration, flags, writer, verbosityLevel, out) => { + return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer, verbosityLevel, out); }, writeSymbol: (symbol, enclosingDeclaration, meaning, flags, writer) => { return symbolToString(symbol, getParseTreeNode(enclosingDeclaration), meaning, flags, writer); @@ -6046,9 +6047,24 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function typeToString(type: Type, enclosingDeclaration?: Node, flags: TypeFormatFlags = TypeFormatFlags.AllowUniqueESSymbolType | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, writer: EmitTextWriter = createTextWriter("")): string { - const noTruncation = compilerOptions.noErrorTruncation || flags & TypeFormatFlags.NoTruncation; - const typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors | (noTruncation ? NodeBuilderFlags.NoTruncation : NodeBuilderFlags.None), /*internalFlags*/ undefined); + function typeToString( + type: Type, + enclosingDeclaration?: Node, + flags: TypeFormatFlags = TypeFormatFlags.AllowUniqueESSymbolType | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, + writer: EmitTextWriter = createTextWriter(""), + verbosityLevel?: number, + out?: WriterContextOut, + ): string { + const noTruncation = compilerOptions.noErrorTruncation || flags & TypeFormatFlags.NoTruncation || verbosityLevel !== undefined; + const typeNode = nodeBuilder.typeToTypeNode( + type, + enclosingDeclaration, + toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors | (noTruncation ? NodeBuilderFlags.NoTruncation : 0), + /*internalFlags*/ undefined, + /*tracker*/ undefined, + verbosityLevel, + out, + ); if (typeNode === undefined) return Debug.fail("should always get typenode"); // The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`. // Otherwise, we always strip comments out. @@ -6268,20 +6284,20 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { }; return { syntacticBuilderResolver, - typeToTypeNode: (type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => typeToTypeNodeHelper(type, context)), - typePredicateToTypePredicateNode: (typePredicate: TypePredicate, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => typePredicateToTypePredicateNodeHelper(typePredicate, context)), - serializeTypeForExpression: (expr: Expression, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)), - serializeTypeForDeclaration: (declaration: HasInferredType, symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)), - serializeReturnTypeForSignature: (signature: SignatureDeclaration, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)), - indexInfoToIndexSignatureDeclaration: (indexInfo: IndexInfo, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => indexInfoToIndexSignatureDeclarationHelper(indexInfo, context, /*typeNode*/ undefined)), - signatureToSignatureDeclaration: (signature: Signature, kind: SignatureDeclaration["kind"], enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => signatureToSignatureDeclarationHelper(signature, kind, context)), - symbolToEntityName: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false)), - symbolToExpression: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => symbolToExpression(symbol, context, meaning)), - symbolToTypeParameterDeclarations: (symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => typeParametersToTypeParameterDeclarations(symbol, context)), - symbolToParameterDeclaration: (symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => symbolToParameterDeclaration(symbol, context)), - typeParameterToDeclaration: (parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => typeParameterToDeclaration(parameter, context)), - symbolTableToDeclarationStatements: (symbolTable: SymbolTable, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => symbolTableToDeclarationStatements(symbolTable, context)), - symbolToNode: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => symbolToNode(symbol, context, meaning)), + typeToTypeNode: (type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number, out?: { couldUnfoldMore: boolean; }) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, context => typeToTypeNodeHelper(type, context), out), + typePredicateToTypePredicateNode: (typePredicate: TypePredicate, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => typePredicateToTypePredicateNodeHelper(typePredicate, context)), + serializeTypeForDeclaration: (declaration: HasInferredType, symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)), + serializeReturnTypeForSignature: (signature: SignatureDeclaration, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)), + serializeTypeForExpression: (expr: Expression, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)), + indexInfoToIndexSignatureDeclaration: (indexInfo: IndexInfo, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => indexInfoToIndexSignatureDeclarationHelper(indexInfo, context, /*typeNode*/ undefined)), + signatureToSignatureDeclaration: (signature: Signature, kind: SignatureDeclaration["kind"], enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => signatureToSignatureDeclarationHelper(signature, kind, context)), + symbolToEntityName: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false)), + symbolToExpression: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolToExpression(symbol, context, meaning)), + symbolToTypeParameterDeclarations: (symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => typeParametersToTypeParameterDeclarations(symbol, context)), + symbolToParameterDeclaration: (symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolToParameterDeclaration(symbol, context)), + typeParameterToDeclaration: (parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, context => typeParameterToDeclaration(parameter, context)), + symbolTableToDeclarationStatements: (symbolTable: SymbolTable, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolTableToDeclarationStatements(symbolTable, context)), + symbolToNode: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolToNode(symbol, context, meaning)), }; function getTypeFromTypeNode(context: NodeBuilderContext, node: TypeNode, noMappedTypes?: false): Type; @@ -6341,7 +6357,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return symbolToExpression(symbol, context, meaning); } - function withContext(enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags: InternalNodeBuilderFlags | undefined, tracker: SymbolTracker | undefined, cb: (context: NodeBuilderContext) => T): T | undefined { + function withContext( + enclosingDeclaration: Node | undefined, + flags: NodeBuilderFlags | undefined, + internalFlags: InternalNodeBuilderFlags | undefined, + tracker: SymbolTracker | undefined, + verbosityLevel: number | undefined, + cb: (context: NodeBuilderContext) => T, + out?: WriterContextOut, + ): T | undefined { const moduleResolverHost = tracker?.trackSymbol ? tracker.moduleResolverHost : (internalFlags || InternalNodeBuilderFlags.None) & InternalNodeBuilderFlags.DoNotIncludeSymbolChain ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : undefined; @@ -6351,6 +6375,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { flags: flags || NodeBuilderFlags.None, internalFlags: internalFlags || InternalNodeBuilderFlags.None, tracker: undefined!, + unfoldDepth: verbosityLevel ?? -1, encounteredError: false, suppressReportInferenceFallback: false, reportedDiagnostic: false, @@ -6373,12 +6398,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { typeParameterNamesByTextNextNameCount: undefined, enclosingSymbolTypes: new Map(), mapper: undefined, + depth: 0, + couldUnfoldMore: false, }; context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost); const resultingNode = cb(context); if (context.truncating && context.flags & NodeBuilderFlags.NoTruncation) { context.tracker.reportTruncationError(); } + if (out) { + out.couldUnfoldMore = context.couldUnfoldMore; + } return context.encounteredError ? undefined : resultingNode; } @@ -6399,12 +6429,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function saveRestoreFlags(context: NodeBuilderContext) { const flags = context.flags; const internalFlags = context.internalFlags; + const depth = context.depth; return restore; function restore() { context.flags = flags; context.internalFlags = internalFlags; + context.depth = depth; } } @@ -6413,6 +6445,25 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return context.truncating = context.approximateLength > ((context.flags & NodeBuilderFlags.NoTruncation) ? noTruncationMaximumTruncationLength : defaultMaximumTruncationLength); } + function couldUnfoldType(type: Type, context: NodeBuilderContext): boolean { + if (context.visitedTypes?.has(type.id)) { + return false; + } + return context.depth < context.unfoldDepth || context.depth === context.unfoldDepth && !context.couldUnfoldMore; + } + + // Determines if a type can be unfolded, based on how many layers of type aliases we're allowed to unfold. + function canUnfoldType(type: Type, context: NodeBuilderContext): boolean { + if (context.visitedTypes?.has(type.id)) { + return false; + } + const result = context.depth < context.unfoldDepth; + if (!result) { + context.couldUnfoldMore = true; + } + return result; + } + function typeToTypeNodeHelper(type: Type, context: NodeBuilderContext): TypeNode { const restoreFlags = saveRestoreFlags(context); const typeNode = typeToTypeNodeWorker(type, context); @@ -6562,18 +6613,25 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } if (!inTypeAlias && type.aliasSymbol && (context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & SymbolFlags.Class)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes); - if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) { - return factory.createArrayTypeNode(typeArgumentNodes![0]); + if (!canUnfoldType(type, context)) { + const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & SymbolFlags.Class)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes); + if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) { + return factory.createArrayTypeNode(typeArgumentNodes![0]); + } + return symbolToTypeNode(type.aliasSymbol, context, SymbolFlags.Type, typeArgumentNodes); } - return symbolToTypeNode(type.aliasSymbol, context, SymbolFlags.Type, typeArgumentNodes); + context.depth += 1; } const objectFlags = getObjectFlags(type); if (objectFlags & ObjectFlags.Reference) { Debug.assert(!!(type.flags & TypeFlags.Object)); + if (canUnfoldType(type, context)) { + context.depth += 1; + return createAnonymousTypeNode(type as TypeReference, /*forceClassExpansion*/ true); + } return (type as TypeReference).node ? visitAndTransformType(type as TypeReference, typeReferenceToTypeNode) : typeReferenceToTypeNode(type as TypeReference); } if (type.flags & TypeFlags.TypeParameter || objectFlags & ObjectFlags.ClassOrInterface) { @@ -6602,6 +6660,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { context.approximateLength += idText(name).length; return factory.createTypeReferenceNode(factory.createIdentifier(idText(name)), /*typeArguments*/ undefined); } + if (objectFlags & ObjectFlags.ClassOrInterface && canUnfoldType(type, context)) { + context.depth += 1; + return createAnonymousTypeNode(type as InterfaceType, /*forceClassExpansion*/ true); + } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. if (type.symbol) { return symbolToTypeNode(type.symbol, context, SymbolFlags.Type); @@ -6809,7 +6871,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return result; } - function createAnonymousTypeNode(type: ObjectType): TypeNode { + function createAnonymousTypeNode(type: ObjectType, forceClassExpansion = false): TypeNode { const typeId = type.id; const symbol = type.symbol; if (symbol) { @@ -6843,10 +6905,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Always use 'typeof T' for type of class, enum, and module objects else if ( symbol.flags & SymbolFlags.Class + && !forceClassExpansion && !getBaseTypeVariableOfClass(symbol) - && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & NodeBuilderFlags.WriteClassExpressionAsTypeLiteral && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== SymbolAccessibility.Accessible)) || - symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || - shouldWriteTypeOfFunctionSymbol() + && !(symbol.valueDeclaration + && isClassLike(symbol.valueDeclaration) + && context.flags & NodeBuilderFlags.WriteClassExpressionAsTypeLiteral + && (!isClassDeclaration(symbol.valueDeclaration) + || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== SymbolAccessibility.Accessible)) + || symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) + || shouldWriteTypeOfFunctionSymbol() ) { return symbolToTypeNode(symbol, context, isInstanceType); } @@ -6899,7 +6966,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { context.symbolDepth = new Map(); } - const links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); + // Don't rely on type cache if we're unfolding a type, because we need to compute `couldUnfoldMore`. + const links = context.unfoldDepth >= 0 ? undefined : context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); const key = `${getTypeId(type)}|${context.flags}|${context.internalFlags}`; if (links) { links.serializedTypes ||= new Map(); @@ -7925,7 +7993,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function typeToTypeNodeHelperWithPossibleReusableTypeNode(type: Type, typeNode: TypeNode | undefined, context: NodeBuilderContext) { - return typeNode && getTypeFromTypeNode(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) + return !couldUnfoldType(type, context) && typeNode && getTypeFromTypeNode(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context); } @@ -8664,7 +8732,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let result; const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration); const decl = declaration ?? symbol.valueDeclaration ?? getDeclarationWithTypeAnnotation(symbol) ?? symbol.declarations?.[0]; - if (decl) { + if (!couldUnfoldType(type, context) && decl) { if (isAccessor(decl)) { result = syntacticNodeBuilder.serializeTypeOfAccessor(decl, symbol, context); } @@ -52907,6 +52975,7 @@ interface NodeBuilderContext extends SyntacticTypeNodeBuilderContext { flags: NodeBuilderFlags; internalFlags: InternalNodeBuilderFlags; tracker: SymbolTrackerImpl; + readonly unfoldDepth: number; // State encounteredError: boolean; @@ -52930,7 +52999,11 @@ interface NodeBuilderContext extends SyntacticTypeNodeBuilderContext { reverseMappedStack: ReverseMappedSymbol[] | undefined; bundled: boolean; mapper: TypeMapper | undefined; + depth: number; // How many levels of nested type aliases we have unfolded so far suppressReportInferenceFallback: boolean; + + // Output + couldUnfoldMore: boolean; // Whether we found a type alias that we could unfold but didn't } class SymbolTrackerImpl implements SymbolTracker { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f6ca75a68e17d..9cd1a9b9fc618 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5048,6 +5048,11 @@ export interface TypeCheckerHost extends ModuleSpecifierResolutionHost, SourceFi packageBundlesTypes(packageName: string): boolean; } +/** @internal */ +export interface WriterContextOut { + couldUnfoldMore: boolean; +} + export interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; getTypeOfSymbol(symbol: Symbol): Type; @@ -5134,6 +5139,7 @@ export interface TypeChecker { symbolToParameterDeclaration(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): ParameterDeclaration | undefined; /** Note that the resulting nodes cannot be checked. */ typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeParameterDeclaration | undefined; + /** @internal */ typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number): TypeParameterDeclaration | undefined; // eslint-disable-line @typescript-eslint/unified-signatures getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol | undefined; @@ -5166,7 +5172,7 @@ export interface TypeChecker { typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; /** @internal */ writeSignature(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind, writer?: EmitTextWriter): string; - /** @internal */ writeType(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string; + /** @internal */ writeType(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter, verbosityLevel?: number, out?: WriterContextOut): string; /** @internal */ writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags, writer?: EmitTextWriter): string; /** @internal */ writeTypePredicate(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string; diff --git a/src/harness/client.ts b/src/harness/client.ts index ec659d738c02a..c735ffa7f3e34 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -254,8 +254,8 @@ export class SessionClient implements LanguageService { return { line, character: offset }; } - getQuickInfoAtPosition(fileName: string, position: number): QuickInfo { - const args = this.createFileLocationRequestArgs(fileName, position); + getQuickInfoAtPosition(fileName: string, position: number, verbosityLevel?: number | undefined): QuickInfo { + const args = { ...this.createFileLocationRequestArgs(fileName, position), verbosityLevel }; const request = this.processRequest(protocol.CommandTypes.Quickinfo, args); const response = this.processResponse(request); @@ -268,6 +268,7 @@ export class SessionClient implements LanguageService { displayParts: [{ kind: "text", text: body.displayString }], documentation: typeof body.documentation === "string" ? [{ kind: "text", text: body.documentation }] : body.documentation, tags: this.decodeLinkDisplayParts(body.tags), + canIncreaseVerbosityLevel: body.canIncreaseVerbosityLevel, }; } diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts index e1a410dfb5d3b..81ffed9cd698f 100644 --- a/src/harness/fourslashImpl.ts +++ b/src/harness/fourslashImpl.ts @@ -86,6 +86,10 @@ export interface TextSpan { end: number; } +export interface VerbosityLevels { + [markerName: string]: number | number[] | undefined; +} + // Name of testcase metadata including ts.CompilerOptions properties that will be used by globalOptions // To add additional option, add property into the testOptMetadataNames, refer the property in either globalMetadataNames or fileMetadataNames // Add cases into convertGlobalOptionsToCompilationsSettings function for the compiler to acknowledge such option from meta data @@ -2451,19 +2455,28 @@ export class TestState { return result; } - public baselineQuickInfo(): void { - const result = ts.arrayFrom(this.testData.markerPositions.entries(), ([name, marker]) => ({ - marker: { ...marker, name }, - item: this.languageService.getQuickInfoAtPosition(marker.fileName, marker.position), - })); + public baselineQuickInfo(verbosityLevels?: VerbosityLevels): void { + const result = ts.arrayFrom(this.testData.markerPositions.entries(), ([name, marker]) => { + const verbosityLevel = toArray(verbosityLevels?.[name]); + const items = verbosityLevel.map(verbosityLevel => { + const item: ts.QuickInfo & { verbosityLevel?: number; } | undefined = this.languageService.getQuickInfoAtPosition(marker.fileName, marker.position, verbosityLevel); + if (item) item.verbosityLevel = verbosityLevel; + return { + marker: { ...marker, name }, + item, + }; + }); + return items; + }).flat(); const annotations = this.annotateContentWithTooltips( result, "quickinfo", item => item.textSpan, - ({ displayParts, documentation, tags }) => [ + ({ displayParts, documentation, tags, verbosityLevel }) => [ ...(displayParts ? displayParts.map(p => p.text).join("").split("\n") : []), ...(documentation?.length ? documentation.map(p => p.text).join("").split("\n") : []), ...(tags?.length ? tags.map(p => `@${p.name} ${p.text?.map(dp => dp.text).join("") ?? ""}`).join("\n").split("\n") : []), + ...(verbosityLevel !== undefined ? [`(verbosity level: ${verbosityLevel})`] : []), ], ); this.baseline("QuickInfo", annotations + "\n\n" + stringify(result)); diff --git a/src/harness/fourslashInterfaceImpl.ts b/src/harness/fourslashInterfaceImpl.ts index ec23609de6db0..bb10cbf744a99 100644 --- a/src/harness/fourslashInterfaceImpl.ts +++ b/src/harness/fourslashInterfaceImpl.ts @@ -449,8 +449,8 @@ export class Verify extends VerifyNegatable { this.state.baselineGetEmitOutput(); } - public baselineQuickInfo(): void { - this.state.baselineQuickInfo(); + public baselineQuickInfo(verbosityLevels?: FourSlash.VerbosityLevels): void { + this.state.baselineQuickInfo(verbosityLevels); } public baselineSignatureHelp(): void { diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 5cce908761082..4683a1f300662 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2005,6 +2005,11 @@ export interface QuickInfoRequest extends FileLocationRequest { arguments: FileLocationRequestArgs; } +export interface QuickInfoRequestArgs extends FileLocationRequestArgs { + /** TODO */ + verbosityLevel?: number; +} + /** * Body of QuickInfoResponse. */ @@ -2044,6 +2049,11 @@ export interface QuickInfoResponseBody { * JSDoc tags associated with symbol. */ tags: JSDocTagInfo[]; + + /** + * TODO + */ + canIncreaseVerbosityLevel?: boolean; } /** diff --git a/src/server/session.ts b/src/server/session.ts index 006eb57d7af70..120f043e2e83c 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -2392,10 +2392,10 @@ export class Session implements EventSender { return languageService.isValidBraceCompletionAtPosition(file, position, args.openingBrace.charCodeAt(0)); } - private getQuickInfoWorker(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.QuickInfoResponseBody | QuickInfo | undefined { + private getQuickInfoWorker(args: protocol.QuickInfoRequestArgs, simplifiedResult: boolean): protocol.QuickInfoResponseBody | QuickInfo | undefined { const { file, project } = this.getFileAndProject(args); const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file)!; - const quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo)); + const quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo), args.verbosityLevel); if (!quickInfo) { return undefined; } @@ -2411,6 +2411,7 @@ export class Session implements EventSender { displayString, documentation: useDisplayParts ? this.mapDisplayParts(quickInfo.documentation, project) : displayPartsToString(quickInfo.documentation), tags: this.mapJSDocTagInfo(quickInfo.tags, project, useDisplayParts), + canIncreaseVerbosityLevel: quickInfo.canIncreaseVerbosityLevel, }; } else { diff --git a/src/services/services.ts b/src/services/services.ts index 7236f146ff1c7..fb5e9a0857929 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2274,7 +2274,7 @@ export function createLanguageService( return Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name, source }, host, preferences); } - function getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined { + function getQuickInfoAtPosition(fileName: string, position: number, verbosityLevel?: number): QuickInfo | undefined { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); @@ -2293,13 +2293,26 @@ export function createLanguageService( kind: ScriptElementKind.unknown, kindModifiers: ScriptElementKindModifier.none, textSpan: createTextSpanFromNode(nodeForQuickInfo, sourceFile), - displayParts: typeChecker.runWithCancellationToken(cancellationToken, typeChecker => typeToDisplayParts(typeChecker, type, getContainerNode(nodeForQuickInfo))), + displayParts: typeChecker.runWithCancellationToken(cancellationToken, typeChecker => typeToDisplayParts(typeChecker, type, getContainerNode(nodeForQuickInfo), /*flags*/ undefined, verbosityLevel)), documentation: type.symbol ? type.symbol.getDocumentationComment(typeChecker) : undefined, tags: type.symbol ? type.symbol.getJsDocTags(typeChecker) : undefined, }; } - const { symbolKind, displayParts, documentation, tags } = typeChecker.runWithCancellationToken(cancellationToken, typeChecker => SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, getContainerNode(nodeForQuickInfo), nodeForQuickInfo)); + const { symbolKind, displayParts, documentation, tags, canIncreaseVerbosityLevel } = typeChecker.runWithCancellationToken( + cancellationToken, + typeChecker => + SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind( + typeChecker, + symbol, + sourceFile, + getContainerNode(nodeForQuickInfo), + nodeForQuickInfo, + /*semanticMeaning*/ undefined, + /*alias*/ undefined, + verbosityLevel, + ), + ); return { kind: symbolKind, kindModifiers: SymbolDisplay.getSymbolModifiers(typeChecker, symbol), @@ -2307,6 +2320,7 @@ export function createLanguageService( displayParts, documentation, tags, + canIncreaseVerbosityLevel, }; } diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 6c49848435e70..0b6e220912921 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -108,6 +108,7 @@ import { TypeParameter, typeToDisplayParts, VariableDeclaration, + WriterContextOut, } from "./_namespaces/ts.js"; const symbolDisplayNodeBuilderFlags = NodeBuilderFlags.OmitParameterModifiers | NodeBuilderFlags.IgnoreErrors | NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope; @@ -254,9 +255,20 @@ export interface SymbolDisplayPartsDocumentationAndSymbolKind { documentation: SymbolDisplayPart[]; symbolKind: ScriptElementKind; tags: JSDocTagInfo[] | undefined; + canIncreaseVerbosityLevel?: boolean; } -function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: TypeChecker, symbol: Symbol, sourceFile: SourceFile, enclosingDeclaration: Node | undefined, location: Node, type: Type | undefined, semanticMeaning: SemanticMeaning, alias?: Symbol): SymbolDisplayPartsDocumentationAndSymbolKind { +function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( + typeChecker: TypeChecker, + symbol: Symbol, + sourceFile: SourceFile, + enclosingDeclaration: Node | undefined, + location: Node, + type: Type | undefined, + semanticMeaning: SemanticMeaning, + alias?: Symbol, + verbosityLevel?: number, +): SymbolDisplayPartsDocumentationAndSymbolKind { const displayParts: SymbolDisplayPart[] = []; let documentation: SymbolDisplayPart[] = []; let tags: JSDocTagInfo[] = []; @@ -267,6 +279,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type let documentationFromAlias: SymbolDisplayPart[] | undefined; let tagsFromAlias: JSDocTagInfo[] | undefined; let hasMultipleSignatures = false; + const typeWriterOut: WriterContextOut | undefined = verbosityLevel !== undefined ? { couldUnfoldMore: false } : undefined; if (location.kind === SyntaxKind.ThisKeyword && !isThisExpression) { return { displayParts: [keywordPart(SyntaxKind.ThisKeyword)], documentation: [], symbolKind: ScriptElementKind.primitiveType, tags: undefined }; @@ -462,7 +475,17 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type displayParts.push(spacePart()); displayParts.push(operatorPart(SyntaxKind.EqualsToken)); displayParts.push(spacePart()); - addRange(displayParts, typeToDisplayParts(typeChecker, location.parent && isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, TypeFormatFlags.InTypeAlias)); + addRange( + displayParts, + typeToDisplayParts( + typeChecker, + location.parent && isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), + enclosingDeclaration, + TypeFormatFlags.InTypeAlias, + verbosityLevel, + typeWriterOut, + ), + ); } if (symbolFlags & SymbolFlags.Enum) { prefixNextMeaning(); @@ -650,13 +673,30 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & SymbolFlags.TypeParameter && symbolKind !== ScriptElementKind.indexSignatureElement) { const typeParameterParts = mapToDisplayParts(writer => { - const param = typeChecker.typeParameterToDeclaration(type as TypeParameter, enclosingDeclaration, symbolDisplayNodeBuilderFlags)!; + const param = typeChecker.typeParameterToDeclaration( + type as TypeParameter, + enclosingDeclaration, + symbolDisplayNodeBuilderFlags, + /*internalFlags*/ undefined, + /*tracker*/ undefined, + verbosityLevel, + )!; getPrinter().writeNode(EmitHint.Unspecified, param, getSourceFileOfNode(getParseTreeNode(enclosingDeclaration)), writer); }); addRange(displayParts, typeParameterParts); } else { - addRange(displayParts, typeToDisplayParts(typeChecker, type, enclosingDeclaration)); + addRange( + displayParts, + typeToDisplayParts( + typeChecker, + type, + enclosingDeclaration, + /*flags*/ undefined, + verbosityLevel, + typeWriterOut, + ), + ); } if (isTransientSymbol(symbol) && symbol.links.target && isTransientSymbol(symbol.links.target) && symbol.links.target.links.tupleLabelDeclaration) { const labelDecl = symbol.links.target.links.tupleLabelDeclaration; @@ -742,7 +782,13 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type tags = tagsFromAlias; } - return { displayParts, documentation, symbolKind, tags: tags.length === 0 ? undefined : tags }; + return { + displayParts, + documentation, + symbolKind, + tags: tags.length === 0 ? undefined : tags, + canIncreaseVerbosityLevel: typeWriterOut?.couldUnfoldMore, + }; function getPrinter() { return createPrinterWithRemoveComments(); @@ -874,8 +920,9 @@ export function getSymbolDisplayPartsDocumentationAndSymbolKind( location: Node, semanticMeaning: SemanticMeaning = getMeaningFromLocation(location), alias?: Symbol, + verbosityLevel?: number, ): SymbolDisplayPartsDocumentationAndSymbolKind { - return getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, /*type*/ undefined, semanticMeaning, alias); + return getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, /*type*/ undefined, semanticMeaning, alias, verbosityLevel); } function isLocalVariableOrFunction(symbol: Symbol) { diff --git a/src/services/types.ts b/src/services/types.ts index 0811d858e6a6e..39c1636fefcd1 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -583,6 +583,8 @@ export interface LanguageService { * @param position A zero-based index of the character where you want the quick info */ getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined; + /** @internal */ + getQuickInfoAtPosition(fileName: string, position: number, verbosityLevel: number | undefined): QuickInfo | undefined; // eslint-disable-line @typescript-eslint/unified-signatures getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined; @@ -1324,6 +1326,7 @@ export interface QuickInfo { displayParts?: SymbolDisplayPart[]; documentation?: SymbolDisplayPart[]; tags?: JSDocTagInfo[]; + canIncreaseVerbosityLevel?: boolean; } export type RenameInfo = RenameInfoSuccess | RenameInfoFailure; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 83db802709fe3..0f7b99250111f 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -390,6 +390,7 @@ import { visitEachChild, VoidExpression, walkUpParenthesizedExpressions, + WriterContextOut, YieldExpression, } from "./_namespaces/ts.js"; @@ -3055,9 +3056,9 @@ export function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbol } /** @internal */ -export function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags: TypeFormatFlags = TypeFormatFlags.None): SymbolDisplayPart[] { +export function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags: TypeFormatFlags = TypeFormatFlags.None, verbosityLevel?: number, out?: WriterContextOut): SymbolDisplayPart[] { return mapToDisplayParts(writer => { - typechecker.writeType(type, enclosingDeclaration, flags | TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, writer); + typechecker.writeType(type, enclosingDeclaration, flags | TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, writer, verbosityLevel, out); }); } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 2531c9ea0413d..7de0463c6150e 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1486,6 +1486,10 @@ declare namespace ts { command: CommandTypes.Quickinfo; arguments: FileLocationRequestArgs; } + export interface QuickInfoRequestArgs extends FileLocationRequestArgs { + /** TODO */ + verbosityLevel?: number; + } /** * Body of QuickInfoResponse. */ @@ -1519,6 +1523,10 @@ declare namespace ts { * JSDoc tags associated with symbol. */ tags: JSDocTagInfo[]; + /** + * TODO + */ + canIncreaseVerbosityLevel?: boolean; } /** * Quickinfo response message. @@ -10757,6 +10765,7 @@ declare namespace ts { displayParts?: SymbolDisplayPart[]; documentation?: SymbolDisplayPart[]; tags?: JSDocTagInfo[]; + canIncreaseVerbosityLevel?: boolean; } type RenameInfo = RenameInfoSuccess | RenameInfoFailure; interface RenameInfoSuccess { diff --git a/tests/baselines/reference/quickinfoVerbosity1.baseline b/tests/baselines/reference/quickinfoVerbosity1.baseline new file mode 100644 index 0000000000000..e41255cd67c1a --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosity1.baseline @@ -0,0 +1,326 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosity1.ts === +// type FooType = string | number; +// const foo: FooType = 1; +// ^^^ +// | ---------------------------------------------------------------------- +// | const foo: string | number +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | const foo: FooType +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// type BarType = FooType | boolean; +// const bar: BarType = 1; +// ^^^ +// | ---------------------------------------------------------------------- +// | const bar: boolean | (string | number) +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | const bar: boolean | FooType +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | const bar: BarType +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosity1.ts", + "position": 41, + "name": "a" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 38, + "length": 3 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosity1.ts", + "position": 41, + "name": "a" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 38, + "length": 3 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosity1.ts", + "position": 99, + "name": "b" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 96, + "length": 3 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "BarType", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosity1.ts", + "position": 99, + "name": "b" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 96, + "length": 3 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosity1.ts", + "position": 99, + "name": "b" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 96, + "length": 3 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosity2.baseline b/tests/baselines/reference/quickinfoVerbosity2.baseline new file mode 100644 index 0000000000000..844d2f7663f34 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosity2.baseline @@ -0,0 +1,431 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosity2.ts === +// type Str = string | {}; +// type FooType = Str | number; +// type Sym = symbol | (() => void); +// type BarType = Sym | boolean; +// type BothType = FooType | BarType; +// const both: BothType = 1; +// ^^^^ +// | ---------------------------------------------------------------------- +// | const both: (number | (string | {})) | (boolean | (symbol | (() => void))) +// | (verbosity level: 3) +// | ---------------------------------------------------------------------- +// ^^^^ +// | ---------------------------------------------------------------------- +// | const both: (number | Str) | (boolean | Sym) +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^^ +// | ---------------------------------------------------------------------- +// | const both: FooType | BarType +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^ +// | ---------------------------------------------------------------------- +// | const both: BothType +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosity2.ts", + "position": 162, + "name": "b" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 158, + "length": 4 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "both", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "BothType", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosity2.ts", + "position": 162, + "name": "b" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 158, + "length": 4 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "both", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "BarType", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosity2.ts", + "position": 162, + "name": "b" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 158, + "length": 4 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "both", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Str", + "kind": "aliasName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Sym", + "kind": "aliasName" + }, + { + "text": ")", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosity2.ts", + "position": 162, + "name": "b" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 158, + "length": 4 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "both", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "symbol", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 3 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityClass1.baseline b/tests/baselines/reference/quickinfoVerbosityClass1.baseline new file mode 100644 index 0000000000000..cd101e72dbec8 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityClass1.baseline @@ -0,0 +1,1908 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityClass1.ts === +// { +// class Foo { +// a!: "a" | "c"; +// } +// const f = new Foo(); +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | a: "a" | "c"; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } +// { +// type FooParam = "a" | "b"; +// class Foo { +// constructor(public x: string) { +// this.x = "a"; +// } +// foo(p: FooParam): void {} +// } +// const f = new Foo(""); +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | x: string; +// | foo(p: "a" | "b"): void; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | x: string; +// | foo(p: FooParam): void; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } +// { +// class Bar { +// a!: string; +// bar(): void {} +// baz(param: string): void {} +// } +// class Foo extends Bar { +// b!: boolean; +// override baz(param: string | number): void {} +// } +// const f = new Foo(); +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | b: boolean; +// | baz(param: string | number): void; +// | a: string; +// | bar(): void; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } +// { +// class Bar { +// bar(param: B): void {} +// baz(): this { return this; } +// } +// class Foo extends Bar<"foo"> { +// foo(): this { return this; } +// } +// const b = new Bar(); +// ^ +// | ---------------------------------------------------------------------- +// | const b: { +// | bar(param: string): void; +// | baz(): Bar; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const b: { +// | bar(param: string): void; +// | baz(): Bar; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const b: Bar +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// const f = new Foo(); +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | foo(): Foo; +// | bar(param: "foo"): void; +// | baz(): Foo; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } +// { +// class Bar { +// bar(param: B): void {} +// baz(): this { return this; } +// } +// const noname = new (class extends Bar<"foo"> { +// ^^^^^^ +// | ---------------------------------------------------------------------- +// | const noname: { +// | foo(): (Anonymous class); +// | bar(param: "foo"): void; +// | baz(): (Anonymous class); +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^^ +// | ---------------------------------------------------------------------- +// | const noname: (Anonymous class) +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// foo(): this { return this; } +// })(); +// const klass = class extends Bar<"foo"> { +// foo(): this { return this; } +// }; +// const k = new klass(); +// ^ +// | ---------------------------------------------------------------------- +// | const k: { +// | foo(): klass; +// | bar(param: "foo"): void; +// | baz(): klass; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const k: klass +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 58, + "name": "f1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 57, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 58, + "name": "f1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 57, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 250, + "name": "f2" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 249, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 250, + "name": "f2" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 249, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "p", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooParam", + "kind": "aliasName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 250, + "name": "f2" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 249, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "p", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"b\"", + "kind": "stringLiteral" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 491, + "name": "f3" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 490, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 491, + "name": "f3" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 490, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "baz", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "param", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 706, + "name": "b1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 705, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 706, + "name": "b1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 705, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "param", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "baz", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 706, + "name": "b1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 705, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "param", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "baz", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 731, + "name": "f4" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 730, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 731, + "name": "f4" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 730, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "param", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "baz", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 873, + "name": "n1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 867, + "length": 6 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "noname", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(Anonymous class)", + "kind": "className" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 873, + "name": "n1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 867, + "length": 6 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "noname", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(Anonymous class)", + "kind": "className" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "param", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "baz", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(Anonymous class)", + "kind": "className" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 1055, + "name": "k1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 1054, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "k", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "klass", + "kind": "className" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 1055, + "name": "k1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 1054, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "k", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "klass", + "kind": "className" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "param", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"foo\"", + "kind": "stringLiteral" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "baz", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "klass", + "kind": "className" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityInterface1.baseline b/tests/baselines/reference/quickinfoVerbosityInterface1.baseline new file mode 100644 index 0000000000000..7d0b66bc6b396 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityInterface1.baseline @@ -0,0 +1,2383 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityInterface1.ts === +// { +// interface Foo { +// a: "a" | "c"; +// } +// const f: Foo = { a: "a" }; +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | a: "a" | "c"; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } +// { +// interface Bar { +// b: "b" | "d"; +// } +// interface Foo extends Bar { +// a: "a" | "c"; +// } +// const f: Foo = { a: "a", b: "b" }; +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | a: "a" | "c"; +// | b: "b" | "d"; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } +// { +// type BarParam = "b" | "d"; +// interface Bar { +// bar(b: BarParam): string; +// } +// type FooType = "a" | "c"; +// interface FooParam { +// param: FooType; +// } +// interface Foo extends Bar { +// a: FooType; +// foo: (a: FooParam) => number; +// } +// const f: Foo = { a: "a", bar: () => "b", foo: () => 1 }; +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | a: "a" | "c"; +// | foo: (a: { +// | param: "a" | "c"; +// | }) => number; +// | bar(b: "b" | "d"): string; +// | } +// | (verbosity level: 3) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | a: "a" | "c"; +// | foo: (a: { +// | param: FooType; +// | }) => number; +// | bar(b: "b" | "d"): string; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | a: FooType; +// | foo: (a: FooParam) => number; +// | bar(b: BarParam): string; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } +// { +// interface Bar { +// bar(b: B): string; +// } +// interface FooParam { +// param: "a" | "c"; +// } +// interface Foo extends Bar { +// a: "a" | "c"; +// foo: (a: FooParam) => number; +// } +// const f: Foo = { a: "a", bar: () => "b", foo: () => 1 }; +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | a: "a" | "c"; +// | foo: (a: { +// | param: "a" | "c"; +// | }) => number; +// | bar(b: { +// | param: "a" | "c"; +// | }): string; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | a: "a" | "c"; +// | foo: (a: FooParam) => number; +// | bar(b: FooParam): string; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// const b: Bar = { bar: () => "" }; +// ^ +// | ---------------------------------------------------------------------- +// | const b: { +// | bar(b: number): string; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const b: Bar +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } +// { +// interface Foo { +// a: A; +// } +// type Alias = Foo; +// const a: Alias = { a: "a" }; +// ^ +// | ---------------------------------------------------------------------- +// | const a: { +// | a: string; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const a: Foo +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const a: Alias +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } +// { +// interface Foo { +// a: "a"; +// } +// interface Foo { +// b: "b"; +// } +// const f: Foo = { a: "a", b: "b" }; +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | a: "a"; +// | b: "b"; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 61, + "name": "f1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 60, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 61, + "name": "f1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 60, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 204, + "name": "f2" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 203, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 204, + "name": "f2" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 203, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"b\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"d\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 519, + "name": "f3" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 518, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 519, + "name": "f3" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 518, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooParam", + "kind": "interfaceName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "b", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "BarParam", + "kind": "aliasName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 519, + "name": "f3" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 518, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "param", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "b", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"b\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"d\"", + "kind": "stringLiteral" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 519, + "name": "f3" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 518, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "param", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "b", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"b\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"d\"", + "kind": "stringLiteral" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 3 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 805, + "name": "f4" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 804, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 805, + "name": "f4" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 804, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooParam", + "kind": "interfaceName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "b", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooParam", + "kind": "interfaceName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 805, + "name": "f4" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 804, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "param", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "b", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "param", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 866, + "name": "b1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 865, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 866, + "name": "b1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 865, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "b", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 989, + "name": "a" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 988, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Alias", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 989, + "name": "a" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 988, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 989, + "name": "a" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 988, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 1110, + "name": "f5" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 1109, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface1.ts", + "position": 1110, + "name": "f5" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 1109, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"b\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityIntersection1.baseline b/tests/baselines/reference/quickinfoVerbosityIntersection1.baseline new file mode 100644 index 0000000000000..145792e628a26 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityIntersection1.baseline @@ -0,0 +1,357 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityIntersection1.ts === +// { +// type Foo = { a: "a" | "c" }; +// type Bar = { a: "a" | "b" }; +// const obj: Foo & Bar = { a: "a" }; +// ^^^ +// | ---------------------------------------------------------------------- +// | const obj: { +// | a: "a" | "c"; +// | } & { +// | a: "a" | "b"; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | const obj: Foo & Bar +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } +// { +// type Foo = { a: "c" }; +// type Bar = { a: "b" }; +// const obj: Foo & Bar = { a: "" }; +// ^^^ +// | ---------------------------------------------------------------------- +// | const obj: never +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } +// { +// type Foo = { a: "c" }; +// type Bar = { a: "b" }; +// type Never = Foo & Bar; +// const obj: Never = { a: "" }; +// ^^^ +// | ---------------------------------------------------------------------- +// | const obj: never +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIntersection1.ts", + "position": 81, + "name": "o1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 78, + "length": 3 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "obj", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "&", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIntersection1.ts", + "position": 81, + "name": "o1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 78, + "length": 3 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "obj", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "&", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"b\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIntersection1.ts", + "position": 178, + "name": "o2" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 175, + "length": 3 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "obj", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "never", + "kind": "keyword" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIntersection1.ts", + "position": 302, + "name": "o3" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 299, + "length": 3 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "obj", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "never", + "kind": "keyword" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 0 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityObjectType1.baseline b/tests/baselines/reference/quickinfoVerbosityObjectType1.baseline new file mode 100644 index 0000000000000..2a4091f720292 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityObjectType1.baseline @@ -0,0 +1,1299 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityObjectType1.ts === +// type Str = string | {}; +// type FooType = Str | number; +// type Sym = symbol | (() => void); +// type BarType = Sym | boolean; +// type Obj = { foo: FooType, bar: BarType, str: Str }; +// const obj1: Obj = { foo: 1, bar: true, str: "3"}; +// ^^^^ +// | ---------------------------------------------------------------------- +// | const obj1: { +// | foo: number | (string | {}); +// | bar: boolean | (symbol | (() => void)); +// | str: string | {}; +// | } +// | (verbosity level: 3) +// | ---------------------------------------------------------------------- +// ^^^^ +// | ---------------------------------------------------------------------- +// | const obj1: { +// | foo: number | Str; +// | bar: boolean | Sym; +// | str: string | {}; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^^ +// | ---------------------------------------------------------------------- +// | const obj1: { +// | foo: FooType; +// | bar: BarType; +// | str: Str; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^ +// | ---------------------------------------------------------------------- +// | const obj1: Obj +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// const obj2: { foo: FooType, bar: BarType, str: Str } = { foo: 1, bar: true, str: "3"}; +// ^^^^ +// | ---------------------------------------------------------------------- +// | const obj2: { +// | foo: number | (string | {}); +// | bar: boolean | (symbol | (() => void)); +// | str: string | {}; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^^ +// | ---------------------------------------------------------------------- +// | const obj2: { +// | foo: number | Str; +// | bar: boolean | Sym; +// | str: string | {}; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^ +// | ---------------------------------------------------------------------- +// | const obj2: { +// | foo: FooType; +// | bar: BarType; +// | str: Str; +// | } +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityObjectType1.ts", + "position": 180, + "name": "o1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 176, + "length": 4 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "obj1", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Obj", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityObjectType1.ts", + "position": 180, + "name": "o1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 176, + "length": 4 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "obj1", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "BarType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "str", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Str", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityObjectType1.ts", + "position": 180, + "name": "o1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 176, + "length": 4 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "obj1", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Str", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Sym", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "str", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityObjectType1.ts", + "position": 180, + "name": "o1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 176, + "length": 4 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "obj1", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "symbol", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "str", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 3 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityObjectType1.ts", + "position": 230, + "name": "o2" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 226, + "length": 4 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "obj2", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "BarType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "str", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Str", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityObjectType1.ts", + "position": 230, + "name": "o2" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 226, + "length": 4 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "obj2", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Str", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Sym", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "str", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityObjectType1.ts", + "position": 230, + "name": "o2" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 226, + "length": 4 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "obj2", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "symbol", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "str", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityServer.baseline b/tests/baselines/reference/quickinfoVerbosityServer.baseline new file mode 100644 index 0000000000000..6bce07cf78b76 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityServer.baseline @@ -0,0 +1,79 @@ +// === QuickInfo === +=== /tests/cases/fourslash/server/quickinfoVerbosityServer.ts === +// type FooType = string | number +// const foo: FooType = 1 +// ^^^ +// | ---------------------------------------------------------------------- +// | const foo: string | number +// | +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | const foo: FooType +// | +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/server/quickinfoVerbosityServer.ts", + "position": 40, + "name": "a" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 37, + "length": 3 + }, + "displayParts": [ + { + "kind": "text", + "text": "const foo: FooType" + } + ], + "documentation": [ + { + "kind": "text", + "text": "" + } + ], + "tags": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/server/quickinfoVerbosityServer.ts", + "position": 40, + "name": "a" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 37, + "length": 3 + }, + "displayParts": [ + { + "kind": "text", + "text": "const foo: string | number" + } + ], + "documentation": [ + { + "kind": "text", + "text": "" + } + ], + "tags": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityTruncation.baseline b/tests/baselines/reference/quickinfoVerbosityTruncation.baseline new file mode 100644 index 0000000000000..b65773e3c335d --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityTruncation.baseline @@ -0,0 +1,706 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityTruncation.ts === +// type Str = string | {}; +// type FooType = Str | number; +// type Sym = symbol | (() => void); +// type BarType = Sym | boolean; +// interface LotsOfProps { +// someLongPropertyName1: Str; +// someLongPropertyName2: FooType; +// someLongPropertyName3: Sym; +// someLongPropertyName4: BarType; +// someLongPropertyName5: Str; +// someLongPropertyName6: FooType; +// someLongPropertyName7: Sym; +// someLongPropertyName8: BarType; +// someLongMethodName1(a: FooType, b: BarType): Sym; +// someLongPropertyName9: Str; +// someLongPropertyName10: FooType; +// someLongPropertyName11: Sym; +// someLongPropertyName12: BarType; +// someLongPropertyName13: Str; +// someLongPropertyName14: FooType; +// someLongPropertyName15: Sym; +// someLongPropertyName16: BarType; +// someLongMethodName2(a: FooType, b: BarType): Sym; +// } +// const obj1: LotsOfProps = undefined as any as LotsOfProps; +// ^^^^ +// | ---------------------------------------------------------------------- +// | const obj1: { +// | someLongPropertyName1: Str; +// | someLongPropertyName2: FooType; +// | someLongPropertyName3: Sym; +// | someLongPropertyName4: BarType; +// | someLongPropertyName5: Str; +// | someLongPropertyName6: FooType; +// | someLongPropertyName7: Sym; +// | someLongPropertyName8: BarType; +// | someLongMethodName1(a: FooType, b: BarType): Sym; +// | someLongPropertyName9: Str; +// | someLongPropertyName10: FooType; +// | someLongPropertyName11: Sym; +// | someLongPropertyName12: BarType; +// | someLongPropertyName13: Str; +// | someLongPropertyName14: FooType; +// | someLongPropertyName15: Sym; +// | someLongPropertyName16: BarType; +// | someLongMethodName2(a: FooType, b: BarType): Sym; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTruncation.ts", + "position": 812, + "name": "o1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 808, + "length": 4 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "obj1", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName1", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Str", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName2", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName3", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Sym", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName4", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "BarType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName5", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Str", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName6", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName7", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Sym", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName8", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "BarType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongMethodName1", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "BarType", + "kind": "aliasName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Sym", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName9", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Str", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName10", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName11", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Sym", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName12", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "BarType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName13", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Str", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName14", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName15", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Sym", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongPropertyName16", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "BarType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someLongMethodName2", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "BarType", + "kind": "aliasName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Sym", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/tsserver/fourslashServer/quickinfoVerbosityServer.js b/tests/baselines/reference/tsserver/fourslashServer/quickinfoVerbosityServer.js new file mode 100644 index 0000000000000..7e9762e4fd5f3 --- /dev/null +++ b/tests/baselines/reference/tsserver/fourslashServer/quickinfoVerbosityServer.js @@ -0,0 +1,199 @@ +Info seq [hh:mm:ss:mss] currentDirectory:: /home/src/Vscode/Projects/bin useCaseSensitiveFileNames:: false +Info seq [hh:mm:ss:mss] libs Location:: /home/src/tslibs/TS/Lib +Info seq [hh:mm:ss:mss] globalTypingsCacheLocation:: /home/src/Library/Caches/typescript +Info seq [hh:mm:ss:mss] Provided types map file "/home/src/tslibs/TS/Lib/typesMap.json" doesn't exist +//// [/home/src/tslibs/TS/Lib/lib.d.ts] +lib.d.ts-Text + +//// [/home/src/tslibs/TS/Lib/lib.decorators.d.ts] +lib.decorators.d.ts-Text + +//// [/home/src/tslibs/TS/Lib/lib.decorators.legacy.d.ts] +lib.decorators.legacy.d.ts-Text + +//// [/tests/cases/fourslash/server/quickinfoVerbosityServer.ts] +type FooType = string | number +const foo: FooType = 1 + + +Info seq [hh:mm:ss:mss] request: + { + "seq": 0, + "type": "request", + "arguments": { + "file": "/tests/cases/fourslash/server/quickinfoVerbosityServer.ts" + }, + "command": "open" + } +Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /tests/cases/fourslash/server/quickinfoVerbosityServer.ts ProjectRootPath: undefined:: Result: undefined +Info seq [hh:mm:ss:mss] Creating InferredProject: /dev/null/inferredProject1*, currentDirectory: /tests/cases/fourslash/server +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /tests/cases/fourslash/server/tsconfig.json 2000 undefined WatchType: Config file for the inferred project root +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /tests/cases/fourslash/server/jsconfig.json 2000 undefined WatchType: Config file for the inferred project root +Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /dev/null/inferredProject1* +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/tslibs/TS/Lib/lib.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /tests/cases/fourslash/server/node_modules 1 undefined Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /tests/cases/fourslash/server/node_modules 1 undefined Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /tests/cases/fourslash/node_modules 1 undefined Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /tests/cases/fourslash/node_modules 1 undefined Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/tslibs/TS/Lib/lib.decorators.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /home/src/tslibs/TS/Lib/lib.decorators.legacy.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /tests/cases/fourslash/server/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /tests/cases/fourslash/server/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots +Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /tests/cases/fourslash/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots +Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /tests/cases/fourslash/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots +Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info seq [hh:mm:ss:mss] Project '/dev/null/inferredProject1*' (Inferred) +Info seq [hh:mm:ss:mss] Files (4) + /home/src/tslibs/TS/Lib/lib.d.ts Text-1 lib.d.ts-Text + /home/src/tslibs/TS/Lib/lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text + /home/src/tslibs/TS/Lib/lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text + /tests/cases/fourslash/server/quickinfoVerbosityServer.ts SVC-1-0 "type FooType = string | number\nconst foo: FooType = 1" + + + ../../../../home/src/tslibs/TS/Lib/lib.d.ts + Default library for target 'es5' + ../../../../home/src/tslibs/TS/Lib/lib.decorators.d.ts + Library referenced via 'decorators' from file '../../../../home/src/tslibs/TS/Lib/lib.d.ts' + ../../../../home/src/tslibs/TS/Lib/lib.decorators.legacy.d.ts + Library referenced via 'decorators.legacy' from file '../../../../home/src/tslibs/TS/Lib/lib.d.ts' + quickinfoVerbosityServer.ts + Root file specified for compilation + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Project '/dev/null/inferredProject1*' (Inferred) +Info seq [hh:mm:ss:mss] Files (4) + +Info seq [hh:mm:ss:mss] ----------------------------------------------- +Info seq [hh:mm:ss:mss] Open files: +Info seq [hh:mm:ss:mss] FileName: /tests/cases/fourslash/server/quickinfoVerbosityServer.ts ProjectRootPath: undefined +Info seq [hh:mm:ss:mss] Projects: /dev/null/inferredProject1* +Info seq [hh:mm:ss:mss] response: + { + "seq": 0, + "type": "response", + "command": "open", + "request_seq": 0, + "success": true, + "performanceData": { + "updateGraphDurationMs": * + } + } +After Request +watchedFiles:: +/home/src/tslibs/TS/Lib/lib.d.ts: *new* + {"pollingInterval":500} +/home/src/tslibs/TS/Lib/lib.decorators.d.ts: *new* + {"pollingInterval":500} +/home/src/tslibs/TS/Lib/lib.decorators.legacy.d.ts: *new* + {"pollingInterval":500} +/tests/cases/fourslash/server/jsconfig.json: *new* + {"pollingInterval":2000} +/tests/cases/fourslash/server/tsconfig.json: *new* + {"pollingInterval":2000} + +watchedDirectoriesRecursive:: +/tests/cases/fourslash/node_modules: *new* + {} +/tests/cases/fourslash/node_modules/@types: *new* + {} +/tests/cases/fourslash/server/node_modules: *new* + {} +/tests/cases/fourslash/server/node_modules/@types: *new* + {} + +Projects:: +/dev/null/inferredProject1* (Inferred) *new* + projectStateVersion: 1 + projectProgramVersion: 1 + autoImportProviderHost: false + +ScriptInfos:: +/home/src/tslibs/TS/Lib/lib.d.ts *new* + version: Text-1 + containingProjects: 1 + /dev/null/inferredProject1* +/home/src/tslibs/TS/Lib/lib.decorators.d.ts *new* + version: Text-1 + containingProjects: 1 + /dev/null/inferredProject1* +/home/src/tslibs/TS/Lib/lib.decorators.legacy.d.ts *new* + version: Text-1 + containingProjects: 1 + /dev/null/inferredProject1* +/tests/cases/fourslash/server/quickinfoVerbosityServer.ts (Open) *new* + version: SVC-1-0 + containingProjects: 1 + /dev/null/inferredProject1* *default* + +Info seq [hh:mm:ss:mss] request: + { + "seq": 1, + "type": "request", + "arguments": { + "file": "/tests/cases/fourslash/server/quickinfoVerbosityServer.ts", + "line": 2, + "offset": 10, + "verbosityLevel": 0 + }, + "command": "quickinfo" + } +Info seq [hh:mm:ss:mss] response: + { + "seq": 0, + "type": "response", + "command": "quickinfo", + "request_seq": 1, + "success": true, + "body": { + "kind": "const", + "kindModifiers": "", + "start": { + "line": 2, + "offset": 7 + }, + "end": { + "line": 2, + "offset": 10 + }, + "displayString": "const foo: FooType", + "documentation": "", + "tags": [], + "canIncreaseVerbosityLevel": true + } + } +Info seq [hh:mm:ss:mss] request: + { + "seq": 2, + "type": "request", + "arguments": { + "file": "/tests/cases/fourslash/server/quickinfoVerbosityServer.ts", + "line": 2, + "offset": 10, + "verbosityLevel": 1 + }, + "command": "quickinfo" + } +Info seq [hh:mm:ss:mss] response: + { + "seq": 0, + "type": "response", + "command": "quickinfo", + "request_seq": 2, + "success": true, + "body": { + "kind": "const", + "kindModifiers": "", + "start": { + "line": 2, + "offset": 7 + }, + "end": { + "line": 2, + "offset": 10 + }, + "displayString": "const foo: string | number", + "documentation": "", + "tags": [], + "canIncreaseVerbosityLevel": false + } + } \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 8be19c1cdf649..3b07ac5a4981b 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -361,7 +361,7 @@ declare namespace FourSlashInterface { baselineSyntacticAndSemanticDiagnostics(): void; getEmitOutput(expectedOutputFiles: ReadonlyArray): void; baselineCompletions(preferences?: UserPreferences): void; - baselineQuickInfo(): void; + baselineQuickInfo(verbosityLevels?: VerbosityLevels): void; baselineSmartSelection(): void; baselineSignatureHelp(): void; nameOrDottedNameSpanTextIs(text: string): void; @@ -701,6 +701,9 @@ declare namespace FourSlashInterface { readonly organizeImportsCaseFirst?: "upper" | "lower" | false; readonly organizeImportsTypeOrder?: "first" | "last" | "inline"; } + interface VerbosityLevels { + [markerName: string]: number | number[] | undefined; + } interface InlayHintsOptions extends UserPreferences { readonly includeInlayParameterNameHints?: "none" | "literals" | "all"; readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean; diff --git a/tests/cases/fourslash/quickinfoVerbosity1.ts b/tests/cases/fourslash/quickinfoVerbosity1.ts new file mode 100644 index 0000000000000..6d95aa6dbd8a9 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosity1.ts @@ -0,0 +1,10 @@ +/// + +//// type FooType = string | number; +//// const foo/*a*/: FooType = 1; + +//// type BarType = FooType | boolean; +//// const bar/*b*/: BarType = 1; + + +verify.baselineQuickInfo({ "a": [0, 1], "b": [0, 1, 2] }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosity2.ts b/tests/cases/fourslash/quickinfoVerbosity2.ts new file mode 100644 index 0000000000000..7f61912b97e5d --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosity2.ts @@ -0,0 +1,11 @@ +/// + +//// type Str = string | {}; +//// type FooType = Str | number; +//// type Sym = symbol | (() => void); +//// type BarType = Sym | boolean; +//// type BothType = FooType | BarType; +//// const both/*b*/: BothType = 1; + + +verify.baselineQuickInfo({ "b": [0, 1, 2, 3], }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityClass1.ts b/tests/cases/fourslash/quickinfoVerbosityClass1.ts new file mode 100644 index 0000000000000..fd63a56939dec --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityClass1.ts @@ -0,0 +1,71 @@ +/// + + +// simple case +//// { +//// class Foo { +//// a!: "a" | "c"; +//// } +//// const f/*f1*/ = new Foo(); +//// } +// constructor +//// { +//// type FooParam = "a" | "b"; +//// class Foo { +//// constructor(public x: string) { +//// this.x = "a"; +//// } +//// foo(p: FooParam): void {} +//// } +//// const f/*f2*/ = new Foo(""); +//// } +// inheritance +//// { +//// class Bar { +//// a!: string; +//// bar(): void {} +//// baz(param: string): void {} +//// } +//// class Foo extends Bar { +//// b!: boolean; +//// override baz(param: string | number): void {} +//// } +//// const f/*f3*/ = new Foo(); +//// } +// type parameters +//// { +//// class Bar { +//// bar(param: B): void {} +//// baz(): this { return this; } +//// } +//// class Foo extends Bar<"foo"> { +//// foo(): this { return this; } +//// } +//// const b/*b1*/ = new Bar(); +//// const f/*f4*/ = new Foo(); +//// } +// class expression +//// { +//// class Bar { +//// bar(param: B): void {} +//// baz(): this { return this; } +//// } +//// const noname/*n1*/ = new (class extends Bar<"foo"> { +//// foo(): this { return this; } +//// })(); +//// const klass = class extends Bar<"foo"> { +//// foo(): this { return this; } +//// }; +//// const k/*k1*/ = new klass(); +//// } + + +verify.baselineQuickInfo({ + f1: [0, 1], + f2: [0, 1, 2], + f3: [0, 1], + b1: [0, 1, 2], + f4: [0, 1], + n1: [0, 1], + k1: [0, 1], +}); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityInterface1.ts b/tests/cases/fourslash/quickinfoVerbosityInterface1.ts new file mode 100644 index 0000000000000..c0898b6fc25c6 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityInterface1.ts @@ -0,0 +1,79 @@ +/// + +// simple case +//// { +//// interface Foo { +//// a: "a" | "c"; +//// } +//// const f/*f1*/: Foo = { a: "a" }; +//// } +// extends +//// { +//// interface Bar { +//// b: "b" | "d"; +//// } +//// interface Foo extends Bar { +//// a: "a" | "c"; +//// } +//// const f/*f2*/: Foo = { a: "a", b: "b" }; +//// } +// methods +//// { +//// type BarParam = "b" | "d"; +//// interface Bar { +//// bar(b: BarParam): string; +//// } +//// type FooType = "a" | "c"; +//// interface FooParam { +//// param: FooType; +//// } +//// interface Foo extends Bar { +//// a: FooType; +//// foo: (a: FooParam) => number; +//// } +//// const f/*f3*/: Foo = { a: "a", bar: () => "b", foo: () => 1 }; +//// } +// type parameters +//// { +//// interface Bar { +//// bar(b: B): string; +//// } +//// interface FooParam { +//// param: "a" | "c"; +//// } +//// interface Foo extends Bar { +//// a: "a" | "c"; +//// foo: (a: FooParam) => number; +//// } +//// const f/*f4*/: Foo = { a: "a", bar: () => "b", foo: () => 1 }; +//// const b/*b1*/: Bar = { bar: () => "" }; +//// } +// alias + interface +//// { +//// interface Foo { +//// a: A; +//// } +//// type Alias = Foo; +//// const a/*a*/: Alias = { a: "a" }; +//// } +// decl merging +//// { +//// interface Foo { +//// a: "a"; +//// } +//// interface Foo { +//// b: "b"; +//// } +//// const f/*f5*/: Foo = { a: "a", b: "b" }; +//// } + + +verify.baselineQuickInfo({ + f1: [0, 1], + f2: [0, 1], + f3: [0, 1, 2, 3], + f4: [0, 1, 2], + b1: [0, 1], + a: [0, 1, 2], + f5: [0, 1], +}); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityIntersection1.ts b/tests/cases/fourslash/quickinfoVerbosityIntersection1.ts new file mode 100644 index 0000000000000..521e624880750 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityIntersection1.ts @@ -0,0 +1,22 @@ +/// + + + +//// { +//// type Foo = { a: "a" | "c" }; +//// type Bar = { a: "a" | "b" }; +//// const obj/*o1*/: Foo & Bar = { a: "a" }; +//// } +//// { +//// type Foo = { a: "c" }; +//// type Bar = { a: "b" }; +//// const obj/*o2*/: Foo & Bar = { a: "" }; +//// } +//// { +//// type Foo = { a: "c" }; +//// type Bar = { a: "b" }; +//// type Never = Foo & Bar; +//// const obj/*o3*/: Never = { a: "" }; +//// } + +verify.baselineQuickInfo({ "o1": [0, 1], "o2": 0, "o3": 0 }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityObjectType1.ts b/tests/cases/fourslash/quickinfoVerbosityObjectType1.ts new file mode 100644 index 0000000000000..d255f61622014 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityObjectType1.ts @@ -0,0 +1,13 @@ +/// + + +//// type Str = string | {}; +//// type FooType = Str | number; +//// type Sym = symbol | (() => void); +//// type BarType = Sym | boolean; +//// type Obj = { foo: FooType, bar: BarType, str: Str }; +//// const obj1/*o1*/: Obj = { foo: 1, bar: true, str: "3"}; +//// const obj2/*o2*/: { foo: FooType, bar: BarType, str: Str } = { foo: 1, bar: true, str: "3"}; + + +verify.baselineQuickInfo({ "o1": [0, 1, 2, 3], "o2": [0, 1, 2] }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityTruncation.ts b/tests/cases/fourslash/quickinfoVerbosityTruncation.ts new file mode 100644 index 0000000000000..b321761950d92 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityTruncation.ts @@ -0,0 +1,31 @@ +/// + +//// type Str = string | {}; +//// type FooType = Str | number; +//// type Sym = symbol | (() => void); +//// type BarType = Sym | boolean; + +//// interface LotsOfProps { +//// someLongPropertyName1: Str; +//// someLongPropertyName2: FooType; +//// someLongPropertyName3: Sym; +//// someLongPropertyName4: BarType; +//// someLongPropertyName5: Str; +//// someLongPropertyName6: FooType; +//// someLongPropertyName7: Sym; +//// someLongPropertyName8: BarType; +//// someLongMethodName1(a: FooType, b: BarType): Sym; +//// someLongPropertyName9: Str; +//// someLongPropertyName10: FooType; +//// someLongPropertyName11: Sym; +//// someLongPropertyName12: BarType; +//// someLongPropertyName13: Str; +//// someLongPropertyName14: FooType; +//// someLongPropertyName15: Sym; +//// someLongPropertyName16: BarType; +//// someLongMethodName2(a: FooType, b: BarType): Sym; +//// } +//// const obj1/*o1*/: LotsOfProps = undefined as any as LotsOfProps; + + +verify.baselineQuickInfo({ "o1": [1], }); \ No newline at end of file diff --git a/tests/cases/fourslash/server/quickinfoVerbosityServer.ts b/tests/cases/fourslash/server/quickinfoVerbosityServer.ts new file mode 100644 index 0000000000000..9fc9eeb7082e1 --- /dev/null +++ b/tests/cases/fourslash/server/quickinfoVerbosityServer.ts @@ -0,0 +1,6 @@ +/// + +//// type FooType = string | number +//// const foo/*a*/: FooType = 1 + +verify.baselineQuickInfo({ "a": [0, 1] }); \ No newline at end of file From 92c49e61b5d582aa95acb308d9218118ff7b01ab Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Thu, 13 Mar 2025 16:44:46 -0700 Subject: [PATCH 02/31] WIP: support more cases --- src/compiler/checker.ts | 57 +- src/compiler/types.ts | 6 +- src/services/symbolDisplay.ts | 78 +- src/services/utilities.ts | 4 +- .../reference/quickinfoVerbosity3.baseline | 624 +++++++++ ...quickinfoVerbosityConditionalType.baseline | 385 ++++++ .../reference/quickinfoVerbosityEnum.baseline | 285 ++++ .../quickinfoVerbosityFunction.baseline | 941 +++++++++++++ .../quickinfoVerbosityImport.baseline | 1212 +++++++++++++++++ .../quickinfoVerbosityIndexSignature.baseline | 588 ++++++++ .../quickinfoVerbosityIndexType.baseline | 584 ++++++++ ...ickinfoVerbosityIndexedAccessType.baseline | 405 ++++++ .../quickinfoVerbosityLibType.baseline | 456 +++++++ .../quickinfoVerbosityMappedType.baseline | 1080 +++++++++++++++ .../quickinfoVerbosityTypeParameter.baseline | 689 ++++++++++ .../quickinfoVerbosityTypeof.baseline | 384 ++++++ tests/cases/fourslash/quickinfoVerbosity3.ts | 42 + .../quickinfoVerbosityConditionalType.ts | 13 + .../cases/fourslash/quickinfoVerbosityEnum.ts | 11 + .../fourslash/quickinfoVerbosityFunction.ts | 22 + .../fourslash/quickinfoVerbosityImport.ts | 28 + .../quickinfoVerbosityIndexSignature.ts | 13 + .../fourslash/quickinfoVerbosityIndexType.ts | 20 + .../quickinfoVerbosityIndexedAccessType.ts | 20 + .../fourslash/quickinfoVerbosityLibType.ts | 15 + .../fourslash/quickinfoVerbosityMappedType.ts | 20 + .../quickinfoVerbosityTypeParameter.ts | 11 + .../fourslash/quickinfoVerbosityTypeof.ts | 23 + 28 files changed, 7982 insertions(+), 34 deletions(-) create mode 100644 tests/baselines/reference/quickinfoVerbosity3.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityConditionalType.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityEnum.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityFunction.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityImport.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityIndexSignature.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityIndexType.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityIndexedAccessType.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityLibType.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityMappedType.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityTypeParameter.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityTypeof.baseline create mode 100644 tests/cases/fourslash/quickinfoVerbosity3.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityConditionalType.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityEnum.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityFunction.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityImport.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityIndexSignature.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityIndexType.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityIndexedAccessType.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityLibType.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityMappedType.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityTypeof.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2ff3708e03128..f74a6bf6b9be1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1717,8 +1717,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { typePredicateToString: (predicate, enclosingDeclaration, flags) => { return typePredicateToString(predicate, getParseTreeNode(enclosingDeclaration), flags); }, - writeSignature: (signature, enclosingDeclaration, flags, kind, writer) => { - return signatureToString(signature, getParseTreeNode(enclosingDeclaration), flags, kind, writer); + writeSignature: (signature, enclosingDeclaration, flags, kind, writer, verbosityLevel, out) => { + return signatureToString(signature, getParseTreeNode(enclosingDeclaration), flags, kind, writer, verbosityLevel, out); }, writeType: (type, enclosingDeclaration, flags, writer, verbosityLevel, out) => { return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer, verbosityLevel, out); @@ -6028,7 +6028,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function signatureToString(signature: Signature, enclosingDeclaration?: Node, flags = TypeFormatFlags.None, kind?: SignatureKind, writer?: EmitTextWriter): string { + function signatureToString(signature: Signature, enclosingDeclaration?: Node, flags = TypeFormatFlags.None, kind?: SignatureKind, writer?: EmitTextWriter, verbosityLevel?: number, out?: WriterContextOut): string { return writer ? signatureToStringWorker(writer).getText() : usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer: EmitTextWriter) { @@ -6039,7 +6039,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { else { sigOutput = kind === SignatureKind.Construct ? SyntaxKind.ConstructSignature : SyntaxKind.CallSignature; } - const sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors | NodeBuilderFlags.WriteTypeParametersInQualifiedName); + const sig = nodeBuilder.signatureToSignatureDeclaration( + signature, + sigOutput, + enclosingDeclaration, + toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors | NodeBuilderFlags.WriteTypeParametersInQualifiedName, + /*internalFlags*/ undefined, + /*tracker*/ undefined, + verbosityLevel, + out); const printer = createPrinterWithRemoveCommentsOmitTrailingSemicolon(); const sourceFile = enclosingDeclaration && getSourceFileOfNode(enclosingDeclaration); printer.writeNode(EmitHint.Unspecified, sig!, /*sourceFile*/ sourceFile, getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 @@ -6284,18 +6292,18 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { }; return { syntacticBuilderResolver, - typeToTypeNode: (type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number, out?: { couldUnfoldMore: boolean; }) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, context => typeToTypeNodeHelper(type, context), out), + typeToTypeNode: (type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number, out?: WriterContextOut) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, context => typeToTypeNodeHelper(type, context), out), typePredicateToTypePredicateNode: (typePredicate: TypePredicate, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => typePredicateToTypePredicateNodeHelper(typePredicate, context)), serializeTypeForDeclaration: (declaration: HasInferredType, symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)), serializeReturnTypeForSignature: (signature: SignatureDeclaration, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)), serializeTypeForExpression: (expr: Expression, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)), indexInfoToIndexSignatureDeclaration: (indexInfo: IndexInfo, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => indexInfoToIndexSignatureDeclarationHelper(indexInfo, context, /*typeNode*/ undefined)), - signatureToSignatureDeclaration: (signature: Signature, kind: SignatureDeclaration["kind"], enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => signatureToSignatureDeclarationHelper(signature, kind, context)), + signatureToSignatureDeclaration: (signature: Signature, kind: SignatureDeclaration["kind"], enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number, out?: WriterContextOut) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, context => signatureToSignatureDeclarationHelper(signature, kind, context), out), symbolToEntityName: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false)), symbolToExpression: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolToExpression(symbol, context, meaning)), symbolToTypeParameterDeclarations: (symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => typeParametersToTypeParameterDeclarations(symbol, context)), symbolToParameterDeclaration: (symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolToParameterDeclaration(symbol, context)), - typeParameterToDeclaration: (parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, context => typeParameterToDeclaration(parameter, context)), + typeParameterToDeclaration: (parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number, out?: WriterContextOut) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, context => typeParameterToDeclaration(parameter, context), out), symbolTableToDeclarationStatements: (symbolTable: SymbolTable, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolTableToDeclarationStatements(symbolTable, context)), symbolToNode: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolToNode(symbol, context, meaning)), }; @@ -6399,6 +6407,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { enclosingSymbolTypes: new Map(), mapper: undefined, depth: 0, + typeStack: [], couldUnfoldMore: false, }; context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost); @@ -6446,16 +6455,20 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function couldUnfoldType(type: Type, context: NodeBuilderContext): boolean { - if (context.visitedTypes?.has(type.id)) { - return false; + for (let i = 0; i < context.typeStack.length - 1; i++) { + if (context.typeStack[i] === type.id) { + return false; + } } return context.depth < context.unfoldDepth || context.depth === context.unfoldDepth && !context.couldUnfoldMore; } // Determines if a type can be unfolded, based on how many layers of type aliases we're allowed to unfold. function canUnfoldType(type: Type, context: NodeBuilderContext): boolean { - if (context.visitedTypes?.has(type.id)) { - return false; + for (let i = 0; i < context.typeStack.length - 1; i++) { + if (context.typeStack[i] === type.id) { + return false; + } } const result = context.depth < context.unfoldDepth; if (!result) { @@ -6464,9 +6477,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return result; } + // Don't unfold types like `Array` or `Promise`, instead treating them as transparent. + function isUnfoldableType(type: Type): boolean { + return (getObjectFlags(type) & ObjectFlags.Reference) !== 0 && + !!((type as TypeReference).target.symbol?.declarations?.some(decl => host.isSourceFileDefaultLibrary(getSourceFileOfNode(decl)))); + } + function typeToTypeNodeHelper(type: Type, context: NodeBuilderContext): TypeNode { const restoreFlags = saveRestoreFlags(context); + type && context.typeStack.push(type.id); const typeNode = typeToTypeNodeWorker(type, context); + type && context.typeStack.pop(); restoreFlags(); return typeNode; } @@ -6628,7 +6649,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (objectFlags & ObjectFlags.Reference) { Debug.assert(!!(type.flags & TypeFlags.Object)); - if (canUnfoldType(type, context)) { + if (!isUnfoldableType(type) && canUnfoldType(type, context)) { context.depth += 1; return createAnonymousTypeNode(type as TypeReference, /*forceClassExpansion*/ true); } @@ -6915,9 +6936,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { || symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || shouldWriteTypeOfFunctionSymbol() ) { - return symbolToTypeNode(symbol, context, isInstanceType); + if (canUnfoldType(type, context)) { + context.depth += 1; + } + else { + return symbolToTypeNode(symbol, context, isInstanceType); + } } - else if (context.visitedTypes?.has(typeId)) { + if (context.visitedTypes?.has(typeId)) { // If type is an anonymous type literal in a type alias declaration, use type alias name const typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { @@ -8782,7 +8808,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const returnType = getReturnTypeOfSignature(signature); if (!(suppressAny && isTypeAny(returnType))) { - if (signature.declaration && !nodeIsSynthesized(signature.declaration)) { + if (signature.declaration && !nodeIsSynthesized(signature.declaration) && !couldUnfoldType(returnType, context)) { const declarationSymbol = getSymbolOfDeclaration(signature.declaration); const restore = addSymbolTypeToContext(context, declarationSymbol, returnType); returnTypeNode = syntacticNodeBuilder.serializeReturnTypeForSignature(signature.declaration, declarationSymbol, context); @@ -53001,6 +53027,7 @@ interface NodeBuilderContext extends SyntacticTypeNodeBuilderContext { mapper: TypeMapper | undefined; depth: number; // How many levels of nested type aliases we have unfolded so far suppressReportInferenceFallback: boolean; + typeStack: number[]; // Output couldUnfoldMore: boolean; // Whether we found a type alias that we could unfold but didn't diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9cd1a9b9fc618..e9daaaf4b9cd3 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5046,6 +5046,8 @@ export interface TypeCheckerHost extends ModuleSpecifierResolutionHost, SourceFi typesPackageExists(packageName: string): boolean; packageBundlesTypes(packageName: string): boolean; + + isSourceFileDefaultLibrary(file: SourceFile): boolean; } /** @internal */ @@ -5139,7 +5141,7 @@ export interface TypeChecker { symbolToParameterDeclaration(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): ParameterDeclaration | undefined; /** Note that the resulting nodes cannot be checked. */ typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeParameterDeclaration | undefined; - /** @internal */ typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number): TypeParameterDeclaration | undefined; // eslint-disable-line @typescript-eslint/unified-signatures + /** @internal */ typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number, out?: WriterContextOut): TypeParameterDeclaration | undefined; // eslint-disable-line @typescript-eslint/unified-signatures getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol | undefined; @@ -5171,7 +5173,7 @@ export interface TypeChecker { symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): string; typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; - /** @internal */ writeSignature(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind, writer?: EmitTextWriter): string; + /** @internal */ writeSignature(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind, writer?: EmitTextWriter, verbosityLevel?: number, out?: WriterContextOut): string; /** @internal */ writeType(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter, verbosityLevel?: number, out?: WriterContextOut): string; /** @internal */ writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags, writer?: EmitTextWriter): string; /** @internal */ writeTypePredicate(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string; diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 0b6e220912921..f04675fb5b58a 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -436,7 +436,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( ); } if (signature) { - addSignatureDisplayParts(signature, allSignatures); + addSignatureDisplayParts(signature, allSignatures, /*flags*/ TypeFormatFlags.None); } hasAddedSymbolInfo = true; hasMultipleSignatures = allSignatures.length > 1; @@ -456,22 +456,19 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( displayParts.push(keywordPart(SyntaxKind.ClassKeyword)); } displayParts.push(spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); + addFullSymbolName(symbol, /*enclosingDeclaration*/ undefined, /*writeTypeParameters*/ true); } if ((symbolFlags & SymbolFlags.Interface) && (semanticMeaning & SemanticMeaning.Type)) { prefixNextMeaning(); displayParts.push(keywordPart(SyntaxKind.InterfaceKeyword)); displayParts.push(spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); + addFullSymbolName(symbol, /*enclosingDeclaration*/ undefined, /*writeTypeParameters*/ true); } if ((symbolFlags & SymbolFlags.TypeAlias) && (semanticMeaning & SemanticMeaning.Type)) { prefixNextMeaning(); displayParts.push(keywordPart(SyntaxKind.TypeKeyword)); displayParts.push(spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); + addFullSymbolName(symbol, /*enclosingDeclaration*/ undefined, /*writeTypeParameters*/ true); displayParts.push(spacePart()); displayParts.push(operatorPart(SyntaxKind.EqualsToken)); displayParts.push(spacePart()); @@ -495,7 +492,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( } displayParts.push(keywordPart(SyntaxKind.EnumKeyword)); displayParts.push(spacePart()); - addFullSymbolName(symbol); + addFullSymbolName(symbol, /*enclosingDeclaration*/ undefined); } if (symbolFlags & SymbolFlags.Module && !isThisExpression) { prefixNextMeaning(); @@ -515,7 +512,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( if (symbol.parent) { // Class/Interface type parameter addInPrefix(); - addFullSymbolName(symbol.parent, enclosingDeclaration); + addFullSymbolName(symbol.parent, enclosingDeclaration); // >> TODO: review this case writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { @@ -544,8 +541,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( addInPrefix(); displayParts.push(keywordPart(SyntaxKind.TypeKeyword)); displayParts.push(spacePart()); - addFullSymbolName(declaration.symbol); - writeTypeParametersOfSymbol(declaration.symbol, sourceFile); + addFullSymbolName(declaration.symbol, /*enclosingDeclaration*/ undefined, /*writeTypeParameters*/ true); } } } @@ -585,11 +581,15 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( type, semanticMeaning, shouldUseAliasName ? symbol : resolvedSymbol, + verbosityLevel, ); displayParts.push(...resolvedInfo.displayParts); displayParts.push(lineBreakPart()); documentationFromAlias = resolvedInfo.documentation; tagsFromAlias = resolvedInfo.tags; + if (typeWriterOut && resolvedInfo.canIncreaseVerbosityLevel) { + typeWriterOut.couldUnfoldMore = true; + } } else { documentationFromAlias = resolvedSymbol.getContextualDocumentationComment(resolvedNode, typeChecker); @@ -680,6 +680,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( /*internalFlags*/ undefined, /*tracker*/ undefined, verbosityLevel, + typeWriterOut, )!; getPrinter().writeNode(EmitHint.Unspecified, param, getSourceFileOfNode(getParseTreeNode(enclosingDeclaration)), writer); }); @@ -814,9 +815,35 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( displayParts.push(spacePart()); } - function addFullSymbolName(symbolToDisplay: Symbol, enclosingDeclaration?: Node) { - let indexInfos; + // >> TODO: can this ever be called with depth > 0, i.e. not at the top level? + function canUnfoldSymbol(symbol: Symbol, out: WriterContextOut | undefined): Type | undefined { + if (verbosityLevel === undefined || !(symbol.flags & SymbolFlags.Type)) { + return undefined; + } + const type = getTypeOfSymbol(symbol); + if (!type) { + return undefined; + } + if (0 < verbosityLevel) { + return type; + } + if (out) { + out.couldUnfoldMore = true; + } + return undefined; + } + + function getTypeOfSymbol(symbol: Symbol) { + if (symbol.flags & (SymbolFlags.Interface)) { + return typeChecker.getDeclaredTypeOfSymbol(symbol); + } + return typeChecker.getTypeOfSymbolAtLocation(symbol, location); + } + function addFullSymbolName(symbolToDisplay: Symbol, enclosingDeclaration?: Node, writeTypeParameters = false) { + let indexInfos; + const originalSymbol = symbolToDisplay; + let hasWrittenTypeParameters = false; if (alias && symbolToDisplay === symbol) { symbolToDisplay = alias; } @@ -843,12 +870,33 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( fullSymbolDisplayParts.push(punctuationPart(SyntaxKind.CloseBracketToken)); } else { - fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments | SymbolFormatFlags.UseOnlyExternalAliasing | SymbolFormatFlags.AllowAnyNodeKind); + let unfoldType; + if (unfoldType = canUnfoldSymbol(originalSymbol, typeWriterOut)) { + if (writeTypeParameters) { + writeTypeParametersOfSymbol(originalSymbol, sourceFile); + hasWrittenTypeParameters = true; + } + fullSymbolDisplayParts = typeToDisplayParts( + typeChecker, + unfoldType, + enclosingDeclaration || sourceFile, + /*flags*/ undefined, + verbosityLevel, + typeWriterOut, + ) + } + else { + fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments | SymbolFormatFlags.UseOnlyExternalAliasing | SymbolFormatFlags.AllowAnyNodeKind); + } } addRange(displayParts, fullSymbolDisplayParts); if (symbol.flags & SymbolFlags.Optional) { displayParts.push(punctuationPart(SyntaxKind.QuestionToken)); } + + if (!hasWrittenTypeParameters && writeTypeParameters) { + writeTypeParametersOfSymbol(originalSymbol, sourceFile); + } } function addPrefixForAnyFunctionOrVar(symbol: Symbol, symbolKind: string) { @@ -882,7 +930,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( } function addSignatureDisplayParts(signature: Signature, allSignatures: readonly Signature[], flags = TypeFormatFlags.None) { - addRange(displayParts, signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | TypeFormatFlags.WriteTypeArgumentsOfSignature)); + addRange(displayParts, signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | TypeFormatFlags.WriteTypeArgumentsOfSignature, verbosityLevel, typeWriterOut)); if (allSignatures.length > 1) { displayParts.push(spacePart()); displayParts.push(punctuationPart(SyntaxKind.OpenParenToken)); diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 0f7b99250111f..9cc0d12f34aa5 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -3070,10 +3070,10 @@ export function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, e } /** @internal */ -export function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags: TypeFormatFlags = TypeFormatFlags.None): SymbolDisplayPart[] { +export function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags: TypeFormatFlags = TypeFormatFlags.None, verbosityLevel?: number, out?: WriterContextOut): SymbolDisplayPart[] { flags |= TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.WriteTypeArgumentsOfSignature | TypeFormatFlags.OmitParameterModifiers; return mapToDisplayParts(writer => { - typechecker.writeSignature(signature, enclosingDeclaration, flags, /*kind*/ undefined, writer); + typechecker.writeSignature(signature, enclosingDeclaration, flags, /*kind*/ undefined, writer, verbosityLevel, out); }); } diff --git a/tests/baselines/reference/quickinfoVerbosity3.baseline b/tests/baselines/reference/quickinfoVerbosity3.baseline new file mode 100644 index 0000000000000..b47e29374d58c --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosity3.baseline @@ -0,0 +1,624 @@ +// === QuickInfo === +=== /tests/cases/fourslash/file.tsx === +// interface OptionProp { +// propx: 2 +// } +// class Opt extends React.Component { +// render() { +// return
Hello
; +// } +// } +// const obj1: OptionProp = { +// propx: 2 +// } +// let y1 = ; +// ^^^ +// | ---------------------------------------------------------------------- +// | class { +// | new (): { +// | render(): any; +// | }; +// | prototype: { +// | render(): any; +// | }; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | class { +// | new (): Opt; +// | prototype: Opt; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | class Opt +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + +=== /b.ts === +// import { f } from "./a"; +// f({ x: 1 }); +// ^ +// | ---------------------------------------------------------------------- +// | (alias) f(x: { +// | x: number; +// | }): void +// | import f +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | (alias) f(x: X): void +// | import f +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/b.ts", + "position": 25, + "name": "1" + }, + "item": { + "kind": "alias", + "kindModifiers": "export", + "textSpan": { + "start": 25, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "aliasName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "X", + "kind": "aliasName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/b.ts", + "position": 25, + "name": "1" + }, + "item": { + "kind": "alias", + "kindModifiers": "export", + "textSpan": { + "start": 25, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "aliasName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/file.tsx", + "position": 201, + "name": "2" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 198, + "length": 3 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Opt", + "kind": "className" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/file.tsx", + "position": 201, + "name": "2" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 198, + "length": 3 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "new", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Opt", + "kind": "className" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prototype", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Opt", + "kind": "className" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/file.tsx", + "position": 201, + "name": "2" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 198, + "length": 3 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "new", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "render", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prototype", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "render", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityConditionalType.baseline b/tests/baselines/reference/quickinfoVerbosityConditionalType.baseline new file mode 100644 index 0000000000000..901ac8820edcf --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityConditionalType.baseline @@ -0,0 +1,385 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityConditionalType.ts === +// interface Apple { +// color: string; +// weight: number; +// } +// type StrInt = string | bigint; +// type T1 = T extends { color: string } ? "one apple" : StrInt; +// function f(x: T1): void { +// x; +// ^ +// | ---------------------------------------------------------------------- +// | (parameter) x: T extends { +// | color: string; +// | } ? "one apple" : string | bigint +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | (parameter) x: T extends { +// | color: string; +// | } ? "one apple" : StrInt +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | (parameter) x: T1 +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityConditionalType.ts", + "position": 240, + "name": "x" + }, + "item": { + "kind": "parameter", + "kindModifiers": "", + "textSpan": { + "start": 239, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "parameter", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T1", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityConditionalType.ts", + "position": 240, + "name": "x" + }, + "item": { + "kind": "parameter", + "kindModifiers": "", + "textSpan": { + "start": 239, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "parameter", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"one apple\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "StrInt", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityConditionalType.ts", + "position": 240, + "name": "x" + }, + "item": { + "kind": "parameter", + "kindModifiers": "", + "textSpan": { + "start": 239, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "parameter", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"one apple\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bigint", + "kind": "keyword" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityEnum.baseline b/tests/baselines/reference/quickinfoVerbosityEnum.baseline new file mode 100644 index 0000000000000..bc29f90664a96 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityEnum.baseline @@ -0,0 +1,285 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityEnum.ts === +// enum Color { +// ^^^^^ +// | ---------------------------------------------------------------------- +// | enum { +// | readonly [x: number]: string; +// | readonly Red: Color.Red; +// | readonly Green: Color.Green; +// | readonly Blue: Color.Blue; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^ +// | ---------------------------------------------------------------------- +// | enum Color +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// Red, +// Green, +// Blue, +// } + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", + "position": 10, + "name": "c" + }, + "item": { + "kind": "enum", + "kindModifiers": "", + "textSpan": { + "start": 5, + "length": 5 + }, + "displayParts": [ + { + "text": "enum", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "enumName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", + "position": 10, + "name": "c" + }, + "item": { + "kind": "enum", + "kindModifiers": "", + "textSpan": { + "start": 5, + "length": 5 + }, + "displayParts": [ + { + "text": "enum", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "readonly", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "readonly", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Red", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "enumName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Red", + "kind": "text" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "readonly", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Green", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "enumName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Green", + "kind": "text" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "readonly", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Blue", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "enumName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Blue", + "kind": "text" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityFunction.baseline b/tests/baselines/reference/quickinfoVerbosityFunction.baseline new file mode 100644 index 0000000000000..2213f32943cd5 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityFunction.baseline @@ -0,0 +1,941 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityFunction.ts === +// interface Apple { +// color: string; +// size: number; +// } +// interface Orchard { +// takeOneApple(a: Apple): void; +// getApple(): Apple; +// getApple(size: number): Apple[]; +// } +// const o: Orchard = {} as any; +// ^ +// | ---------------------------------------------------------------------- +// | const o: { +// | takeOneApple(a: { +// | color: string; +// | size: number; +// | }): void; +// | getApple(): { +// | color: string; +// | size: number; +// | }; +// | getApple(size: number): { +// | color: string; +// | size: number; +// | }[]; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const o: { +// | takeOneApple(a: Apple): void; +// | getApple(): Apple; +// | getApple(size: number): Apple[]; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const o: Orchard +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// declare function isApple(x: unknown): x is Apple; +// ^^^^^^^ +// | ---------------------------------------------------------------------- +// | function isApple(x: unknown): x is { +// | color: string; +// | size: number; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^^^ +// | ---------------------------------------------------------------------- +// | function isApple(x: unknown): x is Apple +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityFunction.ts", + "position": 180, + "name": "o" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 179, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "o", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Orchard", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityFunction.ts", + "position": 180, + "name": "o" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 179, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "o", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "takeOneApple", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "getApple", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "getApple", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "size", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityFunction.ts", + "position": 180, + "name": "o" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 179, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "o", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "takeOneApple", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "size", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "getApple", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "size", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "getApple", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "size", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "size", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityFunction.ts", + "position": 227, + "name": "f" + }, + "item": { + "kind": "function", + "kindModifiers": "declare", + "textSpan": { + "start": 220, + "length": 7 + }, + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "isApple", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "unknown", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "is", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityFunction.ts", + "position": 227, + "name": "f" + }, + "item": { + "kind": "function", + "kindModifiers": "declare", + "textSpan": { + "start": 220, + "length": 7 + }, + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "isApple", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "unknown", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "is", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "size", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityImport.baseline b/tests/baselines/reference/quickinfoVerbosityImport.baseline new file mode 100644 index 0000000000000..a360d9529cabf --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityImport.baseline @@ -0,0 +1,1212 @@ +// === QuickInfo === +=== /2.ts === +// import { a } from "./0"; +// ^ +// | ---------------------------------------------------------------------- +// | (alias) const a: { +// | a: number; +// | b: string; +// | } +// | import a +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | (alias) const a: Apple +// | import a +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// import { Color } from "./0"; +// ^^^^^ +// | ---------------------------------------------------------------------- +// | (alias) enum { +// | readonly [x: number]: string; +// | readonly Red: Color.Red; +// | readonly Green: Color.Green; +// | readonly Blue: Color.Blue; +// | } +// | import Color +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^ +// | ---------------------------------------------------------------------- +// | (alias) enum Color +// | import Color +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + +=== /1.ts === +// import * as zero from "./0"; +// const b = zero; +// ^ +// | ---------------------------------------------------------------------- +// | const b: { +// | readonly a: { +// | a: number; +// | b: string; +// | }; +// | Color: { +// | readonly [x: number]: string; +// | readonly Red: zero.Color.Red; +// | readonly Green: zero.Color.Green; +// | readonly Blue: zero.Color.Blue; +// | }; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const b: { +// | readonly a: zero.Apple; +// | Color: typeof zero.Color; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const b: typeof zero +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/1.ts", + "position": 36, + "name": "b" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 35, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "typeof", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "zero", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/1.ts", + "position": 36, + "name": "b" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 35, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "readonly", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "zero", + "kind": "aliasName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Apple", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "typeof", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "zero", + "kind": "aliasName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Color", + "kind": "enumName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/1.ts", + "position": 36, + "name": "b" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 35, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "readonly", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "readonly", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "readonly", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Red", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "zero", + "kind": "aliasName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Color", + "kind": "enumName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Red", + "kind": "text" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "readonly", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Green", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "zero", + "kind": "aliasName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Color", + "kind": "enumName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Green", + "kind": "text" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "readonly", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Blue", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "zero", + "kind": "aliasName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Color", + "kind": "enumName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Blue", + "kind": "text" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/2.ts", + "position": 10, + "name": "a" + }, + "item": { + "kind": "alias", + "kindModifiers": "export", + "textSpan": { + "start": 9, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "aliasName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/2.ts", + "position": 10, + "name": "a" + }, + "item": { + "kind": "alias", + "kindModifiers": "export", + "textSpan": { + "start": 9, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "aliasName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/2.ts", + "position": 39, + "name": "c" + }, + "item": { + "kind": "alias", + "kindModifiers": "export", + "textSpan": { + "start": 34, + "length": 5 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "enum", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "aliasName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/2.ts", + "position": 39, + "name": "c" + }, + "item": { + "kind": "alias", + "kindModifiers": "export", + "textSpan": { + "start": 34, + "length": 5 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "enum", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "readonly", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "readonly", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Red", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "enumName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Red", + "kind": "text" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "readonly", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Green", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "enumName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Green", + "kind": "text" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "readonly", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Blue", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "enumName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Blue", + "kind": "text" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityIndexSignature.baseline b/tests/baselines/reference/quickinfoVerbosityIndexSignature.baseline new file mode 100644 index 0000000000000..221f5181b3153 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityIndexSignature.baseline @@ -0,0 +1,588 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityIndexSignature.ts === +// type Key = string | number; +// interface Apple { +// banana: number; +// } +// interface Foo { +// [a: Key]: Apple; +// ^ +// | ---------------------------------------------------------------------- +// | (parameter) a: string | number +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | (parameter) a: Key +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } +// const f: Foo = {}; +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | [a: string]: { +// | banana: number; +// | }; +// | [a: number]: { +// | banana: number; +// | }; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | [a: string]: Apple; +// | [a: number]: Apple; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIndexSignature.ts", + "position": 90, + "name": "a" + }, + "item": { + "kind": "parameter", + "kindModifiers": "", + "textSpan": { + "start": 89, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "parameter", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Key", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIndexSignature.ts", + "position": 90, + "name": "a" + }, + "item": { + "kind": "parameter", + "kindModifiers": "", + "textSpan": { + "start": 89, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "parameter", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIndexSignature.ts", + "position": 114, + "name": "f" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 113, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIndexSignature.ts", + "position": 114, + "name": "f" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 113, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIndexSignature.ts", + "position": 114, + "name": "f" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 113, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "banana", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "banana", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityIndexType.baseline b/tests/baselines/reference/quickinfoVerbosityIndexType.baseline new file mode 100644 index 0000000000000..110a99c1f43b4 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityIndexType.baseline @@ -0,0 +1,584 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityIndexType.ts === +// interface T1 { +// banana: string; +// grape: number; +// apple: boolean; +// } +// const x1: keyof T1 = 'banana'; +// ^^ +// | ---------------------------------------------------------------------- +// | const x1: keyof { +// | banana: string; +// | grape: number; +// | apple: boolean; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^ +// | ---------------------------------------------------------------------- +// | const x1: keyof T1 +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// const x2: keyof T1 & ("grape" | "apple") = 'grape'; +// ^^ +// | ---------------------------------------------------------------------- +// | const x2: "grape" | "apple" +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// function fn1(obj: T, key: keyof T, k2: keyof T1) { +// if (key === k2) { +// ^^ +// | ---------------------------------------------------------------------- +// | (parameter) k2: keyof { +// | banana: string; +// | grape: number; +// | apple: boolean; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^ +// | ---------------------------------------------------------------------- +// | (parameter) k2: keyof T1 +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// return obj[key]; +// ^^^ +// | ---------------------------------------------------------------------- +// | (parameter) key: keyof T +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } +// return key; +// } + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIndexType.ts", + "position": 75, + "name": "x1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 73, + "length": 2 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x1", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "keyof", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T1", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIndexType.ts", + "position": 75, + "name": "x1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 73, + "length": 2 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x1", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "keyof", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "banana", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "grape", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "apple", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIndexType.ts", + "position": 106, + "name": "x2" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 104, + "length": 2 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x2", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"grape\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"apple\"", + "kind": "stringLiteral" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIndexType.ts", + "position": 230, + "name": "k2" + }, + "item": { + "kind": "parameter", + "kindModifiers": "", + "textSpan": { + "start": 228, + "length": 2 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "parameter", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "k2", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "keyof", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T1", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIndexType.ts", + "position": 230, + "name": "k2" + }, + "item": { + "kind": "parameter", + "kindModifiers": "", + "textSpan": { + "start": 228, + "length": 2 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "parameter", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "k2", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "keyof", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "banana", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "grape", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "apple", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIndexType.ts", + "position": 250, + "name": "key" + }, + "item": { + "kind": "parameter", + "kindModifiers": "", + "textSpan": { + "start": 247, + "length": 3 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "parameter", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "key", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "keyof", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 0 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityIndexedAccessType.baseline b/tests/baselines/reference/quickinfoVerbosityIndexedAccessType.baseline new file mode 100644 index 0000000000000..4feafb280c7b7 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityIndexedAccessType.baseline @@ -0,0 +1,405 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityIndexedAccessType.ts === +// interface T2 { +// "string key": string; +// "number key": number; +// "any key": string | number | symbol; +// } +// type K2 = "string key" | "any key"; +// function fn2(obj: T, key: keyof T) { +// const value: T[K2] = undefined as any; +// ^^^^^ +// | ---------------------------------------------------------------------- +// | const value: T["string key" | "any key"] +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^ +// | ---------------------------------------------------------------------- +// | const value: T[K2] +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } +// function fn3(obj: T2, key: K) { +// const value: T2[K] = undefined as any;; +// ^^^^^ +// | ---------------------------------------------------------------------- +// | const value: { +// | "string key": string; +// | "number key": number; +// | "any key": string | number | symbol; +// | }[K] +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^ +// | ---------------------------------------------------------------------- +// | const value: T2[K] +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIndexedAccessType.ts", + "position": 200, + "name": "v1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 195, + "length": 5 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "value", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "K2", + "kind": "aliasName" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIndexedAccessType.ts", + "position": 200, + "name": "v1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 195, + "length": 5 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "value", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "\"string key\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"any key\"", + "kind": "stringLiteral" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIndexedAccessType.ts", + "position": 297, + "name": "v2" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 292, + "length": 5 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "value", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T2", + "kind": "interfaceName" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "K", + "kind": "typeParameterName" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityIndexedAccessType.ts", + "position": 297, + "name": "v2" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 292, + "length": 5 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "value", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"string key\"", + "kind": "stringLiteral" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"number key\"", + "kind": "stringLiteral" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"any key\"", + "kind": "stringLiteral" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "symbol", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "K", + "kind": "typeParameterName" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityLibType.baseline b/tests/baselines/reference/quickinfoVerbosityLibType.baseline new file mode 100644 index 0000000000000..991a156b93f5b --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityLibType.baseline @@ -0,0 +1,456 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityLibType.ts === +// interface Apple { +// color: string; +// size: number; +// } +// function f(): Promise { +// return Promise.resolve({ color: "red", size: 5 }); +// } +// const g = f; +// ^ +// | ---------------------------------------------------------------------- +// | const g: () => Promise<{ +// | color: string; +// | size: number; +// | }> +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const g: () => Promise +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// const u: Map = new Map; +// ^ +// | ---------------------------------------------------------------------- +// | const u: Map +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const u: Map +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityLibType.ts", + "position": 152, + "name": "g" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 151, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "g", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Promise", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityLibType.ts", + "position": 152, + "name": "g" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 151, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "g", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Promise", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "size", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityLibType.ts", + "position": 165, + "name": "u" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 164, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "u", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Map", + "kind": "text" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityLibType.ts", + "position": 165, + "name": "u" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 164, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "u", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Map", + "kind": "text" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "size", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityMappedType.baseline b/tests/baselines/reference/quickinfoVerbosityMappedType.baseline new file mode 100644 index 0000000000000..385bbf8803a75 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityMappedType.baseline @@ -0,0 +1,1080 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityMappedType.ts === +// type Apple = boolean | number; +// type Orange = string | boolean; +// type F = { +// [K in keyof T as T[K] extends Apple ? never : K]: T[K]; +// } +// type Bar = { +// banana: string; +// apple: boolean; +// } +// const x: F = { banana: 'hello' }; +// ^ +// | ---------------------------------------------------------------------- +// | const x: { +// | banana: string; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const x: F +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | type F = { [K in keyof T as T[K] extends number | boolean ? never : K]: T[K]; } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | type F = { [K in keyof T as T[K] extends Apple ? never : K]: T[K]; } +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// const y: { [K in keyof Bar]?: Bar[K] } = { banana: 'hello' }; +// ^ +// | ---------------------------------------------------------------------- +// | const y: { +// | banana?: string; +// | apple?: boolean; +// | } +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// type G = { +// [K in keyof T]: T[K] & Apple +// }; +// const z: G = { banana: 'hello', apple: true }; +// ^ +// | ---------------------------------------------------------------------- +// | type G = { [K in keyof T]: T[K] & (number | boolean); } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | type G = { [K in keyof T]: T[K] & Apple; } +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityMappedType.ts", + "position": 192, + "name": "x" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 191, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "F", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "Bar", + "kind": "aliasName" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityMappedType.ts", + "position": 192, + "name": "x" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 191, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "banana", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityMappedType.ts", + "position": 195, + "name": "F" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 194, + "length": 1 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "F", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "K", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "in", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "keyof", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "as", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "K", + "kind": "typeParameterName" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "never", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "K", + "kind": "typeParameterName" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "K", + "kind": "typeParameterName" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityMappedType.ts", + "position": 195, + "name": "F" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 194, + "length": 1 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "F", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "K", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "in", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "keyof", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "as", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "K", + "kind": "typeParameterName" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "never", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "K", + "kind": "typeParameterName" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "K", + "kind": "typeParameterName" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityMappedType.ts", + "position": 231, + "name": "y" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 230, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "banana", + "kind": "propertyName" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "apple", + "kind": "propertyName" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityMappedType.ts", + "position": 343, + "name": "G" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 342, + "length": 1 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "G", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "K", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "in", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "keyof", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "K", + "kind": "typeParameterName" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "&", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityMappedType.ts", + "position": 343, + "name": "G" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 342, + "length": 1 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "G", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "K", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "in", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "keyof", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "K", + "kind": "typeParameterName" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "&", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityTypeParameter.baseline b/tests/baselines/reference/quickinfoVerbosityTypeParameter.baseline new file mode 100644 index 0000000000000..78f8164cb43ba --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityTypeParameter.baseline @@ -0,0 +1,689 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts === +// type Str = string | {}; +// type FooType = Str | number; +// function fn(x: T) { +// x; +// ^ +// | ---------------------------------------------------------------------- +// | (parameter) x: T extends number | (string | {}) +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | (parameter) x: T extends number | Str +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | (parameter) x: T extends FooType +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// } +// const y: (x: T) => void = fn; +// ^ +// | ---------------------------------------------------------------------- +// | const y: (x: T) => void +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const y: (x: T) => void +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const y: (x: T) => void +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts", + "position": 97, + "name": "x" + }, + "item": { + "kind": "parameter", + "kindModifiers": "", + "textSpan": { + "start": 96, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "parameter", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts", + "position": 97, + "name": "x" + }, + "item": { + "kind": "parameter", + "kindModifiers": "", + "textSpan": { + "start": 96, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "parameter", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Str", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts", + "position": 97, + "name": "x" + }, + "item": { + "kind": "parameter", + "kindModifiers": "", + "textSpan": { + "start": 96, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "parameter", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts", + "position": 108, + "name": "y" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 107, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts", + "position": 108, + "name": "y" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 107, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Str", + "kind": "aliasName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts", + "position": 108, + "name": "y" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 107, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityTypeof.baseline b/tests/baselines/reference/quickinfoVerbosityTypeof.baseline new file mode 100644 index 0000000000000..901b6af991a0f --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityTypeof.baseline @@ -0,0 +1,384 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityTypeof.ts === +// interface Apple { +// color: string; +// weight: number; +// } +// const a: Apple = { color: "red", weight: 150 }; +// const b: typeof a = { color: "green", weight: 120 }; +// ^ +// | ---------------------------------------------------------------------- +// | const b: { +// | color: string; +// | weight: number; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const b: Apple +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// class Banana { +// length: number; +// constructor(length: number) { +// this.length = length; +// } +// } +// const c: typeof Banana = Banana; +// ^ +// | ---------------------------------------------------------------------- +// | const c: { +// | new (length: number): Banana; +// | prototype: Banana; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const c: typeof Banana +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTypeof.ts", + "position": 114, + "name": "b" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 113, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTypeof.ts", + "position": 114, + "name": "b" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 113, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "weight", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTypeof.ts", + "position": 274, + "name": "c" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 273, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "typeof", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Banana", + "kind": "className" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTypeof.ts", + "position": 274, + "name": "c" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 273, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "new", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "length", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Banana", + "kind": "className" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prototype", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Banana", + "kind": "className" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosity3.ts b/tests/cases/fourslash/quickinfoVerbosity3.ts new file mode 100644 index 0000000000000..e43f005e0c8e5 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosity3.ts @@ -0,0 +1,42 @@ +/// + +// @Filename: /a.ts +////export type X = { x: number }; +////export function f(x: X): void {} + +// @Filename: /b.ts +////import { f } from "./a"; +/////*1*/f({ x: 1 }); + +// @Filename: file.tsx +// @jsx: preserve +// @noLib: true + +//// interface OptionProp { +//// propx: 2 +//// } +//// class Opt extends React.Component { +//// render() { +//// return
Hello
; +//// } +//// } +//// const obj1: OptionProp = { +//// propx: 2 +//// } +//// let y1 = ; + +// @Filename: a.ts +//// interface Foo/*3*/ { +//// prop: T +//// } +//// class Bar/*4*/ implements Foo { +//// prop!: T +//// } + + +verify.baselineQuickInfo({ + "1": [0, 1], + "2": [0, 1, 2], + "3": [0, 1], + "4": [0, 1], +}); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityConditionalType.ts b/tests/cases/fourslash/quickinfoVerbosityConditionalType.ts new file mode 100644 index 0000000000000..066ce0a8784f8 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityConditionalType.ts @@ -0,0 +1,13 @@ +/// + +//// interface Apple { +//// color: string; +//// weight: number; +//// } +//// type StrInt = string | bigint; +//// type T1 = T extends { color: string } ? "one apple" : StrInt; +//// function f(x: T1): void { +//// x/*x*/; +//// } + +verify.baselineQuickInfo({ "x": [0, 1, 2] }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityEnum.ts b/tests/cases/fourslash/quickinfoVerbosityEnum.ts new file mode 100644 index 0000000000000..9876fc2ad0f07 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityEnum.ts @@ -0,0 +1,11 @@ +/// + +//// enum Color/*c*/ { +//// Red, +//// Green, +//// Blue, +//// } + +verify.baselineQuickInfo({ + c: [0, 1], +}); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityFunction.ts b/tests/cases/fourslash/quickinfoVerbosityFunction.ts new file mode 100644 index 0000000000000..e743a05e6f3f0 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityFunction.ts @@ -0,0 +1,22 @@ +/// + + +//// interface Apple { +//// color: string; +//// size: number; +//// } + +//// interface Orchard { +//// takeOneApple(a: Apple): void; + +//// getApple(): Apple; +//// getApple(size: number): Apple[]; +//// } + +//// const o/*o*/: Orchard = {} as any; + +//// declare function isApple/*f*/(x: unknown): x is Apple; + + + +verify.baselineQuickInfo({ "o": [0, 1, 2], "f": [0, 1] }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityImport.ts b/tests/cases/fourslash/quickinfoVerbosityImport.ts new file mode 100644 index 0000000000000..01ad83ede27d1 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityImport.ts @@ -0,0 +1,28 @@ +/// + +// @module: esnext +// @filename: /0.ts +//// export type Apple = { +//// a: number; +//// b: string; +//// } +//// export const a: Apple = { a: 1, b: "2"}; +//// export enum Color { +//// Red, +//// Green, +//// Blue, +//// } + +// @filename: /1.ts +//// import * as zero from "./0"; +//// const b/*b*/ = zero; + +// @filename: /2.ts +//// import { a/*a*/ } from "./0"; +//// import { Color/*c*/ } from "./0"; + +verify.baselineQuickInfo({ + b: [0, 1, 2], + a: [0, 1], + c: [0, 1], +}); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityIndexSignature.ts b/tests/cases/fourslash/quickinfoVerbosityIndexSignature.ts new file mode 100644 index 0000000000000..0facb3d3f2cf9 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityIndexSignature.ts @@ -0,0 +1,13 @@ +/// + +//// type Key = string | number; +//// interface Apple { +//// banana: number; +//// } +//// interface Foo { +//// [a/*a*/: Key]: Apple; +//// } +//// const f/*f*/: Foo = {}; + + +verify.baselineQuickInfo({ "a": [0, 1], "f": [0, 1, 2] }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityIndexType.ts b/tests/cases/fourslash/quickinfoVerbosityIndexType.ts new file mode 100644 index 0000000000000..c44a0124cac97 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityIndexType.ts @@ -0,0 +1,20 @@ +/// + +//// interface T1 { +//// banana: string; +//// grape: number; +//// apple: boolean; +//// } + +//// const x1/*x1*/: keyof T1 = 'banana'; +//// const x2/*x2*/: keyof T1 & ("grape" | "apple") = 'grape'; + +//// function fn1(obj: T, key: keyof T, k2: keyof T1) { +//// if (key === k2/*k2*/) { +//// return obj[key/*key*/]; +//// } +//// return key; +//// } + + +verify.baselineQuickInfo({ "x1": [0, 1], "x2": [0], "k2": [0, 1], "key": [0] }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityIndexedAccessType.ts b/tests/cases/fourslash/quickinfoVerbosityIndexedAccessType.ts new file mode 100644 index 0000000000000..c58286923b5fa --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityIndexedAccessType.ts @@ -0,0 +1,20 @@ +/// + +//// interface T2 { +//// "string key": string; +//// "number key": number; +//// "any key": string | number | symbol; +//// } + +//// type K2 = "string key" | "any key"; + +//// function fn2(obj: T, key: keyof T) { +//// const value/*v1*/: T[K2] = undefined as any; +//// } + +//// function fn3(obj: T2, key: K) { +//// const value/*v2*/: T2[K] = undefined as any;; +//// } + + +verify.baselineQuickInfo({ "v1": [0, 1], "v2": [0, 1] }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityLibType.ts b/tests/cases/fourslash/quickinfoVerbosityLibType.ts new file mode 100644 index 0000000000000..5eb1aa2a134b6 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityLibType.ts @@ -0,0 +1,15 @@ +/// + +//// interface Apple { +//// color: string; +//// size: number; +//// } + +//// function f(): Promise { +//// return Promise.resolve({ color: "red", size: 5 }); +//// } + +//// const g/*g*/ = f; +//// const u/*u*/: Map = new Map; + +verify.baselineQuickInfo({ "g": [0, 1], "u": [0, 1] }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityMappedType.ts b/tests/cases/fourslash/quickinfoVerbosityMappedType.ts new file mode 100644 index 0000000000000..e6b3588445412 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityMappedType.ts @@ -0,0 +1,20 @@ +/// + +//// type Apple = boolean | number; +//// type Orange = string | boolean; +//// type F = { +//// [K in keyof T as T[K] extends Apple ? never : K]: T[K]; +//// } +//// type Bar = { +//// banana: string; +//// apple: boolean; +//// } +//// const x/*x*/: F/*F*/ = { banana: 'hello' }; +//// const y/*y*/: { [K in keyof Bar]?: Bar[K] } = { banana: 'hello' }; +//// type G = { +//// [K in keyof T]: T[K] & Apple +//// }; +//// const z: G/*G*/ = { banana: 'hello', apple: true }; + + +verify.baselineQuickInfo({ "x": [0, 1], "y": [0], "F": [0, 1], "G": [0, 1] }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts b/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts new file mode 100644 index 0000000000000..4c36edfa1ea73 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts @@ -0,0 +1,11 @@ +/// + +//// type Str = string | {}; +//// type FooType = Str | number; +//// function fn(x: T) { +//// x/*x*/; +//// } +//// const y/*y*/: (x: T) => void = fn; + + +verify.baselineQuickInfo({ "x": [0, 1, 2], "y": [0, 1, 2] }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityTypeof.ts b/tests/cases/fourslash/quickinfoVerbosityTypeof.ts new file mode 100644 index 0000000000000..76d79ab34d1e3 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityTypeof.ts @@ -0,0 +1,23 @@ +/// + +//// interface Apple { +//// color: string; +//// weight: number; +//// } + +//// const a: Apple = { color: "red", weight: 150 }; +//// const b/*b*/: typeof a = { color: "green", weight: 120 }; + +//// class Banana { +//// length: number; +//// constructor(length: number) { +//// this.length = length; +//// } +//// } + +//// const c/*c*/: typeof Banana = Banana; + +verify.baselineQuickInfo({ + b: [0, 1], + c: [0, 1], +}); \ No newline at end of file From e3714695c5bf8def600a62910205c5a9f050f569 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Thu, 13 Mar 2025 19:24:25 -0700 Subject: [PATCH 03/31] Fixes --- src/compiler/checker.ts | 23 +- src/services/symbolDisplay.ts | 61 +- .../reference/quickinfoVerbosity3.baseline | 1567 ++++++++++++++++- .../reference/quickinfoVerbosityEnum.baseline | 10 +- .../quickinfoVerbosityImport.baseline | 16 +- tests/cases/fourslash/quickinfoVerbosity3.ts | 6 +- .../quickinfoVerbosityTypeParameter.ts | 5 +- 7 files changed, 1640 insertions(+), 48 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f74a6bf6b9be1..98f4d78939c0f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6465,6 +6465,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Determines if a type can be unfolded, based on how many layers of type aliases we're allowed to unfold. function canUnfoldType(type: Type, context: NodeBuilderContext): boolean { + if (isUnfoldableType(type)) { + return false; + } for (let i = 0; i < context.typeStack.length - 1; i++) { if (context.typeStack[i] === type.id) { return false; @@ -6479,8 +6482,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Don't unfold types like `Array` or `Promise`, instead treating them as transparent. function isUnfoldableType(type: Type): boolean { - return (getObjectFlags(type) & ObjectFlags.Reference) !== 0 && - !!((type as TypeReference).target.symbol?.declarations?.some(decl => host.isSourceFileDefaultLibrary(getSourceFileOfNode(decl)))); + const symbol = (getObjectFlags(type) & ObjectFlags.Reference) !== 0 ? (type as TypeReference).target.symbol : type.symbol; + return !!(symbol?.declarations?.some(decl => host.isSourceFileDefaultLibrary(getSourceFileOfNode(decl)))) } function typeToTypeNodeHelper(type: Type, context: NodeBuilderContext): TypeNode { @@ -6649,9 +6652,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (objectFlags & ObjectFlags.Reference) { Debug.assert(!!(type.flags & TypeFlags.Object)); - if (!isUnfoldableType(type) && canUnfoldType(type, context)) { + if (canUnfoldType(type, context)) { context.depth += 1; - return createAnonymousTypeNode(type as TypeReference, /*forceClassExpansion*/ true); + return createAnonymousTypeNode(type as TypeReference, /*forceClassExpansion*/ true, /*forceExpansion*/ true); } return (type as TypeReference).node ? visitAndTransformType(type as TypeReference, typeReferenceToTypeNode) : typeReferenceToTypeNode(type as TypeReference); } @@ -6683,7 +6686,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } if (objectFlags & ObjectFlags.ClassOrInterface && canUnfoldType(type, context)) { context.depth += 1; - return createAnonymousTypeNode(type as InterfaceType, /*forceClassExpansion*/ true); + return createAnonymousTypeNode(type as InterfaceType, /*forceClassExpansion*/ true, /*forceExpansion*/ true); } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. if (type.symbol) { @@ -6892,7 +6895,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return result; } - function createAnonymousTypeNode(type: ObjectType, forceClassExpansion = false): TypeNode { + function createAnonymousTypeNode(type: ObjectType, forceClassExpansion = false, forceExpansion = false): TypeNode { const typeId = type.id; const symbol = type.symbol; if (symbol) { @@ -6925,7 +6928,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } // Always use 'typeof T' for type of class, enum, and module objects else if ( - symbol.flags & SymbolFlags.Class + !forceExpansion && + (symbol.flags & SymbolFlags.Class && !forceClassExpansion && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration @@ -6934,7 +6938,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== SymbolAccessibility.Accessible)) || symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) - || shouldWriteTypeOfFunctionSymbol() + || shouldWriteTypeOfFunctionSymbol()) ) { if (canUnfoldType(type, context)) { context.depth += 1; @@ -8025,7 +8029,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function typeParameterToDeclaration(type: TypeParameter, context: NodeBuilderContext, constraint = getConstraintOfTypeParameter(type)): TypeParameterDeclaration { const constraintNode = constraint && typeToTypeNodeHelperWithPossibleReusableTypeNode(constraint, getConstraintDeclaration(type), context); - return typeParameterToDeclarationWithConstraint(type, context, constraintNode); + const typeParam = typeParameterToDeclarationWithConstraint(type, context, constraintNode); + return typeParam; } function typePredicateToTypePredicateNodeHelper(typePredicate: TypePredicate, context: NodeBuilderContext): TypePredicateNode { diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index f04675fb5b58a..ab11f182e6a96 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -456,19 +456,24 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( displayParts.push(keywordPart(SyntaxKind.ClassKeyword)); } displayParts.push(spacePart()); - addFullSymbolName(symbol, /*enclosingDeclaration*/ undefined, /*writeTypeParameters*/ true); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + tryUnfoldSymbol(symbol); } if ((symbolFlags & SymbolFlags.Interface) && (semanticMeaning & SemanticMeaning.Type)) { prefixNextMeaning(); displayParts.push(keywordPart(SyntaxKind.InterfaceKeyword)); displayParts.push(spacePart()); - addFullSymbolName(symbol, /*enclosingDeclaration*/ undefined, /*writeTypeParameters*/ true); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + tryUnfoldSymbol(symbol); } if ((symbolFlags & SymbolFlags.TypeAlias) && (semanticMeaning & SemanticMeaning.Type)) { prefixNextMeaning(); displayParts.push(keywordPart(SyntaxKind.TypeKeyword)); displayParts.push(spacePart()); - addFullSymbolName(symbol, /*enclosingDeclaration*/ undefined, /*writeTypeParameters*/ true); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(spacePart()); displayParts.push(operatorPart(SyntaxKind.EqualsToken)); displayParts.push(spacePart()); @@ -493,6 +498,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( displayParts.push(keywordPart(SyntaxKind.EnumKeyword)); displayParts.push(spacePart()); addFullSymbolName(symbol, /*enclosingDeclaration*/ undefined); + tryUnfoldSymbol(symbol); } if (symbolFlags & SymbolFlags.Module && !isThisExpression) { prefixNextMeaning(); @@ -501,6 +507,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( displayParts.push(keywordPart(isNamespace ? SyntaxKind.NamespaceKeyword : SyntaxKind.ModuleKeyword)); displayParts.push(spacePart()); addFullSymbolName(symbol); + tryUnfoldSymbol(symbol); } if ((symbolFlags & SymbolFlags.TypeParameter) && (semanticMeaning & SemanticMeaning.Type)) { prefixNextMeaning(); @@ -512,7 +519,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( if (symbol.parent) { // Class/Interface type parameter addInPrefix(); - addFullSymbolName(symbol.parent, enclosingDeclaration); // >> TODO: review this case + addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { @@ -541,7 +548,8 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( addInPrefix(); displayParts.push(keywordPart(SyntaxKind.TypeKeyword)); displayParts.push(spacePart()); - addFullSymbolName(declaration.symbol, /*enclosingDeclaration*/ undefined, /*writeTypeParameters*/ true); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); } } } @@ -840,10 +848,24 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( return typeChecker.getTypeOfSymbolAtLocation(symbol, location); } - function addFullSymbolName(symbolToDisplay: Symbol, enclosingDeclaration?: Node, writeTypeParameters = false) { + function tryUnfoldSymbol(symbol: Symbol) { + let unfoldType; + if (unfoldType = canUnfoldSymbol(symbol, typeWriterOut)) { + const expandedDisplayParts = typeToDisplayParts( + typeChecker, + unfoldType, + enclosingDeclaration || sourceFile, + /*flags*/ undefined, + verbosityLevel, + typeWriterOut, + ); + displayParts.push(spacePart()); + addRange(displayParts, expandedDisplayParts); + } + } + + function addFullSymbolName(symbolToDisplay: Symbol, enclosingDeclaration?: Node) { let indexInfos; - const originalSymbol = symbolToDisplay; - let hasWrittenTypeParameters = false; if (alias && symbolToDisplay === symbol) { symbolToDisplay = alias; } @@ -870,33 +892,12 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( fullSymbolDisplayParts.push(punctuationPart(SyntaxKind.CloseBracketToken)); } else { - let unfoldType; - if (unfoldType = canUnfoldSymbol(originalSymbol, typeWriterOut)) { - if (writeTypeParameters) { - writeTypeParametersOfSymbol(originalSymbol, sourceFile); - hasWrittenTypeParameters = true; - } - fullSymbolDisplayParts = typeToDisplayParts( - typeChecker, - unfoldType, - enclosingDeclaration || sourceFile, - /*flags*/ undefined, - verbosityLevel, - typeWriterOut, - ) - } - else { - fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments | SymbolFormatFlags.UseOnlyExternalAliasing | SymbolFormatFlags.AllowAnyNodeKind); - } + fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments | SymbolFormatFlags.UseOnlyExternalAliasing | SymbolFormatFlags.AllowAnyNodeKind); } addRange(displayParts, fullSymbolDisplayParts); if (symbol.flags & SymbolFlags.Optional) { displayParts.push(punctuationPart(SyntaxKind.QuestionToken)); } - - if (!hasWrittenTypeParameters && writeTypeParameters) { - writeTypeParametersOfSymbol(originalSymbol, sourceFile); - } } function addPrefixForAnyFunctionOrVar(symbol: Symbol, symbolKind: string) { diff --git a/tests/baselines/reference/quickinfoVerbosity3.baseline b/tests/baselines/reference/quickinfoVerbosity3.baseline index b47e29374d58c..aa97f5e3cc8db 100644 --- a/tests/baselines/reference/quickinfoVerbosity3.baseline +++ b/tests/baselines/reference/quickinfoVerbosity3.baseline @@ -14,7 +14,7 @@ // let y1 = ; // ^^^ // | ---------------------------------------------------------------------- -// | class { +// | class Opt { // | new (): { // | render(): any; // | }; @@ -26,7 +26,7 @@ // | ---------------------------------------------------------------------- // ^^^ // | ---------------------------------------------------------------------- -// | class { +// | class Opt { // | new (): Opt; // | prototype: Opt; // | } @@ -38,6 +38,97 @@ // | (verbosity level: 0) // | ---------------------------------------------------------------------- +=== /tests/cases/fourslash/a.ts === +// interface Foo { +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Foo { +// | prop: T; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// prop: T +// } +// class Bar implements Foo { +// ^^^ +// | ---------------------------------------------------------------------- +// | class Bar { +// | new (): { +// | prop: T; +// | }; +// | prototype: { +// | prop: any; +// | }; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | class Bar { +// | new (): Bar; +// | prototype: Bar; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | class Bar +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// prop!: T +// } + +=== /tests/cases/fourslash/c.ts === +// class c5b { public foo() { } } +// namespace c5b { export var y = 2; } +// ^^^ +// | ---------------------------------------------------------------------- +// | class c5b { +// | new (): { +// | foo(): void; +// | }; +// | prototype: { +// | foo(): void; +// | }; +// | y: number; +// | } +// | namespace c5b { +// | new (): { +// | foo(): void; +// | }; +// | prototype: { +// | foo(): void; +// | }; +// | y: number; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | class c5b { +// | new (): c5b; +// | prototype: c5b; +// | y: number; +// | } +// | namespace c5b { +// | new (): c5b; +// | prototype: c5b; +// | y: number; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | class c5b +// | namespace c5b +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + === /b.ts === // import { f } from "./a"; // f({ x: 1 }); @@ -331,6 +422,14 @@ "text": " ", "kind": "space" }, + { + "text": "Opt", + "kind": "className" + }, + { + "text": " ", + "kind": "space" + }, { "text": "{", "kind": "punctuation" @@ -439,6 +538,14 @@ "text": " ", "kind": "space" }, + { + "text": "Opt", + "kind": "className" + }, + { + "text": " ", + "kind": "space" + }, { "text": "{", "kind": "punctuation" @@ -620,5 +727,1461 @@ "canIncreaseVerbosityLevel": false, "verbosityLevel": 2 } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/a.ts", + "position": 13, + "name": "3" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 10, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Date", + "kind": "text" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/a.ts", + "position": 13, + "name": "3" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 10, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Date", + "kind": "text" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/a.ts", + "position": 55, + "name": "4" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 52, + "length": 3 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Date", + "kind": "text" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/a.ts", + "position": 55, + "name": "4" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 52, + "length": 3 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Date", + "kind": "text" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "new", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Date", + "kind": "text" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prototype", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "any", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/a.ts", + "position": 55, + "name": "4" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 52, + "length": 3 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Date", + "kind": "text" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "new", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Date", + "kind": "text" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prototype", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/c.ts", + "position": 44, + "name": "5" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 41, + "length": 3 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c5b", + "kind": "className" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c5b", + "kind": "className" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/c.ts", + "position": 44, + "name": "5" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 41, + "length": 3 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c5b", + "kind": "className" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "new", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c5b", + "kind": "className" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prototype", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c5b", + "kind": "className" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c5b", + "kind": "className" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "new", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c5b", + "kind": "className" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prototype", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c5b", + "kind": "className" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/c.ts", + "position": 44, + "name": "5" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 41, + "length": 3 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c5b", + "kind": "className" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "new", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prototype", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c5b", + "kind": "className" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "new", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prototype", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } } ] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityEnum.baseline b/tests/baselines/reference/quickinfoVerbosityEnum.baseline index bc29f90664a96..ec01da2ce89e4 100644 --- a/tests/baselines/reference/quickinfoVerbosityEnum.baseline +++ b/tests/baselines/reference/quickinfoVerbosityEnum.baseline @@ -3,7 +3,7 @@ // enum Color { // ^^^^^ // | ---------------------------------------------------------------------- -// | enum { +// | enum Color { // | readonly [x: number]: string; // | readonly Red: Color.Red; // | readonly Green: Color.Green; @@ -76,6 +76,14 @@ "text": " ", "kind": "space" }, + { + "text": "Color", + "kind": "enumName" + }, + { + "text": " ", + "kind": "space" + }, { "text": "{", "kind": "punctuation" diff --git a/tests/baselines/reference/quickinfoVerbosityImport.baseline b/tests/baselines/reference/quickinfoVerbosityImport.baseline index a360d9529cabf..f8c0895a141fc 100644 --- a/tests/baselines/reference/quickinfoVerbosityImport.baseline +++ b/tests/baselines/reference/quickinfoVerbosityImport.baseline @@ -19,7 +19,7 @@ // import { Color } from "./0"; // ^^^^^ // | ---------------------------------------------------------------------- -// | (alias) enum { +// | (alias) enum Color { // | readonly [x: number]: string; // | readonly Red: Color.Red; // | readonly Green: Color.Green; @@ -987,6 +987,14 @@ "text": " ", "kind": "space" }, + { + "text": "Color", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, { "text": "{", "kind": "punctuation" @@ -1077,7 +1085,7 @@ }, { "text": "Color", - "kind": "enumName" + "kind": "aliasName" }, { "text": ".", @@ -1121,7 +1129,7 @@ }, { "text": "Color", - "kind": "enumName" + "kind": "aliasName" }, { "text": ".", @@ -1165,7 +1173,7 @@ }, { "text": "Color", - "kind": "enumName" + "kind": "aliasName" }, { "text": ".", diff --git a/tests/cases/fourslash/quickinfoVerbosity3.ts b/tests/cases/fourslash/quickinfoVerbosity3.ts index e43f005e0c8e5..6d76ec3a6e45e 100644 --- a/tests/cases/fourslash/quickinfoVerbosity3.ts +++ b/tests/cases/fourslash/quickinfoVerbosity3.ts @@ -33,10 +33,14 @@ //// prop!: T //// } +// @Filename: c.ts +//// class c5b { public foo() { } } +//// namespace c5b/*5*/ { export var y = 2; } verify.baselineQuickInfo({ "1": [0, 1], "2": [0, 1, 2], "3": [0, 1], - "4": [0, 1], + "4": [0, 1, 2], + "5": [0, 1, 2], }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts b/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts index 4c36edfa1ea73..2f2dfc8ecb895 100644 --- a/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts +++ b/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts @@ -8,4 +8,7 @@ //// const y/*y*/: (x: T) => void = fn; -verify.baselineQuickInfo({ "x": [0, 1, 2], "y": [0, 1, 2] }); \ No newline at end of file +verify.baselineQuickInfo({ + "x": [0, 1, 2], + "y": [0, 1, 2] +}); \ No newline at end of file From 5686f686f6985c9928f46e280da70f8c52bedc11 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 14 Mar 2025 09:31:51 -0700 Subject: [PATCH 04/31] use declared symbol for class --- src/services/symbolDisplay.ts | 2 +- .../reference/quickinfoVerbosity3.baseline | 1086 ++--------------- 2 files changed, 114 insertions(+), 974 deletions(-) diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index ab11f182e6a96..f8365cc0df898 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -842,7 +842,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( } function getTypeOfSymbol(symbol: Symbol) { - if (symbol.flags & (SymbolFlags.Interface)) { + if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { return typeChecker.getDeclaredTypeOfSymbol(symbol); } return typeChecker.getTypeOfSymbolAtLocation(symbol, location); diff --git a/tests/baselines/reference/quickinfoVerbosity3.baseline b/tests/baselines/reference/quickinfoVerbosity3.baseline index aa97f5e3cc8db..3327d1fbde21e 100644 --- a/tests/baselines/reference/quickinfoVerbosity3.baseline +++ b/tests/baselines/reference/quickinfoVerbosity3.baseline @@ -15,20 +15,14 @@ // ^^^ // | ---------------------------------------------------------------------- // | class Opt { -// | new (): { -// | render(): any; -// | }; -// | prototype: { -// | render(): any; -// | }; +// | render(): any; // | } // | (verbosity level: 2) // | ---------------------------------------------------------------------- // ^^^ // | ---------------------------------------------------------------------- // | class Opt { -// | new (): Opt; -// | prototype: Opt; +// | render(): any; // | } // | (verbosity level: 1) // | ---------------------------------------------------------------------- @@ -58,20 +52,14 @@ // ^^^ // | ---------------------------------------------------------------------- // | class Bar { -// | new (): { -// | prop: T; -// | }; -// | prototype: { -// | prop: any; -// | }; +// | prop: T; // | } // | (verbosity level: 2) // | ---------------------------------------------------------------------- // ^^^ // | ---------------------------------------------------------------------- // | class Bar { -// | new (): Bar; -// | prototype: Bar; +// | prop: T; // | } // | (verbosity level: 1) // | ---------------------------------------------------------------------- @@ -89,36 +77,20 @@ // ^^^ // | ---------------------------------------------------------------------- // | class c5b { -// | new (): { -// | foo(): void; -// | }; -// | prototype: { -// | foo(): void; -// | }; -// | y: number; +// | foo(): void; // | } // | namespace c5b { -// | new (): { -// | foo(): void; -// | }; -// | prototype: { -// | foo(): void; -// | }; -// | y: number; +// | foo(): void; // | } // | (verbosity level: 2) // | ---------------------------------------------------------------------- // ^^^ // | ---------------------------------------------------------------------- // | class c5b { -// | new (): c5b; -// | prototype: c5b; -// | y: number; +// | foo(): void; // | } // | namespace c5b { -// | new (): c5b; -// | prototype: c5b; -// | y: number; +// | foo(): void; // | } // | (verbosity level: 1) // | ---------------------------------------------------------------------- @@ -443,12 +415,8 @@ "kind": "space" }, { - "text": "new", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" + "text": "render", + "kind": "text" }, { "text": "(", @@ -467,36 +435,8 @@ "kind": "space" }, { - "text": "Opt", - "kind": "className" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "prototype", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Opt", - "kind": "className" + "text": "any", + "kind": "keyword" }, { "text": ";", @@ -512,7 +452,7 @@ } ], "documentation": [], - "canIncreaseVerbosityLevel": true, + "canIncreaseVerbosityLevel": false, "verbosityLevel": 1 } }, @@ -558,118 +498,6 @@ "text": " ", "kind": "space" }, - { - "text": "new", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "render", - "kind": "text" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "any", - "kind": "keyword" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "}", - "kind": "punctuation" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "prototype", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, { "text": "render", "kind": "text" @@ -702,22 +530,6 @@ "text": "\n", "kind": "lineBreak" }, - { - "text": " ", - "kind": "space" - }, - { - "text": "}", - "kind": "punctuation" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, { "text": "}", "kind": "punctuation" @@ -1023,27 +835,55 @@ "kind": "space" }, { - "text": "new", - "kind": "keyword" + "text": "prop", + "kind": "propertyName" }, { - "text": " ", - "kind": "space" + "text": ":", + "kind": "punctuation" }, { - "text": "<", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { "text": "T", "kind": "typeParameterName" }, { - "text": " ", - "kind": "space" + "text": ";", + "kind": "punctuation" }, { - "text": "extends", + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/a.ts", + "position": 55, + "name": "4" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 52, + "length": 3 + }, + "displayParts": [ + { + "text": "class", "kind": "keyword" }, { @@ -1051,47 +891,43 @@ "kind": "space" }, { - "text": "Date", - "kind": "text" + "text": "Bar", + "kind": "className" }, { - "text": ">", + "text": "<", "kind": "punctuation" }, { - "text": "(", - "kind": "punctuation" + "text": "T", + "kind": "typeParameterName" }, { - "text": ")", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": ":", - "kind": "punctuation" + "text": "extends", + "kind": "keyword" }, { "text": " ", "kind": "space" }, { - "text": "Bar", - "kind": "className" + "text": "Date", + "kind": "text" }, { - "text": "<", + "text": ">", "kind": "punctuation" }, { - "text": "T", - "kind": "typeParameterName" - }, - { - "text": ">", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": ";", + "text": "{", "kind": "punctuation" }, { @@ -1103,7 +939,7 @@ "kind": "space" }, { - "text": "prototype", + "text": "prop", "kind": "propertyName" }, { @@ -1115,280 +951,16 @@ "kind": "space" }, { - "text": "Bar", - "kind": "className" + "text": "T", + "kind": "typeParameterName" }, { - "text": "<", + "text": ";", "kind": "punctuation" }, { - "text": "any", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "}", - "kind": "punctuation" - } - ], - "documentation": [], - "canIncreaseVerbosityLevel": true, - "verbosityLevel": 1 - } - }, - { - "marker": { - "fileName": "/tests/cases/fourslash/a.ts", - "position": 55, - "name": "4" - }, - "item": { - "kind": "class", - "kindModifiers": "", - "textSpan": { - "start": 52, - "length": 3 - }, - "displayParts": [ - { - "text": "class", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Bar", - "kind": "className" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "T", - "kind": "typeParameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "extends", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Date", - "kind": "text" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "new", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "T", - "kind": "typeParameterName" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "extends", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Date", - "kind": "text" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "prop", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "T", - "kind": "typeParameterName" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "}", - "kind": "punctuation" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "prototype", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "prop", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "any", - "kind": "keyword" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "}", - "kind": "punctuation" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" + "text": "\n", + "kind": "lineBreak" }, { "text": "}", @@ -1416,255 +988,7 @@ "displayParts": [ { "text": "class", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "c5b", - "kind": "className" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "namespace", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "c5b", - "kind": "className" - } - ], - "documentation": [], - "canIncreaseVerbosityLevel": true, - "verbosityLevel": 0 - } - }, - { - "marker": { - "fileName": "/tests/cases/fourslash/c.ts", - "position": 44, - "name": "5" - }, - "item": { - "kind": "class", - "kindModifiers": "", - "textSpan": { - "start": 41, - "length": 3 - }, - "displayParts": [ - { - "text": "class", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "c5b", - "kind": "className" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "new", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "c5b", - "kind": "className" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "prototype", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "c5b", - "kind": "className" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "y", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "}", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "namespace", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "c5b", - "kind": "className" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "new", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "c5b", - "kind": "className" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "prototype", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" + "kind": "keyword" }, { "text": " ", @@ -1674,50 +998,26 @@ "text": "c5b", "kind": "className" }, - { - "text": ";", - "kind": "punctuation" - }, { "text": "\n", "kind": "lineBreak" }, { - "text": " ", - "kind": "space" - }, - { - "text": "y", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" + "text": "namespace", + "kind": "keyword" }, { "text": " ", "kind": "space" }, { - "text": "number", - "kind": "keyword" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "}", - "kind": "punctuation" + "text": "c5b", + "kind": "className" } ], "documentation": [], "canIncreaseVerbosityLevel": true, - "verbosityLevel": 1 + "verbosityLevel": 0 } }, { @@ -1762,42 +1062,6 @@ "text": " ", "kind": "space" }, - { - "text": "new", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, { "text": "foo", "kind": "text" @@ -1830,33 +1094,25 @@ "text": "\n", "kind": "lineBreak" }, - { - "text": " ", - "kind": "space" - }, { "text": "}", "kind": "punctuation" }, - { - "text": ";", - "kind": "punctuation" - }, { "text": "\n", "kind": "lineBreak" }, { - "text": " ", - "kind": "space" + "text": "namespace", + "kind": "keyword" }, { - "text": "prototype", - "kind": "propertyName" + "text": " ", + "kind": "space" }, { - "text": ":", - "kind": "punctuation" + "text": "c5b", + "kind": "className" }, { "text": " ", @@ -1871,7 +1127,7 @@ "kind": "lineBreak" }, { - "text": " ", + "text": " ", "kind": "space" }, { @@ -1906,60 +1162,32 @@ "text": "\n", "kind": "lineBreak" }, - { - "text": " ", - "kind": "space" - }, - { - "text": "}", - "kind": "punctuation" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "y", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, { "text": "}", "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/c.ts", + "position": 44, + "name": "5" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 41, + "length": 3 + }, + "displayParts": [ { - "text": "namespace", + "text": "class", "kind": "keyword" }, { @@ -1986,42 +1214,6 @@ "text": " ", "kind": "space" }, - { - "text": "new", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, { "text": "foo", "kind": "text" @@ -2054,33 +1246,25 @@ "text": "\n", "kind": "lineBreak" }, - { - "text": " ", - "kind": "space" - }, { "text": "}", "kind": "punctuation" }, - { - "text": ";", - "kind": "punctuation" - }, { "text": "\n", "kind": "lineBreak" }, { - "text": " ", - "kind": "space" + "text": "namespace", + "kind": "keyword" }, { - "text": "prototype", - "kind": "propertyName" + "text": " ", + "kind": "space" }, { - "text": ":", - "kind": "punctuation" + "text": "c5b", + "kind": "className" }, { "text": " ", @@ -2095,7 +1279,7 @@ "kind": "lineBreak" }, { - "text": " ", + "text": " ", "kind": "space" }, { @@ -2130,50 +1314,6 @@ "text": "\n", "kind": "lineBreak" }, - { - "text": " ", - "kind": "space" - }, - { - "text": "}", - "kind": "punctuation" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "y", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, { "text": "}", "kind": "punctuation" From bc99b1f8aafae547c8f31449c69eaac9a01d1a39 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 14 Mar 2025 16:46:27 -0700 Subject: [PATCH 05/31] don't expand when truncating; fix tuple --- src/compiler/checker.ts | 20 +- src/compiler/types.ts | 1 + src/services/symbolDisplay.ts | 4 +- .../quickinfoVerbosityRecursiveType.baseline | 1430 ++++++++++ .../quickinfoVerbosityTruncation.baseline | 385 +-- .../quickinfoVerbosityTuple.baseline | 2512 +++++++++++++++++ .../quickinfoVerbosityRecursiveType.ts | 34 + .../fourslash/quickinfoVerbosityTruncation.ts | 2 +- .../fourslash/quickinfoVerbosityTuple.ts | 28 + 9 files changed, 4064 insertions(+), 352 deletions(-) create mode 100644 tests/baselines/reference/quickinfoVerbosityRecursiveType.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityTuple.baseline create mode 100644 tests/cases/fourslash/quickinfoVerbosityRecursiveType.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityTuple.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 98f4d78939c0f..f4dc5e96c02cb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6063,7 +6063,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { verbosityLevel?: number, out?: WriterContextOut, ): string { - const noTruncation = compilerOptions.noErrorTruncation || flags & TypeFormatFlags.NoTruncation || verbosityLevel !== undefined; + const noTruncation = compilerOptions.noErrorTruncation || + flags & TypeFormatFlags.NoTruncation; const typeNode = nodeBuilder.typeToTypeNode( type, enclosingDeclaration, @@ -6409,6 +6410,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { depth: 0, typeStack: [], couldUnfoldMore: false, + truncated: false, }; context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost); const resultingNode = cb(context); @@ -6417,6 +6419,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } if (out) { out.couldUnfoldMore = context.couldUnfoldMore; + out.truncated = context.truncated; } return context.encounteredError ? undefined : resultingNode; } @@ -6464,8 +6467,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } // Determines if a type can be unfolded, based on how many layers of type aliases we're allowed to unfold. - function canUnfoldType(type: Type, context: NodeBuilderContext): boolean { - if (isUnfoldableType(type)) { + function canUnfoldType(type: Type, context: NodeBuilderContext, isAlias = false): boolean { + if (!isAlias && isLibType(type)) { return false; } for (let i = 0; i < context.typeStack.length - 1; i++) { @@ -6481,9 +6484,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } // Don't unfold types like `Array` or `Promise`, instead treating them as transparent. - function isUnfoldableType(type: Type): boolean { + function isLibType(type: Type): boolean { const symbol = (getObjectFlags(type) & ObjectFlags.Reference) !== 0 ? (type as TypeReference).target.symbol : type.symbol; - return !!(symbol?.declarations?.some(decl => host.isSourceFileDefaultLibrary(getSourceFileOfNode(decl)))) + return isTupleType(type) || !!(symbol?.declarations?.some(decl => host.isSourceFileDefaultLibrary(getSourceFileOfNode(decl)))); } function typeToTypeNodeHelper(type: Type, context: NodeBuilderContext): TypeNode { @@ -6637,7 +6640,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } if (!inTypeAlias && type.aliasSymbol && (context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - if (!canUnfoldType(type, context)) { + if (!canUnfoldType(type, context, true)) { const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & SymbolFlags.Class)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes); if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) { @@ -7358,6 +7361,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] | undefined { if (checkTruncationLength(context)) { + context.truncated = true; if (context.flags & NodeBuilderFlags.NoTruncation) { return [addSyntheticTrailingComment(factory.createNotEmittedTypeElement(), SyntaxKind.MultiLineCommentTrivia, "elided")]; } @@ -7392,6 +7396,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) { + context.truncated = true; if (context.flags & NodeBuilderFlags.NoTruncation) { const typeElement = typeElements.pop()!; typeElements.push(addSyntheticTrailingComment(typeElement, SyntaxKind.MultiLineCommentTrivia, `... ${properties.length - i} more elided ...`)); @@ -7572,6 +7577,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function mapToTypeNodes(types: readonly Type[] | undefined, context: NodeBuilderContext, isBareList?: boolean): TypeNode[] | undefined { if (some(types)) { if (checkTruncationLength(context)) { + context.truncated = true; if (!isBareList) { return [ context.flags & NodeBuilderFlags.NoTruncation @@ -7597,6 +7603,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { for (const type of types) { i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { + context.truncated = true; result.push( context.flags & NodeBuilderFlags.NoTruncation ? addSyntheticLeadingComment(factory.createKeywordTypeNode(SyntaxKind.AnyKeyword), SyntaxKind.MultiLineCommentTrivia, `... ${types.length - i} more elided ...`) @@ -53036,6 +53043,7 @@ interface NodeBuilderContext extends SyntacticTypeNodeBuilderContext { // Output couldUnfoldMore: boolean; // Whether we found a type alias that we could unfold but didn't + truncated: boolean; // Whether we did truncation. } class SymbolTrackerImpl implements SymbolTracker { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index e9daaaf4b9cd3..b2d8a3a7430a9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5053,6 +5053,7 @@ export interface TypeCheckerHost extends ModuleSpecifierResolutionHost, SourceFi /** @internal */ export interface WriterContextOut { couldUnfoldMore: boolean; + truncated: boolean; } export interface TypeChecker { diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index f8365cc0df898..3ebb36a108a1a 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -279,7 +279,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( let documentationFromAlias: SymbolDisplayPart[] | undefined; let tagsFromAlias: JSDocTagInfo[] | undefined; let hasMultipleSignatures = false; - const typeWriterOut: WriterContextOut | undefined = verbosityLevel !== undefined ? { couldUnfoldMore: false } : undefined; + const typeWriterOut: WriterContextOut = { couldUnfoldMore: false, truncated: false }; if (location.kind === SyntaxKind.ThisKeyword && !isThisExpression) { return { displayParts: [keywordPart(SyntaxKind.ThisKeyword)], documentation: [], symbolKind: ScriptElementKind.primitiveType, tags: undefined }; @@ -796,7 +796,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( documentation, symbolKind, tags: tags.length === 0 ? undefined : tags, - canIncreaseVerbosityLevel: typeWriterOut?.couldUnfoldMore, + canIncreaseVerbosityLevel: !typeWriterOut.truncated && typeWriterOut.couldUnfoldMore, }; function getPrinter() { diff --git a/tests/baselines/reference/quickinfoVerbosityRecursiveType.baseline b/tests/baselines/reference/quickinfoVerbosityRecursiveType.baseline new file mode 100644 index 0000000000000..c003523cc6385 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityRecursiveType.baseline @@ -0,0 +1,1430 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityRecursiveType.ts === +// type Node = { +// ^^^^ +// | ---------------------------------------------------------------------- +// | type Node = { +// | value: T; +// | left: Node; +// | right: Node; +// | } +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// value: T; +// left: Node | undefined; +// right: Node | undefined; +// } +// const n: Node = { +// ^ +// | ---------------------------------------------------------------------- +// | const n: { +// | value: number; +// | left: Node; +// | right: Node; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const n: Node +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// value: 1, +// left: undefined, +// right: undefined, +// } +// interface Orange { +// name: string; +// } +// type TreeNode = { +// ^^^^^^^^ +// | ---------------------------------------------------------------------- +// | type TreeNode = { +// | value: T; +// | left: TreeNode; +// | right: TreeNode; +// | orange?: { +// | name: string; +// | }; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^^^^ +// | ---------------------------------------------------------------------- +// | type TreeNode = { +// | value: T; +// | left: TreeNode; +// | right: TreeNode; +// | orange?: Orange; +// | } +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// value: T; +// left: TreeNode | undefined; +// right: TreeNode | undefined; +// orange?: Orange; +// } +// const m: TreeNode = { +// ^ +// | ---------------------------------------------------------------------- +// | const m: { +// | value: number; +// | left: TreeNode; +// | right: TreeNode; +// | orange?: { +// | name: string; +// | }; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const m: { +// | value: number; +// | left: TreeNode; +// | right: TreeNode; +// | orange?: Orange; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const m: TreeNode +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// value: 1, +// left: undefined, +// right: undefined, +// orange: { name: "orange" }, +// } + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityRecursiveType.ts", + "position": 9, + "name": "N" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 5, + "length": 4 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Node", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "value", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "left", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Node", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "right", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Node", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityRecursiveType.ts", + "position": 103, + "name": "n" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 102, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "n", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Node", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityRecursiveType.ts", + "position": 103, + "name": "n" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 102, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "n", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "value", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "left", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Node", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "right", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Node", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityRecursiveType.ts", + "position": 233, + "name": "t" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 225, + "length": 8 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TreeNode", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "value", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "left", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TreeNode", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "right", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TreeNode", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "orange", + "kind": "propertyName" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Orange", + "kind": "interfaceName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityRecursiveType.ts", + "position": 233, + "name": "t" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 225, + "length": 8 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TreeNode", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "value", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "left", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TreeNode", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "right", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TreeNode", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "orange", + "kind": "propertyName" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "name", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityRecursiveType.ts", + "position": 356, + "name": "m" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 355, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "m", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TreeNode", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityRecursiveType.ts", + "position": 356, + "name": "m" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 355, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "m", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "value", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "left", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TreeNode", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "right", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TreeNode", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "orange", + "kind": "propertyName" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Orange", + "kind": "interfaceName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityRecursiveType.ts", + "position": 356, + "name": "m" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 355, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "m", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "value", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "left", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TreeNode", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "right", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TreeNode", + "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "orange", + "kind": "propertyName" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "name", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityTruncation.baseline b/tests/baselines/reference/quickinfoVerbosityTruncation.baseline index b65773e3c335d..df94e7ad1d512 100644 --- a/tests/baselines/reference/quickinfoVerbosityTruncation.baseline +++ b/tests/baselines/reference/quickinfoVerbosityTruncation.baseline @@ -34,21 +34,16 @@ // | someLongPropertyName4: BarType; // | someLongPropertyName5: Str; // | someLongPropertyName6: FooType; -// | someLongPropertyName7: Sym; -// | someLongPropertyName8: BarType; -// | someLongMethodName1(a: FooType, b: BarType): Sym; -// | someLongPropertyName9: Str; -// | someLongPropertyName10: FooType; -// | someLongPropertyName11: Sym; -// | someLongPropertyName12: BarType; -// | someLongPropertyName13: Str; -// | someLongPropertyName14: FooType; -// | someLongPropertyName15: Sym; -// | someLongPropertyName16: BarType; +// | ... 11 more ...; // | someLongMethodName2(a: FooType, b: BarType): Sym; // | } // | (verbosity level: 1) // | ---------------------------------------------------------------------- +// ^^^^ +// | ---------------------------------------------------------------------- +// | const obj1: LotsOfProps +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- [ { @@ -86,292 +81,40 @@ "kind": "space" }, { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "someLongPropertyName1", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Str", - "kind": "aliasName" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "someLongPropertyName2", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "FooType", - "kind": "aliasName" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "someLongPropertyName3", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Sym", - "kind": "aliasName" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "someLongPropertyName4", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "BarType", - "kind": "aliasName" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "someLongPropertyName5", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Str", - "kind": "aliasName" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "someLongPropertyName6", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "FooType", - "kind": "aliasName" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "someLongPropertyName7", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Sym", - "kind": "aliasName" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "someLongPropertyName8", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "BarType", - "kind": "aliasName" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "someLongMethodName1", - "kind": "text" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "a", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "FooType", - "kind": "aliasName" - }, - { - "text": ",", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "b", - "kind": "parameterName" - }, + "text": "LotsOfProps", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTruncation.ts", + "position": 812, + "name": "o1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 808, + "length": 4 + }, + "displayParts": [ { - "text": ":", - "kind": "punctuation" + "text": "const", + "kind": "keyword" }, { "text": " ", "kind": "space" }, { - "text": "BarType", - "kind": "aliasName" - }, - { - "text": ")", - "kind": "punctuation" + "text": "obj1", + "kind": "localName" }, { "text": ":", @@ -382,11 +125,7 @@ "kind": "space" }, { - "text": "Sym", - "kind": "aliasName" - }, - { - "text": ";", + "text": "{", "kind": "punctuation" }, { @@ -398,7 +137,7 @@ "kind": "space" }, { - "text": "someLongPropertyName9", + "text": "someLongPropertyName1", "kind": "propertyName" }, { @@ -426,7 +165,7 @@ "kind": "space" }, { - "text": "someLongPropertyName10", + "text": "someLongPropertyName2", "kind": "propertyName" }, { @@ -454,7 +193,7 @@ "kind": "space" }, { - "text": "someLongPropertyName11", + "text": "someLongPropertyName3", "kind": "propertyName" }, { @@ -482,7 +221,7 @@ "kind": "space" }, { - "text": "someLongPropertyName12", + "text": "someLongPropertyName4", "kind": "propertyName" }, { @@ -510,7 +249,7 @@ "kind": "space" }, { - "text": "someLongPropertyName13", + "text": "someLongPropertyName5", "kind": "propertyName" }, { @@ -538,7 +277,7 @@ "kind": "space" }, { - "text": "someLongPropertyName14", + "text": "someLongPropertyName6", "kind": "propertyName" }, { @@ -566,49 +305,9 @@ "kind": "space" }, { - "text": "someLongPropertyName15", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Sym", - "kind": "aliasName" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "someLongPropertyName16", + "text": "... 11 more ...", "kind": "propertyName" }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "BarType", - "kind": "aliasName" - }, { "text": ";", "kind": "punctuation" @@ -699,7 +398,7 @@ } ], "documentation": [], - "canIncreaseVerbosityLevel": true, + "canIncreaseVerbosityLevel": false, "verbosityLevel": 1 } } diff --git a/tests/baselines/reference/quickinfoVerbosityTuple.baseline b/tests/baselines/reference/quickinfoVerbosityTuple.baseline new file mode 100644 index 0000000000000..78e92ac4ed3cd --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityTuple.baseline @@ -0,0 +1,2512 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityTuple.ts === +// interface Orange { +// color: string; +// } +// interface Apple { +// color: string; +// other: Orange; +// } +// type TwoFruits = [Orange, Apple]; +// ^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | type TwoFruits = [{ +// | color: string; +// | }, { +// | color: string; +// | other: { +// | color: string; +// | }; +// | }] +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | type TwoFruits = [{ +// | color: string; +// | }, { +// | color: string; +// | other: Orange; +// | }] +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | type TwoFruits = [Orange, Apple] +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// const tf: TwoFruits = [ +// ^^ +// | ---------------------------------------------------------------------- +// | const tf: [{ +// | color: string; +// | }, { +// | color: string; +// | other: { +// | color: string; +// | }; +// | }] +// | (verbosity level: 3) +// | ---------------------------------------------------------------------- +// ^^ +// | ---------------------------------------------------------------------- +// | const tf: [{ +// | color: string; +// | }, { +// | color: string; +// | other: Orange; +// | }] +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^ +// | ---------------------------------------------------------------------- +// | const tf: [Orange, Apple] +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^ +// | ---------------------------------------------------------------------- +// | const tf: TwoFruits +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// { color: "orange" }, +// { color: "red", other: { color: "orange" } } +// ]; +// const tf2: [Orange, Apple] = [ +// ^^^ +// | ---------------------------------------------------------------------- +// | const tf2: [{ +// | color: string; +// | }, { +// | color: string; +// | other: { +// | color: string; +// | }; +// | }] +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | const tf2: [{ +// | color: string; +// | }, { +// | color: string; +// | other: Orange; +// | }] +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | const tf2: [Orange, Apple] +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// { color: "orange" }, +// { color: "red", other: { color: "orange" } } +// ]; +// type ManyFruits = (Orange | Apple)[]; +// ^^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | type ManyFruits = ({ +// | color: string; +// | } | { +// | color: string; +// | other: { +// | color: string; +// | }; +// | })[] +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | type ManyFruits = ({ +// | color: string; +// | } | { +// | color: string; +// | other: Orange; +// | })[] +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | type ManyFruits = (Orange | Apple)[] +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// const mf: ManyFruits = []; +// ^^ +// | ---------------------------------------------------------------------- +// | const mf: ({ +// | color: string; +// | } | { +// | color: string; +// | other: { +// | color: string; +// | }; +// | })[] +// | (verbosity level: 3) +// | ---------------------------------------------------------------------- +// ^^ +// | ---------------------------------------------------------------------- +// | const mf: ({ +// | color: string; +// | } | { +// | color: string; +// | other: Orange; +// | })[] +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^ +// | ---------------------------------------------------------------------- +// | const mf: (Orange | Apple)[] +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^ +// | ---------------------------------------------------------------------- +// | const mf: ManyFruits +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 112, + "name": "T" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 103, + "length": 9 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TwoFruits", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "Orange", + "kind": "interfaceName" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 112, + "name": "T" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 103, + "length": 9 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TwoFruits", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "other", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Orange", + "kind": "interfaceName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 112, + "name": "T" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 103, + "length": 9 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TwoFruits", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "other", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 140, + "name": "f" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 138, + "length": 2 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "tf", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "TwoFruits", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 140, + "name": "f" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 138, + "length": 2 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "tf", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "Orange", + "kind": "interfaceName" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 140, + "name": "f" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 138, + "length": 2 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "tf", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "other", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Orange", + "kind": "interfaceName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 140, + "name": "f" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 138, + "length": 2 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "tf", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "other", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 3 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 242, + "name": "f2" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 239, + "length": 3 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "tf2", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "Orange", + "kind": "interfaceName" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 242, + "name": "f2" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 239, + "length": 3 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "tf2", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "other", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Orange", + "kind": "interfaceName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 242, + "name": "f2" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 239, + "length": 3 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "tf2", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "other", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 356, + "name": "m" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 346, + "length": 10 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ManyFruits", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "Orange", + "kind": "interfaceName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 356, + "name": "m" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 346, + "length": 10 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ManyFruits", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "other", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Orange", + "kind": "interfaceName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 356, + "name": "m" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 346, + "length": 10 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ManyFruits", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "other", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 387, + "name": "mf" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 385, + "length": 2 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "mf", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ManyFruits", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 387, + "name": "mf" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 385, + "length": 2 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "mf", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "Orange", + "kind": "interfaceName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 387, + "name": "mf" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 385, + "length": 2 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "mf", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "other", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Orange", + "kind": "interfaceName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTuple.ts", + "position": 387, + "name": "mf" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 385, + "length": 2 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "mf", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "other", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 3 + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityRecursiveType.ts b/tests/cases/fourslash/quickinfoVerbosityRecursiveType.ts new file mode 100644 index 0000000000000..8bd4d17edb297 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityRecursiveType.ts @@ -0,0 +1,34 @@ +/// + +//// type Node/*N*/ = { +//// value: T; +//// left: Node | undefined; +//// right: Node | undefined; +//// } +//// const n/*n*/: Node = { +//// value: 1, +//// left: undefined, +//// right: undefined, +//// } +//// interface Orange { +//// name: string; +//// } +//// type TreeNode/*t*/ = { +//// value: T; +//// left: TreeNode | undefined; +//// right: TreeNode | undefined; +//// orange?: Orange; +//// } +//// const m/*m*/: TreeNode = { +//// value: 1, +//// left: undefined, +//// right: undefined, +//// orange: { name: "orange" }, +//// } + +verify.baselineQuickInfo({ + "N": [0], + "n": [0, 1], + "t": [0, 1], + "m": [0, 1, 2], +}); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityTruncation.ts b/tests/cases/fourslash/quickinfoVerbosityTruncation.ts index b321761950d92..8c11276edb8be 100644 --- a/tests/cases/fourslash/quickinfoVerbosityTruncation.ts +++ b/tests/cases/fourslash/quickinfoVerbosityTruncation.ts @@ -28,4 +28,4 @@ //// const obj1/*o1*/: LotsOfProps = undefined as any as LotsOfProps; -verify.baselineQuickInfo({ "o1": [1], }); \ No newline at end of file +verify.baselineQuickInfo({ "o1": [0, 1], }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityTuple.ts b/tests/cases/fourslash/quickinfoVerbosityTuple.ts new file mode 100644 index 0000000000000..163dc4f0afa72 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityTuple.ts @@ -0,0 +1,28 @@ +/// + +//// interface Orange { +//// color: string; +//// } +//// interface Apple { +//// color: string; +//// other: Orange; +//// } +//// type TwoFruits/*T*/ = [Orange, Apple]; +//// const tf/*f*/: TwoFruits = [ +//// { color: "orange" }, +//// { color: "red", other: { color: "orange" } } +//// ]; +//// const tf2/*f2*/: [Orange, Apple] = [ +//// { color: "orange" }, +//// { color: "red", other: { color: "orange" } } +//// ]; +//// type ManyFruits/*m*/ = (Orange | Apple)[]; +//// const mf/*mf*/: ManyFruits = []; + +verify.baselineQuickInfo({ + "T": [0, 1, 2], + "f": [0, 1, 2, 3], + "f2": [0, 1, 2], + "m": [0, 1, 2], + "mf": [0, 1, 2, 3], +}); \ No newline at end of file From 44770e7a72af87d43ad0c8a62d235e77f9c50f86 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Mon, 17 Mar 2025 09:11:19 -0700 Subject: [PATCH 06/31] lint; test --- src/compiler/checker.ts | 6 +- src/services/symbolDisplay.ts | 3 +- .../quickinfoVerbosityTypeParameter.baseline | 70 +++++++++++++++++++ .../quickinfoVerbosityTypeParameter.ts | 4 +- 4 files changed, 78 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f4dc5e96c02cb..b217ef3d556c3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6491,9 +6491,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function typeToTypeNodeHelper(type: Type, context: NodeBuilderContext): TypeNode { const restoreFlags = saveRestoreFlags(context); - type && context.typeStack.push(type.id); + if (type) context.typeStack.push(type.id); const typeNode = typeToTypeNodeWorker(type, context); - type && context.typeStack.pop(); + if (type) context.typeStack.pop(); restoreFlags(); return typeNode; } @@ -6640,7 +6640,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } if (!inTypeAlias && type.aliasSymbol && (context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - if (!canUnfoldType(type, context, true)) { + if (!canUnfoldType(type, context, /*isAlias*/ true)) { const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & SymbolFlags.Class)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes); if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) { diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 3ebb36a108a1a..297e039a77696 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -791,12 +791,13 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( tags = tagsFromAlias; } + const canIncreaseVerbosityLevel = !typeWriterOut.truncated && typeWriterOut.couldUnfoldMore; return { displayParts, documentation, symbolKind, tags: tags.length === 0 ? undefined : tags, - canIncreaseVerbosityLevel: !typeWriterOut.truncated && typeWriterOut.couldUnfoldMore, + canIncreaseVerbosityLevel: verbosityLevel !== undefined ? canIncreaseVerbosityLevel : undefined }; function getPrinter() { diff --git a/tests/baselines/reference/quickinfoVerbosityTypeParameter.baseline b/tests/baselines/reference/quickinfoVerbosityTypeParameter.baseline index 78f8164cb43ba..41539f890cdcb 100644 --- a/tests/baselines/reference/quickinfoVerbosityTypeParameter.baseline +++ b/tests/baselines/reference/quickinfoVerbosityTypeParameter.baseline @@ -36,6 +36,12 @@ // | const y: (x: T) => void // | (verbosity level: 0) // | ---------------------------------------------------------------------- +// type MixinCtor
= new () => A & { constructor: MixinCtor }; +// ^ +// | ---------------------------------------------------------------------- +// | (type parameter) A in type MixinCtor +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- [ { @@ -685,5 +691,69 @@ "canIncreaseVerbosityLevel": false, "verbosityLevel": 2 } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts", + "position": 181, + "name": "a" + }, + "item": { + "kind": "type parameter", + "kindModifiers": "", + "textSpan": { + "start": 180, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "type parameter", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "A", + "kind": "typeParameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "in", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "MixinCtor", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 0 + } } ] \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts b/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts index 2f2dfc8ecb895..dccf12badf757 100644 --- a/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts +++ b/tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts @@ -6,9 +6,11 @@ //// x/*x*/; //// } //// const y/*y*/: (x: T) => void = fn; +//// type MixinCtor = new () => A/*a*/ & { constructor: MixinCtor }; verify.baselineQuickInfo({ "x": [0, 1, 2], - "y": [0, 1, 2] + "y": [0, 1, 2], + "a": [0], }); \ No newline at end of file From 06c5711dfe7569610b88374955256cd17430b71c Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Mon, 17 Mar 2025 09:54:56 -0700 Subject: [PATCH 07/31] fix type parameter printing, fix lib type at top level --- src/compiler/checker.ts | 14 +++-- src/compiler/types.ts | 1 + src/services/symbolDisplay.ts | 5 +- .../quickinfoVerbosityLibType.baseline | 56 +++++++++++++++++++ .../quickinfoVerbosityTypeParameter.baseline | 14 ++++- .../fourslash/quickinfoVerbosityLibType.ts | 8 ++- 6 files changed, 87 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b217ef3d556c3..c06d1ac7f8fb1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1933,6 +1933,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { typeHasCallOrConstructSignatures, getSymbolFlags, getTypeArgumentsForResolvedSignature, + isLibType, }; function getTypeArgumentsForResolvedSignature(signature: Signature) { @@ -6483,12 +6484,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return result; } - // Don't unfold types like `Array` or `Promise`, instead treating them as transparent. - function isLibType(type: Type): boolean { - const symbol = (getObjectFlags(type) & ObjectFlags.Reference) !== 0 ? (type as TypeReference).target.symbol : type.symbol; - return isTupleType(type) || !!(symbol?.declarations?.some(decl => host.isSourceFileDefaultLibrary(getSourceFileOfNode(decl)))); - } - function typeToTypeNodeHelper(type: Type, context: NodeBuilderContext): TypeNode { const restoreFlags = saveRestoreFlags(context); if (type) context.typeStack.push(type.id); @@ -10611,6 +10606,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } + /** Returns true if a type is declared in a lib file. */ + // Don't unfold types like `Array` or `Promise`, instead treating them as transparent. + function isLibType(type: Type): boolean { + const symbol = (getObjectFlags(type) & ObjectFlags.Reference) !== 0 ? (type as TypeReference).target.symbol : type.symbol; + return isTupleType(type) || !!(symbol?.declarations?.some(decl => host.isSourceFileDefaultLibrary(getSourceFileOfNode(decl)))); + } + function typePredicateToString(typePredicate: TypePredicate, enclosingDeclaration?: Node, flags: TypeFormatFlags = TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, writer?: EmitTextWriter): string { return writer ? typePredicateToStringWorker(writer).getText() : usingSingleLineStringWriter(typePredicateToStringWorker); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b2d8a3a7430a9..6faeda8adaef4 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5444,6 +5444,7 @@ export interface TypeChecker { /** @internal */ fillMissingTypeArguments(typeArguments: readonly Type[], typeParameters: readonly TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScriptImplicitAny: boolean): Type[]; getTypeArgumentsForResolvedSignature(signature: Signature): readonly Type[] | undefined; + /** @internal */ isLibType(type: Type): boolean; } /** @internal */ diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 297e039a77696..9ad4670755e9f 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -549,7 +549,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( displayParts.push(keywordPart(SyntaxKind.TypeKeyword)); displayParts.push(spacePart()); addFullSymbolName(declaration.symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); } } } @@ -824,13 +824,12 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( displayParts.push(spacePart()); } - // >> TODO: can this ever be called with depth > 0, i.e. not at the top level? function canUnfoldSymbol(symbol: Symbol, out: WriterContextOut | undefined): Type | undefined { if (verbosityLevel === undefined || !(symbol.flags & SymbolFlags.Type)) { return undefined; } const type = getTypeOfSymbol(symbol); - if (!type) { + if (!type || typeChecker.isLibType(type)) { return undefined; } if (0 < verbosityLevel) { diff --git a/tests/baselines/reference/quickinfoVerbosityLibType.baseline b/tests/baselines/reference/quickinfoVerbosityLibType.baseline index 991a156b93f5b..d4ec5e2e93ab7 100644 --- a/tests/baselines/reference/quickinfoVerbosityLibType.baseline +++ b/tests/baselines/reference/quickinfoVerbosityLibType.baseline @@ -35,6 +35,13 @@ // | const u: Map // | (verbosity level: 0) // | ---------------------------------------------------------------------- +// type Foo = Promise; +// ^^^^^^^ +// | ---------------------------------------------------------------------- +// | interface Promise +// | Represents the completion of an asynchronous operation +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- [ { @@ -452,5 +459,54 @@ "canIncreaseVerbosityLevel": false, "verbosityLevel": 1 } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityLibType.ts", + "position": 218, + "name": "p" + }, + "item": { + "kind": "interface", + "kindModifiers": "declare", + "textSpan": { + "start": 211, + "length": 7 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Promise", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [ + { + "text": "Represents the completion of an asynchronous operation", + "kind": "text" + } + ], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 0 + } } ] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityTypeParameter.baseline b/tests/baselines/reference/quickinfoVerbosityTypeParameter.baseline index 41539f890cdcb..4af6119b35d3e 100644 --- a/tests/baselines/reference/quickinfoVerbosityTypeParameter.baseline +++ b/tests/baselines/reference/quickinfoVerbosityTypeParameter.baseline @@ -39,7 +39,7 @@ // type MixinCtor = new () => A & { constructor: MixinCtor }; // ^ // | ---------------------------------------------------------------------- -// | (type parameter) A in type MixinCtor +// | (type parameter) A in type MixinCtor // | (verbosity level: 0) // | ---------------------------------------------------------------------- @@ -749,6 +749,18 @@ { "text": "MixinCtor", "kind": "aliasName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "A", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" } ], "documentation": [], diff --git a/tests/cases/fourslash/quickinfoVerbosityLibType.ts b/tests/cases/fourslash/quickinfoVerbosityLibType.ts index 5eb1aa2a134b6..c6f5ee46d0599 100644 --- a/tests/cases/fourslash/quickinfoVerbosityLibType.ts +++ b/tests/cases/fourslash/quickinfoVerbosityLibType.ts @@ -12,4 +12,10 @@ //// const g/*g*/ = f; //// const u/*u*/: Map = new Map; -verify.baselineQuickInfo({ "g": [0, 1], "u": [0, 1] }); \ No newline at end of file +//// type Foo = Promise/*p*/; + +verify.baselineQuickInfo({ + "g": [0, 1], + "u": [0, 1], + "p": [0], +}); \ No newline at end of file From e97074b0d7dc6bbecedd5202ff773f75e1d02b41 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Mon, 17 Mar 2025 11:43:01 -0700 Subject: [PATCH 08/31] fix top-level enum expansion --- src/compiler/checker.ts | 15 +- .../reference/quickinfoVerbosityEnum.baseline | 147 +----------------- 2 files changed, 16 insertions(+), 146 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c06d1ac7f8fb1..f843e28e20579 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7074,7 +7074,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (isGenericMappedType(type) || (type as MappedType).containsError) { return createMappedTypeNodeFromType(type as MappedType); } - const resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.indexInfos.length) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { @@ -7119,14 +7118,26 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const restoreFlags = saveRestoreFlags(context); context.flags |= NodeBuilderFlags.InObjectTypeLiteral; - const members = createTypeNodesFromResolvedType(resolved); + let members = createTypeNodesFromResolvedType(resolved); restoreFlags(); + // Simplify enum type when expanding it for quickinfo. + if (context.unfoldDepth > 0 && type.symbol && type.symbol.flags & SymbolFlags.Enum) { + members = mapDefined(members, simplifyEnumMember); + } const typeLiteralNode = factory.createTypeLiteralNode(members); context.approximateLength += 2; setEmitFlags(typeLiteralNode, (context.flags & NodeBuilderFlags.MultilineObjectLiterals) ? 0 : EmitFlags.SingleLine); return typeLiteralNode; } + function simplifyEnumMember(member: TypeElement): TypeElement | undefined { + // Skip printing reverse mapping signature. + if (member.kind === SyntaxKind.IndexSignature) { + return undefined; + } + return factory.createPropertySignature(/*modifiers*/ undefined, member.name!, /*questionToken*/ undefined, /*typeNode*/ undefined); + } + function typeReferenceToTypeNode(type: TypeReference) { let typeArguments: readonly Type[] = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { diff --git a/tests/baselines/reference/quickinfoVerbosityEnum.baseline b/tests/baselines/reference/quickinfoVerbosityEnum.baseline index ec01da2ce89e4..0b653c84bfae0 100644 --- a/tests/baselines/reference/quickinfoVerbosityEnum.baseline +++ b/tests/baselines/reference/quickinfoVerbosityEnum.baseline @@ -4,10 +4,9 @@ // ^^^^^ // | ---------------------------------------------------------------------- // | enum Color { -// | readonly [x: number]: string; -// | readonly Red: Color.Red; -// | readonly Green: Color.Green; -// | readonly Blue: Color.Blue; +// | Red; +// | Green; +// | Blue; // | } // | (verbosity level: 1) // | ---------------------------------------------------------------------- @@ -96,94 +95,10 @@ "text": " ", "kind": "space" }, - { - "text": "readonly", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "[", - "kind": "punctuation" - }, - { - "text": "x", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, - { - "text": "]", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "readonly", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, { "text": "Red", "kind": "propertyName" }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Color", - "kind": "enumName" - }, - { - "text": ".", - "kind": "punctuation" - }, - { - "text": "Red", - "kind": "text" - }, { "text": ";", "kind": "punctuation" @@ -196,38 +111,10 @@ "text": " ", "kind": "space" }, - { - "text": "readonly", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, { "text": "Green", "kind": "propertyName" }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Color", - "kind": "enumName" - }, - { - "text": ".", - "kind": "punctuation" - }, - { - "text": "Green", - "kind": "text" - }, { "text": ";", "kind": "punctuation" @@ -240,38 +127,10 @@ "text": " ", "kind": "space" }, - { - "text": "readonly", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, { "text": "Blue", "kind": "propertyName" }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Color", - "kind": "enumName" - }, - { - "text": ".", - "kind": "punctuation" - }, - { - "text": "Blue", - "kind": "text" - }, { "text": ";", "kind": "punctuation" From 8aa73139009c39dfadd9d28cac5699663be22ad6 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Mon, 17 Mar 2025 13:50:59 -0700 Subject: [PATCH 09/31] expand enum as type --- src/compiler/checker.ts | 18 +- .../reference/quickinfoVerbosityEnum.baseline | 155 ++++++++++++++++++ .../cases/fourslash/quickinfoVerbosityEnum.ts | 2 + 3 files changed, 170 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f843e28e20579..50b29f067ddec 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6467,7 +6467,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return context.depth < context.unfoldDepth || context.depth === context.unfoldDepth && !context.couldUnfoldMore; } - // Determines if a type can be unfolded, based on how many layers of type aliases we're allowed to unfold. + /** Determines if a type can be unfolded, based on how many layers of type aliases we're allowed to unfold. + * @param isAlias - Whether we're unfolding a type alias or not. + */ function canUnfoldType(type: Type, context: NodeBuilderContext, isAlias = false): boolean { if (!isAlias && isLibType(type)) { return false; @@ -6499,6 +6501,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } const inTypeAlias = context.flags & NodeBuilderFlags.InTypeAlias; context.flags &= ~NodeBuilderFlags.InTypeAlias; + let expandingEnum = false; if (!type) { if (!(context.flags & NodeBuilderFlags.AllowEmptyUnionOrIntersection)) { @@ -6567,7 +6570,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`."); } } - return symbolToTypeNode(type.symbol, context, SymbolFlags.Type); + if (!canUnfoldType(type, context)) { + return symbolToTypeNode(type.symbol, context, SymbolFlags.Type); + } + else { + expandingEnum = true; + } } if (type.flags & TypeFlags.StringLiteral) { context.approximateLength += (type as StringLiteralType).value.length + 2; @@ -6698,7 +6706,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { type = (type as UnionType).origin!; } if (type.flags & (TypeFlags.Union | TypeFlags.Intersection)) { - const types = type.flags & TypeFlags.Union ? formatUnionTypes((type as UnionType).types) : (type as IntersectionType).types; + const types = type.flags & TypeFlags.Union ? formatUnionTypes((type as UnionType).types, expandingEnum) : (type as IntersectionType).types; if (length(types) === 1) { return typeToTypeNodeHelper(types[0], context); } @@ -10637,14 +10645,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function formatUnionTypes(types: readonly Type[]): Type[] { + function formatUnionTypes(types: readonly Type[], expandingEnum: boolean): Type[] { const result: Type[] = []; let flags = 0 as TypeFlags; for (let i = 0; i < types.length; i++) { const t = types[i]; flags |= t.flags; if (!(t.flags & TypeFlags.Nullable)) { - if (t.flags & (TypeFlags.BooleanLiteral | TypeFlags.EnumLike)) { + if (t.flags & (TypeFlags.BooleanLiteral) || !expandingEnum && (t.flags | TypeFlags.EnumLike)) { const baseType = t.flags & TypeFlags.BooleanLiteral ? booleanType : getBaseTypeOfEnumLikeType(t as LiteralType); if (baseType.flags & TypeFlags.Union) { const count = (baseType as UnionType).types.length; diff --git a/tests/baselines/reference/quickinfoVerbosityEnum.baseline b/tests/baselines/reference/quickinfoVerbosityEnum.baseline index 0b653c84bfae0..ac558716a688d 100644 --- a/tests/baselines/reference/quickinfoVerbosityEnum.baseline +++ b/tests/baselines/reference/quickinfoVerbosityEnum.baseline @@ -19,6 +19,17 @@ // Green, // Blue, // } +// const x: Color = Color.Red; +// ^ +// | ---------------------------------------------------------------------- +// | const x: Color.Red | Color.Green | Color.Blue +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const x: Color +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- [ { @@ -148,5 +159,149 @@ "canIncreaseVerbosityLevel": false, "verbosityLevel": 1 } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", + "position": 52, + "name": "x" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 51, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "enumName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", + "position": 52, + "name": "x" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 51, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "enumName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Red", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "enumName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Green", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "enumName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Blue", + "kind": "text" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } } ] \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityEnum.ts b/tests/cases/fourslash/quickinfoVerbosityEnum.ts index 9876fc2ad0f07..81a12761a0301 100644 --- a/tests/cases/fourslash/quickinfoVerbosityEnum.ts +++ b/tests/cases/fourslash/quickinfoVerbosityEnum.ts @@ -5,7 +5,9 @@ //// Green, //// Blue, //// } +//// const x/*x*/: Color = Color.Red; verify.baselineQuickInfo({ c: [0, 1], + x: [0, 1], }); \ No newline at end of file From d4958f637dc8ccd52e72d89c5405bf9238eb56c2 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Wed, 19 Mar 2025 09:06:53 -0700 Subject: [PATCH 10/31] print top-level classes as declarations --- src/compiler/checker.ts | 108 + src/compiler/types.ts | 2 + src/services/symbolDisplay.ts | 70 +- .../quickinfoVerbosityClass1.baseline | 312 +- .../quickinfoVerbosityClass2.baseline | 2560 +++++++++++++++++ .../fourslash/quickinfoVerbosityClass1.ts | 5 +- .../fourslash/quickinfoVerbosityClass2.ts | 52 + 7 files changed, 2957 insertions(+), 152 deletions(-) create mode 100644 tests/baselines/reference/quickinfoVerbosityClass2.baseline create mode 100644 tests/cases/fourslash/quickinfoVerbosityClass2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 50b29f067ddec..b53c7d6a0c5da 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1134,6 +1134,7 @@ import { WithStatement, WriterContextOut, YieldExpression, + visitEachChild, } from "./_namespaces/ts.js"; import * as moduleSpecifiers from "./_namespaces/ts.moduleSpecifiers.js"; import * as performance from "./_namespaces/ts.performance.js"; @@ -1934,6 +1935,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { getSymbolFlags, getTypeArgumentsForResolvedSignature, isLibType, + classSymbolToNode: nodeBuilder.classSymbolToNode, }; function getTypeArgumentsForResolvedSignature(signature: Signature) { @@ -6308,6 +6310,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { typeParameterToDeclaration: (parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number, out?: WriterContextOut) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, context => typeParameterToDeclaration(parameter, context), out), symbolTableToDeclarationStatements: (symbolTable: SymbolTable, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolTableToDeclarationStatements(symbolTable, context)), symbolToNode: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolToNode(symbol, context, meaning)), + classSymbolToNode, }; function getTypeFromTypeNode(context: NodeBuilderContext, node: TypeNode, noMappedTypes?: false): Type; @@ -6367,6 +6370,111 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return symbolToExpression(symbol, context, meaning); } + function classSymbolToNode(symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number, out?: WriterContextOut): Node { + const classDeclarations = filter(symbol.declarations, isClassLike); + if (!classDeclarations || classDeclarations.length === 0) { + Debug.fail("Expected class symbol to have a declaration"); + } + // A valid program should only have one class declaration per class symbol. + const classDeclaration = classDeclarations[0] as ClassDeclaration; + const node = withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, context => classToNodeHelper(classDeclaration, context), out); + if (node === undefined) { + Debug.fail("Should always get a node"); + } + return node; + } + + /** Transforms a class-like declaration into a simplified class-like declaration for quickinfo purposes. + * Type nodes are possibly expanded, inferred types are added, and initializers and function bodies are removed. + */ + function classToNodeHelper(declaration: Declaration, context: NodeBuilderContext): Node { + function visit(node: Node): Node | undefined { + const originalNode = node; + if (isTypeNode(node)) { + if (node.parent.kind === SyntaxKind.HeritageClause) { + return node; + } + const type = getTypeFromTypeNode(context, node); + return typeToTypeNodeHelper(type, context); + } + switch (node.kind) { + case SyntaxKind.Constructor: + node = factory.updateConstructorDeclaration( + node as ConstructorDeclaration, + (node as ConstructorDeclaration).modifiers, + (node as ConstructorDeclaration).parameters, + /*body*/ undefined, + ); + break; + case SyntaxKind.MethodDeclaration: + node = factory.updateMethodDeclaration( + node as MethodDeclaration, + (node as MethodDeclaration).modifiers, + (node as MethodDeclaration).asteriskToken, + (node as MethodDeclaration).name, + (node as MethodDeclaration).questionToken, + (node as MethodDeclaration).typeParameters, + (node as MethodDeclaration).parameters, + (node as MethodDeclaration).type, + /*body*/ undefined, + ); + break; + case SyntaxKind.GetAccessor: + node = factory.updateGetAccessorDeclaration( + node as GetAccessorDeclaration, + (node as GetAccessorDeclaration).modifiers, + (node as GetAccessorDeclaration).name, + (node as GetAccessorDeclaration).parameters, + (node as GetAccessorDeclaration).type, + /*body*/ undefined, + ); + break; + case SyntaxKind.SetAccessor: + node = factory.updateSetAccessorDeclaration( + node as SetAccessorDeclaration, + (node as SetAccessorDeclaration).modifiers, + (node as SetAccessorDeclaration).name, + (node as SetAccessorDeclaration).parameters, + /*body*/ undefined, + ); + break; + case SyntaxKind.PropertyDeclaration: + node = factory.updatePropertyDeclaration( + node as PropertyDeclaration, + (node as PropertyDeclaration).modifiers, + (node as PropertyDeclaration).name, + (node as PropertyDeclaration).questionToken, + (node as PropertyDeclaration).type, + /*initializer*/ undefined, + ) + break; + case SyntaxKind.ClassStaticBlockDeclaration: + case SyntaxKind.SemicolonClassElement: + // Remove altogether. + return undefined; + case SyntaxKind.IndexSignature: + // Preserve. + } + const newNode = visitEachChild(node, visit, /*context*/ undefined); + if (newNode.kind === SyntaxKind.PropertyDeclaration && !(newNode as PropertyDeclaration).type) { + const symbol = getSymbolOfDeclaration(originalNode as PropertyDeclaration); + const type = getTypeOfSymbol(symbol); + const typeNode = typeToTypeNodeHelper(type, context); + return factory.updatePropertyDeclaration( + newNode as PropertyDeclaration, + (newNode as PropertyDeclaration).modifiers, + (newNode as PropertyDeclaration).name, + (newNode as PropertyDeclaration).questionToken, + typeNode, + /*initializer*/ undefined, + ); + } + return newNode; + } + const newDecl = visit(declaration)!; + return newDecl; + } + function withContext( enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6faeda8adaef4..a353f36f18b84 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5445,6 +5445,8 @@ export interface TypeChecker { getTypeArgumentsForResolvedSignature(signature: Signature): readonly Type[] | undefined; /** @internal */ isLibType(type: Type): boolean; + /** @internal */ classSymbolToNode(symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number, out?: WriterContextOut): Node | undefined; + } /** @internal */ diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 9ad4670755e9f..84214d13f8c02 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -20,6 +20,7 @@ import { getCombinedLocalAndExportSymbolFlags, getDeclarationOfKind, getExternalModuleImportEqualsDeclarationExpression, + getIndentString, getMeaningFromLocation, getNameOfDeclaration, getNodeModifiers, @@ -37,6 +38,7 @@ import { isCallExpression, isCallExpressionTarget, isCallOrNewExpression, + isClassDeclaration, isClassExpression, isConstTypeReference, isDeprecatedDeclaration, @@ -69,6 +71,7 @@ import { length, lineBreakPart, ListFormat, + map, mapToDisplayParts, ModifierFlags, ModuleDeclaration, @@ -445,20 +448,23 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( } if (symbolFlags & SymbolFlags.Class && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (getDeclarationOfKind(symbol, SyntaxKind.ClassExpression)) { + const classExpression = getDeclarationOfKind(symbol, SyntaxKind.ClassExpression); + if (classExpression) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class pushSymbolKind(ScriptElementKind.localClassElement); + displayParts.push(spacePart()); } - else { - // Class declaration has name which is not local. - displayParts.push(keywordPart(SyntaxKind.ClassKeyword)); + if (!tryUnfoldSymbol(symbol)) { + if (!classExpression) { + // Class declaration has name which is not local. + displayParts.push(keywordPart(SyntaxKind.ClassKeyword)); + displayParts.push(spacePart()); + } + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); } - displayParts.push(spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); - tryUnfoldSymbol(symbol); } if ((symbolFlags & SymbolFlags.Interface) && (semanticMeaning & SemanticMeaning.Type)) { prefixNextMeaning(); @@ -848,20 +854,46 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( return typeChecker.getTypeOfSymbolAtLocation(symbol, location); } - function tryUnfoldSymbol(symbol: Symbol) { + function tryUnfoldSymbol(symbol: Symbol): boolean { let unfoldType; if (unfoldType = canUnfoldSymbol(symbol, typeWriterOut)) { - const expandedDisplayParts = typeToDisplayParts( - typeChecker, - unfoldType, - enclosingDeclaration || sourceFile, - /*flags*/ undefined, - verbosityLevel, - typeWriterOut, - ); - displayParts.push(spacePart()); - addRange(displayParts, expandedDisplayParts); + if (symbol.flags & SymbolFlags.Enum) { + // >> TODO: probably add enum printing as enum declaration at the top level; add it to return of `createNodeBuilder`. + } + else if (symbol.flags & SymbolFlags.Class) { + let expandedDisplayParts = mapToDisplayParts(writer => { + const node = typeChecker.classSymbolToNode( + symbol, + undefined, + TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, + undefined, + undefined, + verbosityLevel !== undefined ? verbosityLevel - 1 : undefined, + typeWriterOut)!; + getPrinter().writeNode(EmitHint.Unspecified, node, sourceFile, writer); + }); + let start = 0; + while (start < expandedDisplayParts.length && + expandedDisplayParts[start].kind === SymbolDisplayPartKind[SymbolDisplayPartKind.lineBreak]) { + start++; + } + addRange(displayParts, expandedDisplayParts, start); + } + else { + const expandedDisplayParts = typeToDisplayParts( + typeChecker, + unfoldType, + enclosingDeclaration || sourceFile, + /*flags*/ undefined, + verbosityLevel, + typeWriterOut, + ); + displayParts.push(spacePart()); + addRange(displayParts, expandedDisplayParts); + } + return true; } + return false; } function addFullSymbolName(symbolToDisplay: Symbol, enclosingDeclaration?: Node) { diff --git a/tests/baselines/reference/quickinfoVerbosityClass1.baseline b/tests/baselines/reference/quickinfoVerbosityClass1.baseline index cd101e72dbec8..ba0fa94e7120b 100644 --- a/tests/baselines/reference/quickinfoVerbosityClass1.baseline +++ b/tests/baselines/reference/quickinfoVerbosityClass1.baseline @@ -51,6 +51,20 @@ // } // { // class Bar { +// ^^^ +// | ---------------------------------------------------------------------- +// | class Bar { +// | a: string; +// | bar(): void; +// | baz(param: string): void; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | class Bar +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- // a!: string; // bar(): void {} // baz(param: string): void {} @@ -91,14 +105,6 @@ // | bar(param: string): void; // | baz(): Bar; // | } -// | (verbosity level: 2) -// | ---------------------------------------------------------------------- -// ^ -// | ---------------------------------------------------------------------- -// | const b: { -// | bar(param: string): void; -// | baz(): Bar; -// | } // | (verbosity level: 1) // | ---------------------------------------------------------------------- // ^ @@ -632,19 +638,19 @@ { "marker": { "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", - "position": 491, - "name": "f3" + "position": 283, + "name": "B" }, "item": { - "kind": "const", + "kind": "class", "kindModifiers": "", "textSpan": { - "start": 490, - "length": 1 + "start": 280, + "length": 3 }, "displayParts": [ { - "text": "const", + "text": "class", "kind": "keyword" }, { @@ -652,19 +658,7 @@ "kind": "space" }, { - "text": "f", - "kind": "localName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Foo", + "text": "Bar", "kind": "className" } ], @@ -676,19 +670,19 @@ { "marker": { "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", - "position": 491, - "name": "f3" + "position": 283, + "name": "B" }, "item": { - "kind": "const", + "kind": "class", "kindModifiers": "", "textSpan": { - "start": 490, - "length": 1 + "start": 280, + "length": 3 }, "displayParts": [ { - "text": "const", + "text": "class", "kind": "keyword" }, { @@ -696,12 +690,8 @@ "kind": "space" }, { - "text": "f", - "kind": "localName" - }, - { - "text": ":", - "kind": "punctuation" + "text": "Bar", + "kind": "text" }, { "text": " ", @@ -720,8 +710,8 @@ "kind": "space" }, { - "text": "b", - "kind": "propertyName" + "text": "a", + "kind": "text" }, { "text": ":", @@ -732,7 +722,7 @@ "kind": "space" }, { - "text": "boolean", + "text": "string", "kind": "keyword" }, { @@ -748,45 +738,13 @@ "kind": "space" }, { - "text": "baz", + "text": "bar", "kind": "text" }, { "text": "(", "kind": "punctuation" }, - { - "text": "param", - "kind": "parameterName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "|", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, { "text": ")", "kind": "punctuation" @@ -816,40 +774,28 @@ "kind": "space" }, { - "text": "a", - "kind": "propertyName" + "text": "baz", + "kind": "text" }, { - "text": ":", + "text": "(", "kind": "punctuation" }, { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" + "text": "param", + "kind": "parameterName" }, { - "text": ";", + "text": ":", "kind": "punctuation" }, { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", + "text": " ", "kind": "space" }, { - "text": "bar", - "kind": "text" - }, - { - "text": "(", - "kind": "punctuation" + "text": "string", + "kind": "keyword" }, { "text": ")", @@ -888,14 +834,14 @@ { "marker": { "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", - "position": 706, - "name": "b1" + "position": 491, + "name": "f3" }, "item": { "kind": "const", "kindModifiers": "", "textSpan": { - "start": 705, + "start": 490, "length": 1 }, "displayParts": [ @@ -908,7 +854,7 @@ "kind": "space" }, { - "text": "b", + "text": "f", "kind": "localName" }, { @@ -920,20 +866,8 @@ "kind": "space" }, { - "text": "Bar", + "text": "Foo", "kind": "className" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" } ], "documentation": [], @@ -944,14 +878,14 @@ { "marker": { "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", - "position": 706, - "name": "b1" + "position": 491, + "name": "f3" }, "item": { "kind": "const", "kindModifiers": "", "textSpan": { - "start": 705, + "start": 490, "length": 1 }, "displayParts": [ @@ -964,7 +898,7 @@ "kind": "space" }, { - "text": "b", + "text": "f", "kind": "localName" }, { @@ -988,7 +922,35 @@ "kind": "space" }, { - "text": "bar", + "text": "b", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "baz", "kind": "text" }, { @@ -1011,6 +973,22 @@ "text": "string", "kind": "keyword" }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, { "text": ")", "kind": "punctuation" @@ -1040,7 +1018,35 @@ "kind": "space" }, { - "text": "baz", + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", "kind": "text" }, { @@ -1060,37 +1066,81 @@ "kind": "space" }, { - "text": "Bar", - "kind": "className" + "text": "void", + "kind": "keyword" }, { - "text": "<", + "text": ";", "kind": "punctuation" }, { - "text": "string", + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass1.ts", + "position": 706, + "name": "b1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 705, + "length": 1 + }, + "displayParts": [ + { + "text": "const", "kind": "keyword" }, { - "text": ">", + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "localName" + }, + { + "text": ":", "kind": "punctuation" }, { - "text": ";", + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "className" + }, + { + "text": "<", "kind": "punctuation" }, { - "text": "\n", - "kind": "lineBreak" + "text": "string", + "kind": "keyword" }, { - "text": "}", + "text": ">", "kind": "punctuation" } ], "documentation": [], - "canIncreaseVerbosityLevel": false, - "verbosityLevel": 1 + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 } }, { @@ -1242,7 +1292,7 @@ ], "documentation": [], "canIncreaseVerbosityLevel": false, - "verbosityLevel": 2 + "verbosityLevel": 1 } }, { diff --git a/tests/baselines/reference/quickinfoVerbosityClass2.baseline b/tests/baselines/reference/quickinfoVerbosityClass2.baseline new file mode 100644 index 0000000000000..33489efb3686f --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityClass2.baseline @@ -0,0 +1,2560 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityClass2.ts === +// interface Apple { +// color: string; +// } +// class Foo { +// ^^^ +// | ---------------------------------------------------------------------- +// | class Foo { +// | constructor(public x: T); +// | public y: T; +// | static whatever(): void; +// | private foo(): { +// | color: string; +// | }; +// | protected z: boolean; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | class Foo { +// | constructor(public x: T); +// | public y: T; +// | static whatever(): void; +// | private foo(): Apple; +// | protected z: boolean; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | class Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// constructor(public x: T) { } +// public y!: T; +// static whatever(): void { } +// private foo(): Apple { return { color: "green" }; } +// static { +// const a = class { x?: Apple; }; +// } +// protected z = true; +// } +// type Whatever = Foo; +// ^^^^^^^^ +// | ---------------------------------------------------------------------- +// | type Whatever = { +// | x: string; +// | y: string; +// | foo(): { +// | color: string; +// | }; +// | z: boolean; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^^^^^^ +// | ---------------------------------------------------------------------- +// | type Whatever = { +// | x: string; +// | y: string; +// | foo(): Apple; +// | z: boolean; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^^^^ +// | ---------------------------------------------------------------------- +// | type Whatever = Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// const a = Foo; +// ^ +// | ---------------------------------------------------------------------- +// | const a: { +// | new (x: T): Foo; +// | prototype: Foo; +// | whatever(): void; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const a: typeof Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// const c = Foo; +// ^ +// | ---------------------------------------------------------------------- +// | const c: { +// | new (x: string): Foo; +// | prototype: Foo; +// | whatever(): void; +// | } +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// [1].forEach(class { +// ^^^^^ +// | ---------------------------------------------------------------------- +// | (local class) class { +// | constructor(public x: T); +// | public y: T; +// | static whatever(): void; +// | private foo(): { +// | color: string; +// | }; +// | protected z: boolean; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^^^ +// | ---------------------------------------------------------------------- +// | (local class) class { +// | constructor(public x: T); +// | public y: T; +// | static whatever(): void; +// | private foo(): Apple; +// | protected z: boolean; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^ +// | ---------------------------------------------------------------------- +// | (local class) (Anonymous class) +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// constructor(public x: T) { } +// public y!: T; +// static whatever(): void { } +// private foo(): Apple { return { color: "green" }; } +// static { +// const a = class { x?: Apple; }; +// } +// protected z = true; +// }); +// const b = Bar; +// ^ +// | ---------------------------------------------------------------------- +// | const b: any +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// @random() +// abstract class Animal { +// ^^^^^^ +// | ---------------------------------------------------------------------- +// | @random() +// | abstract class Animal { +// | name: string; +// | abstract makeSound(): void; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^^ +// | ---------------------------------------------------------------------- +// | class Animal +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// name!: string; +// abstract makeSound(): void; +// } + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 48, + "name": "1" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 45, + "length": 3 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 48, + "name": "1" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 45, + "length": 3 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "text" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "constructor", + "kind": "keyword" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "public", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "public", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "static", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "whatever", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "private", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "protected", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "z", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 48, + "name": "1" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 45, + "length": 3 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "text" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "constructor", + "kind": "keyword" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "public", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "public", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "static", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "whatever", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "private", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "protected", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "z", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 291, + "name": "2" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 283, + "length": 8 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Whatever", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 291, + "name": "2" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 283, + "length": 8 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Whatever", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "z", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 291, + "name": "2" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 283, + "length": 8 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Whatever", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "z", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 314, + "name": "3" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 313, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "typeof", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 314, + "name": "3" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 313, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "new", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prototype", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "any", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "whatever", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 329, + "name": "4" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 328, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "new", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prototype", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "any", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "whatever", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 362, + "name": "5" + }, + "item": { + "kind": "local class", + "kindModifiers": "", + "textSpan": { + "start": 357, + "length": 5 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "local class", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(Anonymous class)", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 362, + "name": "5" + }, + "item": { + "kind": "local class", + "kindModifiers": "", + "textSpan": { + "start": 357, + "length": 5 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "local class", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "class", + "kind": "keyword" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "text" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "constructor", + "kind": "keyword" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "public", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "public", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "static", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "whatever", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "private", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "protected", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "z", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 362, + "name": "5" + }, + "item": { + "kind": "local class", + "kindModifiers": "", + "textSpan": { + "start": 357, + "length": 5 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "local class", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "class", + "kind": "keyword" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "text" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "constructor", + "kind": "keyword" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "public", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "public", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "static", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "whatever", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "private", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "color", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "protected", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "z", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 602, + "name": "6" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 601, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 649, + "name": "7" + }, + "item": { + "kind": "class", + "kindModifiers": "abstract", + "textSpan": { + "start": 643, + "length": 6 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Animal", + "kind": "className" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 649, + "name": "7" + }, + "item": { + "kind": "class", + "kindModifiers": "abstract", + "textSpan": { + "start": 643, + "length": 6 + }, + "displayParts": [ + { + "text": "@", + "kind": "punctuation" + }, + { + "text": "random", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "abstract", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Animal", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "name", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "abstract", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "makeSound", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityClass1.ts b/tests/cases/fourslash/quickinfoVerbosityClass1.ts index fd63a56939dec..917b57489c629 100644 --- a/tests/cases/fourslash/quickinfoVerbosityClass1.ts +++ b/tests/cases/fourslash/quickinfoVerbosityClass1.ts @@ -21,7 +21,7 @@ //// } // inheritance //// { -//// class Bar { +//// class Bar/*B*/ { //// a!: string; //// bar(): void {} //// baz(param: string): void {} @@ -64,8 +64,9 @@ verify.baselineQuickInfo({ f1: [0, 1], f2: [0, 1, 2], f3: [0, 1], - b1: [0, 1, 2], + b1: [0, 1], f4: [0, 1], n1: [0, 1], k1: [0, 1], + B: [0, 1], }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityClass2.ts b/tests/cases/fourslash/quickinfoVerbosityClass2.ts new file mode 100644 index 0000000000000..8b3187a0d5206 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityClass2.ts @@ -0,0 +1,52 @@ +/// + + +//// interface Apple { +//// color: string; +//// } + +//// class Foo/*1*/ { +//// constructor(public x: T) { } +//// public y!: T; +//// static whatever(): void { } +//// private foo(): Apple { return { color: "green" }; } +//// static { +//// const a = class { x?: Apple; }; +//// } +//// protected z = true; +//// } + +//// type Whatever/*2*/ = Foo; +//// const a/*3*/ = Foo; +//// const c/*4*/ = Foo; + +//// [1].forEach(class/*5*/ { +//// constructor(public x: T) { } +//// public y!: T; +//// static whatever(): void { } +//// private foo(): Apple { return { color: "green" }; } +//// static { +//// const a = class { x?: Apple; }; +//// } +//// protected z = true; +//// }); + +//// const b/*6*/ = Bar; + +//// @random() +//// abstract class Animal/*7*/ { +//// name!: string; + +//// abstract makeSound(): void; +//// } + + +verify.baselineQuickInfo({ + 1: [0, 1, 2], + 2: [0, 1, 2], + 3: [0, 1], + 4: [0], + 5: [0, 1, 2], + 6: [0], + 7: [0, 1], +}); \ No newline at end of file From a7a334f867b82a94eaa65a4dd43419f103761877 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Wed, 19 Mar 2025 14:36:16 -0700 Subject: [PATCH 11/31] add class and enum declaration printing --- src/compiler/checker.ts | 270 +++--- src/compiler/types.ts | 5 +- src/services/symbolDisplay.ts | 37 +- .../quickinfoVerbosityClass2.baseline | 798 ++++++++++++++---- .../reference/quickinfoVerbosityEnum.baseline | 370 +++++++- .../fourslash/quickinfoVerbosityClass2.ts | 8 + .../cases/fourslash/quickinfoVerbosityEnum.ts | 8 + 7 files changed, 1155 insertions(+), 341 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b53c7d6a0c5da..6001c6cd9e2b7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1935,7 +1935,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { getSymbolFlags, getTypeArgumentsForResolvedSignature, isLibType, - classSymbolToNode: nodeBuilder.classSymbolToNode, + classSymbolToDeclaration: nodeBuilder.classSymbolToDeclaration, + enumSymbolToDeclaration: nodeBuilder.enumSymbolToDeclaration, }; function getTypeArgumentsForResolvedSignature(signature: Signature) { @@ -6310,7 +6311,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { typeParameterToDeclaration: (parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number, out?: WriterContextOut) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, context => typeParameterToDeclaration(parameter, context), out), symbolTableToDeclarationStatements: (symbolTable: SymbolTable, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolTableToDeclarationStatements(symbolTable, context)), symbolToNode: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolToNode(symbol, context, meaning)), - classSymbolToNode, + classSymbolToDeclaration, + enumSymbolToDeclaration, }; function getTypeFromTypeNode(context: NodeBuilderContext, node: TypeNode, noMappedTypes?: false): Type; @@ -6370,109 +6372,72 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return symbolToExpression(symbol, context, meaning); } - function classSymbolToNode(symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number, out?: WriterContextOut): Node { + function classSymbolToDeclaration(symbol: Symbol, flags: NodeBuilderFlags, verbosityLevel?: number, out?: WriterContextOut): Declaration { const classDeclarations = filter(symbol.declarations, isClassLike); if (!classDeclarations || classDeclarations.length === 0) { Debug.fail("Expected class symbol to have a declaration"); } - // A valid program should only have one class declaration per class symbol. - const classDeclaration = classDeclarations[0] as ClassDeclaration; - const node = withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, context => classToNodeHelper(classDeclaration, context), out); - if (node === undefined) { - Debug.fail("Should always get a node"); - } + const modifiers = getModifiers(classDeclarations[0]); + const isAnonymous = isClassExpression(classDeclarations[0]); + const instanceType = getDeclaredTypeOfSymbol(symbol); + const node = withContext( + /*enclosingDeclaration*/ undefined, + flags, + /*internalFlags*/ undefined, + /*tracker*/ undefined, + verbosityLevel, + context => classSymbolToDeclarationWorker(symbol, instanceType.id, isAnonymous, modifiers, context), + out); + Debug.assert(node !== undefined, "Should always get a node"); return node; } - /** Transforms a class-like declaration into a simplified class-like declaration for quickinfo purposes. - * Type nodes are possibly expanded, inferred types are added, and initializers and function bodies are removed. - */ - function classToNodeHelper(declaration: Declaration, context: NodeBuilderContext): Node { - function visit(node: Node): Node | undefined { - const originalNode = node; - if (isTypeNode(node)) { - if (node.parent.kind === SyntaxKind.HeritageClause) { - return node; - } - const type = getTypeFromTypeNode(context, node); - return typeToTypeNodeHelper(type, context); - } - switch (node.kind) { - case SyntaxKind.Constructor: - node = factory.updateConstructorDeclaration( - node as ConstructorDeclaration, - (node as ConstructorDeclaration).modifiers, - (node as ConstructorDeclaration).parameters, - /*body*/ undefined, - ); - break; - case SyntaxKind.MethodDeclaration: - node = factory.updateMethodDeclaration( - node as MethodDeclaration, - (node as MethodDeclaration).modifiers, - (node as MethodDeclaration).asteriskToken, - (node as MethodDeclaration).name, - (node as MethodDeclaration).questionToken, - (node as MethodDeclaration).typeParameters, - (node as MethodDeclaration).parameters, - (node as MethodDeclaration).type, - /*body*/ undefined, - ); - break; - case SyntaxKind.GetAccessor: - node = factory.updateGetAccessorDeclaration( - node as GetAccessorDeclaration, - (node as GetAccessorDeclaration).modifiers, - (node as GetAccessorDeclaration).name, - (node as GetAccessorDeclaration).parameters, - (node as GetAccessorDeclaration).type, - /*body*/ undefined, - ); - break; - case SyntaxKind.SetAccessor: - node = factory.updateSetAccessorDeclaration( - node as SetAccessorDeclaration, - (node as SetAccessorDeclaration).modifiers, - (node as SetAccessorDeclaration).name, - (node as SetAccessorDeclaration).parameters, - /*body*/ undefined, - ); - break; - case SyntaxKind.PropertyDeclaration: - node = factory.updatePropertyDeclaration( - node as PropertyDeclaration, - (node as PropertyDeclaration).modifiers, - (node as PropertyDeclaration).name, - (node as PropertyDeclaration).questionToken, - (node as PropertyDeclaration).type, - /*initializer*/ undefined, - ) - break; - case SyntaxKind.ClassStaticBlockDeclaration: - case SyntaxKind.SemicolonClassElement: - // Remove altogether. - return undefined; - case SyntaxKind.IndexSignature: - // Preserve. - } - const newNode = visitEachChild(node, visit, /*context*/ undefined); - if (newNode.kind === SyntaxKind.PropertyDeclaration && !(newNode as PropertyDeclaration).type) { - const symbol = getSymbolOfDeclaration(originalNode as PropertyDeclaration); - const type = getTypeOfSymbol(symbol); - const typeNode = typeToTypeNodeHelper(type, context); - return factory.updatePropertyDeclaration( - newNode as PropertyDeclaration, - (newNode as PropertyDeclaration).modifiers, - (newNode as PropertyDeclaration).name, - (newNode as PropertyDeclaration).questionToken, - typeNode, - /*initializer*/ undefined, - ); - } - return newNode; + function classSymbolToDeclarationWorker( + symbol: Symbol, + instanceTypeId: number, + isAnonymous: boolean, + originalModifiers: readonly Modifier[] | undefined, + context: NodeBuilderContext): Declaration { + // We're already expanding the class type: set it in the stack to avoid expanding it again. + context.typeStack.push(instanceTypeId); + context.typeStack.push(-1); + const table = createSymbolTable([symbol]); + const stmts = symbolTableToDeclarationStatements(table, context); + Debug.assert(stmts.length === 1 && isClassDeclaration(stmts[0]), "Expected a single class declaration."); + let classDecl = stmts[0] as ClassDeclaration; + if (isAnonymous) { + classDecl = factory.updateClassDeclaration( + classDecl, + classDecl.modifiers, + /*name*/ undefined, + classDecl.typeParameters, + classDecl.heritageClauses, + classDecl.members, + ); } - const newDecl = visit(declaration)!; - return newDecl; + return factory.replaceModifiers(classDecl, originalModifiers); + } + + function enumSymbolToDeclaration(symbol: Symbol, flags: NodeBuilderFlags, verbosityLevel?: number, out?: WriterContextOut): Declaration { + const node = withContext( + /*enclosingDeclaration*/ undefined, + flags, + /*internalFlags*/ undefined, + /*tracker*/ undefined, + verbosityLevel, + context => enumSymbolToDeclarationWorker(symbol, context), + out); + Debug.assert(node !== undefined, "Should always get a node"); + return node; + } + + function enumSymbolToDeclarationWorker(symbol: Symbol, context: NodeBuilderContext): Declaration { + const table = createSymbolTable([symbol]); + const stmts = symbolTableToDeclarationStatements(table, context); + Debug.assert(stmts.length === 1 && isEnumDeclaration(stmts[0]), "Expected a single enum declaration."); + const enumDecl = stmts[0] as EnumDeclaration; + const modifiers = getModifiers(enumDecl)?.filter(modifier => modifier.kind !== SyntaxKind.DeclareKeyword); + return factory.replaceModifiers(enumDecl, modifiers); } function withContext( @@ -6518,8 +6483,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { mapper: undefined, depth: 0, typeStack: [], - couldUnfoldMore: false, - truncated: false, + out: { + couldUnfoldMore: false, + truncated: false, + } }; context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost); const resultingNode = cb(context); @@ -6527,8 +6494,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { context.tracker.reportTruncationError(); } if (out) { - out.couldUnfoldMore = context.couldUnfoldMore; - out.truncated = context.truncated; + out.couldUnfoldMore = context.out.couldUnfoldMore; + out.truncated = context.out.truncated; } return context.encounteredError ? undefined : resultingNode; } @@ -6572,7 +6539,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return false; } } - return context.depth < context.unfoldDepth || context.depth === context.unfoldDepth && !context.couldUnfoldMore; + return context.depth < context.unfoldDepth || context.depth === context.unfoldDepth && !context.out.couldUnfoldMore; } /** Determines if a type can be unfolded, based on how many layers of type aliases we're allowed to unfold. @@ -6589,7 +6556,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } const result = context.depth < context.unfoldDepth; if (!result) { - context.couldUnfoldMore = true; + context.out.couldUnfoldMore = true; } return result; } @@ -7234,26 +7201,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const restoreFlags = saveRestoreFlags(context); context.flags |= NodeBuilderFlags.InObjectTypeLiteral; - let members = createTypeNodesFromResolvedType(resolved); + const members = createTypeNodesFromResolvedType(resolved); restoreFlags(); - // Simplify enum type when expanding it for quickinfo. - if (context.unfoldDepth > 0 && type.symbol && type.symbol.flags & SymbolFlags.Enum) { - members = mapDefined(members, simplifyEnumMember); - } const typeLiteralNode = factory.createTypeLiteralNode(members); context.approximateLength += 2; setEmitFlags(typeLiteralNode, (context.flags & NodeBuilderFlags.MultilineObjectLiterals) ? 0 : EmitFlags.SingleLine); return typeLiteralNode; } - function simplifyEnumMember(member: TypeElement): TypeElement | undefined { - // Skip printing reverse mapping signature. - if (member.kind === SyntaxKind.IndexSignature) { - return undefined; - } - return factory.createPropertySignature(/*modifiers*/ undefined, member.name!, /*questionToken*/ undefined, /*typeNode*/ undefined); - } - function typeReferenceToTypeNode(type: TypeReference) { let typeArguments: readonly Type[] = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { @@ -7483,12 +7438,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] | undefined { if (checkTruncationLength(context)) { - context.truncated = true; + context.out.truncated = true; if (context.flags & NodeBuilderFlags.NoTruncation) { return [addSyntheticTrailingComment(factory.createNotEmittedTypeElement(), SyntaxKind.MultiLineCommentTrivia, "elided")]; } return [factory.createPropertySignature(/*modifiers*/ undefined, "...", /*questionToken*/ undefined, /*type*/ undefined)]; } + context.typeStack.push(-1); const typeElements: TypeElement[] = []; for (const signature of resolvedType.callSignatures) { typeElements.push(signatureToSignatureDeclarationHelper(signature, SyntaxKind.CallSignature, context) as CallSignatureDeclaration); @@ -7508,6 +7464,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let i = 0; for (const propertySymbol of properties) { + if (isUnfolding(context) && propertySymbol.flags & SymbolFlags.Prototype) { + continue; + } i++; if (context.flags & NodeBuilderFlags.WriteClassExpressionAsTypeLiteral) { if (propertySymbol.flags & SymbolFlags.Prototype) { @@ -7518,7 +7477,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) { - context.truncated = true; + context.out.truncated = true; if (context.flags & NodeBuilderFlags.NoTruncation) { const typeElement = typeElements.pop()!; typeElements.push(addSyntheticTrailingComment(typeElement, SyntaxKind.MultiLineCommentTrivia, `... ${properties.length - i} more elided ...`)); @@ -7699,7 +7658,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function mapToTypeNodes(types: readonly Type[] | undefined, context: NodeBuilderContext, isBareList?: boolean): TypeNode[] | undefined { if (some(types)) { if (checkTruncationLength(context)) { - context.truncated = true; + context.out.truncated = true; if (!isBareList) { return [ context.flags & NodeBuilderFlags.NoTruncation @@ -7725,7 +7684,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { for (const type of types) { i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - context.truncated = true; + context.out.truncated = true; result.push( context.flags & NodeBuilderFlags.NoTruncation ? addSyntheticLeadingComment(factory.createKeywordTypeNode(SyntaxKind.AnyKeyword), SyntaxKind.MultiLineCommentTrivia, `... ${types.length - i} more elided ...`) @@ -8780,6 +8739,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function getPropertyNameNodeForSymbol(symbol: Symbol, context: NodeBuilderContext) { + const hashPrivateName = getHashPrivateName(symbol); + if (hashPrivateName) { + return hashPrivateName; + } const stringNamed = !!length(symbol.declarations) && every(symbol.declarations, isStringNamed); const singleQuote = !!length(symbol.declarations) && every(symbol.declarations, isSingleQuotedStringNamed); const isMethod = !!(symbol.flags & SymbolFlags.Method); @@ -9948,29 +9911,22 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { ...!length(implementsExpressions) ? [] : [factory.createHeritageClause(SyntaxKind.ImplementsKeyword, implementsExpressions)], ]; const symbolProps = getNonInheritedProperties(classType, baseTypes, getPropertiesOfType(classType)); - const publicSymbolProps = filter(symbolProps, s => { - // `valueDeclaration` could be undefined if inherited from - // a union/intersection base type, but inherited properties - // don't matter here. - const valueDecl = s.valueDeclaration; - return !!valueDecl && !(isNamedDeclaration(valueDecl) && isPrivateIdentifier(valueDecl.name)); - }); - const hasPrivateIdentifier = some(symbolProps, s => { - // `valueDeclaration` could be undefined if inherited from - // a union/intersection base type, but inherited properties - // don't matter here. - const valueDecl = s.valueDeclaration; - return !!valueDecl && isNamedDeclaration(valueDecl) && isPrivateIdentifier(valueDecl.name); - }); + const publicSymbolProps = filter(symbolProps, s => !isHashPrivate(s)); + const hasPrivateIdentifier = some(symbolProps, isHashPrivate); // Boil down all private properties into a single one. const privateProperties = hasPrivateIdentifier ? - [factory.createPropertyDeclaration( - /*modifiers*/ undefined, - factory.createPrivateIdentifier("#private"), - /*questionOrExclamationToken*/ undefined, - /*type*/ undefined, - /*initializer*/ undefined, - )] : + isUnfolding(context) ? + flatMap( + filter(symbolProps, isHashPrivate), + p => serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]) + ) : + [factory.createPropertyDeclaration( + /*modifiers*/ undefined, + factory.createPrivateIdentifier("#private"), + /*questionOrExclamationToken*/ undefined, + /*type*/ undefined, + /*initializer*/ undefined, + )] : emptyArray; const publicProperties = flatMap(publicSymbolProps, p => serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0])); // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics @@ -10433,7 +10389,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { ): (p: Symbol, isStatic: boolean, baseType: Type | undefined) => T | AccessorDeclaration | (T | AccessorDeclaration)[] { return function serializePropertySymbol(p: Symbol, isStatic: boolean, baseType: Type | undefined): T | AccessorDeclaration | (T | AccessorDeclaration)[] { const modifierFlags = getDeclarationModifierFlagsFromSymbol(p); - const isPrivate = !!(modifierFlags & ModifierFlags.Private); + const omitType = !!(modifierFlags & ModifierFlags.Private) && !isUnfolding(context); if (isStatic && (p.flags & (SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias))) { // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols // need to be merged namespace members @@ -10481,7 +10437,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { /*dotDotDotToken*/ undefined, paramSymbol ? parameterToParameterDeclarationName(paramSymbol, getEffectiveParameterDeclaration(paramSymbol), context) : "value", /*questionToken*/ undefined, - isPrivate ? undefined : serializeTypeForDeclaration(context, setterDeclaration, getWriteTypeOfSymbol(p), p), + omitType ? undefined : serializeTypeForDeclaration(context, setterDeclaration, getWriteTypeOfSymbol(p), p), )], /*body*/ undefined, ), @@ -10489,7 +10445,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { )); } if (p.flags & SymbolFlags.GetAccessor) { - const isPrivate = modifierFlags & ModifierFlags.Private; const getterDeclaration = p.declarations?.find(isGetAccessor); result.push(setTextRange( context, @@ -10497,7 +10452,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { factory.createModifiersFromModifierFlags(flag), name, [], - isPrivate ? undefined : serializeTypeForDeclaration(context, getterDeclaration, getTypeOfSymbol(p), p), + omitType ? undefined : serializeTypeForDeclaration(context, getterDeclaration, getTypeOfSymbol(p), p), /*body*/ undefined, ), getterDeclaration ?? firstPropertyLikeDecl, @@ -10514,7 +10469,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? ModifierFlags.Readonly : 0) | flag), name, p.flags & SymbolFlags.Optional ? factory.createToken(SyntaxKind.QuestionToken) : undefined, - isPrivate ? undefined : serializeTypeForDeclaration(context, p.declarations?.find(isSetAccessorDeclaration), getWriteTypeOfSymbol(p), p), + omitType ? undefined : serializeTypeForDeclaration(context, p.declarations?.find(isSetAccessorDeclaration), getWriteTypeOfSymbol(p), p), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ /*initializer*/ undefined, @@ -10525,7 +10480,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (p.flags & (SymbolFlags.Method | SymbolFlags.Function)) { const type = getTypeOfSymbol(p); const signatures = getSignaturesOfType(type, SignatureKind.Call); - if (flag & ModifierFlags.Private) { + if (omitType) { return setTextRange( context, createProperty( @@ -10731,6 +10686,24 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return localName; } } + + function isUnfolding(context: NodeBuilderContext) { + return context.unfoldDepth !== -1; + } + + function isHashPrivate(s: Symbol): boolean { + // `valueDeclaration` could be undefined if inherited from + // a union/intersection base type, but inherited properties + // don't matter here. + return !!s.valueDeclaration && isNamedDeclaration(s.valueDeclaration) && isPrivateIdentifier(s.valueDeclaration.name); + } + + function getHashPrivateName(s: Symbol): PrivateIdentifier | undefined { + if (s.valueDeclaration && isNamedDeclaration(s.valueDeclaration) && isPrivateIdentifier(s.valueDeclaration.name)) { + return factory.cloneNode(s.valueDeclaration.name); + } + return undefined; + } } /** Returns true if a type is declared in a lib file. */ @@ -53171,8 +53144,7 @@ interface NodeBuilderContext extends SyntacticTypeNodeBuilderContext { typeStack: number[]; // Output - couldUnfoldMore: boolean; // Whether we found a type alias that we could unfold but didn't - truncated: boolean; // Whether we did truncation. + out: WriterContextOut; } class SymbolTrackerImpl implements SymbolTracker { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a353f36f18b84..f8525b8c50692 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5052,6 +5052,7 @@ export interface TypeCheckerHost extends ModuleSpecifierResolutionHost, SourceFi /** @internal */ export interface WriterContextOut { + /** Whether we found a type alias that we could unfold but didn't. */ couldUnfoldMore: boolean; truncated: boolean; } @@ -5445,8 +5446,8 @@ export interface TypeChecker { getTypeArgumentsForResolvedSignature(signature: Signature): readonly Type[] | undefined; /** @internal */ isLibType(type: Type): boolean; - /** @internal */ classSymbolToNode(symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number, out?: WriterContextOut): Node | undefined; - + /** @internal */ classSymbolToDeclaration(symbol: Symbol, flags: NodeBuilderFlags, verbosityLevel?: number, out?: WriterContextOut): Declaration | undefined; + /** @internal */ enumSymbolToDeclaration(symbol: Symbol, flags: NodeBuilderFlags, verbosityLevel?: number, out?: WriterContextOut): Declaration | undefined; } /** @internal */ diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 84214d13f8c02..63ae239c6f377 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -497,14 +497,15 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( } if (symbolFlags & SymbolFlags.Enum) { prefixNextMeaning(); - if (some(symbol.declarations, d => isEnumDeclaration(d) && isEnumConst(d))) { - displayParts.push(keywordPart(SyntaxKind.ConstKeyword)); + if (!tryUnfoldSymbol(symbol)) { + if (some(symbol.declarations, d => isEnumDeclaration(d) && isEnumConst(d))) { + displayParts.push(keywordPart(SyntaxKind.ConstKeyword)); + displayParts.push(spacePart()); + } + displayParts.push(keywordPart(SyntaxKind.EnumKeyword)); displayParts.push(spacePart()); + addFullSymbolName(symbol, /*enclosingDeclaration*/ undefined); } - displayParts.push(keywordPart(SyntaxKind.EnumKeyword)); - displayParts.push(spacePart()); - addFullSymbolName(symbol, /*enclosingDeclaration*/ undefined); - tryUnfoldSymbol(symbol); } if (symbolFlags & SymbolFlags.Module && !isThisExpression) { prefixNextMeaning(); @@ -858,26 +859,26 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( let unfoldType; if (unfoldType = canUnfoldSymbol(symbol, typeWriterOut)) { if (symbol.flags & SymbolFlags.Enum) { - // >> TODO: probably add enum printing as enum declaration at the top level; add it to return of `createNodeBuilder`. + const expandedDisplayParts = mapToDisplayParts(writer => { + const node = typeChecker.enumSymbolToDeclaration( + symbol, + TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, + verbosityLevel !== undefined ? verbosityLevel - 1 : undefined, + typeWriterOut)!; + getPrinter().writeNode(EmitHint.Unspecified, node, sourceFile, writer); + }); + addRange(displayParts, expandedDisplayParts); } else if (symbol.flags & SymbolFlags.Class) { - let expandedDisplayParts = mapToDisplayParts(writer => { - const node = typeChecker.classSymbolToNode( + const expandedDisplayParts = mapToDisplayParts(writer => { + const node = typeChecker.classSymbolToDeclaration( symbol, - undefined, TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, - undefined, - undefined, verbosityLevel !== undefined ? verbosityLevel - 1 : undefined, typeWriterOut)!; getPrinter().writeNode(EmitHint.Unspecified, node, sourceFile, writer); }); - let start = 0; - while (start < expandedDisplayParts.length && - expandedDisplayParts[start].kind === SymbolDisplayPartKind[SymbolDisplayPartKind.lineBreak]) { - start++; - } - addRange(displayParts, expandedDisplayParts, start); + addRange(displayParts, expandedDisplayParts); } else { const expandedDisplayParts = typeToDisplayParts( diff --git a/tests/baselines/reference/quickinfoVerbosityClass2.baseline b/tests/baselines/reference/quickinfoVerbosityClass2.baseline index 33489efb3686f..5a72c145eefa8 100644 --- a/tests/baselines/reference/quickinfoVerbosityClass2.baseline +++ b/tests/baselines/reference/quickinfoVerbosityClass2.baseline @@ -7,9 +7,10 @@ // ^^^ // | ---------------------------------------------------------------------- // | class Foo { +// | static whatever(): void; // | constructor(public x: T); +// | public x: T; // | public y: T; -// | static whatever(): void; // | private foo(): { // | color: string; // | }; @@ -20,9 +21,10 @@ // ^^^ // | ---------------------------------------------------------------------- // | class Foo { +// | static whatever(): void; // | constructor(public x: T); +// | public x: T; // | public y: T; -// | static whatever(): void; // | private foo(): Apple; // | protected z: boolean; // | } @@ -75,7 +77,6 @@ // | ---------------------------------------------------------------------- // | const a: { // | new (x: T): Foo; -// | prototype: Foo; // | whatever(): void; // | } // | (verbosity level: 1) @@ -90,7 +91,6 @@ // | ---------------------------------------------------------------------- // | const c: { // | new (x: string): Foo; -// | prototype: Foo; // | whatever(): void; // | } // | (verbosity level: 0) @@ -99,9 +99,10 @@ // ^^^^^ // | ---------------------------------------------------------------------- // | (local class) class { +// | static whatever(): void; // | constructor(public x: T); +// | public x: T; // | public y: T; -// | static whatever(): void; // | private foo(): { // | color: string; // | }; @@ -112,9 +113,10 @@ // ^^^^^ // | ---------------------------------------------------------------------- // | (local class) class { +// | static whatever(): void; // | constructor(public x: T); +// | public x: T; // | public y: T; -// | static whatever(): void; // | private foo(): Apple; // | protected z: boolean; // | } @@ -144,7 +146,6 @@ // abstract class Animal { // ^^^^^^ // | ---------------------------------------------------------------------- -// | @random() // | abstract class Animal { // | name: string; // | abstract makeSound(): void; @@ -159,6 +160,37 @@ // name!: string; // abstract makeSound(): void; // } +// class Dog { +// ^^^ +// | ---------------------------------------------------------------------- +// | class Dog { +// | what(this: this, that: Dog): void; +// | #bones: string[]; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | class Dog +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// what(this: this, that: Dog) { } +// #bones: string[]; +// } +// const d = new Dog(); +// ^ +// | ---------------------------------------------------------------------- +// | const d: { +// | what(this: Dog, that: Dog): void; +// | #bones: string[]; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const d: Dog +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- [ { @@ -237,7 +269,7 @@ }, { "text": "T", - "kind": "text" + "kind": "typeParameterName" }, { "text": ">", @@ -259,6 +291,50 @@ "text": " ", "kind": "space" }, + { + "text": "static", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "whatever", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, { "text": "constructor", "kind": "keyword" @@ -316,7 +392,7 @@ "kind": "space" }, { - "text": "y", + "text": "x", "kind": "text" }, { @@ -344,7 +420,7 @@ "kind": "space" }, { - "text": "static", + "text": "public", "kind": "keyword" }, { @@ -352,17 +428,9 @@ "kind": "space" }, { - "text": "whatever", + "text": "y", "kind": "text" }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, { "text": ":", "kind": "punctuation" @@ -372,8 +440,8 @@ "kind": "space" }, { - "text": "void", - "kind": "keyword" + "text": "T", + "kind": "typeParameterName" }, { "text": ";", @@ -505,7 +573,7 @@ }, { "text": "T", - "kind": "text" + "kind": "typeParameterName" }, { "text": ">", @@ -527,6 +595,50 @@ "text": " ", "kind": "space" }, + { + "text": "static", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "whatever", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, { "text": "constructor", "kind": "keyword" @@ -584,7 +696,7 @@ "kind": "space" }, { - "text": "y", + "text": "x", "kind": "text" }, { @@ -612,7 +724,7 @@ "kind": "space" }, { - "text": "static", + "text": "public", "kind": "keyword" }, { @@ -620,17 +732,9 @@ "kind": "space" }, { - "text": "whatever", + "text": "y", "kind": "text" }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, { "text": ":", "kind": "punctuation" @@ -640,8 +744,8 @@ "kind": "space" }, { - "text": "void", - "kind": "keyword" + "text": "T", + "kind": "typeParameterName" }, { "text": ";", @@ -1411,46 +1515,6 @@ "text": " ", "kind": "space" }, - { - "text": "prototype", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Foo", - "kind": "className" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "any", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, { "text": "whatever", "kind": "text" @@ -1607,46 +1671,6 @@ "text": " ", "kind": "space" }, - { - "text": "prototype", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Foo", - "kind": "className" - }, - { - "text": "<", - "kind": "punctuation" - }, - { - "text": "any", - "kind": "keyword" - }, - { - "text": ">", - "kind": "punctuation" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, { "text": "whatever", "kind": "text" @@ -1781,7 +1805,7 @@ }, { "text": "T", - "kind": "text" + "kind": "typeParameterName" }, { "text": ">", @@ -1804,24 +1828,24 @@ "kind": "space" }, { - "text": "constructor", + "text": "static", "kind": "keyword" }, { - "text": "(", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": "public", - "kind": "keyword" + "text": "whatever", + "kind": "text" }, { - "text": " ", - "kind": "space" + "text": "(", + "kind": "punctuation" }, { - "text": "x", - "kind": "parameterName" + "text": ")", + "kind": "punctuation" }, { "text": ":", @@ -1832,12 +1856,8 @@ "kind": "space" }, { - "text": "T", - "kind": "typeParameterName" - }, - { - "text": ")", - "kind": "punctuation" + "text": "void", + "kind": "keyword" }, { "text": ";", @@ -1851,6 +1871,14 @@ "text": " ", "kind": "space" }, + { + "text": "constructor", + "kind": "keyword" + }, + { + "text": "(", + "kind": "punctuation" + }, { "text": "public", "kind": "keyword" @@ -1860,8 +1888,8 @@ "kind": "space" }, { - "text": "y", - "kind": "text" + "text": "x", + "kind": "parameterName" }, { "text": ":", @@ -1875,6 +1903,10 @@ "text": "T", "kind": "typeParameterName" }, + { + "text": ")", + "kind": "punctuation" + }, { "text": ";", "kind": "punctuation" @@ -1888,7 +1920,7 @@ "kind": "space" }, { - "text": "static", + "text": "public", "kind": "keyword" }, { @@ -1896,17 +1928,45 @@ "kind": "space" }, { - "text": "whatever", + "text": "x", "kind": "text" }, { - "text": "(", + "text": ":", "kind": "punctuation" }, { - "text": ")", + "text": " ", + "kind": "space" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ";", "kind": "punctuation" }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "public", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "text" + }, { "text": ":", "kind": "punctuation" @@ -1916,8 +1976,8 @@ "kind": "space" }, { - "text": "void", - "kind": "keyword" + "text": "T", + "kind": "typeParameterName" }, { "text": ";", @@ -2057,7 +2117,7 @@ }, { "text": "T", - "kind": "text" + "kind": "typeParameterName" }, { "text": ">", @@ -2079,6 +2139,50 @@ "text": " ", "kind": "space" }, + { + "text": "static", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "whatever", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, { "text": "constructor", "kind": "keyword" @@ -2136,7 +2240,7 @@ "kind": "space" }, { - "text": "y", + "text": "x", "kind": "text" }, { @@ -2164,7 +2268,7 @@ "kind": "space" }, { - "text": "static", + "text": "public", "kind": "keyword" }, { @@ -2172,17 +2276,9 @@ "kind": "space" }, { - "text": "whatever", + "text": "y", "kind": "text" }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": ")", - "kind": "punctuation" - }, { "text": ":", "kind": "punctuation" @@ -2192,8 +2288,8 @@ "kind": "space" }, { - "text": "void", - "kind": "keyword" + "text": "T", + "kind": "typeParameterName" }, { "text": ";", @@ -2424,11 +2520,79 @@ }, "displayParts": [ { - "text": "@", + "text": "abstract", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Animal", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", "kind": "punctuation" }, { - "text": "random", + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "name", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "abstract", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "makeSound", "kind": "text" }, { @@ -2439,18 +2603,82 @@ "text": ")", "kind": "punctuation" }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, { "text": "\n", "kind": "lineBreak" }, { - "text": "abstract", + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 714, + "name": "8" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 711, + "length": 3 + }, + "displayParts": [ + { + "text": "class", "kind": "keyword" }, { "text": " ", "kind": "space" }, + { + "text": "Dog", + "kind": "className" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 714, + "name": "8" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 711, + "length": 3 + }, + "displayParts": [ { "text": "class", "kind": "keyword" @@ -2460,7 +2688,7 @@ "kind": "space" }, { - "text": "Animal", + "text": "Dog", "kind": "text" }, { @@ -2480,9 +2708,17 @@ "kind": "space" }, { - "text": "name", + "text": "what", "kind": "text" }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "this", + "kind": "parameterName" + }, { "text": ":", "kind": "punctuation" @@ -2492,7 +2728,47 @@ "kind": "space" }, { - "text": "string", + "text": "this", + "kind": "keyword" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "that", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Dog", + "kind": "className" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", "kind": "keyword" }, { @@ -2508,7 +2784,63 @@ "kind": "space" }, { - "text": "abstract", + "text": "#bones", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 784, + "name": "9" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 783, + "length": 1 + }, + "displayParts": [ + { + "text": "const", "kind": "keyword" }, { @@ -2516,13 +2848,121 @@ "kind": "space" }, { - "text": "makeSound", + "text": "d", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Dog", + "kind": "className" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityClass2.ts", + "position": 784, + "name": "9" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 783, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "d", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "what", "kind": "text" }, { "text": "(", "kind": "punctuation" }, + { + "text": "this", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Dog", + "kind": "className" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "that", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Dog", + "kind": "className" + }, { "text": ")", "kind": "punctuation" @@ -2547,6 +2987,42 @@ "text": "\n", "kind": "lineBreak" }, + { + "text": " ", + "kind": "space" + }, + { + "text": "#bones", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, { "text": "}", "kind": "punctuation" diff --git a/tests/baselines/reference/quickinfoVerbosityEnum.baseline b/tests/baselines/reference/quickinfoVerbosityEnum.baseline index ac558716a688d..21a0fd0b27f78 100644 --- a/tests/baselines/reference/quickinfoVerbosityEnum.baseline +++ b/tests/baselines/reference/quickinfoVerbosityEnum.baseline @@ -4,9 +4,9 @@ // ^^^^^ // | ---------------------------------------------------------------------- // | enum Color { -// | Red; -// | Green; -// | Blue; +// | Red = 0, +// | Green = 1, +// | Blue = 2 // | } // | (verbosity level: 1) // | ---------------------------------------------------------------------- @@ -30,6 +30,34 @@ // | const x: Color // | (verbosity level: 0) // | ---------------------------------------------------------------------- +// const enum Direction { +// ^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | const enum Direction { +// | Up = 0, +// | Down = 1 +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | const enum Direction +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// Up, +// Down, +// } +// const y: Direction = Direction.Up; +// ^ +// | ---------------------------------------------------------------------- +// | const y: Direction.Up | Direction.Down +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const y: Direction +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- [ { @@ -88,7 +116,7 @@ }, { "text": "Color", - "kind": "enumName" + "kind": "text" }, { "text": " ", @@ -108,10 +136,26 @@ }, { "text": "Red", - "kind": "propertyName" + "kind": "text" }, { - "text": ";", + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "0", + "kind": "stringLiteral" + }, + { + "text": ",", "kind": "punctuation" }, { @@ -124,10 +168,26 @@ }, { "text": "Green", - "kind": "propertyName" + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" }, { - "text": ";", + "text": " ", + "kind": "space" + }, + { + "text": "1", + "kind": "stringLiteral" + }, + { + "text": ",", "kind": "punctuation" }, { @@ -140,11 +200,23 @@ }, { "text": "Blue", - "kind": "propertyName" + "kind": "text" }, { - "text": ";", - "kind": "punctuation" + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "2", + "kind": "stringLiteral" }, { "text": "\n", @@ -303,5 +375,281 @@ "canIncreaseVerbosityLevel": false, "verbosityLevel": 1 } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", + "position": 93, + "name": "d" + }, + "item": { + "kind": "enum", + "kindModifiers": "", + "textSpan": { + "start": 84, + "length": 9 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "enum", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Direction", + "kind": "enumName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", + "position": 93, + "name": "d" + }, + "item": { + "kind": "enum", + "kindModifiers": "", + "textSpan": { + "start": 84, + "length": 9 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "enum", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Direction", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Up", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "0", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Down", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "1", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", + "position": 123, + "name": "y" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 122, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Direction", + "kind": "enumName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", + "position": 123, + "name": "y" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 122, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Direction", + "kind": "enumName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Up", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Direction", + "kind": "enumName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Down", + "kind": "text" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } } ] \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityClass2.ts b/tests/cases/fourslash/quickinfoVerbosityClass2.ts index 8b3187a0d5206..57ca867fa0cfb 100644 --- a/tests/cases/fourslash/quickinfoVerbosityClass2.ts +++ b/tests/cases/fourslash/quickinfoVerbosityClass2.ts @@ -40,6 +40,12 @@ //// abstract makeSound(): void; //// } +//// class Dog/*8*/ { +//// what(this: this, that: Dog) { } +//// #bones: string[]; +//// } +//// const d/*9*/ = new Dog(); + verify.baselineQuickInfo({ 1: [0, 1, 2], @@ -49,4 +55,6 @@ verify.baselineQuickInfo({ 5: [0, 1, 2], 6: [0], 7: [0, 1], + 8: [0, 1], + 9: [0, 1], }); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityEnum.ts b/tests/cases/fourslash/quickinfoVerbosityEnum.ts index 81a12761a0301..1410321801f4c 100644 --- a/tests/cases/fourslash/quickinfoVerbosityEnum.ts +++ b/tests/cases/fourslash/quickinfoVerbosityEnum.ts @@ -7,7 +7,15 @@ //// } //// const x/*x*/: Color = Color.Red; +//// const enum Direction/*d*/ { +//// Up, +//// Down, +//// } +//// const y/*y*/: Direction = Direction.Up; + verify.baselineQuickInfo({ c: [0, 1], x: [0, 1], + d: [0, 1], + y: [0, 1], }); \ No newline at end of file From 45a92a427438e39f4947f290eb8f785c4bf9e2ab Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 21 Mar 2025 08:24:54 -0700 Subject: [PATCH 12/31] add one more case to import --- .../quickinfoVerbosityImport.baseline | 396 +++++++++++++++--- .../fourslash/quickinfoVerbosityImport.ts | 12 + 2 files changed, 359 insertions(+), 49 deletions(-) diff --git a/tests/baselines/reference/quickinfoVerbosityImport.baseline b/tests/baselines/reference/quickinfoVerbosityImport.baseline index f8c0895a141fc..24cdb389ea3b2 100644 --- a/tests/baselines/reference/quickinfoVerbosityImport.baseline +++ b/tests/baselines/reference/quickinfoVerbosityImport.baseline @@ -1,4 +1,39 @@ // === QuickInfo === +=== /4.ts === +// import Foo from "./3"; +// ^^^ +// | ---------------------------------------------------------------------- +// | import Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// const f = new Foo(); +// ^ +// | ---------------------------------------------------------------------- +// | const f: { +// | a: boolean; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const f: Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | (alias) new Foo(): { +// | a: boolean; +// | } +// | import Foo +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | (alias) new Foo(): Foo +// | import Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + === /2.ts === // import { a } from "./0"; // ^ @@ -20,10 +55,9 @@ // ^^^^^ // | ---------------------------------------------------------------------- // | (alias) enum Color { -// | readonly [x: number]: string; -// | readonly Red: Color.Red; -// | readonly Green: Color.Green; -// | readonly Blue: Color.Blue; +// | Red = 0, +// | Green = 1, +// | Blue = 2 // | } // | import Color // | (verbosity level: 1) @@ -989,7 +1023,7 @@ }, { "text": "Color", - "kind": "aliasName" + "kind": "text" }, { "text": " ", @@ -1008,51 +1042,95 @@ "kind": "space" }, { - "text": "readonly", - "kind": "keyword" + "text": "Red", + "kind": "text" }, { "text": " ", "kind": "space" }, { - "text": "[", - "kind": "punctuation" + "text": "=", + "kind": "operator" }, { - "text": "x", - "kind": "parameterName" + "text": " ", + "kind": "space" }, { - "text": ":", + "text": "0", + "kind": "stringLiteral" + }, + { + "text": ",", "kind": "punctuation" }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Green", + "kind": "text" + }, { "text": " ", "kind": "space" }, { - "text": "number", - "kind": "keyword" + "text": "=", + "kind": "operator" }, { - "text": "]", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": ":", + "text": "1", + "kind": "stringLiteral" + }, + { + "text": ",", "kind": "punctuation" }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Blue", + "kind": "text" + }, { "text": " ", "kind": "space" }, { - "text": "string", - "kind": "keyword" + "text": "=", + "kind": "operator" }, { - "text": ";", + "text": " ", + "kind": "space" + }, + { + "text": "2", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", "kind": "punctuation" }, { @@ -1060,11 +1138,39 @@ "kind": "lineBreak" }, { - "text": " ", + "text": "import", + "kind": "keyword" + }, + { + "text": " ", "kind": "space" }, { - "text": "readonly", + "text": "Color", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/4.ts", + "position": 10, + "name": "d" + }, + "item": { + "kind": "alias", + "kindModifiers": "export", + "textSpan": { + "start": 7, + "length": 3 + }, + "displayParts": [ + { + "text": "import", "kind": "keyword" }, { @@ -1072,8 +1178,40 @@ "kind": "space" }, { - "text": "Red", - "kind": "propertyName" + "text": "Foo", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/4.ts", + "position": 30, + "name": "e" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 29, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" }, { "text": ":", @@ -1084,19 +1222,51 @@ "kind": "space" }, { - "text": "Color", + "text": "Foo", "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/4.ts", + "position": 30, + "name": "e" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 29, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" }, { - "text": ".", + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "localName" + }, + { + "text": ":", "kind": "punctuation" }, { - "text": "Red", - "kind": "text" + "text": " ", + "kind": "space" }, { - "text": ";", + "text": "{", "kind": "punctuation" }, { @@ -1108,19 +1278,63 @@ "kind": "space" }, { - "text": "readonly", - "kind": "keyword" + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" }, { "text": " ", "kind": "space" }, { - "text": "Green", - "kind": "propertyName" + "text": "boolean", + "kind": "keyword" }, { - "text": ":", + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/4.ts", + "position": 40, + "name": "f" + }, + "item": { + "kind": "alias", + "kindModifiers": "export", + "textSpan": { + "start": 37, + "length": 3 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", "kind": "punctuation" }, { @@ -1128,31 +1342,91 @@ "kind": "space" }, { - "text": "Color", + "text": "new", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", "kind": "aliasName" }, { - "text": ".", + "text": "(", "kind": "punctuation" }, { - "text": "Green", - "kind": "text" + "text": ")", + "kind": "punctuation" }, { - "text": ";", + "text": ":", "kind": "punctuation" }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "aliasName" + }, { "text": "\n", "kind": "lineBreak" }, { - "text": " ", + "text": "import", + "kind": "keyword" + }, + { + "text": " ", "kind": "space" }, { - "text": "readonly", + "text": "Foo", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/4.ts", + "position": 40, + "name": "f" + }, + "item": { + "kind": "alias", + "kindModifiers": "export", + "textSpan": { + "start": 37, + "length": 3 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "new", "kind": "keyword" }, { @@ -1160,8 +1434,16 @@ "kind": "space" }, { - "text": "Blue", - "kind": "propertyName" + "text": "Foo", + "kind": "aliasName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" }, { "text": ":", @@ -1172,16 +1454,32 @@ "kind": "space" }, { - "text": "Color", - "kind": "aliasName" + "text": "{", + "kind": "punctuation" }, { - "text": ".", + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", "kind": "punctuation" }, { - "text": "Blue", - "kind": "text" + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" }, { "text": ";", @@ -1208,7 +1506,7 @@ "kind": "space" }, { - "text": "Color", + "text": "Foo", "kind": "aliasName" } ], diff --git a/tests/cases/fourslash/quickinfoVerbosityImport.ts b/tests/cases/fourslash/quickinfoVerbosityImport.ts index 01ad83ede27d1..9fd309b2857dc 100644 --- a/tests/cases/fourslash/quickinfoVerbosityImport.ts +++ b/tests/cases/fourslash/quickinfoVerbosityImport.ts @@ -21,8 +21,20 @@ //// import { a/*a*/ } from "./0"; //// import { Color/*c*/ } from "./0"; +// @filename: /3.ts +//// export default class { +//// a: boolean; +//// } + +// @filename: /4.ts +//// import Foo/*d*/ from "./3"; +//// const f/*e*/ = new Foo/*f*/(); + verify.baselineQuickInfo({ b: [0, 1, 2], a: [0, 1], c: [0, 1], + d: [0], + e: [0, 1], + f: [0, 1], }); \ No newline at end of file From 4256003ab16752f11d6d08aa12f862171e115ad6 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Mon, 24 Mar 2025 12:42:49 -0700 Subject: [PATCH 13/31] finish impl of top-level declaration expansion --- src/compiler/checker.ts | 123 +- src/compiler/types.ts | 3 +- src/services/symbolDisplay.ts | 111 +- .../reference/quickinfoVerbosity3.baseline | 144 +- .../quickinfoVerbosityInterface2.baseline | 1960 +++++++++++++++++ .../quickinfoVerbosityNamespace.baseline | 1304 +++++++++++ .../quickinfoVerbosityRecursiveType.baseline | 108 +- .../quickinfoVerbosityTypeof.baseline | 29 - .../fourslash/quickinfoVerbosityInterface2.ts | 66 + .../fourslash/quickinfoVerbosityNamespace.ts | 52 + 10 files changed, 3727 insertions(+), 173 deletions(-) create mode 100644 tests/baselines/reference/quickinfoVerbosityInterface2.baseline create mode 100644 tests/baselines/reference/quickinfoVerbosityNamespace.baseline create mode 100644 tests/cases/fourslash/quickinfoVerbosityInterface2.ts create mode 100644 tests/cases/fourslash/quickinfoVerbosityNamespace.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6001c6cd9e2b7..1135dbb7cfecd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1935,8 +1935,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { getSymbolFlags, getTypeArgumentsForResolvedSignature, isLibType, - classSymbolToDeclaration: nodeBuilder.classSymbolToDeclaration, - enumSymbolToDeclaration: nodeBuilder.enumSymbolToDeclaration, + symbolToDeclarations: nodeBuilder.symbolToDeclarations, }; function getTypeArgumentsForResolvedSignature(signature: Signature) { @@ -6311,8 +6310,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { typeParameterToDeclaration: (parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number, out?: WriterContextOut) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, context => typeParameterToDeclaration(parameter, context), out), symbolTableToDeclarationStatements: (symbolTable: SymbolTable, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolTableToDeclarationStatements(symbolTable, context)), symbolToNode: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolToNode(symbol, context, meaning)), - classSymbolToDeclaration, - enumSymbolToDeclaration, + symbolToDeclarations, }; function getTypeFromTypeNode(context: NodeBuilderContext, node: TypeNode, noMappedTypes?: false): Type; @@ -6372,39 +6370,39 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return symbolToExpression(symbol, context, meaning); } - function classSymbolToDeclaration(symbol: Symbol, flags: NodeBuilderFlags, verbosityLevel?: number, out?: WriterContextOut): Declaration { - const classDeclarations = filter(symbol.declarations, isClassLike); - if (!classDeclarations || classDeclarations.length === 0) { - Debug.fail("Expected class symbol to have a declaration"); - } - const modifiers = getModifiers(classDeclarations[0]); - const isAnonymous = isClassExpression(classDeclarations[0]); - const instanceType = getDeclaredTypeOfSymbol(symbol); - const node = withContext( + function symbolToDeclarations(symbol: Symbol, meaning: SymbolFlags, flags: NodeBuilderFlags, verbosityLevel?: number, out?: WriterContextOut): Declaration[] { + const nodes = withContext( /*enclosingDeclaration*/ undefined, flags, /*internalFlags*/ undefined, /*tracker*/ undefined, verbosityLevel, - context => classSymbolToDeclarationWorker(symbol, instanceType.id, isAnonymous, modifiers, context), + context => symbolToDeclarationsWorker(symbol, context), out); - Debug.assert(node !== undefined, "Should always get a node"); - return node; + return mapDefined(nodes, node => { + switch (node.kind) { + case SyntaxKind.ClassDeclaration: + return simplifyClassDeclaration(node as ClassDeclaration, symbol); + case SyntaxKind.EnumDeclaration: + return simplifyEnumDeclaration(node as EnumDeclaration, symbol); + case SyntaxKind.InterfaceDeclaration: + return simplifyInterfaceDeclaration(node as InterfaceDeclaration, symbol, meaning); + case SyntaxKind.ModuleDeclaration: + return simplifyNamespaceDeclaration(node as ModuleDeclaration, symbol); + // TODO: type declaration? + default: + return undefined; + } + }); } - function classSymbolToDeclarationWorker( - symbol: Symbol, - instanceTypeId: number, - isAnonymous: boolean, - originalModifiers: readonly Modifier[] | undefined, - context: NodeBuilderContext): Declaration { - // We're already expanding the class type: set it in the stack to avoid expanding it again. - context.typeStack.push(instanceTypeId); - context.typeStack.push(-1); - const table = createSymbolTable([symbol]); - const stmts = symbolTableToDeclarationStatements(table, context); - Debug.assert(stmts.length === 1 && isClassDeclaration(stmts[0]), "Expected a single class declaration."); - let classDecl = stmts[0] as ClassDeclaration; + function simplifyClassDeclaration(classDecl: ClassDeclaration, symbol: Symbol): ClassDeclaration { + const classDeclarations = filter(symbol.declarations, isClassLike); + if (!classDeclarations || classDeclarations.length === 0) { + Debug.fail("Expected class symbol to have a declaration"); + } + const modifiers = getEffectiveModifierFlags(classDeclarations[0]) & ~ModifierFlags.Export; + const isAnonymous = isClassExpression(classDeclarations[0]); if (isAnonymous) { classDecl = factory.updateClassDeclaration( classDecl, @@ -6415,29 +6413,50 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { classDecl.members, ); } - return factory.replaceModifiers(classDecl, originalModifiers); + return factory.replaceModifiers(classDecl, modifiers); } - function enumSymbolToDeclaration(symbol: Symbol, flags: NodeBuilderFlags, verbosityLevel?: number, out?: WriterContextOut): Declaration { - const node = withContext( - /*enclosingDeclaration*/ undefined, - flags, - /*internalFlags*/ undefined, - /*tracker*/ undefined, - verbosityLevel, - context => enumSymbolToDeclarationWorker(symbol, context), - out); - Debug.assert(node !== undefined, "Should always get a node"); - return node; + // TODO: unify all those 3 functions if possible, after we re-add truncation + function simplifyEnumDeclaration(enumDecl: EnumDeclaration, symbol: Symbol): EnumDeclaration | undefined { + const enumDeclarations = filter(symbol.declarations, isEnumDeclaration); + if (!enumDeclarations || enumDeclarations.length === 0) { + Debug.fail("Expected enum symbol to have a declaration"); + } + const modifiers = getEffectiveModifierFlags(enumDeclarations[0]) & ~ModifierFlags.Export; + return factory.replaceModifiers(enumDecl, modifiers); } - function enumSymbolToDeclarationWorker(symbol: Symbol, context: NodeBuilderContext): Declaration { + function simplifyNamespaceDeclaration(namespaceDecl: ModuleDeclaration, symbol: Symbol): ModuleDeclaration | undefined { + const namespaceDeclarations = filter(symbol.declarations, isModuleDeclaration); + if (!namespaceDeclarations || namespaceDeclarations.length === 0) { + Debug.fail("Expected namespace symbol to have a declaration"); + } + const modifiers = getEffectiveModifierFlags(namespaceDeclarations[0]) & ~ModifierFlags.Export; + return factory.replaceModifiers(namespaceDecl, modifiers); + } + + function simplifyInterfaceDeclaration(interfaceDecl: InterfaceDeclaration, symbol: Symbol, meaning: SymbolFlags): InterfaceDeclaration | undefined { + if (!(meaning & SymbolFlags.Interface)) { + return undefined; + } + const interfaceDeclarations = filter(symbol.declarations, isInterfaceDeclaration); + if (!interfaceDeclarations || interfaceDeclarations.length === 0) { + Debug.fail("Expected interface symbol to have a declaration"); + } + const modifiers = getEffectiveModifierFlags(interfaceDeclarations[0]) & ~ModifierFlags.Export; + return factory.replaceModifiers(interfaceDecl, modifiers); + } + + function symbolToDeclarationsWorker(symbol: Symbol, context: NodeBuilderContext): Statement[] { + // We're already expanding the type: set it in the stack to avoid expanding it again. + const type = getDeclaredTypeOfSymbol(symbol); + context.typeStack.push(type.id); + context.typeStack.push(-1); const table = createSymbolTable([symbol]); - const stmts = symbolTableToDeclarationStatements(table, context); - Debug.assert(stmts.length === 1 && isEnumDeclaration(stmts[0]), "Expected a single enum declaration."); - const enumDecl = stmts[0] as EnumDeclaration; - const modifiers = getModifiers(enumDecl)?.filter(modifier => modifier.kind !== SyntaxKind.DeclareKeyword); - return factory.replaceModifiers(enumDecl, modifiers); + const statements = symbolTableToDeclarationStatements(table, context); + context.typeStack.pop(); + context.typeStack.pop(); + return statements; } function withContext( @@ -7459,6 +7478,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const properties = resolvedType.properties; if (!properties) { + context.typeStack.pop(); return typeElements; } @@ -7490,6 +7510,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } addPropertyToElementList(propertySymbol, context, typeElements); } + context.typeStack.pop(); return typeElements.length ? typeElements : undefined; } } @@ -9701,9 +9722,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function serializeModule(symbol: Symbol, symbolName: string, modifierFlags: ModifierFlags) { - const members = getNamespaceMembersForSerialization(symbol); + const members = getNamespaceMembersForSerialization(symbol); + const unfolding = isUnfolding(context); // Split NS members up by declaration - members whose parent symbol is the ns symbol vs those whose is not (but were added in later via merging) - const locationMap = arrayToMultiMap(members, m => m.parent && m.parent === symbol ? "real" : "merged"); + const locationMap = arrayToMultiMap(members, m => m.parent && m.parent === symbol || unfolding ? "real" : "merged"); const realMembers = locationMap.get("real") || emptyArray; const mergedMembers = locationMap.get("merged") || emptyArray; // TODO: `suppressNewPrivateContext` is questionable -we need to simply be emitting privates in whatever scope they were declared in, rather @@ -9797,7 +9819,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function serializeAsNamespaceDeclaration(props: readonly Symbol[], localName: string, modifierFlags: ModifierFlags, suppressNewPrivateContext: boolean) { if (length(props)) { - const localVsRemoteMap = arrayToMultiMap(props, p => !length(p.declarations) || some(p.declarations, d => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration!)) ? "local" : "remote"); + const unfolding = isUnfolding(context); + const localVsRemoteMap = arrayToMultiMap(props, p => !length(p.declarations) || some(p.declarations, d => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration!)) || unfolding ? "local" : "remote"); const localProps = localVsRemoteMap.get("local") || emptyArray; // handle remote props first - we need to make an `import` declaration that points at the module containing each remote // prop in the outermost scope (TODO: a namespace within a namespace would need to be appropriately handled by this) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f8525b8c50692..62c40cbf4172b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5446,8 +5446,7 @@ export interface TypeChecker { getTypeArgumentsForResolvedSignature(signature: Signature): readonly Type[] | undefined; /** @internal */ isLibType(type: Type): boolean; - /** @internal */ classSymbolToDeclaration(symbol: Symbol, flags: NodeBuilderFlags, verbosityLevel?: number, out?: WriterContextOut): Declaration | undefined; - /** @internal */ enumSymbolToDeclaration(symbol: Symbol, flags: NodeBuilderFlags, verbosityLevel?: number, out?: WriterContextOut): Declaration | undefined; + /** @internal */ symbolToDeclarations(symbol: Symbol, meaning: SymbolFlags, flags: NodeBuilderFlags, verbosityLevel?: number, out?: WriterContextOut): Declaration[]; } /** @internal */ diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 63ae239c6f377..74d875dc6c1b8 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -283,6 +283,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( let tagsFromAlias: JSDocTagInfo[] | undefined; let hasMultipleSignatures = false; const typeWriterOut: WriterContextOut = { couldUnfoldMore: false, truncated: false }; + let hasUnfoldedSymbol = false; if (location.kind === SyntaxKind.ThisKeyword && !isThisExpression) { return { displayParts: [keywordPart(SyntaxKind.ThisKeyword)], documentation: [], symbolKind: ScriptElementKind.primitiveType, tags: undefined }; @@ -456,7 +457,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( pushSymbolKind(ScriptElementKind.localClassElement); displayParts.push(spacePart()); } - if (!tryUnfoldSymbol(symbol)) { + if (!tryUnfoldSymbol(symbol, semanticMeaning)) { if (!classExpression) { // Class declaration has name which is not local. displayParts.push(keywordPart(SyntaxKind.ClassKeyword)); @@ -468,11 +469,12 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( } if ((symbolFlags & SymbolFlags.Interface) && (semanticMeaning & SemanticMeaning.Type)) { prefixNextMeaning(); - displayParts.push(keywordPart(SyntaxKind.InterfaceKeyword)); - displayParts.push(spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); - tryUnfoldSymbol(symbol); + if (!tryUnfoldSymbol(symbol, semanticMeaning)) { + displayParts.push(keywordPart(SyntaxKind.InterfaceKeyword)); + displayParts.push(spacePart()); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + } } if ((symbolFlags & SymbolFlags.TypeAlias) && (semanticMeaning & SemanticMeaning.Type)) { prefixNextMeaning(); @@ -497,7 +499,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( } if (symbolFlags & SymbolFlags.Enum) { prefixNextMeaning(); - if (!tryUnfoldSymbol(symbol)) { + if (!tryUnfoldSymbol(symbol, semanticMeaning)) { if (some(symbol.declarations, d => isEnumDeclaration(d) && isEnumConst(d))) { displayParts.push(keywordPart(SyntaxKind.ConstKeyword)); displayParts.push(spacePart()); @@ -509,12 +511,13 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( } if (symbolFlags & SymbolFlags.Module && !isThisExpression) { prefixNextMeaning(); - const declaration = getDeclarationOfKind(symbol, SyntaxKind.ModuleDeclaration); - const isNamespace = declaration && declaration.name && declaration.name.kind === SyntaxKind.Identifier; - displayParts.push(keywordPart(isNamespace ? SyntaxKind.NamespaceKeyword : SyntaxKind.ModuleKeyword)); - displayParts.push(spacePart()); - addFullSymbolName(symbol); - tryUnfoldSymbol(symbol); + if (!tryUnfoldSymbol(symbol, semanticMeaning)) { + const declaration = getDeclarationOfKind(symbol, SyntaxKind.ModuleDeclaration); + const isNamespace = declaration && declaration.name && declaration.name.kind === SyntaxKind.Identifier; + displayParts.push(keywordPart(isNamespace ? SyntaxKind.NamespaceKeyword : SyntaxKind.ModuleKeyword)); + displayParts.push(spacePart()); + addFullSymbolName(symbol); + } } if ((symbolFlags & SymbolFlags.TypeParameter) && (semanticMeaning & SemanticMeaning.Type)) { prefixNextMeaning(); @@ -831,21 +834,21 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( displayParts.push(spacePart()); } - function canUnfoldSymbol(symbol: Symbol, out: WriterContextOut | undefined): Type | undefined { - if (verbosityLevel === undefined || !(symbol.flags & SymbolFlags.Type)) { - return undefined; + function canUnfoldSymbol(symbol: Symbol, out: WriterContextOut | undefined): boolean { + if (verbosityLevel === undefined) { + return false; } const type = getTypeOfSymbol(symbol); if (!type || typeChecker.isLibType(type)) { - return undefined; + return false; } if (0 < verbosityLevel) { - return type; + return true; } if (out) { out.couldUnfoldMore = true; } - return undefined; + return false; } function getTypeOfSymbol(symbol: Symbol) { @@ -855,43 +858,41 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( return typeChecker.getTypeOfSymbolAtLocation(symbol, location); } - function tryUnfoldSymbol(symbol: Symbol): boolean { - let unfoldType; - if (unfoldType = canUnfoldSymbol(symbol, typeWriterOut)) { - if (symbol.flags & SymbolFlags.Enum) { - const expandedDisplayParts = mapToDisplayParts(writer => { - const node = typeChecker.enumSymbolToDeclaration( - symbol, - TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, - verbosityLevel !== undefined ? verbosityLevel - 1 : undefined, - typeWriterOut)!; - getPrinter().writeNode(EmitHint.Unspecified, node, sourceFile, writer); - }); - addRange(displayParts, expandedDisplayParts); - } - else if (symbol.flags & SymbolFlags.Class) { - const expandedDisplayParts = mapToDisplayParts(writer => { - const node = typeChecker.classSymbolToDeclaration( - symbol, - TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, - verbosityLevel !== undefined ? verbosityLevel - 1 : undefined, - typeWriterOut)!; - getPrinter().writeNode(EmitHint.Unspecified, node, sourceFile, writer); + function getSymbolMeaning(meaning: SemanticMeaning): SymbolFlags { + let symbolMeaning = SymbolFlags.None; + if (meaning & SemanticMeaning.Value) { + symbolMeaning |= SymbolFlags.Value; + } + if (meaning & SemanticMeaning.Type) { + symbolMeaning |= SymbolFlags.Type; + } + if (meaning & SemanticMeaning.Namespace) { + symbolMeaning |= SymbolFlags.Namespace; + } + return symbolMeaning; + } + + function tryUnfoldSymbol(symbol: Symbol, meaning: SemanticMeaning): boolean { + if (hasUnfoldedSymbol) { + return true; + } + if (canUnfoldSymbol(symbol, typeWriterOut)) { + const symbolMeaning = getSymbolMeaning(meaning); + const expandedDisplayParts = mapToDisplayParts(writer => { + const nodes = typeChecker.symbolToDeclarations( + symbol, + symbolMeaning, + TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, + verbosityLevel !== undefined ? verbosityLevel - 1 : undefined, + typeWriterOut); + const printer = getPrinter(); + nodes.forEach((node, i) => { + if (i > 0) writer.writeLine(); + printer.writeNode(EmitHint.Unspecified, node, sourceFile, writer); }); - addRange(displayParts, expandedDisplayParts); - } - else { - const expandedDisplayParts = typeToDisplayParts( - typeChecker, - unfoldType, - enclosingDeclaration || sourceFile, - /*flags*/ undefined, - verbosityLevel, - typeWriterOut, - ); - displayParts.push(spacePart()); - addRange(displayParts, expandedDisplayParts); - } + }); + addRange(displayParts, expandedDisplayParts); + hasUnfoldedSymbol = true; return true; } return false; diff --git a/tests/baselines/reference/quickinfoVerbosity3.baseline b/tests/baselines/reference/quickinfoVerbosity3.baseline index 3327d1fbde21e..e7c81482f2f93 100644 --- a/tests/baselines/reference/quickinfoVerbosity3.baseline +++ b/tests/baselines/reference/quickinfoVerbosity3.baseline @@ -51,14 +51,14 @@ // class Bar implements Foo { // ^^^ // | ---------------------------------------------------------------------- -// | class Bar { +// | class Bar implements Foo { // | prop: T; // | } // | (verbosity level: 2) // | ---------------------------------------------------------------------- // ^^^ // | ---------------------------------------------------------------------- -// | class Bar { +// | class Bar implements Foo { // | prop: T; // | } // | (verbosity level: 1) @@ -77,21 +77,23 @@ // ^^^ // | ---------------------------------------------------------------------- // | class c5b { -// | foo(): void; +// | public foo(): void; // | } // | namespace c5b { -// | foo(): void; +// | let y: number; // | } +// | // | (verbosity level: 2) // | ---------------------------------------------------------------------- // ^^^ // | ---------------------------------------------------------------------- // | class c5b { -// | foo(): void; +// | public foo(): void; // | } // | namespace c5b { -// | foo(): void; +// | let y: number; // | } +// | // | (verbosity level: 1) // | ---------------------------------------------------------------------- // ^^^ @@ -396,7 +398,7 @@ }, { "text": "Opt", - "kind": "className" + "kind": "text" }, { "text": " ", @@ -480,7 +482,7 @@ }, { "text": "Opt", - "kind": "className" + "kind": "text" }, { "text": " ", @@ -624,7 +626,7 @@ }, { "text": "Foo", - "kind": "interfaceName" + "kind": "text" }, { "text": "<", @@ -788,7 +790,7 @@ }, { "text": "Bar", - "kind": "className" + "kind": "text" }, { "text": "<", @@ -822,6 +824,34 @@ "text": " ", "kind": "space" }, + { + "text": "implements", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, { "text": "{", "kind": "punctuation" @@ -836,7 +866,7 @@ }, { "text": "prop", - "kind": "propertyName" + "kind": "text" }, { "text": ":", @@ -892,7 +922,7 @@ }, { "text": "Bar", - "kind": "className" + "kind": "text" }, { "text": "<", @@ -926,6 +956,34 @@ "text": " ", "kind": "space" }, + { + "text": "implements", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, { "text": "{", "kind": "punctuation" @@ -940,7 +998,7 @@ }, { "text": "prop", - "kind": "propertyName" + "kind": "text" }, { "text": ":", @@ -1044,7 +1102,7 @@ }, { "text": "c5b", - "kind": "className" + "kind": "text" }, { "text": " ", @@ -1062,6 +1120,14 @@ "text": " ", "kind": "space" }, + { + "text": "public", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, { "text": "foo", "kind": "text" @@ -1112,7 +1178,7 @@ }, { "text": "c5b", - "kind": "className" + "kind": "text" }, { "text": " ", @@ -1131,16 +1197,16 @@ "kind": "space" }, { - "text": "foo", - "kind": "text" + "text": "let", + "kind": "keyword" }, { - "text": "(", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": ")", - "kind": "punctuation" + "text": "y", + "kind": "text" }, { "text": ":", @@ -1151,7 +1217,7 @@ "kind": "space" }, { - "text": "void", + "text": "number", "kind": "keyword" }, { @@ -1165,6 +1231,10 @@ { "text": "}", "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" } ], "documentation": [], @@ -1196,7 +1266,7 @@ }, { "text": "c5b", - "kind": "className" + "kind": "text" }, { "text": " ", @@ -1214,6 +1284,14 @@ "text": " ", "kind": "space" }, + { + "text": "public", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, { "text": "foo", "kind": "text" @@ -1264,7 +1342,7 @@ }, { "text": "c5b", - "kind": "className" + "kind": "text" }, { "text": " ", @@ -1283,16 +1361,16 @@ "kind": "space" }, { - "text": "foo", - "kind": "text" + "text": "let", + "kind": "keyword" }, { - "text": "(", - "kind": "punctuation" + "text": " ", + "kind": "space" }, { - "text": ")", - "kind": "punctuation" + "text": "y", + "kind": "text" }, { "text": ":", @@ -1303,7 +1381,7 @@ "kind": "space" }, { - "text": "void", + "text": "number", "kind": "keyword" }, { @@ -1317,6 +1395,10 @@ { "text": "}", "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" } ], "documentation": [], diff --git a/tests/baselines/reference/quickinfoVerbosityInterface2.baseline b/tests/baselines/reference/quickinfoVerbosityInterface2.baseline new file mode 100644 index 0000000000000..6a7fbab8ee553 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityInterface2.baseline @@ -0,0 +1,1960 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityInterface2.ts === +// { +// interface Foo { +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Foo { +// | a: "a" | "c"; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// a: "a" | "c"; +// } +// } +// { +// interface Bar { +// b: "b" | "d"; +// } +// interface Foo extends Bar { +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Foo extends Bar { +// | a: "a" | "c"; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// a: "a" | "c"; +// } +// } +// { +// type BarParam = "b" | "d"; +// interface Bar { +// bar(b: BarParam): string; +// } +// type FooType = "a" | "c"; +// interface FooParam { +// param: FooType; +// } +// interface Foo extends Bar { +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Foo extends Bar { +// | a: "a" | "c"; +// | foo: (a: { +// | param: FooType; +// | }) => number; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Foo extends Bar { +// | a: FooType; +// | foo: (a: FooParam) => number; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// a: FooType; +// foo: (a: FooParam) => number; +// } +// } +// { +// interface Bar { +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Bar { +// | bar(b: B): string; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Bar +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// bar(b: B): string; +// } +// interface FooParam { +// param: "a" | "c"; +// } +// interface Foo extends Bar { +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Foo extends Bar<{ +// | param: "a" | "c"; +// | }> { +// | a: "a" | "c"; +// | foo: (a: { +// | param: "a" | "c"; +// | }) => number; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Foo extends Bar { +// | a: "a" | "c"; +// | foo: (a: FooParam) => number; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// a: "a" | "c"; +// foo: (a: FooParam) => number; +// } +// } +// { +// interface Foo { +// a: "a"; +// } +// interface Foo { +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Foo { +// | a: "a"; +// | b: "b"; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// b: "b"; +// } +// } +// interface Foo { +// ^^^ +// | ---------------------------------------------------------------------- +// | namespace Foo { +// | let bar: string; +// | } +// | interface Foo { +// | a: "a"; +// | } +// | +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | interface Foo +// | namespace Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// a: "a"; +// } +// namespace Foo { +// ^^^ +// | ---------------------------------------------------------------------- +// | namespace Foo { +// | let bar: string; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | namespace Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// export const bar: string; +// } + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 19, + "name": "1" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 16, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 19, + "name": "1" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 16, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 119, + "name": "2" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 116, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 119, + "name": "2" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 116, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "interfaceName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 359, + "name": "3" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 356, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 359, + "name": "3" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 356, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "interfaceName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooParam", + "kind": "interfaceName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 359, + "name": "3" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 356, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "interfaceName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "param", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 459, + "name": "4" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 456, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "B", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 459, + "name": "4" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 456, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "text" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "B", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "b", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "B", + "kind": "typeParameterName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 572, + "name": "5" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 569, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 572, + "name": "5" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 569, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "FooParam", + "kind": "interfaceName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "FooParam", + "kind": "interfaceName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 572, + "name": "5" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 569, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "extends", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Bar", + "kind": "interfaceName" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "param", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "param", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"c\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 726, + "name": "6" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 723, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 726, + "name": "6" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 723, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"b\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 766, + "name": "7" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 763, + "length": 3 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 766, + "name": "7" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 763, + "length": 3 + }, + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"a\"", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 796, + "name": "8" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 793, + "length": 3 + }, + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "interfaceName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityInterface2.ts", + "position": 796, + "name": "8" + }, + "item": { + "kind": "interface", + "kindModifiers": "", + "textSpan": { + "start": 793, + "length": 3 + }, + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "bar", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityNamespace.baseline b/tests/baselines/reference/quickinfoVerbosityNamespace.baseline new file mode 100644 index 0000000000000..66f8fca8880b9 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityNamespace.baseline @@ -0,0 +1,1304 @@ +// === QuickInfo === +=== /3.ts === +// import * as Foo_1 from "./b"; +// export declare namespace ns { +// ^^ +// | ---------------------------------------------------------------------- +// | declare namespace ns { +// | export { Foo }; +// | export let c: number; +// | export let d: 1; +// | export let f: { +// | a: string; +// | }; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^ +// | ---------------------------------------------------------------------- +// | declare namespace ns { +// | export { Foo }; +// | export let c: number; +// | export let d: 1; +// | export let f: Apple; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^ +// | ---------------------------------------------------------------------- +// | namespace ns +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// import Foo = Foo_1.Foo; +// export { Foo }; +// export const c: number; +// export const d = 1; +// let e: Apple; +// export let f: Apple; +// } +// interface Apple { +// a: string; +// } + +=== /1.ts === +// export {}; +// class Foo { +// y: string; +// } +// namespace Foo { +// ^^^ +// | ---------------------------------------------------------------------- +// | class Foo { +// | y: string; +// | } +// | namespace Foo { +// | let y: number; +// | let x: string; +// | let w: string; +// | } +// | +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | class Foo +// | namespace Foo +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// export var y: number = 1; +// export var x: string = "hello"; +// export var w = "world"; +// var z = 2; +// } + +=== /4.ts === +// class Foo { +// y!: T; +// } +// namespace Two { +// ^^^ +// | ---------------------------------------------------------------------- +// | namespace Two { +// | let f: { +// | y: number; +// | }; +// | let g: { +// | y: string; +// | }; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | namespace Two { +// | let f: Foo; +// | let g: Foo; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^ +// | ---------------------------------------------------------------------- +// | namespace Two +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// export const f = new Foo(); +// } + +[ + { + "marker": { + "fileName": "/1.ts", + "position": 56, + "name": "1" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 53, + "length": 3 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/1.ts", + "position": 56, + "name": "1" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 53, + "length": 3 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "T", + "kind": "typeParameterName" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "x", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "w", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/3.ts", + "position": 57, + "name": "2" + }, + "item": { + "kind": "module", + "kindModifiers": "export,declare", + "textSpan": { + "start": 55, + "length": 2 + }, + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ns", + "kind": "moduleName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/3.ts", + "position": 57, + "name": "2" + }, + "item": { + "kind": "module", + "kindModifiers": "export,declare", + "textSpan": { + "start": 55, + "length": 2 + }, + "displayParts": [ + { + "text": "declare", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ns", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "d", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "1", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Apple", + "kind": "interfaceName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/3.ts", + "position": 57, + "name": "2" + }, + "item": { + "kind": "module", + "kindModifiers": "export,declare", + "textSpan": { + "start": 55, + "length": 2 + }, + "displayParts": [ + { + "text": "declare", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "ns", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "c", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "d", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "1", + "kind": "stringLiteral" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + }, + { + "marker": { + "fileName": "/4.ts", + "position": 41, + "name": "3" + }, + "item": { + "kind": "module", + "kindModifiers": "", + "textSpan": { + "start": 38, + "length": 3 + }, + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Two", + "kind": "moduleName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/4.ts", + "position": 41, + "name": "3" + }, + "item": { + "kind": "module", + "kindModifiers": "", + "textSpan": { + "start": 38, + "length": 3 + }, + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Two", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "g", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "className" + }, + { + "text": "<", + "kind": "punctuation" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ">", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/4.ts", + "position": 41, + "name": "3" + }, + "item": { + "kind": "module", + "kindModifiers": "", + "textSpan": { + "start": 38, + "length": 3 + }, + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Two", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "g", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "y", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 2 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityRecursiveType.baseline b/tests/baselines/reference/quickinfoVerbosityRecursiveType.baseline index c003523cc6385..672932bf789b7 100644 --- a/tests/baselines/reference/quickinfoVerbosityRecursiveType.baseline +++ b/tests/baselines/reference/quickinfoVerbosityRecursiveType.baseline @@ -5,8 +5,8 @@ // | ---------------------------------------------------------------------- // | type Node = { // | value: T; -// | left: Node; -// | right: Node; +// | left: Node | undefined; +// | right: Node | undefined; // | } // | (verbosity level: 0) // | ---------------------------------------------------------------------- @@ -41,8 +41,8 @@ // | ---------------------------------------------------------------------- // | type TreeNode = { // | value: T; -// | left: TreeNode; -// | right: TreeNode; +// | left: TreeNode | undefined; +// | right: TreeNode | undefined; // | orange?: { // | name: string; // | }; @@ -53,8 +53,8 @@ // | ---------------------------------------------------------------------- // | type TreeNode = { // | value: T; -// | left: TreeNode; -// | right: TreeNode; +// | left: TreeNode | undefined; +// | right: TreeNode | undefined; // | orange?: Orange; // | } // | (verbosity level: 0) @@ -217,6 +217,22 @@ "text": ">", "kind": "punctuation" }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "undefined", + "kind": "keyword" + }, { "text": ";", "kind": "punctuation" @@ -257,6 +273,22 @@ "text": ">", "kind": "punctuation" }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "undefined", + "kind": "keyword" + }, { "text": ";", "kind": "punctuation" @@ -609,6 +641,22 @@ "text": ">", "kind": "punctuation" }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "undefined", + "kind": "keyword" + }, { "text": ";", "kind": "punctuation" @@ -649,6 +697,22 @@ "text": ">", "kind": "punctuation" }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "undefined", + "kind": "keyword" + }, { "text": ";", "kind": "punctuation" @@ -817,6 +881,22 @@ "text": ">", "kind": "punctuation" }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "undefined", + "kind": "keyword" + }, { "text": ";", "kind": "punctuation" @@ -857,6 +937,22 @@ "text": ">", "kind": "punctuation" }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "undefined", + "kind": "keyword" + }, { "text": ";", "kind": "punctuation" diff --git a/tests/baselines/reference/quickinfoVerbosityTypeof.baseline b/tests/baselines/reference/quickinfoVerbosityTypeof.baseline index 901b6af991a0f..efde843770d46 100644 --- a/tests/baselines/reference/quickinfoVerbosityTypeof.baseline +++ b/tests/baselines/reference/quickinfoVerbosityTypeof.baseline @@ -30,7 +30,6 @@ // | ---------------------------------------------------------------------- // | const c: { // | new (length: number): Banana; -// | prototype: Banana; // | } // | (verbosity level: 1) // | ---------------------------------------------------------------------- @@ -343,34 +342,6 @@ "text": "\n", "kind": "lineBreak" }, - { - "text": " ", - "kind": "space" - }, - { - "text": "prototype", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Banana", - "kind": "className" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, { "text": "}", "kind": "punctuation" diff --git a/tests/cases/fourslash/quickinfoVerbosityInterface2.ts b/tests/cases/fourslash/quickinfoVerbosityInterface2.ts new file mode 100644 index 0000000000000..916cc8d9c2e72 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityInterface2.ts @@ -0,0 +1,66 @@ +/// + +//// { +//// interface Foo/*1*/ { +//// a: "a" | "c"; +//// } +//// } +//// { +//// interface Bar { +//// b: "b" | "d"; +//// } +//// interface Foo/*2*/ extends Bar { +//// a: "a" | "c"; +//// } +//// } +//// { +//// type BarParam = "b" | "d"; +//// interface Bar { +//// bar(b: BarParam): string; +//// } +//// type FooType = "a" | "c"; +//// interface FooParam { +//// param: FooType; +//// } +//// interface Foo/*3*/ extends Bar { +//// a: FooType; +//// foo: (a: FooParam) => number; +//// } +//// } +//// { +//// interface Bar/*4*/ { +//// bar(b: B): string; +//// } +//// interface FooParam { +//// param: "a" | "c"; +//// } +//// interface Foo/*5*/ extends Bar { +//// a: "a" | "c"; +//// foo: (a: FooParam) => number; +//// } +//// } +//// { +//// interface Foo { +//// a: "a"; +//// } +//// interface Foo/*6*/ { +//// b: "b"; +//// } +//// } +//// interface Foo/*7*/ { +//// a: "a"; +//// } +//// namespace Foo/*8*/ { +//// export const bar: string; +//// } + +verify.baselineQuickInfo({ + "1": [0, 1], + "2": [0, 1], + "3": [0, 1, 2], + "4": [0, 1], + "5": [0, 1, 2], + "6": [0, 1], + "7": [0, 1], + "8": [0, 1], +}); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityNamespace.ts b/tests/cases/fourslash/quickinfoVerbosityNamespace.ts new file mode 100644 index 0000000000000..225cca32ffd64 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityNamespace.ts @@ -0,0 +1,52 @@ +/// + +// @filename: /1.ts +//// export {}; +//// class Foo { +//// y: string; +//// } +//// namespace Foo/*1*/ { +//// export var y: number = 1; +//// export var x: string = "hello"; +//// export var w = "world"; +//// var z = 2; +//// } + +// @filename: /2.ts +//// export namespace Foo { +//// export var y: number = 1; +//// export var x: string = "hello"; +//// } + +// @filename: /3.ts +//// import * as Foo_1 from "./b"; +//// export declare namespace ns/*2*/ { +//// import Foo = Foo_1.Foo; +//// export { Foo }; +//// export const c: number; +//// export const d = 1; +//// let e: Apple; +//// export let f: Apple; +//// } +//// interface Apple { +//// a: string; +//// } + +// @filename: /4.ts +//// class Foo { +//// y!: T; +//// } +//// namespace Two/*3*/ { +//// export const f = new Foo(); +//// } + +// @filename: /5.ts +//// namespace Two { +//// export const g = new Foo(); +//// } + +verify.baselineQuickInfo({ + 1: [0, 1], + 2: [0, 1, 2], + 3: [0, 1, 2], +}) From 25673e9f4484e9b3407814219b166f00279f3f56 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Mon, 24 Mar 2025 15:27:56 -0700 Subject: [PATCH 14/31] more fixes + tests --- src/compiler/checker.ts | 62 ++-- src/services/symbolDisplay.ts | 4 +- .../quickinfoVerbosityFunction.baseline | 317 ++++++++++++++++++ .../quickinfoVerbosityNamespace.baseline | 115 ++++++- .../fourslash/quickinfoVerbosityFunction.ts | 13 +- .../fourslash/quickinfoVerbosityNamespace.ts | 6 + 6 files changed, 459 insertions(+), 58 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1135dbb7cfecd..9166313fe9bd8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1134,7 +1134,6 @@ import { WithStatement, WriterContextOut, YieldExpression, - visitEachChild, } from "./_namespaces/ts.js"; import * as moduleSpecifiers from "./_namespaces/ts.moduleSpecifiers.js"; import * as performance from "./_namespaces/ts.performance.js"; @@ -6384,25 +6383,22 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { case SyntaxKind.ClassDeclaration: return simplifyClassDeclaration(node as ClassDeclaration, symbol); case SyntaxKind.EnumDeclaration: - return simplifyEnumDeclaration(node as EnumDeclaration, symbol); + return simplifyModifiers(node as EnumDeclaration, isEnumDeclaration, symbol); case SyntaxKind.InterfaceDeclaration: return simplifyInterfaceDeclaration(node as InterfaceDeclaration, symbol, meaning); case SyntaxKind.ModuleDeclaration: - return simplifyNamespaceDeclaration(node as ModuleDeclaration, symbol); - // TODO: type declaration? + return simplifyModifiers(node as ModuleDeclaration, isModuleDeclaration, symbol); default: return undefined; } }); } - function simplifyClassDeclaration(classDecl: ClassDeclaration, symbol: Symbol): ClassDeclaration { + function simplifyClassDeclaration(classDecl: ClassDeclaration, symbol: Symbol): Declaration { const classDeclarations = filter(symbol.declarations, isClassLike); - if (!classDeclarations || classDeclarations.length === 0) { - Debug.fail("Expected class symbol to have a declaration"); - } - const modifiers = getEffectiveModifierFlags(classDeclarations[0]) & ~ModifierFlags.Export; - const isAnonymous = isClassExpression(classDeclarations[0]); + const originalClassDecl = classDeclarations && classDeclarations.length > 0 ? classDeclarations[0] : classDecl; + const modifiers = getEffectiveModifierFlags(originalClassDecl) & ~(ModifierFlags.Export | ModifierFlags.Ambient); + const isAnonymous = isClassExpression(originalClassDecl); if (isAnonymous) { classDecl = factory.updateClassDeclaration( classDecl, @@ -6416,35 +6412,18 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return factory.replaceModifiers(classDecl, modifiers); } - // TODO: unify all those 3 functions if possible, after we re-add truncation - function simplifyEnumDeclaration(enumDecl: EnumDeclaration, symbol: Symbol): EnumDeclaration | undefined { - const enumDeclarations = filter(symbol.declarations, isEnumDeclaration); - if (!enumDeclarations || enumDeclarations.length === 0) { - Debug.fail("Expected enum symbol to have a declaration"); - } - const modifiers = getEffectiveModifierFlags(enumDeclarations[0]) & ~ModifierFlags.Export; - return factory.replaceModifiers(enumDecl, modifiers); - } - - function simplifyNamespaceDeclaration(namespaceDecl: ModuleDeclaration, symbol: Symbol): ModuleDeclaration | undefined { - const namespaceDeclarations = filter(symbol.declarations, isModuleDeclaration); - if (!namespaceDeclarations || namespaceDeclarations.length === 0) { - Debug.fail("Expected namespace symbol to have a declaration"); - } - const modifiers = getEffectiveModifierFlags(namespaceDeclarations[0]) & ~ModifierFlags.Export; - return factory.replaceModifiers(namespaceDecl, modifiers); + function simplifyModifiers(newDecl: Declaration & HasModifiers, isDeclKind: (d: Declaration) => boolean, symbol: Symbol): Declaration & HasModifiers { + const decls = filter(symbol.declarations, isDeclKind); + const declWithModifiers = decls && decls.length > 0 ? decls[0] : newDecl; + const modifiers = getEffectiveModifierFlags(declWithModifiers) & ~(ModifierFlags.Export | ModifierFlags.Ambient); + return factory.replaceModifiers(newDecl, modifiers); } - function simplifyInterfaceDeclaration(interfaceDecl: InterfaceDeclaration, symbol: Symbol, meaning: SymbolFlags): InterfaceDeclaration | undefined { + function simplifyInterfaceDeclaration(interfaceDecl: InterfaceDeclaration, symbol: Symbol, meaning: SymbolFlags): Declaration | undefined { if (!(meaning & SymbolFlags.Interface)) { return undefined; } - const interfaceDeclarations = filter(symbol.declarations, isInterfaceDeclaration); - if (!interfaceDeclarations || interfaceDeclarations.length === 0) { - Debug.fail("Expected interface symbol to have a declaration"); - } - const modifiers = getEffectiveModifierFlags(interfaceDeclarations[0]) & ~ModifierFlags.Export; - return factory.replaceModifiers(interfaceDecl, modifiers); + return simplifyModifiers(interfaceDecl, isInterfaceDeclaration, symbol); } function symbolToDeclarationsWorker(symbol: Symbol, context: NodeBuilderContext): Statement[] { @@ -9731,7 +9710,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // TODO: `suppressNewPrivateContext` is questionable -we need to simply be emitting privates in whatever scope they were declared in, rather // than whatever scope we traverse to them in. That's a bit of a complex rewrite, since we're not _actually_ tracking privates at all in advance, // so we don't even have placeholders to fill in. - if (length(realMembers)) { + if (length(realMembers) || unfolding) { const localName = getInternalSymbolName(symbol, symbolName); serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (SymbolFlags.Function | SymbolFlags.Assignment))); } @@ -9818,8 +9797,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function serializeAsNamespaceDeclaration(props: readonly Symbol[], localName: string, modifierFlags: ModifierFlags, suppressNewPrivateContext: boolean) { + const unfolding = isUnfolding(context); if (length(props)) { - const unfolding = isUnfolding(context); const localVsRemoteMap = arrayToMultiMap(props, p => !length(p.declarations) || some(p.declarations, d => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration!)) || unfolding ? "local" : "remote"); const localProps = localVsRemoteMap.get("local") || emptyArray; // handle remote props first - we need to make an `import` declaration that points at the module containing each remote @@ -9873,6 +9852,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { ); addResult(fakespace, modifierFlags); // namespaces can never be default exported } + else if (unfolding) { + addResult( + factory.createModuleDeclaration( + /*modifiers*/ undefined, + factory.createIdentifier(localName), + factory.createModuleBlock([]), + NodeFlags.Namespace, + ), + modifierFlags, + ) + } } function isNamespaceMember(p: Symbol) { diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 74d875dc6c1b8..7892edc5a688d 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -20,7 +20,6 @@ import { getCombinedLocalAndExportSymbolFlags, getDeclarationOfKind, getExternalModuleImportEqualsDeclarationExpression, - getIndentString, getMeaningFromLocation, getNameOfDeclaration, getNodeModifiers, @@ -38,7 +37,6 @@ import { isCallExpression, isCallExpressionTarget, isCallOrNewExpression, - isClassDeclaration, isClassExpression, isConstTypeReference, isDeprecatedDeclaration, @@ -71,7 +69,6 @@ import { length, lineBreakPart, ListFormat, - map, mapToDisplayParts, ModifierFlags, ModuleDeclaration, @@ -514,6 +511,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( if (!tryUnfoldSymbol(symbol, semanticMeaning)) { const declaration = getDeclarationOfKind(symbol, SyntaxKind.ModuleDeclaration); const isNamespace = declaration && declaration.name && declaration.name.kind === SyntaxKind.Identifier; + // const isNamespace = !(declaration && declaration.name && declaration.name.kind === SyntaxKind.StringLiteral); // TODO: breaking change displayParts.push(keywordPart(isNamespace ? SyntaxKind.NamespaceKeyword : SyntaxKind.ModuleKeyword)); displayParts.push(spacePart()); addFullSymbolName(symbol); diff --git a/tests/baselines/reference/quickinfoVerbosityFunction.baseline b/tests/baselines/reference/quickinfoVerbosityFunction.baseline index 2213f32943cd5..e253de89765b7 100644 --- a/tests/baselines/reference/quickinfoVerbosityFunction.baseline +++ b/tests/baselines/reference/quickinfoVerbosityFunction.baseline @@ -56,6 +56,31 @@ // | function isApple(x: unknown): x is Apple // | (verbosity level: 0) // | ---------------------------------------------------------------------- +// type SomeType = { +// prop1: string; +// } +// function someFun(a: SomeType): SomeType { +// return a; +// } +// someFun.what = 'what'; +// ^^^^^^^ +// | ---------------------------------------------------------------------- +// | namespace someFun { +// | let what: string; +// | } +// | function someFun(a: { +// | prop1: string; +// | }): { +// | prop1: string; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^^^ +// | ---------------------------------------------------------------------- +// | module someFun +// | function someFun(a: SomeType): SomeType +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- [ { @@ -937,5 +962,297 @@ "canIncreaseVerbosityLevel": false, "verbosityLevel": 1 } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityFunction.ts", + "position": 357, + "name": "s" + }, + "item": { + "kind": "function", + "kindModifiers": "", + "textSpan": { + "start": 350, + "length": 7 + }, + "displayParts": [ + { + "text": "module", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someFun", + "kind": "functionName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someFun", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SomeType", + "kind": "aliasName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SomeType", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityFunction.ts", + "position": 357, + "name": "s" + }, + "item": { + "kind": "function", + "kindModifiers": "", + "textSpan": { + "start": 350, + "length": 7 + }, + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someFun", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "what", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someFun", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop1", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop1", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } } ] \ No newline at end of file diff --git a/tests/baselines/reference/quickinfoVerbosityNamespace.baseline b/tests/baselines/reference/quickinfoVerbosityNamespace.baseline index 66f8fca8880b9..dc3fcdbdee117 100644 --- a/tests/baselines/reference/quickinfoVerbosityNamespace.baseline +++ b/tests/baselines/reference/quickinfoVerbosityNamespace.baseline @@ -4,7 +4,7 @@ // export declare namespace ns { // ^^ // | ---------------------------------------------------------------------- -// | declare namespace ns { +// | namespace ns { // | export { Foo }; // | export let c: number; // | export let d: 1; @@ -16,7 +16,7 @@ // | ---------------------------------------------------------------------- // ^^ // | ---------------------------------------------------------------------- -// | declare namespace ns { +// | namespace ns { // | export { Foo }; // | export let c: number; // | export let d: 1; @@ -104,6 +104,21 @@ // export const f = new Foo(); // } +=== /6.ts === +// namespace OnlyLocal { +// ^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | namespace OnlyLocal { } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | namespace OnlyLocal +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// const bar: number; +// } + [ { "marker": { @@ -443,14 +458,6 @@ "length": 2 }, "displayParts": [ - { - "text": "declare", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, { "text": "namespace", "kind": "keyword" @@ -671,14 +678,6 @@ "length": 2 }, "displayParts": [ - { - "text": "declare", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, { "text": "namespace", "kind": "keyword" @@ -1300,5 +1299,85 @@ "canIncreaseVerbosityLevel": false, "verbosityLevel": 2 } + }, + { + "marker": { + "fileName": "/6.ts", + "position": 19, + "name": "4" + }, + "item": { + "kind": "module", + "kindModifiers": "", + "textSpan": { + "start": 10, + "length": 9 + }, + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "OnlyLocal", + "kind": "moduleName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/6.ts", + "position": 19, + "name": "4" + }, + "item": { + "kind": "module", + "kindModifiers": "", + "textSpan": { + "start": 10, + "length": 9 + }, + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "OnlyLocal", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } } ] \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityFunction.ts b/tests/cases/fourslash/quickinfoVerbosityFunction.ts index e743a05e6f3f0..63aefd8a591df 100644 --- a/tests/cases/fourslash/quickinfoVerbosityFunction.ts +++ b/tests/cases/fourslash/quickinfoVerbosityFunction.ts @@ -17,6 +17,17 @@ //// declare function isApple/*f*/(x: unknown): x is Apple; +//// type SomeType = { +//// prop1: string; +//// } +//// function someFun(a: SomeType): SomeType { +//// return a; +//// } +//// someFun/*s*/.what = 'what'; -verify.baselineQuickInfo({ "o": [0, 1, 2], "f": [0, 1] }); \ No newline at end of file +verify.baselineQuickInfo({ + "o": [0, 1, 2], + "f": [0, 1], + "s": [0, 1] +}); \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityNamespace.ts b/tests/cases/fourslash/quickinfoVerbosityNamespace.ts index 225cca32ffd64..e6d594d496af8 100644 --- a/tests/cases/fourslash/quickinfoVerbosityNamespace.ts +++ b/tests/cases/fourslash/quickinfoVerbosityNamespace.ts @@ -45,8 +45,14 @@ //// export const g = new Foo(); //// } +// @filename: /6.ts +//// namespace OnlyLocal/*4*/ { +//// const bar: number; +//// } + verify.baselineQuickInfo({ 1: [0, 1], 2: [0, 1, 2], 3: [0, 1, 2], + 4: [0, 1], }) From f9d230945cb4d129d2eec875c237fd8e3928f528 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Wed, 26 Mar 2025 18:03:12 -0700 Subject: [PATCH 15/31] add top-level truncation --- src/compiler/checker.ts | 242 +++- ...ckinfoVerbosityToplevelTruncation.baseline | 1149 +++++++++++++++++ .../quickinfoVerbosityToplevelTruncation.ts | 57 + 3 files changed, 1411 insertions(+), 37 deletions(-) create mode 100644 tests/baselines/reference/quickinfoVerbosityToplevelTruncation.baseline create mode 100644 tests/cases/fourslash/quickinfoVerbosityToplevelTruncation.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9166313fe9bd8..20c148c4a7e1d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6526,6 +6526,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } + function checkUnfoldingTruncationLength(context: NodeBuilderContext): boolean { + return context.unfoldDepth >= 0 && checkTruncationLength(context); + } + function checkTruncationLength(context: NodeBuilderContext): boolean { if (context.truncating) return context.truncating; return context.truncating = context.approximateLength > ((context.flags & NodeBuilderFlags.NoTruncation) ? noTruncationMaximumTruncationLength : defaultMaximumTruncationLength); @@ -8685,13 +8689,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let firstChar = symbolName.charCodeAt(0); if (isSingleOrDoubleQuote(firstChar) && some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context)); + const specifier = getSpecifierForModuleSymbol(symbol, context); + context.approximateLength += 2 + specifier.length; // "specifier" + return factory.createStringLiteral(specifier); } if (index === 0 || canUsePropertyAccess(symbolName, languageVersion)) { const identifier = setEmitFlags(factory.createIdentifier(symbolName), EmitFlags.NoAsciiEscaping); if (typeParameterNodes) setIdentifierTypeArguments(identifier, factory.createNodeArray(typeParameterNodes)); identifier.symbol = symbol; - + context.approximateLength += 1 + symbolName.length; // .symbolName return index > 0 ? factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier; } else { @@ -8701,17 +8707,22 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } let expression: Expression | undefined; if (isSingleOrDoubleQuote(firstChar) && !(symbol.flags & SymbolFlags.EnumMember)) { - expression = factory.createStringLiteral(stripQuotes(symbolName).replace(/\\./g, s => s.substring(1)), firstChar === CharacterCodes.singleQuote); + const literalText = stripQuotes(symbolName).replace(/\\./g, s => s.substring(1)); + context.approximateLength += literalText.length + 2; // "literalText" + expression = factory.createStringLiteral(literalText, firstChar === CharacterCodes.singleQuote); } else if (("" + +symbolName) === symbolName) { + context.approximateLength += symbolName.length; // +symbolName expression = factory.createNumericLiteral(+symbolName); } if (!expression) { const identifier = setEmitFlags(factory.createIdentifier(symbolName), EmitFlags.NoAsciiEscaping); if (typeParameterNodes) setIdentifierTypeArguments(identifier, factory.createNodeArray(typeParameterNodes)); identifier.symbol = symbol; + context.approximateLength += symbolName.length; // symbolName expression = identifier; } + context.approximateLength += 2; // [] return factory.createElementAccessExpression(createExpressionFromSymbolChain(chain, index - 1), expression); } } @@ -9334,9 +9345,18 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (!suppressNewPrivateContext) { deferredPrivatesStack.push(new Map()); } - symbolTable.forEach((symbol: Symbol) => { + let i = 0; + const symbols = Array.from(symbolTable.values()); + for (const symbol of symbols) { + i++; + if (checkUnfoldingTruncationLength(context) && (i + 2 < symbolTable.size - 1)) { + context.out.truncated = true; + results.push(createTruncationStatement(`... (${symbolTable.size - i} more ...)`)); + serializeSymbol(symbols[symbols.length - 1], /*isPrivate*/ false, !!propertyAsAlias); + break; + } serializeSymbol(symbol, /*isPrivate*/ false, !!propertyAsAlias); - }); + } if (!suppressNewPrivateContext) { // deferredPrivates will be filled up by visiting the symbol table // And will continue to iterate as elements are added while visited `deferredPrivates` @@ -9462,6 +9482,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { && type.symbol?.valueDeclaration && isSourceFile(type.symbol.valueDeclaration) ) { const alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; + context.approximateLength += 12 + ((alias?.escapedText as string | undefined)?.length ?? 0); // `export { alias };` addResult( factory.createExportDeclaration( /*modifiers*/ undefined, @@ -9483,6 +9504,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { ), textRange, ); + context.approximateLength += 7 + name.length; // `var name: ;` addResult(statement, name !== localName ? modifierFlags & ~ModifierFlags.Export : modifierFlags); if (name !== localName && !isPrivate) { // We rename the variable declaration we generate for Property symbols since they may have a name which @@ -9506,6 +9528,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // export { g_1 as g }; // ``` // To create an export named `g` that does _not_ shadow the local `g` + context.approximateLength += 16 + name.length + localName.length; // `export { name as localName };` addResult( factory.createExportDeclaration( /*modifiers*/ undefined, @@ -9560,19 +9583,26 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { for (const node of symbol.declarations) { const resolvedModule = resolveExternalModuleName(node, (node as ExportDeclaration).moduleSpecifier!); if (!resolvedModule) continue; - addResult(factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ (node as ExportDeclaration).isTypeOnly, /*exportClause*/ undefined, factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), ModifierFlags.None); + const isTypeOnly = (node as ExportDeclaration).isTypeOnly; + const specifier = getSpecifierForModuleSymbol(resolvedModule, context); + context.approximateLength += 17 + specifier.length; // `export * from "specifier";` + addResult(factory.createExportDeclaration(/*modifiers*/ undefined, isTypeOnly, /*exportClause*/ undefined, factory.createStringLiteral(specifier)), ModifierFlags.None); } } } if (needsPostExportDefault) { - addResult(factory.createExportAssignment(/*modifiers*/ undefined, /*isExportEquals*/ false, factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), ModifierFlags.None); + const internalSymbolName = getInternalSymbolName(symbol, symbolName); + context.approximateLength += 16 + internalSymbolName.length; // `export default internalName;` + addResult(factory.createExportAssignment(/*modifiers*/ undefined, /*isExportEquals*/ false, factory.createIdentifier(internalSymbolName)), ModifierFlags.None); } else if (needsExportDeclaration) { + const internalSymbolName = getInternalSymbolName(symbol, symbolName); + context.approximateLength += 22 + symbolName.length + internalSymbolName.length; // `export { internalName as symbolName };` addResult( factory.createExportDeclaration( /*modifiers*/ undefined, /*isTypeOnly*/ false, - factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)]), + factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, internalSymbolName, symbolName)]), ), ModifierFlags.None, ); @@ -9603,6 +9633,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` function addResult(node: Statement, additionalModifierFlags: ModifierFlags) { if (canHaveModifiers(node)) { + const oldModifierFlags = getEffectiveModifierFlags(node); let newModifierFlags: ModifierFlags = ModifierFlags.None; const enclosingDeclaration = context.enclosingDeclaration && (isJSDocTypeAlias(context.enclosingDeclaration) ? getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); @@ -9626,8 +9657,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { newModifierFlags |= ModifierFlags.Default; } if (newModifierFlags) { - node = factory.replaceModifiers(node, newModifierFlags | getEffectiveModifierFlags(node)); + node = factory.replaceModifiers(node, newModifierFlags | oldModifierFlags); } + context.approximateLength += modifiersLength(newModifierFlags | oldModifierFlags); } results.push(node); } @@ -9646,9 +9678,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { && isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && syntacticNodeBuilder.tryReuseExistingTypeNode(context, jsdocAliasDecl.typeExpression.type) || typeToTypeNodeHelper(aliasType, context); + const internalSymbolName = getInternalSymbolName(symbol, symbolName); + context.approximateLength += 8 + (commentText?.length ?? 0) + internalSymbolName.length; // `/* comment */ type name = ...` addResult( setSyntheticLeadingComments( - factory.createTypeAliasDeclaration(/*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), + factory.createTypeAliasDeclaration(/*modifiers*/ undefined, internalSymbolName, typeParamDecls, typeNode), !commentText ? [] : [{ kind: SyntaxKind.MultiLineCommentTrivia, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }], ), modifierFlags, @@ -9658,12 +9692,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function serializeInterface(symbol: Symbol, symbolName: string, modifierFlags: ModifierFlags) { + const internalSymbolName = getInternalSymbolName(symbol, symbolName); + context.approximateLength += 14 + internalSymbolName.length; // `interface name { }` const interfaceType = getDeclaredTypeOfClassOrInterface(symbol); const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); const typeParamDecls = map(localParams, p => typeParameterToDeclaration(p, context)); const baseTypes = getBaseTypes(interfaceType); const baseType = length(baseTypes) ? getIntersectionType(baseTypes) : undefined; - const members = flatMap(getPropertiesOfType(interfaceType), p => serializePropertySymbolForInterface(p, baseType)); + const members = serializePropertySymbolsForClassOrInterface(getPropertiesOfType(interfaceType), /*isClass*/ false, baseType); const callSignatures = serializeSignatures(SignatureKind.Call, interfaceType, baseType, SyntaxKind.CallSignature) as CallSignatureDeclaration[]; const constructSignatures = serializeSignatures(SignatureKind.Construct, interfaceType, baseType, SyntaxKind.ConstructSignature) as ConstructSignatureDeclaration[]; const indexSignatures = serializeIndexSignatures(interfaceType, baseType); @@ -9672,7 +9708,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { addResult( factory.createInterfaceDeclaration( /*modifiers*/ undefined, - getInternalSymbolName(symbol, symbolName), + internalSymbolName, typeParamDecls, heritageClauses, [...indexSignatures, ...constructSignatures, ...callSignatures, ...members], @@ -9681,6 +9717,56 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { ); } + function serializePropertySymbolsForClassOrInterface(props: readonly Symbol[], isClass: false, baseType: Type | undefined): TypeElement[]; + function serializePropertySymbolsForClassOrInterface(props: readonly Symbol[], isClass: true, baseType: Type | undefined, isStatic: boolean): ClassElement[]; + function serializePropertySymbolsForClassOrInterface(props: readonly Symbol[], isClass: boolean, baseType: Type | undefined, isStatic?: boolean): (ClassElement | TypeElement)[] { + const elements: (ClassElement | TypeElement)[] = []; + let i = 0; + for (const prop of props) { + i++; + if (checkUnfoldingTruncationLength(context) && (i + 2 < props.length - 1)) { + context.out.truncated = true; + const placeholder = isClass ? + factory.createPropertyDeclaration( + /*modifiers*/ undefined, + `... ${props.length - i} more ... `, + /*questionOrExclamationToken*/ undefined, + /*type*/ undefined, + /*initializer*/ undefined, + ) : + factory.createPropertySignature( + /*modifiers*/ undefined, + `... ${props.length - i} more ... `, + /*questionToken*/ undefined, + /*type*/ undefined, + ); + elements.push(placeholder); + const result = isClass ? + serializePropertySymbolForClass(props[props.length - 1], isStatic!, baseType) : + serializePropertySymbolForInterface(props[props.length - 1], baseType); + if (isArray(result)) { + elements.push(...result); + } + else { + elements.push(result); + } + break; + } + + context.approximateLength += 1; // separator + const result = isClass ? + serializePropertySymbolForClass(prop, isStatic!, baseType) : + serializePropertySymbolForInterface(prop, baseType); + if (isArray(result)) { + elements.push(...result); + } + else { + elements.push(result); + } + } + return elements; + } + function getNamespaceMembersForSerialization(symbol: Symbol) { let exports = arrayFrom(getExportsOfSymbol(symbol).values()); const merged = getMergedSymbol(symbol); @@ -9747,23 +9833,50 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function serializeEnum(symbol: Symbol, symbolName: string, modifierFlags: ModifierFlags) { + const internalSymbolName = getInternalSymbolName(symbol, symbolName); + context.approximateLength += 9 + internalSymbolName.length; // `enum internalName { }` + const members: EnumMember[] = []; + const memberProps = filter(getPropertiesOfType(getTypeOfSymbol(symbol)), p => !!(p.flags & SymbolFlags.EnumMember)); + let i = 0; + for (const p of memberProps) { + i++; + if (checkUnfoldingTruncationLength(context) && (i + 2 < memberProps.length - 1)) { + context.out.truncated = true; + members.push(factory.createEnumMember(` ... ${memberProps.length - i} more ... `)); + const last = memberProps[memberProps.length - 1]; + const initializedValue = last.declarations && last.declarations[0] && isEnumMember(last.declarations[0]) ? getConstantValue(last.declarations[0]) : undefined; + const initializer = initializedValue === undefined ? undefined : + typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : + factory.createNumericLiteral(initializedValue); + const memberName = unescapeLeadingUnderscores(last.escapedName); + const member = factory.createEnumMember( + memberName, + initializer, + ); + members.push(member); + break; + } + // TODO: Handle computed names + // I hate that to get the initialized value we need to walk back to the declarations here; but there's no + // other way to get the possible const value of an enum member that I'm aware of, as the value is cached + // _on the declaration_, not on the declaration's symbol... + const initializedValue = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) ? getConstantValue(p.declarations[0]) : undefined; + const initializer = initializedValue === undefined ? undefined : + typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : + factory.createNumericLiteral(initializedValue); + const memberName = unescapeLeadingUnderscores(p.escapedName); + context.approximateLength += 4 + memberName.length + (initializer?.text.length ?? 0); // `member = initializer,` + const member = factory.createEnumMember( + memberName, + initializer, + ); + members.push(member); + }; addResult( factory.createEnumDeclaration( factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? ModifierFlags.Const : 0), - getInternalSymbolName(symbol, symbolName), - map(filter(getPropertiesOfType(getTypeOfSymbol(symbol)), p => !!(p.flags & SymbolFlags.EnumMember)), p => { - // TODO: Handle computed names - // I hate that to get the initialized value we need to walk back to the declarations here; but there's no - // other way to get the possible const value of an enum member that I'm aware of, as the value is cached - // _on the declaration_, not on the declaration's symbol... - const initializedValue = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) ? getConstantValue(p.declarations[0]) : undefined; - return factory.createEnumMember( - unescapeLeadingUnderscores(p.escapedName), - initializedValue === undefined ? undefined : - typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : - factory.createNumericLiteral(initializedValue), - ); - }), + internalSymbolName, + members, ), modifierFlags, ); @@ -9772,6 +9885,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function serializeAsFunctionNamespaceMerge(type: Type, symbol: Symbol, localName: string, modifierFlags: ModifierFlags) { const signatures = getSignaturesOfType(type, SignatureKind.Call); for (const sig of signatures) { + context.approximateLength += 1; // ; // Each overload becomes a separate function declaration, in order const decl = signatureToSignatureDeclarationHelper(sig, SyntaxKind.FunctionDeclaration, context, { name: factory.createIdentifier(localName) }) as FunctionDeclaration; addResult(setTextRange(context, decl, getSignatureTextRangeLocation(sig)), modifierFlags); @@ -9783,6 +9897,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } + function createTruncationStatement(dotDotDotText: string): Statement { + return factory.createExpressionStatement(factory.createIdentifier(dotDotDotText)) + } + function getSignatureTextRangeLocation(signature: Signature) { if (signature.declaration && signature.declaration.parent) { if (isBinaryExpression(signature.declaration.parent) && getAssignmentDeclarationKind(signature.declaration.parent) === AssignmentDeclarationKind.Property) { @@ -9799,6 +9917,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function serializeAsNamespaceDeclaration(props: readonly Symbol[], localName: string, modifierFlags: ModifierFlags, suppressNewPrivateContext: boolean) { const unfolding = isUnfolding(context); if (length(props)) { + context.approximateLength += localName.length + 14; // "namespace localName { }" const localVsRemoteMap = arrayToMultiMap(props, p => !length(p.declarations) || some(p.declarations, d => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration!)) || unfolding ? "local" : "remote"); const localProps = localVsRemoteMap.get("local") || emptyArray; // handle remote props first - we need to make an `import` declaration that points at the module containing each remote @@ -9853,6 +9972,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { addResult(fakespace, modifierFlags); // namespaces can never be default exported } else if (unfolding) { + context.approximateLength += localName.length + 14; // "namespace { }" addResult( factory.createModuleDeclaration( /*modifiers*/ undefined, @@ -9861,7 +9981,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { NodeFlags.Namespace, ), modifierFlags, - ) + ); } } @@ -9904,11 +10024,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function serializeAsClass(symbol: Symbol, localName: string, modifierFlags: ModifierFlags) { + context.approximateLength += 9 + localName.length; // `class localName { }` const originalDecl = symbol.declarations?.find(isClassLike); const oldEnclosing = context.enclosingDeclaration; context.enclosingDeclaration = originalDecl || oldEnclosing; const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); const typeParamDecls = map(localParams, p => typeParameterToDeclaration(p, context)); + forEach(localParams, p => context.approximateLength += symbolName(p.symbol).length); const classType = getTypeWithThisArgument(getDeclaredTypeOfClassOrInterface(symbol)) as InterfaceType; const baseTypes = getBaseTypes(classType); const originalImplements = originalDecl && getEffectiveImplementsTypeNodes(originalDecl); @@ -9919,6 +10041,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType as InterfaceType) : anyType; + context.approximateLength += (length(baseTypes) ? 8 : 0) + (length(implementsExpressions) ? 11 : 0); // `extends ` and `implements ` const heritageClauses = [ ...!length(baseTypes) ? [] : [factory.createHeritageClause(SyntaxKind.ExtendsKeyword, map(baseTypes, b => serializeBaseType(b, staticBaseType, localName)))], ...!length(implementsExpressions) ? [] : [factory.createHeritageClause(SyntaxKind.ImplementsKeyword, implementsExpressions)], @@ -9929,10 +10052,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Boil down all private properties into a single one. const privateProperties = hasPrivateIdentifier ? isUnfolding(context) ? - flatMap( - filter(symbolProps, isHashPrivate), - p => serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]) - ) : + serializePropertySymbolsForClassOrInterface(filter(symbolProps, isHashPrivate), /*isClass*/ true, baseTypes[0], /*isStatic*/ false) : [factory.createPropertyDeclaration( /*modifiers*/ undefined, factory.createPrivateIdentifier("#private"), @@ -9941,11 +10061,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { /*initializer*/ undefined, )] : emptyArray; - const publicProperties = flatMap(publicSymbolProps, p => serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0])); + if (hasPrivateIdentifier && !isUnfolding(context)) { + context.approximateLength += 9; // `#private;` + } + const publicProperties = serializePropertySymbolsForClassOrInterface(publicSymbolProps, /*isClass*/ true, baseTypes[0], /*isStatic*/ false); // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics - const staticMembers = flatMap( + const staticMembers = serializePropertySymbolsForClassOrInterface( filter(getPropertiesOfType(staticType), p => !(p.flags & SymbolFlags.Prototype) && p.escapedName !== "prototype" && !isNamespaceMember(p)), - p => serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType), + /*isClass*/ true, + staticBaseType, + /*isStatic*/ true, ); // When we encounter an `X.prototype.y` assignment in a JS file, we bind `X` as a class regardless as to whether // the value is ever initialized with a class or function-like value. For cases where `X` could never be @@ -9954,6 +10079,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { !!symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && !some(getSignaturesOfType(staticType, SignatureKind.Construct)); + if (isNonConstructableClassLikeInJsFile) context.approximateLength += 21; // `private constructor()` const constructors = isNonConstructableClassLikeInJsFile ? [factory.createConstructorDeclaration(factory.createModifiersFromModifierFlags(ModifierFlags.Private), [], /*body*/ undefined)] : serializeSignatures(SignatureKind.Construct, staticType, staticBaseType, SyntaxKind.Constructor) as ConstructorDeclaration[]; @@ -10022,6 +10148,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // const { SomeClass } = require('./lib'); const specifier = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' const { propertyName } = node as BindingElement; + const propertyNameText = propertyName && isIdentifier(propertyName) ? idText(propertyName) : undefined; + context.approximateLength += 24 + localName.length + specifier.length + (propertyNameText?.length ?? 0); // `import { propertyName as name } from "specifier";` addResult( factory.createImportDeclaration( /*modifiers*/ undefined, @@ -10030,7 +10158,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { /*name*/ undefined, factory.createNamedImports([factory.createImportSpecifier( /*isTypeOnly*/ false, - propertyName && isIdentifier(propertyName) ? factory.createIdentifier(idText(propertyName)) : undefined, + propertyNameText ? factory.createIdentifier(propertyNameText) : undefined, factory.createIdentifier(localName), )]), ), @@ -10061,6 +10189,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const uniqueName = factory.createUniqueName(localName); // _x const specifier = getSpecifierForModuleSymbol(target.parent || target, context); // 'y' // import _x = require('y'); + context.approximateLength += 22 + specifier.length + idText(uniqueName).length; // `import uniqueName = require("specifier");` addResult( factory.createImportEqualsDeclaration( /*modifiers*/ undefined, @@ -10071,6 +10200,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { ModifierFlags.None, ); // import x = _x.z + context.approximateLength += 12 + localName.length + idText(uniqueName).length + idText(initializer.name).length; // `import localName = uniqueName.initializerName;` addResult( factory.createImportEqualsDeclaration( /*modifiers*/ undefined, @@ -10093,6 +10223,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Could be a local `import localName = ns.member` or // an external `import localName = require("whatever")` const isLocalImport = !(target.flags & SymbolFlags.ValueModule) && !isVariableDeclaration(node); + context.approximateLength += 11 + localName.length + unescapeLeadingUnderscores(target.escapedName).length; // `import localName = target;` addResult( factory.createImportEqualsDeclaration( /*modifiers*/ undefined, @@ -10116,6 +10247,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const specifier = context.bundled ? factory.createStringLiteral(generatedSpecifier) : (node as ImportClause).parent.moduleSpecifier; const attributes = isImportDeclaration(node.parent) ? node.parent.attributes : undefined; const isTypeOnly = isJSDocImportTag((node as ImportClause).parent); + context.approximateLength += 14 + localName.length + 3 + (isTypeOnly ? 4 : 0); // `import localName from specifier;`, approximate specifier addResult( factory.createImportDeclaration( /*modifiers*/ undefined, @@ -10131,6 +10263,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context); // generate specifier (even though we're reusing and existing one) for ambient module reference include side effects const specifier = context.bundled ? factory.createStringLiteral(generatedSpecifier) : (node as NamespaceImport).parent.parent.moduleSpecifier; const isTypeOnly = isJSDocImportTag((node as NamespaceImport).parent.parent); + context.approximateLength += 19 + localName.length + 3 + (isTypeOnly ? 4 : 0); // `import * as localName from specifier;`, approximate specifier addResult( factory.createImportDeclaration( /*modifiers*/ undefined, @@ -10143,6 +10276,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { break; } case SyntaxKind.NamespaceExport: + context.approximateLength += 19 + localName.length + 3; // `export * as localName from specifier;`, approximate specifier addResult( factory.createExportDeclaration( /*modifiers*/ undefined, @@ -10157,6 +10291,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context); // generate specifier (even though we're reusing and existing one) for ambient module reference include side effects const specifier = context.bundled ? factory.createStringLiteral(generatedSpecifier) : (node as ImportSpecifier).parent.parent.parent.moduleSpecifier; const isTypeOnly = isJSDocImportTag((node as ImportSpecifier).parent.parent.parent); + context.approximateLength += 19 + localName.length + 3 + (isTypeOnly ? 4 : 0); // `import { localName } from specifier;`, approximate specifier addResult( factory.createImportDeclaration( /*modifiers*/ undefined, @@ -10218,6 +10353,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function serializeExportSpecifier(localName: string, targetName: string, specifier?: Expression) { + context.approximateLength += 16 + localName.length + (localName !== targetName ? targetName.length : 0); // `export { targetName as localName };` addResult( factory.createExportDeclaration( /*modifiers*/ undefined, @@ -10266,6 +10402,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const prevDisableTrackSymbol = context.tracker.disableTrackSymbol; context.tracker.disableTrackSymbol = true; if (isExportAssignmentCompatibleSymbolName) { + context.approximateLength += 10; // `export = ;` results.push(factory.createExportAssignment( /*modifiers*/ undefined, isExportEquals, @@ -10283,6 +10420,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { else { // serialize as `import _Ref = t.arg.et; export { _Ref as name }` const varName = getUnusedName(name, symbol); + context.approximateLength += varName.length + 10; // `import name = ;` addResult( factory.createImportEqualsDeclaration( /*modifiers*/ undefined, @@ -10310,6 +10448,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } else { const flags = context.enclosingDeclaration?.kind === SyntaxKind.ModuleDeclaration && (!(symbol.flags & SymbolFlags.Accessor) || symbol.flags & SymbolFlags.SetAccessor) ? NodeFlags.Let : NodeFlags.Const; + context.approximateLength += varName.length + 5; // `var name: ;` const statement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ @@ -10326,6 +10465,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { ); } if (isExportAssignmentCompatibleSymbolName) { + context.approximateLength += varName.length + 10; // `export = name;` results.push(factory.createExportAssignment( /*modifiers*/ undefined, isExportEquals, @@ -10440,6 +10580,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { Debug.assert(!!setter); const paramSymbol = isFunctionLikeDeclaration(setter) ? getSignatureFromDeclaration(setter).parameters[0] : undefined; const setterDeclaration = p.declarations?.find(isSetAccessor); + context.approximateLength += modifiersLength(flag) + 7 + (paramSymbol ? symbolName(paramSymbol).length : 5) + (omitType? 0 : 1); // `modifiers set name(param);`, approximate name result.push(setTextRange( context, factory.createSetAccessorDeclaration( @@ -10459,6 +10600,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } if (p.flags & SymbolFlags.GetAccessor) { const getterDeclaration = p.declarations?.find(isGetAccessor); + context.approximateLength += modifiersLength(flag) + 9 + (omitType? 0 : 1); // `modifiers get name(): ;`, approximate name result.push(setTextRange( context, factory.createGetAccessorDeclaration( @@ -10476,10 +10618,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // This is an else/if as accessors and properties can't merge in TS, but might in JS // If this happens, we assume the accessor takes priority, as it imposes more constraints else if (p.flags & (SymbolFlags.Property | SymbolFlags.Variable | SymbolFlags.Accessor)) { + const modifierFlags = (isReadonlySymbol(p) ? ModifierFlags.Readonly : 0) | flag; + context.approximateLength += 1 + (omitType? 0 : 1) + modifiersLength(modifierFlags); // `modifiers name: ;`, approximate name return setTextRange( context, createProperty( - factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? ModifierFlags.Readonly : 0) | flag), + factory.createModifiersFromModifierFlags(modifierFlags), name, p.flags & SymbolFlags.Optional ? factory.createToken(SyntaxKind.QuestionToken) : undefined, omitType ? undefined : serializeTypeForDeclaration(context, p.declarations?.find(isSetAccessorDeclaration), getWriteTypeOfSymbol(p), p), @@ -10494,10 +10638,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const type = getTypeOfSymbol(p); const signatures = getSignaturesOfType(type, SignatureKind.Call); if (omitType) { + const modifierFlags = (isReadonlySymbol(p) ? ModifierFlags.Readonly : 0) | flag; + context.approximateLength += 1 + modifiersLength(modifierFlags); // `modifiers name;`, approximate name return setTextRange( context, createProperty( - factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? ModifierFlags.Readonly : 0) | flag), + factory.createModifiersFromModifierFlags(modifierFlags), name, p.flags & SymbolFlags.Optional ? factory.createToken(SyntaxKind.QuestionToken) : undefined, /*type*/ undefined, @@ -10509,6 +10655,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const results = []; for (const sig of signatures) { + context.approximateLength += 1; // ; // Each overload becomes a separate method declaration, in order const decl = signatureToSignatureDeclarationHelper( sig, @@ -10530,6 +10677,26 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { }; } + function modifiersLength(flags: ModifierFlags): number { + let result = 0; + if (flags & ModifierFlags.Export) result += 6; + if (flags & ModifierFlags.Ambient) result += 7; + if (flags & ModifierFlags.Default) result += 7; + if (flags & ModifierFlags.Const) result += 5; + if (flags & ModifierFlags.Public) result += 6; + if (flags & ModifierFlags.Private) result += 7; + if (flags & ModifierFlags.Protected) result += 9; + if (flags & ModifierFlags.Abstract) result += 8; + if (flags & ModifierFlags.Static) result += 6; + if (flags & ModifierFlags.Override) result += 8; + if (flags & ModifierFlags.Readonly) result += 8; + if (flags & ModifierFlags.Accessor) result += 8; + if (flags & ModifierFlags.Async) result += 5; + if (flags & ModifierFlags.In) result += 2; + if (flags & ModifierFlags.Out) result += 3; + return result; + } + function serializePropertySymbolForInterface(p: Symbol, baseType: Type | undefined) { return serializePropertySymbolForInterfaceWorker(p, /*isStatic*/ false, baseType); } @@ -10580,6 +10747,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const results = []; for (const sig of signatures) { + context.approximateLength += 1; // ; // Each overload becomes a separate constructor declaration, in order const decl = signatureToSignatureDeclarationHelper(sig, outputKind, context); results.push(setTextRange(context, decl, sig.declaration)); diff --git a/tests/baselines/reference/quickinfoVerbosityToplevelTruncation.baseline b/tests/baselines/reference/quickinfoVerbosityToplevelTruncation.baseline new file mode 100644 index 0000000000000..4f74a41b136b5 --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityToplevelTruncation.baseline @@ -0,0 +1,1149 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickinfoVerbosityToplevelTruncation.ts === +// export enum LargeEnum { +// ^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | enum LargeEnum { +// | Member1 = 0, +// | Member2 = 1, +// | Member3 = 2, +// | Member4 = 3, +// | Member5 = 4, +// | Member6 = 5, +// | Member7 = 6, +// | Member8 = 7, +// | Member9 = 8, +// | Member10 = 9, +// | Member11 = 10, +// | Member12 = 11, +// | ... 12 more ... , +// | Member25 = 24 +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// Member1, +// Member2, +// Member3, +// Member4, +// Member5, +// Member6, +// Member7, +// Member8, +// Member9, +// Member10, +// Member11, +// Member12, +// Member13, +// Member14, +// Member15, +// Member16, +// Member17, +// Member18, +// Member19, +// Member20, +// Member21, +// Member22, +// Member23, +// Member24, +// Member25, +// } +// export interface LargeInterface { +// ^^^^^^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | interface LargeInterface { +// | property1: string; +// | property2: number; +// | property3: boolean; +// | property4: Date; +// | property5: string[]; +// | property6: number[]; +// | property7: boolean[]; +// | property8: { +// | [key: string]: unknown; +// | }; +// | property9: string; +// | property10: number; +// | property11: boolean; +// | property12: Date; +// | property13: string | number; +// | ... 6 more ... ; +// | property20: () => void; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// property1: string; +// property2: number; +// property3: boolean; +// property4: Date; +// property5: string[]; +// property6: number[]; +// property7: boolean[]; +// property8: { [key: string]: unknown }; +// property9: string | null; +// property10: number | null; +// property11: boolean | null; +// property12: Date | null; +// property13: string | number; +// property14: number | boolean; +// property15: string | boolean; +// property16: Array<{ id: number; name: string }>; +// property17: Array<{ key: string; value: unknown }>; +// property18: { nestedProp1: string; nestedProp2: number }; +// property19: { nestedProp3: boolean; nestedProp4: Date }; +// property20: () => void; +// } + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityToplevelTruncation.ts", + "position": 21, + "name": "1" + }, + "item": { + "kind": "enum", + "kindModifiers": "export", + "textSpan": { + "start": 12, + "length": 9 + }, + "displayParts": [ + { + "text": "enum", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "LargeEnum", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Member1", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "0", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Member2", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "1", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Member3", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "2", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Member4", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "3", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Member5", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "4", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Member6", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "5", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Member7", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "6", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Member8", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "7", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Member9", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "8", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Member10", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "9", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Member11", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "10", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Member12", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "11", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": " ... 12 more ... ", + "kind": "text" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Member25", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "24", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityToplevelTruncation.ts", + "position": 398, + "name": "2" + }, + "item": { + "kind": "interface", + "kindModifiers": "export", + "textSpan": { + "start": 384, + "length": 14 + }, + "displayParts": [ + { + "text": "interface", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "LargeInterface", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "property1", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "property2", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "property3", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "property4", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Date", + "kind": "localName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "property5", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "property6", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "property7", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "property8", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "key", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": "]", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "unknown", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "property9", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "property10", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "property11", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "boolean", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "property12", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Date", + "kind": "localName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "property13", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "|", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "... 6 more ... ", + "kind": "propertyName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "property20", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityToplevelTruncation.ts b/tests/cases/fourslash/quickinfoVerbosityToplevelTruncation.ts new file mode 100644 index 0000000000000..43b48b7ccb680 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityToplevelTruncation.ts @@ -0,0 +1,57 @@ +/// + +//// export enum LargeEnum/*1*/ { +//// Member1, +//// Member2, +//// Member3, +//// Member4, +//// Member5, +//// Member6, +//// Member7, +//// Member8, +//// Member9, +//// Member10, +//// Member11, +//// Member12, +//// Member13, +//// Member14, +//// Member15, +//// Member16, +//// Member17, +//// Member18, +//// Member19, +//// Member20, +//// Member21, +//// Member22, +//// Member23, +//// Member24, +//// Member25, +//// } + +//// export interface LargeInterface/*2*/ { +//// property1: string; +//// property2: number; +//// property3: boolean; +//// property4: Date; +//// property5: string[]; +//// property6: number[]; +//// property7: boolean[]; +//// property8: { [key: string]: unknown }; +//// property9: string | null; +//// property10: number | null; +//// property11: boolean | null; +//// property12: Date | null; +//// property13: string | number; +//// property14: number | boolean; +//// property15: string | boolean; +//// property16: Array<{ id: number; name: string }>; +//// property17: Array<{ key: string; value: unknown }>; +//// property18: { nestedProp1: string; nestedProp2: number }; +//// property19: { nestedProp3: boolean; nestedProp4: Date }; +//// property20: () => void; +//// } + +verify.baselineQuickInfo({ + 1: [1], + 2: [1], +}) \ No newline at end of file From 794e70bf52c4b17b2df57773c2d3c33aa702dea4 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Wed, 26 Mar 2025 18:16:25 -0700 Subject: [PATCH 16/31] add basic JS tests --- .../reference/quickinfoVerbosityJs.baseline | 1242 +++++++++++++++++ tests/cases/fourslash/quickinfoVerbosityJs.ts | 46 + 2 files changed, 1288 insertions(+) create mode 100644 tests/baselines/reference/quickinfoVerbosityJs.baseline create mode 100644 tests/cases/fourslash/quickinfoVerbosityJs.ts diff --git a/tests/baselines/reference/quickinfoVerbosityJs.baseline b/tests/baselines/reference/quickinfoVerbosityJs.baseline new file mode 100644 index 0000000000000..775dd7de14c5c --- /dev/null +++ b/tests/baselines/reference/quickinfoVerbosityJs.baseline @@ -0,0 +1,1242 @@ +// === QuickInfo === +=== /tests/cases/fourslash/somefile.js === +// /** +// * @typedef {Object} SomeType +// * @property {string} prop1 +// */ +// /** @type {SomeType} */ +// const a = { +// ^ +// | ---------------------------------------------------------------------- +// | const a: { +// | prop1: string; +// | } +// | @type {SomeType} +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | const a: SomeType +// | @type {SomeType} +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// prop1: 'value', +// } +// /** +// * @typedef {Object} SomeType2 +// ^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | type SomeType2 = { +// | prop2: number; +// | prop3: { +// | prop1: string; +// | }; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | type SomeType2 = { +// | prop2: number; +// | prop3: SomeType; +// | } +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// * @property {number} prop2 +// * @property {SomeType} prop3 +// */ +// /** @type {SomeType[]} */ +// const ss = [{ prop1: 'value' }, { prop1: 'value' }]; +// const d = ss.map((s) => s.prop1); +// ^ +// | ---------------------------------------------------------------------- +// | (parameter) s: { +// | prop1: string; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^ +// | ---------------------------------------------------------------------- +// | (parameter) s: SomeType +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// /** @param {SomeType} a +// * @returns {SomeType} +// */ +// function someFun(a) { +// ^^^^^^^ +// | ---------------------------------------------------------------------- +// | function someFun(a: { +// | prop1: string; +// | }): { +// | prop1: string; +// | } +// | namespace someFun { +// | let what: string; +// | } +// | @param a +// | @returns +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^^^ +// | ---------------------------------------------------------------------- +// | function someFun(a: SomeType): SomeType +// | module someFun +// | @param a +// | @returns +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// return a; +// } +// someFun.what = 'what'; +// class SomeClass { +// ^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | class SomeClass { +// | b: { +// | prop2: number; +// | prop3: SomeType; +// | }; +// | } +// | (verbosity level: 2) +// | ---------------------------------------------------------------------- +// ^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | class SomeClass { +// | b: SomeType2; +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^^^^^ +// | ---------------------------------------------------------------------- +// | class SomeClass +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// /** @type {SomeType2} */ +// b; +// } + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/somefile.js", + "position": 97, + "name": "1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 96, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SomeType", + "kind": "aliasName" + } + ], + "documentation": [], + "tags": [ + { + "name": "type", + "text": [ + { + "text": "{SomeType}", + "kind": "text" + } + ] + } + ], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/somefile.js", + "position": 97, + "name": "1" + }, + "item": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 96, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop1", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "tags": [ + { + "name": "type", + "text": [ + { + "text": "{SomeType}", + "kind": "text" + } + ] + } + ], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/somefile.js", + "position": 158, + "name": "2" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 149, + "length": 9 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SomeType2", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop2", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop3", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SomeType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/somefile.js", + "position": 158, + "name": "2" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 149, + "length": 9 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SomeType2", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop2", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop3", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop1", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/somefile.js", + "position": 319, + "name": "3" + }, + "item": { + "kind": "parameter", + "kindModifiers": "", + "textSpan": { + "start": 318, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "parameter", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "s", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SomeType", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/somefile.js", + "position": 319, + "name": "3" + }, + "item": { + "kind": "parameter", + "kindModifiers": "", + "textSpan": { + "start": 318, + "length": 1 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "parameter", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "s", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop1", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/somefile.js", + "position": 401, + "name": "4" + }, + "item": { + "kind": "function", + "kindModifiers": "", + "textSpan": { + "start": 394, + "length": 7 + }, + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someFun", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SomeType", + "kind": "aliasName" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SomeType", + "kind": "aliasName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "module", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someFun", + "kind": "functionName" + } + ], + "documentation": [], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "a", + "kind": "text" + } + ] + }, + { + "name": "returns" + } + ], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/somefile.js", + "position": 401, + "name": "4" + }, + "item": { + "kind": "function", + "kindModifiers": "", + "textSpan": { + "start": 394, + "length": 7 + }, + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someFun", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "a", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop1", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop1", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "someFun", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "let", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "what", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "a", + "kind": "text" + } + ] + }, + { + "name": "returns" + } + ], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/somefile.js", + "position": 461, + "name": "5" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 452, + "length": 9 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SomeClass", + "kind": "className" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/somefile.js", + "position": 461, + "name": "5" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 452, + "length": 9 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SomeClass", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SomeType2", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/somefile.js", + "position": 461, + "name": "5" + }, + "item": { + "kind": "class", + "kindModifiers": "", + "textSpan": { + "start": 452, + "length": 9 + }, + "displayParts": [ + { + "text": "class", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SomeClass", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "b", + "kind": "text" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop2", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "prop3", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "SomeType", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 2 + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityJs.ts b/tests/cases/fourslash/quickinfoVerbosityJs.ts new file mode 100644 index 0000000000000..398674f7bfd38 --- /dev/null +++ b/tests/cases/fourslash/quickinfoVerbosityJs.ts @@ -0,0 +1,46 @@ +/// + +// @Filename: somefile.js +// @allowJs: true +//// /** +//// * @typedef {Object} SomeType +//// * @property {string} prop1 +//// */ + +//// /** @type {SomeType} */ +//// const a/*1*/ = { +//// prop1: 'value', +//// } + +//// /** +//// * @typedef {Object} SomeType2/*2*/ +//// * @property {number} prop2 +//// * @property {SomeType} prop3 +//// */ + +//// /** @type {SomeType[]} */ +//// const ss = [{ prop1: 'value' }, { prop1: 'value' }]; +//// const d = ss.map((s/*3*/) => s.prop1); + +// expando + +//// /** @param {SomeType} a +//// * @returns {SomeType} +//// */ +//// function someFun/*4*/(a) { +//// return a; +//// } +//// someFun.what = 'what'; + +//// class SomeClass/*5*/ { +//// /** @type {SomeType2} */ +//// b; +//// } + +verify.baselineQuickInfo({ + 1: [0, 1], + 2: [0, 1], + 3: [0, 1], + 4: [0, 1], + 5: [0, 1, 2], +}); \ No newline at end of file From d3b2a84774ef8a8c3754dc04fca7dc0d36944173 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Wed, 26 Mar 2025 18:21:35 -0700 Subject: [PATCH 17/31] format --- src/compiler/checker.ts | 40 ++++++++++++++++++----------------- src/services/symbolDisplay.ts | 7 +++--- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 20c148c4a7e1d..7e3fed61fdb7e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6049,7 +6049,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { /*internalFlags*/ undefined, /*tracker*/ undefined, verbosityLevel, - out); + out, + ); const printer = createPrinterWithRemoveCommentsOmitTrailingSemicolon(); const sourceFile = enclosingDeclaration && getSourceFileOfNode(enclosingDeclaration); printer.writeNode(EmitHint.Unspecified, sig!, /*sourceFile*/ sourceFile, getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 @@ -6377,7 +6378,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { /*tracker*/ undefined, verbosityLevel, context => symbolToDeclarationsWorker(symbol, context), - out); + out, + ); return mapDefined(nodes, node => { switch (node.kind) { case SyntaxKind.ClassDeclaration: @@ -6484,7 +6486,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { out: { couldUnfoldMore: false, truncated: false, - } + }, }; context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost); const resultingNode = cb(context); @@ -7011,17 +7013,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } // Always use 'typeof T' for type of class, enum, and module objects else if ( - !forceExpansion && + !forceExpansion && (symbol.flags & SymbolFlags.Class - && !forceClassExpansion - && !getBaseTypeVariableOfClass(symbol) - && !(symbol.valueDeclaration - && isClassLike(symbol.valueDeclaration) - && context.flags & NodeBuilderFlags.WriteClassExpressionAsTypeLiteral - && (!isClassDeclaration(symbol.valueDeclaration) - || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== SymbolAccessibility.Accessible)) - || symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) - || shouldWriteTypeOfFunctionSymbol()) + && !forceClassExpansion + && !getBaseTypeVariableOfClass(symbol) + && !(symbol.valueDeclaration + && isClassLike(symbol.valueDeclaration) + && context.flags & NodeBuilderFlags.WriteClassExpressionAsTypeLiteral + && (!isClassDeclaration(symbol.valueDeclaration) + || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== SymbolAccessibility.Accessible)) + || symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) + || shouldWriteTypeOfFunctionSymbol()) ) { if (canUnfoldType(type, context)) { context.depth += 1; @@ -9787,7 +9789,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function serializeModule(symbol: Symbol, symbolName: string, modifierFlags: ModifierFlags) { - const members = getNamespaceMembersForSerialization(symbol); + const members = getNamespaceMembersForSerialization(symbol); const unfolding = isUnfolding(context); // Split NS members up by declaration - members whose parent symbol is the ns symbol vs those whose is not (but were added in later via merging) const locationMap = arrayToMultiMap(members, m => m.parent && m.parent === symbol || unfolding ? "real" : "merged"); @@ -9871,7 +9873,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { initializer, ); members.push(member); - }; + } addResult( factory.createEnumDeclaration( factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? ModifierFlags.Const : 0), @@ -9898,7 +9900,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function createTruncationStatement(dotDotDotText: string): Statement { - return factory.createExpressionStatement(factory.createIdentifier(dotDotDotText)) + return factory.createExpressionStatement(factory.createIdentifier(dotDotDotText)); } function getSignatureTextRangeLocation(signature: Signature) { @@ -10580,7 +10582,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { Debug.assert(!!setter); const paramSymbol = isFunctionLikeDeclaration(setter) ? getSignatureFromDeclaration(setter).parameters[0] : undefined; const setterDeclaration = p.declarations?.find(isSetAccessor); - context.approximateLength += modifiersLength(flag) + 7 + (paramSymbol ? symbolName(paramSymbol).length : 5) + (omitType? 0 : 1); // `modifiers set name(param);`, approximate name + context.approximateLength += modifiersLength(flag) + 7 + (paramSymbol ? symbolName(paramSymbol).length : 5) + (omitType ? 0 : 1); // `modifiers set name(param);`, approximate name result.push(setTextRange( context, factory.createSetAccessorDeclaration( @@ -10600,7 +10602,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } if (p.flags & SymbolFlags.GetAccessor) { const getterDeclaration = p.declarations?.find(isGetAccessor); - context.approximateLength += modifiersLength(flag) + 9 + (omitType? 0 : 1); // `modifiers get name(): ;`, approximate name + context.approximateLength += modifiersLength(flag) + 9 + (omitType ? 0 : 1); // `modifiers get name(): ;`, approximate name result.push(setTextRange( context, factory.createGetAccessorDeclaration( @@ -10619,7 +10621,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // If this happens, we assume the accessor takes priority, as it imposes more constraints else if (p.flags & (SymbolFlags.Property | SymbolFlags.Variable | SymbolFlags.Accessor)) { const modifierFlags = (isReadonlySymbol(p) ? ModifierFlags.Readonly : 0) | flag; - context.approximateLength += 1 + (omitType? 0 : 1) + modifiersLength(modifierFlags); // `modifiers name: ;`, approximate name + context.approximateLength += 1 + (omitType ? 0 : 1) + modifiersLength(modifierFlags); // `modifiers name: ;`, approximate name return setTextRange( context, createProperty( diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 7892edc5a688d..2a5b2a60c4cf7 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -805,7 +805,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( documentation, symbolKind, tags: tags.length === 0 ? undefined : tags, - canIncreaseVerbosityLevel: verbosityLevel !== undefined ? canIncreaseVerbosityLevel : undefined + canIncreaseVerbosityLevel: verbosityLevel !== undefined ? canIncreaseVerbosityLevel : undefined, }; function getPrinter() { @@ -871,7 +871,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( } function tryUnfoldSymbol(symbol: Symbol, meaning: SemanticMeaning): boolean { - if (hasUnfoldedSymbol) { + if (hasUnfoldedSymbol) { return true; } if (canUnfoldSymbol(symbol, typeWriterOut)) { @@ -882,7 +882,8 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( symbolMeaning, TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, verbosityLevel !== undefined ? verbosityLevel - 1 : undefined, - typeWriterOut); + typeWriterOut, + ); const printer = getPrinter(); nodes.forEach((node, i) => { if (i > 0) writer.writeLine(); From fb7762c4c5dcbca9a7ab5150609465f3959f2645 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Wed, 26 Mar 2025 18:59:52 -0700 Subject: [PATCH 18/31] tiny change unmade --- src/services/symbolDisplay.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 2a5b2a60c4cf7..586187f7c67af 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -437,7 +437,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( ); } if (signature) { - addSignatureDisplayParts(signature, allSignatures, /*flags*/ TypeFormatFlags.None); + addSignatureDisplayParts(signature, allSignatures); } hasAddedSymbolInfo = true; hasMultipleSignatures = allSignatures.length > 1; @@ -511,7 +511,6 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( if (!tryUnfoldSymbol(symbol, semanticMeaning)) { const declaration = getDeclarationOfKind(symbol, SyntaxKind.ModuleDeclaration); const isNamespace = declaration && declaration.name && declaration.name.kind === SyntaxKind.Identifier; - // const isNamespace = !(declaration && declaration.name && declaration.name.kind === SyntaxKind.StringLiteral); // TODO: breaking change displayParts.push(keywordPart(isNamespace ? SyntaxKind.NamespaceKeyword : SyntaxKind.ModuleKeyword)); displayParts.push(spacePart()); addFullSymbolName(symbol); From 8bd48216886c0d0a193bca6193e5162821d093e7 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Thu, 27 Mar 2025 08:27:24 -0700 Subject: [PATCH 19/31] default to printing 'namespace' instead of 'module' --- src/services/symbolDisplay.ts | 2 +- .../completionNoParentLocation.baseline | 4 +- .../completionsCommentsClass.baseline | 4 +- .../completionsCommentsClassMembers.baseline | 80 +++++++++---------- ...completionsCommentsCommentParsing.baseline | 28 +++---- ...etionsCommentsFunctionDeclaration.baseline | 12 +-- ...letionsCommentsFunctionExpression.baseline | 16 ++-- ...completionsCommitCharactersGlobal.baseline | 68 ++++++++-------- .../completionsImportWithKeyword.baseline | 28 +++---- .../completionsImport_asKeyword.baseline | 8 +- ...ompletionsImport_satisfiesKeyword.baseline | 8 +- ...letionsInitializerCommitCharacter.baseline | 4 +- .../exhaustiveCaseCompletions9.baseline | 4 +- ...AllReferencesDynamicImport1.baseline.jsonc | 8 +- ...encesUmdModuleAsGlobalConst.baseline.jsonc | 4 +- .../findAllRefsExportEquals.baseline.jsonc | 4 +- .../findAllRefsForModule.baseline.jsonc | 12 +-- ...AllRefsImportEqualsJsonFile.baseline.jsonc | 8 +- ...findAllRefsModuleDotExports.baseline.jsonc | 8 +- ...efs_importType_exportEquals.baseline.jsonc | 8 +- ...findAllRefs_importType_js.1.baseline.jsonc | 4 +- .../findAllRefs_importType_js.baseline.jsonc | 4 +- ...efs_importType_typeofImport.baseline.jsonc | 8 +- ...esOnRuntimeImportWithPaths1.baseline.jsonc | 4 +- ...foDisplayPartsExternalModuleAlias.baseline | 8 +- ...nfoNestedExportEqualExportDefault.baseline | 8 +- .../quickinfoVerbosityFunction.baseline | 4 +- .../reference/quickinfoVerbosityJs.baseline | 4 +- ...erencesForStatementKeywords.baseline.jsonc | 48 +++++------ ...ailableThroughGlobalNoCrash.baseline.jsonc | 4 +- ...esOnRuntimeImportWithPaths1.baseline.jsonc | 4 +- .../quickInfoElementAccessDeclaration.ts | 2 +- tests/cases/fourslash/quickInfoForRequire.ts | 4 +- .../quickInfoImportNonunicodePath.ts | 2 +- 34 files changed, 213 insertions(+), 213 deletions(-) diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 586187f7c67af..e8b3d2cf0a1bc 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -510,7 +510,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( prefixNextMeaning(); if (!tryUnfoldSymbol(symbol, semanticMeaning)) { const declaration = getDeclarationOfKind(symbol, SyntaxKind.ModuleDeclaration); - const isNamespace = declaration && declaration.name && declaration.name.kind === SyntaxKind.Identifier; + const isNamespace = !(declaration && declaration.name && declaration.name.kind === SyntaxKind.StringLiteral); displayParts.push(keywordPart(isNamespace ? SyntaxKind.NamespaceKeyword : SyntaxKind.ModuleKeyword)); displayParts.push(spacePart()); addFullSymbolName(symbol); diff --git a/tests/baselines/reference/completionNoParentLocation.baseline b/tests/baselines/reference/completionNoParentLocation.baseline index 2e7fa25d92f43..e8fdd98dc0ecd 100644 --- a/tests/baselines/reference/completionNoParentLocation.baseline +++ b/tests/baselines/reference/completionNoParentLocation.baseline @@ -57,7 +57,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1651,7 +1651,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsCommentsClass.baseline b/tests/baselines/reference/completionsCommentsClass.baseline index 1cab2abd39d64..61daeffcd5098 100644 --- a/tests/baselines/reference/completionsCommentsClass.baseline +++ b/tests/baselines/reference/completionsCommentsClass.baseline @@ -109,7 +109,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -2242,7 +2242,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsCommentsClassMembers.baseline b/tests/baselines/reference/completionsCommentsClassMembers.baseline index ff25fd4893846..48d180ff78c51 100644 --- a/tests/baselines/reference/completionsCommentsClassMembers.baseline +++ b/tests/baselines/reference/completionsCommentsClassMembers.baseline @@ -94,7 +94,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -308,7 +308,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -475,7 +475,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -689,7 +689,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -844,7 +844,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1007,7 +1007,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1156,7 +1156,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1318,7 +1318,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1485,7 +1485,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1648,7 +1648,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1811,7 +1811,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1961,7 +1961,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -2113,7 +2113,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -2263,7 +2263,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -2415,7 +2415,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -2565,7 +2565,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -2717,7 +2717,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -2889,7 +2889,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -3079,7 +3079,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -3277,7 +3277,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -6414,7 +6414,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -13976,7 +13976,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -19276,7 +19276,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -26838,7 +26838,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -31384,7 +31384,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -37091,7 +37091,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -41591,7 +41591,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -47252,7 +47252,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -52959,7 +52959,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -58666,7 +58666,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -64373,7 +64373,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -68914,7 +68914,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -73455,7 +73455,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -77996,7 +77996,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -82537,7 +82537,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -87078,7 +87078,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -91619,7 +91619,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -96506,7 +96506,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -102338,7 +102338,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -107431,7 +107431,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsCommentsCommentParsing.baseline b/tests/baselines/reference/completionsCommentsCommentParsing.baseline index 3869899430dcc..8cc8b577c8157 100644 --- a/tests/baselines/reference/completionsCommentsCommentParsing.baseline +++ b/tests/baselines/reference/completionsCommentsCommentParsing.baseline @@ -176,7 +176,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -334,7 +334,7 @@ // | var Function: FunctionConstructor // | (...args: string[]) => Function // | interface Function -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -514,7 +514,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -674,7 +674,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -890,7 +890,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1048,7 +1048,7 @@ // | var Function: FunctionConstructor // | (...args: string[]) => Function // | interface Function -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1240,7 +1240,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -5218,7 +5218,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -11528,7 +11528,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -18248,7 +18248,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -24274,7 +24274,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -30642,7 +30642,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -36952,7 +36952,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -43593,7 +43593,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline b/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline index dda1e063c4812..8e2613966e20a 100644 --- a/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline +++ b/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline @@ -61,7 +61,7 @@ // | var Function: FunctionConstructor // | (...args: string[]) => Function // | interface Function -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -203,7 +203,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -336,7 +336,7 @@ // | var Function: FunctionConstructor // | (...args: string[]) => Function // | interface Function -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -2363,7 +2363,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -6936,7 +6936,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -11113,7 +11113,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsCommentsFunctionExpression.baseline b/tests/baselines/reference/completionsCommentsFunctionExpression.baseline index 0212ef5e5e0a5..865a809123057 100644 --- a/tests/baselines/reference/completionsCommentsFunctionExpression.baseline +++ b/tests/baselines/reference/completionsCommentsFunctionExpression.baseline @@ -62,7 +62,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -214,7 +214,7 @@ // | var Function: FunctionConstructor // | (...args: string[]) => Function // | interface Function -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -383,7 +383,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -517,7 +517,7 @@ // | var Function: FunctionConstructor // | (...args: string[]) => Function // | interface Function -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -2534,7 +2534,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -7111,7 +7111,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -12018,7 +12018,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -16379,7 +16379,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsCommitCharactersGlobal.baseline b/tests/baselines/reference/completionsCommitCharactersGlobal.baseline index 582d3363da492..5e9bb11aea623 100644 --- a/tests/baselines/reference/completionsCommitCharactersGlobal.baseline +++ b/tests/baselines/reference/completionsCommitCharactersGlobal.baseline @@ -83,7 +83,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -255,7 +255,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -426,7 +426,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -595,7 +595,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -764,7 +764,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -932,7 +932,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1103,7 +1103,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1274,7 +1274,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1455,7 +1455,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1629,7 +1629,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1800,7 +1800,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1973,7 +1973,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -2147,7 +2147,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -2320,7 +2320,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -2495,7 +2495,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -2650,7 +2650,7 @@ // | interface Function // | var Function: FunctionConstructor // | interface FunctionConstructor -// | module globalThis +// | namespace globalThis // | interface IArguments // | interface ImportAttributes // | interface ImportCallOptions @@ -2830,7 +2830,7 @@ // | interface Function // | var Function: FunctionConstructor // | interface FunctionConstructor -// | module globalThis +// | namespace globalThis // | interface IArguments // | interface ImportAttributes // | interface ImportCallOptions @@ -5240,7 +5240,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -9991,7 +9991,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -14741,7 +14741,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -19423,7 +19423,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -24110,7 +24110,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -28792,7 +28792,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -33542,7 +33542,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -38292,7 +38292,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -43050,7 +43050,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -47830,7 +47830,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -52581,7 +52581,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -57361,7 +57361,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -62141,7 +62141,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -66966,7 +66966,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -71791,7 +71791,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -78202,7 +78202,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -87673,7 +87673,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsImportWithKeyword.baseline b/tests/baselines/reference/completionsImportWithKeyword.baseline index 6223be88388ed..36268d343657f 100644 --- a/tests/baselines/reference/completionsImportWithKeyword.baseline +++ b/tests/baselines/reference/completionsImportWithKeyword.baseline @@ -65,7 +65,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -213,7 +213,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -360,7 +360,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -508,7 +508,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -656,7 +656,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -803,7 +803,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -942,7 +942,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | import // | in @@ -2598,7 +2598,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -6566,7 +6566,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -10522,7 +10522,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -14494,7 +14494,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -18450,7 +18450,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -22406,7 +22406,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -26191,7 +26191,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsImport_asKeyword.baseline b/tests/baselines/reference/completionsImport_asKeyword.baseline index ab6cc8c862232..07b7ea968e52e 100644 --- a/tests/baselines/reference/completionsImport_asKeyword.baseline +++ b/tests/baselines/reference/completionsImport_asKeyword.baseline @@ -55,7 +55,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -197,7 +197,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1729,7 +1729,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -5635,7 +5635,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsImport_satisfiesKeyword.baseline b/tests/baselines/reference/completionsImport_satisfiesKeyword.baseline index 9fbb9f3a3151d..83e35e632438a 100644 --- a/tests/baselines/reference/completionsImport_satisfiesKeyword.baseline +++ b/tests/baselines/reference/completionsImport_satisfiesKeyword.baseline @@ -55,7 +55,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -197,7 +197,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1729,7 +1729,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -5635,7 +5635,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsInitializerCommitCharacter.baseline b/tests/baselines/reference/completionsInitializerCommitCharacter.baseline index 02e1f65213751..0ed2ce655f70e 100644 --- a/tests/baselines/reference/completionsInitializerCommitCharacter.baseline +++ b/tests/baselines/reference/completionsInitializerCommitCharacter.baseline @@ -57,7 +57,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1621,7 +1621,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/exhaustiveCaseCompletions9.baseline b/tests/baselines/reference/exhaustiveCaseCompletions9.baseline index 5749e8befa01c..a1dba30dcd52e 100644 --- a/tests/baselines/reference/exhaustiveCaseCompletions9.baseline +++ b/tests/baselines/reference/exhaustiveCaseCompletions9.baseline @@ -59,7 +59,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | module globalThis +// | namespace globalThis // | if // | implements // | import @@ -1614,7 +1614,7 @@ "sortText": "15", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllReferencesDynamicImport1.baseline.jsonc b/tests/baselines/reference/findAllReferencesDynamicImport1.baseline.jsonc index 63e5167d0ecd2..bf1da5aed99c7 100644 --- a/tests/baselines/reference/findAllReferencesDynamicImport1.baseline.jsonc +++ b/tests/baselines/reference/findAllReferencesDynamicImport1.baseline.jsonc @@ -24,10 +24,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/tests/cases/fourslash/foo\"", + "name": "namespace \"/tests/cases/fourslash/foo\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -144,10 +144,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/tests/cases/fourslash/foo\"", + "name": "namespace \"/tests/cases/fourslash/foo\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc b/tests/baselines/reference/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc index 3516bee024db8..08c1f5553bb5a 100644 --- a/tests/baselines/reference/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc +++ b/tests/baselines/reference/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc @@ -60,10 +60,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/node_modules/@types/three/index\"", + "name": "namespace \"/node_modules/@types/three/index\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefsExportEquals.baseline.jsonc b/tests/baselines/reference/findAllRefsExportEquals.baseline.jsonc index ce0bdb21e8734..1eba5c5ac0484 100644 --- a/tests/baselines/reference/findAllRefsExportEquals.baseline.jsonc +++ b/tests/baselines/reference/findAllRefsExportEquals.baseline.jsonc @@ -645,10 +645,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/a\"", + "name": "namespace \"/a\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefsForModule.baseline.jsonc b/tests/baselines/reference/findAllRefsForModule.baseline.jsonc index b2fbd06179fe9..e25481a5eb0bf 100644 --- a/tests/baselines/reference/findAllRefsForModule.baseline.jsonc +++ b/tests/baselines/reference/findAllRefsForModule.baseline.jsonc @@ -18,10 +18,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/a\"", + "name": "namespace \"/a\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -58,10 +58,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/a\"", + "name": "namespace \"/a\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -98,10 +98,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/a\"", + "name": "namespace \"/a\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefsImportEqualsJsonFile.baseline.jsonc b/tests/baselines/reference/findAllRefsImportEqualsJsonFile.baseline.jsonc index 7f1d934ba209e..a39cd59a0e558 100644 --- a/tests/baselines/reference/findAllRefsImportEqualsJsonFile.baseline.jsonc +++ b/tests/baselines/reference/findAllRefsImportEqualsJsonFile.baseline.jsonc @@ -148,10 +148,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/j\"", + "name": "namespace \"/j\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -190,10 +190,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/j\"", + "name": "namespace \"/j\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefsModuleDotExports.baseline.jsonc b/tests/baselines/reference/findAllRefsModuleDotExports.baseline.jsonc index c95be2f8836bd..71ae53320ca14 100644 --- a/tests/baselines/reference/findAllRefsModuleDotExports.baseline.jsonc +++ b/tests/baselines/reference/findAllRefsModuleDotExports.baseline.jsonc @@ -49,10 +49,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/b\"", + "name": "namespace \"/b\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -86,10 +86,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/b\"", + "name": "namespace \"/b\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefs_importType_exportEquals.baseline.jsonc b/tests/baselines/reference/findAllRefs_importType_exportEquals.baseline.jsonc index bd7279c9ebebc..d99ceaeef792d 100644 --- a/tests/baselines/reference/findAllRefs_importType_exportEquals.baseline.jsonc +++ b/tests/baselines/reference/findAllRefs_importType_exportEquals.baseline.jsonc @@ -223,10 +223,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/a\"", + "name": "namespace \"/a\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -323,10 +323,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/a\"", + "name": "namespace \"/a\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefs_importType_js.1.baseline.jsonc b/tests/baselines/reference/findAllRefs_importType_js.1.baseline.jsonc index 1170886f836b0..1a93532cd31bf 100644 --- a/tests/baselines/reference/findAllRefs_importType_js.1.baseline.jsonc +++ b/tests/baselines/reference/findAllRefs_importType_js.1.baseline.jsonc @@ -21,7 +21,7 @@ "containerKind": "", "containerName": "", "kind": "local class", - "name": "(local class) C\nmodule C", + "name": "(local class) C\nnamespace C", "displayParts": [ { "text": "(", @@ -48,7 +48,7 @@ "kind": "lineBreak" }, { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefs_importType_js.baseline.jsonc b/tests/baselines/reference/findAllRefs_importType_js.baseline.jsonc index 8fd8197d59865..c0458b741d79e 100644 --- a/tests/baselines/reference/findAllRefs_importType_js.baseline.jsonc +++ b/tests/baselines/reference/findAllRefs_importType_js.baseline.jsonc @@ -20,10 +20,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/a\"", + "name": "namespace \"/a\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefs_importType_typeofImport.baseline.jsonc b/tests/baselines/reference/findAllRefs_importType_typeofImport.baseline.jsonc index bad8985b8fcec..6cf734530bcf8 100644 --- a/tests/baselines/reference/findAllRefs_importType_typeofImport.baseline.jsonc +++ b/tests/baselines/reference/findAllRefs_importType_typeofImport.baseline.jsonc @@ -81,10 +81,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/a\"", + "name": "namespace \"/a\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -184,10 +184,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/a\"", + "name": "namespace \"/a\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/jsxFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc b/tests/baselines/reference/jsxFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc index e512e8d47cbd7..cc17a6c7f8121 100644 --- a/tests/baselines/reference/jsxFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc +++ b/tests/baselines/reference/jsxFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc @@ -30,10 +30,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/tests/cases/fourslash/project/src/dir/jsx-runtime\"", + "name": "namespace \"/tests/cases/fourslash/project/src/dir/jsx-runtime\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/quickInfoDisplayPartsExternalModuleAlias.baseline b/tests/baselines/reference/quickInfoDisplayPartsExternalModuleAlias.baseline index 7745fa2442617..d41bfb5ea749a 100644 --- a/tests/baselines/reference/quickInfoDisplayPartsExternalModuleAlias.baseline +++ b/tests/baselines/reference/quickInfoDisplayPartsExternalModuleAlias.baseline @@ -7,7 +7,7 @@ // | ---------------------------------------------------------------------- // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- -// | module a1 +// | namespace a1 // | ---------------------------------------------------------------------- // new a1.m1.c(); // ^^ @@ -21,7 +21,7 @@ // | ---------------------------------------------------------------------- // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- -// | module a1 +// | namespace a1 // | ---------------------------------------------------------------------- // new a2.m1.c(); // ^^ @@ -103,7 +103,7 @@ }, "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -249,7 +249,7 @@ }, "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/quickInfoNestedExportEqualExportDefault.baseline b/tests/baselines/reference/quickInfoNestedExportEqualExportDefault.baseline index 3dec1073bd9e2..8c16caff716d5 100644 --- a/tests/baselines/reference/quickInfoNestedExportEqualExportDefault.baseline +++ b/tests/baselines/reference/quickInfoNestedExportEqualExportDefault.baseline @@ -6,7 +6,7 @@ // | ---------------------------------------------------------------------- // | class (Anonymous function).default // | enum (Anonymous function).default -// | module (Anonymous function).default +// | namespace (Anonymous function).default // | (enum member) (Anonymous function).default // | (enum member) (Anonymous function).default: {} // | ---------------------------------------------------------------------- @@ -14,7 +14,7 @@ // | ---------------------------------------------------------------------- // | class (Anonymous function).default // | enum (Anonymous function).default -// | module (Anonymous function).default +// | namespace (Anonymous function).default // | (enum member) (Anonymous function).default // | (enum member) (Anonymous function).default: {} // | ---------------------------------------------------------------------- @@ -85,7 +85,7 @@ "kind": "lineBreak" }, { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -251,7 +251,7 @@ "kind": "lineBreak" }, { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/quickinfoVerbosityFunction.baseline b/tests/baselines/reference/quickinfoVerbosityFunction.baseline index e253de89765b7..a5996a2923022 100644 --- a/tests/baselines/reference/quickinfoVerbosityFunction.baseline +++ b/tests/baselines/reference/quickinfoVerbosityFunction.baseline @@ -77,7 +77,7 @@ // | ---------------------------------------------------------------------- // ^^^^^^^ // | ---------------------------------------------------------------------- -// | module someFun +// | namespace someFun // | function someFun(a: SomeType): SomeType // | (verbosity level: 0) // | ---------------------------------------------------------------------- @@ -978,7 +978,7 @@ }, "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/quickinfoVerbosityJs.baseline b/tests/baselines/reference/quickinfoVerbosityJs.baseline index 775dd7de14c5c..34a2998c97768 100644 --- a/tests/baselines/reference/quickinfoVerbosityJs.baseline +++ b/tests/baselines/reference/quickinfoVerbosityJs.baseline @@ -81,7 +81,7 @@ // ^^^^^^^ // | ---------------------------------------------------------------------- // | function someFun(a: SomeType): SomeType -// | module someFun +// | namespace someFun // | @param a // | @returns // | (verbosity level: 0) @@ -734,7 +734,7 @@ "kind": "lineBreak" }, { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/referencesForStatementKeywords.baseline.jsonc b/tests/baselines/reference/referencesForStatementKeywords.baseline.jsonc index d75e92c4c4251..448fb9a373ba6 100644 --- a/tests/baselines/reference/referencesForStatementKeywords.baseline.jsonc +++ b/tests/baselines/reference/referencesForStatementKeywords.baseline.jsonc @@ -89,10 +89,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/a\"", + "name": "namespace \"/a\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -447,10 +447,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/b\"", + "name": "namespace \"/b\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -639,10 +639,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/c\"", + "name": "namespace \"/c\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -901,10 +901,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/d\"", + "name": "namespace \"/d\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -972,10 +972,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/e\"", + "name": "namespace \"/e\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -1108,10 +1108,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/f\"", + "name": "namespace \"/f\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -1150,10 +1150,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/g\"", + "name": "namespace \"/g\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -1192,10 +1192,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/g\"", + "name": "namespace \"/g\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -1234,10 +1234,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/g\"", + "name": "namespace \"/g\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -1426,10 +1426,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/h\"", + "name": "namespace \"/h\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -1688,10 +1688,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/i\"", + "name": "namespace \"/i\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { @@ -1762,10 +1762,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/j\"", + "name": "namespace \"/j\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc b/tests/baselines/reference/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc index 080e387be7318..b28a786efdb8c 100644 --- a/tests/baselines/reference/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc +++ b/tests/baselines/reference/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc @@ -30,10 +30,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/packages/playwright-core/bundles/utils/node_modules/@types/debug/index\"", + "name": "namespace \"/packages/playwright-core/bundles/utils/node_modules/@types/debug/index\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/baselines/reference/tslibFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc b/tests/baselines/reference/tslibFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc index 2afc5d77de9eb..ebeee5b8d825b 100644 --- a/tests/baselines/reference/tslibFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc +++ b/tests/baselines/reference/tslibFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc @@ -19,10 +19,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "module \"/tests/cases/fourslash/project/src/dir/tslib\"", + "name": "namespace \"/tests/cases/fourslash/project/src/dir/tslib\"", "displayParts": [ { - "text": "module", + "text": "namespace", "kind": "keyword" }, { diff --git a/tests/cases/fourslash/quickInfoElementAccessDeclaration.ts b/tests/cases/fourslash/quickInfoElementAccessDeclaration.ts index 4f36146887490..f4d2905f12e22 100644 --- a/tests/cases/fourslash/quickInfoElementAccessDeclaration.ts +++ b/tests/cases/fourslash/quickInfoElementAccessDeclaration.ts @@ -8,5 +8,5 @@ ////mod["/**/@@thing1"]["@@thing2"] = 0; goTo.marker(); -verify.quickInfoIs(`module mod["@@thing1"] +verify.quickInfoIs(`namespace mod["@@thing1"] (property) mod["@@thing1"]: typeof mod.@@thing1`); diff --git a/tests/cases/fourslash/quickInfoForRequire.ts b/tests/cases/fourslash/quickInfoForRequire.ts index 231dd8603b288..5595ddde472bf 100644 --- a/tests/cases/fourslash/quickInfoForRequire.ts +++ b/tests/cases/fourslash/quickInfoForRequire.ts @@ -9,7 +9,7 @@ goTo.marker("1"); -verify.quickInfoIs("module a"); +verify.quickInfoIs("namespace a"); goTo.marker("2"); -verify.quickInfoIs("module a"); +verify.quickInfoIs("namespace a"); diff --git a/tests/cases/fourslash/quickInfoImportNonunicodePath.ts b/tests/cases/fourslash/quickInfoImportNonunicodePath.ts index 62d043a214b86..62dd4a073a8f6 100644 --- a/tests/cases/fourslash/quickInfoImportNonunicodePath.ts +++ b/tests/cases/fourslash/quickInfoImportNonunicodePath.ts @@ -6,4 +6,4 @@ // @Filename: /test.ts //// import { foo } from "./江南/*1*/今何在/tmp"; -verify.quickInfoAt("1", 'module "/江南今何在/tmp"'); +verify.quickInfoAt("1", 'namespace "/江南今何在/tmp"'); From 2511624915b416ee2ab104cfda709913fdeda4ab Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Thu, 27 Mar 2025 08:44:44 -0700 Subject: [PATCH 20/31] update protocol comments --- src/server/protocol.ts | 7 +++++-- tests/baselines/reference/api/typescript.d.ts | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 4683a1f300662..6031643109680 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2006,7 +2006,10 @@ export interface QuickInfoRequest extends FileLocationRequest { } export interface QuickInfoRequestArgs extends FileLocationRequestArgs { - /** TODO */ + /** + * This controls how many levels of definitions will be expanded in the quick info response. + * The default value is 0. + */ verbosityLevel?: number; } @@ -2051,7 +2054,7 @@ export interface QuickInfoResponseBody { tags: JSDocTagInfo[]; /** - * TODO + * Whether the verbosity level can be increased for this quick info response. */ canIncreaseVerbosityLevel?: boolean; } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 7de0463c6150e..0e9fc9ce22e9d 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1487,7 +1487,10 @@ declare namespace ts { arguments: FileLocationRequestArgs; } export interface QuickInfoRequestArgs extends FileLocationRequestArgs { - /** TODO */ + /** + * This controls how many levels of definitions will be expanded in the quick info response. + * The default value is 0. + */ verbosityLevel?: number; } /** @@ -1524,7 +1527,7 @@ declare namespace ts { */ tags: JSDocTagInfo[]; /** - * TODO + * Whether the verbosity level can be increased for this quick info response. */ canIncreaseVerbosityLevel?: boolean; } From 14d8405876129bb73ede1d18fcc9f315a7b6d588 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Thu, 27 Mar 2025 09:01:39 -0700 Subject: [PATCH 21/31] Revert "default to printing 'namespace' instead of 'module'" This reverts commit 8bd48216886c0d0a193bca6193e5162821d093e7. --- src/services/symbolDisplay.ts | 2 +- .../completionNoParentLocation.baseline | 4 +- .../completionsCommentsClass.baseline | 4 +- .../completionsCommentsClassMembers.baseline | 80 +++++++++---------- ...completionsCommentsCommentParsing.baseline | 28 +++---- ...etionsCommentsFunctionDeclaration.baseline | 12 +-- ...letionsCommentsFunctionExpression.baseline | 16 ++-- ...completionsCommitCharactersGlobal.baseline | 68 ++++++++-------- .../completionsImportWithKeyword.baseline | 28 +++---- .../completionsImport_asKeyword.baseline | 8 +- ...ompletionsImport_satisfiesKeyword.baseline | 8 +- ...letionsInitializerCommitCharacter.baseline | 4 +- .../exhaustiveCaseCompletions9.baseline | 4 +- ...AllReferencesDynamicImport1.baseline.jsonc | 8 +- ...encesUmdModuleAsGlobalConst.baseline.jsonc | 4 +- .../findAllRefsExportEquals.baseline.jsonc | 4 +- .../findAllRefsForModule.baseline.jsonc | 12 +-- ...AllRefsImportEqualsJsonFile.baseline.jsonc | 8 +- ...findAllRefsModuleDotExports.baseline.jsonc | 8 +- ...efs_importType_exportEquals.baseline.jsonc | 8 +- ...findAllRefs_importType_js.1.baseline.jsonc | 4 +- .../findAllRefs_importType_js.baseline.jsonc | 4 +- ...efs_importType_typeofImport.baseline.jsonc | 8 +- ...esOnRuntimeImportWithPaths1.baseline.jsonc | 4 +- ...foDisplayPartsExternalModuleAlias.baseline | 8 +- ...nfoNestedExportEqualExportDefault.baseline | 8 +- .../quickinfoVerbosityFunction.baseline | 4 +- .../reference/quickinfoVerbosityJs.baseline | 4 +- ...erencesForStatementKeywords.baseline.jsonc | 48 +++++------ ...ailableThroughGlobalNoCrash.baseline.jsonc | 4 +- ...esOnRuntimeImportWithPaths1.baseline.jsonc | 4 +- .../quickInfoElementAccessDeclaration.ts | 2 +- tests/cases/fourslash/quickInfoForRequire.ts | 4 +- .../quickInfoImportNonunicodePath.ts | 2 +- 34 files changed, 213 insertions(+), 213 deletions(-) diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index e8b3d2cf0a1bc..586187f7c67af 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -510,7 +510,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( prefixNextMeaning(); if (!tryUnfoldSymbol(symbol, semanticMeaning)) { const declaration = getDeclarationOfKind(symbol, SyntaxKind.ModuleDeclaration); - const isNamespace = !(declaration && declaration.name && declaration.name.kind === SyntaxKind.StringLiteral); + const isNamespace = declaration && declaration.name && declaration.name.kind === SyntaxKind.Identifier; displayParts.push(keywordPart(isNamespace ? SyntaxKind.NamespaceKeyword : SyntaxKind.ModuleKeyword)); displayParts.push(spacePart()); addFullSymbolName(symbol); diff --git a/tests/baselines/reference/completionNoParentLocation.baseline b/tests/baselines/reference/completionNoParentLocation.baseline index e8fdd98dc0ecd..2e7fa25d92f43 100644 --- a/tests/baselines/reference/completionNoParentLocation.baseline +++ b/tests/baselines/reference/completionNoParentLocation.baseline @@ -57,7 +57,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1651,7 +1651,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsCommentsClass.baseline b/tests/baselines/reference/completionsCommentsClass.baseline index 61daeffcd5098..1cab2abd39d64 100644 --- a/tests/baselines/reference/completionsCommentsClass.baseline +++ b/tests/baselines/reference/completionsCommentsClass.baseline @@ -109,7 +109,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -2242,7 +2242,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsCommentsClassMembers.baseline b/tests/baselines/reference/completionsCommentsClassMembers.baseline index 48d180ff78c51..ff25fd4893846 100644 --- a/tests/baselines/reference/completionsCommentsClassMembers.baseline +++ b/tests/baselines/reference/completionsCommentsClassMembers.baseline @@ -94,7 +94,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -308,7 +308,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -475,7 +475,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -689,7 +689,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -844,7 +844,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1007,7 +1007,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1156,7 +1156,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1318,7 +1318,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1485,7 +1485,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1648,7 +1648,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1811,7 +1811,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1961,7 +1961,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -2113,7 +2113,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -2263,7 +2263,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -2415,7 +2415,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -2565,7 +2565,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -2717,7 +2717,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -2889,7 +2889,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -3079,7 +3079,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -3277,7 +3277,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -6414,7 +6414,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -13976,7 +13976,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -19276,7 +19276,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -26838,7 +26838,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -31384,7 +31384,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -37091,7 +37091,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -41591,7 +41591,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -47252,7 +47252,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -52959,7 +52959,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -58666,7 +58666,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -64373,7 +64373,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -68914,7 +68914,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -73455,7 +73455,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -77996,7 +77996,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -82537,7 +82537,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -87078,7 +87078,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -91619,7 +91619,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -96506,7 +96506,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -102338,7 +102338,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -107431,7 +107431,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsCommentsCommentParsing.baseline b/tests/baselines/reference/completionsCommentsCommentParsing.baseline index 8cc8b577c8157..3869899430dcc 100644 --- a/tests/baselines/reference/completionsCommentsCommentParsing.baseline +++ b/tests/baselines/reference/completionsCommentsCommentParsing.baseline @@ -176,7 +176,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -334,7 +334,7 @@ // | var Function: FunctionConstructor // | (...args: string[]) => Function // | interface Function -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -514,7 +514,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -674,7 +674,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -890,7 +890,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1048,7 +1048,7 @@ // | var Function: FunctionConstructor // | (...args: string[]) => Function // | interface Function -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1240,7 +1240,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -5218,7 +5218,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -11528,7 +11528,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -18248,7 +18248,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -24274,7 +24274,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -30642,7 +30642,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -36952,7 +36952,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -43593,7 +43593,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline b/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline index 8e2613966e20a..dda1e063c4812 100644 --- a/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline +++ b/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline @@ -61,7 +61,7 @@ // | var Function: FunctionConstructor // | (...args: string[]) => Function // | interface Function -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -203,7 +203,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -336,7 +336,7 @@ // | var Function: FunctionConstructor // | (...args: string[]) => Function // | interface Function -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -2363,7 +2363,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -6936,7 +6936,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -11113,7 +11113,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsCommentsFunctionExpression.baseline b/tests/baselines/reference/completionsCommentsFunctionExpression.baseline index 865a809123057..0212ef5e5e0a5 100644 --- a/tests/baselines/reference/completionsCommentsFunctionExpression.baseline +++ b/tests/baselines/reference/completionsCommentsFunctionExpression.baseline @@ -62,7 +62,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -214,7 +214,7 @@ // | var Function: FunctionConstructor // | (...args: string[]) => Function // | interface Function -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -383,7 +383,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -517,7 +517,7 @@ // | var Function: FunctionConstructor // | (...args: string[]) => Function // | interface Function -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -2534,7 +2534,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -7111,7 +7111,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -12018,7 +12018,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -16379,7 +16379,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsCommitCharactersGlobal.baseline b/tests/baselines/reference/completionsCommitCharactersGlobal.baseline index 5e9bb11aea623..582d3363da492 100644 --- a/tests/baselines/reference/completionsCommitCharactersGlobal.baseline +++ b/tests/baselines/reference/completionsCommitCharactersGlobal.baseline @@ -83,7 +83,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -255,7 +255,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -426,7 +426,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -595,7 +595,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -764,7 +764,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -932,7 +932,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1103,7 +1103,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1274,7 +1274,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1455,7 +1455,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1629,7 +1629,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1800,7 +1800,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1973,7 +1973,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -2147,7 +2147,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -2320,7 +2320,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -2495,7 +2495,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -2650,7 +2650,7 @@ // | interface Function // | var Function: FunctionConstructor // | interface FunctionConstructor -// | namespace globalThis +// | module globalThis // | interface IArguments // | interface ImportAttributes // | interface ImportCallOptions @@ -2830,7 +2830,7 @@ // | interface Function // | var Function: FunctionConstructor // | interface FunctionConstructor -// | namespace globalThis +// | module globalThis // | interface IArguments // | interface ImportAttributes // | interface ImportCallOptions @@ -5240,7 +5240,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -9991,7 +9991,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -14741,7 +14741,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -19423,7 +19423,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -24110,7 +24110,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -28792,7 +28792,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -33542,7 +33542,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -38292,7 +38292,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -43050,7 +43050,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -47830,7 +47830,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -52581,7 +52581,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -57361,7 +57361,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -62141,7 +62141,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -66966,7 +66966,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -71791,7 +71791,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -78202,7 +78202,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -87673,7 +87673,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsImportWithKeyword.baseline b/tests/baselines/reference/completionsImportWithKeyword.baseline index 36268d343657f..6223be88388ed 100644 --- a/tests/baselines/reference/completionsImportWithKeyword.baseline +++ b/tests/baselines/reference/completionsImportWithKeyword.baseline @@ -65,7 +65,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -213,7 +213,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -360,7 +360,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -508,7 +508,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -656,7 +656,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -803,7 +803,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -942,7 +942,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | import // | in @@ -2598,7 +2598,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -6566,7 +6566,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -10522,7 +10522,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -14494,7 +14494,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -18450,7 +18450,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -22406,7 +22406,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -26191,7 +26191,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsImport_asKeyword.baseline b/tests/baselines/reference/completionsImport_asKeyword.baseline index 07b7ea968e52e..ab6cc8c862232 100644 --- a/tests/baselines/reference/completionsImport_asKeyword.baseline +++ b/tests/baselines/reference/completionsImport_asKeyword.baseline @@ -55,7 +55,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -197,7 +197,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1729,7 +1729,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -5635,7 +5635,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsImport_satisfiesKeyword.baseline b/tests/baselines/reference/completionsImport_satisfiesKeyword.baseline index 83e35e632438a..9fbb9f3a3151d 100644 --- a/tests/baselines/reference/completionsImport_satisfiesKeyword.baseline +++ b/tests/baselines/reference/completionsImport_satisfiesKeyword.baseline @@ -55,7 +55,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -197,7 +197,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1729,7 +1729,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -5635,7 +5635,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/completionsInitializerCommitCharacter.baseline b/tests/baselines/reference/completionsInitializerCommitCharacter.baseline index 0ed2ce655f70e..02e1f65213751 100644 --- a/tests/baselines/reference/completionsInitializerCommitCharacter.baseline +++ b/tests/baselines/reference/completionsInitializerCommitCharacter.baseline @@ -57,7 +57,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1621,7 +1621,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/exhaustiveCaseCompletions9.baseline b/tests/baselines/reference/exhaustiveCaseCompletions9.baseline index a1dba30dcd52e..5749e8befa01c 100644 --- a/tests/baselines/reference/exhaustiveCaseCompletions9.baseline +++ b/tests/baselines/reference/exhaustiveCaseCompletions9.baseline @@ -59,7 +59,7 @@ // | function // | interface Function // | var Function: FunctionConstructor -// | namespace globalThis +// | module globalThis // | if // | implements // | import @@ -1614,7 +1614,7 @@ "sortText": "15", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllReferencesDynamicImport1.baseline.jsonc b/tests/baselines/reference/findAllReferencesDynamicImport1.baseline.jsonc index bf1da5aed99c7..63e5167d0ecd2 100644 --- a/tests/baselines/reference/findAllReferencesDynamicImport1.baseline.jsonc +++ b/tests/baselines/reference/findAllReferencesDynamicImport1.baseline.jsonc @@ -24,10 +24,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/tests/cases/fourslash/foo\"", + "name": "module \"/tests/cases/fourslash/foo\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -144,10 +144,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/tests/cases/fourslash/foo\"", + "name": "module \"/tests/cases/fourslash/foo\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc b/tests/baselines/reference/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc index 08c1f5553bb5a..3516bee024db8 100644 --- a/tests/baselines/reference/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc +++ b/tests/baselines/reference/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc @@ -60,10 +60,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/node_modules/@types/three/index\"", + "name": "module \"/node_modules/@types/three/index\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefsExportEquals.baseline.jsonc b/tests/baselines/reference/findAllRefsExportEquals.baseline.jsonc index 1eba5c5ac0484..ce0bdb21e8734 100644 --- a/tests/baselines/reference/findAllRefsExportEquals.baseline.jsonc +++ b/tests/baselines/reference/findAllRefsExportEquals.baseline.jsonc @@ -645,10 +645,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/a\"", + "name": "module \"/a\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefsForModule.baseline.jsonc b/tests/baselines/reference/findAllRefsForModule.baseline.jsonc index e25481a5eb0bf..b2fbd06179fe9 100644 --- a/tests/baselines/reference/findAllRefsForModule.baseline.jsonc +++ b/tests/baselines/reference/findAllRefsForModule.baseline.jsonc @@ -18,10 +18,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/a\"", + "name": "module \"/a\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -58,10 +58,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/a\"", + "name": "module \"/a\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -98,10 +98,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/a\"", + "name": "module \"/a\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefsImportEqualsJsonFile.baseline.jsonc b/tests/baselines/reference/findAllRefsImportEqualsJsonFile.baseline.jsonc index a39cd59a0e558..7f1d934ba209e 100644 --- a/tests/baselines/reference/findAllRefsImportEqualsJsonFile.baseline.jsonc +++ b/tests/baselines/reference/findAllRefsImportEqualsJsonFile.baseline.jsonc @@ -148,10 +148,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/j\"", + "name": "module \"/j\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -190,10 +190,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/j\"", + "name": "module \"/j\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefsModuleDotExports.baseline.jsonc b/tests/baselines/reference/findAllRefsModuleDotExports.baseline.jsonc index 71ae53320ca14..c95be2f8836bd 100644 --- a/tests/baselines/reference/findAllRefsModuleDotExports.baseline.jsonc +++ b/tests/baselines/reference/findAllRefsModuleDotExports.baseline.jsonc @@ -49,10 +49,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/b\"", + "name": "module \"/b\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -86,10 +86,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/b\"", + "name": "module \"/b\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefs_importType_exportEquals.baseline.jsonc b/tests/baselines/reference/findAllRefs_importType_exportEquals.baseline.jsonc index d99ceaeef792d..bd7279c9ebebc 100644 --- a/tests/baselines/reference/findAllRefs_importType_exportEquals.baseline.jsonc +++ b/tests/baselines/reference/findAllRefs_importType_exportEquals.baseline.jsonc @@ -223,10 +223,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/a\"", + "name": "module \"/a\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -323,10 +323,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/a\"", + "name": "module \"/a\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefs_importType_js.1.baseline.jsonc b/tests/baselines/reference/findAllRefs_importType_js.1.baseline.jsonc index 1a93532cd31bf..1170886f836b0 100644 --- a/tests/baselines/reference/findAllRefs_importType_js.1.baseline.jsonc +++ b/tests/baselines/reference/findAllRefs_importType_js.1.baseline.jsonc @@ -21,7 +21,7 @@ "containerKind": "", "containerName": "", "kind": "local class", - "name": "(local class) C\nnamespace C", + "name": "(local class) C\nmodule C", "displayParts": [ { "text": "(", @@ -48,7 +48,7 @@ "kind": "lineBreak" }, { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefs_importType_js.baseline.jsonc b/tests/baselines/reference/findAllRefs_importType_js.baseline.jsonc index c0458b741d79e..8fd8197d59865 100644 --- a/tests/baselines/reference/findAllRefs_importType_js.baseline.jsonc +++ b/tests/baselines/reference/findAllRefs_importType_js.baseline.jsonc @@ -20,10 +20,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/a\"", + "name": "module \"/a\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/findAllRefs_importType_typeofImport.baseline.jsonc b/tests/baselines/reference/findAllRefs_importType_typeofImport.baseline.jsonc index 6cf734530bcf8..bad8985b8fcec 100644 --- a/tests/baselines/reference/findAllRefs_importType_typeofImport.baseline.jsonc +++ b/tests/baselines/reference/findAllRefs_importType_typeofImport.baseline.jsonc @@ -81,10 +81,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/a\"", + "name": "module \"/a\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -184,10 +184,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/a\"", + "name": "module \"/a\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/jsxFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc b/tests/baselines/reference/jsxFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc index cc17a6c7f8121..e512e8d47cbd7 100644 --- a/tests/baselines/reference/jsxFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc +++ b/tests/baselines/reference/jsxFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc @@ -30,10 +30,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/tests/cases/fourslash/project/src/dir/jsx-runtime\"", + "name": "module \"/tests/cases/fourslash/project/src/dir/jsx-runtime\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/quickInfoDisplayPartsExternalModuleAlias.baseline b/tests/baselines/reference/quickInfoDisplayPartsExternalModuleAlias.baseline index d41bfb5ea749a..7745fa2442617 100644 --- a/tests/baselines/reference/quickInfoDisplayPartsExternalModuleAlias.baseline +++ b/tests/baselines/reference/quickInfoDisplayPartsExternalModuleAlias.baseline @@ -7,7 +7,7 @@ // | ---------------------------------------------------------------------- // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- -// | namespace a1 +// | module a1 // | ---------------------------------------------------------------------- // new a1.m1.c(); // ^^ @@ -21,7 +21,7 @@ // | ---------------------------------------------------------------------- // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // | ---------------------------------------------------------------------- -// | namespace a1 +// | module a1 // | ---------------------------------------------------------------------- // new a2.m1.c(); // ^^ @@ -103,7 +103,7 @@ }, "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -249,7 +249,7 @@ }, "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/quickInfoNestedExportEqualExportDefault.baseline b/tests/baselines/reference/quickInfoNestedExportEqualExportDefault.baseline index 8c16caff716d5..3dec1073bd9e2 100644 --- a/tests/baselines/reference/quickInfoNestedExportEqualExportDefault.baseline +++ b/tests/baselines/reference/quickInfoNestedExportEqualExportDefault.baseline @@ -6,7 +6,7 @@ // | ---------------------------------------------------------------------- // | class (Anonymous function).default // | enum (Anonymous function).default -// | namespace (Anonymous function).default +// | module (Anonymous function).default // | (enum member) (Anonymous function).default // | (enum member) (Anonymous function).default: {} // | ---------------------------------------------------------------------- @@ -14,7 +14,7 @@ // | ---------------------------------------------------------------------- // | class (Anonymous function).default // | enum (Anonymous function).default -// | namespace (Anonymous function).default +// | module (Anonymous function).default // | (enum member) (Anonymous function).default // | (enum member) (Anonymous function).default: {} // | ---------------------------------------------------------------------- @@ -85,7 +85,7 @@ "kind": "lineBreak" }, { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -251,7 +251,7 @@ "kind": "lineBreak" }, { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/quickinfoVerbosityFunction.baseline b/tests/baselines/reference/quickinfoVerbosityFunction.baseline index a5996a2923022..e253de89765b7 100644 --- a/tests/baselines/reference/quickinfoVerbosityFunction.baseline +++ b/tests/baselines/reference/quickinfoVerbosityFunction.baseline @@ -77,7 +77,7 @@ // | ---------------------------------------------------------------------- // ^^^^^^^ // | ---------------------------------------------------------------------- -// | namespace someFun +// | module someFun // | function someFun(a: SomeType): SomeType // | (verbosity level: 0) // | ---------------------------------------------------------------------- @@ -978,7 +978,7 @@ }, "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/quickinfoVerbosityJs.baseline b/tests/baselines/reference/quickinfoVerbosityJs.baseline index 34a2998c97768..775dd7de14c5c 100644 --- a/tests/baselines/reference/quickinfoVerbosityJs.baseline +++ b/tests/baselines/reference/quickinfoVerbosityJs.baseline @@ -81,7 +81,7 @@ // ^^^^^^^ // | ---------------------------------------------------------------------- // | function someFun(a: SomeType): SomeType -// | namespace someFun +// | module someFun // | @param a // | @returns // | (verbosity level: 0) @@ -734,7 +734,7 @@ "kind": "lineBreak" }, { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/referencesForStatementKeywords.baseline.jsonc b/tests/baselines/reference/referencesForStatementKeywords.baseline.jsonc index 448fb9a373ba6..d75e92c4c4251 100644 --- a/tests/baselines/reference/referencesForStatementKeywords.baseline.jsonc +++ b/tests/baselines/reference/referencesForStatementKeywords.baseline.jsonc @@ -89,10 +89,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/a\"", + "name": "module \"/a\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -447,10 +447,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/b\"", + "name": "module \"/b\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -639,10 +639,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/c\"", + "name": "module \"/c\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -901,10 +901,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/d\"", + "name": "module \"/d\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -972,10 +972,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/e\"", + "name": "module \"/e\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -1108,10 +1108,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/f\"", + "name": "module \"/f\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -1150,10 +1150,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/g\"", + "name": "module \"/g\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -1192,10 +1192,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/g\"", + "name": "module \"/g\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -1234,10 +1234,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/g\"", + "name": "module \"/g\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -1426,10 +1426,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/h\"", + "name": "module \"/h\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -1688,10 +1688,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/i\"", + "name": "module \"/i\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { @@ -1762,10 +1762,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/j\"", + "name": "module \"/j\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc b/tests/baselines/reference/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc index b28a786efdb8c..080e387be7318 100644 --- a/tests/baselines/reference/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc +++ b/tests/baselines/reference/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc @@ -30,10 +30,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/packages/playwright-core/bundles/utils/node_modules/@types/debug/index\"", + "name": "module \"/packages/playwright-core/bundles/utils/node_modules/@types/debug/index\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/baselines/reference/tslibFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc b/tests/baselines/reference/tslibFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc index ebeee5b8d825b..2afc5d77de9eb 100644 --- a/tests/baselines/reference/tslibFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc +++ b/tests/baselines/reference/tslibFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc @@ -19,10 +19,10 @@ "containerKind": "", "containerName": "", "kind": "module", - "name": "namespace \"/tests/cases/fourslash/project/src/dir/tslib\"", + "name": "module \"/tests/cases/fourslash/project/src/dir/tslib\"", "displayParts": [ { - "text": "namespace", + "text": "module", "kind": "keyword" }, { diff --git a/tests/cases/fourslash/quickInfoElementAccessDeclaration.ts b/tests/cases/fourslash/quickInfoElementAccessDeclaration.ts index f4d2905f12e22..4f36146887490 100644 --- a/tests/cases/fourslash/quickInfoElementAccessDeclaration.ts +++ b/tests/cases/fourslash/quickInfoElementAccessDeclaration.ts @@ -8,5 +8,5 @@ ////mod["/**/@@thing1"]["@@thing2"] = 0; goTo.marker(); -verify.quickInfoIs(`namespace mod["@@thing1"] +verify.quickInfoIs(`module mod["@@thing1"] (property) mod["@@thing1"]: typeof mod.@@thing1`); diff --git a/tests/cases/fourslash/quickInfoForRequire.ts b/tests/cases/fourslash/quickInfoForRequire.ts index 5595ddde472bf..231dd8603b288 100644 --- a/tests/cases/fourslash/quickInfoForRequire.ts +++ b/tests/cases/fourslash/quickInfoForRequire.ts @@ -9,7 +9,7 @@ goTo.marker("1"); -verify.quickInfoIs("namespace a"); +verify.quickInfoIs("module a"); goTo.marker("2"); -verify.quickInfoIs("namespace a"); +verify.quickInfoIs("module a"); diff --git a/tests/cases/fourslash/quickInfoImportNonunicodePath.ts b/tests/cases/fourslash/quickInfoImportNonunicodePath.ts index 62dd4a073a8f6..62d043a214b86 100644 --- a/tests/cases/fourslash/quickInfoImportNonunicodePath.ts +++ b/tests/cases/fourslash/quickInfoImportNonunicodePath.ts @@ -6,4 +6,4 @@ // @Filename: /test.ts //// import { foo } from "./江南/*1*/今何在/tmp"; -verify.quickInfoAt("1", 'namespace "/江南今何在/tmp"'); +verify.quickInfoAt("1", 'module "/江南今何在/tmp"'); From 0def080c3a228390a29b387b41c57a1a6e372743 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Thu, 27 Mar 2025 10:00:53 -0700 Subject: [PATCH 22/31] fix expansion of namespaces with non-id names --- src/compiler/checker.ts | 31 ++- .../quickinfoVerbosityNamespace.baseline | 188 +++++++++++++++++- .../fourslash/quickinfoVerbosityNamespace.ts | 6 + 3 files changed, 212 insertions(+), 13 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b17f97dd0f13c..3295f1036a91b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1134,6 +1134,7 @@ import { WithStatement, WriterContextOut, YieldExpression, + ModuleName, } from "./_namespaces/ts.js"; import * as moduleSpecifiers from "./_namespaces/ts.moduleSpecifiers.js"; import * as performance from "./_namespaces/ts.performance.js"; @@ -9802,7 +9803,19 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // than whatever scope we traverse to them in. That's a bit of a complex rewrite, since we're not _actually_ tracking privates at all in advance, // so we don't even have placeholders to fill in. if (length(realMembers) || unfolding) { - const localName = getInternalSymbolName(symbol, symbolName); + let localName: ModuleName; + if (unfolding) { + // Use the same name as symbol display. + const oldFlags = context.flags; + context.flags |= NodeBuilderFlags.WriteTypeParametersInQualifiedName | SymbolFormatFlags.UseOnlyExternalAliasing; + localName = symbolToNode(symbol, context, /*meaning*/ SymbolFlags.All) as ModuleName; + context.flags = oldFlags; + } + else { + const localText = getInternalSymbolName(symbol, symbolName); + localName = factory.createIdentifier(localText); + context.approximateLength += localText.length; + } serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (SymbolFlags.Function | SymbolFlags.Assignment))); } if (length(mergedMembers)) { @@ -9898,7 +9911,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Module symbol emit will take care of module-y members, provided it has exports if (!(symbol.flags & (SymbolFlags.ValueModule | SymbolFlags.NamespaceModule) && !!symbol.exports && !!symbol.exports.size)) { const props = filter(getPropertiesOfType(type), isNamespaceMember); - serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); + context.approximateLength += localName.length; + serializeAsNamespaceDeclaration(props, factory.createIdentifier(localName), modifierFlags, /*suppressNewPrivateContext*/ true); } } @@ -9919,10 +9933,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return signature.declaration; } - function serializeAsNamespaceDeclaration(props: readonly Symbol[], localName: string, modifierFlags: ModifierFlags, suppressNewPrivateContext: boolean) { + function serializeAsNamespaceDeclaration(props: readonly Symbol[], localName: ModuleName, modifierFlags: ModifierFlags, suppressNewPrivateContext: boolean) { + const nodeFlags = isIdentifier(localName) ? NodeFlags.Namespace : NodeFlags.None; const unfolding = isUnfolding(context); if (length(props)) { - context.approximateLength += localName.length + 14; // "namespace localName { }" + context.approximateLength += 14; // "namespace { }" const localVsRemoteMap = arrayToMultiMap(props, p => !length(p.declarations) || some(p.declarations, d => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration!)) || unfolding ? "local" : "remote"); const localProps = localVsRemoteMap.get("local") || emptyArray; // handle remote props first - we need to make an `import` declaration that points at the module containing each remote @@ -9942,7 +9957,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Add a namespace // Create namespace as non-synthetic so it is usable as an enclosing declaration - let fakespace = parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, factory.createIdentifier(localName), factory.createModuleBlock([]), NodeFlags.Namespace); + let fakespace = parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, localName, factory.createModuleBlock([]), nodeFlags); setParent(fakespace, enclosingDeclaration as SourceFile | NamespaceDeclaration); fakespace.locals = createSymbolTable(props); fakespace.symbol = props[0].parent!; @@ -9977,13 +9992,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { addResult(fakespace, modifierFlags); // namespaces can never be default exported } else if (unfolding) { - context.approximateLength += localName.length + 14; // "namespace { }" + context.approximateLength += 14; // "namespace { }" addResult( factory.createModuleDeclaration( /*modifiers*/ undefined, - factory.createIdentifier(localName), + localName, factory.createModuleBlock([]), - NodeFlags.Namespace, + nodeFlags, ), modifierFlags, ); diff --git a/tests/baselines/reference/quickinfoVerbosityNamespace.baseline b/tests/baselines/reference/quickinfoVerbosityNamespace.baseline index dc3fcdbdee117..3b3a056588300 100644 --- a/tests/baselines/reference/quickinfoVerbosityNamespace.baseline +++ b/tests/baselines/reference/quickinfoVerbosityNamespace.baseline @@ -71,6 +71,24 @@ // var z = 2; // } +=== /tests/cases/fourslash/foo.ts === +// export function foo() { return "foo"; } +// import("./foo") +// ^^^^^^^ +// | ---------------------------------------------------------------------- +// | module "/tests/cases/fourslash/foo" { +// | function foo(): string; +// | namespace foo { } +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^^^ +// | ---------------------------------------------------------------------- +// | module "/tests/cases/fourslash/foo" +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// var x = import("./foo") + === /4.ts === // class Foo { // y!: T; @@ -276,7 +294,7 @@ }, { "text": "Foo", - "kind": "text" + "kind": "className" }, { "text": " ", @@ -468,7 +486,7 @@ }, { "text": "ns", - "kind": "text" + "kind": "moduleName" }, { "text": " ", @@ -688,7 +706,7 @@ }, { "text": "ns", - "kind": "text" + "kind": "moduleName" }, { "text": " ", @@ -980,7 +998,7 @@ }, { "text": "Two", - "kind": "text" + "kind": "moduleName" }, { "text": " ", @@ -1124,7 +1142,7 @@ }, { "text": "Two", - "kind": "text" + "kind": "moduleName" }, { "text": " ", @@ -1356,6 +1374,158 @@ }, { "text": "OnlyLocal", + "kind": "moduleName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/foo.ts", + "position": 48, + "name": "5" + }, + "item": { + "kind": "module", + "kindModifiers": "", + "textSpan": { + "start": 47, + "length": 7 + }, + "displayParts": [ + { + "text": "module", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"/tests/cases/fourslash/foo\"", + "kind": "stringLiteral" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/foo.ts", + "position": 48, + "name": "5" + }, + "item": { + "kind": "module", + "kindModifiers": "", + "textSpan": { + "start": 47, + "length": 7 + }, + "displayParts": [ + { + "text": "module", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"/tests/cases/fourslash/foo\"", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", + "kind": "text" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "string", + "kind": "keyword" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "foo", "kind": "text" }, { @@ -1370,6 +1540,14 @@ "text": " ", "kind": "space" }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, { "text": "}", "kind": "punctuation" diff --git a/tests/cases/fourslash/quickinfoVerbosityNamespace.ts b/tests/cases/fourslash/quickinfoVerbosityNamespace.ts index e6d594d496af8..1927a3c8e4ba6 100644 --- a/tests/cases/fourslash/quickinfoVerbosityNamespace.ts +++ b/tests/cases/fourslash/quickinfoVerbosityNamespace.ts @@ -50,9 +50,15 @@ //// const bar: number; //// } +// @filename: foo.ts +//// export function foo() { return "foo"; } +//// import("/*5*/./foo") +//// var x = import("./foo") + verify.baselineQuickInfo({ 1: [0, 1], 2: [0, 1, 2], 3: [0, 1, 2], 4: [0, 1], + 5: [0, 1], }) From 0c3edf92f8bd75c6b31f7894607c86571b758bf1 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Thu, 27 Mar 2025 10:21:16 -0700 Subject: [PATCH 23/31] format --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3295f1036a91b..5107e57225bef 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -881,6 +881,7 @@ import { moduleExportNameTextUnescaped, ModuleInstanceState, ModuleKind, + ModuleName, ModuleResolutionKind, ModuleSpecifierResolutionHost, moduleSupportsImportAttributes, @@ -1134,7 +1135,6 @@ import { WithStatement, WriterContextOut, YieldExpression, - ModuleName, } from "./_namespaces/ts.js"; import * as moduleSpecifiers from "./_namespaces/ts.moduleSpecifiers.js"; import * as performance from "./_namespaces/ts.performance.js"; From 7562951b38f3efc3fdbb0f04d9625a108342365c Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Thu, 27 Mar 2025 10:53:03 -0700 Subject: [PATCH 24/31] update displayparts baselines --- tests/baselines/reference/quickinfoVerbosity3.baseline | 4 ++-- tests/baselines/reference/quickinfoVerbosityFunction.baseline | 2 +- .../baselines/reference/quickinfoVerbosityInterface2.baseline | 4 ++-- tests/baselines/reference/quickinfoVerbosityJs.baseline | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/baselines/reference/quickinfoVerbosity3.baseline b/tests/baselines/reference/quickinfoVerbosity3.baseline index e7c81482f2f93..301aecb7812b5 100644 --- a/tests/baselines/reference/quickinfoVerbosity3.baseline +++ b/tests/baselines/reference/quickinfoVerbosity3.baseline @@ -1178,7 +1178,7 @@ }, { "text": "c5b", - "kind": "text" + "kind": "className" }, { "text": " ", @@ -1342,7 +1342,7 @@ }, { "text": "c5b", - "kind": "text" + "kind": "className" }, { "text": " ", diff --git a/tests/baselines/reference/quickinfoVerbosityFunction.baseline b/tests/baselines/reference/quickinfoVerbosityFunction.baseline index e253de89765b7..64dd6f46907ac 100644 --- a/tests/baselines/reference/quickinfoVerbosityFunction.baseline +++ b/tests/baselines/reference/quickinfoVerbosityFunction.baseline @@ -1071,7 +1071,7 @@ }, { "text": "someFun", - "kind": "text" + "kind": "functionName" }, { "text": " ", diff --git a/tests/baselines/reference/quickinfoVerbosityInterface2.baseline b/tests/baselines/reference/quickinfoVerbosityInterface2.baseline index 6a7fbab8ee553..a5111b44248ff 100644 --- a/tests/baselines/reference/quickinfoVerbosityInterface2.baseline +++ b/tests/baselines/reference/quickinfoVerbosityInterface2.baseline @@ -1717,7 +1717,7 @@ }, { "text": "Foo", - "kind": "text" + "kind": "interfaceName" }, { "text": " ", @@ -1897,7 +1897,7 @@ }, { "text": "Foo", - "kind": "text" + "kind": "interfaceName" }, { "text": " ", diff --git a/tests/baselines/reference/quickinfoVerbosityJs.baseline b/tests/baselines/reference/quickinfoVerbosityJs.baseline index 775dd7de14c5c..ae0aabf6777bd 100644 --- a/tests/baselines/reference/quickinfoVerbosityJs.baseline +++ b/tests/baselines/reference/quickinfoVerbosityJs.baseline @@ -913,7 +913,7 @@ }, { "text": "someFun", - "kind": "text" + "kind": "functionName" }, { "text": " ", From a187291c8e14e985d163afe6f1fb1246e4430022 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 11 Apr 2025 09:28:08 -0700 Subject: [PATCH 25/31] use enum member initializer if present --- src/compiler/checker.ts | 25 +- .../reference/quickinfoVerbosityEnum.baseline | 273 ++++++++++++++++++ .../cases/fourslash/quickinfoVerbosityEnum.ts | 8 + 3 files changed, 299 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5107e57225bef..db4f0c3dfdf99 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8127,8 +8127,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function typeParameterToDeclaration(type: TypeParameter, context: NodeBuilderContext, constraint = getConstraintOfTypeParameter(type)): TypeParameterDeclaration { const constraintNode = constraint && typeToTypeNodeHelperWithPossibleReusableTypeNode(constraint, getConstraintDeclaration(type), context); - const typeParam = typeParameterToDeclarationWithConstraint(type, context, constraintNode); - return typeParam; + return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function typePredicateToTypePredicateNodeHelper(typePredicate: TypePredicate, context: NodeBuilderContext): TypePredicateNode { @@ -9878,12 +9877,24 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // I hate that to get the initialized value we need to walk back to the declarations here; but there's no // other way to get the possible const value of an enum member that I'm aware of, as the value is cached // _on the declaration_, not on the declaration's symbol... - const initializedValue = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) ? getConstantValue(p.declarations[0]) : undefined; - const initializer = initializedValue === undefined ? undefined : - typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : - factory.createNumericLiteral(initializedValue); + const memberDecl = p.declarations && p.declarations[0] && isEnumMember(p.declarations[0]) ? + p.declarations[0] : + undefined; + let initializer: Expression | undefined; + let initializerLength: number; + if (isUnfolding(context) && memberDecl && memberDecl.initializer) { + initializer = visitNode(memberDecl.initializer, factory.cloneNode, isExpression); + initializerLength = memberDecl.initializer.end - memberDecl.initializer.pos; + } + else { + const initializedValue = memberDecl && getConstantValue(memberDecl); + initializer = initializedValue === undefined ? undefined : + typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : + factory.createNumericLiteral(initializedValue); + initializerLength = (initializer as StringLiteral | NumericLiteral | undefined)?.text.length ?? 0 + } const memberName = unescapeLeadingUnderscores(p.escapedName); - context.approximateLength += 4 + memberName.length + (initializer?.text.length ?? 0); // `member = initializer,` + context.approximateLength += 4 + memberName.length + initializerLength; // `member = initializer,` const member = factory.createEnumMember( memberName, initializer, diff --git a/tests/baselines/reference/quickinfoVerbosityEnum.baseline b/tests/baselines/reference/quickinfoVerbosityEnum.baseline index 21a0fd0b27f78..eda0f187988e3 100644 --- a/tests/baselines/reference/quickinfoVerbosityEnum.baseline +++ b/tests/baselines/reference/quickinfoVerbosityEnum.baseline @@ -58,6 +58,27 @@ // | const y: Direction // | (verbosity level: 0) // | ---------------------------------------------------------------------- +// enum Flags { +// ^^^^^ +// | ---------------------------------------------------------------------- +// | enum Flags { +// | None = 0, +// | IsDirectory = 1 << 0, +// | IsFile = 1 << 1, +// | IsSymlink = 1 << 2 +// | } +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^ +// | ---------------------------------------------------------------------- +// | enum Flags +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- +// None = 0, +// IsDirectory = 1 << 0, +// IsFile = 1 << 1, +// IsSymlink = 1 << 2, +// } [ { @@ -651,5 +672,257 @@ "canIncreaseVerbosityLevel": false, "verbosityLevel": 1 } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", + "position": 161, + "name": "f" + }, + "item": { + "kind": "enum", + "kindModifiers": "", + "textSpan": { + "start": 156, + "length": 5 + }, + "displayParts": [ + { + "text": "enum", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Flags", + "kind": "enumName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", + "position": 161, + "name": "f" + }, + "item": { + "kind": "enum", + "kindModifiers": "", + "textSpan": { + "start": 156, + "length": 5 + }, + "displayParts": [ + { + "text": "enum", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Flags", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "None", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "0", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "IsDirectory", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "1", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "<<", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "0", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "IsFile", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "1", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "<<", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "1", + "kind": "stringLiteral" + }, + { + "text": ",", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "IsSymlink", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "1", + "kind": "stringLiteral" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "<<", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "2", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } } ] \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityEnum.ts b/tests/cases/fourslash/quickinfoVerbosityEnum.ts index 1410321801f4c..63ed42a4c4d9e 100644 --- a/tests/cases/fourslash/quickinfoVerbosityEnum.ts +++ b/tests/cases/fourslash/quickinfoVerbosityEnum.ts @@ -13,9 +13,17 @@ //// } //// const y/*y*/: Direction = Direction.Up; +//// enum Flags/*f*/ { +//// None = 0, +//// IsDirectory = 1 << 0, +//// IsFile = 1 << 1, +//// IsSymlink = 1 << 2, +//// } + verify.baselineQuickInfo({ c: [0, 1], x: [0, 1], d: [0, 1], y: [0, 1], + f: [0, 1], }); \ No newline at end of file From 6af0483e471ecd799932678e84d18a750c2c98b0 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 11 Apr 2025 10:29:20 -0700 Subject: [PATCH 26/31] truncation with comment when necessary --- src/compiler/checker.ts | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index db4f0c3dfdf99..704bbeb9774c3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9731,20 +9731,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { i++; if (checkUnfoldingTruncationLength(context) && (i + 2 < props.length - 1)) { context.out.truncated = true; - const placeholder = isClass ? - factory.createPropertyDeclaration( - /*modifiers*/ undefined, - `... ${props.length - i} more ... `, - /*questionOrExclamationToken*/ undefined, - /*type*/ undefined, - /*initializer*/ undefined, - ) : - factory.createPropertySignature( - /*modifiers*/ undefined, - `... ${props.length - i} more ... `, - /*questionToken*/ undefined, - /*type*/ undefined, - ); + const placeholder = createTruncationProperty(`... ${props.length - i} more ... `, isClass); elements.push(placeholder); const result = isClass ? serializePropertySymbolForClass(props[props.length - 1], isStatic!, baseType) : @@ -9772,6 +9759,26 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return elements; } + function createTruncationProperty(dotDotDotText: string, isClass: boolean): TypeElement | ClassElement { + if (context.flags & NodeBuilderFlags.NoTruncation) { + return addSyntheticLeadingComment(factory.createNotEmittedTypeElement(), SyntaxKind.MultiLineCommentTrivia, dotDotDotText); + } + return isClass ? + factory.createPropertyDeclaration( + /*modifiers*/ undefined, + dotDotDotText, + /*questionOrExclamationToken*/ undefined, + /*type*/ undefined, + /*initializer*/ undefined, + ) : + factory.createPropertySignature( + /*modifiers*/ undefined, + dotDotDotText, + /*questionToken*/ undefined, + /*type*/ undefined, + ); + } + function getNamespaceMembersForSerialization(symbol: Symbol) { let exports = arrayFrom(getExportsOfSymbol(symbol).values()); const merged = getMergedSymbol(symbol); @@ -9891,7 +9898,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { initializer = initializedValue === undefined ? undefined : typeof initializedValue === "string" ? factory.createStringLiteral(initializedValue) : factory.createNumericLiteral(initializedValue); - initializerLength = (initializer as StringLiteral | NumericLiteral | undefined)?.text.length ?? 0 + initializerLength = (initializer as StringLiteral | NumericLiteral | undefined)?.text.length ?? 0; } const memberName = unescapeLeadingUnderscores(p.escapedName); context.approximateLength += 4 + memberName.length + initializerLength; // `member = initializer,` @@ -9928,6 +9935,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function createTruncationStatement(dotDotDotText: string): Statement { + if (context.flags & NodeBuilderFlags.NoTruncation) { + return addSyntheticLeadingComment(factory.createEmptyStatement(), SyntaxKind.MultiLineCommentTrivia, dotDotDotText); + } return factory.createExpressionStatement(factory.createIdentifier(dotDotDotText)); } From 435418a667920a925e53b64390b3af543c397db7 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 11 Apr 2025 10:31:06 -0700 Subject: [PATCH 27/31] comments --- src/compiler/checker.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 704bbeb9774c3..f08fadfe78835 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10929,7 +10929,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } /** Returns true if a type is declared in a lib file. */ - // Don't unfold types like `Array` or `Promise`, instead treating them as transparent. + // Don't unfold types like `Array` or `Promise`, instead treating them as opaque. function isLibType(type: Type): boolean { const symbol = (getObjectFlags(type) & ObjectFlags.Reference) !== 0 ? (type as TypeReference).target.symbol : type.symbol; return isTupleType(type) || !!(symbol?.declarations?.some(decl => host.isSourceFileDefaultLibrary(getSourceFileOfNode(decl)))); @@ -53337,6 +53337,7 @@ interface NodeBuilderContext extends SyntacticTypeNodeBuilderContext { flags: NodeBuilderFlags; internalFlags: InternalNodeBuilderFlags; tracker: SymbolTrackerImpl; + /* Maximum depth we're allowed to unfold aliases. */ readonly unfoldDepth: number; // State @@ -53361,7 +53362,8 @@ interface NodeBuilderContext extends SyntacticTypeNodeBuilderContext { reverseMappedStack: ReverseMappedSymbol[] | undefined; bundled: boolean; mapper: TypeMapper | undefined; - depth: number; // How many levels of nested type aliases we have unfolded so far + /* How many levels of nested aliases we have unfolded so far. */ + depth: number; suppressReportInferenceFallback: boolean; typeStack: number[]; From 7fe7ec232732183e77c47544bb3264edc4901a28 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 11 Apr 2025 10:49:49 -0700 Subject: [PATCH 28/31] refactor: move things around --- src/compiler/checker.ts | 4 +++- src/compiler/emitter.ts | 1 + src/compiler/types.ts | 2 +- src/services/symbolDisplay.ts | 13 ++++--------- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f08fadfe78835..6ff151d27a7ce 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1935,7 +1935,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { getSymbolFlags, getTypeArgumentsForResolvedSignature, isLibType, - symbolToDeclarations: nodeBuilder.symbolToDeclarations, }; function getTypeArgumentsForResolvedSignature(signature: Signature) { @@ -51003,6 +51002,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } }, + symbolToDeclarations: (symbol, meaning, flags, verbosityLevel, out) => { + return nodeBuilder.symbolToDeclarations(symbol, meaning, flags, verbosityLevel, out); + } }; function isImportRequiredByAugmentation(node: ImportDeclaration) { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 01a96579861f4..1fd93c74ed455 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1168,6 +1168,7 @@ export const notImplementedResolver: EmitResolver = { isImportRequiredByAugmentation: notImplemented, isDefinitelyReferenceToGlobalSymbolObject: notImplemented, createLateBoundIndexSignatures: notImplemented, + symbolToDeclarations: notImplemented, }; const enum PipelinePhase { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index bc7960c7634c5..98ca8cf4c5642 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5446,7 +5446,6 @@ export interface TypeChecker { getTypeArgumentsForResolvedSignature(signature: Signature): readonly Type[] | undefined; /** @internal */ isLibType(type: Type): boolean; - /** @internal */ symbolToDeclarations(symbol: Symbol, meaning: SymbolFlags, flags: NodeBuilderFlags, verbosityLevel?: number, out?: WriterContextOut): Declaration[]; } /** @internal */ @@ -5893,6 +5892,7 @@ export interface EmitResolver { isImportRequiredByAugmentation(decl: ImportDeclaration): boolean; isDefinitelyReferenceToGlobalSymbolObject(node: Node): boolean; createLateBoundIndexSignatures(cls: ClassLikeDeclaration, enclosingDeclaration: Node, flags: NodeBuilderFlags, internalFlags: InternalNodeBuilderFlags, tracker: SymbolTracker): (IndexSignatureDeclaration | PropertyDeclaration)[] | undefined; + symbolToDeclarations(symbol: Symbol, meaning: SymbolFlags, flags: NodeBuilderFlags, verbosityLevel?: number, out?: WriterContextOut): Declaration[]; } // dprint-ignore diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 586187f7c67af..67a339c7faa45 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -835,7 +835,9 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( if (verbosityLevel === undefined) { return false; } - const type = getTypeOfSymbol(symbol); + const type = symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) ? + typeChecker.getDeclaredTypeOfSymbol(symbol) : + typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (!type || typeChecker.isLibType(type)) { return false; } @@ -848,13 +850,6 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( return false; } - function getTypeOfSymbol(symbol: Symbol) { - if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - return typeChecker.getDeclaredTypeOfSymbol(symbol); - } - return typeChecker.getTypeOfSymbolAtLocation(symbol, location); - } - function getSymbolMeaning(meaning: SemanticMeaning): SymbolFlags { let symbolMeaning = SymbolFlags.None; if (meaning & SemanticMeaning.Value) { @@ -876,7 +871,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( if (canUnfoldSymbol(symbol, typeWriterOut)) { const symbolMeaning = getSymbolMeaning(meaning); const expandedDisplayParts = mapToDisplayParts(writer => { - const nodes = typeChecker.symbolToDeclarations( + const nodes = typeChecker.getEmitResolver().symbolToDeclarations( symbol, symbolMeaning, TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, From defed5d0e7b11e258abb4d5e351b6cea0ec1423d Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 11 Apr 2025 11:56:39 -0700 Subject: [PATCH 29/31] renaming, more comments --- src/compiler/checker.ts | 94 +++++++++++++++++++---------------- src/compiler/types.ts | 4 +- src/services/symbolDisplay.ts | 40 +++++++++------ 3 files changed, 76 insertions(+), 62 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6ff151d27a7ce..b568dbd876e33 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6460,7 +6460,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { flags: flags || NodeBuilderFlags.None, internalFlags: internalFlags || InternalNodeBuilderFlags.None, tracker: undefined!, - unfoldDepth: verbosityLevel ?? -1, + maxExpansionDepth: verbosityLevel ?? -1, encounteredError: false, suppressReportInferenceFallback: false, reportedDiagnostic: false, @@ -6486,7 +6486,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { depth: 0, typeStack: [], out: { - couldUnfoldMore: false, + canIncreaseExpansionDepth: false, truncated: false, }, }; @@ -6496,7 +6496,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { context.tracker.reportTruncationError(); } if (out) { - out.couldUnfoldMore = context.out.couldUnfoldMore; + out.canIncreaseExpansionDepth = context.out.canIncreaseExpansionDepth; out.truncated = context.out.truncated; } return context.encounteredError ? undefined : resultingNode; @@ -6530,8 +6530,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function checkUnfoldingTruncationLength(context: NodeBuilderContext): boolean { - return context.unfoldDepth >= 0 && checkTruncationLength(context); + function checkTruncationLengthIfExpanding(context: NodeBuilderContext): boolean { + return context.maxExpansionDepth >= 0 && checkTruncationLength(context); } function checkTruncationLength(context: NodeBuilderContext): boolean { @@ -6539,19 +6539,24 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return context.truncating = context.approximateLength > ((context.flags & NodeBuilderFlags.NoTruncation) ? noTruncationMaximumTruncationLength : defaultMaximumTruncationLength); } - function couldUnfoldType(type: Type, context: NodeBuilderContext): boolean { + /** + * Returns true if it's possible the type or one of its components can be expanded. + */ + function canPossiblyExpandType(type: Type, context: NodeBuilderContext): boolean { for (let i = 0; i < context.typeStack.length - 1; i++) { if (context.typeStack[i] === type.id) { return false; } } - return context.depth < context.unfoldDepth || context.depth === context.unfoldDepth && !context.out.couldUnfoldMore; + return context.depth < context.maxExpansionDepth || + context.depth === context.maxExpansionDepth && !context.out.canIncreaseExpansionDepth; } - /** Determines if a type can be unfolded, based on how many layers of type aliases we're allowed to unfold. - * @param isAlias - Whether we're unfolding a type alias or not. + /** + * Determines if the input type should be expanded, based on how many layers of names we're allowed to expand. + * @param isAlias - Whether we're expanding a type alias or not. */ - function canUnfoldType(type: Type, context: NodeBuilderContext, isAlias = false): boolean { + function shouldExpandType(type: Type, context: NodeBuilderContext, isAlias = false): boolean { if (!isAlias && isLibType(type)) { return false; } @@ -6560,9 +6565,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return false; } } - const result = context.depth < context.unfoldDepth; + const result = context.depth < context.maxExpansionDepth; if (!result) { - context.out.couldUnfoldMore = true; + // This type would have been expanded if `maxExpansionDepth` was increased. + context.out.canIncreaseExpansionDepth = true; } return result; } @@ -6651,7 +6657,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`."); } } - if (!canUnfoldType(type, context)) { + if (!shouldExpandType(type, context)) { return symbolToTypeNode(type.symbol, context, SymbolFlags.Type); } else { @@ -6724,7 +6730,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } if (!inTypeAlias && type.aliasSymbol && (context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - if (!canUnfoldType(type, context, /*isAlias*/ true)) { + if (!shouldExpandType(type, context, /*isAlias*/ true)) { const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & SymbolFlags.Class)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes); if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) { @@ -6739,7 +6745,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (objectFlags & ObjectFlags.Reference) { Debug.assert(!!(type.flags & TypeFlags.Object)); - if (canUnfoldType(type, context)) { + if (shouldExpandType(type, context)) { context.depth += 1; return createAnonymousTypeNode(type as TypeReference, /*forceClassExpansion*/ true, /*forceExpansion*/ true); } @@ -6771,7 +6777,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { context.approximateLength += idText(name).length; return factory.createTypeReferenceNode(factory.createIdentifier(idText(name)), /*typeArguments*/ undefined); } - if (objectFlags & ObjectFlags.ClassOrInterface && canUnfoldType(type, context)) { + if (objectFlags & ObjectFlags.ClassOrInterface && shouldExpandType(type, context)) { context.depth += 1; return createAnonymousTypeNode(type as InterfaceType, /*forceClassExpansion*/ true, /*forceExpansion*/ true); } @@ -7027,7 +7033,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { || symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || shouldWriteTypeOfFunctionSymbol()) ) { - if (canUnfoldType(type, context)) { + if (shouldExpandType(type, context)) { context.depth += 1; } else { @@ -7083,8 +7089,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { context.symbolDepth = new Map(); } - // Don't rely on type cache if we're unfolding a type, because we need to compute `couldUnfoldMore`. - const links = context.unfoldDepth >= 0 ? undefined : context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); + // Don't rely on type cache if we're expand a type, because we need to compute `canIncreaseExpansionDepth`. + const links = context.maxExpansionDepth >= 0 ? undefined : context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); const key = `${getTypeId(type)}|${context.flags}|${context.internalFlags}`; if (links) { links.serializedTypes ||= new Map(); @@ -7471,7 +7477,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let i = 0; for (const propertySymbol of properties) { - if (isUnfolding(context) && propertySymbol.flags & SymbolFlags.Prototype) { + if (isExpanding(context) && propertySymbol.flags & SymbolFlags.Prototype) { continue; } i++; @@ -8120,7 +8126,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function typeToTypeNodeHelperWithPossibleReusableTypeNode(type: Type, typeNode: TypeNode | undefined, context: NodeBuilderContext) { - return !couldUnfoldType(type, context) && typeNode && getTypeFromTypeNode(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) + return !canPossiblyExpandType(type, context) && typeNode && getTypeFromTypeNode(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context); } @@ -8870,7 +8876,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let result; const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration); const decl = declaration ?? symbol.valueDeclaration ?? getDeclarationWithTypeAnnotation(symbol) ?? symbol.declarations?.[0]; - if (!couldUnfoldType(type, context) && decl) { + if (!canPossiblyExpandType(type, context) && decl) { const restore = addSymbolTypeToContext(context, symbol, type); if (isAccessor(decl)) { result = syntacticNodeBuilder.serializeTypeOfAccessor(decl, symbol, context); @@ -8920,7 +8926,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const returnType = getReturnTypeOfSignature(signature); if (!(suppressAny && isTypeAny(returnType))) { - if (signature.declaration && !nodeIsSynthesized(signature.declaration) && !couldUnfoldType(returnType, context)) { + if (signature.declaration && !nodeIsSynthesized(signature.declaration) && !canPossiblyExpandType(returnType, context)) { const declarationSymbol = getSymbolOfDeclaration(signature.declaration); const restore = addSymbolTypeToContext(context, declarationSymbol, returnType); returnTypeNode = syntacticNodeBuilder.serializeReturnTypeForSignature(signature.declaration, declarationSymbol, context); @@ -9353,7 +9359,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const symbols = Array.from(symbolTable.values()); for (const symbol of symbols) { i++; - if (checkUnfoldingTruncationLength(context) && (i + 2 < symbolTable.size - 1)) { + if (checkTruncationLengthIfExpanding(context) && (i + 2 < symbolTable.size - 1)) { context.out.truncated = true; results.push(createTruncationStatement(`... (${symbolTable.size - i} more ...)`)); serializeSymbol(symbols[symbols.length - 1], /*isPrivate*/ false, !!propertyAsAlias); @@ -9728,7 +9734,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let i = 0; for (const prop of props) { i++; - if (checkUnfoldingTruncationLength(context) && (i + 2 < props.length - 1)) { + if (checkTruncationLengthIfExpanding(context) && (i + 2 < props.length - 1)) { context.out.truncated = true; const placeholder = createTruncationProperty(`... ${props.length - i} more ... `, isClass); elements.push(placeholder); @@ -9799,17 +9805,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function serializeModule(symbol: Symbol, symbolName: string, modifierFlags: ModifierFlags) { const members = getNamespaceMembersForSerialization(symbol); - const unfolding = isUnfolding(context); + const expanding = isExpanding(context); // Split NS members up by declaration - members whose parent symbol is the ns symbol vs those whose is not (but were added in later via merging) - const locationMap = arrayToMultiMap(members, m => m.parent && m.parent === symbol || unfolding ? "real" : "merged"); + const locationMap = arrayToMultiMap(members, m => m.parent && m.parent === symbol || expanding ? "real" : "merged"); const realMembers = locationMap.get("real") || emptyArray; const mergedMembers = locationMap.get("merged") || emptyArray; // TODO: `suppressNewPrivateContext` is questionable -we need to simply be emitting privates in whatever scope they were declared in, rather // than whatever scope we traverse to them in. That's a bit of a complex rewrite, since we're not _actually_ tracking privates at all in advance, // so we don't even have placeholders to fill in. - if (length(realMembers) || unfolding) { + if (length(realMembers) || expanding) { let localName: ModuleName; - if (unfolding) { + if (expanding) { // Use the same name as symbol display. const oldFlags = context.flags; context.flags |= NodeBuilderFlags.WriteTypeParametersInQualifiedName | SymbolFormatFlags.UseOnlyExternalAliasing; @@ -9863,7 +9869,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let i = 0; for (const p of memberProps) { i++; - if (checkUnfoldingTruncationLength(context) && (i + 2 < memberProps.length - 1)) { + if (checkTruncationLengthIfExpanding(context) && (i + 2 < memberProps.length - 1)) { context.out.truncated = true; members.push(factory.createEnumMember(` ... ${memberProps.length - i} more ... `)); const last = memberProps[memberProps.length - 1]; @@ -9888,7 +9894,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { undefined; let initializer: Expression | undefined; let initializerLength: number; - if (isUnfolding(context) && memberDecl && memberDecl.initializer) { + if (isExpanding(context) && memberDecl && memberDecl.initializer) { initializer = visitNode(memberDecl.initializer, factory.cloneNode, isExpression); initializerLength = memberDecl.initializer.end - memberDecl.initializer.pos; } @@ -9955,10 +9961,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function serializeAsNamespaceDeclaration(props: readonly Symbol[], localName: ModuleName, modifierFlags: ModifierFlags, suppressNewPrivateContext: boolean) { const nodeFlags = isIdentifier(localName) ? NodeFlags.Namespace : NodeFlags.None; - const unfolding = isUnfolding(context); + const expanding = isExpanding(context); if (length(props)) { context.approximateLength += 14; // "namespace { }" - const localVsRemoteMap = arrayToMultiMap(props, p => !length(p.declarations) || some(p.declarations, d => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration!)) || unfolding ? "local" : "remote"); + const localVsRemoteMap = arrayToMultiMap(props, p => !length(p.declarations) || some(p.declarations, d => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration!)) || expanding ? "local" : "remote"); const localProps = localVsRemoteMap.get("local") || emptyArray; // handle remote props first - we need to make an `import` declaration that points at the module containing each remote // prop in the outermost scope (TODO: a namespace within a namespace would need to be appropriately handled by this) @@ -10011,7 +10017,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { ); addResult(fakespace, modifierFlags); // namespaces can never be default exported } - else if (unfolding) { + else if (expanding) { context.approximateLength += 14; // "namespace { }" addResult( factory.createModuleDeclaration( @@ -10091,7 +10097,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const hasPrivateIdentifier = some(symbolProps, isHashPrivate); // Boil down all private properties into a single one. const privateProperties = hasPrivateIdentifier ? - isUnfolding(context) ? + isExpanding(context) ? serializePropertySymbolsForClassOrInterface(filter(symbolProps, isHashPrivate), /*isClass*/ true, baseTypes[0], /*isStatic*/ false) : [factory.createPropertyDeclaration( /*modifiers*/ undefined, @@ -10101,7 +10107,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { /*initializer*/ undefined, )] : emptyArray; - if (hasPrivateIdentifier && !isUnfolding(context)) { + if (hasPrivateIdentifier && !isExpanding(context)) { context.approximateLength += 9; // `#private;` } const publicProperties = serializePropertySymbolsForClassOrInterface(publicSymbolProps, /*isClass*/ true, baseTypes[0], /*isStatic*/ false); @@ -10582,7 +10588,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { ): (p: Symbol, isStatic: boolean, baseType: Type | undefined) => T | AccessorDeclaration | (T | AccessorDeclaration)[] { return function serializePropertySymbol(p: Symbol, isStatic: boolean, baseType: Type | undefined): T | AccessorDeclaration | (T | AccessorDeclaration)[] { const modifierFlags = getDeclarationModifierFlagsFromSymbol(p); - const omitType = !!(modifierFlags & ModifierFlags.Private) && !isUnfolding(context); + const omitType = !!(modifierFlags & ModifierFlags.Private) && !isExpanding(context); if (isStatic && (p.flags & (SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias))) { // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols // need to be merged namespace members @@ -10908,8 +10914,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function isUnfolding(context: NodeBuilderContext) { - return context.unfoldDepth !== -1; + function isExpanding(context: NodeBuilderContext) { + return context.maxExpansionDepth !== -1; } function isHashPrivate(s: Symbol): boolean { @@ -10928,7 +10934,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } /** Returns true if a type is declared in a lib file. */ - // Don't unfold types like `Array` or `Promise`, instead treating them as opaque. + // Don't expand types like `Array` or `Promise`, instead treating them as opaque. function isLibType(type: Type): boolean { const symbol = (getObjectFlags(type) & ObjectFlags.Reference) !== 0 ? (type as TypeReference).target.symbol : type.symbol; return isTupleType(type) || !!(symbol?.declarations?.some(decl => host.isSourceFileDefaultLibrary(getSourceFileOfNode(decl)))); @@ -51004,7 +51010,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { }, symbolToDeclarations: (symbol, meaning, flags, verbosityLevel, out) => { return nodeBuilder.symbolToDeclarations(symbol, meaning, flags, verbosityLevel, out); - } + }, }; function isImportRequiredByAugmentation(node: ImportDeclaration) { @@ -53339,8 +53345,8 @@ interface NodeBuilderContext extends SyntacticTypeNodeBuilderContext { flags: NodeBuilderFlags; internalFlags: InternalNodeBuilderFlags; tracker: SymbolTrackerImpl; - /* Maximum depth we're allowed to unfold aliases. */ - readonly unfoldDepth: number; + /* Maximum depth we're allowed to expand names. */ + readonly maxExpansionDepth: number; // State encounteredError: boolean; @@ -53364,7 +53370,7 @@ interface NodeBuilderContext extends SyntacticTypeNodeBuilderContext { reverseMappedStack: ReverseMappedSymbol[] | undefined; bundled: boolean; mapper: TypeMapper | undefined; - /* How many levels of nested aliases we have unfolded so far. */ + /* How many levels of nested names we have expanded so far. */ depth: number; suppressReportInferenceFallback: boolean; typeStack: number[]; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 98ca8cf4c5642..71f82a6e13d28 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5052,8 +5052,8 @@ export interface TypeCheckerHost extends ModuleSpecifierResolutionHost, SourceFi /** @internal */ export interface WriterContextOut { - /** Whether we found a type alias that we could unfold but didn't. */ - couldUnfoldMore: boolean; + /** Whether increasing the expansion depth will cause us to expand more types. */ + canIncreaseExpansionDepth: boolean; truncated: boolean; } diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 67a339c7faa45..163424116f694 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -279,8 +279,8 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( let documentationFromAlias: SymbolDisplayPart[] | undefined; let tagsFromAlias: JSDocTagInfo[] | undefined; let hasMultipleSignatures = false; - const typeWriterOut: WriterContextOut = { couldUnfoldMore: false, truncated: false }; - let hasUnfoldedSymbol = false; + const typeWriterOut: WriterContextOut = { canIncreaseExpansionDepth: false, truncated: false }; + let symbolWasExpanded = false; if (location.kind === SyntaxKind.ThisKeyword && !isThisExpression) { return { displayParts: [keywordPart(SyntaxKind.ThisKeyword)], documentation: [], symbolKind: ScriptElementKind.primitiveType, tags: undefined }; @@ -454,7 +454,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( pushSymbolKind(ScriptElementKind.localClassElement); displayParts.push(spacePart()); } - if (!tryUnfoldSymbol(symbol, semanticMeaning)) { + if (!tryExpandSymbol(symbol, semanticMeaning)) { if (!classExpression) { // Class declaration has name which is not local. displayParts.push(keywordPart(SyntaxKind.ClassKeyword)); @@ -466,7 +466,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( } if ((symbolFlags & SymbolFlags.Interface) && (semanticMeaning & SemanticMeaning.Type)) { prefixNextMeaning(); - if (!tryUnfoldSymbol(symbol, semanticMeaning)) { + if (!tryExpandSymbol(symbol, semanticMeaning)) { displayParts.push(keywordPart(SyntaxKind.InterfaceKeyword)); displayParts.push(spacePart()); addFullSymbolName(symbol); @@ -496,7 +496,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( } if (symbolFlags & SymbolFlags.Enum) { prefixNextMeaning(); - if (!tryUnfoldSymbol(symbol, semanticMeaning)) { + if (!tryExpandSymbol(symbol, semanticMeaning)) { if (some(symbol.declarations, d => isEnumDeclaration(d) && isEnumConst(d))) { displayParts.push(keywordPart(SyntaxKind.ConstKeyword)); displayParts.push(spacePart()); @@ -508,7 +508,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( } if (symbolFlags & SymbolFlags.Module && !isThisExpression) { prefixNextMeaning(); - if (!tryUnfoldSymbol(symbol, semanticMeaning)) { + if (!tryExpandSymbol(symbol, semanticMeaning)) { const declaration = getDeclarationOfKind(symbol, SyntaxKind.ModuleDeclaration); const isNamespace = declaration && declaration.name && declaration.name.kind === SyntaxKind.Identifier; displayParts.push(keywordPart(isNamespace ? SyntaxKind.NamespaceKeyword : SyntaxKind.ModuleKeyword)); @@ -603,7 +603,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( documentationFromAlias = resolvedInfo.documentation; tagsFromAlias = resolvedInfo.tags; if (typeWriterOut && resolvedInfo.canIncreaseVerbosityLevel) { - typeWriterOut.couldUnfoldMore = true; + typeWriterOut.canIncreaseExpansionDepth = true; } } else { @@ -798,7 +798,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( tags = tagsFromAlias; } - const canIncreaseVerbosityLevel = !typeWriterOut.truncated && typeWriterOut.couldUnfoldMore; + const canIncreaseVerbosityLevel = !typeWriterOut.truncated && typeWriterOut.canIncreaseExpansionDepth; return { displayParts, documentation, @@ -831,7 +831,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( displayParts.push(spacePart()); } - function canUnfoldSymbol(symbol: Symbol, out: WriterContextOut | undefined): boolean { + function canExpandSymbol(symbol: Symbol, out: WriterContextOut | undefined): boolean { if (verbosityLevel === undefined) { return false; } @@ -845,12 +845,12 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( return true; } if (out) { - out.couldUnfoldMore = true; + out.canIncreaseExpansionDepth = true; } return false; } - function getSymbolMeaning(meaning: SemanticMeaning): SymbolFlags { + function semanticToSymbolMeaning(meaning: SemanticMeaning): SymbolFlags { let symbolMeaning = SymbolFlags.None; if (meaning & SemanticMeaning.Value) { symbolMeaning |= SymbolFlags.Value; @@ -864,12 +864,20 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( return symbolMeaning; } - function tryUnfoldSymbol(symbol: Symbol, meaning: SemanticMeaning): boolean { - if (hasUnfoldedSymbol) { + /** + * Attempts to expand the hover for a symbol, returning true if it succeeded. + * e.g. Given a symbol `Foo` corresponding to `class Foo { prop1: number }`, + * we will expand the hover to contain a full declaration of the class. + */ + function tryExpandSymbol(symbol: Symbol, meaning: SemanticMeaning): boolean { + // It's possible we call this function multiple times for the same symbol, if the symbol represents more than one kind of thing. + // For instance, we'll call this function twice for a symbol that is both a function and a namespace. + // In this case, `symbolWasExpanded` will be true the second time we call this function, and we don't need to expand it again. + if (symbolWasExpanded) { return true; } - if (canUnfoldSymbol(symbol, typeWriterOut)) { - const symbolMeaning = getSymbolMeaning(meaning); + if (canExpandSymbol(symbol, typeWriterOut)) { + const symbolMeaning = semanticToSymbolMeaning(meaning); const expandedDisplayParts = mapToDisplayParts(writer => { const nodes = typeChecker.getEmitResolver().symbolToDeclarations( symbol, @@ -885,7 +893,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( }); }); addRange(displayParts, expandedDisplayParts); - hasUnfoldedSymbol = true; + symbolWasExpanded = true; return true; } return false; From 9e2feca5d4a765c19adcd8b54af387025c72c038 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Mon, 14 Apr 2025 14:01:54 -0700 Subject: [PATCH 30/31] address some CR comments --- src/compiler/checker.ts | 43 +-- src/services/symbolDisplay.ts | 2 +- .../reference/quickinfoVerbosityEnum.baseline | 253 +++++++++++++++--- .../cases/fourslash/quickinfoVerbosityEnum.ts | 11 + 4 files changed, 256 insertions(+), 53 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b568dbd876e33..8e119a0dacc79 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8760,7 +8760,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function getPropertyNameNodeForSymbol(symbol: Symbol, context: NodeBuilderContext) { - const hashPrivateName = getHashPrivateName(symbol); + const hashPrivateName = getClonedHashPrivateName(symbol); if (hashPrivateName) { return hashPrivateName; } @@ -9895,7 +9895,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let initializer: Expression | undefined; let initializerLength: number; if (isExpanding(context) && memberDecl && memberDecl.initializer) { - initializer = visitNode(memberDecl.initializer, factory.cloneNode, isExpression); + initializer = memberDecl.initializer; initializerLength = memberDecl.initializer.end - memberDecl.initializer.pos; } else { @@ -10626,7 +10626,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { Debug.assert(!!setter); const paramSymbol = isFunctionLikeDeclaration(setter) ? getSignatureFromDeclaration(setter).parameters[0] : undefined; const setterDeclaration = p.declarations?.find(isSetAccessor); - context.approximateLength += modifiersLength(flag) + 7 + (paramSymbol ? symbolName(paramSymbol).length : 5) + (omitType ? 0 : 1); // `modifiers set name(param);`, approximate name + context.approximateLength += modifiersLength(flag) + 7 + (paramSymbol ? symbolName(paramSymbol).length : 5) + (omitType ? 0 : 2); // `modifiers set name(param);`, approximate name result.push(setTextRange( context, factory.createSetAccessorDeclaration( @@ -10646,7 +10646,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } if (p.flags & SymbolFlags.GetAccessor) { const getterDeclaration = p.declarations?.find(isGetAccessor); - context.approximateLength += modifiersLength(flag) + 9 + (omitType ? 0 : 1); // `modifiers get name(): ;`, approximate name + context.approximateLength += modifiersLength(flag) + 8 + (omitType ? 0 : 2); // `modifiers get name(): ;`, approximate name result.push(setTextRange( context, factory.createGetAccessorDeclaration( @@ -10665,7 +10665,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // If this happens, we assume the accessor takes priority, as it imposes more constraints else if (p.flags & (SymbolFlags.Property | SymbolFlags.Variable | SymbolFlags.Accessor)) { const modifierFlags = (isReadonlySymbol(p) ? ModifierFlags.Readonly : 0) | flag; - context.approximateLength += 1 + (omitType ? 0 : 1) + modifiersLength(modifierFlags); // `modifiers name: ;`, approximate name + context.approximateLength += 2 + (omitType ? 0 : 2) + modifiersLength(modifierFlags); // `modifiers name: ;`, approximate name return setTextRange( context, createProperty( @@ -10725,21 +10725,22 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function modifiersLength(flags: ModifierFlags): number { let result = 0; - if (flags & ModifierFlags.Export) result += 6; - if (flags & ModifierFlags.Ambient) result += 7; - if (flags & ModifierFlags.Default) result += 7; - if (flags & ModifierFlags.Const) result += 5; - if (flags & ModifierFlags.Public) result += 6; - if (flags & ModifierFlags.Private) result += 7; - if (flags & ModifierFlags.Protected) result += 9; - if (flags & ModifierFlags.Abstract) result += 8; - if (flags & ModifierFlags.Static) result += 6; - if (flags & ModifierFlags.Override) result += 8; - if (flags & ModifierFlags.Readonly) result += 8; - if (flags & ModifierFlags.Accessor) result += 8; - if (flags & ModifierFlags.Async) result += 5; - if (flags & ModifierFlags.In) result += 2; - if (flags & ModifierFlags.Out) result += 3; + // Include the trailing space after the modifier keyword. + if (flags & ModifierFlags.Export) result += 7; + if (flags & ModifierFlags.Ambient) result += 8; + if (flags & ModifierFlags.Default) result += 8; + if (flags & ModifierFlags.Const) result += 6; + if (flags & ModifierFlags.Public) result += 7; + if (flags & ModifierFlags.Private) result += 8; + if (flags & ModifierFlags.Protected) result += 10; + if (flags & ModifierFlags.Abstract) result += 9; + if (flags & ModifierFlags.Static) result += 7; + if (flags & ModifierFlags.Override) result += 9; + if (flags & ModifierFlags.Readonly) result += 9; + if (flags & ModifierFlags.Accessor) result += 9; + if (flags & ModifierFlags.Async) result += 6; + if (flags & ModifierFlags.In) result += 3; + if (flags & ModifierFlags.Out) result += 4; return result; } @@ -10925,7 +10926,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return !!s.valueDeclaration && isNamedDeclaration(s.valueDeclaration) && isPrivateIdentifier(s.valueDeclaration.name); } - function getHashPrivateName(s: Symbol): PrivateIdentifier | undefined { + function getClonedHashPrivateName(s: Symbol): PrivateIdentifier | undefined { if (s.valueDeclaration && isNamedDeclaration(s.valueDeclaration) && isPrivateIdentifier(s.valueDeclaration.name)) { return factory.cloneNode(s.valueDeclaration.name); } diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 163424116f694..b727b3cf008dd 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -889,7 +889,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( const printer = getPrinter(); nodes.forEach((node, i) => { if (i > 0) writer.writeLine(); - printer.writeNode(EmitHint.Unspecified, node, sourceFile, writer); + printer.writeNode(EmitHint.Unspecified, node, /*sourceFile*/ undefined, writer); }); }); addRange(displayParts, expandedDisplayParts); diff --git a/tests/baselines/reference/quickinfoVerbosityEnum.baseline b/tests/baselines/reference/quickinfoVerbosityEnum.baseline index eda0f187988e3..b86afbe3ecfdd 100644 --- a/tests/baselines/reference/quickinfoVerbosityEnum.baseline +++ b/tests/baselines/reference/quickinfoVerbosityEnum.baseline @@ -1,5 +1,6 @@ // === QuickInfo === -=== /tests/cases/fourslash/quickinfoVerbosityEnum.ts === +=== /tests/cases/fourslash/a.ts === +// export {}; // enum Color { // ^^^^^ // | ---------------------------------------------------------------------- @@ -80,18 +81,36 @@ // IsSymlink = 1 << 2, // } +=== /tests/cases/fourslash/c.ts === +// import { Color } from "./b"; +// const c: Color = Color.Red; +// ^^^^^ +// | ---------------------------------------------------------------------- +// | (alias) enum Color { +// | Red = "red" +// | } +// | import Color +// | (verbosity level: 1) +// | ---------------------------------------------------------------------- +// ^^^^^ +// | ---------------------------------------------------------------------- +// | (alias) enum Color +// | import Color +// | (verbosity level: 0) +// | ---------------------------------------------------------------------- + [ { "marker": { - "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", - "position": 10, + "fileName": "/tests/cases/fourslash/a.ts", + "position": 21, "name": "c" }, "item": { "kind": "enum", "kindModifiers": "", "textSpan": { - "start": 5, + "start": 16, "length": 5 }, "displayParts": [ @@ -115,15 +134,15 @@ }, { "marker": { - "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", - "position": 10, + "fileName": "/tests/cases/fourslash/a.ts", + "position": 21, "name": "c" }, "item": { "kind": "enum", "kindModifiers": "", "textSpan": { - "start": 5, + "start": 16, "length": 5 }, "displayParts": [ @@ -255,15 +274,15 @@ }, { "marker": { - "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", - "position": 52, + "fileName": "/tests/cases/fourslash/a.ts", + "position": 63, "name": "x" }, "item": { "kind": "const", "kindModifiers": "", "textSpan": { - "start": 51, + "start": 62, "length": 1 }, "displayParts": [ @@ -299,15 +318,15 @@ }, { "marker": { - "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", - "position": 52, + "fileName": "/tests/cases/fourslash/a.ts", + "position": 63, "name": "x" }, "item": { "kind": "const", "kindModifiers": "", "textSpan": { - "start": 51, + "start": 62, "length": 1 }, "displayParts": [ @@ -399,15 +418,15 @@ }, { "marker": { - "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", - "position": 93, + "fileName": "/tests/cases/fourslash/a.ts", + "position": 104, "name": "d" }, "item": { "kind": "enum", "kindModifiers": "", "textSpan": { - "start": 84, + "start": 95, "length": 9 }, "displayParts": [ @@ -439,15 +458,15 @@ }, { "marker": { - "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", - "position": 93, + "fileName": "/tests/cases/fourslash/a.ts", + "position": 104, "name": "d" }, "item": { "kind": "enum", "kindModifiers": "", "textSpan": { - "start": 84, + "start": 95, "length": 9 }, "displayParts": [ @@ -555,15 +574,15 @@ }, { "marker": { - "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", - "position": 123, + "fileName": "/tests/cases/fourslash/a.ts", + "position": 134, "name": "y" }, "item": { "kind": "const", "kindModifiers": "", "textSpan": { - "start": 122, + "start": 133, "length": 1 }, "displayParts": [ @@ -599,15 +618,15 @@ }, { "marker": { - "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", - "position": 123, + "fileName": "/tests/cases/fourslash/a.ts", + "position": 134, "name": "y" }, "item": { "kind": "const", "kindModifiers": "", "textSpan": { - "start": 122, + "start": 133, "length": 1 }, "displayParts": [ @@ -675,15 +694,15 @@ }, { "marker": { - "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", - "position": 161, + "fileName": "/tests/cases/fourslash/a.ts", + "position": 172, "name": "f" }, "item": { "kind": "enum", "kindModifiers": "", "textSpan": { - "start": 156, + "start": 167, "length": 5 }, "displayParts": [ @@ -707,15 +726,15 @@ }, { "marker": { - "fileName": "/tests/cases/fourslash/quickinfoVerbosityEnum.ts", - "position": 161, + "fileName": "/tests/cases/fourslash/a.ts", + "position": 172, "name": "f" }, "item": { "kind": "enum", "kindModifiers": "", "textSpan": { - "start": 156, + "start": 167, "length": 5 }, "displayParts": [ @@ -924,5 +943,177 @@ "canIncreaseVerbosityLevel": false, "verbosityLevel": 1 } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/c.ts", + "position": 43, + "name": "a" + }, + "item": { + "kind": "alias", + "kindModifiers": "export", + "textSpan": { + "start": 38, + "length": 5 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "enum", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "aliasName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": true, + "verbosityLevel": 0 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/c.ts", + "position": 43, + "name": "a" + }, + "item": { + "kind": "alias", + "kindModifiers": "export", + "textSpan": { + "start": 38, + "length": 5 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "alias", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "enum", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Red", + "kind": "text" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"red\"", + "kind": "stringLiteral" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "import", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Color", + "kind": "aliasName" + } + ], + "documentation": [], + "canIncreaseVerbosityLevel": false, + "verbosityLevel": 1 + } } ] \ No newline at end of file diff --git a/tests/cases/fourslash/quickinfoVerbosityEnum.ts b/tests/cases/fourslash/quickinfoVerbosityEnum.ts index 63ed42a4c4d9e..c38af64b98ee7 100644 --- a/tests/cases/fourslash/quickinfoVerbosityEnum.ts +++ b/tests/cases/fourslash/quickinfoVerbosityEnum.ts @@ -1,5 +1,7 @@ /// +// @filename: a.ts +//// export {}; //// enum Color/*c*/ { //// Red, //// Green, @@ -20,10 +22,19 @@ //// IsSymlink = 1 << 2, //// } +// @filename: b.ts +//// export enum Color { +//// Red = "red" +//// } +// @filename: c.ts +//// import { Color } from "./b"; +//// const c: Color/*a*/ = Color.Red; + verify.baselineQuickInfo({ c: [0, 1], x: [0, 1], d: [0, 1], y: [0, 1], f: [0, 1], + a: [0, 1], }); \ No newline at end of file From 98772e15b8fc27c6e2b7443078d0d53efdc06047 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Tue, 15 Apr 2025 11:11:02 -0700 Subject: [PATCH 31/31] deep clone enum initializer when reused for quickinfo expansion --- src/compiler/checker.ts | 3 +- src/compiler/utilities.ts | 122 +++++++++++++++++ src/services/symbolDisplay.ts | 3 +- src/services/utilities.ts | 126 ------------------ ...ckinfoVerbosityToplevelTruncation.baseline | 78 +---------- 5 files changed, 128 insertions(+), 204 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8e119a0dacc79..e3a42439ff63a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -374,6 +374,7 @@ import { getStrictOptionValue, getSuperContainer, getSymbolNameForPrivateIdentifier, + getSynthesizedDeepClone, getTextOfIdentifierOrLiteral, getTextOfJSDocComment, getTextOfJsxAttributeName, @@ -9895,7 +9896,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let initializer: Expression | undefined; let initializerLength: number; if (isExpanding(context) && memberDecl && memberDecl.initializer) { - initializer = memberDecl.initializer; + initializer = getSynthesizedDeepClone(memberDecl.initializer); initializerLength = memberDecl.initializer.end - memberDecl.initializer.pos; } else { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5755369134d8a..bf28d3e8982d5 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2,6 +2,7 @@ import { __String, AccessExpression, AccessorDeclaration, + addEmitFlags, addRange, affectsDeclarationPathOptionDeclarations, affectsEmitOptionDeclarations, @@ -511,6 +512,8 @@ import { ScriptTarget, semanticDiagnosticsOptionDeclarations, SetAccessorDeclaration, + setOriginalNode, + setTextRange, ShorthandPropertyAssignment, shouldAllowImportingTsExtension, Signature, @@ -592,6 +595,7 @@ import { VariableDeclarationList, VariableLikeDeclaration, VariableStatement, + visitEachChild, WhileStatement, WithStatement, WrappedExpression, @@ -12208,3 +12212,121 @@ export function getOptionsSyntaxByValue(optionsObject: ObjectLiteralExpression | export function forEachOptionsSyntaxByName(optionsObject: ObjectLiteralExpression | undefined, name: string, callback: (prop: PropertyAssignment) => T | undefined): T | undefined { return forEachPropertyAssignment(optionsObject, name, callback); } + +/** + * Creates a deep, memberwise clone of a node with no source map location. + * + * WARNING: This is an expensive operation and is only intended to be used in refactorings + * and code fixes (because those are triggered by explicit user actions). + * + * @internal + */ +// Moved here to compiler utilities for usage in node builder for quickinfo. +export function getSynthesizedDeepClone(node: T, includeTrivia = true): T { + const clone = node && getSynthesizedDeepCloneWorker(node); + if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone); + return setParentRecursive(clone, /*incremental*/ false); +} + +/** @internal */ +export function getSynthesizedDeepCloneWithReplacements( + node: T, + includeTrivia: boolean, + replaceNode: (node: Node) => Node | undefined, +): T { + let clone = replaceNode(node); + if (clone) { + setOriginalNode(clone, node); + } + else { + clone = getSynthesizedDeepCloneWorker(node as NonNullable, replaceNode); + } + + if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone); + return clone as T; +} + +function getSynthesizedDeepCloneWorker(node: T, replaceNode?: (node: Node) => Node | undefined): T { + const nodeClone: (n: T) => T = replaceNode + ? n => getSynthesizedDeepCloneWithReplacements(n, /*includeTrivia*/ true, replaceNode) + : getSynthesizedDeepClone; + const nodesClone: (ns: NodeArray | undefined) => NodeArray | undefined = replaceNode + ? ns => ns && getSynthesizedDeepClonesWithReplacements(ns, /*includeTrivia*/ true, replaceNode) + : ns => ns && getSynthesizedDeepClones(ns); + const visited = visitEachChild(node, nodeClone, /*context*/ undefined, nodesClone, nodeClone); + + if (visited === node) { + // This only happens for leaf nodes - internal nodes always see their children change. + const clone = isStringLiteral(node) ? setOriginalNode(factory.createStringLiteralFromNode(node), node) as Node as T : + isNumericLiteral(node) ? setOriginalNode(factory.createNumericLiteral(node.text, node.numericLiteralFlags), node) as Node as T : + factory.cloneNode(node); + return setTextRange(clone, node); + } + + // PERF: As an optimization, rather than calling factory.cloneNode, we'll update + // the new node created by visitEachChild with the extra changes factory.cloneNode + // would have made. + (visited as Mutable).parent = undefined!; + return visited; +} + +/** @internal */ +export function getSynthesizedDeepClones(nodes: NodeArray, includeTrivia?: boolean): NodeArray; +/** @internal */ +export function getSynthesizedDeepClones(nodes: NodeArray | undefined, includeTrivia?: boolean): NodeArray | undefined; +/** @internal */ +export function getSynthesizedDeepClones(nodes: NodeArray | undefined, includeTrivia = true): NodeArray | undefined { + if (nodes) { + const cloned = factory.createNodeArray(nodes.map(n => getSynthesizedDeepClone(n, includeTrivia)), nodes.hasTrailingComma); + setTextRange(cloned, nodes); + return cloned; + } + return nodes; +} + +/** @internal */ +export function getSynthesizedDeepClonesWithReplacements( + nodes: NodeArray, + includeTrivia: boolean, + replaceNode: (node: Node) => Node | undefined, +): NodeArray { + return factory.createNodeArray(nodes.map(n => getSynthesizedDeepCloneWithReplacements(n, includeTrivia, replaceNode)), nodes.hasTrailingComma); +} + +/** + * Sets EmitFlags to suppress leading and trailing trivia on the node. + * + * @internal + */ +export function suppressLeadingAndTrailingTrivia(node: Node): void { + suppressLeadingTrivia(node); + suppressTrailingTrivia(node); +} + +/** + * Sets EmitFlags to suppress leading trivia on the node. + * + * @internal + */ +export function suppressLeadingTrivia(node: Node): void { + addEmitFlagsRecursively(node, EmitFlags.NoLeadingComments, getFirstChild); +} + +/** + * Sets EmitFlags to suppress trailing trivia on the node. + * + * @internal @knipignore + */ +export function suppressTrailingTrivia(node: Node): void { + addEmitFlagsRecursively(node, EmitFlags.NoTrailingComments, getLastChild); +} + +function addEmitFlagsRecursively(node: Node, flag: EmitFlags, getChild: (n: Node) => Node | undefined) { + addEmitFlags(node, flag); + const child = getChild(node); + if (child) addEmitFlagsRecursively(child, flag, getChild); +} + +function getFirstChild(node: Node): Node | undefined { + return forEachChild(node, child => child); +} diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index b727b3cf008dd..231b18a105975 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -887,9 +887,10 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker( typeWriterOut, ); const printer = getPrinter(); + const sourceFile = symbol.valueDeclaration && getSourceFileOfNode(symbol.valueDeclaration); nodes.forEach((node, i) => { if (i > 0) writer.writeLine(); - printer.writeNode(EmitHint.Unspecified, node, /*sourceFile*/ undefined, writer); + printer.writeNode(EmitHint.Unspecified, node, sourceFile, writer); }); }); addRange(displayParts, expandedDisplayParts); diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 9cc0d12f34aa5..df0647ec41ea7 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1,6 +1,5 @@ import { __String, - addEmitFlags, addSyntheticLeadingComment, addSyntheticTrailingComment, AnyImportOrRequireStatement, @@ -51,7 +50,6 @@ import { DocumentSpan, DoStatement, ElementAccessExpression, - EmitFlags, emitModuleKindIsNonNodeESM, emptyArray, EndOfFileToken, @@ -101,7 +99,6 @@ import { getImpliedNodeFormatForFileWorker, getIndentString, getJSDocEnumTag, - getLastChild, getLineAndCharacterOfPosition, getLineStarts, getLocaleSpecificMessage, @@ -223,7 +220,6 @@ import { isNamespaceExport, isNamespaceImport, isNewExpression, - isNumericLiteral, isObjectBindingPattern, isObjectLiteralExpression, isOptionalChain, @@ -292,7 +288,6 @@ import { ModuleResolutionKind, ModuleSpecifierResolutionHost, moduleSpecifiers, - Mutable, NewExpression, NewLineKind, Node, @@ -332,9 +327,6 @@ import { ScriptTarget, SemicolonPreference, setConfigFileInOptions, - setOriginalNode, - setParentRecursive, - setTextRange, Signature, SignatureDeclaration, singleOrUndefined, @@ -387,7 +379,6 @@ import { unescapeLeadingUnderscores, UserPreferences, VariableDeclaration, - visitEachChild, VoidExpression, walkUpParenthesizedExpressions, WriterContextOut, @@ -3128,113 +3119,6 @@ export function getPrecedingNonSpaceCharacterPosition(text: string, position: nu return position + 1; } -/** - * Creates a deep, memberwise clone of a node with no source map location. - * - * WARNING: This is an expensive operation and is only intended to be used in refactorings - * and code fixes (because those are triggered by explicit user actions). - * - * @internal - */ -export function getSynthesizedDeepClone(node: T, includeTrivia = true): T { - const clone = node && getSynthesizedDeepCloneWorker(node); - if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone); - return setParentRecursive(clone, /*incremental*/ false); -} - -/** @internal */ -export function getSynthesizedDeepCloneWithReplacements( - node: T, - includeTrivia: boolean, - replaceNode: (node: Node) => Node | undefined, -): T { - let clone = replaceNode(node); - if (clone) { - setOriginalNode(clone, node); - } - else { - clone = getSynthesizedDeepCloneWorker(node as NonNullable, replaceNode); - } - - if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone); - return clone as T; -} - -function getSynthesizedDeepCloneWorker(node: T, replaceNode?: (node: Node) => Node | undefined): T { - const nodeClone: (n: T) => T = replaceNode - ? n => getSynthesizedDeepCloneWithReplacements(n, /*includeTrivia*/ true, replaceNode) - : getSynthesizedDeepClone; - const nodesClone: (ns: NodeArray | undefined) => NodeArray | undefined = replaceNode - ? ns => ns && getSynthesizedDeepClonesWithReplacements(ns, /*includeTrivia*/ true, replaceNode) - : ns => ns && getSynthesizedDeepClones(ns); - const visited = visitEachChild(node, nodeClone, /*context*/ undefined, nodesClone, nodeClone); - - if (visited === node) { - // This only happens for leaf nodes - internal nodes always see their children change. - const clone = isStringLiteral(node) ? setOriginalNode(factory.createStringLiteralFromNode(node), node) as Node as T : - isNumericLiteral(node) ? setOriginalNode(factory.createNumericLiteral(node.text, node.numericLiteralFlags), node) as Node as T : - factory.cloneNode(node); - return setTextRange(clone, node); - } - - // PERF: As an optimization, rather than calling factory.cloneNode, we'll update - // the new node created by visitEachChild with the extra changes factory.cloneNode - // would have made. - (visited as Mutable).parent = undefined!; - return visited; -} - -/** @internal */ -export function getSynthesizedDeepClones(nodes: NodeArray, includeTrivia?: boolean): NodeArray; -/** @internal */ -export function getSynthesizedDeepClones(nodes: NodeArray | undefined, includeTrivia?: boolean): NodeArray | undefined; -/** @internal */ -export function getSynthesizedDeepClones(nodes: NodeArray | undefined, includeTrivia = true): NodeArray | undefined { - if (nodes) { - const cloned = factory.createNodeArray(nodes.map(n => getSynthesizedDeepClone(n, includeTrivia)), nodes.hasTrailingComma); - setTextRange(cloned, nodes); - return cloned; - } - return nodes; -} - -/** @internal */ -export function getSynthesizedDeepClonesWithReplacements( - nodes: NodeArray, - includeTrivia: boolean, - replaceNode: (node: Node) => Node | undefined, -): NodeArray { - return factory.createNodeArray(nodes.map(n => getSynthesizedDeepCloneWithReplacements(n, includeTrivia, replaceNode)), nodes.hasTrailingComma); -} - -/** - * Sets EmitFlags to suppress leading and trailing trivia on the node. - * - * @internal - */ -export function suppressLeadingAndTrailingTrivia(node: Node): void { - suppressLeadingTrivia(node); - suppressTrailingTrivia(node); -} - -/** - * Sets EmitFlags to suppress leading trivia on the node. - * - * @internal - */ -export function suppressLeadingTrivia(node: Node): void { - addEmitFlagsRecursively(node, EmitFlags.NoLeadingComments, getFirstChild); -} - -/** - * Sets EmitFlags to suppress trailing trivia on the node. - * - * @internal @knipignore - */ -export function suppressTrailingTrivia(node: Node): void { - addEmitFlagsRecursively(node, EmitFlags.NoTrailingComments, getLastChild); -} - /** @internal */ export function copyComments(sourceNode: Node, targetNode: Node): void { const sourceFile = sourceNode.getSourceFile(); @@ -3257,16 +3141,6 @@ function hasLeadingLineBreak(node: Node, text: string) { return false; } -function addEmitFlagsRecursively(node: Node, flag: EmitFlags, getChild: (n: Node) => Node | undefined) { - addEmitFlags(node, flag); - const child = getChild(node); - if (child) addEmitFlagsRecursively(child, flag, getChild); -} - -function getFirstChild(node: Node): Node | undefined { - return node.forEachChild(child => child); -} - /** @internal */ export function getUniqueName(baseName: string, sourceFile: SourceFile): string { let nameText = baseName; diff --git a/tests/baselines/reference/quickinfoVerbosityToplevelTruncation.baseline b/tests/baselines/reference/quickinfoVerbosityToplevelTruncation.baseline index 4f74a41b136b5..c285564e95f35 100644 --- a/tests/baselines/reference/quickinfoVerbosityToplevelTruncation.baseline +++ b/tests/baselines/reference/quickinfoVerbosityToplevelTruncation.baseline @@ -64,9 +64,7 @@ // | property9: string; // | property10: number; // | property11: boolean; -// | property12: Date; -// | property13: string | number; -// | ... 6 more ... ; +// | ... 8 more ... ; // | property20: () => void; // | } // | (verbosity level: 1) @@ -1005,79 +1003,7 @@ "kind": "space" }, { - "text": "property12", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "Date", - "kind": "localName" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "property13", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "|", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "number", - "kind": "keyword" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "... 6 more ... ", + "text": "... 8 more ... ", "kind": "propertyName" }, {