Expandable hover (#61492)

This commit is contained in:
Gabriela Araujo Britto 2025-04-15 12:14:38 -07:00 committed by GitHub
parent eef7c14ef1
commit 069de743db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
70 changed files with 32173 additions and 289 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1168,6 +1168,7 @@ export const notImplementedResolver: EmitResolver = {
isImportRequiredByAugmentation: notImplemented,
isDefinitelyReferenceToGlobalSymbolObject: notImplemented,
createLateBoundIndexSignatures: notImplemented,
symbolToDeclarations: notImplemented,
};
const enum PipelinePhase {

View File

@ -5046,6 +5046,15 @@ export interface TypeCheckerHost extends ModuleSpecifierResolutionHost, SourceFi
typesPackageExists(packageName: string): boolean;
packageBundlesTypes(packageName: string): boolean;
isSourceFileDefaultLibrary(file: SourceFile): boolean;
}
/** @internal */
export interface WriterContextOut {
/** Whether increasing the expansion depth will cause us to expand more types. */
canIncreaseExpansionDepth: boolean;
truncated: boolean;
}
export interface TypeChecker {
@ -5134,6 +5143,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, out?: WriterContextOut): TypeParameterDeclaration | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
getSymbolAtLocation(node: Node): Symbol | undefined;
@ -5165,8 +5175,8 @@ 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 */ writeType(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags, 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;
@ -5435,6 +5445,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 */
@ -5881,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

View File

@ -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<T>(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<T extends Node | undefined>(node: T, includeTrivia = true): T {
const clone = node && getSynthesizedDeepCloneWorker(node);
if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone);
return setParentRecursive(clone, /*incremental*/ false);
}
/** @internal */
export function getSynthesizedDeepCloneWithReplacements<T extends Node>(
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<T>, replaceNode);
}
if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone);
return clone as T;
}
function getSynthesizedDeepCloneWorker<T extends Node>(node: T, replaceNode?: (node: Node) => Node | undefined): T {
const nodeClone: <T extends Node>(n: T) => T = replaceNode
? n => getSynthesizedDeepCloneWithReplacements(n, /*includeTrivia*/ true, replaceNode)
: getSynthesizedDeepClone;
const nodesClone: <T extends Node>(ns: NodeArray<T> | undefined) => NodeArray<T> | 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<T>).parent = undefined!;
return visited;
}
/** @internal */
export function getSynthesizedDeepClones<T extends Node>(nodes: NodeArray<T>, includeTrivia?: boolean): NodeArray<T>;
/** @internal */
export function getSynthesizedDeepClones<T extends Node>(nodes: NodeArray<T> | undefined, includeTrivia?: boolean): NodeArray<T> | undefined;
/** @internal */
export function getSynthesizedDeepClones<T extends Node>(nodes: NodeArray<T> | undefined, includeTrivia = true): NodeArray<T> | 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<T extends Node>(
nodes: NodeArray<T>,
includeTrivia: boolean,
replaceNode: (node: Node) => Node | undefined,
): NodeArray<T> {
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);
}

View File

@ -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.QuickInfoRequest>(protocol.CommandTypes.Quickinfo, args);
const response = this.processResponse<protocol.QuickInfoResponse>(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,
};
}

View File

@ -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));

View File

