This commit is contained in:
Gabriela Araujo Britto 2024-11-05 16:41:13 -08:00 коммит произвёл GitHub
Родитель 9d7e087022
Коммит 80eeb4ec8d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
30 изменённых файлов: 8169 добавлений и 57 удалений

Просмотреть файл

@ -1130,6 +1130,7 @@ import {
WhileStatement,
WideningContext,
WithStatement,
WriterContextOut,
YieldExpression,
} from "./_namespaces/ts.js";
import * as moduleSpecifiers from "./_namespaces/ts.moduleSpecifiers.js";
@ -1717,8 +1718,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
writeSignature: (signature, enclosingDeclaration, flags, kind, writer) => {
return signatureToString(signature, getParseTreeNode(enclosingDeclaration), flags, kind, writer);
},
writeType: (type, enclosingDeclaration, flags, writer) => {
return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer);
writeType: (type, enclosingDeclaration, flags, writer, verbosityLevel, out) => {
return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer, verbosityLevel, out);
},
writeSymbol: (symbol, enclosingDeclaration, meaning, flags, writer) => {
return symbolToString(symbol, getParseTreeNode(enclosingDeclaration), meaning, flags, writer);
@ -6035,9 +6036,24 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
}
function typeToString(type: Type, enclosingDeclaration?: Node, flags: TypeFormatFlags = TypeFormatFlags.AllowUniqueESSymbolType | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, writer: EmitTextWriter = createTextWriter("")): string {
const noTruncation = compilerOptions.noErrorTruncation || flags & TypeFormatFlags.NoTruncation;
const typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors | (noTruncation ? NodeBuilderFlags.NoTruncation : NodeBuilderFlags.None), /*internalFlags*/ undefined);
function typeToString(
type: Type,
enclosingDeclaration?: Node,
flags: TypeFormatFlags = TypeFormatFlags.AllowUniqueESSymbolType | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope,
writer: EmitTextWriter = createTextWriter(""),
verbosityLevel?: number,
out?: WriterContextOut,
): string {
const noTruncation = compilerOptions.noErrorTruncation || flags & TypeFormatFlags.NoTruncation || verbosityLevel !== undefined;
const typeNode = nodeBuilder.typeToTypeNode(
type,
enclosingDeclaration,
toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors | (noTruncation ? NodeBuilderFlags.NoTruncation : 0),
/*internalFlags*/ undefined,
/*tracker*/ undefined,
verbosityLevel,
out,
);
if (typeNode === undefined) return Debug.fail("should always get typenode");
// The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`.
// Otherwise, we always strip comments out.
@ -6255,20 +6271,20 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
};
return {
syntacticBuilderResolver,
typeToTypeNode: (type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => typeToTypeNodeHelper(type, context)),
typePredicateToTypePredicateNode: (typePredicate: TypePredicate, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
serializeTypeForExpression: (expr: Expression, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)),
serializeTypeForDeclaration: (declaration: HasInferredType, symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)),
serializeReturnTypeForSignature: (signature: SignatureDeclaration, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)),
indexInfoToIndexSignatureDeclaration: (indexInfo: IndexInfo, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => indexInfoToIndexSignatureDeclarationHelper(indexInfo, context, /*typeNode*/ undefined)),
signatureToSignatureDeclaration: (signature: Signature, kind: SignatureDeclaration["kind"], enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => signatureToSignatureDeclarationHelper(signature, kind, context)),
symbolToEntityName: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false)),
symbolToExpression: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => symbolToExpression(symbol, context, meaning)),
symbolToTypeParameterDeclarations: (symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => typeParametersToTypeParameterDeclarations(symbol, context)),
symbolToParameterDeclaration: (symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => symbolToParameterDeclaration(symbol, context)),
typeParameterToDeclaration: (parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => typeParameterToDeclaration(parameter, context)),
symbolTableToDeclarationStatements: (symbolTable: SymbolTable, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => symbolTableToDeclarationStatements(symbolTable, context)),
symbolToNode: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, context => symbolToNode(symbol, context, meaning)),
typeToTypeNode: (type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number, out?: { couldUnfoldMore: boolean; }) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, context => typeToTypeNodeHelper(type, context), out),
typePredicateToTypePredicateNode: (typePredicate: TypePredicate, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
serializeTypeForDeclaration: (declaration: HasInferredType, symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)),
serializeReturnTypeForSignature: (signature: SignatureDeclaration, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)),
serializeTypeForExpression: (expr: Expression, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)),
indexInfoToIndexSignatureDeclaration: (indexInfo: IndexInfo, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => indexInfoToIndexSignatureDeclarationHelper(indexInfo, context, /*typeNode*/ undefined)),
signatureToSignatureDeclaration: (signature: Signature, kind: SignatureDeclaration["kind"], enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => signatureToSignatureDeclarationHelper(signature, kind, context)),
symbolToEntityName: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false)),
symbolToExpression: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolToExpression(symbol, context, meaning)),
symbolToTypeParameterDeclarations: (symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => typeParametersToTypeParameterDeclarations(symbol, context)),
symbolToParameterDeclaration: (symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolToParameterDeclaration(symbol, context)),
typeParameterToDeclaration: (parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, context => typeParameterToDeclaration(parameter, context)),
symbolTableToDeclarationStatements: (symbolTable: SymbolTable, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolTableToDeclarationStatements(symbolTable, context)),
symbolToNode: (symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, /*verbosityLevel*/ undefined, context => symbolToNode(symbol, context, meaning)),
};
function getTypeFromTypeNode(context: NodeBuilderContext, node: TypeNode, noMappedTypes?: false): Type;
@ -6328,7 +6344,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return symbolToExpression(symbol, context, meaning);
}
function withContext<T>(enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags: InternalNodeBuilderFlags | undefined, tracker: SymbolTracker | undefined, cb: (context: NodeBuilderContext) => T): T | undefined {
function withContext<T>(
enclosingDeclaration: Node | undefined,
flags: NodeBuilderFlags | undefined,
internalFlags: InternalNodeBuilderFlags | undefined,
tracker: SymbolTracker | undefined,
verbosityLevel: number | undefined,
cb: (context: NodeBuilderContext) => T,
out?: WriterContextOut,
): T | undefined {
const moduleResolverHost = tracker?.trackSymbol ? tracker.moduleResolverHost :
(internalFlags || InternalNodeBuilderFlags.None) & InternalNodeBuilderFlags.DoNotIncludeSymbolChain ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) :
undefined;
@ -6338,6 +6362,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
flags: flags || NodeBuilderFlags.None,
internalFlags: internalFlags || InternalNodeBuilderFlags.None,
tracker: undefined!,
unfoldDepth: verbosityLevel ?? -1,
encounteredError: false,
suppressReportInferenceFallback: false,
reportedDiagnostic: false,
@ -6360,12 +6385,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
typeParameterNamesByTextNextNameCount: undefined,
enclosingSymbolTypes: new Map(),
mapper: undefined,
depth: 0,
couldUnfoldMore: false,
};
context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
const resultingNode = cb(context);
if (context.truncating && context.flags & NodeBuilderFlags.NoTruncation) {
context.tracker.reportTruncationError();
}
if (out) {
out.couldUnfoldMore = context.couldUnfoldMore;
}
return context.encounteredError ? undefined : resultingNode;
}
@ -6386,12 +6416,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
function saveRestoreFlags(context: NodeBuilderContext) {
const flags = context.flags;
const internalFlags = context.internalFlags;
const depth = context.depth;
return restore;
function restore() {
context.flags = flags;
context.internalFlags = internalFlags;
context.depth = depth;
}
}
@ -6400,6 +6432,25 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return context.truncating = context.approximateLength > ((context.flags & NodeBuilderFlags.NoTruncation) ? noTruncationMaximumTruncationLength : defaultMaximumTruncationLength);
}
function couldUnfoldType(type: Type, context: NodeBuilderContext): boolean {
if (context.visitedTypes?.has(type.id)) {
return false;
}
return context.depth < context.unfoldDepth || context.depth === context.unfoldDepth && !context.couldUnfoldMore;
}
// Determines if a type can be unfolded, based on how many layers of type aliases we're allowed to unfold.
function canUnfoldType(type: Type, context: NodeBuilderContext): boolean {
if (context.visitedTypes?.has(type.id)) {
return false;
}
const result = context.depth < context.unfoldDepth;
if (!result) {
context.couldUnfoldMore = true;
}
return result;
}
function typeToTypeNodeHelper(type: Type, context: NodeBuilderContext): TypeNode {
const restoreFlags = saveRestoreFlags(context);
const typeNode = typeToTypeNodeWorker(type, context);
@ -6549,18 +6600,25 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
if (!inTypeAlias && type.aliasSymbol && (context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & SymbolFlags.Class)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes);
if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
return factory.createArrayTypeNode(typeArgumentNodes![0]);
if (!canUnfoldType(type, context)) {
const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & SymbolFlags.Class)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes);
if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
return factory.createArrayTypeNode(typeArgumentNodes![0]);
}
return symbolToTypeNode(type.aliasSymbol, context, SymbolFlags.Type, typeArgumentNodes);
}
return symbolToTypeNode(type.aliasSymbol, context, SymbolFlags.Type, typeArgumentNodes);
context.depth += 1;
}
const objectFlags = getObjectFlags(type);
if (objectFlags & ObjectFlags.Reference) {
Debug.assert(!!(type.flags & TypeFlags.Object));
if (canUnfoldType(type, context)) {
context.depth += 1;
return createAnonymousTypeNode(type as TypeReference, /*forceClassExpansion*/ true);
}
return (type as TypeReference).node ? visitAndTransformType(type as TypeReference, typeReferenceToTypeNode) : typeReferenceToTypeNode(type as TypeReference);
}
if (type.flags & TypeFlags.TypeParameter || objectFlags & ObjectFlags.ClassOrInterface) {
@ -6589,6 +6647,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
context.approximateLength += idText(name).length;
return factory.createTypeReferenceNode(factory.createIdentifier(idText(name)), /*typeArguments*/ undefined);
}
if (objectFlags & ObjectFlags.ClassOrInterface && canUnfoldType(type, context)) {
context.depth += 1;
return createAnonymousTypeNode(type as InterfaceType, /*forceClassExpansion*/ true);
}
// Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter.
if (type.symbol) {
return symbolToTypeNode(type.symbol, context, SymbolFlags.Type);
@ -6796,7 +6858,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return result;
}
function createAnonymousTypeNode(type: ObjectType): TypeNode {
function createAnonymousTypeNode(type: ObjectType, forceClassExpansion = false): TypeNode {
const typeId = type.id;
const symbol = type.symbol;
if (symbol) {
@ -6830,10 +6892,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// Always use 'typeof T' for type of class, enum, and module objects
else if (
symbol.flags & SymbolFlags.Class
&& !forceClassExpansion
&& !getBaseTypeVariableOfClass(symbol)
&& !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & NodeBuilderFlags.WriteClassExpressionAsTypeLiteral && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== SymbolAccessibility.Accessible)) ||
symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) ||
shouldWriteTypeOfFunctionSymbol()
&& !(symbol.valueDeclaration
&& isClassLike(symbol.valueDeclaration)
&& context.flags & NodeBuilderFlags.WriteClassExpressionAsTypeLiteral
&& (!isClassDeclaration(symbol.valueDeclaration)
|| isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== SymbolAccessibility.Accessible))
|| symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule)
|| shouldWriteTypeOfFunctionSymbol()
) {
return symbolToTypeNode(symbol, context, isInstanceType);
}
@ -6886,7 +6953,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
context.symbolDepth = new Map();
}
const links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
// Don't rely on type cache if we're unfolding a type, because we need to compute `couldUnfoldMore`.
const links = context.unfoldDepth >= 0 ? undefined : context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
const key = `${getTypeId(type)}|${context.flags}|${context.internalFlags}`;
if (links) {
links.serializedTypes ||= new Map();
@ -7881,7 +7949,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
function typeToTypeNodeHelperWithPossibleReusableTypeNode(type: Type, typeNode: TypeNode | undefined, context: NodeBuilderContext) {
return typeNode && getTypeFromTypeNode(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode)
return !couldUnfoldType(type, context) && typeNode && getTypeFromTypeNode(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode)
|| typeToTypeNodeHelper(type, context);
}
@ -8613,7 +8681,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
let result;
const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration);
const decl = declaration ?? symbol.valueDeclaration ?? getDeclarationWithTypeAnnotation(symbol) ?? symbol.declarations?.[0];
if (decl) {
if (!couldUnfoldType(type, context) && decl) {
if (isAccessor(decl)) {
result = syntacticNodeBuilder.serializeTypeOfAccessor(decl, symbol, context);
}
@ -52656,6 +52724,7 @@ interface NodeBuilderContext extends SyntacticTypeNodeBuilderContext {
flags: NodeBuilderFlags;
internalFlags: InternalNodeBuilderFlags;
tracker: SymbolTrackerImpl;
readonly unfoldDepth: number;
// State
encounteredError: boolean;
@ -52679,7 +52748,11 @@ interface NodeBuilderContext extends SyntacticTypeNodeBuilderContext {
reverseMappedStack: ReverseMappedSymbol[] | undefined;
bundled: boolean;
mapper: TypeMapper | undefined;
depth: number; // How many levels of nested type aliases we have unfolded so far
suppressReportInferenceFallback: boolean;
// Output
couldUnfoldMore: boolean; // Whether we found a type alias that we could unfold but didn't
}
class SymbolTrackerImpl implements SymbolTracker {

Просмотреть файл

@ -5042,6 +5042,11 @@ export interface TypeCheckerHost extends ModuleSpecifierResolutionHost, SourceFi
packageBundlesTypes(packageName: string): boolean;
}
/** @internal */
export interface WriterContextOut {
couldUnfoldMore: boolean;
}
export interface TypeChecker {
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
getTypeOfSymbol(symbol: Symbol): Type;
@ -5128,6 +5133,7 @@ export interface TypeChecker {
symbolToParameterDeclaration(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): ParameterDeclaration | undefined;
/** Note that the resulting nodes cannot be checked. */
typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeParameterDeclaration | undefined;
/** @internal */ typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags?: InternalNodeBuilderFlags, tracker?: SymbolTracker, verbosityLevel?: number): TypeParameterDeclaration | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
getSymbolAtLocation(node: Node): Symbol | undefined;
@ -5160,7 +5166,7 @@ export interface TypeChecker {
typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
/** @internal */ writeSignature(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind, writer?: EmitTextWriter): string;
/** @internal */ writeType(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string;
/** @internal */ writeType(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter, verbosityLevel?: number, out?: WriterContextOut): string;
/** @internal */ writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags, writer?: EmitTextWriter): string;
/** @internal */ writeTypePredicate(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string;

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -453,8 +453,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 {

Просмотреть файл

@ -2004,6 +2004,11 @@ export interface QuickInfoRequest extends FileLocationRequest {
arguments: FileLocationRequestArgs;
}
export interface QuickInfoRequestArgs extends FileLocationRequestArgs {
/** TODO */
verbosityLevel?: number;
}
/**
* Body of QuickInfoResponse.
*/
@ -2043,6 +2048,11 @@ export interface QuickInfoResponseBody {
* JSDoc tags associated with symbol.
*/
tags: JSDocTagInfo[];
/**
* TODO
*/
canIncreaseVerbosityLevel?: boolean;
}
/**

Просмотреть файл

@ -2394,10 +2394,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;
}
@ -2413,6 +2413,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 {

Просмотреть файл

@ -2277,7 +2277,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);
@ -2296,13 +2296,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),
@ -2310,6 +2323,7 @@ export function createLanguageService(
displayParts,
documentation,
tags,
canIncreaseVerbosityLevel,
};
}

Просмотреть файл

@ -108,6 +108,7 @@ import {
TypeParameter,
typeToDisplayParts,
VariableDeclaration,
WriterContextOut,
} from "./_namespaces/ts.js";
const symbolDisplayNodeBuilderFlags = NodeBuilderFlags.OmitParameterModifiers | NodeBuilderFlags.IgnoreErrors | NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope;
@ -254,9 +255,20 @@ export interface SymbolDisplayPartsDocumentationAndSymbolKind {
documentation: SymbolDisplayPart[];
symbolKind: ScriptElementKind;
tags: JSDocTagInfo[] | undefined;
canIncreaseVerbosityLevel?: boolean;
}
function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: TypeChecker, symbol: Symbol, sourceFile: SourceFile, enclosingDeclaration: Node | undefined, location: Node, type: Type | undefined, semanticMeaning: SemanticMeaning, alias?: Symbol): SymbolDisplayPartsDocumentationAndSymbolKind {
function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
typeChecker: TypeChecker,
symbol: Symbol,
sourceFile: SourceFile,
enclosingDeclaration: Node | undefined,
location: Node,
type: Type | undefined,
semanticMeaning: SemanticMeaning,
alias?: Symbol,
verbosityLevel?: number,
): SymbolDisplayPartsDocumentationAndSymbolKind {
const displayParts: SymbolDisplayPart[] = [];
let documentation: SymbolDisplayPart[] = [];
let tags: JSDocTagInfo[] = [];
@ -267,6 +279,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
let documentationFromAlias: SymbolDisplayPart[] | undefined;
let tagsFromAlias: JSDocTagInfo[] | undefined;
let hasMultipleSignatures = false;
const typeWriterOut: WriterContextOut | undefined = verbosityLevel !== undefined ? { couldUnfoldMore: false } : undefined;
if (location.kind === SyntaxKind.ThisKeyword && !isThisExpression) {
return { displayParts: [keywordPart(SyntaxKind.ThisKeyword)], documentation: [], symbolKind: ScriptElementKind.primitiveType, tags: undefined };
@ -462,7 +475,17 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
displayParts.push(spacePart());
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
displayParts.push(spacePart());
addRange(displayParts, typeToDisplayParts(typeChecker, location.parent && isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, TypeFormatFlags.InTypeAlias));
addRange(
displayParts,
typeToDisplayParts(
typeChecker,
location.parent && isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol),
enclosingDeclaration,
TypeFormatFlags.InTypeAlias,
verbosityLevel,
typeWriterOut,
),
);
}
if (symbolFlags & SymbolFlags.Enum) {
prefixNextMeaning();
@ -650,13 +673,30 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
// If the type is type parameter, format it specially
if (type.symbol && type.symbol.flags & SymbolFlags.TypeParameter && symbolKind !== ScriptElementKind.indexSignatureElement) {
const typeParameterParts = mapToDisplayParts(writer => {
const param = typeChecker.typeParameterToDeclaration(type as TypeParameter, enclosingDeclaration, symbolDisplayNodeBuilderFlags)!;
const param = typeChecker.typeParameterToDeclaration(
type as TypeParameter,
enclosingDeclaration,
symbolDisplayNodeBuilderFlags,
/*internalFlags*/ undefined,
/*tracker*/ undefined,
verbosityLevel,
)!;
getPrinter().writeNode(EmitHint.Unspecified, param, getSourceFileOfNode(getParseTreeNode(enclosingDeclaration)), writer);
});
addRange(displayParts, typeParameterParts);
}
else {
addRange(displayParts, typeToDisplayParts(typeChecker, type, enclosingDeclaration));
addRange(
displayParts,
typeToDisplayParts(
typeChecker,
type,
enclosingDeclaration,
/*flags*/ undefined,
verbosityLevel,
typeWriterOut,
),
);
}
if (isTransientSymbol(symbol) && symbol.links.target && isTransientSymbol(symbol.links.target) && symbol.links.target.links.tupleLabelDeclaration) {
const labelDecl = symbol.links.target.links.tupleLabelDeclaration;
@ -742,7 +782,13 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
tags = tagsFromAlias;
}
return { displayParts, documentation, symbolKind, tags: tags.length === 0 ? undefined : tags };
return {
displayParts,
documentation,
symbolKind,
tags: tags.length === 0 ? undefined : tags,
canIncreaseVerbosityLevel: typeWriterOut?.couldUnfoldMore,
};
function getPrinter() {
return createPrinterWithRemoveComments();
@ -874,8 +920,9 @@ export function getSymbolDisplayPartsDocumentationAndSymbolKind(
location: Node,
semanticMeaning: SemanticMeaning = getMeaningFromLocation(location),
alias?: Symbol,
verbosityLevel?: number,
): SymbolDisplayPartsDocumentationAndSymbolKind {
return getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, /*type*/ undefined, semanticMeaning, alias);
return getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, /*type*/ undefined, semanticMeaning, alias, verbosityLevel);
}
function isLocalVariableOrFunction(symbol: Symbol) {

Просмотреть файл

@ -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;
@ -1325,6 +1327,7 @@ export interface QuickInfo {
displayParts?: SymbolDisplayPart[];
documentation?: SymbolDisplayPart[];
tags?: JSDocTagInfo[];
canIncreaseVerbosityLevel?: boolean;
}
export type RenameInfo = RenameInfoSuccess | RenameInfoFailure;

Просмотреть файл

@ -390,6 +390,7 @@ import {
visitEachChild,
VoidExpression,
walkUpParenthesizedExpressions,
WriterContextOut,
YieldExpression,
} from "./_namespaces/ts.js";
@ -3055,9 +3056,9 @@ export function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbol
}
/** @internal */
export function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags: TypeFormatFlags = TypeFormatFlags.None): SymbolDisplayPart[] {
export function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags: TypeFormatFlags = TypeFormatFlags.None, verbosityLevel?: number, out?: WriterContextOut): SymbolDisplayPart[] {
return mapToDisplayParts(writer => {
typechecker.writeType(type, enclosingDeclaration, flags | TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, writer);
typechecker.writeType(type, enclosingDeclaration, flags | TypeFormatFlags.MultilineObjectLiterals | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, writer, verbosityLevel, out);
});
}

Просмотреть файл

@ -1487,6 +1487,10 @@ declare namespace ts {
command: CommandTypes.Quickinfo;
arguments: FileLocationRequestArgs;
}
export interface QuickInfoRequestArgs extends FileLocationRequestArgs {
/** TODO */
verbosityLevel?: number;
}
/**
* Body of QuickInfoResponse.
*/
@ -1520,6 +1524,10 @@ declare namespace ts {
* JSDoc tags associated with symbol.
*/
tags: JSDocTagInfo[];
/**
* TODO
*/
canIncreaseVerbosityLevel?: boolean;
}
/**
* Quickinfo response message.
@ -10757,6 +10765,7 @@ declare namespace ts {
displayParts?: SymbolDisplayPart[];
documentation?: SymbolDisplayPart[];
tags?: JSDocTagInfo[];
canIncreaseVerbosityLevel?: boolean;
}
type RenameInfo = RenameInfoSuccess | RenameInfoFailure;
interface RenameInfoSuccess {

Просмотреть файл

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

Просмотреть файл

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

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

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

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

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

Просмотреть файл

@ -0,0 +1,706 @@
// === QuickInfo ===
=== /tests/cases/fourslash/quickinfoVerbosityTruncation.ts ===
// type Str = string | {};
// type FooType = Str | number;
// type Sym = symbol | (() => void);
// type BarType = Sym | boolean;
// interface LotsOfProps {
// someLongPropertyName1: Str;
// someLongPropertyName2: FooType;
// someLongPropertyName3: Sym;
// someLongPropertyName4: BarType;
// someLongPropertyName5: Str;
// someLongPropertyName6: FooType;
// someLongPropertyName7: Sym;
// someLongPropertyName8: BarType;
// someLongMethodName1(a: FooType, b: BarType): Sym;
// someLongPropertyName9: Str;
// someLongPropertyName10: FooType;
// someLongPropertyName11: Sym;
// someLongPropertyName12: BarType;
// someLongPropertyName13: Str;
// someLongPropertyName14: FooType;
// someLongPropertyName15: Sym;
// someLongPropertyName16: BarType;
// someLongMethodName2(a: FooType, b: BarType): Sym;
// }
// const obj1: LotsOfProps = undefined as any as LotsOfProps;
// ^^^^
// | ----------------------------------------------------------------------
// | const obj1: {
// | someLongPropertyName1: Str;
// | someLongPropertyName2: FooType;
// | someLongPropertyName3: Sym;
// | someLongPropertyName4: BarType;
// | someLongPropertyName5: Str;
// | someLongPropertyName6: FooType;
// | someLongPropertyName7: Sym;
// | someLongPropertyName8: BarType;
// | someLongMethodName1(a: FooType, b: BarType): Sym;
// | someLongPropertyName9: Str;
// | someLongPropertyName10: FooType;
// | someLongPropertyName11: Sym;
// | someLongPropertyName12: BarType;
// | someLongPropertyName13: Str;
// | someLongPropertyName14: FooType;
// | someLongPropertyName15: Sym;
// | someLongPropertyName16: BarType;
// | someLongMethodName2(a: FooType, b: BarType): Sym;
// | }
// | (verbosity level: 1)
// | ----------------------------------------------------------------------
[
{
"marker": {
"fileName": "/tests/cases/fourslash/quickinfoVerbosityTruncation.ts",
"position": 812,
"name": "o1"
},
"item": {
"kind": "const",
"kindModifiers": "",
"textSpan": {
"start": 808,
"length": 4
},
"displayParts": [
{
"text": "const",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "obj1",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "{",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName1",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Str",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName2",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "FooType",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName3",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Sym",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName4",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "BarType",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName5",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Str",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName6",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "FooType",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName7",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Sym",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName8",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "BarType",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongMethodName1",
"kind": "text"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": "a",
"kind": "parameterName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "FooType",
"kind": "aliasName"
},
{
"text": ",",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "b",
"kind": "parameterName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "BarType",
"kind": "aliasName"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Sym",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName9",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Str",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName10",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "FooType",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName11",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Sym",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName12",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "BarType",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName13",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Str",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName14",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "FooType",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName15",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Sym",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongPropertyName16",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "BarType",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "someLongMethodName2",
"kind": "text"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": "a",
"kind": "parameterName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "FooType",
"kind": "aliasName"
},
{
"text": ",",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "b",
"kind": "parameterName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "BarType",
"kind": "aliasName"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Sym",
"kind": "aliasName"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": "}",
"kind": "punctuation"
}
],
"documentation": [],
"canIncreaseVerbosityLevel": true,
"verbosityLevel": 1
}
}
]

Просмотреть файл

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

Просмотреть файл

@ -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;
@ -702,6 +702,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;

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -0,0 +1,71 @@
/// <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 {
//// 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, 2],
f4: [0, 1],
n1: [0, 1],
k1: [0, 1],
});

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -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": [1], });

Просмотреть файл

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