_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/autoImportFileExcludePatterns8.ts_0_977
/// <reference path="fourslash.ts" /> // @Filename: /src/vs/workbench/test.ts //// import { Parts } from './parts'; //// export class /**/EditorParts implements Parts { } // @Filename: /src/vs/event/event.ts //// export interface Event { //// (): string; //// } // @Filename: /src/vs/workbench/parts.ts //// import { Event } from '../event/event'; //// export interface Parts { //// readonly options: Event; //// } // @Filename: /src/vs/workbench/workbench.ts //// import { Event } from './workbench2'; //// export { Event }; // @Filename: /src/vs/workbench/workbench2.ts //// import { Event } from '../event/event'; //// export { Event }; verify.codeFix({ description: "Implement interface 'Parts'", newFileContent: `import { Event } from '../event/event'; import { Parts } from './parts'; export class EditorParts implements Parts { options: Event; }`, preferences: { autoImportFileExcludePatterns: ["src/vs/workbench/workbench*"], } });
{ "end_byte": 977, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportFileExcludePatterns8.ts" }
TypeScript/tests/cases/fourslash/renamePrivateAccessor.ts_0_339
/// <reference path='fourslash.ts' /> ////class Foo { //// [|get [|{| "contextRangeIndex": 0 |}#foo|]() { return 1 }|] //// [|set [|{| "contextRangeIndex": 2 |}#foo|](value: number) { }|] //// retFoo() { //// return this.[|#foo|]; //// } ////} const ranges = test.rangesByText().get("#foo"); verify.baselineRename(ranges);
{ "end_byte": 339, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renamePrivateAccessor.ts" }
TypeScript/tests/cases/fourslash/gotoDefinitionLinkTag5.ts_0_167
/// <reference path="fourslash.ts" /> ////enum E { //// /** {@link /*1*/[|B|]} */ //// A, //// [|/*2*/B|] ////} verify.baselineGetDefinitionAtPosition("1");
{ "end_byte": 167, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/gotoDefinitionLinkTag5.ts" }
TypeScript/tests/cases/fourslash/signatureHelpInCallback.ts_0_236
/// <reference path='fourslash.ts' /> ////declare function forEach(f: () => void); ////forEach(/*1*/() => { //// /*2*/ ////}); verify.signatureHelp({ marker: "1", text: "forEach(f: () => void): any" }) verify.noSignatureHelp("2");
{ "end_byte": 236, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpInCallback.ts" }
TypeScript/tests/cases/fourslash/getEmitOutputSourceMap2.ts_0_469
/// <reference path="fourslash.ts" /> // @BaselineFile: getEmitOutputSourceMap2.baseline // @sourceMap: true // @outDir: sample/outDir // @Filename: inputFile1.ts // @emitThisFile: true //// var x = 109; //// var foo = "hello world"; //// class M { //// x: number; //// y: string; //// } // @Filename: inputFile2.ts // @emitThisFile: true //// var intro = "hello world"; //// if (intro !== undefined) { //// var k = 10; //// } verify.baselineGetEmitOutput();
{ "end_byte": 469, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputSourceMap2.ts" }
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_Availability_Arrow_FnArgument.ts_0_1891
/// <reference path='fourslash.ts' /> //// function foo(a){} //// /*z*/f/*y*/oo/*x*/(/*w*//*v*/(/*u*//*t*/a/*s*/, b) => /*r*/a/*q*/ + b) goTo.select("z", "y"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function"); goTo.select("x", "w"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function"); goTo.select("v", "u"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function"); verify.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function"); goTo.select("t", "s"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function"); verify.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function"); goTo.select("r", "q"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
{ "end_byte": 1891, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_Availability_Arrow_FnArgument.ts" }
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class_emptySwitchCase.ts_0_436
/// <reference path='fourslash.ts' /> // @allowNonTsExtensions: true // @Filename: /a.js ////function /**/MyClass() { ////} ////MyClass.prototype.f = function(x) { //// switch (x) { //// case 0: //// } ////} verify.codeFix({ description: "Convert function to an ES2015 class", newFileContent: `class MyClass { constructor() { } f(x) { switch (x) { case 0: } } } `, });
{ "end_byte": 436, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class_emptySwitchCase.ts" }
TypeScript/tests/cases/fourslash/navbarForDoubleAmbientModules01.ts_0_486
/// <reference path="./fourslash.ts" /> //// declare module "foo"; //// declare module "foo"; verify.navigationBar([ { "text": "<global>", "kind": "script", "childItems": [ { "text": "\"foo\"", "kind": "module", "kindModifiers": "declare" } ] }, { "text": "\"foo\"", "kind": "module", "kindModifiers": "declare", "indent": 1 } ]);
{ "end_byte": 486, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navbarForDoubleAmbientModules01.ts" }
TypeScript/tests/cases/fourslash/autoImportPackageJsonImports_capsInPath1.ts_0_359
/// <reference path="fourslash.ts" /> // @module: nodenext // @Filename: /Dev/package.json //// { //// "imports": { //// "#thing": "./src/something.js" //// } //// } // @Filename: /Dev/src/something.ts //// export function something(name: string): any; // @Filename: /Dev/a.ts //// something/**/ verify.importFixModuleSpecifiers("", ["#thing"]);
{ "end_byte": 359, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPackageJsonImports_capsInPath1.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationDo.ts_0_406
/// <reference path='fourslash.ts' /> // @BaselineFile: bpSpan_do.baseline // @Filename: bpSpan_do.ts ////var i = 0; ////do ////{ //// i++; ////} while (i < 10); ////do { //// i++; ////} while (i < 20); ////do { //// i++; ////} ////while (i < 30); ////do { //// i--; ////} while ((function () { //// return 30 * i; //// })() !== i); verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 406, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDo.ts" }
TypeScript/tests/cases/fourslash/organizeImportsAttributes.ts_0_679
/// <reference path="fourslash.ts" /> //// import { A } from "./file"; //// import { type B } from "./file"; //// import { C } from "./file" assert { type: "a" }; //// import { A as D } from "./file" assert { type: "b" }; //// import { E } from "./file" with { type: "a" }; //// import { A as F } from "./file" with { type: "b" }; //// //// type G = A | B | C | D | E | F; verify.organizeImports( `import { A, type B } from "./file"; import { C } from "./file" assert { type: "a" }; import { A as D } from "./file" assert { type: "b" }; import { E } from "./file" with { type: "a" }; import { A as F } from "./file" with { type: "b" }; type G = A | B | C | D | E | F;`);
{ "end_byte": 679, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsAttributes.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingMember2.ts_0_313
/// <reference path='fourslash.ts' /> ////class C { //// method() { //// this.foo = 10; //// } ////} verify.codeFix({ description: "Add index signature for property 'foo'", index: 1, newFileContent: `class C { [x: string]: number; method() { this.foo = 10; } }` });
{ "end_byte": 313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember2.ts" }
TypeScript/tests/cases/fourslash/completionsLiteralOnPropertyValueMatchingGeneric.ts_0_248
/// <reference path="fourslash.ts" /> // @Filename: /a.tsx //// declare function bar1<P extends "" | "bar" | "baz">(p: { type: P }): void; //// //// bar1({ type: "/*ts*/" }) //// verify.completions({ marker: ["ts"], exact: ["", "bar", "baz"] });
{ "end_byte": 248, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsLiteralOnPropertyValueMatchingGeneric.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_shorthandPropertyAssignment1.ts_0_228
/// <reference path="fourslash.ts" /> // @Filename: /a.ts ////export const a = 1; // @Filename: /b.ts ////const b = { /**/a }; goTo.file("/b.ts"); verify.importFixAtPosition([ `import { a } from "./a"; const b = { a };` ]);
{ "end_byte": 228, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_shorthandPropertyAssignment1.ts" }
TypeScript/tests/cases/fourslash/jsRequireQuickInfo.ts_0_185
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: a.js ////const /**/x = require("./b"); // @Filename: b.js ////exports.x = 0; verify.quickInfoAt("",'import x');
{ "end_byte": 185, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsRequireQuickInfo.ts" }
TypeScript/tests/cases/fourslash/unusedImports14FS.ts_0_532
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @Filename: file2.ts //// [| import /* 1 */ A /* 2 */, /* 3 */ { /* 4 */ x /* 5 */ } /* 6 */ from './a'; |] //// console.log(A); // @Filename: file1.ts //// export default 10; //// export var x = 10; // It's ambiguous which token comment /* 6 */ applies to or whether it should be removed. // In the current implementation the comment is left behind, but this behavior isn't a requirement. verify.rangeAfterCodeFix("import /* 1 */ A /* 2 */ /* 6 */ from './a';");
{ "end_byte": 532, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedImports14FS.ts" }
TypeScript/tests/cases/fourslash/referencesForMergedDeclarations2.ts_0_317
/// <reference path='fourslash.ts'/> ////module ATest { //// export interface Bar { } ////} //// ////function ATest() { } //// /////*1*/import /*2*/alias = ATest; // definition //// ////var a: /*3*/alias.Bar; // namespace /////*4*/alias.call(this); // value verify.baselineFindAllReferences('1', '2', '3', '4');
{ "end_byte": 317, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForMergedDeclarations2.ts" }
TypeScript/tests/cases/fourslash/unusedImports7FS.ts_0_328
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @Filename: file2.ts //// [| import * as n from "./file1" |] // @Filename: file1.ts //// export class Calculator { //// handleChar() { } //// } //// export function test() { //// } //// export default function test2() { //// } verify.rangeAfterCodeFix('');
{ "end_byte": 328, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedImports7FS.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingCallParentheses16.ts_0_526
/// <reference path='fourslash.ts'/> // @strictNullChecks: true ////class Foo { //// #test = () => true; //// run() { //// this.#test/**/ && console.log('test'); //// } ////} verify.codeFixAvailable([ { description: ts.Diagnostics.Add_missing_call_parentheses.message } ]); verify.codeFix({ description: ts.Diagnostics.Add_missing_call_parentheses.message, index: 0, newFileContent: `class Foo { #test = () => true; run() { this.#test() && console.log('test'); } }`, });
{ "end_byte": 526, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingCallParentheses16.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics3.ts_0_135
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: a.js ////class C<T> { } verify.baselineSyntacticDiagnostics();
{ "end_byte": 135, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics3.ts" }
TypeScript/tests/cases/fourslash/completionsJsxAttributeInitializer.ts_0_796
/// <reference path="fourslash.ts" /> // @Filename: /a.tsx ////function f(this: { p: number; "a b": number }, x: number): void { //// <div foo=/**/ />; ////} verify.completions({ marker: "", includes: [ { name: "x", text: "(parameter) x: number", kind: "parameter", insertText: "{x}" }, { name: "p", text: "(property) p: number", kind: "property", insertText: "{this.p}", sortText: completion.SortText.SuggestedClassMembers, source: completion.CompletionSource.ThisProperty }, { name: "a b", text: '(property) "a b": number', kind: "property", insertText: '{this["a b"]}', sortText: completion.SortText.SuggestedClassMembers, source: completion.CompletionSource.ThisProperty }, ], preferences: { includeInsertTextCompletions: true, }, });
{ "end_byte": 796, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsJsxAttributeInitializer.ts" }
TypeScript/tests/cases/fourslash/completionList_getExportsOfModule.ts_0_447
/// <reference path='fourslash.ts'/> // This used to cause a crash because we would ask for exports on `"x"`, // which would return undefined and cause a NPE. Now we return emptySymbol instead. // See GH#16610. ////declare module "x" { //// declare var x: number; //// export = x; ////} //// ////let y: /**/ // This is just a dummy test to cause `getCompletionsAtPosition` to be called. verify.completions({ marker: "", excludes: "x" });
{ "end_byte": 447, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionList_getExportsOfModule.ts" }
TypeScript/tests/cases/fourslash/incrementalResolveAccessor.ts_0_362
/// <reference path="fourslash.ts" /> ////class c1 { //// get p1(): string { //// return "30"; //// } //// set p1(a: number) { //// a = "30"; //// } ////} ////var val = new c1(); ////var b = val.p1; /////*1*/b; // Resolve without typeCheck verify.quickInfoAt("1", "var b: string"); // TypeCheck verify.numberOfErrorsInCurrentFile(1);
{ "end_byte": 362, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incrementalResolveAccessor.ts" }
TypeScript/tests/cases/fourslash/renameStringLiteralTypes1.ts_0_368
/// <reference path='fourslash.ts' /> ////interface AnimationOptions { //// deltaX: number; //// deltaY: number; //// easing: "ease-in" | "ease-out" | "[|ease-in-out|]"; ////} //// ////function animate(o: AnimationOptions) { } //// ////animate({ deltaX: 100, deltaY: 100, easing: "[|ease-in-out|]" }); verify.baselineRenameAtRangesWithText("ease-in-out");
{ "end_byte": 368, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameStringLiteralTypes1.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionImportedNames.ts_0_347
/// <reference path='fourslash.ts' /> // @Filename: b.ts ////export {[|/*classAliasDefinition*/Class|]} from "./a"; // @Filename: a.ts ////export module Module { ////} ////export class /*classDefinition*/Class { //// private f; ////} ////export interface Interface { //// x; ////} verify.baselineGoToDefinition("classAliasDefinition");
{ "end_byte": 347, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionImportedNames.ts" }
TypeScript/tests/cases/fourslash/memberListOnThisInClassWithPrivates.ts_0_532
/// <reference path='fourslash.ts'/> ////class C1 { //// public pubMeth() {this./**/} // test on 'this.' //// private privMeth() {} //// public pubProp = 0; //// private privProp = 0; ////} verify.completions({ marker: "", exact: [ { name: "privMeth", text: "(method) C1.privMeth(): void" }, { name: "privProp", text: "(property) C1.privProp: number" }, { name: "pubMeth", text: "(method) C1.pubMeth(): void" }, { name: "pubProp", text: "(property) C1.pubProp: number" }, ], })
{ "end_byte": 532, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberListOnThisInClassWithPrivates.ts" }
TypeScript/tests/cases/fourslash/completionAfterBackslashFollowingString.ts_0_133
/// <reference path='fourslash.ts'/> ////Harness.newLine = ""\n/**/ verify.completions({ marker: "", exact: completion.globals });
{ "end_byte": 133, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionAfterBackslashFollowingString.ts" }
TypeScript/tests/cases/fourslash/formattingNonNullAssertionOperator.ts_0_515
/// <reference path='fourslash.ts' /> /////*1*/ 'bar' ! ; /////*2*/ ( 'bar' ) ! ; /////*3*/ 'bar' [ 1 ] ! ; /////*4*/ var bar = 'bar' . foo ! ; /////*5*/ var foo = bar ! ; format.document(); goTo.marker("1"); verify.currentLineContentIs("'bar'!;"); goTo.marker("2"); verify.currentLineContentIs("('bar')!;"); goTo.marker("3"); verify.currentLineContentIs("'bar'[1]!;"); goTo.marker("4"); verify.currentLineContentIs("var bar = 'bar'.foo!;"); goTo.marker("5"); verify.currentLineContentIs("var foo = bar!;");
{ "end_byte": 515, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingNonNullAssertionOperator.ts" }
TypeScript/tests/cases/fourslash/syntacticClassificationsConflictDiff3Markers2.ts_0_772
/// <reference path="fourslash.ts"/> ////<<<<<<< HEAD ////class C { } ////||||||| merged common ancestors ////class E { } ////======= ////class D { } ////>>>>>>> Branch - a const c = classification("original"); verify.syntacticClassificationsAre( c.comment("<<<<<<< HEAD"), c.keyword("class"), c.className("C"), c.punctuation("{"), c.punctuation("}"), c.comment("||||||| merged common ancestors"), c.keyword("class"), c.identifier("E"), c.punctuation("{"), c.punctuation("}"), c.comment("======="), c.keyword("class"), c.identifier("D"), c.punctuation("{"), c.punctuation("}"), c.comment(">>>>>>> Branch - a")); const c2 = classification("2020"); verify.semanticClassificationsAre("2020", c2.semanticToken("class.declaration", "C"), );
{ "end_byte": 772, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsConflictDiff3Markers2.ts" }
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_interfaceContextualParams.ts_0_886
/// <reference path='fourslash.ts' /> ////interface IFoo { //// method(x: string, y: string): void; ////} ////const x: IFoo = { //// method(/*a*/x, y/*b*/): void {}, ////}; /* When there are no type annotations on the params in the implementation, we ultimately would like to handle them like we do for calls resulting in `method({x, y}) {}`. Note that simply adding the annotations from the signature can fail as the implementation can take more paramters than the signatures. */ goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert parameters to destructured object", actionName: "Convert parameters to destructured object", actionDescription: "Convert parameters to destructured object", newContent: `interface IFoo { method({ x, y }: { x: string; y: string; }): void; } const x: IFoo = { method({ x, y }: { x; y; }): void {}, };` });
{ "end_byte": 886, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_interfaceContextualParams.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesSwitchCaseDefaultBroken.ts_0_611
/// <reference path='fourslash.ts' /> ////swi/*1*/tch(10) { //// case 1: //// case 2: //// c/*2*/ase 4: //// case 8: //// case 0xBEEF: //// de/*4*/fult: //// break; //// /*5*/cas 16: //// c/*3*/ase 12: //// function f() { //// br/*11*/eak; //// /*12*/break; //// } ////} //// ////sw/*6*/itch (10) { //// de/*7*/fault //// case 1: //// case 2 //// //// c/*8*/ose 4: //// case 8: //// case 0xBEEF: //// bre/*9*/ak; //// case 16: //// () => bre/*10*/ak; ////} verify.baselineDocumentHighlights(test.markers());
{ "end_byte": 611, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesSwitchCaseDefaultBroken.ts" }
TypeScript/tests/cases/fourslash/quickInfoOnUnionPropertiesWithIdenticalJSDocComments01.ts_0_926
/// <reference path="fourslash.ts" /> ////export type DocumentFilter = { //// /** A language id, like `typescript`. */ //// language: string; //// /** A Uri [scheme](#Uri.scheme), like `file` or `untitled`. */ //// scheme?: string; //// /** A glob pattern, like `*.{ts,js}`. */ //// pattern?: string; ////} | { //// /** A language id, like `typescript`. */ //// language?: string; //// /** A Uri [scheme](#Uri.scheme), like `file` or `untitled`. */ //// scheme: string; //// /** A glob pattern, like `*.{ts,js}`. */ //// pattern?: string; ////} | { //// /** A language id, like `typescript`. */ //// language?: string; //// /** A Uri [scheme](#Uri.scheme), like `file` or `untitled`. */ //// scheme?: string; //// /** A glob pattern, like `*.{ts,js}`. */ //// pattern: string; ////}; //// ////declare let x: DocumentFilter; ////x./**/language verify.baselineQuickInfo();
{ "end_byte": 926, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnUnionPropertiesWithIdenticalJSDocComments01.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess7.ts_0_517
/// <reference path='fourslash.ts' /> //// class A { //// /*a*/protected _a: string;/*b*/ //// } goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Generate 'get' and 'set' accessors", actionName: "Generate 'get' and 'set' accessors", actionDescription: "Generate 'get' and 'set' accessors", newContent: `class A { private _a: string; protected get /*RENAME*/a(): string { return this._a; } protected set a(value: string) { this._a = value; } }`, });
{ "end_byte": 517, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess7.ts" }
TypeScript/tests/cases/fourslash/findAllRefsJsThisPropertyAssignment.ts_0_636
/// <reference path="fourslash.ts" /> // @allowJs: true // @noImplicitThis: true // @Filename: infer.d.ts //// export declare function infer(o: { m(): void } & ThisType<{ x: number }>): void; // @Filename: a.js //// import { infer } from "./infer"; //// infer({ //// m() { //// this.x = 1; //// this./*1*/x; //// }, //// }); // @Filename: b.js //// /** //// * @template T //// * @param {{m(): void} & ThisType<{x: number}>} o //// */ //// function infer(o) {} //// infer({ //// m() { //// this.x = 2; //// this./*2*/x; //// }, //// }); verify.baselineFindAllReferences("1", "2");
{ "end_byte": 636, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsJsThisPropertyAssignment.ts" }
TypeScript/tests/cases/fourslash/completionPropertyShorthandForObjectLiteral2.ts_0_385
/// <reference path="fourslash.ts"/> //// const foo = 1; //// const bar = 2; //// const obj1 = { //// foo b/*1*/ //// }; //// const obj2: any = { //// foo b/*2*/ //// }; verify.completions({ marker: ["1"], exact: completion.globalsPlus(["bar", "foo", "obj2"]), }); verify.completions({ marker: ["2"], exact: completion.globalsPlus(["bar", "foo", "obj1"]), });
{ "end_byte": 385, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionPropertyShorthandForObjectLiteral2.ts" }
TypeScript/tests/cases/fourslash/completionListInNamedFunctionExpression.ts_0_631
/// <reference path="fourslash.ts"/> ////function foo(a: number): string { //// /*insideFunctionDeclaration*/ //// return ""; ////} //// ////(function foo(): number { //// /*insideFunctionExpression*/ //// fo/*referenceInsideFunctionExpression*/o; //// return ""; ////}) //// /////*globalScope*/ ////fo/*referenceInGlobalScope*/o; verify.completions({ marker: ["globalScope", "insideFunctionDeclaration", "insideFunctionExpression"], includes: "foo" }); verify.quickInfos({ referenceInsideFunctionExpression: "(local function) foo(): number", referenceInGlobalScope: "function foo(a: number): string" });
{ "end_byte": 631, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInNamedFunctionExpression.ts" }
TypeScript/tests/cases/fourslash/signatureHelpJSDocTags.ts_0_1485
///<reference path="fourslash.ts" /> //// /** //// * This is class Foo. //// * @mytag comment1 comment2 //// */ //// class Foo { //// /** //// * This is the constructor. //// * @myjsdoctag this is a comment //// */ //// constructor(value: number) {} //// /** //// * method1 documentation //// * @mytag comment1 comment2 //// */ //// static method1() {} //// /** //// * @mytag //// */ //// method2() {} //// /** //// * @mytag comment1 comment2 //// */ //// property1: string; //// /** //// * @mytag1 some comments //// * some more comments about mytag1 //// * @mytag2 //// * here all the comments are on a new line //// * @mytag3 //// * @mytag //// */ //// property2: number; //// /** //// * @returns {number} a value //// */ //// method3(): number { return 3; } //// /** //// * @param {string} foo A value. //// * @returns {number} Another value //// * @mytag //// */ //// method4(foo: string): number { return 3; } //// /** @mytag */ //// method5() {} //// /** method documentation //// * @mytag a JSDoc tag //// */ //// newMethod() {} //// } //// var foo = new Foo(/*10*/4); //// Foo.method1(/*11*/); //// foo.method2(/*12*/); //// foo.method3(/*13*/); //// foo.method4(); //// foo.property1; //// foo.property2; //// foo.method5(); //// foo.newMet verify.baselineSignatureHelp()
{ "end_byte": 1485, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpJSDocTags.ts" }
TypeScript/tests/cases/fourslash/genericCombinatorWithConstraints1.ts_0_339
/// <reference path='fourslash.ts'/> ////function apply<T, U extends Date>(source: T[], selector: (x: T) => U) { //// var /*1*/xs = source.map(selector); // any[] //// var /*2*/xs2 = source.map((x: T, a, b): U => { return null }); // any[] ////} verify.quickInfos({ 1: "(local var) xs: U[]", 2: "(local var) xs2: U[]" });
{ "end_byte": 339, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericCombinatorWithConstraints1.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingInvocationForDecorator01.ts_0_259
/// <reference path='fourslash.ts' /> ////declare function foo(): (...args: any[]) => void; ////class C { //// [|@foo|] //// bar() { //// //// } ////} verify.codeFix({ description: "Call decorator expression", newRangeContent: `@foo()` });
{ "end_byte": 259, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingInvocationForDecorator01.ts" }
TypeScript/tests/cases/fourslash/codeFixConvertToMappedObjectType7.ts_0_408
/// <reference path='fourslash.ts' /> //// type K = "foo" | "bar"; //// interface Foo { } //// interface Bar { } //// interface SomeType extends Foo, Bar { //// [prop: K]: any; //// } verify.codeFix({ description: `Convert 'SomeType' to mapped object type`, newFileContent: `type K = "foo" | "bar"; interface Foo { } interface Bar { } type SomeType = Foo & Bar & { [prop in K]: any; };` })
{ "end_byte": 408, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToMappedObjectType7.ts" }
TypeScript/tests/cases/fourslash/formatSimulatingScriptBlocks.ts_0_1234
/// <reference path="fourslash.ts" /> /////* BEGIN EXTERNAL SOURCE */ /////*begin5*/ //// var a = 1; //// alert("/*end5*//********//*begin4*/"); //// /*end4*/ /////* END EXTERNAL SOURCE */ //// /////* BEGIN EXTERNAL SOURCE */ /////*begin3*/ //// var b = 1; //// //// var c = "/*end3*//********//*begin2*/"; //// var d = 1; //// //// var e = "/*end2*//********//*begin1*/"; //// var f = 1; //// /*end1*/ /////* END EXTERNAL SOURCE */ format.setOption("BaseIndentSize", 12); format.selection("begin1", "end1"); format.selection("begin2", "end2"); format.selection("begin3", "end3"); format.setOption("BaseIndentSize", 24); format.selection("begin4", "end4"); format.selection("begin5", "end5"); verify.currentFileContentIs("/* BEGIN EXTERNAL SOURCE */\n\n var a = 1;\n alert(\"/********/\");\n\n/* END EXTERNAL SOURCE */\n\n/* BEGIN EXTERNAL SOURCE */\n\n var b = 1;\n\n var c = \"/********/\";\n var d = 1;\n\n var e = \"/********/\";\n var f = 1;\n\n/* END EXTERNAL SOURCE */");
{ "end_byte": 1234, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatSimulatingScriptBlocks.ts" }
TypeScript/tests/cases/fourslash/referencesForTypeKeywords.ts_0_689
/// <reference path='fourslash.ts'/> ////interface I {} ////function f<T /*typeParam_extendsKeyword*/extends I>() {} ////type A1<T, U> = T /*conditionalType_extendsKeyword*/extends U ? 1 : 0; ////type A2<T> = T extends /*inferType_inferKeyword*/infer U ? 1 : 0; ////type A3<T> = { [P /*mappedType_inOperator*/in keyof T]: 1 }; ////type A4<T> = /*keyofOperator_keyofKeyword*/keyof T; ////type A5<T> = /*readonlyOperator_readonlyKeyword*/readonly T[]; verify.baselineFindAllReferences( 'typeParam_extendsKeyword', 'conditionalType_extendsKeyword', 'inferType_inferKeyword', 'mappedType_inOperator', 'keyofOperator_keyofKeyword', 'readonlyOperator_readonlyKeyword')
{ "end_byte": 689, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForTypeKeywords.ts" }
TypeScript/tests/cases/fourslash/jsdocOnInheritedMembers2.ts_0_364
///<reference path="fourslash.ts" /> // @allowJs: true // @checkJs: true // @filename: /a.js /////** @template T */ ////class A { //// /** Method documentation. */ //// method() {} ////} //// /////** @extends {A<number>} */ ////const B = class extends A { //// method() {} ////} //// ////const b = new B(); ////b.method/**/; verify.baselineQuickInfo();
{ "end_byte": 364, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocOnInheritedMembers2.ts" }
TypeScript/tests/cases/fourslash/completionListAfterSpreadOperator01.ts_0_135
/// <reference path="fourslash.ts" /> ////let v = [1,2,3,4]; ////let x = [.../**/ verify.completions({ marker: "", includes: "v" });
{ "end_byte": 135, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAfterSpreadOperator01.ts" }
TypeScript/tests/cases/fourslash/jsDocPropertyDescription4.ts_0_381
///<reference path="fourslash.ts" /> //// interface MultipleExample { //// /** Something generic */ //// [key: string | number | symbol]: string; //// } //// function multipleExample(e: MultipleExample) { //// console.log(e./*multiple*/anything); //// } verify.quickInfoAt("multiple", "(index) MultipleExample[string | number | symbol]: string", "Something generic");
{ "end_byte": 381, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocPropertyDescription4.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_InIfStatement.ts_0_390
/// <reference path='fourslash.ts' /> ////let a = { b: { c: 0 } }; ////if(/*a*/a && a.b && a.b.c/*b*/){}; goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert to optional chain expression", actionName: "Convert to optional chain expression", actionDescription: "Convert to optional chain expression", newContent: `let a = { b: { c: 0 } }; if(a?.b?.c){};` });
{ "end_byte": 390, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_InIfStatement.ts" }
TypeScript/tests/cases/fourslash/codeFixUndeclaredPropertyObjectLiteralStrictNullChecks.ts_0_533
/// <reference path='fourslash.ts' /> // @strictNullChecks: true //// [|class A { //// constructor() { //// let e: any = 10; //// this.x = { a: 10, b: "hello", c: undefined, d: null, e: e }; //// } //// }|] verify.rangeAfterCodeFix(` class A { x: { a: number; b: string; c: undefined; d: null; e: any; }; constructor() { let e: any = 10; this.x = { a: 10, b: "hello", c: undefined, d: null, e: e }; } } `, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
{ "end_byte": 533, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUndeclaredPropertyObjectLiteralStrictNullChecks.ts" }
TypeScript/tests/cases/fourslash/formattingOnStatementsWithNoSemicolon.ts_0_4811
/// <reference path='fourslash.ts' /> /////*1*/do //// { var a/*2*/ /////*3*/} while (1) /////*4*/function f() { /////*5*/ var s = 1 /////*6*/ } /////*7*/switch (t) { /////*8*/ case 1: /////*9*/{ /////*10*/test /////*11*/} /////*12*/} /////*13*/do{do{do{}while(a!==b)}while(a!==b)}while(a!==b) /////*14*/do{ /////*15*/do{ /////*16*/do{ /////*17*/}while(a!==b) /////*18*/}while(a!==b) /////*19*/}while(a!==b) /////*20*/for(var i=0;i<10;i++){ /////*21*/for(var j=0;j<10;j++){ /////*22*/j-=i /////*23*/}/*24*/} /////*25*/function foo() { /////*26*/try { /////*27*/x+=2 /////*28*/} /////*29*/catch( e){ /////*30*/x+=2 /////*31*/}finally { /////*32*/x+=2 /////*33*/} /////*34*/} /////*35*/do { var a } while (1) //// foo(function (file) {/*49*/ //// return 0/*50*/ //// }).then(function (doc) {/*51*/ //// return 1/*52*/ //// });/*53*/ /////*54*/if(1) /////*55*/if(1) /////*56*/x++ /////*57*/else /////*58*/if(1) /////*59*/x+=2 /////*60*/else /////*61*/x+=2 //// //// //// /////*62*/; //// do do do do/*63*/ //// test;/*64*/ //// while (0)/*65*/ //// while (0)/*66*/ //// while (0)/*67*/ //// while (0)/*68*/ format.document(); goTo.marker("1"); verify.currentLineContentIs("do {"); goTo.marker("2"); verify.currentLineContentIs(" var a"); goTo.marker("3"); verify.currentLineContentIs("} while (1)"); goTo.marker("4"); verify.currentLineContentIs("function f() {"); goTo.marker("5"); verify.currentLineContentIs(" var s = 1"); goTo.marker("6"); verify.currentLineContentIs("}"); goTo.marker("7"); verify.currentLineContentIs("switch (t) {"); goTo.marker("8"); verify.currentLineContentIs(" case 1:"); goTo.marker("9"); verify.currentLineContentIs(" {"); goTo.marker("10"); verify.currentLineContentIs(" test"); goTo.marker("11"); verify.currentLineContentIs(" }"); goTo.marker("12"); verify.currentLineContentIs("}"); goTo.marker("13"); verify.currentLineContentIs("do { do { do { } while (a !== b) } while (a !== b) } while (a !== b)"); goTo.marker("14"); verify.currentLineContentIs("do {"); goTo.marker("15"); verify.currentLineContentIs(" do {"); goTo.marker("16"); verify.currentLineContentIs(" do {"); goTo.marker("17"); verify.currentLineContentIs(" } while (a !== b)"); goTo.marker("18"); verify.currentLineContentIs(" } while (a !== b)"); goTo.marker("19"); verify.currentLineContentIs("} while (a !== b)"); goTo.marker("20"); verify.currentLineContentIs("for (var i = 0; i < 10; i++) {"); goTo.marker("21"); verify.currentLineContentIs(" for (var j = 0; j < 10; j++) {"); goTo.marker("22"); verify.currentLineContentIs(" j -= i"); goTo.marker("23"); verify.currentLineContentIs(" }"); goTo.marker("24"); verify.currentLineContentIs(" }"); goTo.marker("25"); verify.currentLineContentIs("function foo() {"); goTo.marker("26"); verify.currentLineContentIs(" try {"); goTo.marker("27"); verify.currentLineContentIs(" x += 2"); goTo.marker("28"); verify.currentLineContentIs(" }"); goTo.marker("29"); verify.currentLineContentIs(" catch (e) {"); goTo.marker("30"); verify.currentLineContentIs(" x += 2"); goTo.marker("31"); verify.currentLineContentIs(" } finally {"); goTo.marker("32"); verify.currentLineContentIs(" x += 2"); goTo.marker("33"); verify.currentLineContentIs(" }"); goTo.marker("34"); verify.currentLineContentIs("}"); goTo.marker("35"); verify.currentLineContentIs("do { var a } while (1)"); goTo.marker("49"); verify.currentLineContentIs("foo(function(file) {"); goTo.marker("50"); verify.currentLineContentIs(" return 0"); goTo.marker("51"); verify.currentLineContentIs("}).then(function(doc) {"); goTo.marker("52"); verify.currentLineContentIs(" return 1"); goTo.marker("53"); verify.currentLineContentIs("});"); goTo.marker("54"); verify.currentLineContentIs("if (1)"); goTo.marker("55"); verify.currentLineContentIs(" if (1)"); goTo.marker("56"); verify.currentLineContentIs(" x++"); goTo.marker("57"); verify.currentLineContentIs(" else"); goTo.marker("58"); verify.currentLineContentIs(" if (1)"); goTo.marker("59"); verify.currentLineContentIs(" x += 2"); goTo.marker("60"); verify.currentLineContentIs(" else"); goTo.marker("61"); verify.currentLineContentIs(" x += 2"); goTo.marker("62"); verify.currentLineContentIs(" ;"); goTo.marker("63"); verify.currentLineContentIs("do do do do"); goTo.marker("64"); verify.currentLineContentIs(" test;"); goTo.marker("65"); verify.currentLineContentIs("while (0)"); goTo.marker("66"); verify.currentLineContentIs("while (0)"); goTo.marker("67"); verify.currentLineContentIs("while (0)"); goTo.marker("68"); verify.currentLineContentIs("while (0)");
{ "end_byte": 4811, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnStatementsWithNoSemicolon.ts" }
TypeScript/tests/cases/fourslash/goToTypeDefinition_returnType.ts_0_920
/// <reference path='fourslash.ts' /> ////interface /*I*/I { x: number; } ////interface /*J*/J { y: number; } //// ////function f0(): I { return { x: 0 }; } //// ////type T = /*T*/(i: I) => I; ////const f1: T = i => ({ x: i.x + 1 }); //// ////const f2 = (i: I): I => ({ x: i.x + 1 }); //// ////const f3 = (i: I) => (/*f3Def*/{ x: i.x + 1 }); //// ////const f4 = (i: I) => i; //// ////const f5 = /*f5Def*/(i: I): I | J => ({ x: i.x + 1 }); //// ////const f6 = (i: I, j: J, b: boolean) => b ? i : j; //// ////const /*f7Def*/f7 = (i: I) => {}; //// ////function f8(i: I): I; ////function f8(j: J): J; ////function /*f8Def*/f8(ij: any): any { return ij; } //// /////*f0*/f0(); /////*f1*/f1(); /////*f2*/f2(); /////*f3*/f3(); /////*f4*/f4(); /////*f5*/f5(); /////*f6*/f6(); /////*f7*/f7(); /////*f8*/f8(); verify.baselineGoToType( "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8" );
{ "end_byte": 920, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToTypeDefinition_returnType.ts" }
TypeScript/tests/cases/fourslash/formattingMappedType.ts_0_307
/// <reference path='fourslash.ts' /> /////*generic*/type t < T > = { /////*map*/ [ P in keyof T ] : T [ P ] ////}; format.document(); goTo.marker("generic"); verify.currentLineContentIs("type t<T> = {"); goTo.marker("map"); verify.currentLineContentIs(" [P in keyof T]: T[P]");
{ "end_byte": 307, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingMappedType.ts" }
TypeScript/tests/cases/fourslash/completionsImport_filteredByPackageJson_@typesOnly.ts_0_930
/// <reference path="fourslash.ts" /> //@noEmit: true //@Filename: /package.json ////{ //// "devDependencies": { //// "@types/react": "*" //// } ////} //@Filename: /node_modules/@types/react/index.d.ts ////export declare var React: any; //@Filename: /node_modules/@types/react/package.json ////{ //// "name": "@types/react" ////} //@Filename: /node_modules/@types/fake-react/index.d.ts ////export declare var ReactFake: any; //@Filename: /node_modules/@types/fake-react/package.json ////{ //// "name": "@types/fake-react" ////} //@Filename: /src/index.ts ////const x = Re/**/ verify.completions({ marker: test.marker(""), isNewIdentifierLocation: true, includes: { name: "React", hasAction: true, source: "/node_modules/@types/react/index", sortText: completion.SortText.AutoImportSuggestions }, excludes: "ReactFake", preferences: { includeCompletionsForModuleExports: true } });
{ "end_byte": 930, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_filteredByPackageJson_@typesOnly.ts" }
TypeScript/tests/cases/fourslash/inlayHintsInteractiveRestParameters1.ts_0_453
/// <reference path="fourslash.ts" /> //// function foo1(a: number, ...b: number[]) {} //// foo1(1, 1, 1, 1); //// type Args2 = [a: number, b: number] //// declare function foo2(c: number, ...args: Args2); //// foo2(1, 2, 3) //// type Args3 = [number, number] //// declare function foo3(c: number, ...args: Args3); //// foo3(1, 2, 3) verify.baselineInlayHints(undefined, { includeInlayParameterNameHints: "literals", interactiveInlayHints: true });
{ "end_byte": 453, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveRestParameters1.ts" }
TypeScript/tests/cases/fourslash/enumAddition.ts_0_159
/// <reference path="fourslash.ts" /> //// module m { export enum Color { Red } } //// var /**/t = m.Color.Red + 1; verify.quickInfoAt("", "var t: number");
{ "end_byte": 159, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/enumAddition.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_moveNamedImport1.ts_0_327
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////import { foo as oFoo } from './other'; ////[|export const x = oFoo();|] ////export const a = 0; verify.moveToNewFile({ newFileContents: { "/a.ts": `export const a = 0;`, "/x.ts": `import { foo as oFoo } from './other'; export const x = oFoo(); ` }, });
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_moveNamedImport1.ts" }
TypeScript/tests/cases/fourslash/completionListInScope.ts_0_2709
/// <reference path="fourslash.ts" /> ////module TestModule { //// var localVariable = ""; //// export var exportedVariable = 0; //// //// function localFunction() { } //// export function exportedFunction() { } //// //// class localClass { } //// export class exportedClass { } //// //// interface localInterface {} //// export interface exportedInterface {} //// //// module localModule { //// export var x = 0; //// } //// export module exportedModule { //// export var x = 0; //// } //// //// var v = /*valueReference*/ 0; //// var t :/*typeReference*/; ////} //// ////// Add some new items to the module ////module TestModule { //// var localVariable2 = ""; //// export var exportedVariable2 = 0; //// //// function localFunction2() { } //// export function exportedFunction2() { } //// //// class localClass2 { } //// export class exportedClass2 { } //// //// interface localInterface2 {} //// export interface exportedInterface2 {} //// //// module localModule2 { //// export var x = 0; //// } //// export module exportedModule2 { //// export var x = 0; //// } ////} ////var globalVar: string = ""; ////function globalFunction() { } //// ////class TestClass { //// property: number; //// method() { } //// staticMethod() { } //// testMethod(param: number) { //// var localVar = 0; //// function localFunction() {}; //// /*insideMethod*/ //// } ////} verify.completions( { marker: "valueReference", includes: [ "localVariable", "exportedVariable", "localFunction", "exportedFunction", "localClass", "exportedClass", "localModule", "exportedModule", "exportedVariable2", "exportedFunction2", "exportedClass2", "exportedModule2", ], isNewIdentifierLocation: true, // TODO: Should not be a new identifier location }, { marker: "typeReference", includes: [ "localInterface", "exportedInterface", "localClass", "exportedClass", "exportedClass2", ], excludes: [ "localModule", "exportedModule", "exportedModule2", ], }, { marker: "insideMethod", includes: [ "globalVar", "globalFunction", "param", "localVar", "localFunction", ], excludes: [ "property", "testMethod", "staticMethod", ], }, );
{ "end_byte": 2709, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInScope.ts" }
TypeScript/tests/cases/fourslash/findAllRefsExportDefaultClassConstructor.ts_0_103
////export default class { //// /*1*/constructor() {} ////} verify.baselineFindAllReferences('1');
{ "end_byte": 103, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsExportDefaultClassConstructor.ts" }
TypeScript/tests/cases/fourslash/renameInheritedProperties5.ts_3_280
/ <reference path='fourslash.ts'/> //// interface C extends D { //// propC: number; //// } //// interface D extends C { //// [|[|{| "contextRangeIndex": 0 |}propD|]: string;|] //// } //// var d: D; //// d.[|propD|]; verify.baselineRenameAtRangesWithText("propD");
{ "end_byte": 280, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameInheritedProperties5.ts" }
TypeScript/tests/cases/fourslash/findAllRefsInheritedProperties4.ts_3_322
/ <reference path='fourslash.ts'/> //// interface C extends D { //// /*0*/prop0: string; //// /*1*/prop1: number; //// } //// //// interface D extends C { //// /*2*/prop0: string; //// } //// //// var d: D; //// d./*3*/prop0; //// d./*4*/prop1; verify.baselineFindAllReferences('0', '2', '3', '1', '4')
{ "end_byte": 322, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsInheritedProperties4.ts" }
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue1.ts_0_166
/// <reference path='fourslash.ts' /> //// function Foo (): number { //// 1 //// } verify.codeFixAvailable([ { description: 'Add a return statement' }, ]);
{ "end_byte": 166, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue1.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDocTags11.ts_0_314
/// <reference path="fourslash.ts" /> // @noEmit: true // @allowJs: true // @Filename: quickInfoJsDocTags11.js /////** //// * @param {T1} a //// * @param {T2} b //// * @template {number} T1 Comment T1 //// * @template {number} T2 Comment T2 //// */ ////const /**/foo = (a, b) => {}; verify.baselineQuickInfo();
{ "end_byte": 314, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTags11.ts" }
TypeScript/tests/cases/fourslash/renameForAliasingExport02.ts_0_226
/// <reference path='fourslash.ts'/> // @Filename: foo.ts ////let x = 1; //// ////export { x as /**/[|y|] }; goTo.marker(); verify.renameInfoSucceeded(/*displayName*/"y", /*fullDisplayName*/'"/tests/cases/fourslash/foo".y');
{ "end_byte": 226, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameForAliasingExport02.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteral16.ts_0_473
/// <reference path='fourslash.ts' /> ////interface Foo { //// a: string; //// b: number; //// c: string; ////} //// ////declare function f1<T>(key: keyof T): T; ////declare function f2<T>(a: keyof T, b: keyof T): T; //// ////f1<Foo>("/*1*/",); ////f1<Foo>("/*2*/"); ////f1<Foo>("/*3*/",,,); ////f2<Foo>("/*4*/", "/*5*/",); ////f2<Foo>("/*6*/", "/*7*/"); ////f2<Foo>("/*8*/", "/*9*/",,,); verify.completions({ marker: test.markers(), exact: ["a", "b", "c"] });
{ "end_byte": 473, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral16.ts" }
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc25.ts_0_694
/// <reference path="fourslash.ts" /> // @strict: true ////class C { //// /** //// * @private //// * @param {number} foo //// * @param {Object} [bar] //// * @param {String} bar.a //// * @param {Object} [baz] //// * @param {number} baz.c //// */ //// m(foo, bar, baz) { } ////} verify.codeFix({ description: ts.Diagnostics.Annotate_with_type_from_JSDoc.message, index: 3, newFileContent: `class C { /** * @private * @param {number} foo * @param {Object} [bar] * @param {String} bar.a * @param {Object} [baz] * @param {number} baz.c */ m(foo: number, bar: { a: string; }, baz: { c: number; }) { } }`, });
{ "end_byte": 694, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc25.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_js_6.ts_0_543
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: a.js //// class A { //// "_a" = 2; //// /*a*/"a"/*b*/ = 1; //// } goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Generate 'get' and 'set' accessors", actionName: "Generate 'get' and 'set' accessors", actionDescription: "Generate 'get' and 'set' accessors", newContent: `class A { "_a" = 2; /*RENAME*/"_a_1" = 1; get "a"() { return this["_a_1"]; } set "a"(value) { this["_a_1"] = value; } }`, });
{ "end_byte": 543, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_js_6.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_importType2.ts_0_1295
/// <reference path="fourslash.ts" /> // @verbatimModuleSyntax: true // @module: es2015 // @Filename: /exports1.ts //// export default interface SomeType {} //// export interface OtherType {} //// export interface OtherOtherType {} //// export const someValue = 0; // @Filename: /a.ts //// import type SomeType from "./exports1.js"; //// someValue/*a*/ // @Filename: /b.ts //// import { someValue } from "./exports1.js"; //// const b: SomeType/*b*/ = someValue; // @Filename: /c.ts //// import type SomeType from "./exports1.js"; //// const x: OtherType/*c*/ // @Filename: /d.ts //// import type { OtherType } from "./exports1.js"; //// const x: OtherOtherType/*d*/ goTo.marker("a"); verify.importFixAtPosition([ `import type SomeType from "./exports1.js"; import { someValue } from "./exports1.js"; someValue`]); goTo.marker("b"); verify.importFixAtPosition([ `import type SomeType from "./exports1.js"; import { someValue } from "./exports1.js"; const b: SomeType = someValue;`]); goTo.marker("c"); verify.importFixAtPosition([ `import type { OtherType } from "./exports1.js"; import type SomeType from "./exports1.js"; const x: OtherType`]); goTo.marker("d"); verify.importFixAtPosition([ `import type { OtherOtherType, OtherType } from "./exports1.js"; const x: OtherOtherType`]);
{ "end_byte": 1295, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_importType2.ts" }
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsTypeParameterInInterface.ts_0_992
/// <reference path='fourslash.ts'/> ////interface /*1*/I</*2*/T> { //// new </*3*/U>(/*4*/a: /*5*/U, /*6*/b: /*7*/T): /*8*/U; //// </*9*/U>(/*10*/a: /*11*/U, /*12*/b: /*13*/T): /*14*/U; //// /*15*/method</*16*/U>(/*17*/a: /*18*/U, /*19*/b: /*20*/T): /*21*/U; ////} ////var /*22*/iVal: /*23*/I<string>; ////new /*24*/iVal("hello", "hello"); /////*25*/iVal("hello", "hello"); /////*26*/iVal./*27*/method("hello", "hello"); ////interface /*28*/I1</*29*/T extends /*30*/I<string>> { //// new </*31*/U extends /*32*/I<string>>(/*33*/a: /*34*/U, /*35*/b: /*36*/T): /*37*/U; //// </*38*/U extends /*39*/I<string>>(/*40*/a: /*41*/U, /*42*/b: /*43*/T): /*44*/U; //// /*45*/method</*46*/U extends /*47*/I<string>>(/*48*/a: /*49*/U, /*50*/b: /*51*/T): /*52*/U; ////} ////var /*53*/iVal1: /*54*/I1</*55*/I<string>>; ////new /*56*/iVal1(/*57*/iVal, /*58*/iVal); /////*59*/iVal1(/*60*/iVal, /*61*/iVal); /////*62*/iVal1./*63*/method(/*64*/iVal, /*65*/iVal); verify.baselineQuickInfo();
{ "end_byte": 992, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsTypeParameterInInterface.ts" }
TypeScript/tests/cases/fourslash/quickInfoOnCatchVariable.ts_0_147
/// <reference path="fourslash.ts" /> //// function f() { //// try { } catch (/**/e) { } //// } verify.quickInfoAt("", "(local var) e: any");
{ "end_byte": 147, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnCatchVariable.ts" }
TypeScript/tests/cases/fourslash/completionListAfterInvalidCharacter.ts_0_216
/// <reference path="fourslash.ts" /> ////// Completion after invalid character ////module testModule { //// export var foo = 1; ////} ////@ ////testModule./**/ verify.completions({ marker: "", exact: "foo" });
{ "end_byte": 216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAfterInvalidCharacter.ts" }
TypeScript/tests/cases/fourslash/quickInfoSatisfiesTag.ts_0_202
///<reference path="fourslash.ts" /> // @noEmit: true // @allowJS: true // @checkJs: true // @filename: /a.js /////** @satisfies {number} comment */ ////const /*1*/a = 1; verify.baselineQuickInfo();
{ "end_byte": 202, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoSatisfiesTag.ts" }
TypeScript/tests/cases/fourslash/codeFixNoPropertyAccessFromIndexSignature5.ts_0_408
/// <reference path='fourslash.ts'/> // @noPropertyAccessFromIndexSignature: true //// declare let x: { y: { [x: string]: string } }; //// x.y.yadda; verify.codeFix({ description: [ts.Diagnostics.Use_element_access_for_0.message, 'yadda'], index: 0, preferences: { quotePreference: 'single' }, newFileContent: `declare let x: { y: { [x: string]: string } }; x.y['yadda'];`, });
{ "end_byte": 408, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixNoPropertyAccessFromIndexSignature5.ts" }
TypeScript/tests/cases/fourslash/generatorDeclarationFormatting.ts_0_270
/// <reference path="fourslash.ts"/> //// function *g() { }/*1*/ //// var v = function *() { };/*2*/ format.document(); goTo.marker('1'); verify.currentLineContentIs("function* g() { }"); goTo.marker('2'); verify.currentLineContentIs("var v = function*() { };");
{ "end_byte": 270, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/generatorDeclarationFormatting.ts" }
TypeScript/tests/cases/fourslash/docCommentTemplatePrototypeMethod.ts_0_286
/// <reference path='fourslash.ts' /> // @Filename: foo.js /////** @class */ ////function C() { } /////*above*/ ////C.prototype.method = /*next*/ function (p) {} for (const marker of test.markerNames()) { verify.docCommentTemplateAt(marker, 7, `/** * * @param {any} p */`); }
{ "end_byte": 286, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplatePrototypeMethod.ts" }
TypeScript/tests/cases/fourslash/navigationItemsSpecialPropertyAssignment.ts_0_1236
/// <reference path="fourslash.ts"/> // @noLib: true // @allowJs: true // @Filename: /a.js ////[|exports.x = 0|]; ////[|exports.y = function() {}|]; ////function Cls() { //// [|this.instanceProp = 0|]; ////} ////[|Cls.staticMethod = function() {}|]; ////[|Cls.staticProperty = 0|]; ////[|Cls.prototype.instanceMethod = function() {}|]; const [rX, rY0, rInstanceProp, rStaticMethod, rStaticProp, rInstanceMethod] = test.ranges(); verify.navigateTo( { pattern: "x", expected: [{ name: "x", kind: "const", range: rX }] }, { pattern: "y", expected: [{ name: "y", kind: "function", range: rY0 }], }, { pattern: "instanceProp", expected: [ { name: "instanceProp", kind: "property", range: rInstanceProp, containerName: "Cls", containerKind: "function" }, ], }, { pattern: "staticMethod", expected: [{ name: "staticMethod", kind: "method", range: rStaticMethod }], }, { pattern: "staticProperty", expected: [{ name: "staticProperty", kind: "property", range: rStaticProp }], }, { pattern: "instanceMethod", expected: [{ name: "instanceMethod", kind: "method", range: rInstanceMethod }], }, );
{ "end_byte": 1236, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationItemsSpecialPropertyAssignment.ts" }
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_EmptyReturn.ts_0_370
/// <reference path='fourslash.ts' /> //// const foo = /*x*/f/*y*/unction() { //// return; //// }; goTo.select("x", "y"); edit.applyRefactor({ refactorName: "Convert arrow function or function expression", actionName: "Convert to arrow function", actionDescription: "Convert to arrow function", newContent: `const foo = () => { return; };`, });
{ "end_byte": 370, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_EmptyReturn.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements2.ts_0_332
/// <reference path="fourslash.ts" /> // @noUnusedLocals: true // @noUnusedParameters: true ////[|function f({ //// a, b, //// c, ////}: any)|] { //// a; //// c; ////} verify.codeFix({ index: 0, description: "Remove unused declaration for: 'b'", newRangeContent: `function f({ a, c, }: any)` });
{ "end_byte": 332, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements2.ts" }
TypeScript/tests/cases/fourslash/codeFixImplicitThis_ts_all.ts_0_516
/// <reference path='fourslash.ts' /> // @noImplicitThis: true ////class C { //// m() { //// function f() { //// this; //// } //// const g = function() { //// this; //// }; //// } ////} verify.codeFixAll({ fixId: "fixImplicitThis", fixAllDescription: "Fix all implicit-'this' errors", newFileContent: `class C { m() { const f = () => { this; } const g = () => { this; }; } }`, });
{ "end_byte": 516, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImplicitThis_ts_all.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts_0_1086
/// <reference path='fourslash.ts' /> // Should not give duplicate entries for similarly named files with different extensions // @Filename: tests/test0.ts //// import * as foo1 from "fake-module//*import_as0*/ //// import foo2 = require("fake-module//*import_equals0*/ //// var foo3 = require("fake-module//*require0*/ // @Filename: package.json //// { "dependencies": { "fake-module": "latest" }, "devDependencies": { "fake-module-dev": "latest" } } // @Filename: node_modules/fake-module/repeated.ts //// /*repeatedts*/ // @Filename: node_modules/fake-module/repeated.tsx //// /*repeatedtsx*/ // @Filename: node_modules/fake-module/repeated.d.ts //// /*repeateddts*/ // @Filename: node_modules/fake-module/other.js //// /*other*/ // @Filename: node_modules/fake-module/other2.js //// /*other2*/ // @Filename: node_modules/unlisted-module/index.js //// /*unlisted-module*/ // @Filename: ambient.ts //// declare module "fake-module/other" verify.completions({ marker: ["import_as0", "import_equals0", "require0"], exact: ["other", "repeated"], isNewIdentifierLocation: true });
{ "end_byte": 1086, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts" }
TypeScript/tests/cases/fourslash/signatureHelpOptionalCall2.ts_0_346
/// <reference path='fourslash.ts'/> ////declare const fnTest: undefined | ((str: string, num: number) => void); ////fnTest?.(/*1*/); verify.signatureHelp( { marker: "1", text: 'fnTest(str: string, num: number): void', parameterCount: 2, parameterName: "str", parameterSpan: "str: string", }, );
{ "end_byte": 346, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpOptionalCall2.ts" }
TypeScript/tests/cases/fourslash/pathCompletionsTypesVersionsWildcard2.ts_0_718
/// <reference path="fourslash.ts" /> // @module: commonjs // @Filename: /node_modules/foo/package.json //// { //// "types": "index.d.ts", //// "typesVersions": { //// "<=3.4.1": { //// "*": ["ts-old/*"] //// } //// } //// } // @Filename: /node_modules/foo/nope.d.ts //// export const nope = 0; // @Filename: /node_modules/foo/ts-old/index.d.ts //// export const index = 0; // @Filename: /node_modules/foo/ts-old/blah.d.ts //// export const blah = 0; // @Filename: /node_modules/foo/ts-old/subfolder/one.d.ts //// export const one = 0; // @Filename: /a.ts //// import { } from "foo//**/"; verify.completions({ marker: "", isNewIdentifierLocation: true, exact: ["nope", "ts-old"], });
{ "end_byte": 718, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsTypesVersionsWildcard2.ts" }
TypeScript/tests/cases/fourslash/quickInfoSignatureRestParameterFromUnion1.ts_0_401
/// <reference path='fourslash.ts'/> // based on https://github.com/microsoft/TypeScript/issues/55574 //// declare const rest: //// | ((v: { a: true }, ...rest: string[]) => unknown) //// | ((v: { b: true }) => unknown); //// //// /**/rest({ a: true, b: true }, "foo", "bar"); verify.quickInfoAt( "", `const rest: (v: { a: true; } & { b: true; }, ...rest: string[]) => unknown`, );
{ "end_byte": 401, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoSignatureRestParameterFromUnion1.ts" }
TypeScript/tests/cases/fourslash/completionsImport_duplicatePackages_scopedTypes.ts_0_1676
/// <reference path="fourslash.ts" /> // @module: commonjs // @esModuleInterop: true // @Filename: /node_modules/@types/scope__react-dom/package.json //// { "name": "react-dom", "version": "1.0.0", "types": "./index.d.ts" } // @Filename: /node_modules/@types/scope__react-dom/index.d.ts //// import * as React from "react"; //// export function render(): void; // @Filename: /node_modules/@types/scope__react/package.json //// { "name": "react", "version": "1.0.0", "types": "./index.d.ts" } // @Filename: /node_modules/@types/scope__react/index.d.ts //// import "./other"; //// export declare function useState(): void; // @Filename: /node_modules/@types/scope__react/other.d.ts //// export declare function useRef(): void; // @Filename: /packages/a/node_modules/@types/scope__react/package.json //// { "name": "react", "version": "1.0.1", "types": "./index.d.ts" } // @Filename: /packages/a/node_modules/@types/scope__react/index.d.ts //// export declare function useState(): void; // @Filename: /packages/a/index.ts //// import "@scope/react-dom"; //// import "@scope/react"; // @Filename: /packages/a/foo.ts //// /**/ goTo.marker(""); verify.completions({ marker: "", exact: completion.globalsPlus([{ name: "render", source: "@scope/react-dom", sourceDisplay: "@scope/react-dom", hasAction: true, sortText: completion.SortText.AutoImportSuggestions, }, { name: "useState", source: "@scope/react", sourceDisplay: "@scope/react", hasAction: true, sortText: completion.SortText.AutoImportSuggestions, }]), preferences: { includeCompletionsForModuleExports: true, allowIncompleteCompletions: true, }, });
{ "end_byte": 1676, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_duplicatePackages_scopedTypes.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteral3.ts_0_619
/// <reference path='fourslash.ts'/> ////declare function f(a: "A", b: number): void; ////declare function f(a: "B", b: number): void; ////declare function f(a: "C", b: number): void; ////declare function f(a: string, b: number): void; //// ////f("[|/*1*/C|]", 2); //// ////f("/*2*/ verify.completions({ marker: "1", exact: [ { name: "A", replacementSpan: test.ranges()[0] }, { name: "B", replacementSpan: test.ranges()[0] }, { name: "C", replacementSpan: test.ranges()[0] } ], isNewIdentifierLocation: true }); verify.completions({ marker: "2", exact: [ "A", "B", "C"], isNewIdentifierLocation: true });
{ "end_byte": 619, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral3.ts" }
TypeScript/tests/cases/fourslash/callHierarchyFunctionAmbiguity.2.ts_0_338
/// <reference path="fourslash.ts" /> // @filename: a.d.ts //// declare function /**/foo(x?: number): void; // @filename: b.d.ts //// declare function foo(x?: string): void; //// declare function foo(x?: boolean): void; // @filename: main.ts //// function bar() { //// foo(); //// } goTo.marker(); verify.baselineCallHierarchy();
{ "end_byte": 338, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyFunctionAmbiguity.2.ts" }
TypeScript/tests/cases/fourslash/completionListClassMembersWithSuperClassFromUnknownNamespace.ts_0_212
/// <reference path="fourslash.ts" /> ////class Child extends Namespace.Parent { //// /**/ ////} verify.completions({ marker: "", includes: completion.classElementKeywords, isNewIdentifierLocation: true });
{ "end_byte": 212, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListClassMembersWithSuperClassFromUnknownNamespace.ts" }
TypeScript/tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc3.ts_0_140
/// <reference path='fourslash.ts' /> /////** @param p */ /////*/**/ ////function foo(p) {} verify.docCommentTemplateAt("", 3, `/** */`);
{ "end_byte": 140, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc3.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports49-private-name.ts_0_834
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true // @moduleResolution: node // @target: es2018 // @jsx: react-jsx ////export function two() { //// const y = ""; //// return {} as typeof y; ////} //// ////export function three() { //// type Z = string; //// return {} as Z; ////} verify.codeFix({ description: "Add return type '\"\"'", index: 0, newFileContent: `export function two(): "" { const y = ""; return {} as typeof y; } export function three() { type Z = string; return {} as Z; }`, }); verify.codeFix({ description: "Add return type 'string'", index: 1, newFileContent: `export function two() { const y = ""; return {} as typeof y; } export function three(): string { type Z = string; return {} as Z; }`, });
{ "end_byte": 834, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports49-private-name.ts" }
TypeScript/tests/cases/fourslash/javaScriptModules12.ts_0_1582
///<reference path="fourslash.ts" /> // Invocations of 'require' stop top-level variables from becoming global // @allowJs: true // @Filename: mod1.js //// var x = require('fs'); //// /*1*/ // @Filename: mod2.js //// var y; //// if(true) { //// y = require('fs'); //// } //// /*2*/ // @Filename: glob1.js //// var a = require; //// /*3*/ // @Filename: glob2.js //// var b = ''; //// /*4*/ // @Filename: consumer.js //// /*5*/ verify.completions( { marker: "1", includes: [ "x", { name: "a", sortText: completion.SortText.GlobalsOrKeywords }, { name: "b", sortText: completion.SortText.GlobalsOrKeywords } ], excludes: "y" }, { marker: "2", includes: [ "y", { name: "a", sortText: completion.SortText.GlobalsOrKeywords }, { name: "b", sortText: completion.SortText.GlobalsOrKeywords } ], excludes: "x" }, { marker: "3", includes: [ "a", { name: "b", sortText: completion.SortText.GlobalsOrKeywords } ], excludes: ["x", "y"] }, { marker: "4", includes: [ { name: "a", sortText: completion.SortText.GlobalsOrKeywords }, "b" ], excludes: ["x", "y"] }, { marker: ["5"], includes: [ { name: "a", sortText: completion.SortText.GlobalsOrKeywords }, { name: "b", sortText: completion.SortText.GlobalsOrKeywords } ], excludes: ["x", "y"] }, );
{ "end_byte": 1582, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javaScriptModules12.ts" }
TypeScript/tests/cases/fourslash/extract-method_jsxSelfClosingElement2.ts_0_596
/// <reference path='fourslash.ts' /> // @jsx: preserve // @filename: a.tsx ////function Foo() { //// return ( //// <div> //// /*a*/<br />/*b*/ //// </div> //// ); ////} goTo.file("a.tsx"); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "function_scope_0", actionDescription: "Extract to inner function in function 'Foo'", newContent: `function Foo() { return ( <div> {newFunction()} </div> ); function /*RENAME*/newFunction() { return <br />; } }` });
{ "end_byte": 596, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method_jsxSelfClosingElement2.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionOverriddenMember1.ts_0_212
/// <reference path="./fourslash.ts"/> // @noImplicitOverride: true ////class Foo { //// /*2*/p = ''; ////} ////class Bar extends Foo { //// [|/*1*/override|] p = ''; ////} verify.baselineGoToDefinition("1");
{ "end_byte": 212, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionOverriddenMember1.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingConstToArrayDestructuring2.ts_0_226
/// <reference path='fourslash.ts' /> ////[x, y] = [0, 1]; verify.codeFixAll({ fixId: "addMissingConst", fixAllDescription: "Add 'const' to all unresolved variables", newFileContent: "const [x, y] = [0, 1];" });
{ "end_byte": 226, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingConstToArrayDestructuring2.ts" }
TypeScript/tests/cases/fourslash/stringLiteralCompletionsForGenericConditionalTypesUsingTemplateLiteralTypes.ts_0_600
/// <reference path="fourslash.ts" /> // repro from https://github.com/microsoft/TypeScript/issues/49680 //// type PathOf<T, K extends string, P extends string = ""> = //// K extends `${infer U}.${infer V}` //// ? U extends keyof T ? PathOf<T[U], V, `${P}${U}.`> : `${P}${keyof T & (string | number)}` //// : K extends keyof T ? `${P}${K}` : `${P}${keyof T & (string | number)}`; //// //// declare function consumer<K extends string>(path: PathOf<{a: string, b: {c: string}}, K>) : number; //// //// consumer('b./*ts*/') verify.completions({ marker: ["ts"], exact: ["a", "b", "b.c"] });
{ "end_byte": 600, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/stringLiteralCompletionsForGenericConditionalTypesUsingTemplateLiteralTypes.ts" }
TypeScript/tests/cases/fourslash/signatureHelpRestArgs2.ts_0_409
/// <reference path="fourslash.ts" /> // @strict: true // @allowJs: true // @checkJs: true // @filename: index.js //// const promisify = function (thisArg, fnName) { //// const fn = thisArg[fnName]; //// return function () { //// return new Promise((resolve) => { //// fn.call(thisArg, ...arguments, /*1*/); //// }); //// }; //// }; verify.baselineSignatureHelp();
{ "end_byte": 409, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpRestArgs2.ts" }
TypeScript/tests/cases/fourslash/goToImplementationInterfaceProperty_01.ts_0_340
/// <reference path='fourslash.ts'/> // Should handle property assignments within class declarations //// interface Foo { hello: number } //// //// class Bar implements Foo { //// [|hello|] = 5 * 9; //// } //// //// function whatever(foo: Foo) { //// foo.he/*reference*/llo; //// } verify.baselineGoToImplementation("reference");
{ "end_byte": 340, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationInterfaceProperty_01.ts" }
TypeScript/tests/cases/fourslash/fixExactOptionalUnassignableProperties3.ts_0_495
/// <reference path='fourslash.ts'/> // @strictNullChecks: true // @exactOptionalPropertyTypes: true // @Filename: fixExactOptionalUnassignableProperties2.ts //// import { INodeModules } from 'foo' //// interface J { //// a?: number | undefined //// } //// declare var inm: INodeModules //// declare var j: J //// inm/**/ = j //// console.log(inm) // @Filename: node_modules/@types/foo/index.d.ts //// export interface INodeModules { //// a?: number //// } verify.codeFixAvailable([]);
{ "end_byte": 495, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixExactOptionalUnassignableProperties3.ts" }
TypeScript/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace.ts_0_751
/// <reference path="fourslash.ts" /> // @module: esnext // @Filename: /a.d.ts ////declare namespace N { //// export const foo = 0; ////} ////export = N; // @Filename: /b.ts ////f/**/; verify.completions({ marker: "", includes: { name: "foo", source: "/a", sourceDisplay: "./a", text: "const N.foo: 0", kind: "const", kindModifiers: "export,declare", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, preferences: { includeCompletionsForModuleExports: true }, }); verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", description: `Add import from "./a"`, newFileContent: `import { foo } from "./a"; f;`, });
{ "end_byte": 751, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace.ts" }
TypeScript/tests/cases/fourslash/unusedMethodInClass5.ts_0_238
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true ////class C { //// private ["string"] (){} ////} verify.codeFix({ description: `Remove unused declaration for: '["string"]'`, newFileContent: "class C {\n}", });
{ "end_byte": 238, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedMethodInClass5.ts" }
TypeScript/tests/cases/fourslash/memberListOfVarInArrowExpression.ts_0_531
/// <reference path='fourslash.ts' /> ////interface IMap<T> { //// [key: string]: T; ////} ////var map: IMap<{ a1: string; }[]>; ////var categories: string[]; ////each(categories, category => { //// var changes = map[category]; //// changes[0]./*1*/a1; //// return each(changes, change => { //// }); ////}); ////function each<T>(items: T[], handler: (item: T) => void) { } verify.quickInfoAt("1", "(property) a1: string"); verify.completions({ marker: "1", exact: { name: "a1", text: "(property) a1: string" } });
{ "end_byte": 531, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberListOfVarInArrowExpression.ts" }
TypeScript/tests/cases/fourslash/getOutliningForArrayDestructuring.ts_0_705
/// <reference path="fourslash.ts"/> ////const[| [ //// a, //// b, //// c ////]|] =[| [ //// 1, //// 2, //// 3 ////]|]; ////const[| [ //// [|[ //// [|[ //// [|[ //// a, //// b, //// c //// ]|] //// ]|] //// ]|], //// [|[ //// a1, //// b1, //// c1 //// ]|] ////]|] =[| [ //// [|[ //// [|[ //// [|[ //// 1, //// 2, //// 3 //// ]|] //// ]|] //// ]|], //// [|[ //// 1, //// 2, //// 3 //// ]|] ////]|] verify.outliningSpansInCurrentFile(test.ranges(), "code");
{ "end_byte": 705, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOutliningForArrayDestructuring.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceAuto2.ts_0_712
/// <reference path='fourslash.ts' /> // @filename: a.ts ////export interface I { //// a(): void; //// b(x: 'x', y: 'a' | 'b'): 'b'; //// //// c: 'c'; //// d: { e: 'e'; }; ////} // @filename: b.ts ////import { I } from './a'; ////class Foo implements I {} goTo.file("b.ts") verify.codeFix({ description: [ts.Diagnostics.Implement_interface_0.message, "I"], index: 0, newFileContent: `import { I } from './a'; class Foo implements I { a(): void { throw new Error('Method not implemented.'); } b(x: 'x', y: 'a' | 'b'): 'b' { throw new Error('Method not implemented.'); } c: 'c'; d: { e: 'e'; }; }`, preferences: { quotePreference: "auto" } });
{ "end_byte": 712, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceAuto2.ts" }
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax9.ts_0_218
/// <reference path='fourslash.ts' /> //// var x: [|function(new: number)|] = 12; verify.codeFix({ description: "Change 'function(new: number)' to 'new () => number'", newRangeContent: "new () => number", });
{ "end_byte": 218, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax9.ts" }