@ -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 {

View File

@ -2005,6 +2005,14 @@ export interface QuickInfoRequest extends FileLocationRequest {
arguments: FileLocationRequestArgs;
}
export interface QuickInfoRequestArgs extends FileLocationRequestArgs {
/**
* This controls how many levels of definitions will be expanded in the quick info response.
* The default value is 0.
*/
verbosityLevel?: number;
}
/**
* Body of QuickInfoResponse.
*/
@ -2044,6 +2052,11 @@ export interface QuickInfoResponseBody {
* JSDoc tags associated with symbol.
*/
tags: JSDocTagInfo[];
/**
* Whether the verbosity level can be increased for this quick info response.
*/
canIncreaseVerbosityLevel?: boolean;
}
/**

View File

@ -2392,10 +2392,10 @@ export class Session<TMessage = string> 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<TMessage = string> implements EventSender {
displayString,
documentation: useDisplayParts ? this.mapDisplayParts(quickInfo.documentation, project) : displayPartsToString(quickInfo.documentation),
tags: this.mapJSDocTagInfo(quickInfo.tags, project, useDisplayParts),
canIncreaseVerbosityLevel: quickInfo.canIncreaseVerbosityLevel,
};
}
else {

View File

@ -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,
};
}

View File

@ -107,6 +107,7 @@ import {
TypeParameter,
typeToDisplayParts,
VariableDeclaration,
WriterContextOut,
} from "./_namespaces/ts.js";
const symbolDisplayNodeBuilderFlags = NodeBuilderFlags.OmitParameterModifiers | NodeBuilderFlags.IgnoreErrors | NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope;
@ -253,9 +254,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[] = [];
@ -266,6 +278,8 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
let documentationFromAlias: SymbolDisplayPart[] | undefined;
let tagsFromAlias: JSDocTagInfo[] | undefined;
let hasMultipleSignatures = 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 };
@ -438,26 +452,32 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
}
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 <className>
pushSymbolKind(ScriptElementKind.localClassElement);
displayParts.push(spacePart());
}
else {
// Class declaration has name which is not local.
displayParts.push(keywordPart(SyntaxKind.ClassKeyword));
if (!tryExpandSymbol(symbol, semanticMeaning)) {
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);
}
if ((symbolFlags & SymbolFlags.Interface) && (semanticMeaning & SemanticMeaning.Type)) {
prefixNextMeaning();
displayParts.push(keywordPart(SyntaxKind.InterfaceKeyword));
displayParts.push(spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
if (!tryExpandSymbol(symbol, semanticMeaning)) {
displayParts.push(keywordPart(SyntaxKind.InterfaceKeyword));
displayParts.push(spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
}
}
if ((symbolFlags & SymbolFlags.TypeAlias) && (semanticMeaning & SemanticMeaning.Type)) {
prefixNextMeaning();
@ -468,25 +488,39 @@ 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();
if (some(symbol.declarations, d => isEnumDeclaration(d) && isEnumConst(d))) {
displayParts.push(keywordPart(SyntaxKind.ConstKeyword));
if (!tryExpandSymbol(symbol, semanticMeaning)) {
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);
}
if (symbolFlags & SymbolFlags.Module && !isThisExpression) {
prefixNextMeaning();
const declaration = getDeclarationOfKind<ModuleDeclaration>(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 (!tryExpandSymbol(symbol, semanticMeaning)) {
const declaration = getDeclarationOfKind<ModuleDeclaration>(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();
@ -568,11 +602,15 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
type,
semanticMeaning,
shouldUseAliasName ? symbol : resolvedSymbol,
verbosityLevel,
);
displayParts.push(...resolvedInfo.displayParts);
displayParts.push(lineBreakPart());
documentationFromAlias = resolvedInfo.documentation;
tagsFromAlias = resolvedInfo.tags;
if (typeWriterOut && resolvedInfo.canIncreaseVerbosityLevel) {
typeWriterOut.canIncreaseExpansionDepth = true;
}
}
else {
documentationFromAlias = resolvedSymbol.getContextualDocumentationComment(resolvedNode, typeChecker);
@ -656,13 +694,31 @@ 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,
typeWriterOut,
)!;
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;
@ -748,7 +804,14 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
tags = tagsFromAlias;
}
return { displayParts, documentation, symbolKind, tags: tags.length === 0 ? undefined : tags };
const canIncreaseVerbosityLevel = !typeWriterOut.truncated && typeWriterOut.canIncreaseExpansionDepth;
return {
displayParts,
documentation,
symbolKind,
tags: tags.length === 0 ? undefined : tags,
canIncreaseVerbosityLevel: verbosityLevel !== undefined ? canIncreaseVerbosityLevel : undefined,
};
function getPrinter() {
return createPrinterWithRemoveComments();
@ -774,9 +837,77 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
displayParts.push(spacePart());
}
function canExpandSymbol(symbol: Symbol, out: WriterContextOut | undefined): boolean {
if (verbosityLevel === undefined) {
return false;
}
const type = symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) ?
typeChecker.getDeclaredTypeOfSymbol(symbol) :
typeChecker.getTypeOfSymbolAtLocation(symbol, location);
if (!type || typeChecker.isLibType(type)) {
return false;
}
if (0 < verbosityLevel) {
return true;
}
if (out) {
out.canIncreaseExpansionDepth = true;
}
return false;
}
function semanticToSymbolMeaning(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;
}
/**
* 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 (canExpandSymbol(symbol, typeWriterOut)) {
const symbolMeaning = semanticToSymbolMeaning(meaning);
const expandedDisplayParts = mapToDisplayParts(writer => {
const nodes = typeChecker.getEmitResolver().symbolToDeclarations(
symbol,
symbolMeaning,
TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope,
verbosityLevel !== undefined ? verbosityLevel - 1 : undefined,
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, writer);
});
});
addRange(displayParts, expandedDisplayParts);
symbolWasExpanded = true;
return true;
}
return false;
}
function addFullSymbolName(symbolToDisplay: Symbol, enclosingDeclaration?: Node) {
let indexInfos;
if (alias && symbolToDisplay === symbol) {
symbolToDisplay = alias;
}
@ -842,7 +973,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
}
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));
@ -880,8 +1011,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) {

View File

@ -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;

View File

@ -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,9 +379,9 @@ import {
unescapeLeadingUnderscores,
UserPreferences,
VariableDeclaration,
visitEachChild,
VoidExpression,
walkUpParenthesizedExpressions,
WriterContextOut,
YieldExpression,
} from "./_namespaces/ts.js";
@ -3055,9 +3047,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);
});
}
@ -3069,10 +3061,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);
});
}
@ -3127,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<T extends Node | undefined>(node: T, includeTrivia = true): T {
const clone = node && getSynthesizedDeepCloneWorker(node);
if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone);
return setParentRecursive(clone, /*incremental*/ false);
}
/** @internal */
export function getSynthesizedDeepCloneWithReplacements<T extends Node>(
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<T>, replaceNode);
}
if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone);
return clone as T;
}
function getSynthesizedDeepCloneWorker<T extends Node>(node: T, replaceNode?: (node: Node) => Node | undefined): T {
const nodeClone: <T extends Node>(n: T) => T = replaceNode
? n => getSynthesizedDeepCloneWithReplacements(n, /*includeTrivia*/ true, replaceNode)
: getSynthesizedDeepClone;
const nodesClone: <T extends Node>(ns: NodeArray<T> | undefined) => NodeArray<T> | 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<T>).parent = undefined!;
return visited;
}
/** @internal */
export function getSynthesizedDeepClones<T extends Node>(nodes: NodeArray<T>, includeTrivia?: boolean): NodeArray<T>;
/** @internal */
export function getSynthesizedDeepClones<T extends Node>(nodes: NodeArray<T> | undefined, includeTrivia?: boolean): NodeArray<T> | undefined;
/** @internal */
export function getSynthesizedDeepClones<T extends Node>(nodes: NodeArray<T> | undefined, includeTrivia = true): NodeArray<T> | 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<T extends Node>(
nodes: NodeArray<T>,
includeTrivia: boolean,
replaceNode: (node: Node) => Node | undefined,
): NodeArray<T> {
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();
@ -3256,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;

View File

@ -1486,6 +1486,13 @@ declare namespace ts {
command: CommandTypes.Quickinfo;
arguments: FileLocationRequestArgs;
}
export interface QuickInfoRequestArgs extends FileLocationRequestArgs {
/**
* This controls how many levels of definitions will be expanded in the quick info response.
* The default value is 0.
*/
verbosityLevel?: number;
}
/**
* Body of QuickInfoResponse.
*/
@ -1519,6 +1526,10 @@ declare namespace ts {
* JSDoc tags associated with symbol.
*/
tags: JSDocTagInfo[];
/**
* Whether the verbosity level can be increased for this quick info response.
*/
canIncreaseVerbosityLevel?: boolean;
}
/**
* Quickinfo response message.
@ -10757,6 +10768,7 @@ declare namespace ts {
displayParts?: SymbolDisplayPart[];
documentation?: SymbolDisplayPart[];
tags?: JSDocTagInfo[];
canIncreaseVerbosityLevel?: boolean;
}
type RenameInfo = RenameInfoSuccess | RenameInfoFailure;
interface RenameInfoSuccess {

View File

@ -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
}
}
]

View File

@ -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
}
}
]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,385 @@
// === QuickInfo ===
=== /tests/cases/fourslash/quickinfoVerbosityConditionalType.ts ===
// interface Apple {
// color: string;
// weight: number;
// }
// type StrInt = string | bigint;
// type T1<T extends Apple | Apple[]> = T extends { color: string } ? "one apple" : StrInt;
// function f<T extends Apple | Apple[]>(x: T1<T>): 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<T>
// | (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
}
}
]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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
}
}
]

View File

@ -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<T extends T1>(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
}
}
]

View File

@ -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<T extends T2>(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<K extends keyof T2>(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
}
}
]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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
}
}
]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,512 @@
// === QuickInfo ===
=== /tests/cases/fourslash/quickinfoVerbosityLibType.ts ===
// interface Apple {
// color: string;
// size: number;
// }
// function f(): Promise<Apple> {
// return Promise.resolve({ color: "red", size: 5 });
// }
// const g = f;
// ^
// | ----------------------------------------------------------------------
// | const g: () => Promise<{
// | color: string;
// | size: number;
// | }>
// | (verbosity level: 1)
// | ----------------------------------------------------------------------
// ^
// | ----------------------------------------------------------------------
// | const g: () => Promise<Apple>
// | (verbosity level: 0)
// | ----------------------------------------------------------------------
// const u: Map<string, Apple> = new Map;
// ^
// | ----------------------------------------------------------------------
// | const u: Map<string, {
// | color: string;
// | size: number;
// | }>
// | (verbosity level: 1)
// | ----------------------------------------------------------------------
// ^
// | ----------------------------------------------------------------------
// | const u: Map<string, Apple>
// | (verbosity level: 0)
// | ----------------------------------------------------------------------
// type Foo<T> = Promise<T>;
// ^^^^^^^
// | ----------------------------------------------------------------------
// | interface Promise<T>
// | Represents the completion of an asynchronous operation
// | (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
}
},
{
"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
}
}
]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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
}
}
]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,405 @@
// === 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;
// | ... 11 more ...;
// | someLongMethodName2(a: FooType, b: BarType): Sym;
// | }
// | (verbosity level: 1)
// | ----------------------------------------------------------------------
// ^^^^
// | ----------------------------------------------------------------------
// | const obj1: LotsOfProps
// | (verbosity level: 0)
// | ----------------------------------------------------------------------
[
{
"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": "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": "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": "... 11 more ...",
"kind": "propertyName"
},
{
"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": false,
"verbosityLevel": 1
}
}
]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,771 @@
// === QuickInfo ===
=== /tests/cases/fourslash/quickinfoVerbosityTypeParameter.ts ===
// type Str = string | {};
// type FooType = Str | number;
// function fn<T extends FooType>(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: <T extends FooType>(x: T) => void = fn;
// ^
// | ----------------------------------------------------------------------
// | const y: <T extends number | (string | {})>(x: T) => void
// | (verbosity level: 2)
// | ----------------------------------------------------------------------
// ^
// | ----------------------------------------------------------------------
// | const y: <T extends number | Str>(x: T) => void
// | (verbosity level: 1)
// | ----------------------------------------------------------------------
// ^
// | ----------------------------------------------------------------------
// | const y: <T extends FooType>(x: T) => void
// | (verbosity level: 0)
// | ----------------------------------------------------------------------
// type MixinCtor<A> = new () => A & { constructor: MixinCtor<A> };
// ^
// | ----------------------------------------------------------------------
// | (type parameter) A in type MixinCtor<A>
// | (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
}
},
{
"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"
},
{
"text": "<",
"kind": "punctuation"
},
{
"text": "A",
"kind": "typeParameterName"
},
{
"text": ">",
"kind": "punctuation"
}
],
"documentation": [],
"canIncreaseVerbosityLevel": false,
"verbosityLevel": 0
}
}
]

View File

@ -0,0 +1,355 @@
// === 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;
// | }
// | (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": "punctuation"
}
],
"documentation": [],
"canIncreaseVerbosityLevel": true,
"verbosityLevel": 1
}
}
]

View File

@ -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
}
}

View File

@ -361,7 +361,7 @@ declare namespace FourSlashInterface {
baselineSyntacticAndSemanticDiagnostics(): void;
getEmitOutput(expectedOutputFiles: ReadonlyArray<string>): 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;

View File

@ -0,0 +1,10 @@
/// <reference path='fourslash.ts'/>
//// 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] });

View File

@ -0,0 +1,11 @@
/// <reference path='fourslash.ts'/>
//// 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], });

View File

@ -0,0 +1,46 @@
/// <reference path='fourslash.ts'/>
// @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<OptionProp, {}> {
//// render() {
//// return <div>Hello</div>;
//// }
//// }
//// const obj1: OptionProp = {
//// propx: 2
//// }
//// let y1 = <Opt/*2*/ propx={2} />;
// @Filename: a.ts
//// interface Foo/*3*/<T extends Date> {
//// prop: T
//// }
//// class Bar/*4*/<T extends Date> implements Foo<T> {
//// 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, 2],
"5": [0, 1, 2],
});

