From 6d458e81cd20e3c2fcedc5eac0a4c50e06675055 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 4 Mar 2024 11:41:49 -0800 Subject: [PATCH] Deduplicate protocol.ts content (#57361) Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com> --- scripts/dtsBundler.mjs | 109 +- src/compiler/types.ts | 96 + src/server/protocol.ts | 866 +------- src/services/types.ts | 65 + tests/baselines/reference/api/typescript.d.ts | 1743 ++++++----------- .../loads-missing-files-from-disk.js | 2 +- .../works-using-legacy-resolution-logic.js | 6 +- .../dynamic-file-without-external-project.js | 2 +- ...n-files-should-not-schedule-any-refresh.js | 2 +- ...oject-root-with-case-insensitive-system.js | 6 +- ...project-root-with-case-sensitive-system.js | 6 +- .../inferred-projects-per-project-root.js | 4 +- .../project-settings-for-inferred-projects.js | 2 +- ...t-to-2-if-the-project-has-js-root-files.js | 2 +- .../projectErrors/for-external-project.js | 2 +- .../projectErrors/for-inferred-project.js | 2 +- ...che-handles-changes-in-project-settings.js | 4 +- ...otPath-is-provided-for-inferred-project.js | 6 +- 18 files changed, 1029 insertions(+), 1896 deletions(-) diff --git a/scripts/dtsBundler.mjs b/scripts/dtsBundler.mjs index 7bf4203b990cc..e76cad1655316 100644 --- a/scripts/dtsBundler.mjs +++ b/scripts/dtsBundler.mjs @@ -214,28 +214,35 @@ function nodeToLocation(node) { /** * @param {ts.Node} node + * @param {boolean} needExportModifier * @returns {ts.Node | undefined} */ -function removeDeclareConstExport(node) { +function removeDeclareConstExport(node, needExportModifier) { switch (node.kind) { case ts.SyntaxKind.DeclareKeyword: // No need to emit this in d.ts files. case ts.SyntaxKind.ConstKeyword: // Remove const from const enums. - case ts.SyntaxKind.ExportKeyword: // No export modifier; we are already in the namespace. return undefined; + case ts.SyntaxKind.ExportKeyword: // No export modifier; we are already in the namespace. + if (!needExportModifier) { + return undefined; + } } return node; } -/** @type {Map[]} */ +/** @type {{ locals: Map, exports: Map}[]} */ const scopeStack = []; +/** @type {Map} */ +const symbolToNamespace = new Map(); + /** * @param {string} name */ function findInScope(name) { for (let i = scopeStack.length - 1; i >= 0; i--) { const scope = scopeStack[i]; - const symbol = scope.get(name); + const symbol = scope.exports.get(name); if (symbol) { return symbol; } @@ -290,8 +297,9 @@ function symbolsConflict(s1, s2) { /** * @param {ts.Statement} decl + * @param {boolean} isInternal */ -function verifyMatchingSymbols(decl) { +function verifyMatchingSymbols(decl, isInternal) { ts.visitEachChild(decl, /** @type {(node: ts.Node) => ts.Node} */ function visit(node) { if (ts.isIdentifier(node) && ts.isPartOfTypeNode(node)) { if (ts.isQualifiedName(node.parent) && node !== node.parent.left) { @@ -310,6 +318,10 @@ function verifyMatchingSymbols(decl) { } const symbolInScope = findInScope(symbolOfNode.name); if (!symbolInScope) { + if (symbolOfNode.declarations?.every(d => isLocalDeclaration(d) && d.getSourceFile() === decl.getSourceFile()) && !isSelfReference(node, symbolOfNode)) { + // The symbol is a local that needs to be copied into the scope. + scopeStack[scopeStack.length - 1].locals.set(symbolOfNode.name, { symbol: symbolOfNode, writeTarget: isInternal ? WriteTarget.Internal : WriteTarget.Both }); + } // We didn't find the symbol in scope at all. Just allow it and we'll fail at test time. return node; } @@ -323,39 +335,72 @@ function verifyMatchingSymbols(decl) { }, /*context*/ undefined); } +/** + * @param {ts.Declaration} decl + */ +function isLocalDeclaration(decl) { + return ts.canHaveModifiers(decl) + && !ts.getModifiers(decl)?.some(m => m.kind === ts.SyntaxKind.ExportKeyword) + && !!getDeclarationStatement(decl); +} + +/** + * @param {ts.Node} reference + * @param {ts.Symbol} symbol + */ +function isSelfReference(reference, symbol) { + return symbol.declarations?.every(parent => ts.findAncestor(reference, p => p === parent)); +} + /** * @param {string} name + * @param {string} parent + * @param {boolean} needExportModifier * @param {ts.Symbol} moduleSymbol */ -function emitAsNamespace(name, moduleSymbol) { +function emitAsNamespace(name, parent, moduleSymbol, needExportModifier) { assert(moduleSymbol.flags & ts.SymbolFlags.ValueModule, "moduleSymbol is not a module"); - scopeStack.push(new Map()); + const fullName = parent ? `${parent}.${name}` : name; + + scopeStack.push({ locals: new Map(), exports: new Map() }); const currentScope = scopeStack[scopeStack.length - 1]; const target = containsPublicAPI(moduleSymbol) ? WriteTarget.Both : WriteTarget.Internal; if (name === "ts") { // We will write `export = ts` at the end. + assert(!needExportModifier, "ts namespace should not have an export modifier"); write(`declare namespace ${name} {`, target); } else { - // No export modifier; we are already in the namespace. - write(`namespace ${name} {`, target); + write(`${needExportModifier ? "export " : ""}namespace ${name} {`, target); } increaseIndent(); const moduleExports = typeChecker.getExportsOfModule(moduleSymbol); for (const me of moduleExports) { - currentScope.set(me.name, me); + currentScope.exports.set(me.name, me); + symbolToNamespace.set(me, fullName); } + /** @type {[ts.Statement, ts.SourceFile, WriteTarget][]} */ + const exportedStatements = []; + /** @type {[name: string, fullName: string, moduleSymbol: ts.Symbol][]} */ + const nestedNamespaces = []; for (const me of moduleExports) { assert(me.declarations?.length); if (me.flags & ts.SymbolFlags.Alias) { const resolved = typeChecker.getAliasedSymbol(me); - emitAsNamespace(me.name, resolved); + if (resolved.flags & ts.SymbolFlags.ValueModule) { + nestedNamespaces.push([me.name, fullName, resolved]); + } + else { + const namespaceName = symbolToNamespace.get(resolved); + assert(namespaceName, `Failed to find namespace for ${me.name} at ${nodeToLocation(me.declarations[0])}`); + write(`export import ${me.name} = ${namespaceName}.${me.name}`, target); + } continue; } @@ -367,34 +412,60 @@ function emitAsNamespace(name, moduleSymbol) { fail(`Unhandled declaration for ${me.name} at ${nodeToLocation(decl)}`); } - verifyMatchingSymbols(statement); - const isInternal = ts.isInternalDeclaration(statement); + if (!ts.isModuleDeclaration(decl)) { + verifyMatchingSymbols(statement, isInternal); + } + if (!isInternal) { const publicStatement = ts.visitEachChild(statement, node => { // No @internal comments in the public API. if (ts.isInternalDeclaration(node)) { return undefined; } - return removeDeclareConstExport(node); + return node; }, /*context*/ undefined); - writeNode(publicStatement, sourceFile, WriteTarget.Public); + exportedStatements.push([publicStatement, sourceFile, WriteTarget.Public]); } - const internalStatement = ts.visitEachChild(statement, removeDeclareConstExport, /*context*/ undefined); - - writeNode(internalStatement, sourceFile, WriteTarget.Internal); + exportedStatements.push([statement, sourceFile, WriteTarget.Internal]); } } + const childrenNeedExportModifier = !!currentScope.locals.size; + + nestedNamespaces.forEach(namespace => emitAsNamespace(...namespace, childrenNeedExportModifier)); + + currentScope.locals.forEach(({ symbol, writeTarget }) => { + symbol.declarations?.forEach(decl => { + // We already checked that getDeclarationStatement(decl) works for each declaration. + const statement = getDeclarationStatement(decl); + writeNode(/** @type {ts.Statement} */ (statement), decl.getSourceFile(), writeTarget); + }); + }); + + exportedStatements.forEach(([statement, ...rest]) => { + let updated = ts.visitEachChild(statement, node => removeDeclareConstExport(node, childrenNeedExportModifier), /*context*/ undefined); + if (childrenNeedExportModifier && ts.canHaveModifiers(updated) && !updated.modifiers?.some(m => m.kind === ts.SyntaxKind.ExportKeyword)) { + updated = ts.factory.replaceModifiers( + updated, + [ + ts.factory.createModifier(ts.SyntaxKind.ExportKeyword), + .../**@type {ts.NodeArray | undefined}*/ (updated.modifiers) ?? [], + ], + ); + } + writeNode(updated, ...rest); + }); + scopeStack.pop(); decreaseIndent(); write(`}`, target); } -emitAsNamespace("ts", moduleSymbol); +emitAsNamespace("ts", "", moduleSymbol, /*needExportModifier*/ false); write("export = ts;", WriteTarget.Both); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3d7b3580bccfb..bc6d608584359 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -9845,13 +9845,49 @@ export interface CommentDirectivesMap { export interface UserPreferences { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; + /** + * If enabled, TypeScript will search through all external modules' exports and add them to the completions list. + * This affects lone identifier completions but not completions on the right hand side of `obj.`. + */ readonly includeCompletionsForModuleExports?: boolean; + /** + * Enables auto-import-style completions on partially-typed import statements. E.g., allows + * `import write|` to be completed to `import { writeFile } from "fs"`. + */ readonly includeCompletionsForImportStatements?: boolean; + /** + * Allows completions to be formatted with snippet text, indicated by `CompletionItem["isSnippet"]`. + */ readonly includeCompletionsWithSnippetText?: boolean; + /** + * Unless this option is `false`, or `includeCompletionsWithInsertText` is not enabled, + * member completion lists triggered with `.` will include entries on potentially-null and potentially-undefined + * values, with insertion text to replace preceding `.` tokens with `?.`. + */ readonly includeAutomaticOptionalChainCompletions?: boolean; + /** + * If enabled, the completion list will include completions with invalid identifier names. + * For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`. + */ readonly includeCompletionsWithInsertText?: boolean; + /** + * If enabled, completions for class members (e.g. methods and properties) will include + * a whole declaration for the member. + * E.g., `class A { f| }` could be completed to `class A { foo(): number {} }`, instead of + * `class A { foo }`. + */ readonly includeCompletionsWithClassMemberSnippets?: boolean; + /** + * If enabled, object literal methods will have a method declaration completion entry in addition + * to the regular completion entry containing just the method name. + * E.g., `const objectLiteral: T = { f| }` could be completed to `const objectLiteral: T = { foo(): void {} }`, + * in addition to `const objectLiteral: T = { foo }`. + */ readonly includeCompletionsWithObjectLiteralMethodSnippets?: boolean; + /** + * Indicates whether {@link CompletionEntry.labelDetails completion entry label details} are supported. + * If not, contents of `labelDetails` may be included in the {@link CompletionEntry.name} property. + */ readonly useLabelDetailsInCompletionEntries?: boolean; readonly allowIncompleteCompletions?: boolean; readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative"; @@ -9874,14 +9910,74 @@ export interface UserPreferences { readonly allowRenameOfImportPath?: boolean; readonly autoImportFileExcludePatterns?: string[]; readonly preferTypeOnlyAutoImports?: boolean; + /** + * Indicates whether imports should be organized in a case-insensitive manner. + */ readonly organizeImportsIgnoreCase?: "auto" | boolean; + /** + * Indicates whether imports should be organized via an "ordinal" (binary) comparison using the numeric value + * of their code points, or via "unicode" collation (via the + * [Unicode Collation Algorithm](https://unicode.org/reports/tr10/#Scope)) using rules associated with the locale + * specified in {@link organizeImportsCollationLocale}. + * + * Default: `"ordinal"`. + */ readonly organizeImportsCollation?: "ordinal" | "unicode"; + /** + * Indicates the locale to use for "unicode" collation. If not specified, the locale `"en"` is used as an invariant + * for the sake of consistent sorting. Use `"auto"` to use the detected UI locale. + * + * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. + * + * Default: `"en"` + */ readonly organizeImportsLocale?: string; + /** + * Indicates whether numeric collation should be used for digit sequences in strings. When `true`, will collate + * strings such that `a1z < a2z < a100z`. When `false`, will collate strings such that `a1z < a100z < a2z`. + * + * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. + * + * Default: `false` + */ readonly organizeImportsNumericCollation?: boolean; + /** + * Indicates whether accents and other diacritic marks are considered unequal for the purpose of collation. When + * `true`, characters with accents and other diacritics will be collated in the order defined by the locale specified + * in {@link organizeImportsCollationLocale}. + * + * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. + * + * Default: `true` + */ readonly organizeImportsAccentCollation?: boolean; + /** + * Indicates whether upper case or lower case should sort first. When `false`, the default order for the locale + * specified in {@link organizeImportsCollationLocale} is used. + * + * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. This preference is also + * ignored if we are using case-insensitive sorting, which occurs when {@link organizeImportsIgnoreCase} is `true`, + * or if {@link organizeImportsIgnoreCase} is `"auto"` and the auto-detected case sensitivity is determined to be + * case-insensitive. + * + * Default: `false` + */ readonly organizeImportsCaseFirst?: "upper" | "lower" | false; + /** + * Indicates where named type-only imports should sort. "inline" sorts named imports without regard to if the import is + * type-only. + * + * Default: `last` + */ readonly organizeImportsTypeOrder?: "first" | "last" | "inline"; + /** + * Indicates whether to exclude standard library and node_modules file symbols from navTo results. + */ readonly excludeLibrarySymbolsInNavTo?: boolean; + readonly lazyConfiguredProjectsFromExternalProject?: boolean; + readonly displayPartsForJSDoc?: boolean; + readonly generateReturnInDocTemplate?: boolean; + readonly disableLineTextInReferences?: boolean; } /** Represents a bigint literal value without requiring bigint support */ diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 815f7222af62a..369d7b1589365 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -1,24 +1,41 @@ import type * as ts from "./_namespaces/ts"; import type { + ApplicableRefactorInfo, CompilerOptionsValue, + CompletionsTriggerCharacter, EndOfLineState, FileExtensionInfo, HighlightSpanKind, InteractiveRefactorArguments, - MapLike, - OutliningSpanKind, OutputFile, - PluginImport, - ProjectReference, + RefactorTriggerReason, + RenameInfoFailure, RenameLocation, ScriptElementKind, ScriptKind, + SignatureHelpTriggerReason, + SymbolDisplayPart, TextChange, TextInsertion, TodoComment, TodoCommentDescriptor, TypeAcquisition, + UserPreferences, } from "./_namespaces/ts"; +import { + ClassificationType, + CompletionTriggerKind, + OrganizeImportsMode, + SemicolonPreference, +} from "./_namespaces/ts"; + +// These types/enums used to be defined in duplicate here and exported. They are re-exported to avoid breaking changes. +export { ApplicableRefactorInfo, ClassificationType, CompletionsTriggerCharacter, CompletionTriggerKind, OrganizeImportsMode, RefactorTriggerReason, RenameInfoFailure, SemicolonPreference, SignatureHelpTriggerReason, SymbolDisplayPart, UserPreferences }; + +type ChangeStringIndexSignature = { [K in keyof T]: string extends K ? NewStringIndexSignatureType : T[K]; }; +type ChangePropertyTypes = { + [K in keyof T]: K extends keyof Substitutions ? Substitutions[K] : T[K]; +}; // Declaration module describing the TypeScript Server protocol @@ -380,27 +397,7 @@ export interface OutliningSpansRequest extends FileRequest { command: CommandTypes.GetOutliningSpans; } -export interface OutliningSpan { - /** The span of the document to actually collapse. */ - textSpan: TextSpan; - - /** The span of the document to display when the user hovers over the collapsed span. */ - hintSpan: TextSpan; - - /** The text to display in the editor for the collapsed region. */ - bannerText: string; - - /** - * Whether or not this region should be automatically collapsed when - * the 'Collapse to Definitions' command is invoked. - */ - autoCollapse: boolean; - - /** - * Classification of the contents of the span - */ - kind: OutliningSpanKind; -} +export type OutliningSpan = ChangePropertyTypes; /** * Response to OutliningSpansRequest request. @@ -599,8 +596,6 @@ export type GetApplicableRefactorsRequestArgs = FileLocationOrRangeRequestArgs & includeInteractiveActions?: boolean; }; -export type RefactorTriggerReason = "implicit" | "invoked"; - /** * Response is a list of available refactorings. * Each refactoring exposes one or more "Actions"; a user selects one action to invoke a refactoring @@ -630,66 +625,6 @@ export interface GetMoveToRefactoringFileSuggestions extends Response { }; } -/** - * A set of one or more available refactoring actions, grouped under a parent refactoring. - */ -export interface ApplicableRefactorInfo { - /** - * The programmatic name of the refactoring - */ - name: string; - /** - * A description of this refactoring category to show to the user. - * If the refactoring gets inlined (see below), this text will not be visible. - */ - description: string; - /** - * Inlineable refactorings can have their actions hoisted out to the top level - * of a context menu. Non-inlineanable refactorings should always be shown inside - * their parent grouping. - * - * If not specified, this value is assumed to be 'true' - */ - inlineable?: boolean; - - actions: RefactorActionInfo[]; -} - -/** - * Represents a single refactoring action - for example, the "Extract Method..." refactor might - * offer several actions, each corresponding to a surround class or closure to extract into. - */ -export interface RefactorActionInfo { - /** - * The programmatic name of the refactoring action - */ - name: string; - - /** - * A description of this refactoring action to show to the user. - * If the parent refactoring is inlined away, this will be the only text shown, - * so this description should make sense by itself if the parent is inlineable=true - */ - description: string; - - /** - * A message to show to the user if the refactoring cannot be applied in - * the current context. - */ - notApplicableReason?: string; - - /** - * The hierarchical dotted name of the refactor action. - */ - kind?: string; - - /** - * Indicates that the action requires additional arguments to be passed - * when calling 'GetEditsForRefactor'. - */ - isInteractive?: boolean; -} - export interface GetEditsForRefactorRequest extends Request { command: CommandTypes.GetEditsForRefactor; arguments: GetEditsForRefactorRequestArgs; @@ -737,12 +672,6 @@ export interface OrganizeImportsRequest extends Request { export type OrganizeImportsScope = GetCombinedCodeFixScope; -export const enum OrganizeImportsMode { - All = "All", - SortAndCombine = "SortAndCombine", - RemoveUnused = "RemoveUnused", -} - export interface OrganizeImportsRequestArgs { scope: OrganizeImportsScope; /** @deprecated Use `mode` instead */ @@ -1318,48 +1247,8 @@ export interface RenameFullResponse extends Response { * Information about the item to be renamed. */ export type RenameInfo = RenameInfoSuccess | RenameInfoFailure; -export interface RenameInfoSuccess { - /** - * True if item can be renamed. - */ - canRename: true; - /** - * File or directory to rename. - * If set, `getEditsForFileRename` should be called instead of `findRenameLocations`. - */ - fileToRename?: string; - - /** - * Display name of the item to be renamed. - */ - displayName: string; - - /** - * Full display name of item to be renamed. - * If item to be renamed is a file, then this is the original text of the module specifer - */ - fullDisplayName: string; - /** - * The items's kind (such as 'className' or 'parameterName' or plain 'text'). - */ - kind: ScriptElementKind; - - /** - * Optional modifiers for the kind (such as 'public'). - */ - kindModifiers: string; - - /** Span of text to rename. */ - triggerSpan: TextSpan; -} -export interface RenameInfoFailure { - canRename: false; - /** - * Error message if item can not be renamed. - */ - localizedErrorMessage: string; -} +export type RenameInfoSuccess = ChangePropertyTypes; /** * A group of text spans, all in 'file'. @@ -2223,19 +2112,6 @@ export interface FormatOnKeyRequest extends FileLocationRequest { arguments: FormatOnKeyRequestArgs; } -export type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#" | " "; - -export const enum CompletionTriggerKind { - /** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */ - Invoked = 1, - - /** Completion was triggered by a trigger character. */ - TriggerCharacter = 2, - - /** Completion was re-triggered as the current completion list is incomplete. */ - TriggerForIncompleteCompletions = 3, -} - /** * Arguments for completions messages. */ @@ -2298,176 +2174,24 @@ export interface CompletionDetailsRequest extends FileLocationRequest { arguments: CompletionDetailsRequestArgs; } -/** - * Part of a symbol description. - */ -export interface SymbolDisplayPart { - /** - * Text of an item describing the symbol. - */ - text: string; - - /** - * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). - */ - kind: string; -} - /** A part of a symbol description that links from a jsdoc @link tag to a declaration */ export interface JSDocLinkDisplayPart extends SymbolDisplayPart { /** The location of the declaration that the @link tag links to. */ target: FileSpan; } -/** - * An item found in a completion response. - */ -export interface CompletionEntry { - /** - * The symbol's name. - */ - name: string; - /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ - kind: ScriptElementKind; - /** - * Optional modifiers for the kind (such as 'public'). - */ - kindModifiers?: string; - /** - * A string that is used for comparing completion items so that they can be ordered. This - * is often the same as the name but may be different in certain circumstances. - */ - sortText: string; - /** - * Text to insert instead of `name`. - * This is used to support bracketed completions; If `name` might be "a-b" but `insertText` would be `["a-b"]`, - * coupled with `replacementSpan` to replace a dotted access with a bracket access. - */ - insertText?: string; - /** - * A string that should be used when filtering a set of - * completion items. - */ - filterText?: string; - /** - * `insertText` should be interpreted as a snippet if true. - */ - isSnippet?: true; - /** - * An optional span that indicates the text to be replaced by this completion item. - * If present, this span should be used instead of the default one. - * It will be set if the required span differs from the one generated by the default replacement behavior. - */ - replacementSpan?: TextSpan; - /** - * Indicates whether commiting this completion entry will require additional code actions to be - * made to avoid errors. The CompletionEntryDetails will have these actions. - */ - hasAction?: true; - /** - * Identifier (not necessarily human-readable) identifying where this completion came from. - */ - source?: string; - /** - * Human-readable description of the `source`. - */ - sourceDisplay?: SymbolDisplayPart[]; - /** - * Additional details for the label. - */ - labelDetails?: CompletionEntryLabelDetails; - /** - * If true, this completion should be highlighted as recommended. There will only be one of these. - * This will be set when we know the user should write an expression with a certain type and that type is an enum or constructable class. - * Then either that enum/class or a namespace containing it will be the recommended symbol. - */ - isRecommended?: true; - /** - * If true, this completion was generated from traversing the name table of an unchecked JS file, - * and therefore may not be accurate. - */ - isFromUncheckedFile?: true; - /** - * If true, this completion was for an auto-import of a module not yet in the program, but listed - * in the project package.json. Used for telemetry reporting. - */ - isPackageJsonImport?: true; - /** - * If true, this completion was an auto-import-style completion of an import statement (i.e., the - * module specifier was inserted along with the imported identifier). Used for telemetry reporting. - */ - isImportStatementCompletion?: true; - /** - * A property to be sent back to TS Server in the CompletionDetailsRequest, along with `name`, - * that allows TS Server to look up the symbol represented by the completion item, disambiguating - * items with the same name. - */ - data?: unknown; -} - -export interface CompletionEntryLabelDetails { - /** - * An optional string which is rendered less prominently directly after - * {@link CompletionEntry.name name}, without any spacing. Should be - * used for function signatures or type annotations. - */ - detail?: string; - /** - * An optional string which is rendered less prominently after - * {@link CompletionEntryLabelDetails.detail}. Should be used for fully qualified - * names or file path. - */ - description?: string; -} +export type CompletionEntry = ChangePropertyTypes, { + replacementSpan: TextSpan; + data: unknown; +}>; /** * Additional completion entry details, available on demand */ -export interface CompletionEntryDetails { - /** - * The symbol's name. - */ - name: string; - /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ - kind: ScriptElementKind; - /** - * Optional modifiers for the kind (such as 'public'). - */ - kindModifiers: string; - /** - * Display parts of the symbol (similar to quick info). - */ - displayParts: SymbolDisplayPart[]; - - /** - * Documentation strings for the symbol. - */ - documentation?: SymbolDisplayPart[]; - - /** - * JSDoc tags for the symbol. - */ - tags?: JSDocTagInfo[]; - - /** - * The associated code actions for this entry - */ - codeActions?: CodeAction[]; - - /** - * @deprecated Use `sourceDisplay` instead. - */ - source?: SymbolDisplayPart[]; - - /** - * Human-readable description of the `source` from the CompletionEntry. - */ - sourceDisplay?: SymbolDisplayPart[]; -} +export type CompletionEntryDetails = ChangePropertyTypes; /** @deprecated Prefer CompletionInfoResponse, which supports several top-level fields in addition to the array of entries. */ export interface CompletionsResponse extends Response { @@ -2478,89 +2202,19 @@ export interface CompletionInfoResponse extends Response { body?: CompletionInfo; } -export interface CompletionInfo { - readonly flags?: number; - readonly isGlobalCompletion: boolean; - readonly isMemberCompletion: boolean; - readonly isNewIdentifierLocation: boolean; - /** - * In the absence of `CompletionEntry["replacementSpan"]`, the editor may choose whether to use - * this span or its default one. If `CompletionEntry["replacementSpan"]` is defined, that span - * must be used to commit that completion entry. - */ - readonly optionalReplacementSpan?: TextSpan; - readonly isIncomplete?: boolean; - readonly entries: readonly CompletionEntry[]; -} +export type CompletionInfo = ChangePropertyTypes; export interface CompletionDetailsResponse extends Response { body?: CompletionEntryDetails[]; } -/** - * Signature help information for a single parameter - */ -export interface SignatureHelpParameter { - /** - * The parameter's name - */ - name: string; - - /** - * Documentation of the parameter. - */ - documentation: SymbolDisplayPart[]; - - /** - * Display parts of the parameter. - */ - displayParts: SymbolDisplayPart[]; - - /** - * Whether the parameter is optional or not. - */ - isOptional: boolean; -} - /** * Represents a single signature to show in signature help. */ -export interface SignatureHelpItem { - /** - * Whether the signature accepts a variable number of arguments. - */ - isVariadic: boolean; - - /** - * The prefix display parts. - */ - prefixDisplayParts: SymbolDisplayPart[]; - - /** - * The suffix display parts. - */ - suffixDisplayParts: SymbolDisplayPart[]; - - /** - * The separator display parts. - */ - separatorDisplayParts: SymbolDisplayPart[]; - - /** - * The signature helps items for the parameters. - */ - parameters: SignatureHelpParameter[]; - - /** - * The signature's documentation - */ - documentation: SymbolDisplayPart[]; - - /** - * The signature's JSDoc tags - */ - tags: JSDocTagInfo[]; -} +export type SignatureHelpItem = ChangePropertyTypes; /** * Signature help items found in the response of a signature help request. @@ -2592,9 +2246,6 @@ export interface SignatureHelpItems { argumentCount: number; } -export type SignatureHelpTriggerCharacter = "," | "(" | "<"; -export type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; - /** * Arguments of a signature help request. */ @@ -2606,46 +2257,6 @@ export interface SignatureHelpRequestArgs extends FileLocationRequestArgs { triggerReason?: SignatureHelpTriggerReason; } -export type SignatureHelpTriggerReason = - | SignatureHelpInvokedReason - | SignatureHelpCharacterTypedReason - | SignatureHelpRetriggeredReason; - -/** - * Signals that the user manually requested signature help. - * The language service will unconditionally attempt to provide a result. - */ -export interface SignatureHelpInvokedReason { - kind: "invoked"; - triggerCharacter?: undefined; -} - -/** - * Signals that the signature help request came from a user typing a character. - * Depending on the character and the syntactic context, the request may or may not be served a result. - */ -export interface SignatureHelpCharacterTypedReason { - kind: "characterTyped"; - /** - * Character that was responsible for triggering signature help. - */ - triggerCharacter: SignatureHelpTriggerCharacter; -} - -/** - * Signals that this signature help request came from typing a character or moving the cursor. - * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. - * The language service will unconditionally attempt to provide a result. - * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. - */ -export interface SignatureHelpRetriggeredReason { - kind: "retrigger"; - /** - * Character that was responsible for triggering signature help. - */ - triggerCharacter?: SignatureHelpRetriggerCharacter; -} - /** * Signature help request; value of command field is "signatureHelp". * Given a file location (file, line, col), return the signature @@ -2663,8 +2274,6 @@ export interface SignatureHelpResponse extends Response { body?: SignatureHelpItems; } -export type InlayHintKind = "Type" | "Parameter" | "Enum"; - export interface InlayHintsRequestArgs extends FileRequestArgs { /** * Start position of the span. @@ -2681,15 +2290,10 @@ export interface InlayHintsRequest extends Request { arguments: InlayHintsRequestArgs; } -export interface InlayHintItem { - /** This property will be the empty string when displayParts is set. */ - text: string; +export type InlayHintItem = ChangePropertyTypes; export interface InlayHintItemDisplayPart { text: string; @@ -3428,15 +3032,7 @@ export interface NavTreeResponse extends Response { body?: NavigationTree; } -export interface CallHierarchyItem { - name: string; - kind: ScriptElementKind; - kindModifiers?: string; - file: string; - span: TextSpan; - selectionSpan: TextSpan; - containerName?: string; -} +export type CallHierarchyItem = ChangePropertyTypes; export interface CallHierarchyIncomingCall { from: CallHierarchyItem; @@ -3478,297 +3074,53 @@ export const enum IndentStyle { Smart = "Smart", } -export enum SemicolonPreference { - Ignore = "ignore", - Insert = "insert", - Remove = "remove", -} - -export interface EditorSettings { - baseIndentSize?: number; - indentSize?: number; - tabSize?: number; - newLineCharacter?: string; - convertTabsToSpaces?: boolean; - indentStyle?: IndentStyle | ts.IndentStyle; - trimTrailingWhitespace?: boolean; -} - -export interface FormatCodeSettings extends EditorSettings { - insertSpaceAfterCommaDelimiter?: boolean; - insertSpaceAfterSemicolonInForStatements?: boolean; - insertSpaceBeforeAndAfterBinaryOperators?: boolean; - insertSpaceAfterConstructor?: boolean; - insertSpaceAfterKeywordsInControlFlowStatements?: boolean; - insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; - insertSpaceAfterOpeningAndBeforeClosingEmptyBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; - insertSpaceAfterTypeAssertion?: boolean; - insertSpaceBeforeFunctionParenthesis?: boolean; - placeOpenBraceOnNewLineForFunctions?: boolean; - placeOpenBraceOnNewLineForControlBlocks?: boolean; - insertSpaceBeforeTypeAnnotation?: boolean; - semicolons?: SemicolonPreference; - indentSwitchCase?: boolean; -} - -export interface UserPreferences { - readonly disableSuggestions?: boolean; - readonly quotePreference?: "auto" | "double" | "single"; - /** - * If enabled, TypeScript will search through all external modules' exports and add them to the completions list. - * This affects lone identifier completions but not completions on the right hand side of `obj.`. - */ - readonly includeCompletionsForModuleExports?: boolean; - /** - * Enables auto-import-style completions on partially-typed import statements. E.g., allows - * `import write|` to be completed to `import { writeFile } from "fs"`. - */ - readonly includeCompletionsForImportStatements?: boolean; - /** - * Allows completions to be formatted with snippet text, indicated by `CompletionItem["isSnippet"]`. - */ - readonly includeCompletionsWithSnippetText?: boolean; - /** - * If enabled, the completion list will include completions with invalid identifier names. - * For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`. - */ - readonly includeCompletionsWithInsertText?: boolean; - /** - * Unless this option is `false`, or `includeCompletionsWithInsertText` is not enabled, - * member completion lists triggered with `.` will include entries on potentially-null and potentially-undefined - * values, with insertion text to replace preceding `.` tokens with `?.`. - */ - readonly includeAutomaticOptionalChainCompletions?: boolean; - /** - * If enabled, completions for class members (e.g. methods and properties) will include - * a whole declaration for the member. - * E.g., `class A { f| }` could be completed to `class A { foo(): number {} }`, instead of - * `class A { foo }`. - */ - readonly includeCompletionsWithClassMemberSnippets?: boolean; - /** - * If enabled, object literal methods will have a method declaration completion entry in addition - * to the regular completion entry containing just the method name. - * E.g., `const objectLiteral: T = { f| }` could be completed to `const objectLiteral: T = { foo(): void {} }`, - * in addition to `const objectLiteral: T = { foo }`. - */ - readonly includeCompletionsWithObjectLiteralMethodSnippets?: boolean; - /** - * Indicates whether {@link CompletionEntry.labelDetails completion entry label details} are supported. - * If not, contents of `labelDetails` may be included in the {@link CompletionEntry.name} property. - */ - readonly useLabelDetailsInCompletionEntries?: boolean; - readonly allowIncompleteCompletions?: boolean; - readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative"; - /** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */ - readonly importModuleSpecifierEnding?: "auto" | "minimal" | "index" | "js"; - readonly allowTextChangesInNewFiles?: boolean; - readonly lazyConfiguredProjectsFromExternalProject?: boolean; - readonly providePrefixAndSuffixTextForRename?: boolean; - readonly provideRefactorNotApplicableReason?: boolean; - readonly allowRenameOfImportPath?: boolean; - readonly includePackageJsonAutoImports?: "auto" | "on" | "off"; - readonly jsxAttributeCompletionStyle?: "auto" | "braces" | "none"; - - readonly displayPartsForJSDoc?: boolean; - readonly generateReturnInDocTemplate?: boolean; - - readonly includeInlayParameterNameHints?: "none" | "literals" | "all"; - readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean; - readonly includeInlayFunctionParameterTypeHints?: boolean; - readonly includeInlayVariableTypeHints?: boolean; - readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean; - readonly includeInlayPropertyDeclarationTypeHints?: boolean; - readonly includeInlayFunctionLikeReturnTypeHints?: boolean; - readonly includeInlayEnumMemberValueHints?: boolean; - readonly interactiveInlayHints?: boolean; - - readonly autoImportFileExcludePatterns?: string[]; - - /** - * Indicates whether imports should be organized in a case-insensitive manner. - */ - readonly organizeImportsIgnoreCase?: "auto" | boolean; - /** - * Indicates whether imports should be organized via an "ordinal" (binary) comparison using the numeric value - * of their code points, or via "unicode" collation (via the - * [Unicode Collation Algorithm](https://unicode.org/reports/tr10/#Scope)) using rules associated with the locale - * specified in {@link organizeImportsCollationLocale}. - * - * Default: `"ordinal"`. - */ - readonly organizeImportsCollation?: "ordinal" | "unicode"; - /** - * Indicates the locale to use for "unicode" collation. If not specified, the locale `"en"` is used as an invariant - * for the sake of consistent sorting. Use `"auto"` to use the detected UI locale. - * - * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. - * - * Default: `"en"` - */ - readonly organizeImportsCollationLocale?: string; - /** - * Indicates whether numeric collation should be used for digit sequences in strings. When `true`, will collate - * strings such that `a1z < a2z < a100z`. When `false`, will collate strings such that `a1z < a100z < a2z`. - * - * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. - * - * Default: `false` - */ - readonly organizeImportsNumericCollation?: boolean; - /** - * Indicates whether accents and other diacritic marks are considered unequal for the purpose of collation. When - * `true`, characters with accents and other diacritics will be collated in the order defined by the locale specified - * in {@link organizeImportsCollationLocale}. - * - * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. - * - * Default: `true` - */ - readonly organizeImportsAccentCollation?: boolean; - /** - * Indicates whether upper case or lower case should sort first. When `false`, the default order for the locale - * specified in {@link organizeImportsCollationLocale} is used. - * - * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. This preference is also - * ignored if we are using case-insensitive sorting, which occurs when {@link organizeImportsIgnoreCase} is `true`, - * or if {@link organizeImportsIgnoreCase} is `"auto"` and the auto-detected case sensitivity is determined to be - * case-insensitive. - * - * Default: `false` - */ - readonly organizeImportsCaseFirst?: "upper" | "lower" | false; - /** - * Indicates where named type-only imports should sort. "inline" sorts named imports without regard to if the import is - * type-only. - * - * Default: `last` - */ - readonly organizeImportsTypeOrder?: "last" | "first" | "inline"; - - /** - * Indicates whether {@link ReferencesResponseItem.lineText} is supported. - */ - readonly disableLineTextInReferences?: boolean; +export type EditorSettings = ChangePropertyTypes; - /** - * Indicates whether to exclude standard library and node_modules file symbols from navTo results. - */ - readonly excludeLibrarySymbolsInNavTo?: boolean; -} +export type FormatCodeSettings = ChangePropertyTypes; -export interface CompilerOptions { - allowJs?: boolean; - allowSyntheticDefaultImports?: boolean; - allowUnreachableCode?: boolean; - allowUnusedLabels?: boolean; - alwaysStrict?: boolean; - baseUrl?: string; - /** @deprecated */ - charset?: string; - checkJs?: boolean; - declaration?: boolean; - declarationDir?: string; - disableSizeLimit?: boolean; - downlevelIteration?: boolean; - emitBOM?: boolean; - emitDecoratorMetadata?: boolean; - experimentalDecorators?: boolean; - forceConsistentCasingInFileNames?: boolean; - importHelpers?: boolean; - inlineSourceMap?: boolean; - inlineSources?: boolean; - isolatedModules?: boolean; - jsx?: JsxEmit | ts.JsxEmit; - lib?: string[]; - locale?: string; - mapRoot?: string; - maxNodeModuleJsDepth?: number; - module?: ModuleKind | ts.ModuleKind; - moduleResolution?: ModuleResolutionKind | ts.ModuleResolutionKind; - newLine?: NewLineKind | ts.NewLineKind; - noEmit?: boolean; - noEmitHelpers?: boolean; - noEmitOnError?: boolean; - noErrorTruncation?: boolean; - noFallthroughCasesInSwitch?: boolean; - noImplicitAny?: boolean; - noImplicitReturns?: boolean; - noImplicitThis?: boolean; - noUnusedLocals?: boolean; - noUnusedParameters?: boolean; - /** @deprecated */ - noImplicitUseStrict?: boolean; - noLib?: boolean; - noResolve?: boolean; - /** @deprecated */ - out?: string; - outDir?: string; - outFile?: string; - paths?: MapLike; - plugins?: PluginImport[]; - preserveConstEnums?: boolean; - preserveSymlinks?: boolean; - project?: string; - reactNamespace?: string; - removeComments?: boolean; - references?: ProjectReference[]; - rootDir?: string; - rootDirs?: string[]; - skipLibCheck?: boolean; - skipDefaultLibCheck?: boolean; - sourceMap?: boolean; - sourceRoot?: string; - strict?: boolean; - strictNullChecks?: boolean; - /** @deprecated */ - suppressExcessPropertyErrors?: boolean; - /** @deprecated */ - suppressImplicitAnyIndexErrors?: boolean; - useDefineForClassFields?: boolean; - target?: ScriptTarget | ts.ScriptTarget; - traceResolution?: boolean; - resolveJsonModule?: boolean; - types?: string[]; - /** Paths used to used to compute primary types search locations */ - typeRoots?: string[]; - [option: string]: CompilerOptionsValue | undefined; -} +export type CompilerOptions = ChangePropertyTypes, { + jsx: JsxEmit | ts.JsxEmit; + module: ModuleKind | ts.ModuleKind; + moduleResolution: ModuleResolutionKind | ts.ModuleResolutionKind; + newLine: NewLineKind | ts.NewLineKind; + target: ScriptTarget | ts.ScriptTarget; +}>; export const enum JsxEmit { - None = "None", - Preserve = "Preserve", - ReactNative = "ReactNative", - React = "React", + None = "none", + Preserve = "preserve", + ReactNative = "react-native", + React = "react", + ReactJSX = "react-jsx", + ReactJSXDev = "react-jsxdev", } export const enum ModuleKind { - None = "None", - CommonJS = "CommonJS", - AMD = "AMD", - UMD = "UMD", - System = "System", - ES6 = "ES6", - ES2015 = "ES2015", - ESNext = "ESNext", - Node16 = "Node16", - NodeNext = "NodeNext", - Preserve = "Preserve", + None = "none", + CommonJS = "commonjs", + AMD = "amd", + UMD = "umd", + System = "system", + ES6 = "es6", + ES2015 = "es2015", + ES2020 = "es2020", + ES2022 = "es2022", + ESNext = "esnext", + Node16 = "node16", + NodeNext = "nodenext", + Preserve = "preserve", } export const enum ModuleResolutionKind { - Classic = "Classic", + Classic = "classic", + /** @deprecated Renamed to `Node10` */ + Node = "node", /** @deprecated Renamed to `Node10` */ - Node = "Node", - Node10 = "Node10", - Node16 = "Node16", - NodeNext = "NodeNext", - Bundler = "Bundler", + NodeJs = "node", + Node10 = "node10", + Node16 = "node16", + NodeNext = "nodenext", + Bundler = "bundler", } export const enum NewLineKind { @@ -3778,44 +3130,30 @@ export const enum NewLineKind { export const enum ScriptTarget { /** @deprecated */ - ES3 = "ES3", - ES5 = "ES5", - ES6 = "ES6", - ES2015 = "ES2015", - ES2016 = "ES2016", - ES2017 = "ES2017", - ES2018 = "ES2018", - ES2019 = "ES2019", - ES2020 = "ES2020", - ES2021 = "ES2021", - ES2022 = "ES2022", - ESNext = "ESNext", -} - -export const enum ClassificationType { - comment = 1, - identifier = 2, - keyword = 3, - numericLiteral = 4, - operator = 5, - stringLiteral = 6, - regularExpressionLiteral = 7, - whiteSpace = 8, - text = 9, - punctuation = 10, - className = 11, - enumName = 12, - interfaceName = 13, - moduleName = 14, - typeParameterName = 15, - typeAliasName = 16, - parameterName = 17, - docCommentTagName = 18, - jsxOpenTagName = 19, - jsxCloseTagName = 20, - jsxSelfClosingTagName = 21, - jsxAttribute = 22, - jsxText = 23, - jsxAttributeStringLiteralValue = 24, - bigintLiteral = 25, + ES3 = "es3", + ES5 = "es5", + ES6 = "es6", + ES2015 = "es2015", + ES2016 = "es2016", + ES2017 = "es2017", + ES2018 = "es2018", + ES2019 = "es2019", + ES2020 = "es2020", + ES2021 = "es2021", + ES2022 = "es2022", + ESNext = "esnext", + JSON = "json", + Latest = ESNext, +} + +{ + type AssertKeysComplete = Source; + // eslint-disable-next-line @typescript-eslint/no-unused-vars + type CopiedTypesComplete = [ + AssertKeysComplete, + AssertKeysComplete, + AssertKeysComplete, + AssertKeysComplete, + AssertKeysComplete, + ]; } diff --git a/src/services/types.ts b/src/services/types.ts index 9bb560af02ac9..342636d0d96aa 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -1260,7 +1260,13 @@ export enum SymbolDisplayPartKind { } export interface SymbolDisplayPart { + /** + * Text of an item describing the symbol. + */ text: string; + /** + * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). + */ kind: string; } @@ -1320,6 +1326,9 @@ export interface InteractiveRefactorArguments { targetFile: string; } +/** + * Signature help information for a single parameter + */ export interface SignatureHelpParameter { name: string; documentation: SymbolDisplayPart[]; @@ -1426,9 +1435,25 @@ export interface CompletionEntry { name: string; kind: ScriptElementKind; kindModifiers?: string; // see ScriptElementKindModifier, comma separated + /** + * A string that is used for comparing completion items so that they can be ordered. This + * is often the same as the name but may be different in certain circumstances. + */ sortText: string; + /** + * Text to insert instead of `name`. + * This is used to support bracketed completions; If `name` might be "a-b" but `insertText` would be `["a-b"]`, + * coupled with `replacementSpan` to replace a dotted access with a bracket access. + */ insertText?: string; + /** + * A string that should be used when filtering a set of + * completion items. + */ filterText?: string; + /** + * `insertText` should be interpreted as a snippet if true. + */ isSnippet?: true; /** * An optional span that indicates the text to be replaced by this completion item. @@ -1436,13 +1461,43 @@ export interface CompletionEntry { * It will be set if the required span differs from the one generated by the default replacement behavior. */ replacementSpan?: TextSpan; + /** + * Indicates whether commiting this completion entry will require additional code actions to be + * made to avoid errors. The CompletionEntryDetails will have these actions. + */ hasAction?: true; + /** + * Identifier (not necessarily human-readable) identifying where this completion came from. + */ source?: string; + /** + * Human-readable description of the `source`. + */ sourceDisplay?: SymbolDisplayPart[]; + /** + * Additional details for the label. + */ labelDetails?: CompletionEntryLabelDetails; + /** + * If true, this completion should be highlighted as recommended. There will only be one of these. + * This will be set when we know the user should write an expression with a certain type and that type is an enum or constructable class. + * Then either that enum/class or a namespace containing it will be the recommended symbol. + */ isRecommended?: true; + /** + * If true, this completion was generated from traversing the name table of an unchecked JS file, + * and therefore may not be accurate. + */ isFromUncheckedFile?: true; + /** + * If true, this completion was for an auto-import of a module not yet in the program, but listed + * in the project package.json. Used for telemetry reporting. + */ isPackageJsonImport?: true; + /** + * If true, this completion was an auto-import-style completion of an import statement (i.e., the + * module specifier was inserted along with the imported identifier). Used for telemetry reporting. + */ isImportStatementCompletion?: true; /** * For API purposes. @@ -1462,7 +1517,17 @@ export interface CompletionEntry { } export interface CompletionEntryLabelDetails { + /** + * An optional string which is rendered less prominently directly after + * {@link CompletionEntry.name name}, without any spacing. Should be + * used for function signatures or type annotations. + */ detail?: string; + /** + * An optional string which is rendered less prominently after + * {@link CompletionEntryLabelDetails.detail}. Should be used for fully qualified + * names or file path. + */ description?: string; } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 3d00867ece840..61c467dc32ec9 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -15,92 +15,30 @@ and limitations under the License. declare namespace ts { namespace server { - type ActionSet = "action::set"; - type ActionInvalidate = "action::invalidate"; - type ActionPackageInstalled = "action::packageInstalled"; - type EventTypesRegistry = "event::typesRegistry"; - type EventBeginInstallTypes = "event::beginInstallTypes"; - type EventEndInstallTypes = "event::endInstallTypes"; - type EventInitializationFailed = "event::initializationFailed"; - type ActionWatchTypingLocations = "action::watchTypingLocations"; - interface TypingInstallerResponse { - readonly kind: ActionSet | ActionInvalidate | EventTypesRegistry | ActionPackageInstalled | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed | ActionWatchTypingLocations; - } - interface TypingInstallerRequestWithProjectName { - readonly projectName: string; - } - interface DiscoverTypings extends TypingInstallerRequestWithProjectName { - readonly fileNames: string[]; - readonly projectRootPath: Path; - readonly compilerOptions: CompilerOptions; - readonly typeAcquisition: TypeAcquisition; - readonly unresolvedImports: SortedReadonlyArray; - readonly cachePath?: string; - readonly kind: "discover"; - } - interface CloseProject extends TypingInstallerRequestWithProjectName { - readonly kind: "closeProject"; - } - interface TypesRegistryRequest { - readonly kind: "typesRegistry"; - } - interface InstallPackageRequest extends TypingInstallerRequestWithProjectName { - readonly kind: "installPackage"; - readonly fileName: Path; - readonly packageName: string; - readonly projectRootPath: Path; - readonly id: number; - } - interface PackageInstalledResponse extends ProjectResponse { - readonly kind: ActionPackageInstalled; - readonly id: number; - readonly success: boolean; - readonly message: string; - } - interface InitializationFailedResponse extends TypingInstallerResponse { - readonly kind: EventInitializationFailed; - readonly message: string; - readonly stack?: string; - } - interface ProjectResponse extends TypingInstallerResponse { - readonly projectName: string; - } - interface InvalidateCachedTypings extends ProjectResponse { - readonly kind: ActionInvalidate; - } - interface InstallTypes extends ProjectResponse { - readonly kind: EventBeginInstallTypes | EventEndInstallTypes; - readonly eventId: number; - readonly typingsInstallerVersion: string; - readonly packagesToInstall: readonly string[]; - } - interface BeginInstallTypes extends InstallTypes { - readonly kind: EventBeginInstallTypes; - } - interface EndInstallTypes extends InstallTypes { - readonly kind: EventEndInstallTypes; - readonly installSuccess: boolean; - } - interface InstallTypingHost extends JsTyping.TypingResolutionHost { - useCaseSensitiveFileNames: boolean; - writeFile(path: string, content: string): void; - createDirectory(path: string): void; - getCurrentDirectory?(): string; - } - interface SetTypings extends ProjectResponse { - readonly typeAcquisition: TypeAcquisition; - readonly compilerOptions: CompilerOptions; - readonly typings: string[]; - readonly unresolvedImports: SortedReadonlyArray; - readonly kind: ActionSet; - } - interface WatchTypingLocations extends ProjectResponse { - /** if files is undefined, retain same set of watchers */ - readonly files: readonly string[] | undefined; - readonly kind: ActionWatchTypingLocations; - } namespace protocol { - enum CommandTypes { + export import ApplicableRefactorInfo = ts.ApplicableRefactorInfo; + export import ClassificationType = ts.ClassificationType; + export import CompletionsTriggerCharacter = ts.CompletionsTriggerCharacter; + export import CompletionTriggerKind = ts.CompletionTriggerKind; + export import OrganizeImportsMode = ts.OrganizeImportsMode; + export import RefactorTriggerReason = ts.RefactorTriggerReason; + export import RenameInfoFailure = ts.RenameInfoFailure; + export import SemicolonPreference = ts.SemicolonPreference; + export import SignatureHelpTriggerReason = ts.SignatureHelpTriggerReason; + export import SymbolDisplayPart = ts.SymbolDisplayPart; + export import UserPreferences = ts.UserPreferences; + type ChangePropertyTypes< + T, + Substitutions extends { + [K in keyof T]?: any; + }, + > = { + [K in keyof T]: K extends keyof Substitutions ? Substitutions[K] : T[K]; + }; + type ChangeStringIndexSignature = { + [K in keyof T]: string extends K ? NewStringIndexSignatureType : T[K]; + }; + export enum CommandTypes { JsxClosingTag = "jsxClosingTag", LinkedEditingRange = "linkedEditingRange", Brace = "brace", @@ -178,7 +116,7 @@ declare namespace ts { /** * A TypeScript Server message */ - interface Message { + export interface Message { /** * Sequence number of the message */ @@ -191,7 +129,7 @@ declare namespace ts { /** * Client-initiated request message */ - interface Request extends Message { + export interface Request extends Message { type: "request"; /** * The command to execute @@ -205,13 +143,13 @@ declare namespace ts { /** * Request to reload the project structure for all the opened files */ - interface ReloadProjectsRequest extends Request { + export interface ReloadProjectsRequest extends Request { command: CommandTypes.ReloadProjects; } /** * Server-initiated event message */ - interface Event extends Message { + export interface Event extends Message { type: "event"; /** * Name of event @@ -225,7 +163,7 @@ declare namespace ts { /** * Response by server to client request message. */ - interface Response extends Message { + export interface Response extends Message { type: "response"; /** * Sequence number of the request message. @@ -257,7 +195,7 @@ declare namespace ts { */ performanceData?: PerformanceData; } - interface PerformanceData { + export interface PerformanceData { /** * Time spent updating the program graph, in milliseconds. */ @@ -270,17 +208,17 @@ declare namespace ts { /** * Arguments for FileRequest messages. */ - interface FileRequestArgs { + export interface FileRequestArgs { /** * The file for the request (absolute pathname required). */ file: string; projectFileName?: string; } - interface StatusRequest extends Request { + export interface StatusRequest extends Request { command: CommandTypes.Status; } - interface StatusResponseBody { + export interface StatusResponseBody { /** * The TypeScript version (`ts.version`). */ @@ -289,32 +227,32 @@ declare namespace ts { /** * Response to StatusRequest */ - interface StatusResponse extends Response { + export interface StatusResponse extends Response { body: StatusResponseBody; } /** * Requests a JS Doc comment template for a given position */ - interface DocCommentTemplateRequest extends FileLocationRequest { + export interface DocCommentTemplateRequest extends FileLocationRequest { command: CommandTypes.DocCommentTemplate; } /** * Response to DocCommentTemplateRequest */ - interface DocCommandTemplateResponse extends Response { + export interface DocCommandTemplateResponse extends Response { body?: TextInsertion; } /** * A request to get TODO comments from the file */ - interface TodoCommentRequest extends FileRequest { + export interface TodoCommentRequest extends FileRequest { command: CommandTypes.TodoComments; arguments: TodoCommentRequestArgs; } /** * Arguments for TodoCommentRequest request. */ - interface TodoCommentRequestArgs extends FileRequestArgs { + export interface TodoCommentRequestArgs extends FileRequestArgs { /** * Array of target TodoCommentDescriptors that describes TODO comments to be found */ @@ -323,17 +261,17 @@ declare namespace ts { /** * Response for TodoCommentRequest request. */ - interface TodoCommentsResponse extends Response { + export interface TodoCommentsResponse extends Response { body?: TodoComment[]; } /** * A request to determine if the caret is inside a comment. */ - interface SpanOfEnclosingCommentRequest extends FileLocationRequest { + export interface SpanOfEnclosingCommentRequest extends FileLocationRequest { command: CommandTypes.GetSpanOfEnclosingComment; arguments: SpanOfEnclosingCommentRequestArgs; } - interface SpanOfEnclosingCommentRequestArgs extends FileLocationRequestArgs { + export interface SpanOfEnclosingCommentRequestArgs extends FileLocationRequestArgs { /** * Requires that the enclosing span be a multi-line comment, or else the request returns undefined. */ @@ -342,49 +280,36 @@ declare namespace ts { /** * Request to obtain outlining spans in file. */ - interface OutliningSpansRequest extends FileRequest { + export interface OutliningSpansRequest extends FileRequest { command: CommandTypes.GetOutliningSpans; } - interface OutliningSpan { - /** The span of the document to actually collapse. */ + export type OutliningSpan = ChangePropertyTypes; /** * Response to OutliningSpansRequest request. */ - interface OutliningSpansResponse extends Response { + export interface OutliningSpansResponse extends Response { body?: OutliningSpan[]; } /** * A request to get indentation for a location in file */ - interface IndentationRequest extends FileLocationRequest { + export interface IndentationRequest extends FileLocationRequest { command: CommandTypes.Indentation; arguments: IndentationRequestArgs; } /** * Response for IndentationRequest request. */ - interface IndentationResponse extends Response { + export interface IndentationResponse extends Response { body?: IndentationResult; } /** * Indentation result representing where indentation should be placed */ - interface IndentationResult { + export interface IndentationResult { /** * The base position in the document that the indent should be relative to */ @@ -397,7 +322,7 @@ declare namespace ts { /** * Arguments for IndentationRequest request. */ - interface IndentationRequestArgs extends FileLocationRequestArgs { + export interface IndentationRequestArgs extends FileLocationRequestArgs { /** * An optional set of settings to be used when computing indentation. * If argument is omitted - then it will use settings for file that were previously set via 'configure' request or global settings. @@ -407,7 +332,7 @@ declare namespace ts { /** * Arguments for ProjectInfoRequest request. */ - interface ProjectInfoRequestArgs extends FileRequestArgs { + export interface ProjectInfoRequestArgs extends FileRequestArgs { /** * Indicate if the file name list of the project is needed */ @@ -416,20 +341,20 @@ declare namespace ts { /** * A request to get the project information of the current file. */ - interface ProjectInfoRequest extends Request { + export interface ProjectInfoRequest extends Request { command: CommandTypes.ProjectInfo; arguments: ProjectInfoRequestArgs; } /** * A request to retrieve compiler options diagnostics for a project */ - interface CompilerOptionsDiagnosticsRequest extends Request { + export interface CompilerOptionsDiagnosticsRequest extends Request { arguments: CompilerOptionsDiagnosticsRequestArgs; } /** * Arguments for CompilerOptionsDiagnosticsRequest request. */ - interface CompilerOptionsDiagnosticsRequestArgs { + export interface CompilerOptionsDiagnosticsRequestArgs { /** * Name of the project to retrieve compiler options diagnostics. */ @@ -438,7 +363,7 @@ declare namespace ts { /** * Response message body for "projectInfo" request */ - interface ProjectInfo { + export interface ProjectInfo { /** * For configured project, this is the normalized path of the 'tsconfig.json' file * For inferred project, this is undefined @@ -458,7 +383,7 @@ declare namespace ts { * - start position and length of the error span * - startLocation and endLocation - a pair of Location objects that store start/end line and offset of the error span. */ - interface DiagnosticWithLinePosition { + export interface DiagnosticWithLinePosition { message: string; start: number; length: number; @@ -474,20 +399,20 @@ declare namespace ts { /** * Response message for "projectInfo" request */ - interface ProjectInfoResponse extends Response { + export interface ProjectInfoResponse extends Response { body?: ProjectInfo; } /** * Request whose sole parameter is a file name. */ - interface FileRequest extends Request { + export interface FileRequest extends Request { arguments: FileRequestArgs; } /** * Instances of this interface specify a location in a source file: * (file, line, character offset), where line and character offset are 1-based. */ - interface FileLocationRequestArgs extends FileRequestArgs { + export interface FileLocationRequestArgs extends FileRequestArgs { /** * The line number for the request (1-based). */ @@ -497,15 +422,15 @@ declare namespace ts { */ offset: number; } - type FileLocationOrRangeRequestArgs = FileLocationRequestArgs | FileRangeRequestArgs; + export type FileLocationOrRangeRequestArgs = FileLocationRequestArgs | FileRangeRequestArgs; /** * Request refactorings at a given position or selection area. */ - interface GetApplicableRefactorsRequest extends Request { + export interface GetApplicableRefactorsRequest extends Request { command: CommandTypes.GetApplicableRefactors; arguments: GetApplicableRefactorsRequestArgs; } - type GetApplicableRefactorsRequestArgs = FileLocationOrRangeRequestArgs & { + export type GetApplicableRefactorsRequestArgs = FileLocationOrRangeRequestArgs & { triggerReason?: RefactorTriggerReason; kind?: string; /** @@ -517,88 +442,34 @@ declare namespace ts { */ includeInteractiveActions?: boolean; }; - type RefactorTriggerReason = "implicit" | "invoked"; /** * Response is a list of available refactorings. * Each refactoring exposes one or more "Actions"; a user selects one action to invoke a refactoring */ - interface GetApplicableRefactorsResponse extends Response { + export interface GetApplicableRefactorsResponse extends Response { body?: ApplicableRefactorInfo[]; } /** * Request refactorings at a given position or selection area to move to an existing file. */ - interface GetMoveToRefactoringFileSuggestionsRequest extends Request { + export interface GetMoveToRefactoringFileSuggestionsRequest extends Request { command: CommandTypes.GetMoveToRefactoringFileSuggestions; arguments: GetMoveToRefactoringFileSuggestionsRequestArgs; } - type GetMoveToRefactoringFileSuggestionsRequestArgs = FileLocationOrRangeRequestArgs & { + export type GetMoveToRefactoringFileSuggestionsRequestArgs = FileLocationOrRangeRequestArgs & { kind?: string; }; /** * Response is a list of available files. * Each refactoring exposes one or more "Actions"; a user selects one action to invoke a refactoring */ - interface GetMoveToRefactoringFileSuggestions extends Response { + export interface GetMoveToRefactoringFileSuggestions extends Response { body: { newFileName: string; files: string[]; }; } - /** - * A set of one or more available refactoring actions, grouped under a parent refactoring. - */ - interface ApplicableRefactorInfo { - /** - * The programmatic name of the refactoring - */ - name: string; - /** - * A description of this refactoring category to show to the user. - * If the refactoring gets inlined (see below), this text will not be visible. - */ - description: string; - /** - * Inlineable refactorings can have their actions hoisted out to the top level - * of a context menu. Non-inlineanable refactorings should always be shown inside - * their parent grouping. - * - * If not specified, this value is assumed to be 'true' - */ - inlineable?: boolean; - actions: RefactorActionInfo[]; - } - /** - * Represents a single refactoring action - for example, the "Extract Method..." refactor might - * offer several actions, each corresponding to a surround class or closure to extract into. - */ - interface RefactorActionInfo { - /** - * The programmatic name of the refactoring action - */ - name: string; - /** - * A description of this refactoring action to show to the user. - * If the parent refactoring is inlined away, this will be the only text shown, - * so this description should make sense by itself if the parent is inlineable=true - */ - description: string; - /** - * A message to show to the user if the refactoring cannot be applied in - * the current context. - */ - notApplicableReason?: string; - /** - * The hierarchical dotted name of the refactor action. - */ - kind?: string; - /** - * Indicates that the action requires additional arguments to be passed - * when calling 'GetEditsForRefactor'. - */ - isInteractive?: boolean; - } - interface GetEditsForRefactorRequest extends Request { + export interface GetEditsForRefactorRequest extends Request { command: CommandTypes.GetEditsForRefactor; arguments: GetEditsForRefactorRequestArgs; } @@ -606,15 +477,15 @@ declare namespace ts { * Request the edits that a particular refactoring action produces. * Callers must specify the name of the refactor and the name of the action. */ - type GetEditsForRefactorRequestArgs = FileLocationOrRangeRequestArgs & { + export type GetEditsForRefactorRequestArgs = FileLocationOrRangeRequestArgs & { refactor: string; action: string; interactiveRefactorArguments?: InteractiveRefactorArguments; }; - interface GetEditsForRefactorResponse extends Response { + export interface GetEditsForRefactorResponse extends Response { body?: RefactorEditInfo; } - interface RefactorEditInfo { + export interface RefactorEditInfo { edits: FileCodeEdits[]; /** * An optional location where the editor should start a rename operation once @@ -630,58 +501,53 @@ declare namespace ts { * 2) Coalescing imports from the same module * 3) Sorting imports */ - interface OrganizeImportsRequest extends Request { + export interface OrganizeImportsRequest extends Request { command: CommandTypes.OrganizeImports; arguments: OrganizeImportsRequestArgs; } - type OrganizeImportsScope = GetCombinedCodeFixScope; - enum OrganizeImportsMode { - All = "All", - SortAndCombine = "SortAndCombine", - RemoveUnused = "RemoveUnused", - } - interface OrganizeImportsRequestArgs { + export type OrganizeImportsScope = GetCombinedCodeFixScope; + export interface OrganizeImportsRequestArgs { scope: OrganizeImportsScope; /** @deprecated Use `mode` instead */ skipDestructiveCodeActions?: boolean; mode?: OrganizeImportsMode; } - interface OrganizeImportsResponse extends Response { + export interface OrganizeImportsResponse extends Response { body: readonly FileCodeEdits[]; } - interface GetEditsForFileRenameRequest extends Request { + export interface GetEditsForFileRenameRequest extends Request { command: CommandTypes.GetEditsForFileRename; arguments: GetEditsForFileRenameRequestArgs; } /** Note: Paths may also be directories. */ - interface GetEditsForFileRenameRequestArgs { + export interface GetEditsForFileRenameRequestArgs { readonly oldFilePath: string; readonly newFilePath: string; } - interface GetEditsForFileRenameResponse extends Response { + export interface GetEditsForFileRenameResponse extends Response { body: readonly FileCodeEdits[]; } /** * Request for the available codefixes at a specific position. */ - interface CodeFixRequest extends Request { + export interface CodeFixRequest extends Request { command: CommandTypes.GetCodeFixes; arguments: CodeFixRequestArgs; } - interface GetCombinedCodeFixRequest extends Request { + export interface GetCombinedCodeFixRequest extends Request { command: CommandTypes.GetCombinedCodeFix; arguments: GetCombinedCodeFixRequestArgs; } - interface GetCombinedCodeFixResponse extends Response { + export interface GetCombinedCodeFixResponse extends Response { body: CombinedCodeActions; } - interface ApplyCodeActionCommandRequest extends Request { + export interface ApplyCodeActionCommandRequest extends Request { command: CommandTypes.ApplyCodeActionCommand; arguments: ApplyCodeActionCommandRequestArgs; } - interface ApplyCodeActionCommandResponse extends Response { + export interface ApplyCodeActionCommandResponse extends Response { } - interface FileRangeRequestArgs extends FileRequestArgs { + export interface FileRangeRequestArgs extends FileRequestArgs { /** * The line number for the request (1-based). */ @@ -702,47 +568,47 @@ declare namespace ts { /** * Instances of this interface specify errorcodes on a specific location in a sourcefile. */ - interface CodeFixRequestArgs extends FileRangeRequestArgs { + export interface CodeFixRequestArgs extends FileRangeRequestArgs { /** * Errorcodes we want to get the fixes for. */ errorCodes: readonly number[]; } - interface GetCombinedCodeFixRequestArgs { + export interface GetCombinedCodeFixRequestArgs { scope: GetCombinedCodeFixScope; fixId: {}; } - interface GetCombinedCodeFixScope { + export interface GetCombinedCodeFixScope { type: "file"; args: FileRequestArgs; } - interface ApplyCodeActionCommandRequestArgs { + export interface ApplyCodeActionCommandRequestArgs { /** May also be an array of commands. */ command: {}; } /** * Response for GetCodeFixes request. */ - interface GetCodeFixesResponse extends Response { + export interface GetCodeFixesResponse extends Response { body?: CodeAction[]; } /** * A request whose arguments specify a file location (file, line, col). */ - interface FileLocationRequest extends FileRequest { + export interface FileLocationRequest extends FileRequest { arguments: FileLocationRequestArgs; } /** * A request to get codes of supported code fixes. */ - interface GetSupportedCodeFixesRequest extends Request { + export interface GetSupportedCodeFixesRequest extends Request { command: CommandTypes.GetSupportedCodeFixes; arguments?: Partial; } /** * A response for GetSupportedCodeFixesRequest request. */ - interface GetSupportedCodeFixesResponse extends Response { + export interface GetSupportedCodeFixesResponse extends Response { /** * List of error codes supported by the server. */ @@ -751,13 +617,13 @@ declare namespace ts { /** * A request to get encoded semantic classifications for a span in the file */ - interface EncodedSemanticClassificationsRequest extends FileRequest { + export interface EncodedSemanticClassificationsRequest extends FileRequest { arguments: EncodedSemanticClassificationsRequestArgs; } /** * Arguments for EncodedSemanticClassificationsRequest request. */ - interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { + export interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { /** * Start position of the span. */ @@ -773,13 +639,13 @@ declare namespace ts { format?: "original" | "2020"; } /** The response for a EncodedSemanticClassificationsRequest */ - interface EncodedSemanticClassificationsResponse extends Response { + export interface EncodedSemanticClassificationsResponse extends Response { body?: EncodedSemanticClassificationsResponseBody; } /** * Implementation response message. Gives series of text spans depending on the format ar. */ - interface EncodedSemanticClassificationsResponseBody { + export interface EncodedSemanticClassificationsResponseBody { endOfLineState: EndOfLineState; spans: number[]; } @@ -787,7 +653,7 @@ declare namespace ts { * Arguments in document highlight request; include: filesToSearch, file, * line, offset. */ - interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { + export interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { /** * List of files to search for document highlights. */ @@ -798,16 +664,16 @@ declare namespace ts { * "definition". Return response giving the file locations that * define the symbol found in file at location line, col. */ - interface DefinitionRequest extends FileLocationRequest { + export interface DefinitionRequest extends FileLocationRequest { command: CommandTypes.Definition; } - interface DefinitionAndBoundSpanRequest extends FileLocationRequest { + export interface DefinitionAndBoundSpanRequest extends FileLocationRequest { readonly command: CommandTypes.DefinitionAndBoundSpan; } - interface FindSourceDefinitionRequest extends FileLocationRequest { + export interface FindSourceDefinitionRequest extends FileLocationRequest { readonly command: CommandTypes.FindSourceDefinition; } - interface DefinitionAndBoundSpanResponse extends Response { + export interface DefinitionAndBoundSpanResponse extends Response { readonly body: DefinitionInfoAndBoundSpan; } /** @@ -815,7 +681,7 @@ declare namespace ts { * "typeDefinition". Return response giving the file locations that * define the type for the symbol found in file at location line, col. */ - interface TypeDefinitionRequest extends FileLocationRequest { + export interface TypeDefinitionRequest extends FileLocationRequest { command: CommandTypes.TypeDefinition; } /** @@ -823,20 +689,20 @@ declare namespace ts { * "implementation". Return response giving the file locations that * implement the symbol found in file at location line, col. */ - interface ImplementationRequest extends FileLocationRequest { + export interface ImplementationRequest extends FileLocationRequest { command: CommandTypes.Implementation; } /** * Location in source code expressed as (one-based) line and (one-based) column offset. */ - interface Location { + export interface Location { line: number; offset: number; } /** * Object found in response messages defining a span of text in source code. */ - interface TextSpan { + export interface TextSpan { /** * First character of the definition. */ @@ -849,13 +715,13 @@ declare namespace ts { /** * Object found in response messages defining a span of text in a specific source file. */ - interface FileSpan extends TextSpan { + export interface FileSpan extends TextSpan { /** * File containing text span. */ file: string; } - interface JSDocTagInfo { + export interface JSDocTagInfo { /** Name of the JSDoc tag */ name: string; /** @@ -864,78 +730,78 @@ declare namespace ts { */ text?: string | SymbolDisplayPart[]; } - interface TextSpanWithContext extends TextSpan { + export interface TextSpanWithContext extends TextSpan { contextStart?: Location; contextEnd?: Location; } - interface FileSpanWithContext extends FileSpan, TextSpanWithContext { + export interface FileSpanWithContext extends FileSpan, TextSpanWithContext { } - interface DefinitionInfo extends FileSpanWithContext { + export interface DefinitionInfo extends FileSpanWithContext { /** * When true, the file may or may not exist. */ unverified?: boolean; } - interface DefinitionInfoAndBoundSpan { + export interface DefinitionInfoAndBoundSpan { definitions: readonly DefinitionInfo[]; textSpan: TextSpan; } /** * Definition response message. Gives text range for definition. */ - interface DefinitionResponse extends Response { + export interface DefinitionResponse extends Response { body?: DefinitionInfo[]; } - interface DefinitionInfoAndBoundSpanResponse extends Response { + export interface DefinitionInfoAndBoundSpanResponse extends Response { body?: DefinitionInfoAndBoundSpan; } /** @deprecated Use `DefinitionInfoAndBoundSpanResponse` instead. */ - type DefinitionInfoAndBoundSpanReponse = DefinitionInfoAndBoundSpanResponse; + export type DefinitionInfoAndBoundSpanReponse = DefinitionInfoAndBoundSpanResponse; /** * Definition response message. Gives text range for definition. */ - interface TypeDefinitionResponse extends Response { + export interface TypeDefinitionResponse extends Response { body?: FileSpanWithContext[]; } /** * Implementation response message. Gives text range for implementations. */ - interface ImplementationResponse extends Response { + export interface ImplementationResponse extends Response { body?: FileSpanWithContext[]; } /** * Request to get brace completion for a location in the file. */ - interface BraceCompletionRequest extends FileLocationRequest { + export interface BraceCompletionRequest extends FileLocationRequest { command: CommandTypes.BraceCompletion; arguments: BraceCompletionRequestArgs; } /** * Argument for BraceCompletionRequest request. */ - interface BraceCompletionRequestArgs extends FileLocationRequestArgs { + export interface BraceCompletionRequestArgs extends FileLocationRequestArgs { /** * Kind of opening brace */ openingBrace: string; } - interface JsxClosingTagRequest extends FileLocationRequest { + export interface JsxClosingTagRequest extends FileLocationRequest { readonly command: CommandTypes.JsxClosingTag; readonly arguments: JsxClosingTagRequestArgs; } - interface JsxClosingTagRequestArgs extends FileLocationRequestArgs { + export interface JsxClosingTagRequestArgs extends FileLocationRequestArgs { } - interface JsxClosingTagResponse extends Response { + export interface JsxClosingTagResponse extends Response { readonly body: TextInsertion; } - interface LinkedEditingRangeRequest extends FileLocationRequest { + export interface LinkedEditingRangeRequest extends FileLocationRequest { readonly command: CommandTypes.LinkedEditingRange; } - interface LinkedEditingRangesBody { + export interface LinkedEditingRangesBody { ranges: TextSpan[]; wordPattern?: string; } - interface LinkedEditingRangeResponse extends Response { + export interface LinkedEditingRangeResponse extends Response { readonly body: LinkedEditingRangesBody; } /** @@ -943,20 +809,20 @@ declare namespace ts { * "documentHighlights". Return response giving spans that are relevant * in the file at a given line and column. */ - interface DocumentHighlightsRequest extends FileLocationRequest { + export interface DocumentHighlightsRequest extends FileLocationRequest { command: CommandTypes.DocumentHighlights; arguments: DocumentHighlightsRequestArgs; } /** * Span augmented with extra information that denotes the kind of the highlighting to be used for span. */ - interface HighlightSpan extends TextSpanWithContext { + export interface HighlightSpan extends TextSpanWithContext { kind: HighlightSpanKind; } /** * Represents a set of highligh spans for a give name */ - interface DocumentHighlightsItem { + export interface DocumentHighlightsItem { /** * File containing highlight spans. */ @@ -969,7 +835,7 @@ declare namespace ts { /** * Response for a DocumentHighlightsRequest request. */ - interface DocumentHighlightsResponse extends Response { + export interface DocumentHighlightsResponse extends Response { body?: DocumentHighlightsItem[]; } /** @@ -977,10 +843,10 @@ declare namespace ts { * "references". Return response giving the file locations that * reference the symbol found in file at location line, col. */ - interface ReferencesRequest extends FileLocationRequest { + export interface ReferencesRequest extends FileLocationRequest { command: CommandTypes.References; } - interface ReferencesResponseItem extends FileSpanWithContext { + export interface ReferencesResponseItem extends FileSpanWithContext { /** * Text of line containing the reference. Including this * with the response avoids latency of editor loading files @@ -1004,7 +870,7 @@ declare namespace ts { /** * The body of a "references" response message. */ - interface ReferencesResponseBody { + export interface ReferencesResponseBody { /** * The file locations referencing the symbol. */ @@ -1025,13 +891,13 @@ declare namespace ts { /** * Response to "references" request. */ - interface ReferencesResponse extends Response { + export interface ReferencesResponse extends Response { body?: ReferencesResponseBody; } - interface FileReferencesRequest extends FileRequest { + export interface FileReferencesRequest extends FileRequest { command: CommandTypes.FileReferences; } - interface FileReferencesResponseBody { + export interface FileReferencesResponseBody { /** * The file locations referencing the symbol. */ @@ -1041,13 +907,13 @@ declare namespace ts { */ symbolName: string; } - interface FileReferencesResponse extends Response { + export interface FileReferencesResponse extends Response { body?: FileReferencesResponseBody; } /** * Argument for RenameRequest request. */ - interface RenameRequestArgs extends FileLocationRequestArgs { + export interface RenameRequestArgs extends FileLocationRequestArgs { /** * Should text at specified location be found/changed in comments? */ @@ -1063,65 +929,31 @@ declare namespace ts { * found in file at location line, col. Also return full display * name of the symbol so that client can print it unambiguously. */ - interface RenameRequest extends FileLocationRequest { + export interface RenameRequest extends FileLocationRequest { command: CommandTypes.Rename; arguments: RenameRequestArgs; } /** * Information about the item to be renamed. */ - type RenameInfo = RenameInfoSuccess | RenameInfoFailure; - interface RenameInfoSuccess { - /** - * True if item can be renamed. - */ - canRename: true; - /** - * File or directory to rename. - * If set, `getEditsForFileRename` should be called instead of `findRenameLocations`. - */ - fileToRename?: string; - /** - * Display name of the item to be renamed. - */ - displayName: string; - /** - * Full display name of item to be renamed. - * If item to be renamed is a file, then this is the original text of the module specifer - */ - fullDisplayName: string; - /** - * The items's kind (such as 'className' or 'parameterName' or plain 'text'). - */ - kind: ScriptElementKind; - /** - * Optional modifiers for the kind (such as 'public'). - */ - kindModifiers: string; - /** Span of text to rename. */ + export type RenameInfo = RenameInfoSuccess | RenameInfoFailure; + export type RenameInfoSuccess = ChangePropertyTypes; /** * A group of text spans, all in 'file'. */ - interface SpanGroup { + export interface SpanGroup { /** The file to which the spans apply */ file: string; /** The text spans in this group */ locs: RenameTextSpan[]; } - interface RenameTextSpan extends TextSpanWithContext { + export interface RenameTextSpan extends TextSpanWithContext { readonly prefixText?: string; readonly suffixText?: string; } - interface RenameResponseBody { + export interface RenameResponseBody { /** * Information about the item to be renamed. */ @@ -1134,7 +966,7 @@ declare namespace ts { /** * Rename response message. */ - interface RenameResponse extends Response { + export interface RenameResponse extends Response { body?: RenameResponseBody; } /** @@ -1146,7 +978,7 @@ declare namespace ts { * create configured project for every config file but will maintain a link that these projects were created * as a result of opening external project so they should be removed once external project is closed. */ - interface ExternalFile { + export interface ExternalFile { /** * Name of file file */ @@ -1167,7 +999,7 @@ declare namespace ts { /** * Represent an external project */ - interface ExternalProject { + export interface ExternalProject { /** * Project name */ @@ -1185,7 +1017,7 @@ declare namespace ts { */ typeAcquisition?: TypeAcquisition; } - interface CompileOnSaveMixin { + export interface CompileOnSaveMixin { /** * If compile on save is enabled for the project */ @@ -1195,8 +1027,8 @@ declare namespace ts { * For external projects, some of the project settings are sent together with * compiler settings. */ - type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin & WatchOptions; - interface FileWithProjectReferenceRedirectInfo { + export type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin & WatchOptions; + export interface FileWithProjectReferenceRedirectInfo { /** * Name of file */ @@ -1209,7 +1041,7 @@ declare namespace ts { /** * Represents a set of changes that happen in project */ - interface ProjectChanges { + export interface ProjectChanges { /** * List of added files */ @@ -1231,7 +1063,7 @@ declare namespace ts { /** * Information found in a configure request. */ - interface ConfigureRequestArguments { + export interface ConfigureRequestArguments { /** * Information about the host, for example 'Emacs 24.4' or * 'Sublime Text version 3075' @@ -1252,7 +1084,7 @@ declare namespace ts { extraFileExtensions?: FileExtensionInfo[]; watchOptions?: WatchOptions; } - enum WatchFileKind { + export enum WatchFileKind { FixedPollingInterval = "FixedPollingInterval", PriorityPollingInterval = "PriorityPollingInterval", DynamicPriorityPolling = "DynamicPriorityPolling", @@ -1260,19 +1092,19 @@ declare namespace ts { UseFsEvents = "UseFsEvents", UseFsEventsOnParentDirectory = "UseFsEventsOnParentDirectory", } - enum WatchDirectoryKind { + export enum WatchDirectoryKind { UseFsEvents = "UseFsEvents", FixedPollingInterval = "FixedPollingInterval", DynamicPriorityPolling = "DynamicPriorityPolling", FixedChunkSizePolling = "FixedChunkSizePolling", } - enum PollingWatchKind { + export enum PollingWatchKind { FixedInterval = "FixedInterval", PriorityInterval = "PriorityInterval", DynamicPriority = "DynamicPriority", FixedChunkSize = "FixedChunkSize", } - interface WatchOptions { + export interface WatchOptions { watchFile?: WatchFileKind | ts.WatchFileKind; watchDirectory?: WatchDirectoryKind | ts.WatchDirectoryKind; fallbackPolling?: PollingWatchKind | ts.PollingWatchKind; @@ -1285,7 +1117,7 @@ declare namespace ts { * Configure request; value of command field is "configure". Specifies * host information, such as host type, tab size, and indent size. */ - interface ConfigureRequest extends Request { + export interface ConfigureRequest extends Request { command: CommandTypes.Configure; arguments: ConfigureRequestArguments; } @@ -1293,52 +1125,52 @@ declare namespace ts { * Response to "configure" request. This is just an acknowledgement, so * no body field is required. */ - interface ConfigureResponse extends Response { + export interface ConfigureResponse extends Response { } - interface ConfigurePluginRequestArguments { + export interface ConfigurePluginRequestArguments { pluginName: string; configuration: any; } - interface ConfigurePluginRequest extends Request { + export interface ConfigurePluginRequest extends Request { command: CommandTypes.ConfigurePlugin; arguments: ConfigurePluginRequestArguments; } - interface ConfigurePluginResponse extends Response { + export interface ConfigurePluginResponse extends Response { } - interface SelectionRangeRequest extends FileRequest { + export interface SelectionRangeRequest extends FileRequest { command: CommandTypes.SelectionRange; arguments: SelectionRangeRequestArgs; } - interface SelectionRangeRequestArgs extends FileRequestArgs { + export interface SelectionRangeRequestArgs extends FileRequestArgs { locations: Location[]; } - interface SelectionRangeResponse extends Response { + export interface SelectionRangeResponse extends Response { body?: SelectionRange[]; } - interface SelectionRange { + export interface SelectionRange { textSpan: TextSpan; parent?: SelectionRange; } - interface ToggleLineCommentRequest extends FileRequest { + export interface ToggleLineCommentRequest extends FileRequest { command: CommandTypes.ToggleLineComment; arguments: FileRangeRequestArgs; } - interface ToggleMultilineCommentRequest extends FileRequest { + export interface ToggleMultilineCommentRequest extends FileRequest { command: CommandTypes.ToggleMultilineComment; arguments: FileRangeRequestArgs; } - interface CommentSelectionRequest extends FileRequest { + export interface CommentSelectionRequest extends FileRequest { command: CommandTypes.CommentSelection; arguments: FileRangeRequestArgs; } - interface UncommentSelectionRequest extends FileRequest { + export interface UncommentSelectionRequest extends FileRequest { command: CommandTypes.UncommentSelection; arguments: FileRangeRequestArgs; } /** * Information found in an "open" request. */ - interface OpenRequestArgs extends FileRequestArgs { + export interface OpenRequestArgs extends FileRequestArgs { /** * Used when a version of the file content is known to be more up to date than the one on disk. * Then the known content will be used upon opening instead of the disk copy @@ -1355,7 +1187,7 @@ declare namespace ts { */ projectRootPath?: string; } - type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; + export type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; /** * Open request; value of command field is "open". Notify the * server that the client has file open. The server will not @@ -1364,32 +1196,32 @@ declare namespace ts { * reload messages) when the file changes. Server does not currently * send a response to an open request. */ - interface OpenRequest extends Request { + export interface OpenRequest extends Request { command: CommandTypes.Open; arguments: OpenRequestArgs; } /** * Request to open or update external project */ - interface OpenExternalProjectRequest extends Request { + export interface OpenExternalProjectRequest extends Request { command: CommandTypes.OpenExternalProject; arguments: OpenExternalProjectArgs; } /** * Arguments to OpenExternalProjectRequest request */ - type OpenExternalProjectArgs = ExternalProject; + export type OpenExternalProjectArgs = ExternalProject; /** * Request to open multiple external projects */ - interface OpenExternalProjectsRequest extends Request { + export interface OpenExternalProjectsRequest extends Request { command: CommandTypes.OpenExternalProjects; arguments: OpenExternalProjectsArgs; } /** * Arguments to OpenExternalProjectsRequest */ - interface OpenExternalProjectsArgs { + export interface OpenExternalProjectsArgs { /** * List of external projects to open or update */ @@ -1399,25 +1231,25 @@ declare namespace ts { * Response to OpenExternalProjectRequest request. This is just an acknowledgement, so * no body field is required. */ - interface OpenExternalProjectResponse extends Response { + export interface OpenExternalProjectResponse extends Response { } /** * Response to OpenExternalProjectsRequest request. This is just an acknowledgement, so * no body field is required. */ - interface OpenExternalProjectsResponse extends Response { + export interface OpenExternalProjectsResponse extends Response { } /** * Request to close external project. */ - interface CloseExternalProjectRequest extends Request { + export interface CloseExternalProjectRequest extends Request { command: CommandTypes.CloseExternalProject; arguments: CloseExternalProjectRequestArgs; } /** * Arguments to CloseExternalProjectRequest request */ - interface CloseExternalProjectRequestArgs { + export interface CloseExternalProjectRequestArgs { /** * Name of the project to close */ @@ -1427,19 +1259,19 @@ declare namespace ts { * Response to CloseExternalProjectRequest request. This is just an acknowledgement, so * no body field is required. */ - interface CloseExternalProjectResponse extends Response { + export interface CloseExternalProjectResponse extends Response { } /** * Request to synchronize list of open files with the client */ - interface UpdateOpenRequest extends Request { + export interface UpdateOpenRequest extends Request { command: CommandTypes.UpdateOpen; arguments: UpdateOpenRequestArgs; } /** * Arguments to UpdateOpenRequest */ - interface UpdateOpenRequestArgs { + export interface UpdateOpenRequestArgs { /** * List of newly open files */ @@ -1456,7 +1288,7 @@ declare namespace ts { /** * External projects have a typeAcquisition option so they need to be added separately to compiler options for inferred projects. */ - type InferredProjectCompilerOptions = ExternalProjectCompilerOptions & TypeAcquisition; + export type InferredProjectCompilerOptions = ExternalProjectCompilerOptions & TypeAcquisition; /** * Request to set compiler options for inferred projects. * External projects are opened / closed explicitly. @@ -1466,14 +1298,14 @@ declare namespace ts { * or configured project and will contain only open file and transitive closure of referenced files if 'useOneInferredProject' is false, * or all open loose files and its transitive closure of referenced files if 'useOneInferredProject' is true. */ - interface SetCompilerOptionsForInferredProjectsRequest extends Request { + export interface SetCompilerOptionsForInferredProjectsRequest extends Request { command: CommandTypes.CompilerOptionsForInferredProjects; arguments: SetCompilerOptionsForInferredProjectsArgs; } /** * Argument for SetCompilerOptionsForInferredProjectsRequest request. */ - interface SetCompilerOptionsForInferredProjectsArgs { + export interface SetCompilerOptionsForInferredProjectsArgs { /** * Compiler options to be used with inferred projects. */ @@ -1489,13 +1321,13 @@ declare namespace ts { * Response to SetCompilerOptionsForInferredProjectsResponse request. This is just an acknowledgement, so * no body field is required. */ - interface SetCompilerOptionsForInferredProjectsResponse extends Response { + export interface SetCompilerOptionsForInferredProjectsResponse extends Response { } /** * Exit request; value of command field is "exit". Ask the server process * to exit. */ - interface ExitRequest extends Request { + export interface ExitRequest extends Request { command: CommandTypes.Exit; } /** @@ -1505,14 +1337,14 @@ declare namespace ts { * monitoring the filesystem for changes to file. Server does not * currently send a response to a close request. */ - interface CloseRequest extends FileRequest { + export interface CloseRequest extends FileRequest { command: CommandTypes.Close; } - interface WatchChangeRequest extends Request { + export interface WatchChangeRequest extends Request { command: CommandTypes.WatchChange; arguments: WatchChangeRequestArgs; } - interface WatchChangeRequestArgs { + export interface WatchChangeRequestArgs { id: number; path: string; eventType: "create" | "delete" | "update"; @@ -1521,13 +1353,13 @@ declare namespace ts { * Request to obtain the list of files that should be regenerated if target file is recompiled. * NOTE: this us query-only operation and does not generate any output on disk. */ - interface CompileOnSaveAffectedFileListRequest extends FileRequest { + export interface CompileOnSaveAffectedFileListRequest extends FileRequest { command: CommandTypes.CompileOnSaveAffectedFileList; } /** * Contains a list of files that should be regenerated in a project */ - interface CompileOnSaveAffectedFileListSingleProject { + export interface CompileOnSaveAffectedFileListSingleProject { /** * Project name */ @@ -1544,20 +1376,20 @@ declare namespace ts { /** * Response for CompileOnSaveAffectedFileListRequest request; */ - interface CompileOnSaveAffectedFileListResponse extends Response { + export interface CompileOnSaveAffectedFileListResponse extends Response { body: CompileOnSaveAffectedFileListSingleProject[]; } /** * Request to recompile the file. All generated outputs (.js, .d.ts or .js.map files) is written on disk. */ - interface CompileOnSaveEmitFileRequest extends FileRequest { + export interface CompileOnSaveEmitFileRequest extends FileRequest { command: CommandTypes.CompileOnSaveEmitFile; arguments: CompileOnSaveEmitFileRequestArgs; } /** * Arguments for CompileOnSaveEmitFileRequest */ - interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { + export interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { /** * if true - then file should be recompiled even if it does not have any changes. */ @@ -1566,10 +1398,10 @@ declare namespace ts { /** if true - return response as object with emitSkipped and diagnostics */ richResponse?: boolean; } - interface CompileOnSaveEmitFileResponse extends Response { + export interface CompileOnSaveEmitFileResponse extends Response { body: boolean | EmitResult; } - interface EmitResult { + export interface EmitResult { emitSkipped: boolean; diagnostics: Diagnostic[] | DiagnosticWithLinePosition[]; } @@ -1579,14 +1411,14 @@ declare namespace ts { * documentation string for the symbol found in file at location * line, col. */ - interface QuickInfoRequest extends FileLocationRequest { + export interface QuickInfoRequest extends FileLocationRequest { command: CommandTypes.Quickinfo; arguments: FileLocationRequestArgs; } /** * Body of QuickInfoResponse. */ - interface QuickInfoResponseBody { + export interface QuickInfoResponseBody { /** * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). */ @@ -1620,13 +1452,13 @@ declare namespace ts { /** * Quickinfo response message. */ - interface QuickInfoResponse extends Response { + export interface QuickInfoResponse extends Response { body?: QuickInfoResponseBody; } /** * Arguments for format messages. */ - interface FormatRequestArgs extends FileLocationRequestArgs { + export interface FormatRequestArgs extends FileLocationRequestArgs { /** * Last line of range for which to format text in file. */ @@ -1647,7 +1479,7 @@ declare namespace ts { * instructions in reverse to file will result in correctly * reformatted text. */ - interface FormatRequest extends FileLocationRequest { + export interface FormatRequest extends FileLocationRequest { command: CommandTypes.Format; arguments: FormatRequestArgs; } @@ -1658,7 +1490,7 @@ declare namespace ts { * ending one character before end with newText. For an insertion, * the text span is empty. For a deletion, newText is empty. */ - interface CodeEdit { + export interface CodeEdit { /** * First character of the text span to edit. */ @@ -1673,15 +1505,15 @@ declare namespace ts { */ newText: string; } - interface FileCodeEdits { + export interface FileCodeEdits { fileName: string; textChanges: CodeEdit[]; } - interface CodeFixResponse extends Response { + export interface CodeFixResponse extends Response { /** The code actions that are available */ body?: CodeFixAction[]; } - interface CodeAction { + export interface CodeAction { /** Description of the code action to display in the UI of the editor */ description: string; /** Text changes to apply to each file as part of the code action */ @@ -1689,11 +1521,11 @@ declare namespace ts { /** A command is an opaque object that should be passed to `ApplyCodeActionCommandRequestArgs` without modification. */ commands?: {}[]; } - interface CombinedCodeActions { + export interface CombinedCodeActions { changes: readonly FileCodeEdits[]; commands?: readonly {}[]; } - interface CodeFixAction extends CodeAction { + export interface CodeFixAction extends CodeAction { /** Short name to identify the fix, for use by telemetry. */ fixName: string; /** @@ -1707,13 +1539,13 @@ declare namespace ts { /** * Format and format on key response message. */ - interface FormatResponse extends Response { + export interface FormatResponse extends Response { body?: CodeEdit[]; } /** * Arguments for format on key messages. */ - interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { + export interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { /** * Key pressed (';', '\n', or '}'). */ @@ -1728,23 +1560,14 @@ declare namespace ts { * edit instructions in reverse to file will result in correctly * reformatted text. */ - interface FormatOnKeyRequest extends FileLocationRequest { + export interface FormatOnKeyRequest extends FileLocationRequest { command: CommandTypes.Formatonkey; arguments: FormatOnKeyRequestArgs; } - type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#" | " "; - enum CompletionTriggerKind { - /** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */ - Invoked = 1, - /** Completion was triggered by a trigger character. */ - TriggerCharacter = 2, - /** Completion was re-triggered as the current completion list is incomplete. */ - TriggerForIncompleteCompletions = 3, - } /** * Arguments for completions messages. */ - interface CompletionsRequestArgs extends FileLocationRequestArgs { + export interface CompletionsRequestArgs extends FileLocationRequestArgs { /** * Optional prefix to apply to possible completions. */ @@ -1770,20 +1593,20 @@ declare namespace ts { * be the empty string), return the possible completions that * begin with prefix. */ - interface CompletionsRequest extends FileLocationRequest { + export interface CompletionsRequest extends FileLocationRequest { command: CommandTypes.Completions | CommandTypes.CompletionInfo; arguments: CompletionsRequestArgs; } /** * Arguments for completion details request. */ - interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { + export interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { /** * Names of one or more entries for which to obtain details. */ entryNames: (string | CompletionEntryIdentifier)[]; } - interface CompletionEntryIdentifier { + export interface CompletionEntryIdentifier { name: string; source?: string; data?: unknown; @@ -1794,252 +1617,50 @@ declare namespace ts { * col) and an array of completion entry names return more * detailed information for each completion entry. */ - interface CompletionDetailsRequest extends FileLocationRequest { + export interface CompletionDetailsRequest extends FileLocationRequest { command: CommandTypes.CompletionDetails; arguments: CompletionDetailsRequestArgs; } - /** - * Part of a symbol description. - */ - interface SymbolDisplayPart { - /** - * Text of an item describing the symbol. - */ - text: string; - /** - * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). - */ - kind: string; - } /** A part of a symbol description that links from a jsdoc @link tag to a declaration */ - interface JSDocLinkDisplayPart extends SymbolDisplayPart { + export interface JSDocLinkDisplayPart extends SymbolDisplayPart { /** The location of the declaration that the @link tag links to. */ target: FileSpan; } - /** - * An item found in a completion response. - */ - interface CompletionEntry { - /** - * The symbol's name. - */ - name: string; - /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ - kind: ScriptElementKind; - /** - * Optional modifiers for the kind (such as 'public'). - */ - kindModifiers?: string; - /** - * A string that is used for comparing completion items so that they can be ordered. This - * is often the same as the name but may be different in certain circumstances. - */ - sortText: string; - /** - * Text to insert instead of `name`. - * This is used to support bracketed completions; If `name` might be "a-b" but `insertText` would be `["a-b"]`, - * coupled with `replacementSpan` to replace a dotted access with a bracket access. - */ - insertText?: string; - /** - * A string that should be used when filtering a set of - * completion items. - */ - filterText?: string; - /** - * `insertText` should be interpreted as a snippet if true. - */ - isSnippet?: true; - /** - * An optional span that indicates the text to be replaced by this completion item. - * If present, this span should be used instead of the default one. - * It will be set if the required span differs from the one generated by the default replacement behavior. - */ - replacementSpan?: TextSpan; - /** - * Indicates whether commiting this completion entry will require additional code actions to be - * made to avoid errors. The CompletionEntryDetails will have these actions. - */ - hasAction?: true; - /** - * Identifier (not necessarily human-readable) identifying where this completion came from. - */ - source?: string; - /** - * Human-readable description of the `source`. - */ - sourceDisplay?: SymbolDisplayPart[]; - /** - * Additional details for the label. - */ - labelDetails?: CompletionEntryLabelDetails; - /** - * If true, this completion should be highlighted as recommended. There will only be one of these. - * This will be set when we know the user should write an expression with a certain type and that type is an enum or constructable class. - * Then either that enum/class or a namespace containing it will be the recommended symbol. - */ - isRecommended?: true; - /** - * If true, this completion was generated from traversing the name table of an unchecked JS file, - * and therefore may not be accurate. - */ - isFromUncheckedFile?: true; - /** - * If true, this completion was for an auto-import of a module not yet in the program, but listed - * in the project package.json. Used for telemetry reporting. - */ - isPackageJsonImport?: true; - /** - * If true, this completion was an auto-import-style completion of an import statement (i.e., the - * module specifier was inserted along with the imported identifier). Used for telemetry reporting. - */ - isImportStatementCompletion?: true; - /** - * A property to be sent back to TS Server in the CompletionDetailsRequest, along with `name`, - * that allows TS Server to look up the symbol represented by the completion item, disambiguating - * items with the same name. - */ - data?: unknown; - } - interface CompletionEntryLabelDetails { - /** - * An optional string which is rendered less prominently directly after - * {@link CompletionEntry.name name}, without any spacing. Should be - * used for function signatures or type annotations. - */ - detail?: string; - /** - * An optional string which is rendered less prominently after - * {@link CompletionEntryLabelDetails.detail}. Should be used for fully qualified - * names or file path. - */ - description?: string; - } + export type CompletionEntry = ChangePropertyTypes, { + replacementSpan: TextSpan; + data: unknown; + }>; /** * Additional completion entry details, available on demand */ - interface CompletionEntryDetails { - /** - * The symbol's name. - */ - name: string; - /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ - kind: ScriptElementKind; - /** - * Optional modifiers for the kind (such as 'public'). - */ - kindModifiers: string; - /** - * Display parts of the symbol (similar to quick info). - */ - displayParts: SymbolDisplayPart[]; - /** - * Documentation strings for the symbol. - */ - documentation?: SymbolDisplayPart[]; - /** - * JSDoc tags for the symbol. - */ - tags?: JSDocTagInfo[]; - /** - * The associated code actions for this entry - */ - codeActions?: CodeAction[]; - /** - * @deprecated Use `sourceDisplay` instead. - */ - source?: SymbolDisplayPart[]; - /** - * Human-readable description of the `source` from the CompletionEntry. - */ - sourceDisplay?: SymbolDisplayPart[]; - } + export type CompletionEntryDetails = ChangePropertyTypes; /** @deprecated Prefer CompletionInfoResponse, which supports several top-level fields in addition to the array of entries. */ - interface CompletionsResponse extends Response { + export interface CompletionsResponse extends Response { body?: CompletionEntry[]; } - interface CompletionInfoResponse extends Response { + export interface CompletionInfoResponse extends Response { body?: CompletionInfo; } - interface CompletionInfo { - readonly flags?: number; - readonly isGlobalCompletion: boolean; - readonly isMemberCompletion: boolean; - readonly isNewIdentifierLocation: boolean; - /** - * In the absence of `CompletionEntry["replacementSpan"]`, the editor may choose whether to use - * this span or its default one. If `CompletionEntry["replacementSpan"]` is defined, that span - * must be used to commit that completion entry. - */ - readonly optionalReplacementSpan?: TextSpan; - readonly isIncomplete?: boolean; - readonly entries: readonly CompletionEntry[]; - } - interface CompletionDetailsResponse extends Response { + export type CompletionInfo = ChangePropertyTypes; + export interface CompletionDetailsResponse extends Response { body?: CompletionEntryDetails[]; } - /** - * Signature help information for a single parameter - */ - interface SignatureHelpParameter { - /** - * The parameter's name - */ - name: string; - /** - * Documentation of the parameter. - */ - documentation: SymbolDisplayPart[]; - /** - * Display parts of the parameter. - */ - displayParts: SymbolDisplayPart[]; - /** - * Whether the parameter is optional or not. - */ - isOptional: boolean; - } /** * Represents a single signature to show in signature help. */ - interface SignatureHelpItem { - /** - * Whether the signature accepts a variable number of arguments. - */ - isVariadic: boolean; - /** - * The prefix display parts. - */ - prefixDisplayParts: SymbolDisplayPart[]; - /** - * The suffix display parts. - */ - suffixDisplayParts: SymbolDisplayPart[]; - /** - * The separator display parts. - */ - separatorDisplayParts: SymbolDisplayPart[]; - /** - * The signature helps items for the parameters. - */ - parameters: SignatureHelpParameter[]; - /** - * The signature's documentation - */ - documentation: SymbolDisplayPart[]; - /** - * The signature's JSDoc tags - */ + export type SignatureHelpItem = ChangePropertyTypes; /** * Signature help items found in the response of a signature help request. */ - interface SignatureHelpItems { + export interface SignatureHelpItems { /** * The signature help items. */ @@ -2061,68 +1682,32 @@ declare namespace ts { */ argumentCount: number; } - type SignatureHelpTriggerCharacter = "," | "(" | "<"; - type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; /** * Arguments of a signature help request. */ - interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + export interface SignatureHelpRequestArgs extends FileLocationRequestArgs { /** * Reason why signature help was invoked. * See each individual possible */ triggerReason?: SignatureHelpTriggerReason; } - type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason; - /** - * Signals that the user manually requested signature help. - * The language service will unconditionally attempt to provide a result. - */ - interface SignatureHelpInvokedReason { - kind: "invoked"; - triggerCharacter?: undefined; - } - /** - * Signals that the signature help request came from a user typing a character. - * Depending on the character and the syntactic context, the request may or may not be served a result. - */ - interface SignatureHelpCharacterTypedReason { - kind: "characterTyped"; - /** - * Character that was responsible for triggering signature help. - */ - triggerCharacter: SignatureHelpTriggerCharacter; - } - /** - * Signals that this signature help request came from typing a character or moving the cursor. - * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. - * The language service will unconditionally attempt to provide a result. - * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. - */ - interface SignatureHelpRetriggeredReason { - kind: "retrigger"; - /** - * Character that was responsible for triggering signature help. - */ - triggerCharacter?: SignatureHelpRetriggerCharacter; - } /** * Signature help request; value of command field is "signatureHelp". * Given a file location (file, line, col), return the signature * help. */ - interface SignatureHelpRequest extends FileLocationRequest { + export interface SignatureHelpRequest extends FileLocationRequest { command: CommandTypes.SignatureHelp; arguments: SignatureHelpRequestArgs; } /** * Response object for a SignatureHelpRequest. */ - interface SignatureHelpResponse extends Response { + export interface SignatureHelpResponse extends Response { body?: SignatureHelpItems; } - type InlayHintKind = "Type" | "Parameter" | "Enum"; - interface InlayHintsRequestArgs extends FileRequestArgs { + export interface InlayHintsRequestArgs extends FileRequestArgs { /** * Start position of the span. */ @@ -2132,68 +1717,63 @@ declare namespace ts { */ length: number; } - interface InlayHintsRequest extends Request { + export interface InlayHintsRequest extends Request { command: CommandTypes.ProvideInlayHints; arguments: InlayHintsRequestArgs; } - interface InlayHintItem { - /** This property will be the empty string when displayParts is set. */ - text: string; + export type InlayHintItem = ChangePropertyTypes; + export interface InlayHintItemDisplayPart { text: string; span?: FileSpan; } - interface InlayHintsResponse extends Response { + export interface InlayHintsResponse extends Response { body?: InlayHintItem[]; } /** * Synchronous request for semantic diagnostics of one file. */ - interface SemanticDiagnosticsSyncRequest extends FileRequest { + export interface SemanticDiagnosticsSyncRequest extends FileRequest { command: CommandTypes.SemanticDiagnosticsSync; arguments: SemanticDiagnosticsSyncRequestArgs; } - interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { + export interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { includeLinePosition?: boolean; } /** * Response object for synchronous sematic diagnostics request. */ - interface SemanticDiagnosticsSyncResponse extends Response { + export interface SemanticDiagnosticsSyncResponse extends Response { body?: Diagnostic[] | DiagnosticWithLinePosition[]; } - interface SuggestionDiagnosticsSyncRequest extends FileRequest { + export interface SuggestionDiagnosticsSyncRequest extends FileRequest { command: CommandTypes.SuggestionDiagnosticsSync; arguments: SuggestionDiagnosticsSyncRequestArgs; } - type SuggestionDiagnosticsSyncRequestArgs = SemanticDiagnosticsSyncRequestArgs; - type SuggestionDiagnosticsSyncResponse = SemanticDiagnosticsSyncResponse; + export type SuggestionDiagnosticsSyncRequestArgs = SemanticDiagnosticsSyncRequestArgs; + export type SuggestionDiagnosticsSyncResponse = SemanticDiagnosticsSyncResponse; /** * Synchronous request for syntactic diagnostics of one file. */ - interface SyntacticDiagnosticsSyncRequest extends FileRequest { + export interface SyntacticDiagnosticsSyncRequest extends FileRequest { command: CommandTypes.SyntacticDiagnosticsSync; arguments: SyntacticDiagnosticsSyncRequestArgs; } - interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { + export interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { includeLinePosition?: boolean; } /** * Response object for synchronous syntactic diagnostics request. */ - interface SyntacticDiagnosticsSyncResponse extends Response { + export interface SyntacticDiagnosticsSyncResponse extends Response { body?: Diagnostic[] | DiagnosticWithLinePosition[]; } /** * Arguments for GeterrForProject request. */ - interface GeterrForProjectRequestArgs { + export interface GeterrForProjectRequestArgs { /** * the file requesting project error list */ @@ -2209,14 +1789,14 @@ declare namespace ts { * "geterrForProject". It works similarly with 'Geterr', only * it request for every file in this project. */ - interface GeterrForProjectRequest extends Request { + export interface GeterrForProjectRequest extends Request { command: CommandTypes.GeterrForProject; arguments: GeterrForProjectRequestArgs; } /** * Arguments for geterr messages. */ - interface GeterrRequestArgs { + export interface GeterrRequestArgs { /** * List of file names for which to compute compiler errors. * The files will be checked in list order. @@ -2238,25 +1818,25 @@ declare namespace ts { * practice for an editor is to send a file list containing each * file that is currently visible, in most-recently-used order. */ - interface GeterrRequest extends Request { + export interface GeterrRequest extends Request { command: CommandTypes.Geterr; arguments: GeterrRequestArgs; } - type RequestCompletedEventName = "requestCompleted"; + export type RequestCompletedEventName = "requestCompleted"; /** * Event that is sent when server have finished processing request with specified id. */ - interface RequestCompletedEvent extends Event { + export interface RequestCompletedEvent extends Event { event: RequestCompletedEventName; body: RequestCompletedEventBody; } - interface RequestCompletedEventBody { + export interface RequestCompletedEventBody { request_seq: number; } /** * Item of diagnostic information found in a DiagnosticEvent message. */ - interface Diagnostic { + export interface Diagnostic { /** * Starting file location at which text applies. */ @@ -2288,7 +1868,7 @@ declare namespace ts { */ source?: string; } - interface DiagnosticWithFileName extends Diagnostic { + export interface DiagnosticWithFileName extends Diagnostic { /** * Name of the file the diagnostic is in */ @@ -2297,7 +1877,7 @@ declare namespace ts { /** * Represents additional spans returned with a diagnostic which are relevant to it */ - interface DiagnosticRelatedInformation { + export interface DiagnosticRelatedInformation { /** * The category of the related information message, e.g. "error", "warning", or "suggestion". */ @@ -2315,7 +1895,7 @@ declare namespace ts { */ span?: FileSpan; } - interface DiagnosticEventBody { + export interface DiagnosticEventBody { /** * The file for which diagnostic information is reported. */ @@ -2325,16 +1905,16 @@ declare namespace ts { */ diagnostics: Diagnostic[]; } - type DiagnosticEventKind = "semanticDiag" | "syntaxDiag" | "suggestionDiag"; + export type DiagnosticEventKind = "semanticDiag" | "syntaxDiag" | "suggestionDiag"; /** * Event message for DiagnosticEventKind event types. * These events provide syntactic and semantic errors for a file. */ - interface DiagnosticEvent extends Event { + export interface DiagnosticEvent extends Event { body?: DiagnosticEventBody; event: DiagnosticEventKind; } - interface ConfigFileDiagnosticEventBody { + export interface ConfigFileDiagnosticEventBody { /** * The file which trigged the searching and error-checking of the config file */ @@ -2352,16 +1932,16 @@ declare namespace ts { * Event message for "configFileDiag" event type. * This event provides errors for a found config file. */ - interface ConfigFileDiagnosticEvent extends Event { + export interface ConfigFileDiagnosticEvent extends Event { body?: ConfigFileDiagnosticEventBody; event: "configFileDiag"; } - type ProjectLanguageServiceStateEventName = "projectLanguageServiceState"; - interface ProjectLanguageServiceStateEvent extends Event { + export type ProjectLanguageServiceStateEventName = "projectLanguageServiceState"; + export interface ProjectLanguageServiceStateEvent extends Event { event: ProjectLanguageServiceStateEventName; body?: ProjectLanguageServiceStateEventBody; } - interface ProjectLanguageServiceStateEventBody { + export interface ProjectLanguageServiceStateEventBody { /** * Project name that has changes in the state of language service. * For configured projects this will be the config file path. @@ -2375,52 +1955,52 @@ declare namespace ts { */ languageServiceEnabled: boolean; } - type ProjectsUpdatedInBackgroundEventName = "projectsUpdatedInBackground"; - interface ProjectsUpdatedInBackgroundEvent extends Event { + export type ProjectsUpdatedInBackgroundEventName = "projectsUpdatedInBackground"; + export interface ProjectsUpdatedInBackgroundEvent extends Event { event: ProjectsUpdatedInBackgroundEventName; body: ProjectsUpdatedInBackgroundEventBody; } - interface ProjectsUpdatedInBackgroundEventBody { + export interface ProjectsUpdatedInBackgroundEventBody { /** * Current set of open files */ openFiles: string[]; } - type ProjectLoadingStartEventName = "projectLoadingStart"; - interface ProjectLoadingStartEvent extends Event { + export type ProjectLoadingStartEventName = "projectLoadingStart"; + export interface ProjectLoadingStartEvent extends Event { event: ProjectLoadingStartEventName; body: ProjectLoadingStartEventBody; } - interface ProjectLoadingStartEventBody { + export interface ProjectLoadingStartEventBody { /** name of the project */ projectName: string; /** reason for loading */ reason: string; } - type ProjectLoadingFinishEventName = "projectLoadingFinish"; - interface ProjectLoadingFinishEvent extends Event { + export type ProjectLoadingFinishEventName = "projectLoadingFinish"; + export interface ProjectLoadingFinishEvent extends Event { event: ProjectLoadingFinishEventName; body: ProjectLoadingFinishEventBody; } - interface ProjectLoadingFinishEventBody { + export interface ProjectLoadingFinishEventBody { /** name of the project */ projectName: string; } - type SurveyReadyEventName = "surveyReady"; - interface SurveyReadyEvent extends Event { + export type SurveyReadyEventName = "surveyReady"; + export interface SurveyReadyEvent extends Event { event: SurveyReadyEventName; body: SurveyReadyEventBody; } - interface SurveyReadyEventBody { + export interface SurveyReadyEventBody { /** Name of the survey. This is an internal machine- and programmer-friendly name */ surveyId: string; } - type LargeFileReferencedEventName = "largeFileReferenced"; - interface LargeFileReferencedEvent extends Event { + export type LargeFileReferencedEventName = "largeFileReferenced"; + export interface LargeFileReferencedEvent extends Event { event: LargeFileReferencedEventName; body: LargeFileReferencedEventBody; } - interface LargeFileReferencedEventBody { + export interface LargeFileReferencedEventBody { /** * name of the large file being loaded */ @@ -2434,37 +2014,37 @@ declare namespace ts { */ maxFileSize: number; } - type CreateFileWatcherEventName = "createFileWatcher"; - interface CreateFileWatcherEvent extends Event { + export type CreateFileWatcherEventName = "createFileWatcher"; + export interface CreateFileWatcherEvent extends Event { readonly event: CreateFileWatcherEventName; readonly body: CreateFileWatcherEventBody; } - interface CreateFileWatcherEventBody { + export interface CreateFileWatcherEventBody { readonly id: number; readonly path: string; } - type CreateDirectoryWatcherEventName = "createDirectoryWatcher"; - interface CreateDirectoryWatcherEvent extends Event { + export type CreateDirectoryWatcherEventName = "createDirectoryWatcher"; + export interface CreateDirectoryWatcherEvent extends Event { readonly event: CreateDirectoryWatcherEventName; readonly body: CreateDirectoryWatcherEventBody; } - interface CreateDirectoryWatcherEventBody { + export interface CreateDirectoryWatcherEventBody { readonly id: number; readonly path: string; readonly recursive: boolean; } - type CloseFileWatcherEventName = "closeFileWatcher"; - interface CloseFileWatcherEvent extends Event { + export type CloseFileWatcherEventName = "closeFileWatcher"; + export interface CloseFileWatcherEvent extends Event { readonly event: CloseFileWatcherEventName; readonly body: CloseFileWatcherEventBody; } - interface CloseFileWatcherEventBody { + export interface CloseFileWatcherEventBody { readonly id: number; } /** * Arguments for reload request. */ - interface ReloadRequestArgs extends FileRequestArgs { + export interface ReloadRequestArgs extends FileRequestArgs { /** * Name of temporary file from which to reload file * contents. May be same as file. @@ -2477,7 +2057,7 @@ declare namespace ts { * from temporary file with name given by the 'tmpfile' argument. * The two names can be identical. */ - interface ReloadRequest extends FileRequest { + export interface ReloadRequest extends FileRequest { command: CommandTypes.Reload; arguments: ReloadRequestArgs; } @@ -2485,12 +2065,12 @@ declare namespace ts { * Response to "reload" request. This is just an acknowledgement, so * no body field is required. */ - interface ReloadResponse extends Response { + export interface ReloadResponse extends Response { } /** * Arguments for saveto request. */ - interface SavetoRequestArgs extends FileRequestArgs { + export interface SavetoRequestArgs extends FileRequestArgs { /** * Name of temporary file into which to save server's view of * file contents. @@ -2504,14 +2084,14 @@ declare namespace ts { * 'file'. The server does not currently send a response to a * "saveto" request. */ - interface SavetoRequest extends FileRequest { + export interface SavetoRequest extends FileRequest { command: CommandTypes.Saveto; arguments: SavetoRequestArgs; } /** * Arguments for navto request message. */ - interface NavtoRequestArgs { + export interface NavtoRequestArgs { /** * Search term to navigate to from current location; term can * be '.*' or an identifier prefix. @@ -2538,14 +2118,14 @@ declare namespace ts { * match the search term given in argument 'searchTerm'. The * context for the search is given by the named file. */ - interface NavtoRequest extends Request { + export interface NavtoRequest extends Request { command: CommandTypes.Navto; arguments: NavtoRequestArgs; } /** * An item found in a navto response. */ - interface NavtoItem extends FileSpan { + export interface NavtoItem extends FileSpan { /** * The symbol's name. */ @@ -2580,13 +2160,13 @@ declare namespace ts { * Navto response message. Body is an array of navto items. Each * item gives a symbol that matched the search term. */ - interface NavtoResponse extends Response { + export interface NavtoResponse extends Response { body?: NavtoItem[]; } /** * Arguments for change request message. */ - interface ChangeRequestArgs extends FormatRequestArgs { + export interface ChangeRequestArgs extends FormatRequestArgs { /** * Optional string to insert at location (file, line, offset). */ @@ -2597,14 +2177,14 @@ declare namespace ts { * Update the server's view of the file named by argument 'file'. * Server does not currently send a response to a change request. */ - interface ChangeRequest extends FileLocationRequest { + export interface ChangeRequest extends FileLocationRequest { command: CommandTypes.Change; arguments: ChangeRequestArgs; } /** * Response to "brace" request. */ - interface BraceResponse extends Response { + export interface BraceResponse extends Response { body?: TextSpan[]; } /** @@ -2612,7 +2192,7 @@ declare namespace ts { * Return response giving the file locations of matching braces * found in file at location line, offset. */ - interface BraceRequest extends FileLocationRequest { + export interface BraceRequest extends FileLocationRequest { command: CommandTypes.Brace; } /** @@ -2620,17 +2200,17 @@ declare namespace ts { * Return response giving the list of navigation bar entries * extracted from the requested file. */ - interface NavBarRequest extends FileRequest { + export interface NavBarRequest extends FileRequest { command: CommandTypes.NavBar; } /** * NavTree request; value of command field is "navtree". * Return response giving the navigation tree of the requested file. */ - interface NavTreeRequest extends FileRequest { + export interface NavTreeRequest extends FileRequest { command: CommandTypes.NavTree; } - interface NavigationBarItem { + export interface NavigationBarItem { /** * The item's display text. */ @@ -2657,7 +2237,7 @@ declare namespace ts { indent: number; } /** protocol.NavigationTree is identical to ts.NavigationTree, except using protocol.TextSpan instead of ts.TextSpan */ - interface NavigationTree { + export interface NavigationTree { text: string; kind: ScriptElementKind; kindModifiers: string; @@ -2665,29 +2245,29 @@ declare namespace ts { nameSpan: TextSpan | undefined; childItems?: NavigationTree[]; } - type TelemetryEventName = "telemetry"; - interface TelemetryEvent extends Event { + export type TelemetryEventName = "telemetry"; + export interface TelemetryEvent extends Event { event: TelemetryEventName; body: TelemetryEventBody; } - interface TelemetryEventBody { + export interface TelemetryEventBody { telemetryEventName: string; payload: any; } - type TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed"; - interface TypesInstallerInitializationFailedEvent extends Event { + export type TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed"; + export interface TypesInstallerInitializationFailedEvent extends Event { event: TypesInstallerInitializationFailedEventName; body: TypesInstallerInitializationFailedEventBody; } - interface TypesInstallerInitializationFailedEventBody { + export interface TypesInstallerInitializationFailedEventBody { message: string; } - type TypingsInstalledTelemetryEventName = "typingsInstalled"; - interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody { + export type TypingsInstalledTelemetryEventName = "typingsInstalled"; + export interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody { telemetryEventName: TypingsInstalledTelemetryEventName; payload: TypingsInstalledTelemetryEventPayload; } - interface TypingsInstalledTelemetryEventPayload { + export interface TypingsInstalledTelemetryEventPayload { /** * Comma separated list of installed typing packages */ @@ -2701,17 +2281,17 @@ declare namespace ts { */ typingsInstallerVersion: string; } - type BeginInstallTypesEventName = "beginInstallTypes"; - type EndInstallTypesEventName = "endInstallTypes"; - interface BeginInstallTypesEvent extends Event { + export type BeginInstallTypesEventName = "beginInstallTypes"; + export type EndInstallTypesEventName = "endInstallTypes"; + export interface BeginInstallTypesEvent extends Event { event: BeginInstallTypesEventName; body: BeginInstallTypesEventBody; } - interface EndInstallTypesEvent extends Event { + export interface EndInstallTypesEvent extends Event { event: EndInstallTypesEventName; body: EndInstallTypesEventBody; } - interface InstallTypesEventBody { + export interface InstallTypesEventBody { /** * correlation id to match begin and end events */ @@ -2721,384 +2301,122 @@ declare namespace ts { */ packages: readonly string[]; } - interface BeginInstallTypesEventBody extends InstallTypesEventBody { + export interface BeginInstallTypesEventBody extends InstallTypesEventBody { } - interface EndInstallTypesEventBody extends InstallTypesEventBody { + export interface EndInstallTypesEventBody extends InstallTypesEventBody { /** * true if installation succeeded, otherwise false */ success: boolean; } - interface NavBarResponse extends Response { + export interface NavBarResponse extends Response { body?: NavigationBarItem[]; } - interface NavTreeResponse extends Response { + export interface NavTreeResponse extends Response { body?: NavigationTree; } - interface CallHierarchyItem { - name: string; - kind: ScriptElementKind; - kindModifiers?: string; - file: string; + export type CallHierarchyItem = ChangePropertyTypes; + export interface CallHierarchyIncomingCall { from: CallHierarchyItem; fromSpans: TextSpan[]; } - interface CallHierarchyOutgoingCall { + export interface CallHierarchyOutgoingCall { to: CallHierarchyItem; fromSpans: TextSpan[]; } - interface PrepareCallHierarchyRequest extends FileLocationRequest { + export interface PrepareCallHierarchyRequest extends FileLocationRequest { command: CommandTypes.PrepareCallHierarchy; } - interface PrepareCallHierarchyResponse extends Response { + export interface PrepareCallHierarchyResponse extends Response { readonly body: CallHierarchyItem | CallHierarchyItem[]; } - interface ProvideCallHierarchyIncomingCallsRequest extends FileLocationRequest { + export interface ProvideCallHierarchyIncomingCallsRequest extends FileLocationRequest { command: CommandTypes.ProvideCallHierarchyIncomingCalls; } - interface ProvideCallHierarchyIncomingCallsResponse extends Response { + export interface ProvideCallHierarchyIncomingCallsResponse extends Response { readonly body: CallHierarchyIncomingCall[]; } - interface ProvideCallHierarchyOutgoingCallsRequest extends FileLocationRequest { + export interface ProvideCallHierarchyOutgoingCallsRequest extends FileLocationRequest { command: CommandTypes.ProvideCallHierarchyOutgoingCalls; } - interface ProvideCallHierarchyOutgoingCallsResponse extends Response { + export interface ProvideCallHierarchyOutgoingCallsResponse extends Response { readonly body: CallHierarchyOutgoingCall[]; } - enum IndentStyle { + export enum IndentStyle { None = "None", Block = "Block", Smart = "Smart", } - enum SemicolonPreference { - Ignore = "ignore", - Insert = "insert", - Remove = "remove", - } - interface EditorSettings { - baseIndentSize?: number; - indentSize?: number; - tabSize?: number; - newLineCharacter?: string; - convertTabsToSpaces?: boolean; - indentStyle?: IndentStyle | ts.IndentStyle; - trimTrailingWhitespace?: boolean; - } - interface FormatCodeSettings extends EditorSettings { - insertSpaceAfterCommaDelimiter?: boolean; - insertSpaceAfterSemicolonInForStatements?: boolean; - insertSpaceBeforeAndAfterBinaryOperators?: boolean; - insertSpaceAfterConstructor?: boolean; - insertSpaceAfterKeywordsInControlFlowStatements?: boolean; - insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; - insertSpaceAfterOpeningAndBeforeClosingEmptyBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; - insertSpaceAfterTypeAssertion?: boolean; - insertSpaceBeforeFunctionParenthesis?: boolean; - placeOpenBraceOnNewLineForFunctions?: boolean; - placeOpenBraceOnNewLineForControlBlocks?: boolean; - insertSpaceBeforeTypeAnnotation?: boolean; - semicolons?: SemicolonPreference; - indentSwitchCase?: boolean; - } - interface UserPreferences { - readonly disableSuggestions?: boolean; - readonly quotePreference?: "auto" | "double" | "single"; - /** - * If enabled, TypeScript will search through all external modules' exports and add them to the completions list. - * This affects lone identifier completions but not completions on the right hand side of `obj.`. - */ - readonly includeCompletionsForModuleExports?: boolean; - /** - * Enables auto-import-style completions on partially-typed import statements. E.g., allows - * `import write|` to be completed to `import { writeFile } from "fs"`. - */ - readonly includeCompletionsForImportStatements?: boolean; - /** - * Allows completions to be formatted with snippet text, indicated by `CompletionItem["isSnippet"]`. - */ - readonly includeCompletionsWithSnippetText?: boolean; - /** - * If enabled, the completion list will include completions with invalid identifier names. - * For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`. - */ - readonly includeCompletionsWithInsertText?: boolean; - /** - * Unless this option is `false`, or `includeCompletionsWithInsertText` is not enabled, - * member completion lists triggered with `.` will include entries on potentially-null and potentially-undefined - * values, with insertion text to replace preceding `.` tokens with `?.`. - */ - readonly includeAutomaticOptionalChainCompletions?: boolean; - /** - * If enabled, completions for class members (e.g. methods and properties) will include - * a whole declaration for the member. - * E.g., `class A { f| }` could be completed to `class A { foo(): number {} }`, instead of - * `class A { foo }`. - */ - readonly includeCompletionsWithClassMemberSnippets?: boolean; - /** - * If enabled, object literal methods will have a method declaration completion entry in addition - * to the regular completion entry containing just the method name. - * E.g., `const objectLiteral: T = { f| }` could be completed to `const objectLiteral: T = { foo(): void {} }`, - * in addition to `const objectLiteral: T = { foo }`. - */ - readonly includeCompletionsWithObjectLiteralMethodSnippets?: boolean; - /** - * Indicates whether {@link CompletionEntry.labelDetails completion entry label details} are supported. - * If not, contents of `labelDetails` may be included in the {@link CompletionEntry.name} property. - */ - readonly useLabelDetailsInCompletionEntries?: boolean; - readonly allowIncompleteCompletions?: boolean; - readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative"; - /** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */ - readonly importModuleSpecifierEnding?: "auto" | "minimal" | "index" | "js"; - readonly allowTextChangesInNewFiles?: boolean; - readonly lazyConfiguredProjectsFromExternalProject?: boolean; - readonly providePrefixAndSuffixTextForRename?: boolean; - readonly provideRefactorNotApplicableReason?: boolean; - readonly allowRenameOfImportPath?: boolean; - readonly includePackageJsonAutoImports?: "auto" | "on" | "off"; - readonly jsxAttributeCompletionStyle?: "auto" | "braces" | "none"; - readonly displayPartsForJSDoc?: boolean; - readonly generateReturnInDocTemplate?: boolean; - readonly includeInlayParameterNameHints?: "none" | "literals" | "all"; - readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean; - readonly includeInlayFunctionParameterTypeHints?: boolean; - readonly includeInlayVariableTypeHints?: boolean; - readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean; - readonly includeInlayPropertyDeclarationTypeHints?: boolean; - readonly includeInlayFunctionLikeReturnTypeHints?: boolean; - readonly includeInlayEnumMemberValueHints?: boolean; - readonly interactiveInlayHints?: boolean; - readonly autoImportFileExcludePatterns?: string[]; - /** - * Indicates whether imports should be organized in a case-insensitive manner. - */ - readonly organizeImportsIgnoreCase?: "auto" | boolean; - /** - * Indicates whether imports should be organized via an "ordinal" (binary) comparison using the numeric value - * of their code points, or via "unicode" collation (via the - * [Unicode Collation Algorithm](https://unicode.org/reports/tr10/#Scope)) using rules associated with the locale - * specified in {@link organizeImportsCollationLocale}. - * - * Default: `"ordinal"`. - */ - readonly organizeImportsCollation?: "ordinal" | "unicode"; - /** - * Indicates the locale to use for "unicode" collation. If not specified, the locale `"en"` is used as an invariant - * for the sake of consistent sorting. Use `"auto"` to use the detected UI locale. - * - * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. - * - * Default: `"en"` - */ - readonly organizeImportsCollationLocale?: string; - /** - * Indicates whether numeric collation should be used for digit sequences in strings. When `true`, will collate - * strings such that `a1z < a2z < a100z`. When `false`, will collate strings such that `a1z < a100z < a2z`. - * - * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. - * - * Default: `false` - */ - readonly organizeImportsNumericCollation?: boolean; - /** - * Indicates whether accents and other diacritic marks are considered unequal for the purpose of collation. When - * `true`, characters with accents and other diacritics will be collated in the order defined by the locale specified - * in {@link organizeImportsCollationLocale}. - * - * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. - * - * Default: `true` - */ - readonly organizeImportsAccentCollation?: boolean; - /** - * Indicates whether upper case or lower case should sort first. When `false`, the default order for the locale - * specified in {@link organizeImportsCollationLocale} is used. - * - * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. This preference is also - * ignored if we are using case-insensitive sorting, which occurs when {@link organizeImportsIgnoreCase} is `true`, - * or if {@link organizeImportsIgnoreCase} is `"auto"` and the auto-detected case sensitivity is determined to be - * case-insensitive. - * - * Default: `false` - */ - readonly organizeImportsCaseFirst?: "upper" | "lower" | false; - /** - * Indicates where named type-only imports should sort. "inline" sorts named imports without regard to if the import is - * type-only. - * - * Default: `last` - */ - readonly organizeImportsTypeOrder?: "last" | "first" | "inline"; - /** - * Indicates whether {@link ReferencesResponseItem.lineText} is supported. - */ - readonly disableLineTextInReferences?: boolean; - /** - * Indicates whether to exclude standard library and node_modules file symbols from navTo results. - */ - readonly excludeLibrarySymbolsInNavTo?: boolean; - } - interface CompilerOptions { - allowJs?: boolean; - allowSyntheticDefaultImports?: boolean; - allowUnreachableCode?: boolean; - allowUnusedLabels?: boolean; - alwaysStrict?: boolean; - baseUrl?: string; - /** @deprecated */ - charset?: string; - checkJs?: boolean; - declaration?: boolean; - declarationDir?: string; - disableSizeLimit?: boolean; - downlevelIteration?: boolean; - emitBOM?: boolean; - emitDecoratorMetadata?: boolean; - experimentalDecorators?: boolean; - forceConsistentCasingInFileNames?: boolean; - importHelpers?: boolean; - inlineSourceMap?: boolean; - inlineSources?: boolean; - isolatedModules?: boolean; - jsx?: JsxEmit | ts.JsxEmit; - lib?: string[]; - locale?: string; - mapRoot?: string; - maxNodeModuleJsDepth?: number; - module?: ModuleKind | ts.ModuleKind; - moduleResolution?: ModuleResolutionKind | ts.ModuleResolutionKind; - newLine?: NewLineKind | ts.NewLineKind; - noEmit?: boolean; - noEmitHelpers?: boolean; - noEmitOnError?: boolean; - noErrorTruncation?: boolean; - noFallthroughCasesInSwitch?: boolean; - noImplicitAny?: boolean; - noImplicitReturns?: boolean; - noImplicitThis?: boolean; - noUnusedLocals?: boolean; - noUnusedParameters?: boolean; - /** @deprecated */ - noImplicitUseStrict?: boolean; - noLib?: boolean; - noResolve?: boolean; - /** @deprecated */ - out?: string; - outDir?: string; - outFile?: string; - paths?: MapLike; - plugins?: PluginImport[]; - preserveConstEnums?: boolean; - preserveSymlinks?: boolean; - project?: string; - reactNamespace?: string; - removeComments?: boolean; - references?: ProjectReference[]; - rootDir?: string; - rootDirs?: string[]; - skipLibCheck?: boolean; - skipDefaultLibCheck?: boolean; - sourceMap?: boolean; - sourceRoot?: string; - strict?: boolean; - strictNullChecks?: boolean; - /** @deprecated */ - suppressExcessPropertyErrors?: boolean; - /** @deprecated */ - suppressImplicitAnyIndexErrors?: boolean; - useDefineForClassFields?: boolean; - target?: ScriptTarget | ts.ScriptTarget; - traceResolution?: boolean; - resolveJsonModule?: boolean; - types?: string[]; - /** Paths used to used to compute primary types search locations */ - typeRoots?: string[]; - [option: string]: CompilerOptionsValue | undefined; - } - enum JsxEmit { - None = "None", - Preserve = "Preserve", - ReactNative = "ReactNative", - React = "React", - } - enum ModuleKind { - None = "None", - CommonJS = "CommonJS", - AMD = "AMD", - UMD = "UMD", - System = "System", - ES6 = "ES6", - ES2015 = "ES2015", - ESNext = "ESNext", - Node16 = "Node16", - NodeNext = "NodeNext", - Preserve = "Preserve", - } - enum ModuleResolutionKind { - Classic = "Classic", + export type EditorSettings = ChangePropertyTypes; + export type FormatCodeSettings = ChangePropertyTypes; + export type CompilerOptions = ChangePropertyTypes, { + jsx: JsxEmit | ts.JsxEmit; + module: ModuleKind | ts.ModuleKind; + moduleResolution: ModuleResolutionKind | ts.ModuleResolutionKind; + newLine: NewLineKind | ts.NewLineKind; + target: ScriptTarget | ts.ScriptTarget; + }>; + export enum JsxEmit { + None = "none", + Preserve = "preserve", + ReactNative = "react-native", + React = "react", + ReactJSX = "react-jsx", + ReactJSXDev = "react-jsxdev", + } + export enum ModuleKind { + None = "none", + CommonJS = "commonjs", + AMD = "amd", + UMD = "umd", + System = "system", + ES6 = "es6", + ES2015 = "es2015", + ES2020 = "es2020", + ES2022 = "es2022", + ESNext = "esnext", + Node16 = "node16", + NodeNext = "nodenext", + Preserve = "preserve", + } + export enum ModuleResolutionKind { + Classic = "classic", /** @deprecated Renamed to `Node10` */ - Node = "Node", - Node10 = "Node10", - Node16 = "Node16", - NodeNext = "NodeNext", - Bundler = "Bundler", + Node = "node", + /** @deprecated Renamed to `Node10` */ + NodeJs = "node", + Node10 = "node10", + Node16 = "node16", + NodeNext = "nodenext", + Bundler = "bundler", } - enum NewLineKind { + export enum NewLineKind { Crlf = "Crlf", Lf = "Lf", } - enum ScriptTarget { + export enum ScriptTarget { /** @deprecated */ - ES3 = "ES3", - ES5 = "ES5", - ES6 = "ES6", - ES2015 = "ES2015", - ES2016 = "ES2016", - ES2017 = "ES2017", - ES2018 = "ES2018", - ES2019 = "ES2019", - ES2020 = "ES2020", - ES2021 = "ES2021", - ES2022 = "ES2022", - ESNext = "ESNext", - } - enum ClassificationType { - comment = 1, - identifier = 2, - keyword = 3, - numericLiteral = 4, - operator = 5, - stringLiteral = 6, - regularExpressionLiteral = 7, - whiteSpace = 8, - text = 9, - punctuation = 10, - className = 11, - enumName = 12, - interfaceName = 13, - moduleName = 14, - typeParameterName = 15, - typeAliasName = 16, - parameterName = 17, - docCommentTagName = 18, - jsxOpenTagName = 19, - jsxCloseTagName = 20, - jsxSelfClosingTagName = 21, - jsxAttribute = 22, - jsxText = 23, - jsxAttributeStringLiteralValue = 24, - bigintLiteral = 25, + ES3 = "es3", + ES5 = "es5", + ES6 = "es6", + ES2015 = "es2015", + ES2016 = "es2016", + ES2017 = "es2017", + ES2018 = "es2018", + ES2019 = "es2019", + ES2020 = "es2020", + ES2021 = "es2021", + ES2022 = "es2022", + ESNext = "esnext", + JSON = "json", + Latest = "esnext", } } namespace typingsInstaller { @@ -3147,6 +2465,90 @@ declare namespace ts { protected readonly latestDistTag = "latest"; } } + type ActionSet = "action::set"; + type ActionInvalidate = "action::invalidate"; + type ActionPackageInstalled = "action::packageInstalled"; + type EventTypesRegistry = "event::typesRegistry"; + type EventBeginInstallTypes = "event::beginInstallTypes"; + type EventEndInstallTypes = "event::endInstallTypes"; + type EventInitializationFailed = "event::initializationFailed"; + type ActionWatchTypingLocations = "action::watchTypingLocations"; + interface TypingInstallerResponse { + readonly kind: ActionSet | ActionInvalidate | EventTypesRegistry | ActionPackageInstalled | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed | ActionWatchTypingLocations; + } + interface TypingInstallerRequestWithProjectName { + readonly projectName: string; + } + interface DiscoverTypings extends TypingInstallerRequestWithProjectName { + readonly fileNames: string[]; + readonly projectRootPath: Path; + readonly compilerOptions: CompilerOptions; + readonly typeAcquisition: TypeAcquisition; + readonly unresolvedImports: SortedReadonlyArray; + readonly cachePath?: string; + readonly kind: "discover"; + } + interface CloseProject extends TypingInstallerRequestWithProjectName { + readonly kind: "closeProject"; + } + interface TypesRegistryRequest { + readonly kind: "typesRegistry"; + } + interface InstallPackageRequest extends TypingInstallerRequestWithProjectName { + readonly kind: "installPackage"; + readonly fileName: Path; + readonly packageName: string; + readonly projectRootPath: Path; + readonly id: number; + } + interface PackageInstalledResponse extends ProjectResponse { + readonly kind: ActionPackageInstalled; + readonly id: number; + readonly success: boolean; + readonly message: string; + } + interface InitializationFailedResponse extends TypingInstallerResponse { + readonly kind: EventInitializationFailed; + readonly message: string; + readonly stack?: string; + } + interface ProjectResponse extends TypingInstallerResponse { + readonly projectName: string; + } + interface InvalidateCachedTypings extends ProjectResponse { + readonly kind: ActionInvalidate; + } + interface InstallTypes extends ProjectResponse { + readonly kind: EventBeginInstallTypes | EventEndInstallTypes; + readonly eventId: number; + readonly typingsInstallerVersion: string; + readonly packagesToInstall: readonly string[]; + } + interface BeginInstallTypes extends InstallTypes { + readonly kind: EventBeginInstallTypes; + } + interface EndInstallTypes extends InstallTypes { + readonly kind: EventEndInstallTypes; + readonly installSuccess: boolean; + } + interface InstallTypingHost extends JsTyping.TypingResolutionHost { + useCaseSensitiveFileNames: boolean; + writeFile(path: string, content: string): void; + createDirectory(path: string): void; + getCurrentDirectory?(): string; + } + interface SetTypings extends ProjectResponse { + readonly typeAcquisition: TypeAcquisition; + readonly compilerOptions: CompilerOptions; + readonly typings: string[]; + readonly unresolvedImports: SortedReadonlyArray; + readonly kind: ActionSet; + } + interface WatchTypingLocations extends ProjectResponse { + /** if files is undefined, retain same set of watchers */ + readonly files: readonly string[] | undefined; + readonly kind: ActionWatchTypingLocations; + } interface CompressedData { length: number; compressionKind: string; @@ -4145,6 +3547,14 @@ declare namespace ts { responseRequired?: boolean; } } + namespace JsTyping { + interface TypingResolutionHost { + directoryExists(path: string): boolean; + fileExists(fileName: string): boolean; + readFile(path: string, encoding?: string): string | undefined; + readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[] | undefined, depth?: number): string[]; + } + } const versionMajorMinor = "5.5"; /** The version of the TypeScript compiler release */ const version: string; @@ -8719,13 +8129,49 @@ declare namespace ts { interface UserPreferences { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; + /** + * If enabled, TypeScript will search through all external modules' exports and add them to the completions list. + * This affects lone identifier completions but not completions on the right hand side of `obj.`. + */ readonly includeCompletionsForModuleExports?: boolean; + /** + * Enables auto-import-style completions on partially-typed import statements. E.g., allows + * `import write|` to be completed to `import { writeFile } from "fs"`. + */ readonly includeCompletionsForImportStatements?: boolean; + /** + * Allows completions to be formatted with snippet text, indicated by `CompletionItem["isSnippet"]`. + */ readonly includeCompletionsWithSnippetText?: boolean; + /** + * Unless this option is `false`, or `includeCompletionsWithInsertText` is not enabled, + * member completion lists triggered with `.` will include entries on potentially-null and potentially-undefined + * values, with insertion text to replace preceding `.` tokens with `?.`. + */ readonly includeAutomaticOptionalChainCompletions?: boolean; + /** + * If enabled, the completion list will include completions with invalid identifier names. + * For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`. + */ readonly includeCompletionsWithInsertText?: boolean; + /** + * If enabled, completions for class members (e.g. methods and properties) will include + * a whole declaration for the member. + * E.g., `class A { f| }` could be completed to `class A { foo(): number {} }`, instead of + * `class A { foo }`. + */ readonly includeCompletionsWithClassMemberSnippets?: boolean; + /** + * If enabled, object literal methods will have a method declaration completion entry in addition + * to the regular completion entry containing just the method name. + * E.g., `const objectLiteral: T = { f| }` could be completed to `const objectLiteral: T = { foo(): void {} }`, + * in addition to `const objectLiteral: T = { foo }`. + */ readonly includeCompletionsWithObjectLiteralMethodSnippets?: boolean; + /** + * Indicates whether {@link CompletionEntry.labelDetails completion entry label details} are supported. + * If not, contents of `labelDetails` may be included in the {@link CompletionEntry.name} property. + */ readonly useLabelDetailsInCompletionEntries?: boolean; readonly allowIncompleteCompletions?: boolean; readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative"; @@ -8748,14 +8194,74 @@ declare namespace ts { readonly allowRenameOfImportPath?: boolean; readonly autoImportFileExcludePatterns?: string[]; readonly preferTypeOnlyAutoImports?: boolean; + /** + * Indicates whether imports should be organized in a case-insensitive manner. + */ readonly organizeImportsIgnoreCase?: "auto" | boolean; + /** + * Indicates whether imports should be organized via an "ordinal" (binary) comparison using the numeric value + * of their code points, or via "unicode" collation (via the + * [Unicode Collation Algorithm](https://unicode.org/reports/tr10/#Scope)) using rules associated with the locale + * specified in {@link organizeImportsCollationLocale}. + * + * Default: `"ordinal"`. + */ readonly organizeImportsCollation?: "ordinal" | "unicode"; + /** + * Indicates the locale to use for "unicode" collation. If not specified, the locale `"en"` is used as an invariant + * for the sake of consistent sorting. Use `"auto"` to use the detected UI locale. + * + * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. + * + * Default: `"en"` + */ readonly organizeImportsLocale?: string; + /** + * Indicates whether numeric collation should be used for digit sequences in strings. When `true`, will collate + * strings such that `a1z < a2z < a100z`. When `false`, will collate strings such that `a1z < a100z < a2z`. + * + * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. + * + * Default: `false` + */ readonly organizeImportsNumericCollation?: boolean; + /** + * Indicates whether accents and other diacritic marks are considered unequal for the purpose of collation. When + * `true`, characters with accents and other diacritics will be collated in the order defined by the locale specified + * in {@link organizeImportsCollationLocale}. + * + * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. + * + * Default: `true` + */ readonly organizeImportsAccentCollation?: boolean; + /** + * Indicates whether upper case or lower case should sort first. When `false`, the default order for the locale + * specified in {@link organizeImportsCollationLocale} is used. + * + * This preference is ignored if {@link organizeImportsCollation} is not `"unicode"`. This preference is also + * ignored if we are using case-insensitive sorting, which occurs when {@link organizeImportsIgnoreCase} is `true`, + * or if {@link organizeImportsIgnoreCase} is `"auto"` and the auto-detected case sensitivity is determined to be + * case-insensitive. + * + * Default: `false` + */ readonly organizeImportsCaseFirst?: "upper" | "lower" | false; + /** + * Indicates where named type-only imports should sort. "inline" sorts named imports without regard to if the import is + * type-only. + * + * Default: `last` + */ readonly organizeImportsTypeOrder?: "first" | "last" | "inline"; + /** + * Indicates whether to exclude standard library and node_modules file symbols from navTo results. + */ readonly excludeLibrarySymbolsInNavTo?: boolean; + readonly lazyConfiguredProjectsFromExternalProject?: boolean; + readonly displayPartsForJSDoc?: boolean; + readonly generateReturnInDocTemplate?: boolean; + readonly disableLineTextInReferences?: boolean; } /** Represents a bigint literal value without requiring bigint support */ interface PseudoBigInt { @@ -10299,14 +9805,6 @@ declare namespace ts { emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult | undefined; } type InvalidatedProject = UpdateOutputFileStampsProject | BuildInvalidedProject; - namespace JsTyping { - interface TypingResolutionHost { - directoryExists(path: string): boolean; - fileExists(fileName: string): boolean; - readFile(path: string, encoding?: string): string | undefined; - readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[] | undefined, depth?: number): string[]; - } - } function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings; /** * Represents an immutable snapshot of a script at a specified time.Once acquired, the @@ -11041,7 +10539,13 @@ declare namespace ts { linkText = 24, } interface SymbolDisplayPart { + /** + * Text of an item describing the symbol. + */ text: string; + /** + * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). + */ kind: string; } interface JSDocLinkDisplayPart extends SymbolDisplayPart { @@ -11093,6 +10597,9 @@ declare namespace ts { interface InteractiveRefactorArguments { targetFile: string; } + /** + * Signature help information for a single parameter + */ interface SignatureHelpParameter { name: string; documentation: SymbolDisplayPart[]; @@ -11187,9 +10694,25 @@ declare namespace ts { name: string; kind: ScriptElementKind; kindModifiers?: string; + /** + * A string that is used for comparing completion items so that they can be ordered. This + * is often the same as the name but may be different in certain circumstances. + */ sortText: string; + /** + * Text to insert instead of `name`. + * This is used to support bracketed completions; If `name` might be "a-b" but `insertText` would be `["a-b"]`, + * coupled with `replacementSpan` to replace a dotted access with a bracket access. + */ insertText?: string; + /** + * A string that should be used when filtering a set of + * completion items. + */ filterText?: string; + /** + * `insertText` should be interpreted as a snippet if true. + */ isSnippet?: true; /** * An optional span that indicates the text to be replaced by this completion item. @@ -11197,13 +10720,43 @@ declare namespace ts { * It will be set if the required span differs from the one generated by the default replacement behavior. */ replacementSpan?: TextSpan; + /** + * Indicates whether commiting this completion entry will require additional code actions to be + * made to avoid errors. The CompletionEntryDetails will have these actions. + */ hasAction?: true; + /** + * Identifier (not necessarily human-readable) identifying where this completion came from. + */ source?: string; + /** + * Human-readable description of the `source`. + */ sourceDisplay?: SymbolDisplayPart[]; + /** + * Additional details for the label. + */ labelDetails?: CompletionEntryLabelDetails; + /** + * If true, this completion should be highlighted as recommended. There will only be one of these. + * This will be set when we know the user should write an expression with a certain type and that type is an enum or constructable class. + * Then either that enum/class or a namespace containing it will be the recommended symbol. + */ isRecommended?: true; + /** + * If true, this completion was generated from traversing the name table of an unchecked JS file, + * and therefore may not be accurate. + */ isFromUncheckedFile?: true; + /** + * If true, this completion was for an auto-import of a module not yet in the program, but listed + * in the project package.json. Used for telemetry reporting. + */ isPackageJsonImport?: true; + /** + * If true, this completion was an auto-import-style completion of an import statement (i.e., the + * module specifier was inserted along with the imported identifier). Used for telemetry reporting. + */ isImportStatementCompletion?: true; /** * For API purposes. @@ -11222,7 +10775,17 @@ declare namespace ts { data?: CompletionEntryData; } interface CompletionEntryLabelDetails { + /** + * An optional string which is rendered less prominently directly after + * {@link CompletionEntry.name name}, without any spacing. Should be + * used for function signatures or type annotations. + */ detail?: string; + /** + * An optional string which is rendered less prominently after + * {@link CompletionEntryLabelDetails.detail}. Should be used for fully qualified + * names or file path. + */ description?: string; } interface CompletionEntryDetails { diff --git a/tests/baselines/reference/tsserver/cachingFileSystemInformation/loads-missing-files-from-disk.js b/tests/baselines/reference/tsserver/cachingFileSystemInformation/loads-missing-files-from-disk.js index b1e4f91280152..903a86cb3ad53 100644 --- a/tests/baselines/reference/tsserver/cachingFileSystemInformation/loads-missing-files-from-disk.js +++ b/tests/baselines/reference/tsserver/cachingFileSystemInformation/loads-missing-files-from-disk.js @@ -10,7 +10,7 @@ Info seq [hh:mm:ss:mss] request: "command": "compilerOptionsForInferredProjects", "arguments": { "options": { - "module": "AMD", + "module": "amd", "noLib": true } }, diff --git a/tests/baselines/reference/tsserver/cachingFileSystemInformation/works-using-legacy-resolution-logic.js b/tests/baselines/reference/tsserver/cachingFileSystemInformation/works-using-legacy-resolution-logic.js index acb51aec23219..fedebb9988f7e 100644 --- a/tests/baselines/reference/tsserver/cachingFileSystemInformation/works-using-legacy-resolution-logic.js +++ b/tests/baselines/reference/tsserver/cachingFileSystemInformation/works-using-legacy-resolution-logic.js @@ -13,7 +13,7 @@ Info seq [hh:mm:ss:mss] request: "command": "compilerOptionsForInferredProjects", "arguments": { "options": { - "module": "AMD", + "module": "amd", "noLib": true } }, @@ -303,9 +303,9 @@ Info seq [hh:mm:ss:mss] request: "command": "compilerOptionsForInferredProjects", "arguments": { "options": { - "module": "AMD", + "module": "amd", "noLib": true, - "target": "ES5" + "target": "es5" } }, "seq": 3, diff --git a/tests/baselines/reference/tsserver/dynamicFiles/dynamic-file-without-external-project.js b/tests/baselines/reference/tsserver/dynamicFiles/dynamic-file-without-external-project.js index cd2dc8bad452b..ef43af169c024 100644 --- a/tests/baselines/reference/tsserver/dynamicFiles/dynamic-file-without-external-project.js +++ b/tests/baselines/reference/tsserver/dynamicFiles/dynamic-file-without-external-project.js @@ -20,7 +20,7 @@ Info seq [hh:mm:ss:mss] request: "command": "compilerOptionsForInferredProjects", "arguments": { "options": { - "module": "CommonJS", + "module": "commonjs", "allowJs": true, "allowSyntheticDefaultImports": true, "allowNonTsExtensions": true diff --git a/tests/baselines/reference/tsserver/inferredProjects/Setting-compiler-options-for-inferred-projects-when-there-are-no-open-files-should-not-schedule-any-refresh.js b/tests/baselines/reference/tsserver/inferredProjects/Setting-compiler-options-for-inferred-projects-when-there-are-no-open-files-should-not-schedule-any-refresh.js index 9cfae312918b0..8cfcadfced669 100644 --- a/tests/baselines/reference/tsserver/inferredProjects/Setting-compiler-options-for-inferred-projects-when-there-are-no-open-files-should-not-schedule-any-refresh.js +++ b/tests/baselines/reference/tsserver/inferredProjects/Setting-compiler-options-for-inferred-projects-when-there-are-no-open-files-should-not-schedule-any-refresh.js @@ -24,7 +24,7 @@ Info seq [hh:mm:ss:mss] request: "arguments": { "options": { "allowJs": true, - "target": "ES2015" + "target": "es2015" } }, "seq": 1, diff --git a/tests/baselines/reference/tsserver/inferredProjects/inferred-projects-per-project-root-with-case-insensitive-system.js b/tests/baselines/reference/tsserver/inferredProjects/inferred-projects-per-project-root-with-case-insensitive-system.js index 75c117b846bff..398582e7b446a 100644 --- a/tests/baselines/reference/tsserver/inferredProjects/inferred-projects-per-project-root-with-case-insensitive-system.js +++ b/tests/baselines/reference/tsserver/inferredProjects/inferred-projects-per-project-root-with-case-insensitive-system.js @@ -20,7 +20,7 @@ Info seq [hh:mm:ss:mss] request: "arguments": { "options": { "allowJs": true, - "target": "ESNext" + "target": "esnext" } }, "seq": 1, @@ -41,7 +41,7 @@ Info seq [hh:mm:ss:mss] request: "arguments": { "options": { "allowJs": true, - "target": "ES2015" + "target": "es2015" }, "projectRootPath": "/a" }, @@ -2249,7 +2249,7 @@ Info seq [hh:mm:ss:mss] request: "arguments": { "options": { "allowJs": true, - "target": "ES2017" + "target": "es2017" }, "projectRootPath": "/A" }, diff --git a/tests/baselines/reference/tsserver/inferredProjects/inferred-projects-per-project-root-with-case-sensitive-system.js b/tests/baselines/reference/tsserver/inferredProjects/inferred-projects-per-project-root-with-case-sensitive-system.js index d1428aeb6a7ef..2a97bba89aea6 100644 --- a/tests/baselines/reference/tsserver/inferredProjects/inferred-projects-per-project-root-with-case-sensitive-system.js +++ b/tests/baselines/reference/tsserver/inferredProjects/inferred-projects-per-project-root-with-case-sensitive-system.js @@ -20,7 +20,7 @@ Info seq [hh:mm:ss:mss] request: "arguments": { "options": { "allowJs": true, - "target": "ESNext" + "target": "esnext" } }, "seq": 1, @@ -41,7 +41,7 @@ Info seq [hh:mm:ss:mss] request: "arguments": { "options": { "allowJs": true, - "target": "ES2015" + "target": "es2015" }, "projectRootPath": "/a" }, @@ -2348,7 +2348,7 @@ Info seq [hh:mm:ss:mss] request: "arguments": { "options": { "allowJs": true, - "target": "ES2017" + "target": "es2017" }, "projectRootPath": "/A" }, diff --git a/tests/baselines/reference/tsserver/inferredProjects/inferred-projects-per-project-root.js b/tests/baselines/reference/tsserver/inferredProjects/inferred-projects-per-project-root.js index 2ac5fc794cb21..fa64347230086 100644 --- a/tests/baselines/reference/tsserver/inferredProjects/inferred-projects-per-project-root.js +++ b/tests/baselines/reference/tsserver/inferredProjects/inferred-projects-per-project-root.js @@ -20,7 +20,7 @@ Info seq [hh:mm:ss:mss] request: "arguments": { "options": { "allowJs": true, - "target": "ESNext" + "target": "esnext" } }, "seq": 1, @@ -41,7 +41,7 @@ Info seq [hh:mm:ss:mss] request: "arguments": { "options": { "allowJs": true, - "target": "ES2015" + "target": "es2015" }, "projectRootPath": "/b" }, diff --git a/tests/baselines/reference/tsserver/inferredProjects/project-settings-for-inferred-projects.js b/tests/baselines/reference/tsserver/inferredProjects/project-settings-for-inferred-projects.js index 9d40956068f46..eea7d0699723e 100644 --- a/tests/baselines/reference/tsserver/inferredProjects/project-settings-for-inferred-projects.js +++ b/tests/baselines/reference/tsserver/inferredProjects/project-settings-for-inferred-projects.js @@ -128,7 +128,7 @@ Info seq [hh:mm:ss:mss] request: "command": "compilerOptionsForInferredProjects", "arguments": { "options": { - "moduleResolution": "Classic" + "moduleResolution": "classic" } }, "seq": 3, diff --git a/tests/baselines/reference/tsserver/maxNodeModuleJsDepth/should-be-set-to-2-if-the-project-has-js-root-files.js b/tests/baselines/reference/tsserver/maxNodeModuleJsDepth/should-be-set-to-2-if-the-project-has-js-root-files.js index eed4c77b18b9b..546988acec8be 100644 --- a/tests/baselines/reference/tsserver/maxNodeModuleJsDepth/should-be-set-to-2-if-the-project-has-js-root-files.js +++ b/tests/baselines/reference/tsserver/maxNodeModuleJsDepth/should-be-set-to-2-if-the-project-has-js-root-files.js @@ -222,7 +222,7 @@ Info seq [hh:mm:ss:mss] request: "command": "compilerOptionsForInferredProjects", "arguments": { "options": { - "target": "ES2016" + "target": "es2016" } }, "seq": 2, diff --git a/tests/baselines/reference/tsserver/projectErrors/for-external-project.js b/tests/baselines/reference/tsserver/projectErrors/for-external-project.js index 374a170e5b585..dba0cf1c8a841 100644 --- a/tests/baselines/reference/tsserver/projectErrors/for-external-project.js +++ b/tests/baselines/reference/tsserver/projectErrors/for-external-project.js @@ -271,7 +271,7 @@ Info seq [hh:mm:ss:mss] request: } ], "options": { - "module": "CommonJS" + "module": "commonjs" } }, "seq": 3, diff --git a/tests/baselines/reference/tsserver/projectErrors/for-inferred-project.js b/tests/baselines/reference/tsserver/projectErrors/for-inferred-project.js index aa620791a2779..d3ae6d1493b85 100644 --- a/tests/baselines/reference/tsserver/projectErrors/for-inferred-project.js +++ b/tests/baselines/reference/tsserver/projectErrors/for-inferred-project.js @@ -232,7 +232,7 @@ Info seq [hh:mm:ss:mss] request: "command": "compilerOptionsForInferredProjects", "arguments": { "options": { - "module": "CommonJS" + "module": "commonjs" } }, "seq": 3, diff --git a/tests/baselines/reference/tsserver/projects/syntax-tree-cache-handles-changes-in-project-settings.js b/tests/baselines/reference/tsserver/projects/syntax-tree-cache-handles-changes-in-project-settings.js index 7d01f10316d01..ad33ac05354e5 100644 --- a/tests/baselines/reference/tsserver/projects/syntax-tree-cache-handles-changes-in-project-settings.js +++ b/tests/baselines/reference/tsserver/projects/syntax-tree-cache-handles-changes-in-project-settings.js @@ -10,7 +10,7 @@ Info seq [hh:mm:ss:mss] request: "command": "compilerOptionsForInferredProjects", "arguments": { "options": { - "target": "ES5", + "target": "es5", "allowJs": false } }, @@ -128,7 +128,7 @@ Info seq [hh:mm:ss:mss] request: "command": "compilerOptionsForInferredProjects", "arguments": { "options": { - "target": "ES5", + "target": "es5", "allowJs": true } }, diff --git a/tests/baselines/reference/tsserver/typingsInstaller/projectRootPath-is-provided-for-inferred-project.js b/tests/baselines/reference/tsserver/typingsInstaller/projectRootPath-is-provided-for-inferred-project.js index 2ec4f69a29922..70e40a3b282bb 100644 --- a/tests/baselines/reference/tsserver/typingsInstaller/projectRootPath-is-provided-for-inferred-project.js +++ b/tests/baselines/reference/tsserver/typingsInstaller/projectRootPath-is-provided-for-inferred-project.js @@ -37,9 +37,9 @@ Info seq [hh:mm:ss:mss] request: "command": "compilerOptionsForInferredProjects", "arguments": { "options": { - "module": "CommonJS", - "target": "ES2016", - "jsx": "Preserve", + "module": "commonjs", + "target": "es2016", + "jsx": "preserve", "experimentalDecorators": true, "allowJs": true, "allowSyntheticDefaultImports": true,