• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import {
2    BuilderProgram, CancellationToken, CompilerHost, CompilerOptions, ConditionCheckResult, CustomTransformers,
3    Diagnostic, DiagnosticWithLocation, DocumentHighlights, DocumentPositionMapper, EmitOutput, ESMap, ExportInfoMap,
4    FileCheckModuleInfo, FileReference, GetEffectiveTypeRootsHost, HasChangedAutomaticTypeDirectiveNames,
5    HasInvalidatedResolutions, JsDocNodeCheckConfig, JsDocTagInfo, LineAndCharacter, MinimalResolutionCacheHost,
6    ModuleKind, ModuleResolutionCache, ModuleSpecifierCache, ParsedCommandLine, Path, Program, ProjectReference,
7    ResolvedModule, ResolvedModuleWithFailedLookupLocations, ResolvedProjectReference, ResolvedTypeReferenceDirective,
8    ScriptKind, Set, SourceFile, SourceFileLike, SourceMapper, Symbol, SymbolDisplayPart, SymlinkCache, TextChangeRange,
9    textChanges, TextRange, TextSpan, UserPreferences,
10} from "./_namespaces/ts";
11
12declare module "../compiler/types" {
13    // Module transform: converted from interface augmentation
14    export interface Node {
15        getSourceFile(): SourceFile;
16        getChildCount(sourceFile?: SourceFile): number;
17        getChildAt(index: number, sourceFile?: SourceFile): Node;
18        getChildren(sourceFile?: SourceFile): Node[];
19        /** @internal */
20        getChildren(sourceFile?: SourceFileLike): Node[]; // eslint-disable-line @typescript-eslint/unified-signatures
21        getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number;
22        /** @internal */
23        getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number; // eslint-disable-line @typescript-eslint/unified-signatures
24        getFullStart(): number;
25        getEnd(): number;
26        getWidth(sourceFile?: SourceFileLike): number;
27        getFullWidth(): number;
28        getLeadingTriviaWidth(sourceFile?: SourceFile): number;
29        getFullText(sourceFile?: SourceFile): string;
30        getText(sourceFile?: SourceFile): string;
31        getFirstToken(sourceFile?: SourceFile): Node | undefined;
32        /** @internal */
33        getFirstToken(sourceFile?: SourceFileLike): Node | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
34        getLastToken(sourceFile?: SourceFile): Node | undefined;
35        /** @internal */
36        getLastToken(sourceFile?: SourceFileLike): Node | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
37        // See ts.forEachChild for documentation.
38        forEachChild<T>(cbNode: (node: Node) => T | undefined, cbNodeArray?: (nodes: NodeArray<Node>) => T | undefined): T | undefined;
39    }
40}
41
42declare module "../compiler/types" {
43    // Module transform: converted from interface augmentation
44    export interface Identifier {
45        readonly text: string;
46    }
47}
48
49declare module "../compiler/types" {
50    // Module transform: converted from interface augmentation
51    export interface PrivateIdentifier {
52        readonly text: string;
53    }
54}
55
56declare module "../compiler/types" {
57    // Module transform: converted from interface augmentation
58    export interface Symbol {
59        readonly name: string;
60        getFlags(): SymbolFlags;
61        getEscapedName(): __String;
62        getName(): string;
63        getDeclarations(): Declaration[] | undefined;
64        getDocumentationComment(typeChecker: TypeChecker | undefined): SymbolDisplayPart[];
65        /** @internal */
66        getContextualDocumentationComment(context: Node | undefined, checker: TypeChecker | undefined): SymbolDisplayPart[]
67        getJsDocTags(checker?: TypeChecker): JSDocTagInfo[];
68        /** @internal */
69        getContextualJsDocTags(context: Node | undefined, checker: TypeChecker | undefined): JSDocTagInfo[];
70    }
71}
72
73declare module "../compiler/types" {
74    // Module transform: converted from interface augmentation
75    export interface Type {
76        getFlags(): TypeFlags;
77        getSymbol(): Symbol | undefined;
78        getProperties(): Symbol[];
79        getProperty(propertyName: string): Symbol | undefined;
80        getApparentProperties(): Symbol[];
81        getCallSignatures(): readonly Signature[];
82        getConstructSignatures(): readonly Signature[];
83        getStringIndexType(): Type | undefined;
84        getNumberIndexType(): Type | undefined;
85        getBaseTypes(): BaseType[] | undefined;
86        getNonNullableType(): Type;
87        /** @internal */ getNonOptionalType(): Type;
88        /** @internal */ isNullableType(): boolean;
89        getConstraint(): Type | undefined;
90        getDefault(): Type | undefined;
91
92        isUnion(): this is UnionType;
93        isIntersection(): this is IntersectionType;
94        isUnionOrIntersection(): this is UnionOrIntersectionType;
95        isLiteral(): this is LiteralType;
96        isStringLiteral(): this is StringLiteralType;
97        isNumberLiteral(): this is NumberLiteralType;
98        isTypeParameter(): this is TypeParameter;
99        isClassOrInterface(): this is InterfaceType;
100        isClass(): this is InterfaceType;
101        isIndexType(): this is IndexType;
102    }
103}
104
105declare module "../compiler/types" {
106    // Module transform: converted from interface augmentation
107    export interface TypeReference {
108        typeArguments?: readonly Type[];
109    }
110}
111
112declare module "../compiler/types" {
113    // Module transform: converted from interface augmentation
114    export interface Signature {
115        getDeclaration(): SignatureDeclaration;
116        getTypeParameters(): TypeParameter[] | undefined;
117        getParameters(): Symbol[];
118        getTypeParameterAtPosition(pos: number): Type;
119        getReturnType(): Type;
120        getDocumentationComment(typeChecker: TypeChecker | undefined): SymbolDisplayPart[];
121        getJsDocTags(): JSDocTagInfo[];
122    }
123}
124
125declare module "../compiler/types" {
126    // Module transform: converted from interface augmentation
127    export interface SourceFile {
128        /** @internal */ version: string;
129        /** @internal */ scriptSnapshot: IScriptSnapshot | undefined;
130        /** @internal */ nameTable: UnderscoreEscapedMap<number> | undefined;
131
132        /** @internal */ getNamedDeclarations(): ESMap<string, readonly Declaration[]>;
133
134        getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
135        getLineEndOfPosition(pos: number): number;
136        getLineStarts(): readonly number[];
137        getPositionOfLineAndCharacter(line: number, character: number): number;
138        update(newText: string, textChangeRange: TextChangeRange): SourceFile;
139
140        /** @internal */ sourceMapper?: DocumentPositionMapper;
141    }
142}
143
144declare module "../compiler/types" {
145    // Module transform: converted from interface augmentation
146    export interface SourceFileLike {
147        getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
148    }
149}
150
151declare module "../compiler/types" {
152    // Module transform: converted from interface augmentation
153    export interface SourceMapSource {
154        getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
155    }
156}
157
158/**
159 * Represents an immutable snapshot of a script at a specified time.Once acquired, the
160 * snapshot is observably immutable. i.e. the same calls with the same parameters will return
161 * the same values.
162 */
163// eslint-disable-next-line @typescript-eslint/naming-convention
164export interface IScriptSnapshot {
165    /** Gets a portion of the script snapshot specified by [start, end). */
166    getText(start: number, end: number): string;
167
168    /** Gets the length of this script snapshot. */
169    getLength(): number;
170
171    /**
172     * Gets the TextChangeRange that describe how the text changed between this text and
173     * an older version.  This information is used by the incremental parser to determine
174     * what sections of the script need to be re-parsed.  'undefined' can be returned if the
175     * change range cannot be determined.  However, in that case, incremental parsing will
176     * not happen and the entire document will be re - parsed.
177     */
178    getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange | undefined;
179
180    /** Releases all resources held by this script snapshot */
181    dispose?(): void;
182}
183
184export namespace ScriptSnapshot {
185    class StringScriptSnapshot implements IScriptSnapshot {
186
187        constructor(private text: string) {
188        }
189
190        public getText(start: number, end: number): string {
191            return start === 0 && end === this.text.length
192                ? this.text
193                : this.text.substring(start, end);
194        }
195
196        public getLength(): number {
197            return this.text.length;
198        }
199
200        public getChangeRange(): TextChangeRange | undefined {
201            // Text-based snapshots do not support incremental parsing. Return undefined
202            // to signal that to the caller.
203            return undefined;
204        }
205    }
206
207    export function fromString(text: string): IScriptSnapshot {
208        return new StringScriptSnapshot(text);
209    }
210}
211
212export interface PreProcessedFileInfo {
213    referencedFiles: FileReference[];
214    typeReferenceDirectives: FileReference[];
215    libReferenceDirectives: FileReference[];
216    importedFiles: FileReference[];
217    ambientExternalModules?: string[];
218    isLibFile: boolean;
219}
220
221export interface HostCancellationToken {
222    isCancellationRequested(): boolean;
223}
224
225export interface InstallPackageOptions {
226    fileName: Path;
227    packageName: string;
228}
229
230/** @internal */
231export const enum PackageJsonDependencyGroup {
232    Dependencies         = 1 << 0,
233    DevDependencies      = 1 << 1,
234    PeerDependencies     = 1 << 2,
235    OptionalDependencies = 1 << 3,
236    All = Dependencies | DevDependencies | PeerDependencies | OptionalDependencies,
237}
238
239/** @internal */
240export interface ProjectPackageJsonInfo {
241    fileName: string;
242    parseable: boolean;
243    dependencies?: ESMap<string, string>;
244    devDependencies?: ESMap<string, string>;
245    peerDependencies?: ESMap<string, string>;
246    optionalDependencies?: ESMap<string, string>;
247    get(dependencyName: string, inGroups?: PackageJsonDependencyGroup): string | undefined;
248    has(dependencyName: string, inGroups?: PackageJsonDependencyGroup): boolean;
249}
250
251/** @internal */
252export interface FormattingHost {
253    getNewLine?(): string;
254}
255
256/** @internal */
257export const enum PackageJsonAutoImportPreference {
258    Off,
259    On,
260    Auto,
261}
262
263export interface PerformanceEvent {
264    kind: "UpdateGraph" | "CreatePackageJsonAutoImportProvider";
265    durationMs: number;
266}
267
268export enum LanguageServiceMode {
269    Semantic,
270    PartialSemantic,
271    Syntactic,
272}
273
274export interface IncompleteCompletionsCache {
275    get(): CompletionInfo | undefined;
276    set(response: CompletionInfo): void;
277    clear(): void;
278}
279
280//
281// Public interface of the host of a language service instance.
282//
283export interface LanguageServiceHost extends GetEffectiveTypeRootsHost, MinimalResolutionCacheHost {
284    getCompilationSettings(): CompilerOptions;
285    getNewLine?(): string;
286    getProjectVersion?(): string;
287    getScriptFileNames(): string[];
288    getScriptKind?(fileName: string): ScriptKind;
289    getScriptVersion(fileName: string): string;
290    getScriptSnapshot(fileName: string): IScriptSnapshot | undefined;
291    getProjectReferences?(): readonly ProjectReference[] | undefined;
292    getLocalizedDiagnosticMessages?(): any;
293    getCancellationToken?(): HostCancellationToken;
294    getCurrentDirectory(): string;
295    getDefaultLibFileName(options: CompilerOptions): string;
296    log?(s: string): void;
297    trace?(s: string): void;
298    error?(s: string): void;
299    useCaseSensitiveFileNames?(): boolean;
300
301    /*
302     * LS host can optionally implement these methods to support completions for module specifiers.
303     * Without these methods, only completions for ambient modules will be provided.
304     */
305    readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[];
306    realpath?(path: string): string;
307
308    /*
309     * Unlike `realpath and `readDirectory`, `readFile` and `fileExists` are now _required_
310     * to properly acquire and setup source files under module: node16+ modes.
311     */
312    readFile(path: string, encoding?: string): string | undefined;
313    fileExists(path: string): boolean;
314
315    /*
316     * LS host can optionally implement these methods to support automatic updating when new type libraries are installed
317     */
318    getTypeRootsVersion?(): number;
319
320    /*
321     * LS host can optionally implement this method if it wants to be completely in charge of module name resolution.
322     * if implementation is omitted then language service will use built-in module resolution logic and get answers to
323     * host specific questions using 'getScriptSnapshot'.
324     *
325     * If this is implemented, `getResolvedModuleWithFailedLookupLocationsFromCache` should be too.
326     */
327    resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
328    getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined;
329    resolveTypeReferenceDirectives?(typeDirectiveNames: string[] | FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
330    /** @internal */ hasInvalidatedResolutions?: HasInvalidatedResolutions;
331    /** @internal */ hasChangedAutomaticTypeDirectiveNames?: HasChangedAutomaticTypeDirectiveNames;
332    /** @internal */ getGlobalTypingsCacheLocation?(): string | undefined;
333    /** @internal */ getSymlinkCache?(files?: readonly SourceFile[]): SymlinkCache;
334    /* Lets the Program from a AutoImportProviderProject use its host project's ModuleResolutionCache */
335    /** @internal */ getModuleResolutionCache?(): ModuleResolutionCache | undefined;
336
337    /*
338     * Required for full import and type reference completions.
339     * These should be unprefixed names. E.g. `getDirectories("/foo/bar")` should return `["a", "b"]`, not `["/foo/bar/a", "/foo/bar/b"]`.
340     */
341    getDirectories?(directoryName: string): string[];
342
343    /**
344     * Gets a set of custom transformers to use during emit.
345     */
346    getCustomTransformers?(): CustomTransformers | undefined;
347
348    isKnownTypesPackageName?(name: string): boolean;
349    installPackage?(options: InstallPackageOptions): Promise<ApplyCodeActionCommandResult>;
350    writeFile?(fileName: string, content: string): void;
351
352    /** @internal */ getDocumentPositionMapper?(generatedFileName: string, sourceFileName?: string): DocumentPositionMapper | undefined;
353    /** @internal */ getSourceFileLike?(fileName: string): SourceFileLike | undefined;
354    /** @internal */ getPackageJsonsVisibleToFile?(fileName: string, rootDir?: string): readonly ProjectPackageJsonInfo[];
355    /** @internal */ getNearestAncestorDirectoryWithPackageJson?(fileName: string): string | undefined;
356    /** @internal */ getPackageJsonsForAutoImport?(rootDir?: string): readonly ProjectPackageJsonInfo[];
357    /** @internal */ getCachedExportInfoMap?(): ExportInfoMap;
358    /** @internal */ getModuleSpecifierCache?(): ModuleSpecifierCache;
359    /** @internal */ setCompilerHost?(host: CompilerHost): void;
360    /** @internal */ useSourceOfProjectReferenceRedirect?(): boolean;
361    /** @internal */ getPackageJsonAutoImportProvider?(): Program | undefined;
362    /** @internal */ sendPerformanceEvent?(kind: PerformanceEvent["kind"], durationMs: number): void;
363    getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
364    /** @internal */ onReleaseParsedCommandLine?(configFileName: string, oldResolvedRef: ResolvedProjectReference | undefined, optionOptions: CompilerOptions): void;
365    /** @internal */ getIncompleteCompletionsCache?(): IncompleteCompletionsCache;
366    getJsDocNodeCheckedConfig?(jsDocFileCheckInfo: FileCheckModuleInfo, symbolSourceFilePath: string): JsDocNodeCheckConfig;
367    getJsDocNodeConditionCheckedResult?(jsDocFileCheckedInfo: FileCheckModuleInfo, jsDocs: JsDocTagInfo[]): ConditionCheckResult;
368    getFileCheckedModuleInfo?(containFilePath: string): FileCheckModuleInfo;
369    shouldCompletionSortCustom?: boolean;
370    uiProps?: Set<string>;
371    clearProps?(): void;
372    clearFileCache?(): void;
373    isStaticSourceFile?(fileName: string): boolean;
374}
375
376/** @internal */
377export const emptyOptions = {};
378
379export type WithMetadata<T> = T & { metadata?: unknown; };
380
381export const enum SemanticClassificationFormat {
382    Original = "original",
383    TwentyTwenty = "2020"
384}
385
386//
387// Public services of a language service instance associated
388// with a language service host instance
389//
390export interface LanguageService {
391    /** This is used as a part of restarting the language service. */
392    cleanupSemanticCache(): void;
393
394    /**
395     * Gets errors indicating invalid syntax in a file.
396     *
397     * In English, "this cdeo have, erorrs" is syntactically invalid because it has typos,
398     * grammatical errors, and misplaced punctuation. Likewise, examples of syntax
399     * errors in TypeScript are missing parentheses in an `if` statement, mismatched
400     * curly braces, and using a reserved keyword as a variable name.
401     *
402     * These diagnostics are inexpensive to compute and don't require knowledge of
403     * other files. Note that a non-empty result increases the likelihood of false positives
404     * from `getSemanticDiagnostics`.
405     *
406     * While these represent the majority of syntax-related diagnostics, there are some
407     * that require the type system, which will be present in `getSemanticDiagnostics`.
408     *
409     * @param fileName A path to the file you want syntactic diagnostics for
410     */
411    getSyntacticDiagnostics(fileName: string): DiagnosticWithLocation[];
412
413    /**
414     * Gets warnings or errors indicating type system issues in a given file.
415     * Requesting semantic diagnostics may start up the type system and
416     * run deferred work, so the first call may take longer than subsequent calls.
417     *
418     * Unlike the other get*Diagnostics functions, these diagnostics can potentially not
419     * include a reference to a source file. Specifically, the first time this is called,
420     * it will return global diagnostics with no associated location.
421     *
422     * To contrast the differences between semantic and syntactic diagnostics, consider the
423     * sentence: "The sun is green." is syntactically correct; those are real English words with
424     * correct sentence structure. However, it is semantically invalid, because it is not true.
425     *
426     * @param fileName A path to the file you want semantic diagnostics for
427     */
428    getSemanticDiagnostics(fileName: string): Diagnostic[];
429
430    /**
431     * Gets suggestion diagnostics for a specific file. These diagnostics tend to
432     * proactively suggest refactors, as opposed to diagnostics that indicate
433     * potentially incorrect runtime behavior.
434     *
435     * @param fileName A path to the file you want semantic diagnostics for
436     */
437    getSuggestionDiagnostics(fileName: string): DiagnosticWithLocation[];
438
439    // TODO: Rename this to getProgramDiagnostics to better indicate that these are any
440    // diagnostics present for the program level, and not just 'options' diagnostics.
441
442    /**
443     * Gets global diagnostics related to the program configuration and compiler options.
444     */
445    getCompilerOptionsDiagnostics(): Diagnostic[];
446
447    /** @deprecated Use getEncodedSyntacticClassifications instead. */
448    getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
449    getSyntacticClassifications(fileName: string, span: TextSpan, format: SemanticClassificationFormat): ClassifiedSpan[] | ClassifiedSpan2020[];
450
451    /** @deprecated Use getEncodedSemanticClassifications instead. */
452    getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
453    getSemanticClassifications(fileName: string, span: TextSpan, format: SemanticClassificationFormat): ClassifiedSpan[] | ClassifiedSpan2020[];
454
455    /** Encoded as triples of [start, length, ClassificationType]. */
456    getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications;
457
458    /**
459     * Gets semantic highlights information for a particular file. Has two formats, an older
460     * version used by VS and a format used by VS Code.
461     *
462     * @param fileName The path to the file
463     * @param position A text span to return results within
464     * @param format Which format to use, defaults to "original"
465     * @returns a number array encoded as triples of [start, length, ClassificationType, ...].
466     */
467    getEncodedSemanticClassifications(fileName: string, span: TextSpan, format?: SemanticClassificationFormat): Classifications;
468
469    /**
470     * Gets completion entries at a particular position in a file.
471     *
472     * @param fileName The path to the file
473     * @param position A zero-based index of the character where you want the entries
474     * @param options An object describing how the request was triggered and what kinds
475     * of code actions can be returned with the completions.
476     * @param formattingSettings settings needed for calling formatting functions.
477     */
478    getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined, formattingSettings?: FormatCodeSettings): WithMetadata<CompletionInfo> | undefined;
479
480    /**
481     * Gets the extended details for a completion entry retrieved from `getCompletionsAtPosition`.
482     *
483     * @param fileName The path to the file
484     * @param position A zero based index of the character where you want the entries
485     * @param entryName The `name` from an existing completion which came from `getCompletionsAtPosition`
486     * @param formatOptions How should code samples in the completions be formatted, can be undefined for backwards compatibility
487     * @param source `source` property from the completion entry
488     * @param preferences User settings, can be undefined for backwards compatibility
489     * @param data `data` property from the completion entry
490     */
491    getCompletionEntryDetails(
492        fileName: string,
493        position: number,
494        entryName: string,
495        formatOptions: FormatCodeOptions | FormatCodeSettings | undefined,
496        source: string | undefined,
497        preferences: UserPreferences | undefined,
498        data: CompletionEntryData | undefined,
499    ): CompletionEntryDetails | undefined;
500
501    getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol | undefined;
502
503    /**
504     * Gets semantic information about the identifier at a particular position in a
505     * file. Quick info is what you typically see when you hover in an editor.
506     *
507     * @param fileName The path to the file
508     * @param position A zero-based index of the character where you want the quick info
509     */
510    getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined;
511
512    getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined;
513
514    getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined;
515
516    getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined;
517
518    getRenameInfo(fileName: string, position: number, preferences: UserPreferences): RenameInfo;
519    /** @deprecated Use the signature with `UserPreferences` instead. */
520    getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo;
521
522    findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): readonly RenameLocation[] | undefined;
523
524    getSmartSelectionRange(fileName: string, position: number): SelectionRange;
525
526    /** @internal */
527    // eslint-disable-next-line @typescript-eslint/unified-signatures
528    getDefinitionAtPosition(fileName: string, position: number, searchOtherFilesOnly: false, stopAtAlias: boolean): readonly DefinitionInfo[] | undefined;
529    /** @internal */
530    // eslint-disable-next-line @typescript-eslint/unified-signatures
531    getDefinitionAtPosition(fileName: string, position: number, searchOtherFilesOnly: boolean, stopAtAlias: false): readonly DefinitionInfo[] | undefined;
532    getDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined;
533    getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined;
534    getTypeDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined;
535    getImplementationAtPosition(fileName: string, position: number): readonly ImplementationLocation[] | undefined;
536
537    getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined;
538    findReferences(fileName: string, position: number): ReferencedSymbol[] | undefined;
539    getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined;
540    getFileReferences(fileName: string): ReferenceEntry[];
541
542    /** @deprecated */
543    getOccurrencesAtPosition(fileName: string, position: number): readonly ReferenceEntry[] | undefined;
544
545    getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[];
546    getNavigationBarItems(fileName: string): NavigationBarItem[];
547    getNavigationTree(fileName: string): NavigationTree;
548
549    prepareCallHierarchy(fileName: string, position: number): CallHierarchyItem | CallHierarchyItem[] | undefined;
550    provideCallHierarchyIncomingCalls(fileName: string, position: number): CallHierarchyIncomingCall[];
551    provideCallHierarchyOutgoingCalls(fileName: string, position: number): CallHierarchyOutgoingCall[];
552
553    provideInlayHints(fileName: string, span: TextSpan, preferences: UserPreferences | undefined): InlayHint[]
554
555    getOutliningSpans(fileName: string): OutliningSpan[];
556    getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
557    getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[];
558    getIndentationAtPosition(fileName: string, position: number, options: EditorOptions | EditorSettings): number;
559
560    getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
561    getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
562    getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
563
564    getDocCommentTemplateAtPosition(fileName: string, position: number, options?: DocCommentTemplateOptions): TextInsertion | undefined;
565
566    isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
567    /**
568     * This will return a defined result if the position is after the `>` of the opening tag, or somewhere in the text, of a JSXElement with no closing tag.
569     * Editors should call this after `>` is typed.
570     */
571    getJsxClosingTagAtPosition(fileName: string, position: number): JsxClosingTagInfo | undefined;
572
573    getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined;
574
575    toLineColumnOffset?(fileName: string, position: number): LineAndCharacter;
576    /** @internal */
577    getSourceMapper(): SourceMapper;
578    /** @internal */
579    clearSourceMapperCache(): void;
580
581    getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: readonly number[], formatOptions: FormatCodeSettings, preferences: UserPreferences): readonly CodeFixAction[];
582    getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions;
583
584    applyCodeActionCommand(action: CodeActionCommand, formatSettings?: FormatCodeSettings): Promise<ApplyCodeActionCommandResult>;
585    applyCodeActionCommand(action: CodeActionCommand[], formatSettings?: FormatCodeSettings): Promise<ApplyCodeActionCommandResult[]>;
586    applyCodeActionCommand(action: CodeActionCommand | CodeActionCommand[], formatSettings?: FormatCodeSettings): Promise<ApplyCodeActionCommandResult | ApplyCodeActionCommandResult[]>;
587    /** @deprecated `fileName` will be ignored */
588    applyCodeActionCommand(fileName: string, action: CodeActionCommand): Promise<ApplyCodeActionCommandResult>;
589    /** @deprecated `fileName` will be ignored */
590    applyCodeActionCommand(fileName: string, action: CodeActionCommand[]): Promise<ApplyCodeActionCommandResult[]>;
591    /** @deprecated `fileName` will be ignored */
592    applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise<ApplyCodeActionCommandResult | ApplyCodeActionCommandResult[]>;
593
594    getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined, triggerReason?: RefactorTriggerReason, kind?: string): ApplicableRefactorInfo[];
595    getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined): RefactorEditInfo | undefined;
596    organizeImports(args: OrganizeImportsArgs, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[];
597    getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[];
598
599    getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean, forceDtsEmit?: boolean): EmitOutput;
600
601    getProgram(): Program | undefined;
602    getBuilderProgram(): BuilderProgram | undefined;
603    /** @internal */ getCurrentProgram(): Program | undefined;
604
605    /** @internal */ getNonBoundSourceFile(fileName: string): SourceFile;
606    /** @internal */ getAutoImportProvider(): Program | undefined;
607
608    /// Returns true if a suitable symbol was found in the project.
609    /// May set isDefinition properties in `referencedSymbols` to false.
610    /// May add elements to `knownSymbolSpans`.
611    /** @internal */ updateIsDefinitionOfReferencedSymbols(referencedSymbols: readonly ReferencedSymbol[], knownSymbolSpans: Set<DocumentSpan>): boolean;
612
613    toggleLineComment(fileName: string, textRange: TextRange): TextChange[];
614    toggleMultilineComment(fileName: string, textRange: TextRange): TextChange[];
615    commentSelection(fileName: string, textRange: TextRange): TextChange[];
616    uncommentSelection(fileName: string, textRange: TextRange): TextChange[];
617
618    dispose(): void;
619    updateRootFiles?(rootFiles: string[]): void;
620    // Returns arkui's collection of props
621    getProps?(propsSwitch: boolean): string[] | Set<string>;
622}
623
624export interface JsxClosingTagInfo {
625    readonly newText: string;
626}
627
628export interface CombinedCodeFixScope { type: "file"; fileName: string; }
629
630export const enum OrganizeImportsMode {
631    All = "All",
632    SortAndCombine = "SortAndCombine",
633    RemoveUnused = "RemoveUnused",
634}
635
636export interface OrganizeImportsArgs extends CombinedCodeFixScope {
637    /** @deprecated Use `mode` instead */
638    skipDestructiveCodeActions?: boolean;
639    mode?: OrganizeImportsMode;
640}
641
642export type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#" | " ";
643
644export const enum CompletionTriggerKind {
645    /** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */
646    Invoked = 1,
647
648    /** Completion was triggered by a trigger character. */
649    TriggerCharacter = 2,
650
651    /** Completion was re-triggered as the current completion list is incomplete. */
652    TriggerForIncompleteCompletions = 3,
653}
654
655export interface GetCompletionsAtPositionOptions extends UserPreferences {
656    /**
657     * If the editor is asking for completions because a certain character was typed
658     * (as opposed to when the user explicitly requested them) this should be set.
659     */
660    triggerCharacter?: CompletionsTriggerCharacter;
661    triggerKind?: CompletionTriggerKind;
662    /** @deprecated Use includeCompletionsForModuleExports */
663    includeExternalModuleExports?: boolean;
664    /** @deprecated Use includeCompletionsWithInsertText */
665    includeInsertTextCompletions?: boolean;
666}
667
668export type SignatureHelpTriggerCharacter = "," | "(" | "<";
669export type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")";
670
671export interface SignatureHelpItemsOptions {
672    triggerReason?: SignatureHelpTriggerReason;
673}
674
675export type SignatureHelpTriggerReason =
676    | SignatureHelpInvokedReason
677    | SignatureHelpCharacterTypedReason
678    | SignatureHelpRetriggeredReason;
679
680/**
681 * Signals that the user manually requested signature help.
682 * The language service will unconditionally attempt to provide a result.
683 */
684export interface SignatureHelpInvokedReason {
685    kind: "invoked";
686    triggerCharacter?: undefined;
687}
688
689/**
690 * Signals that the signature help request came from a user typing a character.
691 * Depending on the character and the syntactic context, the request may or may not be served a result.
692 */
693export interface SignatureHelpCharacterTypedReason {
694    kind: "characterTyped";
695    /**
696     * Character that was responsible for triggering signature help.
697     */
698    triggerCharacter: SignatureHelpTriggerCharacter;
699}
700
701/**
702 * Signals that this signature help request came from typing a character or moving the cursor.
703 * This should only occur if a signature help session was already active and the editor needs to see if it should adjust.
704 * The language service will unconditionally attempt to provide a result.
705 * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move.
706 */
707export interface SignatureHelpRetriggeredReason {
708    kind: "retrigger";
709    /**
710     * Character that was responsible for triggering signature help.
711     */
712    triggerCharacter?: SignatureHelpRetriggerCharacter;
713}
714
715export interface ApplyCodeActionCommandResult {
716    successMessage: string;
717}
718
719export interface Classifications {
720    spans: number[];
721    endOfLineState: EndOfLineState;
722}
723
724export interface ClassifiedSpan {
725    textSpan: TextSpan;
726    classificationType: ClassificationTypeNames;
727}
728
729export interface ClassifiedSpan2020 {
730    textSpan: TextSpan;
731    classificationType: number;
732}
733
734/**
735 * Navigation bar interface designed for visual studio's dual-column layout.
736 * This does not form a proper tree.
737 * The navbar is returned as a list of top-level items, each of which has a list of child items.
738 * Child items always have an empty array for their `childItems`.
739 */
740export interface NavigationBarItem {
741    text: string;
742    kind: ScriptElementKind;
743    kindModifiers: string;
744    spans: TextSpan[];
745    childItems: NavigationBarItem[];
746    indent: number;
747    bolded: boolean;
748    grayed: boolean;
749}
750
751/**
752 * Node in a tree of nested declarations in a file.
753 * The top node is always a script or module node.
754 */
755export interface NavigationTree {
756    /** Name of the declaration, or a short description, e.g. "<class>". */
757    text: string;
758    kind: ScriptElementKind;
759    /** ScriptElementKindModifier separated by commas, e.g. "public,abstract" */
760    kindModifiers: string;
761    /**
762     * Spans of the nodes that generated this declaration.
763     * There will be more than one if this is the result of merging.
764     */
765    spans: TextSpan[];
766    nameSpan: TextSpan | undefined;
767    /** Present if non-empty */
768    childItems?: NavigationTree[];
769}
770
771export interface CallHierarchyItem {
772    name: string;
773    kind: ScriptElementKind;
774    kindModifiers?: string;
775    file: string;
776    span: TextSpan;
777    selectionSpan: TextSpan;
778    containerName?: string;
779}
780
781export interface CallHierarchyIncomingCall {
782    from: CallHierarchyItem;
783    fromSpans: TextSpan[];
784}
785
786export interface CallHierarchyOutgoingCall {
787    to: CallHierarchyItem;
788    fromSpans: TextSpan[];
789}
790
791export const enum InlayHintKind {
792    Type = "Type",
793    Parameter = "Parameter",
794    Enum = "Enum",
795}
796
797export interface InlayHint {
798    text: string;
799    position: number;
800    kind: InlayHintKind;
801    whitespaceBefore?: boolean;
802    whitespaceAfter?: boolean;
803}
804
805export interface TodoCommentDescriptor {
806    text: string;
807    priority: number;
808}
809
810export interface TodoComment {
811    descriptor: TodoCommentDescriptor;
812    message: string;
813    position: number;
814}
815
816export interface TextChange {
817    span: TextSpan;
818    newText: string;
819}
820
821export interface FileTextChanges {
822    fileName: string;
823    textChanges: readonly TextChange[];
824    isNewFile?: boolean;
825}
826
827export interface CodeAction {
828    /** Description of the code action to display in the UI of the editor */
829    description: string;
830    /** Text changes to apply to each file as part of the code action */
831    changes: FileTextChanges[];
832    /**
833     * If the user accepts the code fix, the editor should send the action back in a `applyAction` request.
834     * This allows the language service to have side effects (e.g. installing dependencies) upon a code fix.
835     */
836    commands?: CodeActionCommand[];
837}
838
839export interface CodeFixAction extends CodeAction {
840    /** Short name to identify the fix, for use by telemetry. */
841    fixName: string;
842    /**
843     * If present, one may call 'getCombinedCodeFix' with this fixId.
844     * This may be omitted to indicate that the code fix can't be applied in a group.
845     */
846    fixId?: {};
847    fixAllDescription?: string;
848}
849
850export interface CombinedCodeActions {
851    changes: readonly FileTextChanges[];
852    commands?: readonly CodeActionCommand[];
853}
854
855// Publicly, this type is just `{}`. Internally it is a union of all the actions we use.
856// See `commands?: {}[]` in protocol.ts
857export type CodeActionCommand = InstallPackageAction;
858
859export interface InstallPackageAction {
860    /** @internal */ readonly type: "install package";
861    /** @internal */ readonly file: string;
862    /** @internal */ readonly packageName: string;
863}
864
865/**
866 * A set of one or more available refactoring actions, grouped under a parent refactoring.
867 */
868export interface ApplicableRefactorInfo {
869    /**
870     * The programmatic name of the refactoring
871     */
872    name: string;
873    /**
874     * A description of this refactoring category to show to the user.
875     * If the refactoring gets inlined (see below), this text will not be visible.
876     */
877    description: string;
878    /**
879     * Inlineable refactorings can have their actions hoisted out to the top level
880     * of a context menu. Non-inlineanable refactorings should always be shown inside
881     * their parent grouping.
882     *
883     * If not specified, this value is assumed to be 'true'
884     */
885    inlineable?: boolean;
886
887    actions: RefactorActionInfo[];
888}
889
890/**
891 * Represents a single refactoring action - for example, the "Extract Method..." refactor might
892 * offer several actions, each corresponding to a surround class or closure to extract into.
893 */
894export interface RefactorActionInfo {
895    /**
896     * The programmatic name of the refactoring action
897     */
898    name: string;
899
900    /**
901     * A description of this refactoring action to show to the user.
902     * If the parent refactoring is inlined away, this will be the only text shown,
903     * so this description should make sense by itself if the parent is inlineable=true
904     */
905    description: string;
906
907    /**
908     * A message to show to the user if the refactoring cannot be applied in
909     * the current context.
910     */
911    notApplicableReason?: string;
912
913    /**
914     * The hierarchical dotted name of the refactor action.
915     */
916    kind?: string;
917}
918
919/**
920 * A set of edits to make in response to a refactor action, plus an optional
921 * location where renaming should be invoked from
922 */
923export interface RefactorEditInfo {
924    edits: FileTextChanges[];
925    renameFilename?: string ;
926    renameLocation?: number;
927    commands?: CodeActionCommand[];
928}
929
930export type RefactorTriggerReason = "implicit" | "invoked";
931
932export interface TextInsertion {
933    newText: string;
934    /** The position in newText the caret should point to after the insertion. */
935    caretOffset: number;
936}
937
938export interface DocumentSpan {
939    textSpan: TextSpan;
940    fileName: string;
941
942    /**
943     * If the span represents a location that was remapped (e.g. via a .d.ts.map file),
944     * then the original filename and span will be specified here
945     */
946    originalTextSpan?: TextSpan;
947    originalFileName?: string;
948
949    /**
950     * If DocumentSpan.textSpan is the span for name of the declaration,
951     * then this is the span for relevant declaration
952     */
953    contextSpan?: TextSpan;
954    originalContextSpan?: TextSpan;
955}
956
957export interface RenameLocation extends DocumentSpan {
958    readonly prefixText?: string;
959    readonly suffixText?: string;
960}
961
962export interface ReferenceEntry extends DocumentSpan {
963    isWriteAccess: boolean;
964    isInString?: true;
965}
966
967export interface ImplementationLocation extends DocumentSpan {
968    kind: ScriptElementKind;
969    displayParts: SymbolDisplayPart[];
970}
971
972export const enum HighlightSpanKind {
973    none = "none",
974    definition = "definition",
975    reference = "reference",
976    writtenReference = "writtenReference",
977}
978
979export interface HighlightSpan {
980    fileName?: string;
981    isInString?: true;
982    textSpan: TextSpan;
983    contextSpan?: TextSpan;
984    kind: HighlightSpanKind;
985}
986
987export interface NavigateToItem {
988    name: string;
989    kind: ScriptElementKind;
990    kindModifiers: string;
991    matchKind: "exact" | "prefix" | "substring" | "camelCase";
992    isCaseSensitive: boolean;
993    fileName: string;
994    textSpan: TextSpan;
995    containerName: string;
996    containerKind: ScriptElementKind;
997}
998
999export enum IndentStyle {
1000    None = 0,
1001    Block = 1,
1002    Smart = 2,
1003}
1004
1005export enum SemicolonPreference {
1006    Ignore = "ignore",
1007    Insert = "insert",
1008    Remove = "remove",
1009}
1010
1011/** @deprecated - consider using EditorSettings instead */
1012export interface EditorOptions {
1013    BaseIndentSize?: number;
1014    IndentSize: number;
1015    TabSize: number;
1016    NewLineCharacter: string;
1017    ConvertTabsToSpaces: boolean;
1018    IndentStyle: IndentStyle;
1019}
1020
1021// TODO: GH#18217 These are frequently asserted as defined
1022export interface EditorSettings {
1023    baseIndentSize?: number;
1024    indentSize?: number;
1025    tabSize?: number;
1026    newLineCharacter?: string;
1027    convertTabsToSpaces?: boolean;
1028    indentStyle?: IndentStyle;
1029    trimTrailingWhitespace?: boolean;
1030}
1031
1032/** @deprecated - consider using FormatCodeSettings instead */
1033export interface FormatCodeOptions extends EditorOptions {
1034    InsertSpaceAfterCommaDelimiter: boolean;
1035    InsertSpaceAfterSemicolonInForStatements: boolean;
1036    InsertSpaceBeforeAndAfterBinaryOperators: boolean;
1037    InsertSpaceAfterConstructor?: boolean;
1038    InsertSpaceAfterKeywordsInControlFlowStatements: boolean;
1039    InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean;
1040    InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
1041    InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
1042    InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean;
1043    InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
1044    InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
1045    InsertSpaceAfterTypeAssertion?: boolean;
1046    InsertSpaceBeforeFunctionParenthesis?: boolean;
1047    PlaceOpenBraceOnNewLineForFunctions: boolean;
1048    PlaceOpenBraceOnNewLineForControlBlocks: boolean;
1049    insertSpaceBeforeTypeAnnotation?: boolean;
1050}
1051
1052export interface FormatCodeSettings extends EditorSettings {
1053    readonly insertSpaceAfterCommaDelimiter?: boolean;
1054    readonly insertSpaceAfterSemicolonInForStatements?: boolean;
1055    readonly insertSpaceBeforeAndAfterBinaryOperators?: boolean;
1056    readonly insertSpaceAfterConstructor?: boolean;
1057    readonly insertSpaceAfterKeywordsInControlFlowStatements?: boolean;
1058    readonly insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean;
1059    readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean;
1060    readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean;
1061    readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean;
1062    readonly insertSpaceAfterOpeningAndBeforeClosingEmptyBraces?: boolean;
1063    readonly insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean;
1064    readonly insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
1065    readonly insertSpaceAfterTypeAssertion?: boolean;
1066    readonly insertSpaceBeforeFunctionParenthesis?: boolean;
1067    readonly placeOpenBraceOnNewLineForFunctions?: boolean;
1068    readonly placeOpenBraceOnNewLineForControlBlocks?: boolean;
1069    readonly insertSpaceBeforeTypeAnnotation?: boolean;
1070    readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean;
1071    readonly semicolons?: SemicolonPreference;
1072}
1073
1074export function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings {
1075    return {
1076        indentSize: 4,
1077        tabSize: 4,
1078        newLineCharacter: newLineCharacter || "\n",
1079        convertTabsToSpaces: true,
1080        indentStyle: IndentStyle.Smart,
1081        insertSpaceAfterConstructor: false,
1082        insertSpaceAfterCommaDelimiter: true,
1083        insertSpaceAfterSemicolonInForStatements: true,
1084        insertSpaceBeforeAndAfterBinaryOperators: true,
1085        insertSpaceAfterKeywordsInControlFlowStatements: true,
1086        insertSpaceAfterFunctionKeywordForAnonymousFunctions: false,
1087        insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
1088        insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
1089        insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true,
1090        insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false,
1091        insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false,
1092        insertSpaceBeforeFunctionParenthesis: false,
1093        placeOpenBraceOnNewLineForFunctions: false,
1094        placeOpenBraceOnNewLineForControlBlocks: false,
1095        semicolons: SemicolonPreference.Ignore,
1096        trimTrailingWhitespace: true
1097    };
1098}
1099
1100/** @internal */
1101export const testFormatSettings = getDefaultFormatCodeSettings("\n");
1102
1103export interface DefinitionInfo extends DocumentSpan {
1104    kind: ScriptElementKind;
1105    name: string;
1106    containerKind: ScriptElementKind;
1107    containerName: string;
1108    unverified?: boolean;
1109    /**
1110     * @internal
1111     * Initially, this value is determined syntactically, but it is updated by the checker to cover
1112     * cases like declarations that are exported in subsequent statements.  As a result, the value
1113     * may be "incomplete" if this span has yet to be checked.
1114     */
1115    isLocal?: boolean;
1116    /** @internal */ isAmbient?: boolean;
1117    /** @internal */ failedAliasResolution?: boolean;
1118}
1119
1120export interface DefinitionInfoAndBoundSpan {
1121    definitions?: readonly DefinitionInfo[];
1122    textSpan: TextSpan;
1123}
1124
1125export interface ReferencedSymbolDefinitionInfo extends DefinitionInfo {
1126    displayParts: SymbolDisplayPart[];
1127}
1128
1129export interface ReferencedSymbol {
1130    definition: ReferencedSymbolDefinitionInfo;
1131    references: ReferencedSymbolEntry[];
1132}
1133
1134export interface ReferencedSymbolEntry extends ReferenceEntry {
1135    isDefinition?: boolean;
1136}
1137
1138export enum SymbolDisplayPartKind {
1139    aliasName,
1140    className,
1141    enumName,
1142    fieldName,
1143    interfaceName,
1144    keyword,
1145    lineBreak,
1146    numericLiteral,
1147    stringLiteral,
1148    localName,
1149    methodName,
1150    moduleName,
1151    operator,
1152    parameterName,
1153    propertyName,
1154    punctuation,
1155    space,
1156    text,
1157    typeParameterName,
1158    enumMemberName,
1159    functionName,
1160    regularExpressionLiteral,
1161    link,
1162    linkName,
1163    linkText,
1164}
1165
1166declare module "../compiler/types" {
1167    // Module transform: converted from interface augmentation
1168    export interface SymbolDisplayPart {
1169        text: string;
1170        kind: string;
1171    }
1172}
1173
1174export interface JSDocLinkDisplayPart extends SymbolDisplayPart {
1175    target: DocumentSpan;
1176}
1177
1178export interface JSDocTagInfo {
1179    name: string;
1180    text?: SymbolDisplayPart[] | string;
1181    index?: number;
1182}
1183
1184export interface QuickInfo {
1185    kind: ScriptElementKind;
1186    kindModifiers: string;
1187    textSpan: TextSpan;
1188    displayParts?: SymbolDisplayPart[];
1189    documentation?: SymbolDisplayPart[];
1190    tags?: JSDocTagInfo[];
1191}
1192
1193export type RenameInfo = RenameInfoSuccess | RenameInfoFailure;
1194export interface RenameInfoSuccess {
1195    canRename: true;
1196    /**
1197     * File or directory to rename.
1198     * If set, `getEditsForFileRename` should be called instead of `findRenameLocations`.
1199     */
1200    fileToRename?: string;
1201    displayName: string;
1202    fullDisplayName: string;
1203    kind: ScriptElementKind;
1204    kindModifiers: string;
1205    triggerSpan: TextSpan;
1206}
1207export interface RenameInfoFailure {
1208    canRename: false;
1209    localizedErrorMessage: string;
1210}
1211
1212/**
1213 * @deprecated Use `UserPreferences` instead.
1214 */
1215export interface RenameInfoOptions {
1216    readonly allowRenameOfImportPath?: boolean;
1217}
1218
1219export interface DocCommentTemplateOptions {
1220    readonly generateReturnInDocTemplate?: boolean;
1221}
1222
1223export interface SignatureHelpParameter {
1224    name: string;
1225    documentation: SymbolDisplayPart[];
1226    displayParts: SymbolDisplayPart[];
1227    isOptional: boolean;
1228    isRest?: boolean;
1229}
1230
1231export interface SelectionRange {
1232    textSpan: TextSpan;
1233    parent?: SelectionRange;
1234}
1235
1236/**
1237 * Represents a single signature to show in signature help.
1238 * The id is used for subsequent calls into the language service to ask questions about the
1239 * signature help item in the context of any documents that have been updated.  i.e. after
1240 * an edit has happened, while signature help is still active, the host can ask important
1241 * questions like 'what parameter is the user currently contained within?'.
1242 */
1243export interface SignatureHelpItem {
1244    isVariadic: boolean;
1245    prefixDisplayParts: SymbolDisplayPart[];
1246    suffixDisplayParts: SymbolDisplayPart[];
1247    separatorDisplayParts: SymbolDisplayPart[];
1248    parameters: SignatureHelpParameter[];
1249    documentation: SymbolDisplayPart[];
1250    tags: JSDocTagInfo[];
1251}
1252
1253/**
1254 * Represents a set of signature help items, and the preferred item that should be selected.
1255 */
1256export interface SignatureHelpItems {
1257    items: SignatureHelpItem[];
1258    applicableSpan: TextSpan;
1259    selectedItemIndex: number;
1260    argumentIndex: number;
1261    argumentCount: number;
1262}
1263
1264// Do not change existing values, as they exist in telemetry.
1265export const enum CompletionInfoFlags {
1266    None = 0,
1267    MayIncludeAutoImports = 1 << 0,
1268    IsImportStatementCompletion = 1 << 1,
1269    IsContinuation = 1 << 2,
1270    ResolvedModuleSpecifiers = 1 << 3,
1271    ResolvedModuleSpecifiersBeyondLimit = 1 << 4,
1272    MayIncludeMethodSnippets = 1 << 5,
1273}
1274
1275export interface CompletionInfo {
1276    /** For performance telemetry. */
1277    flags?: CompletionInfoFlags;
1278    /** Not true for all global completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. */
1279    isGlobalCompletion: boolean;
1280    isMemberCompletion: boolean;
1281    /**
1282     * In the absence of `CompletionEntry["replacementSpan"]`, the editor may choose whether to use
1283     * this span or its default one. If `CompletionEntry["replacementSpan"]` is defined, that span
1284     * must be used to commit that completion entry.
1285     */
1286    optionalReplacementSpan?: TextSpan;
1287    /**
1288     * true when the current location also allows for a new identifier
1289     */
1290    isNewIdentifierLocation: boolean;
1291    /**
1292     * Indicates to client to continue requesting completions on subsequent keystrokes.
1293     */
1294    isIncomplete?: true;
1295    entries: CompletionEntry[];
1296}
1297
1298export interface CompletionEntryDataAutoImport {
1299    /**
1300     * The name of the property or export in the module's symbol table. Differs from the completion name
1301     * in the case of InternalSymbolName.ExportEquals and InternalSymbolName.Default.
1302     */
1303    exportName: string;
1304    moduleSpecifier?: string;
1305    /** The file name declaring the export's module symbol, if it was an external module */
1306    fileName?: string;
1307    /** The module name (with quotes stripped) of the export's module symbol, if it was an ambient module */
1308    ambientModuleName?: string;
1309    /** True if the export was found in the package.json AutoImportProvider */
1310    isPackageJsonImport?: true;
1311}
1312
1313export interface CompletionEntryDataUnresolved extends CompletionEntryDataAutoImport {
1314    /** The key in the `ExportMapCache` where the completion entry's `SymbolExportInfo[]` is found */
1315    exportMapKey: string;
1316}
1317
1318export interface CompletionEntryDataResolved extends CompletionEntryDataAutoImport {
1319    moduleSpecifier: string;
1320}
1321
1322export type CompletionEntryData = CompletionEntryDataUnresolved | CompletionEntryDataResolved;
1323
1324// see comments in protocol.ts
1325export interface CompletionEntry {
1326    name: string;
1327    kind: ScriptElementKind;
1328    kindModifiers?: string; // see ScriptElementKindModifier, comma separated
1329    sortText: string;
1330    insertText?: string;
1331    isSnippet?: true;
1332    /**
1333     * An optional span that indicates the text to be replaced by this completion item.
1334     * If present, this span should be used instead of the default one.
1335     * It will be set if the required span differs from the one generated by the default replacement behavior.
1336     */
1337    replacementSpan?: TextSpan;
1338    hasAction?: true;
1339    source?: string;
1340    sourceDisplay?: SymbolDisplayPart[];
1341    labelDetails?: CompletionEntryLabelDetails;
1342    isRecommended?: true;
1343    isFromUncheckedFile?: true;
1344    isPackageJsonImport?: true;
1345    isImportStatementCompletion?: true;
1346    /**
1347     * A property to be sent back to TS Server in the CompletionDetailsRequest, along with `name`,
1348     * that allows TS Server to look up the symbol represented by the completion item, disambiguating
1349     * items with the same name. Currently only defined for auto-import completions, but the type is
1350     * `unknown` in the protocol, so it can be changed as needed to support other kinds of completions.
1351     * The presence of this property should generally not be used to assume that this completion entry
1352     * is an auto-import.
1353     */
1354    data?: CompletionEntryData;
1355    jsDoc?: JSDocTagInfo[];
1356    displayParts?: SymbolDisplayPart[];
1357}
1358
1359export interface CompletionEntryLabelDetails {
1360    detail?: string;
1361    description?: string;
1362}
1363
1364export interface CompletionEntryDetails {
1365    name: string;
1366    kind: ScriptElementKind;
1367    kindModifiers: string;   // see ScriptElementKindModifier, comma separated
1368    displayParts: SymbolDisplayPart[];
1369    documentation?: SymbolDisplayPart[];
1370    tags?: JSDocTagInfo[];
1371    codeActions?: CodeAction[];
1372    /** @deprecated Use `sourceDisplay` instead. */
1373    source?: SymbolDisplayPart[];
1374    sourceDisplay?: SymbolDisplayPart[];
1375}
1376
1377export interface OutliningSpan {
1378    /** The span of the document to actually collapse. */
1379    textSpan: TextSpan;
1380
1381    /** The span of the document to display when the user hovers over the collapsed span. */
1382    hintSpan: TextSpan;
1383
1384    /** The text to display in the editor for the collapsed region. */
1385    bannerText: string;
1386
1387    /**
1388     * Whether or not this region should be automatically collapsed when
1389     * the 'Collapse to Definitions' command is invoked.
1390     */
1391    autoCollapse: boolean;
1392
1393    /**
1394     * Classification of the contents of the span
1395     */
1396    kind: OutliningSpanKind;
1397}
1398
1399export const enum OutliningSpanKind {
1400    /** Single or multi-line comments */
1401    Comment = "comment",
1402
1403    /** Sections marked by '// #region' and '// #endregion' comments */
1404    Region = "region",
1405
1406    /** Declarations and expressions */
1407    Code = "code",
1408
1409    /** Contiguous blocks of import declarations */
1410    Imports = "imports"
1411}
1412
1413export const enum OutputFileType {
1414    JavaScript,
1415    SourceMap,
1416    Declaration
1417}
1418
1419export const enum EndOfLineState {
1420    None,
1421    InMultiLineCommentTrivia,
1422    InSingleQuoteStringLiteral,
1423    InDoubleQuoteStringLiteral,
1424    InTemplateHeadOrNoSubstitutionTemplate,
1425    InTemplateMiddleOrTail,
1426    InTemplateSubstitutionPosition,
1427}
1428
1429export enum TokenClass {
1430    Punctuation,
1431    Keyword,
1432    Operator,
1433    Comment,
1434    Whitespace,
1435    Identifier,
1436    NumberLiteral,
1437    BigIntLiteral,
1438    StringLiteral,
1439    RegExpLiteral,
1440}
1441
1442export interface ClassificationResult {
1443    finalLexState: EndOfLineState;
1444    entries: ClassificationInfo[];
1445}
1446
1447export interface ClassificationInfo {
1448    length: number;
1449    classification: TokenClass;
1450}
1451
1452export interface Classifier {
1453    /**
1454     * Gives lexical classifications of tokens on a line without any syntactic context.
1455     * For instance, a token consisting of the text 'string' can be either an identifier
1456     * named 'string' or the keyword 'string', however, because this classifier is not aware,
1457     * it relies on certain heuristics to give acceptable results. For classifications where
1458     * speed trumps accuracy, this function is preferable; however, for true accuracy, the
1459     * syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
1460     * lexical, syntactic, and semantic classifiers may issue the best user experience.
1461     *
1462     * @param text                      The text of a line to classify.
1463     * @param lexState                  The state of the lexical classifier at the end of the previous line.
1464     * @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
1465     *                                  If there is no syntactic classifier (syntacticClassifierAbsent=true),
1466     *                                  certain heuristics may be used in its place; however, if there is a
1467     *                                  syntactic classifier (syntacticClassifierAbsent=false), certain
1468     *                                  classifications which may be incorrectly categorized will be given
1469     *                                  back as Identifiers in order to allow the syntactic classifier to
1470     *                                  subsume the classification.
1471     * @deprecated Use getLexicalClassifications instead.
1472     */
1473    getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
1474    getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications;
1475}
1476
1477export const enum ScriptElementKind {
1478    unknown = "",
1479    warning = "warning",
1480
1481    /** predefined type (void) or keyword (class) */
1482    keyword = "keyword",
1483
1484    /** top level script node */
1485    scriptElement = "script",
1486
1487    /** module foo {} */
1488    moduleElement = "module",
1489
1490    /** class X {} */
1491    classElement = "class",
1492
1493    /** var x = class X {} */
1494    localClassElement = "local class",
1495
1496    /** struct X {} */
1497    structElement = "struct",
1498
1499    /** interface Y {} */
1500    interfaceElement = "interface",
1501
1502    /** type T = ... */
1503    typeElement = "type",
1504
1505    /** enum E */
1506    enumElement = "enum",
1507    enumMemberElement = "enum member",
1508
1509    /**
1510     * Inside module and script only
1511     * const v = ..
1512     */
1513    variableElement = "var",
1514
1515    /** Inside function */
1516    localVariableElement = "local var",
1517
1518    /**
1519     * Inside module and script only
1520     * function f() { }
1521     */
1522    functionElement = "function",
1523
1524    /** Inside function */
1525    localFunctionElement = "local function",
1526
1527    /** class X { [public|private]* foo() {} } */
1528    memberFunctionElement = "method",
1529
1530    /** class X { [public|private]* [get|set] foo:number; } */
1531    memberGetAccessorElement = "getter",
1532    memberSetAccessorElement = "setter",
1533
1534    /**
1535     * class X { [public|private]* foo:number; }
1536     * interface Y { foo:number; }
1537     */
1538    memberVariableElement = "property",
1539
1540    /** class X { [public|private]* accessor foo: number; } */
1541    memberAccessorVariableElement = "accessor",
1542
1543    /**
1544     * class X { constructor() { } }
1545     * class X { static { } }
1546     */
1547    constructorImplementationElement = "constructor",
1548
1549    /** interface Y { ():number; } */
1550    callSignatureElement = "call",
1551
1552    /** interface Y { []:number; } */
1553    indexSignatureElement = "index",
1554
1555    /** interface Y { new():Y; } */
1556    constructSignatureElement = "construct",
1557
1558    /** function foo(*Y*: string) */
1559    parameterElement = "parameter",
1560
1561    typeParameterElement = "type parameter",
1562
1563    primitiveType = "primitive type",
1564
1565    label = "label",
1566
1567    alias = "alias",
1568
1569    constElement = "const",
1570
1571    letElement = "let",
1572
1573    directory = "directory",
1574
1575    externalModuleName = "external module name",
1576
1577    /**
1578     * <JsxTagName attribute1 attribute2={0} />
1579     * @deprecated
1580     */
1581    jsxAttribute = "JSX attribute",
1582
1583    /** String literal */
1584    string = "string",
1585
1586    /** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */
1587    link = "link",
1588
1589    /** Jsdoc @link: in `{@link C link text}`, the entity name "C" */
1590    linkName = "link name",
1591
1592    /** Jsdoc @link: in `{@link C link text}`, the link text "link text" */
1593    linkText = "link text",
1594}
1595
1596export const enum ScriptElementKindModifier {
1597    none = "",
1598    publicMemberModifier = "public",
1599    privateMemberModifier = "private",
1600    protectedMemberModifier = "protected",
1601    exportedModifier = "export",
1602    ambientModifier = "declare",
1603    staticModifier = "static",
1604    abstractModifier = "abstract",
1605    optionalModifier = "optional",
1606
1607    deprecatedModifier = "deprecated",
1608
1609    dtsModifier = ".d.ts",
1610    tsModifier = ".ts",
1611    tsxModifier = ".tsx",
1612    jsModifier = ".js",
1613    jsxModifier = ".jsx",
1614    jsonModifier = ".json",
1615    dmtsModifier = ".d.mts",
1616    mtsModifier = ".mts",
1617    mjsModifier = ".mjs",
1618    dctsModifier = ".d.cts",
1619    ctsModifier = ".cts",
1620    cjsModifier = ".cjs",
1621    etsModifier = ".ets",
1622    detsModifier = ".d.ets",
1623}
1624
1625export const enum ClassificationTypeNames {
1626    comment = "comment",
1627    identifier = "identifier",
1628    keyword = "keyword",
1629    numericLiteral = "number",
1630    bigintLiteral = "bigint",
1631    operator = "operator",
1632    stringLiteral = "string",
1633    whiteSpace = "whitespace",
1634    text = "text",
1635
1636    punctuation = "punctuation",
1637
1638    className = "class name",
1639    enumName = "enum name",
1640    interfaceName = "interface name",
1641    moduleName = "module name",
1642    typeParameterName = "type parameter name",
1643    typeAliasName = "type alias name",
1644    parameterName = "parameter name",
1645    docCommentTagName = "doc comment tag name",
1646    jsxOpenTagName = "jsx open tag name",
1647    jsxCloseTagName = "jsx close tag name",
1648    jsxSelfClosingTagName = "jsx self closing tag name",
1649    jsxAttribute = "jsx attribute",
1650    jsxText = "jsx text",
1651    jsxAttributeStringLiteralValue = "jsx attribute string literal value",
1652}
1653
1654export const enum ClassificationType {
1655    comment = 1,
1656    identifier = 2,
1657    keyword = 3,
1658    numericLiteral = 4,
1659    operator = 5,
1660    stringLiteral = 6,
1661    regularExpressionLiteral = 7,
1662    whiteSpace = 8,
1663    text = 9,
1664    punctuation = 10,
1665    className = 11,
1666    enumName = 12,
1667    interfaceName = 13,
1668    moduleName = 14,
1669    typeParameterName = 15,
1670    typeAliasName = 16,
1671    parameterName = 17,
1672    docCommentTagName = 18,
1673    jsxOpenTagName = 19,
1674    jsxCloseTagName = 20,
1675    jsxSelfClosingTagName = 21,
1676    jsxAttribute = 22,
1677    jsxText = 23,
1678    jsxAttributeStringLiteralValue = 24,
1679    bigintLiteral = 25,
1680}
1681
1682/** @internal */
1683export interface CodeFixRegistration {
1684    errorCodes: readonly number[];
1685    getCodeActions(context: CodeFixContext): CodeFixAction[] | undefined;
1686    fixIds?: readonly string[];
1687    getAllCodeActions?(context: CodeFixAllContext): CombinedCodeActions;
1688}
1689
1690/** @internal */
1691export interface CodeFixContextBase extends textChanges.TextChangesContext {
1692    sourceFile: SourceFile;
1693    program: Program;
1694    cancellationToken: CancellationToken;
1695    preferences: UserPreferences;
1696}
1697
1698/** @internal */
1699export interface CodeFixAllContext extends CodeFixContextBase {
1700    fixId: {};
1701}
1702
1703/** @internal */
1704export interface CodeFixContext extends CodeFixContextBase {
1705    errorCode: number;
1706    span: TextSpan;
1707}
1708
1709/** @internal */
1710export interface Refactor {
1711    /** List of action kinds a refactor can provide.
1712     * Used to skip unnecessary calculation when specific refactors are requested. */
1713    kinds?: string[];
1714
1715    /** Compute the associated code actions */
1716    getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined;
1717
1718    /** Compute (quickly) which actions are available here */
1719    getAvailableActions(context: RefactorContext): readonly ApplicableRefactorInfo[];
1720}
1721
1722/** @internal */
1723export interface RefactorContext extends textChanges.TextChangesContext {
1724    file: SourceFile;
1725    startPosition: number;
1726    endPosition?: number;
1727    program: Program;
1728    cancellationToken?: CancellationToken;
1729    preferences: UserPreferences;
1730    triggerReason?: RefactorTriggerReason;
1731    kind?: string;
1732}
1733
1734export interface InlayHintsContext {
1735    file: SourceFile;
1736    program: Program;
1737    cancellationToken: CancellationToken;
1738    host: LanguageServiceHost;
1739    span: TextSpan;
1740    preferences: UserPreferences;
1741}
1742