View File

@ -0,0 +1,72 @@
/// <reference path='fourslash.ts'/>
// 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/*B*/ {
//// 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<B extends string> {
//// 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<B extends string> {
//// 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],
f4: [0, 1],
n1: [0, 1],
k1: [0, 1],
B: [0, 1],
});

View File

@ -0,0 +1,60 @@
/// <reference path='fourslash.ts'/>
//// interface Apple {
//// color: string;
//// }
//// class Foo/*1*/<T> {
//// 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<string>;
//// const a/*3*/ = Foo;
//// const c/*4*/ = Foo<string>;
//// [1].forEach(class/*5*/ <T> {
//// 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<number>;
//// @random()
//// abstract class Animal/*7*/ {
//// name!: string;
//// abstract makeSound(): void;
//// }
//// class Dog/*8*/ {
//// what(this: this, that: Dog) { }
//// #bones: string[];
//// }
//// const d/*9*/ = new Dog();
verify.baselineQuickInfo({
1: [0, 1, 2],
2: [0, 1, 2],
3: [0, 1],
4: [0],
5: [0, 1, 2],
6: [0],
7: [0, 1],
8: [0, 1],
9: [0, 1],
});

View File

@ -0,0 +1,13 @@
/// <reference path='fourslash.ts'/>
//// interface Apple {
//// color: string;
//// weight: number;
//// }
//// type StrInt = string | bigint;
//// type T1<T extends Apple | Apple[]> = T extends { color: string } ? "one apple" : StrInt;
//// function f<T extends Apple | Apple[]>(x: T1<T>): void {
//// x/*x*/;
//// }
verify.baselineQuickInfo({ "x": [0, 1, 2] });

