1// Welcome to the FourSlash syntax guide! 2 3// A line in the source text is indicated by four slashes (////) 4// Tip: Hit Ctrl-K Ctrl-C Ctrl-K Ctrl-C to prefix-slash any selected block of text in Visual Studio 5//// This is a line in the source text! 6// Files are terminated by any entirely blank line (e.g. 7// interspersed //-initiated comments are allowed) 8 9// You can indicate a 'marker' with /**/ 10//// function./**/ 11// ... goTo.marker(); 12 13// Optionally, markers may have names: 14//// function.go(/*1*/x, /*2*/y); 15// goTo.marker('1'); 16// Marker names may consist of any alphanumeric characters 17 18// File metadata must occur directly before the first line of source text 19// and is indicated by an @ symbol: 20// @Filename: lib.d.ts 21//// this is the first line of my file 22 23// Global options may appear anywhere 24// @Module: Node 25// @Target: ES5 26 27// In the imperative section, you can write any valid TypeScript code. 28 29//--------------------------------------- 30// For API editors: 31// When editting this file, and only while editing this file, enable the reference comments 32// and comment out the declarations in this section to get proper type information. 33// Undo these changes before compiling/committing/editing any other fourslash tests. 34// The test suite will likely crash if you try 'jake runtests' with reference comments enabled. 35// 36// Explanation: 37// We want type-completion while we edit this file, but at compile time/while editting fourslash tests, 38// we don't want to include the following reference because we are compiling this file in "--out" mode and don't want to rope 39// in the entire codebase into the compilation each fourslash test. Additionally, we don't want to expose the 40// src/harness/fourslash.ts API's (or the rest of the compiler) because they are unstable and complicate the 41// fourslash testing DSL. Finally, in this case, runtime reflection is (much) faster. 42// 43// TODO: figure out a better solution to the API exposure problem. 44 45/// <reference path="../../../src/compiler/diagnosticInformationMap.generated.ts" /> 46 47declare module ts { 48 export type MapKey = string | number; 49 export interface Map<T> { 50 forEach(action: (value: T, key: string) => void): void; 51 get(key: MapKey): T; 52 has(key: MapKey): boolean; 53 set(key: MapKey, value: T): this; 54 delete(key: MapKey): boolean; 55 clear(): void; 56 } 57 58 interface SymbolDisplayPart { 59 text: string; 60 kind: string; 61 } 62 63 enum IndentStyle { 64 None = 0, 65 Block = 1, 66 Smart = 2, 67 } 68 69 const enum InlayHintKind { 70 Type = "Type", 71 Parameter = "Parameter", 72 Enum = "Enum", 73 } 74 75 enum SemicolonPreference { 76 Ignore = "ignore", 77 Insert = "insert", 78 Remove = "remove", 79 } 80 81 interface OutputFile { 82 name: string; 83 writeByteOrderMark: boolean; 84 text: string; 85 } 86 87 enum DiagnosticCategory { 88 Warning, 89 Error, 90 Suggestion, 91 Message 92 } 93 94 enum OrganizeImportsMode { 95 All = "All", 96 SortAndCombine = "SortAndCombine", 97 RemoveUnused = "RemoveUnused", 98 } 99 100 interface DiagnosticMessage { 101 key: string; 102 category: DiagnosticCategory; 103 code: number; 104 message: string; 105 reportsUnnecessary?: {}; 106 } 107 108 interface LineAndCharacter { 109 line: number; 110 character: number; 111 } 112 113 interface CompletionEntryData { 114 fileName?: string; 115 ambientModuleName?: string; 116 isPackageJsonImport?: true; 117 moduleSpecifier?: string; 118 exportName: string; 119 } 120 121 interface CompilerOptions { 122 module?: string; 123 target?: string; 124 jsx?: string; 125 allowJs?: boolean; 126 maxNodeModulesJsDepth?: number; 127 strictNullChecks?: boolean; 128 sourceMap?: boolean; 129 allowSyntheticDefaultImports?: boolean; 130 allowNonTsExtensions?: boolean; 131 resolveJsonModule?: boolean; 132 [key: string]: string | number | boolean | undefined; 133 } 134 135 function flatMap<T, U>(array: ReadonlyArray<T>, mapfn: (x: T, i: number) => U | ReadonlyArray<U> | undefined): U[]; 136} 137 138declare namespace FourSlashInterface { 139 interface Marker { 140 fileName: string; 141 position: number; 142 data?: any; 143 } 144 enum IndentStyle { 145 None = 0, 146 Block = 1, 147 Smart = 2, 148 } 149 interface EditorOptions { 150 BaseIndentSize?: number, 151 IndentSize: number; 152 TabSize: number; 153 NewLineCharacter: string; 154 ConvertTabsToSpaces: boolean; 155 } 156 interface EditorSettings { 157 baseIndentSize?: number; 158 indentSize?: number; 159 tabSize?: number; 160 newLineCharacter?: string; 161 convertTabsToSpaces?: boolean; 162 indentStyle?: IndentStyle; 163 trimTrailingWhitespace?: boolean; 164 } 165 interface FormatCodeOptions extends EditorOptions { 166 InsertSpaceAfterCommaDelimiter: boolean; 167 InsertSpaceAfterSemicolonInForStatements: boolean; 168 InsertSpaceBeforeAndAfterBinaryOperators: boolean; 169 InsertSpaceAfterKeywordsInControlFlowStatements: boolean; 170 InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; 171 InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; 172 InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; 173 InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: boolean; 174 InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; 175 InsertSpaceAfterTypeAssertion: boolean; 176 PlaceOpenBraceOnNewLineForFunctions: boolean; 177 PlaceOpenBraceOnNewLineForControlBlocks: boolean; 178 insertSpaceBeforeTypeAnnotation: boolean; 179 [s: string]: boolean | number | string | undefined; 180 } 181 interface FormatCodeSettings extends EditorSettings { 182 readonly insertSpaceAfterCommaDelimiter?: boolean; 183 readonly insertSpaceAfterSemicolonInForStatements?: boolean; 184 readonly insertSpaceBeforeAndAfterBinaryOperators?: boolean; 185 readonly insertSpaceAfterConstructor?: boolean; 186 readonly insertSpaceAfterKeywordsInControlFlowStatements?: boolean; 187 readonly insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; 188 readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; 189 readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; 190 readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; 191 readonly insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; 192 readonly insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; 193 readonly insertSpaceAfterTypeAssertion?: boolean; 194 readonly insertSpaceBeforeFunctionParenthesis?: boolean; 195 readonly placeOpenBraceOnNewLineForFunctions?: boolean; 196 readonly placeOpenBraceOnNewLineForControlBlocks?: boolean; 197 readonly insertSpaceBeforeTypeAnnotation?: boolean; 198 readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; 199 readonly semicolons?: ts.SemicolonPreference; 200 } 201 interface Range { 202 fileName: string; 203 pos: number; 204 end: number; 205 marker?: Marker; 206 } 207 interface TextSpan { 208 start: number; 209 end: number; 210 } 211 class test_ { 212 markers(): Marker[]; 213 markerNames(): string[]; 214 markerName(m: Marker): string; 215 marker(name?: string): Marker; 216 ranges(): Range[]; 217 rangesInFile(fileName?: string): Range[]; 218 spans(): Array<{ start: number, length: number }>; 219 rangesByText(): ts.Map<Range[]>; 220 markerByName(s: string): Marker; 221 symbolsInScope(range: Range): any[]; 222 setTypesRegistry(map: { [key: string]: void }): void; 223 } 224 class config { 225 configurePlugin(pluginName: string, configuration: any): void; 226 setCompilerOptionsForInferredProjects(options: ts.CompilerOptions) 227 } 228 class goTo { 229 marker(name?: string | Marker): void; 230 eachMarker(markers: ReadonlyArray<string>, action: (marker: Marker, index: number) => void): void; 231 eachMarker(action: (marker: Marker, index: number) => void): void; 232 rangeStart(range: Range): void; 233 eachRange(action: (range: Range) => void): void; 234 bof(): void; 235 eof(): void; 236 implementation(): void; 237 position(position: number, fileIndex?: number): any; 238 position(position: number, fileName?: string): any; 239 position(lineAndCharacter: ts.LineAndCharacter, fileName?: string): void; 240 file(index: number, content?: string, scriptKindName?: string): any; 241 file(name: string, content?: string, scriptKindName?: string): any; 242 select(startMarker: string, endMarker: string): void; 243 selectRange(range: Range): void; 244 /** 245 * Selects a line at a given index, not including any newline characters. 246 * @param index 0-based 247 */ 248 selectLine(index: number): void; 249 } 250 class verifyNegatable { 251 private negative; 252 not: verifyNegatable; 253 allowedClassElementKeywords: string[]; 254 allowedConstructorParameterKeywords: string[]; 255 constructor(negative?: boolean); 256 errorExistsBetweenMarkers(startMarker: string, endMarker: string): void; 257 errorExistsAfterMarker(markerName?: string): void; 258 errorExistsBeforeMarker(markerName?: string): void; 259 quickInfoExists(): void; 260 typeDefinitionCountIs(expectedCount: number): void; 261 implementationListIsEmpty(): void; 262 isValidBraceCompletionAtPosition(openingBrace?: string): void; 263 jsxClosingTag(map: { [markerName: string]: { readonly newText: string } | undefined }): void; 264 isInCommentAtPosition(onlyMultiLineDiverges?: boolean): void; 265 codeFix(options: { 266 description: string | [string, ...(string | number)[]] | DiagnosticIgnoredInterpolations, 267 newFileContent?: NewFileContent, 268 newRangeContent?: string, 269 errorCode?: number, 270 index?: number, 271 preferences?: UserPreferences, 272 applyChanges?: boolean, 273 commands?: {}[], 274 }); 275 codeFixAvailable(options?: ReadonlyArray<VerifyCodeFixAvailableOptions> | string): void; 276 codeFixAllAvailable(fixName: string): void; 277 applicableRefactorAvailableAtMarker(markerName: string): void; 278 codeFixDiagnosticsAvailableAtMarkers(markerNames: string[], diagnosticCode?: number): void; 279 applicableRefactorAvailableForRange(): void; 280 281 refactorAvailable(name: string, actionName?: string, actionDescription?: string): void; 282 refactorAvailableForTriggerReason(triggerReason: RefactorTriggerReason, name: string, action?: string): void; 283 refactorKindAvailable(refactorKind: string, expected: string[], preferences?: {}): void; 284 } 285 class verify extends verifyNegatable { 286 assertHasRanges(ranges: Range[]): void; 287 caretAtMarker(markerName?: string): void; 288 completions(...options: CompletionsOptions[]): void; 289 applyCodeActionFromCompletion(markerName: string, options: { 290 name: string, 291 source?: string, 292 data?: ts.CompletionEntryData, 293 description: string, 294 newFileContent?: string, 295 newRangeContent?: string, 296 preferences?: UserPreferences, 297 }); 298 indentationIs(numberOfSpaces: number): void; 299 indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle?: ts.IndentStyle, baseIndentSize?: number): void; 300 textAtCaretIs(text: string): void; 301 /** 302 * Compiles the current file and evaluates 'expr' in a context containing 303 * the emitted output, then compares (using ===) the result of that expression 304 * to 'value'. Do not use this function with external modules as it is not supported. 305 */ 306 eval(expr: string, value: any): void; 307 currentLineContentIs(text: string): void; 308 currentFileContentIs(text: string): void; 309 formatDocumentChangesNothing(): void; 310 /** Verifies that goToDefinition at the current position would take you to `endMarker`. */ 311 goToDefinitionIs(endMarkers: ArrayOrSingle<string>): void; 312 goToDefinitionName(name: string, containerName: string): void; 313 /** 314 * `verify.goToDefinition("a", "b");` verifies that go-to-definition at marker "a" takes you to marker "b". 315 * `verify.goToDefinition(["a", "aa"], "b");` verifies that markers "a" and "aa" have the same definition "b". 316 * `verify.goToDefinition("a", ["b", "bb"]);` verifies that "a" has multiple definitions available. 317 */ 318 goToDefinition(startMarkerNames: ArrayOrSingle<string>, fileResult: { file: string, unverified?: boolean }): void; 319 goToDefinition(startMarkerNames: ArrayOrSingle<string>, endMarkerNames: ArrayOrSingle<string | { marker: string, unverified?: boolean }>): void; 320 goToDefinition(startMarkerNames: ArrayOrSingle<string>, endMarkerNames: ArrayOrSingle<string>, range: Range): void; 321 /** Performs `goToDefinition` for each pair. */ 322 goToDefinition(startsAndEnds: [ArrayOrSingle<string>, ArrayOrSingle<string>][]): void; 323 /** Performs `goToDefinition` on each key and value. */ 324 goToDefinition(startsAndEnds: { [startMarkerName: string]: ArrayOrSingle<string> }): void; 325 /** Verifies goToDefinition for each `${markerName}Reference` -> `${markerName}Definition` */ 326 goToDefinitionForMarkers(...markerNames: string[]): void; 327 goToSourceDefinition(startMarkerNames: ArrayOrSingle<string>, fileResult: { file: string, unverified?: boolean }): void; 328 goToSourceDefinition(startMarkerNames: ArrayOrSingle<string>, endMarkerNames: ArrayOrSingle<string | { marker: string, unverified?: boolean }>): void; 329 goToSourceDefinition(startMarkerNames: ArrayOrSingle<string>, endMarkerNames: ArrayOrSingle<string>): void; 330 goToType(startsAndEnds: { [startMarkerName: string]: ArrayOrSingle<string> }): void; 331 goToType(startMarkerNames: ArrayOrSingle<string>, endMarkerNames: ArrayOrSingle<string>): void; 332 verifyGetEmitOutputForCurrentFile(expected: string): void; 333 verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void; 334 baselineFindAllReferences(...markerNames: string[]): void; 335 baselineFindAllReferencesMulti(seq: number, ...markerNames: string[]): void; 336 baselineGetFileReferences(fileName: string): void; 337 symbolAtLocation(startRange: Range, ...declarationRanges: Range[]): void; 338 typeOfSymbolAtLocation(range: Range, symbol: any, expected: string): void; 339 /** @deprecated Use baselineFindAllReferences instead */ 340 singleReferenceGroup(definition: ReferencesDefinition, ranges?: Range[] | string): void; 341 rangesAreOccurrences(isWriteAccess?: boolean, ranges?: Range[]): void; 342 rangesWithSameTextAreRenameLocations(...texts: string[]): void; 343 rangesAreRenameLocations(options?: Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges?: Range[], providePrefixAndSuffixTextForRename?: boolean }); 344 findReferencesDefinitionDisplayPartsAtCaretAre(expected: ts.SymbolDisplayPart[]): void; 345 noSignatureHelp(...markers: (string | Marker)[]): void; 346 noSignatureHelpForTriggerReason(triggerReason: SignatureHelpTriggerReason, ...markers: (string | Marker)[]): void 347 signatureHelpPresentForTriggerReason(triggerReason: SignatureHelpTriggerReason, ...markers: (string | Marker)[]): void 348 signatureHelp(...options: VerifySignatureHelpOptions[], ): void; 349 // Checks that there are no compile errors. 350 noErrors(): void; 351 errorExistsAtRange(range: Range, code: number, message?: string): void; 352 numberOfErrorsInCurrentFile(expected: number): void; 353 baselineCurrentFileBreakpointLocations(): void; 354 baselineCurrentFileNameOrDottedNameSpans(): void; 355 baselineGetEmitOutput(insertResultsIntoVfs?: boolean): void; 356 baselineSyntacticDiagnostics(): void; 357 baselineSyntacticAndSemanticDiagnostics(): void; 358 getEmitOutput(expectedOutputFiles: ReadonlyArray<string>): void; 359 baselineCompletions(preferences?: UserPreferences): void; 360 baselineQuickInfo(): void; 361 baselineSmartSelection(): void; 362 baselineSignatureHelp(): void; 363 nameOrDottedNameSpanTextIs(text: string): void; 364 outliningSpansInCurrentFile(spans: Range[], kind?: "comment" | "region" | "code" | "imports"): void; 365 outliningHintSpansInCurrentFile(spans: Range[]): void; 366 todoCommentsInCurrentFile(descriptors: string[]): void; 367 matchingBracePositionInCurrentFile(bracePosition: number, expectedMatchPosition: number): void; 368 noMatchingBracePositionInCurrentFile(bracePosition: number): void; 369 docCommentTemplateAt(markerName: string | FourSlashInterface.Marker, expectedOffset: number, expectedText: string, options?: VerifyDocCommentTemplateOptions): void; 370 noDocCommentTemplateAt(markerName: string | FourSlashInterface.Marker): void; 371 rangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number, index?: number): void; 372 codeFixAll(options: { fixId: string, fixAllDescription: string, newFileContent: NewFileContent, commands?: {}[] }): void; 373 fileAfterApplyingRefactorAtMarker(markerName: string, expectedContent: string, refactorNameToApply: string, actionName: string, formattingOptions?: FormatCodeOptions): void; 374 rangeIs(expectedText: string, includeWhiteSpace?: boolean): void; 375 fileAfterApplyingRefactorAtMarker(markerName: string, expectedContent: string, refactorNameToApply: string, formattingOptions?: FormatCodeOptions): void; 376 getAndApplyCodeFix(errorCode?: number, index?: number): void; 377 importFixAtPosition(expectedTextArray: string[], errorCode?: number, options?: UserPreferences): void; 378 importFixModuleSpecifiers(marker: string, moduleSpecifiers: string[], options?: UserPreferences): void; 379 380 navigationBar(json: any, options?: { checkSpans?: boolean }): void; 381 navigationTree(json: any, options?: { checkSpans?: boolean }): void; 382 navigateTo(...options: VerifyNavigateToOptions[]); 383 occurrencesAtPositionContains(range: Range, isWriteAccess?: boolean): void; 384 occurrencesAtPositionCount(expectedCount: number): void; 385 rangesAreDocumentHighlights(ranges?: Range[], options?: VerifyDocumentHighlightsOptions): void; 386 rangesWithSameTextAreDocumentHighlights(): void; 387 documentHighlightsOf(startRange: Range, ranges: Range[], options?: VerifyDocumentHighlightsOptions): void; 388 /** Prefer {@link syntacticClassificationsAre} for more descriptive tests */ 389 encodedSyntacticClassificationsLength(expected: number): void; 390 /** Prefer {@link semanticClassificationsAre} for more descriptive tests */ 391 encodedSemanticClassificationsLength(format: "original" | "2020", length: number): void; 392 /** 393 * This method *requires* a contiguous, complete, and ordered stream of classifications for a file. 394 */ 395 syntacticClassificationsAre(...classifications: { 396 classificationType: string; 397 text?: string; 398 }[]): void; 399 /** 400 * This method *requires* an ordered stream of classifications for a file, and spans are highly recommended. 401 */ 402 semanticClassificationsAre(format: "original" | "2020", ...classifications: { 403 classificationType: string | number; 404 text?: string; 405 textSpan?: TextSpan; 406 }[]): void; 407 /** Edits the current testfile and replaces with the semantic classifications */ 408 replaceWithSemanticClassifications(format: "2020") 409 renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, range?: Range, preferences?: UserPreferences): void; 410 renameInfoFailed(message?: string, preferences?: UserPreferences): void; 411 renameLocations(startRanges: ArrayOrSingle<Range>, options: RenameLocationsOptions): void; 412 baselineRename(marker: string, options: RenameOptions): void; 413 414 /** Verify the quick info available at the current marker. */ 415 quickInfoIs(expectedText: string, expectedDocumentation?: string, expectedTags?: { name: string; text: string; }[]): void; 416 /** Goto a marker and call `quickInfoIs`. */ 417 quickInfoAt(markerName: string | Range, expectedText?: string, expectedDocumentation?: string, expectedTags?: { name: string; text: string; }[]): void; 418 /** 419 * Call `quickInfoAt` for each pair in the object. 420 * (If the value is an array, it is [expectedText, expectedDocumentation].) 421 */ 422 quickInfos(namesAndTexts: { [name: string]: string | [string, string] }): void; 423 verifyQuickInfoDisplayParts(kind: string, kindModifiers: string, textSpan: { 424 start: number; 425 length: number; 426 }, displayParts: ts.SymbolDisplayPart[], documentation: ts.SymbolDisplayPart[], tags: { name: string, text?: string }[] | undefined): void; 427 getInlayHints(expected: readonly VerifyInlayHintsOptions[], textSpan?: { 428 start: number; 429 length: number; 430 }, preference?: InlayHintsOptions); 431 getSyntacticDiagnostics(expected: ReadonlyArray<Diagnostic>): void; 432 getSemanticDiagnostics(expected: ReadonlyArray<Diagnostic>): void; 433 getSuggestionDiagnostics(expected: ReadonlyArray<Diagnostic>): void; 434 ProjectInfo(expected: string[]): void; 435 allRangesAppearInImplementationList(markerName: string): void; 436 getEditsForFileRename(options: { 437 readonly oldPath: string; 438 readonly newPath: string; 439 readonly newFileContents: { readonly [fileName: string]: string }; 440 readonly preferences?: UserPreferences; 441 }): void; 442 baselineCallHierarchy(): void; 443 moveToNewFile(options: { 444 readonly newFileContents: { readonly [fileName: string]: string }; 445 readonly preferences?: UserPreferences; 446 }): void; 447 noMoveToNewFile(): void; 448 449 generateTypes(...options: GenerateTypesOptions[]): void; 450 451 organizeImports(newContent: string, mode?: ts.OrganizeImportsMode): void; 452 453 toggleLineComment(newFileContent: string): void; 454 toggleMultilineComment(newFileContent: string): void; 455 commentSelection(newFileContent: string): void; 456 uncommentSelection(newFileContent: string): void; 457 } 458 class edit { 459 backspace(count?: number): void; 460 deleteAtCaret(times?: number): void; 461 replace(start: number, length: number, text: string): void; 462 paste(text: string): void; 463 insert(text: string): void; 464 insertLine(text: string): void; 465 insertLines(...lines: string[]): void; 466 /** @param index 0-based */ 467 deleteLine(index: number): void; 468 /** 469 * @param startIndex 0-based 470 * @param endIndexInclusive 0-based 471 */ 472 deleteLineRange(startIndex: number, endIndexInclusive: number): void; 473 /** @param index 0-based */ 474 replaceLine(index: number, text: string): void; 475 moveRight(count?: number): void; 476 moveLeft(count?: number): void; 477 enableFormatting(): void; 478 disableFormatting(): void; 479 480 applyRefactor(options: { refactorName: string, actionName: string, actionDescription: string, newContent: NewFileContent, triggerReason?: RefactorTriggerReason }): void; 481 } 482 class debug { 483 printCurrentParameterHelp(): void; 484 printCurrentFileState(): void; 485 printCurrentFileStateWithWhitespace(): void; 486 printCurrentFileStateWithoutCaret(): void; 487 printCurrentQuickInfo(): void; 488 printCurrentSignatureHelp(): void; 489 printCompletionListMembers(options?: { includeExternalModuleExports: boolean }): void; 490 printAvailableCodeFixes(): void; 491 printBreakpointLocation(pos: number): void; 492 printBreakpointAtCurrentLocation(): void; 493 printNameOrDottedNameSpans(pos: number): void; 494 printErrorList(): void; 495 printNavigationBar(): void; 496 printNavigationItems(searchValue?: string): void; 497 printScriptLexicalStructureItems(): void; 498 printOutliningSpans(): void; 499 printReferences(): void; 500 printContext(): void; 501 } 502 class format { 503 document(): void; 504 copyFormatOptions(): FormatCodeOptions; 505 setFormatOptions(options: FormatCodeOptions | FormatCodeSettings): any; 506 selection(startMarker: string, endMarker: string): void; 507 onType(posMarker: string, key: string): void; 508 setOption(name: keyof FormatCodeOptions, value: number | string | boolean): void; 509 } 510 class cancellation { 511 resetCancelled(): void; 512 setCancelled(numberOfCalls?: number): void; 513 } 514 515 interface ModernClassificationFactory { 516 semanticToken(identifier: string, name: string) 517 } 518 519 interface ClassificationFactory { 520 comment(text: string, position?: number): { 521 classificationType: string; 522 text: string; 523 textSpan?: TextSpan; 524 }; 525 identifier(text: string, position?: number): { 526 classificationType: string; 527 text: string; 528 textSpan?: TextSpan; 529 }; 530 keyword(text: string, position?: number): { 531 classificationType: string; 532 text: string; 533 textSpan?: TextSpan; 534 }; 535 numericLiteral(text: string, position?: number): { 536 classificationType: string; 537 text: string; 538 textSpan?: TextSpan; 539 }; 540 operator(text: string, position?: number): { 541 classificationType: string; 542 text: string; 543 textSpan?: TextSpan; 544 }; 545 stringLiteral(text: string, position?: number): { 546 classificationType: string; 547 text: string; 548 textSpan?: TextSpan; 549 }; 550 whiteSpace(text: string, position?: number): { 551 classificationType: string; 552 text: string; 553 textSpan?: TextSpan; 554 }; 555 text(text: string, position?: number): { 556 classificationType: string; 557 text: string; 558 textSpan?: TextSpan; 559 }; 560 punctuation(text: string, position?: number): { 561 classificationType: string; 562 text: string; 563 textSpan?: TextSpan; 564 }; 565 docCommentTagName(text: string, position?: number): { 566 classificationType: string; 567 text: string; 568 textSpan?: TextSpan; 569 }; 570 className(text: string, position?: number): { 571 classificationType: string; 572 text: string; 573 textSpan?: TextSpan; 574 }; 575 enumName(text: string, position?: number): { 576 classificationType: string; 577 text: string; 578 textSpan?: TextSpan; 579 }; 580 interfaceName(text: string, position?: number): { 581 classificationType: string; 582 text: string; 583 textSpan?: TextSpan; 584 }; 585 moduleName(text: string, position?: number): { 586 classificationType: string; 587 text: string; 588 textSpan?: TextSpan; 589 }; 590 typeParameterName(text: string, position?: number): { 591 classificationType: string; 592 text: string; 593 textSpan?: TextSpan; 594 }; 595 parameterName(text: string, position?: number): { 596 classificationType: string; 597 text: string; 598 textSpan?: TextSpan; 599 }; 600 typeAliasName(text: string, position?: number): { 601 classificationType: string; 602 text: string; 603 textSpan?: TextSpan; 604 }; 605 jsxOpenTagName(text: string, position?: number): { 606 classificationType: string; 607 text: string; 608 textSpan?: TextSpan; 609 }; 610 jsxCloseTagName(text: string, position?: number): { 611 classificationType: string; 612 text: string; 613 textSpan?: TextSpan; 614 }; 615 jsxSelfClosingTagName(text: string, position?: number): { 616 classificationType: string; 617 text: string; 618 textSpan?: TextSpan; 619 }; 620 jsxAttribute(text: string, position?: number): { 621 classificationType: string; 622 text: string; 623 textSpan?: TextSpan; 624 }; 625 jsxText(text: string, position?: number): { 626 classificationType: string; 627 text: string; 628 textSpan?: TextSpan; 629 }; 630 jsxAttributeStringLiteralValue(text: string, position?: number): { 631 classificationType: string; 632 text: string; 633 textSpan?: TextSpan; 634 }; 635 } 636 637 interface ReferenceGroup { 638 readonly definition: ReferencesDefinition; 639 readonly ranges: ReadonlyArray<Range>; 640 } 641 type ReferencesDefinition = string | { 642 text: string; 643 range: Range; 644 } 645 interface Diagnostic { 646 message: string; 647 /** @default `test.ranges()[0]` */ 648 range?: Range; 649 code: number; 650 reportsUnnecessary?: true; 651 reportsDeprecated?: true; 652 } 653 interface VerifyDocumentHighlightsOptions { 654 filesToSearch?: ReadonlyArray<string>; 655 } 656 interface UserPreferences { 657 readonly quotePreference?: "auto" | "double" | "single"; 658 readonly includeCompletionsForModuleExports?: boolean; 659 readonly includeCompletionsForImportStatements?: boolean; 660 readonly includeCompletionsWithSnippetText?: boolean; 661 readonly includeCompletionsWithInsertText?: boolean; 662 readonly includeCompletionsWithClassMemberSnippets?: boolean; 663 readonly includeCompletionsWithObjectLiteralMethodSnippets?: boolean; 664 readonly useLabelDetailsInCompletionEntries?: boolean; 665 readonly allowIncompleteCompletions?: boolean; 666 /** @deprecated use `includeCompletionsWithInsertText` */ 667 readonly includeInsertTextCompletions?: boolean; 668 readonly includeAutomaticOptionalChainCompletions?: boolean; 669 readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative"; 670 readonly importModuleSpecifierEnding?: "minimal" | "index" | "js"; 671 readonly jsxAttributeCompletionStyle?: "auto" | "braces" | "none"; 672 readonly providePrefixAndSuffixTextForRename?: boolean; 673 readonly allowRenameOfImportPath?: boolean; 674 readonly autoImportFileExcludePatterns?: readonly string[]; 675 } 676 interface InlayHintsOptions extends UserPreferences { 677 readonly includeInlayParameterNameHints?: "none" | "literals" | "all"; 678 readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean; 679 readonly includeInlayFunctionParameterTypeHints?: boolean; 680 readonly includeInlayVariableTypeHints?: boolean; 681 readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean; 682 readonly includeInlayPropertyDeclarationTypeHints?: boolean; 683 readonly includeInlayFunctionLikeReturnTypeHints?: boolean; 684 readonly includeInlayEnumMemberValueHints?: boolean; 685 } 686 interface CompletionsOptions { 687 readonly marker?: ArrayOrSingle<string | Marker>; 688 readonly isNewIdentifierLocation?: boolean; 689 readonly isGlobalCompletion?: boolean; 690 readonly optionalReplacementSpan?: Range; 691 /** Must provide all completion entries in order. */ 692 readonly exact?: ArrayOrSingle<ExpectedCompletionEntry>; 693 /** Must provide all completion entries, but order doesn't matter. */ 694 readonly unsorted?: readonly ExpectedCompletionEntry[]; 695 readonly includes?: ArrayOrSingle<ExpectedCompletionEntry>; 696 readonly excludes?: ArrayOrSingle<string>; 697 readonly preferences?: UserPreferences; 698 readonly triggerCharacter?: string; 699 } 700 type ExpectedCompletionEntry = string | ExpectedCompletionEntryObject; 701 interface ExpectedCompletionEntryObject { 702 readonly name: string; 703 readonly source?: string; 704 readonly insertText?: string; 705 readonly replacementSpan?: Range; 706 readonly hasAction?: boolean; 707 readonly isRecommended?: boolean; 708 readonly isFromUncheckedFile?: boolean; 709 readonly kind?: string; 710 readonly kindModifiers?: string; 711 readonly sortText?: completion.SortText; 712 readonly isPackageJsonImport?: boolean; 713 readonly isSnippet?: boolean; 714 715 // details 716 readonly text?: string; 717 readonly documentation?: string; 718 readonly tags?: ReadonlyArray<JSDocTagInfo>; 719 readonly sourceDisplay?: string; 720 readonly labelDetails?: ExpectedCompletionEntryLabelDetails; 721 } 722 723 export interface ExpectedCompletionEntryLabelDetails { 724 detail?: string; 725 description?: string; 726 } 727 728 interface VerifySignatureHelpOptions { 729 marker?: ArrayOrSingle<string | Marker>; 730 /** @default 1 */ 731 overloadsCount?: number; 732 docComment?: string; 733 text?: string; 734 parameterName?: string; 735 parameterSpan?: string; 736 parameterDocComment?: string; 737 parameterCount?: number; 738 argumentCount?: number; 739 isVariadic?: boolean; 740 tags?: ReadonlyArray<JSDocTagInfo>; 741 triggerReason?: SignatureHelpTriggerReason; 742 overrideSelectedItemIndex?: number; 743 } 744 745 interface VerifyDocCommentTemplateOptions { 746 generateReturnInDocTemplate?: boolean; 747 } 748 749 export type SignatureHelpTriggerReason = 750 | SignatureHelpInvokedReason 751 | SignatureHelpCharacterTypedReason 752 | SignatureHelpRetriggeredReason; 753 754 /** 755 * Signals that the user manually requested signature help. 756 * The language service will unconditionally attempt to provide a result. 757 */ 758 export interface SignatureHelpInvokedReason { 759 kind: "invoked", 760 triggerCharacter?: undefined, 761 } 762 763 /** 764 * Signals that the signature help request came from a user typing a character. 765 * Depending on the character and the syntactic context, the request may or may not be served a result. 766 */ 767 export interface SignatureHelpCharacterTypedReason { 768 kind: "characterTyped", 769 /** 770 * Character that was responsible for triggering signature help. 771 */ 772 triggerCharacter: string, 773 } 774 775 /** 776 * Signals that this signature help request came from typing a character or moving the cursor. 777 * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. 778 * The language service will unconditionally attempt to provide a result. 779 * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. 780 */ 781 export interface SignatureHelpRetriggeredReason { 782 kind: "retrigger", 783 /** 784 * Character that was responsible for triggering signature help. 785 */ 786 triggerCharacter?: string, 787 } 788 789 export type RefactorTriggerReason = "implicit" | "invoked"; 790 791 export interface VerifyCodeFixAvailableOptions { 792 readonly description: string; 793 readonly actions?: ReadonlyArray<{ readonly type: string, readonly data: {} }>; 794 readonly commands?: ReadonlyArray<{}>; 795 } 796 797 export interface VerifyInlayHintsOptions { 798 text: string; 799 position: number; 800 kind?: ts.InlayHintKind; 801 whitespaceBefore?: boolean; 802 whitespaceAfter?: boolean; 803 } 804 805 interface VerifyNavigateToOptions { 806 readonly pattern: string; 807 readonly fileName?: string; 808 readonly expected: ReadonlyArray<ExpectedNavigateToItem>; 809 } 810 interface ExpectedNavigateToItem { 811 readonly name: string; 812 readonly kind: string; 813 readonly kindModifiers?: string; // default: "" 814 readonly matchKind?: string; // default: "exact" 815 readonly isCaseSensitive?: boolean; // default: "true" 816 readonly range: Range; 817 readonly containerName?: string; // default: "" 818 readonly containerKind?: string; // default: ScriptElementKind.unknown 819 } 820 821 interface JSDocTagInfo { 822 readonly name: string; 823 readonly text: string | ts.SymbolDisplayPart[] | undefined; 824 } 825 826 interface GenerateTypesOptions { 827 readonly name?: string; 828 readonly value: unknown; 829 readonly global?: boolean; 830 readonly output?: string | undefined; 831 readonly outputBaseline?: string; 832 } 833 834 type ArrayOrSingle<T> = T | ReadonlyArray<T>; 835 type NewFileContent = string | { readonly [fileName: string]: string }; 836 837 type RenameLocationsOptions = ReadonlyArray<RenameLocationOptions> | { 838 readonly findInStrings?: boolean; 839 readonly findInComments?: boolean; 840 readonly ranges: ReadonlyArray<RenameLocationOptions>; 841 readonly providePrefixAndSuffixTextForRename?: boolean; 842 }; 843 844 type RenameOptions = { readonly findInStrings?: boolean, readonly findInComments?: boolean, readonly providePrefixAndSuffixTextForRename?: boolean }; 845 type RenameLocationOptions = Range | { readonly range: Range, readonly prefixText?: string, readonly suffixText?: string }; 846 type DiagnosticIgnoredInterpolations = { template: string } 847} 848/** Wraps a diagnostic message to be compared ignoring interpolated strings */ 849declare function ignoreInterpolations(diagnostic: string | ts.DiagnosticMessage): FourSlashInterface.DiagnosticIgnoredInterpolations; 850declare function verifyOperationIsCancelled(f: any): void; 851declare var test: FourSlashInterface.test_; 852declare var config: FourSlashInterface.config; 853declare var goTo: FourSlashInterface.goTo; 854declare var verify: FourSlashInterface.verify; 855declare var edit: FourSlashInterface.edit; 856declare var debug: FourSlashInterface.debug; 857declare var format: FourSlashInterface.format; 858declare var cancellation: FourSlashInterface.cancellation; 859declare function classification(format: "original"): FourSlashInterface.ClassificationFactory; 860declare function classification(format: "2020"): FourSlashInterface.ModernClassificationFactory; 861declare namespace completion { 862 type Entry = FourSlashInterface.ExpectedCompletionEntryObject; 863 interface GlobalsPlusOptions { 864 noLib?: boolean; 865 } 866 export type SortText = string & { __sortText: any }; 867 export const SortText: { 868 LocalDeclarationPriority: SortText, 869 LocationPriority: SortText, 870 OptionalMember: SortText, 871 MemberDeclaredBySpreadAssignment: SortText, 872 SuggestedClassMembers: SortText, 873 GlobalsOrKeywords: SortText, 874 AutoImportSuggestions: SortText, 875 ClassMemberSnippets: SortText, 876 JavascriptIdentifiers: SortText, 877 878 Deprecated(sortText: SortText): SortText, 879 ObjectLiteralProperty(presetSortText: SortText, symbolDisplayName: string): SortText, 880 SortBelow(sortText: SortText): SortText, 881 }; 882 883 export const enum CompletionSource { 884 ThisProperty = "ThisProperty/", 885 ClassMemberSnippet = "ClassMemberSnippet/", 886 TypeOnlyAlias = "TypeOnlyAlias/", 887 ObjectLiteralMethodSnippet = "ObjectLiteralMethodSnippet/", 888 } 889 export const globalThisEntry: Entry; 890 export const undefinedVarEntry: Entry; 891 export const globals: ReadonlyArray<Entry>; 892 export const globalsInJs: ReadonlyArray<Entry>; 893 export const globalKeywords: ReadonlyArray<Entry>; 894 export const globalInJsKeywords: ReadonlyArray<Entry>; 895 export const insideMethodKeywords: ReadonlyArray<Entry>; 896 export const insideMethodInJsKeywords: ReadonlyArray<Entry>; 897 export const globalsVars: ReadonlyArray<Entry>; 898 export function sorted(entries: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>; 899 export function globalsInsideFunction(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>, options?: GlobalsPlusOptions): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>; 900 export function globalsInJsInsideFunction(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>, options?: GlobalsPlusOptions): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>; 901 export function globalsPlus(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>, options?: GlobalsPlusOptions): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>; 902 export function globalsInJsPlus(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>, options?: GlobalsPlusOptions): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>; 903 export const keywordsWithUndefined: ReadonlyArray<Entry>; 904 export const keywords: ReadonlyArray<Entry>; 905 export const typeKeywords: ReadonlyArray<Entry>; 906 export function typeKeywordsPlus(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>): ReadonlyArray<Entry>; 907 export const globalTypes: ReadonlyArray<Entry>; 908 export function globalTypesPlus(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>): ReadonlyArray<Entry>; 909 export const typeAssertionKeywords: ReadonlyArray<Entry>; 910 export const classElementKeywords: ReadonlyArray<Entry>; 911 export const classElementInJsKeywords: ReadonlyArray<Entry>; 912 export const constructorParameterKeywords: ReadonlyArray<Entry>; 913 export const functionMembers: ReadonlyArray<Entry>; 914 export function functionMembersPlus(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>; 915 export const functionMembersWithPrototype: ReadonlyArray<Entry>; 916 export function functionMembersWithPrototypePlus(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>; 917 export const stringMembers: ReadonlyArray<Entry>; 918 export const statementKeywordsWithTypes: ReadonlyArray<Entry>; 919 export const statementKeywords: ReadonlyArray<Entry>; 920 export const statementInJsKeywords: ReadonlyArray<Entry>; 921} 922