View File

@ -0,0 +1,40 @@
/// <reference path='fourslash.ts'/>
// @filename: a.ts
//// export {};
//// enum Color/*c*/ {
//// Red,
//// Green,
//// Blue,
//// }
//// const x/*x*/: Color = Color.Red;
//// const enum Direction/*d*/ {
//// Up,
//// Down,
//// }
//// const y/*y*/: Direction = Direction.Up;
//// enum Flags/*f*/ {
//// None = 0,
//// IsDirectory = 1 << 0,
//// IsFile = 1 << 1,
//// 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],
});

View File

@ -0,0 +1,33 @@
/// <reference path='fourslash.ts'/>
//// 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;
//// type SomeType = {
//// prop1: string;
//// }
//// function someFun(a: SomeType): SomeType {
//// return a;
//// }
//// someFun/*s*/.what = 'what';
verify.baselineQuickInfo({
"o": [0, 1, 2],
"f": [0, 1],
"s": [0, 1]
});

View File

@ -0,0 +1,40 @@
/// <reference path='fourslash.ts'/>
// @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";
// @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],
});

View File

@ -0,0 +1,13 @@
/// <reference path='fourslash.ts'/>
//// 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] });

View File

@ -0,0 +1,20 @@
/// <reference path='fourslash.ts'/>
//// interface T1 {
//// banana: string;
//// grape: number;
//// apple: boolean;
//// }
//// const x1/*x1*/: keyof T1 = 'banana';
//// const x2/*x2*/: keyof T1 & ("grape" | "apple") = 'grape';
//// function fn1<T extends T1>(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] });

View File

@ -0,0 +1,20 @@
/// <reference path='fourslash.ts'/>
//// interface T2 {
//// "string key": string;
//// "number key": number;
//// "any key": string | number | symbol;
//// }
//// type K2 = "string key" | "any key";
//// function fn2<T extends T2>(obj: T, key: keyof T) {
//// const value/*v1*/: T[K2] = undefined as any;
//// }
//// function fn3<K extends keyof T2>(obj: T2, key: K) {
//// const value/*v2*/: T2[K] = undefined as any;;
//// }
verify.baselineQuickInfo({ "v1": [0, 1], "v2": [0, 1] });

View File

@ -0,0 +1,79 @@
/// <reference path='fourslash.ts'/>
// 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<B> {
//// bar(b: B): string;
//// }
//// interface FooParam {
//// param: "a" | "c";
//// }
//// interface Foo extends Bar<FooParam> {
//// a: "a" | "c";
//// foo: (a: FooParam) => number;
//// }
//// const f/*f4*/: Foo = { a: "a", bar: () => "b", foo: () => 1 };
//// const b/*b1*/: Bar<number> = { bar: () => "" };
//// }
// alias + interface
//// {
//// interface Foo<A> {
//// a: A;
//// }
//// type Alias = Foo<string>;
//// 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],
});

View File

@ -0,0 +1,66 @@
/// <reference path='fourslash.ts'/>
//// {
//// 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*/<B> {
//// bar(b: B): string;
//// }
//// interface FooParam {
//// param: "a" | "c";
//// }
//// interface Foo/*5*/ extends Bar<FooParam> {
//// 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],
});

View File

@ -0,0 +1,22 @@
/// <reference path='fourslash.ts'/>
//// {
//// 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 });

View File

@ -0,0 +1,46 @@
/// <reference path='fourslash.ts'/>
// @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],
});

View File

@ -0,0 +1,21 @@
/// <reference path='fourslash.ts'/>
//// interface Apple {
//// color: string;
//// size: number;
//// }
//// function f(): Promise<Apple> {
//// return Promise.resolve({ color: "red", size: 5 });
//// }
//// const g/*g*/ = f;
//// const u/*u*/: Map<string, Apple> = new Map;
//// type Foo<T> = Promise/*p*/<T>;
verify.baselineQuickInfo({
"g": [0, 1],
"u": [0, 1],
"p": [0],
});

View File

@ -0,0 +1,20 @@
/// <reference path='fourslash.ts'/>
//// type Apple = boolean | number;
//// type Orange = string | boolean;
//// type F<T> = {
//// [K in keyof T as T[K] extends Apple ? never : K]: T[K];
//// }
//// type Bar = {
//// banana: string;
//// apple: boolean;
//// }
//// const x/*x*/: F/*F*/<Bar> = { banana: 'hello' };
//// const y/*y*/: { [K in keyof Bar]?: Bar[K] } = { banana: 'hello' };
//// type G<T> = {
//// [K in keyof T]: T[K] & Apple
//// };
//// const z: G/*G*/<Bar> = { banana: 'hello', apple: true };
verify.baselineQuickInfo({ "x": [0, 1], "y": [0], "F": [0, 1], "G": [0, 1] });

View File

@ -0,0 +1,64 @@
/// <reference path='fourslash.ts'/>
// @filename: /1.ts
//// export {};
//// class Foo<T> {
//// 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<T> {
//// y!: T;
//// }
//// namespace Two/*3*/ {
//// export const f = new Foo<number>();
//// }
// @filename: /5.ts
//// namespace Two {
//// export const g = new Foo<string>();
//// }
// @filename: /6.ts
//// namespace OnlyLocal/*4*/ {
//// 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],
})

View File

@ -0,0 +1,13 @@
/// <reference path='fourslash.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/*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] });

View File

@ -0,0 +1,34 @@
/// <reference path='fourslash.ts'/>
//// type Node/*N*/<T> = {
//// value: T;
//// left: Node<T> | undefined;
//// right: Node<T> | undefined;
//// }
//// const n/*n*/: Node<number> = {
//// value: 1,
//// left: undefined,
//// right: undefined,
//// }
//// interface Orange {
//// name: string;
//// }
//// type TreeNode/*t*/<T> = {
//// value: T;
//// left: TreeNode<T> | undefined;
//// right: TreeNode<T> | undefined;
//// orange?: Orange;
//// }
//// const m/*m*/: TreeNode<number> = {
//// value: 1,
//// left: undefined,
//// right: undefined,
//// orange: { name: "orange" },
//// }
verify.baselineQuickInfo({
"N": [0],
"n": [0, 1],
"t": [0, 1],
"m": [0, 1, 2],
});

View File

@ -0,0 +1,57 @@
/// <reference path='fourslash.ts'/>
//// 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],
})

View File

@ -0,0 +1,31 @@
/// <reference path='fourslash.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/*o1*/: LotsOfProps = undefined as any as LotsOfProps;
verify.baselineQuickInfo({ "o1": [0, 1], });

View File

@ -0,0 +1,28 @@
/// <reference path='fourslash.ts'/>
//// 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],
});

View File

@ -0,0 +1,16 @@
/// <reference path='fourslash.ts'/>
//// type Str = string | {};
//// type FooType = Str | number;
//// function fn<T extends FooType>(x: T) {
//// x/*x*/;
//// }
//// const y/*y*/: <T extends FooType>(x: T) => void = fn;
//// type MixinCtor<A> = new () => A/*a*/ & { constructor: MixinCtor<A> };
verify.baselineQuickInfo({
"x": [0, 1, 2],
"y": [0, 1, 2],
"a": [0],
});

View File

@ -0,0 +1,23 @@
/// <reference path='fourslash.ts'/>
//// 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],
});

View File

@ -0,0 +1,6 @@
/// <reference path="../fourslash.ts"/>
//// type FooType = string | number
//// const foo/*a*/: FooType = 1
verify.baselineQuickInfo({ "a": [0, 1] });