_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/getEditsForFileRename_renameFromIndex.ts_0_1112
/// <reference path='fourslash.ts' /> // @Filename: /a.ts /////// <reference path="./src/index.ts" /> ////import old from "./src"; ////import old2 from "./src/index"; // @Filename: /src/a.ts /////// <reference path="./index.ts" /> ////import old from "."; ////import old2 from "./index"; // @Filename: /src/foo/a.ts /////// <reference path="../index.ts" /> ////import old from ".."; ////import old2 from "../index"; // @Filename: /src/index.ts //// // @Filename: /tsconfig.json ////{ "files": ["a.ts", "src/a.ts", "src/foo/a.ts", "src/index.ts"] } verify.getEditsForFileRename({ oldPath: "/src/index.ts", newPath: "/src/new.ts", newFileContents: { "/a.ts": `/// <reference path="./src/new.ts" /> import old from "./src/new"; import old2 from "./src/new";`, "/src/a.ts": `/// <reference path="./new.ts" /> import old from "./new"; import old2 from "./new";`, "/src/foo/a.ts": `/// <reference path="../new.ts" /> import old from "../new"; import old2 from "../new";`, "/tsconfig.json": '{ "files": ["a.ts", "src/a.ts", "src/foo/a.ts", "src/new.ts"] }', }, });
{ "end_byte": 1112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_renameFromIndex.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts_0_274
/// <reference path='fourslash.ts' /> ////interface I<T> { x: T; } ////class C implements I<number> { } verify.codeFix({ description: "Implement interface 'I<number>'", newFileContent: `interface I<T> { x: T; } class C implements I<number> { x: number; }` });
{ "end_byte": 274, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts" }
TypeScript/tests/cases/fourslash/memberListAfterSingleDot.ts_0_103
/// <reference path='fourslash.ts'/> ////./**/ verify.completions({ marker: "", exact: undefined });
{ "end_byte": 103, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberListAfterSingleDot.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts_0_392
/// <reference path="fourslash.ts" /> // @allowNonTsExtensions: true // @Filename: Foo.js //// function f() { //// // helloWorld leaks from here into the global space? //// if (helloWorld) { //// return 3; //// } //// return 5; //// } //// //// hello/**/ verify.completions({ includes: { name: "helloWorld", sortText: completion.SortText.JavascriptIdentifiers } });
{ "end_byte": 392, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts" }
TypeScript/tests/cases/fourslash/memberListOfModule.ts_0_226
/// <reference path='fourslash.ts' /> ////module Foo { //// export class Bar { //// //// } //// //// //// export module Blah { //// //// } ////} //// ////var x: Foo./**/ verify.completions({ marker: "", exact: "Bar" });
{ "end_byte": 226, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberListOfModule.ts" }
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_initializer.ts_0_501
/// <reference path='fourslash.ts' /> ////function f(/*a*/a: number, b: string = "1"/*b*/): string { //// return b; ////} ////f(4, "b"); 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: `function f({ a, b = "1" }: { a: number; b?: string; }): string { return b; } f({ a: 4, b: "b" });` });
{ "end_byte": 501, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_initializer.ts" }
TypeScript/tests/cases/fourslash/quickInfoSignatureRestParameterFromUnion4.ts_0_364
/// <reference path='fourslash.ts'/> //// declare const fn: //// | ((a?: { x: number }, b?: { x: number }) => number) //// | ((...a: { y: number }[]) => number); //// //// /**/fn(); verify.quickInfoAt( "", `const fn: (a?: { x: number; } & { y: number; }, b?: { x: number; } & { y: number; }, ...args: { y: number; }[]) => number`, );
{ "end_byte": 364, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoSignatureRestParameterFromUnion4.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteral6.ts_0_273
/// <reference path='fourslash.ts'/> ////interface Foo { //// x: "abc" | "def"; ////} ////function bar(f: Foo) { }; ////bar({x: "[|/**/|]"}); verify.completions({ marker: "", exact: ["abc", "def"].map(name => ({ name, replacementSpan: test.ranges()[0] })) });
{ "end_byte": 273, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral6.ts" }
TypeScript/tests/cases/fourslash/renameJsPropertyAssignment2.ts_0_285
/// <reference path='fourslash.ts'/> // @allowJs: true // @Filename: a.js ////class Minimatch { ////} ////[|Minimatch.[|{| "contextRangeIndex": 0 |}staticProperty|] = "string";|] ////console.log(Minimatch.[|staticProperty|]); verify.baselineRenameAtRangesWithText("staticProperty");
{ "end_byte": 285, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameJsPropertyAssignment2.ts" }
TypeScript/tests/cases/fourslash/parameterWithDestructuring.ts_0_485
/// <reference path='fourslash.ts'/> ////const result = [{ a: 'hello' }] //// .map(({ /*1*/a }) => /*2*/a) //// .map(a => a); //// ////const f1 = (a: (b: string[]) => void) => {}; ////f1(([a, b]) => { /*3*/a.charAt(0); }); //// ////function f2({/*4*/a }: { a: string; }, [/*5*/b]: [string]) {} verify.quickInfos({ 1: "(parameter) a: string", 2: "(parameter) a: string", 3: "(parameter) a: string", 4: "(parameter) a: string", 5: "(parameter) b: string" });
{ "end_byte": 485, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/parameterWithDestructuring.ts" }
TypeScript/tests/cases/fourslash/completionListAfterAnyType.ts_0_241
/// <reference path="fourslash.ts"/> //// declare class myString { //// charAt(pos: number): string; //// } //// //// function bar(a: myString) { //// var x: any = a./**/ //// } verify.completions({ marker: "", exact: "charAt" });
{ "end_byte": 241, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAfterAnyType.ts" }
TypeScript/tests/cases/fourslash/javaScriptModules17.ts_0_471
///<reference path="fourslash.ts" /> // @allowJs: true // @Filename: myMod.js //// module.exports = { n: 3, s: 'foo', b: true }; // @Filename: consumer.js //// var x = require('./myMod'); //// x/**/; goTo.file('consumer.js'); goTo.marker(); edit.insert('.'); verify.completions({ includes: ["n", "s", "b"].map(name => ({ name, kind: "property" })) }); edit.insert('n.'); verify.completions({ includes: { name: "toFixed", kind: "method", kindModifiers: "declare" } });
{ "end_byte": 471, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javaScriptModules17.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationTypeAssertionExpressions.ts_0_368
/// <reference path='fourslash.ts' /> // @BaselineFile: bpSpan_typeAssertionExpressions.baseline // @Filename: bpSpan_typeAssertionExpressions.ts ////class Greeter { ////} ////var a = <Greeter>new Greeter(); ////a = (<Greeter> new Greeter()); ////a = <Greeter>(function foo() { //// return new Greeter(); ////})(); verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 368, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationTypeAssertionExpressions.ts" }
TypeScript/tests/cases/fourslash/incompleteFunctionCallCodefixTypeUnions.ts_0_604
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////function existing<T, U>(value1: T | U & string, value2: U & T, value3: U | T, value4: U) { //// added/*1*/(value1, value2, value3, value4); ////} goTo.marker("1"); verify.codeFix({ description: "Add missing function declaration 'added'", index: 0, newFileContent: `function existing<T, U>(value1: T | U & string, value2: U & T, value3: U | T, value4: U) { added(value1, value2, value3, value4); } function added<T, U, V>(value1: T, value2: U, value3: V, value4: U) { throw new Error("Function not implemented."); } `, });
{ "end_byte": 604, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incompleteFunctionCallCodefixTypeUnions.ts" }
TypeScript/tests/cases/fourslash/completionListWithModulesInsideModuleScope.ts_0_6467
/// <reference path='fourslash.ts'/> // @noLib: true ////namespace mod1 { //// var mod1var = 1; //// function mod1fn() { //// var bar = 1; //// function foob() { } //// /*function*/ //// } //// class mod1cls { //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// /*class*/ //// } //// interface mod1int { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// /*interface*/ //// } //// namespace mod1mod { //// var m1X = 1; //// function m1Func() { //// var bar = 1; //// function foob() { } //// } //// class m1Class { //// private cVar = 1; //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// interface m1Int { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// } //// export var m1eX = 1; //// export function m1eFunc() { //// } //// export class m1eClass { //// private cVar = 1; //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// export interface m1eInt { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// } //// namespace m1Mod { } //// export namespace m1eMod { } //// /*namespace*/ //// var tmp: /*namespaceType*/ //// } //// export var mod1evar = 1; //// export function mod1efn() { //// var bar = 1; //// function foob() { } //// /*exportedFunction*/ //// } //// export class mod1ecls { //// private cVar = 1; //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// /*exportedClass*/ //// } //// export interface mod1eint { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// /*exportedInterface*/ //// } //// export namespace mod1emod { //// var mX = 1; //// function mFunc() { //// var bar = 1; //// function foob() { } //// } //// class mClass { //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// interface mInt { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// } //// export var meX = 1; //// export function meFunc() { //// } //// export class meClass { //// private cVar = 1; //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// export interface meInt { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// } //// namespace mMod { } //// export namespace meMod { } //// /*exportedNamespace*/ //// var tmp: /*exportedNamespaceType*/ //// } //// /*mod1*/ //// var tmp: /*mod1Type*/; ////} //// ////// EXTENDING NAMESPACE 1 ////namespace mod1 { //// export var mod1eexvar = 1; //// var mod1exvar = 2; //// /*extendedNamespace*/ //// var tmp: /*extendedNamespaceType*/; ////} //// ////namespace mod2 { //// var mod2var = "shadow"; //// function mod2fn() { //// var bar = 1; //// function foob() { } //// } //// class mod2cls { //// private cVar = 1; //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// namespace mod2mod { } //// interface mod2int { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// } //// export var mod2evar = 1; //// export function mod2efn() { //// } //// export class mod2ecls { //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// export interface mod2eint { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// } //// export namespace mod2emod { } ////} //// ////namespace mod2 { //// export var mod2eexvar = 1; ////} //// ////namespace mod3 { //// var shwvar = "shadow"; //// function shwfn() { //// var bar = 1; //// function foob() { } //// } //// class shwcls { //// constructor(public shadow: any) { } //// private cVar = 1; //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// interface shwint { //// (bar: any): any; //// new (bar: any): any; //// sivar: string; //// sifn(shadow: any): any; //// } ////} //// ////function shwfn() { //// var sfvar = 1; //// function sffn() { } ////} //// ////class shwcls { //// private scvar = 1; //// private scfn() { } //// public scpfn() { } //// public scpvar = 1; //// static scsvar = 1; //// static scsfn() { } ////} //// ////interface shwint { //// (bar: any): any; //// new (bar: any): any; //// sivar: any; //// sifn(bar: any): any; ////} //// ////var shwvar = 1; interface VerifyGeneralOptions { readonly isClassScope?: boolean; readonly isTypeLocation?: boolean; readonly insideMod1?: boolean; readonly isNewIdentifierLocation?: boolean; readonly moreIncludes?: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>; readonly moreExcludes?: ReadonlyArray<string>; }
{ "end_byte": 6467, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListWithModulesInsideModuleScope.ts" }
TypeScript/tests/cases/fourslash/completionListWithModulesInsideModuleScope.ts_6469_12503
function verifyGeneral(marker: string, { isClassScope, isTypeLocation, insideMod1, isNewIdentifierLocation, moreIncludes, moreExcludes }: VerifyGeneralOptions = {}) { const mod1Dot = insideMod1 ? "" : "mod1."; const valueInModule: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> = [ { name: "mod1var", text: "var mod1var: number" }, { name: "mod1fn", text: "function mod1fn(): void" }, { name: "mod1evar", text: `var ${mod1Dot}mod1evar: number` }, { name: "mod1efn", text: `function ${mod1Dot}mod1efn(): void` }, { name: "mod1eexvar", text: `var mod1.mod1eexvar: number` }, { name: "mod3", text: "namespace mod3" }, { name: "shwvar", text: "var shwvar: number" }, { name: "shwfn", text: "function shwfn(): void" }, ]; const typeInModule: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> = [ { name: "mod1int", text: "interface mod1int" }, { name: "mod1eint", text: `interface ${mod1Dot}mod1eint` }, { name: "shwint", text: "interface shwint" }, ]; const valueOrTypeInModule: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> = [ { name: "mod1cls", text: "class mod1cls" }, { name: "mod1mod", text: "namespace mod1mod" }, { name: "mod1ecls", text: `class ${mod1Dot}mod1ecls` }, { name: "mod1emod", text: `namespace ${mod1Dot}mod1emod` }, { name: "mod2", text: "namespace mod2" }, { name: "shwcls", text: "class shwcls" }, ]; verify.completions({ marker, includes: [ ...(isClassScope || isTypeLocation ? [] : valueInModule), ...(isClassScope ? [] : valueOrTypeInModule), ...(isTypeLocation ? typeInModule : []), ...(moreIncludes || []), ], excludes: [ "mod2var", "mod2fn", "mod2cls", "mod2int", "mod2mod", "mod2evar", "mod2efn", "mod2ecls", "mod2eint", "mod2emod", "sfvar", "sffn", "scvar", "scfn", "scpfn", "scpvar", "scsvar", "scsfn", "sivar", "sifn", "mod1exvar", "mod2eexvar", ...(moreExcludes || []), ], isNewIdentifierLocation, }); } // from mod1 verifyGeneral('mod1', { insideMod1: true }); // from mod1 in type position verifyGeneral('mod1Type', { isTypeLocation: true, insideMod1: true }); // from function in mod1 verifyGeneral('function', { insideMod1: true, moreIncludes: [ { name: "bar", text: "(local var) bar: number" }, { name: "foob", text: "(local function) foob(): void" }, ], }); // from class in mod1 verifyGeneral('class', { isClassScope: true, isNewIdentifierLocation: true, moreExcludes: ["ceFunc", "ceVar"], }); // from interface in mod1 verify.completions({ marker: "interface", exact: { name: "readonly", sortText: completion.SortText.GlobalsOrKeywords }, isNewIdentifierLocation: true, }); // from namespace in mod1 verifyNamespaceInMod1('namespace'); verifyNamespaceInMod1('namespaceType', /*isTypeLocation*/ true); function verifyNamespaceInMod1(marker: string, isTypeLocation?: boolean) { verifyGeneral(marker, { isTypeLocation, insideMod1: true }); const values: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> = [ { name: "m1X", text: "var m1X: number" }, { name: "m1Func", text: "function m1Func(): void" }, { name: "m1eX", text: "var m1eX: number" }, { name: "m1eFunc", text: "function m1eFunc(): void" }, ]; const types: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> = [ { name: "m1Int", text: "interface m1Int" }, { name: "m1eInt", text: "interface m1eInt" }, ]; verify.completions({ includes: [ ...(isTypeLocation ? types : values), { name: "m1Class", text: "class m1Class" }, { name: "m1eClass", text: "class m1eClass" }, ], excludes: ["m1Mod", "m1eMod"], }); } // from exported function in mod1 verifyGeneral('exportedFunction', { insideMod1: true, moreIncludes: [ { name: "bar", text: "(local var) bar: number" }, { name: "foob", text: "(local function) foob(): void" }, ], }); // from exported class in mod1 verifyGeneral('exportedClass', { isClassScope: true, isNewIdentifierLocation: true, moreExcludes: ["ceFunc", "ceVar"], }); // from exported interface in mod1 verify.completions({ marker: "exportedInterface", exact: [{ name: "readonly", sortText: completion.SortText.GlobalsOrKeywords }], isNewIdentifierLocation: true }); // from exported namespace in mod1 verifyExportedNamespace('exportedNamespace'); verifyExportedNamespace('exportedNamespaceType', /*isTypeLocation*/ true); function verifyExportedNamespace(marker: string, isTypeLocation?: boolean) { const values: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> = [ { name: "mX", text: "var mX: number" }, { name: "mFunc", text: "function mFunc(): void" }, { name: "meX", text: "var meX: number" }, { name: "meFunc", text: "function meFunc(): void" }, ]; const types: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> = [ { name: "mInt", text: "interface mInt" }, { name: "meInt", text: "interface meInt" }, ]; verifyGeneral(marker, { isTypeLocation, insideMod1: true, moreIncludes: [ ...(isTypeLocation ? types : values), { name: "mClass", text: "class mClass" }, { name: "meClass", text: "class meClass" }, ], moreExcludes: ["mMod", "meMod"], }); } // from extended namespace verifyExtendedNamespace('extendedNamespace'); verifyExtendedNamespace('extendedNamespaceType', /*isTypeLocation*/ true);
{ "end_byte": 12503, "start_byte": 6469, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListWithModulesInsideModuleScope.ts" }
TypeScript/tests/cases/fourslash/completionListWithModulesInsideModuleScope.ts_12505_14103
function verifyExtendedNamespace(marker: string, isTypeLocation?: boolean) { const values: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> = [ { name: "mod1evar", text: "var mod1.mod1evar: number" }, { name: "mod1efn", text: "function mod1.mod1efn(): void" }, { name: "mod1eexvar", text: "var mod1eexvar: number" }, { name: "mod3", text: "namespace mod3" }, { name: "shwvar", text: "var shwvar: number" }, { name: "shwfn", text: "function shwfn(): void" }, ]; const types: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> = [ { name: "mod1eint", text: "interface mod1.mod1eint" }, { name: "shwint", text: "interface shwint" }, ]; verify.completions({ marker, includes: [ ...(isTypeLocation ? types : values), { name: "mod1ecls", text: "class mod1.mod1ecls" }, { name: "mod1emod", text: "namespace mod1.mod1emod" }, { name: "mod2", text: "namespace mod2" }, { name: "shwcls", text: "class shwcls" }, ], excludes: [ "mod2var", "mod2fn", "mod2cls", "mod2int", "mod2mod", "mod2evar", "mod2efn", "mod2ecls", "mod2eint", "mod2emod", "sfvar", "sffn", "scvar", "scfn", "scpfn", "scpvar", "scsvar", "scsfn", "sivar", "sifn", "mod2eexvar", ], }); }
{ "end_byte": 14103, "start_byte": 12505, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListWithModulesInsideModuleScope.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionOverriddenMember4.ts_0_258
/// <reference path="./fourslash.ts"/> // @noImplicitOverride: true ////class Foo { //// /*2*/m() {} ////} ////function f () { //// return class extends Foo { //// [|/*1*/override|] m() {} //// } ////} verify.baselineGoToDefinition("1");
{ "end_byte": 258, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionOverriddenMember4.ts" }
TypeScript/tests/cases/fourslash/completionsThisPropertiesInPropertyDeclaration2.ts_0_666
/// <reference path="fourslash.ts" /> ////class Foo { //// private static _prop = 1; //// public static a = [|_/*1*/|] //// //// static foo() { //// [|_/*2*/|] //// } ////} verify.completions({ marker: ["2"], includes: [ { name: "_prop", insertText: "this._prop", kind: "property", sortText: completion.SortText.SuggestedClassMembers, source: completion.CompletionSource.ThisProperty, text: "(property) Foo._prop: number", kindModifiers: "private,static" }, ], preferences: { includeInsertTextCompletions: true } });
{ "end_byte": 666, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsThisPropertiesInPropertyDeclaration2.ts" }
TypeScript/tests/cases/fourslash/isInMultiLineComment.ts_0_1254
/// <reference path="fourslash.ts" /> //// /* x */ //// /** //// * @param this doesn't make sense here. //// */ //// // x //// let x = 1; /* //// * const firstCommentStart = 0; const firstCommentEnd = 7; goTo.position(firstCommentStart); verify.not.isInCommentAtPosition(); goTo.position(firstCommentStart + 1); verify.isInCommentAtPosition(); goTo.position(firstCommentEnd - 1); verify.isInCommentAtPosition(); goTo.position(firstCommentEnd); verify.not.isInCommentAtPosition(); const multilineJsDocStart = firstCommentEnd + 1; const multilineJsDocEnd = multilineJsDocStart + 49; goTo.position(multilineJsDocStart); verify.not.isInCommentAtPosition(); goTo.position(multilineJsDocStart + 1); verify.isInCommentAtPosition(); goTo.position(multilineJsDocEnd - 1); verify.isInCommentAtPosition(); goTo.position(multilineJsDocEnd); verify.not.isInCommentAtPosition(); const singleLineCommentStart = multilineJsDocEnd + 1; goTo.position(singleLineCommentStart + 1); verify.isInCommentAtPosition(/*onlyMultiLineDiverges*/ true); const postNodeCommentStart = singleLineCommentStart + 16; goTo.position(postNodeCommentStart); verify.not.isInCommentAtPosition(); goTo.position(postNodeCommentStart + 1); verify.isInCommentAtPosition();
{ "end_byte": 1254, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/isInMultiLineComment.ts" }
TypeScript/tests/cases/fourslash/completionsPathsJsonModule.ts_0_366
/// <reference path="fourslash.ts" /> // @moduleResolution: node // @resolveJsonModule: true // @Filename: /project/node_modules/test.json ////not read // @Filename: /project/index.ts ////import { } from "/**/"; verify.completions({ marker: "", exact: { name: "test.json", kind: "script", kindModifiers: ".json" }, isNewIdentifierLocation: true, });
{ "end_byte": 366, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsPathsJsonModule.ts" }
TypeScript/tests/cases/fourslash/formatOnTypeOpenCurlyWithBraceCompletion.ts_0_191
/// <reference path="fourslash.ts"/> //// if (foo) { //// if (bar) {/**/} //// } goTo.marker(""); format.onType("", "{"); verify.currentFileContentIs( `if (foo) { if (bar) { } }`);
{ "end_byte": 191, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatOnTypeOpenCurlyWithBraceCompletion.ts" }
TypeScript/tests/cases/fourslash/unusedVariableInClass5.ts_0_176
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @target: esnext ////declare class greeter { //// #private; //// private name; ////} verify.noErrors()
{ "end_byte": 176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedVariableInClass5.ts" }
TypeScript/tests/cases/fourslash/signatureHelpExplicitTypeArguments.ts_0_1489
/// <reference path='fourslash.ts'/> //// declare function f<T = boolean, U = string>(x: T, y: U): T; //// f<number, string>(/*1*/); //// f(/*2*/); //// f<number>(/*3*/); //// f<number, string, boolean>(/*4*/); //// interface A { a: number } //// interface B extends A { b: string } //// declare function g<T, U, V extends A = B>(x: T, y: U, z: V): T; //// declare function h<T, U, V extends A>(x: T, y: U, z: V): T; //// declare function j<T, U, V = B>(x: T, y: U, z: V): T; //// g(/*5*/); //// h(/*6*/); //// j(/*7*/); //// g<number>(/*8*/); //// h<number>(/*9*/); //// j<number>(/*10*/); verify.signatureHelp( { marker: "1", text: "f(x: number, y: string): number" }, { marker: "2", text: "f(x: boolean, y: string): boolean" }, // too few -- fill in rest with default { marker: "3", text: "f(x: number, y: string): number" }, // too many -- ignore extra type arguments { marker: "4", text: "f(x: number, y: string): number" }, // not matched signature and no type arguments { marker: "5", text: "g(x: unknown, y: unknown, z: B): unknown" }, { marker: "6", text: "h(x: unknown, y: unknown, z: A): unknown" }, { marker: "7", text: "j(x: unknown, y: unknown, z: B): unknown" }, // not matched signature and too few type arguments { marker: "8", text: "g(x: number, y: unknown, z: B): number" }, { marker: "9", text: "h(x: number, y: unknown, z: A): number" }, { marker: "10", text: "j(x: number, y: unknown, z: B): number" }, );
{ "end_byte": 1489, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpExplicitTypeArguments.ts" }
TypeScript/tests/cases/fourslash/jsdocSatisfiesTagCompletion2.ts_0_234
///<reference path="fourslash.ts" /> // @noEmit: true // @allowJS: true // @checkJs: true // @filename: /a.js /////** //// * @/**/ //// */ ////const t = { a: 1 }; verify.completions( { marker: "", includes: ["satisfies"] }, );
{ "end_byte": 234, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocSatisfiesTagCompletion2.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDocAlias.ts_0_281
/// <reference path="fourslash.ts" /> // @filename: /a.d.ts /////** docs - type T */ ////export type T = () => void; /////** //// * docs - const A: T //// */ ////export declare const A: T; // @filename: /b.ts ////import { A } from "./a"; ////A/**/() verify.baselineQuickInfo();
{ "end_byte": 281, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocAlias.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteral_quotePreference5.ts_0_281
/// <reference path='fourslash.ts'/> ////type T = "0" | "1"; ////const t: T = /**/ verify.completions({ marker: "", includes: [ { name: "'1'" }, { name: "'0'" }, ], isNewIdentifierLocation: true, preferences: { quotePreference: "single" } });
{ "end_byte": 281, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral_quotePreference5.ts" }
TypeScript/tests/cases/fourslash/autoImportFileExcludePatterns10.ts_0_950
/// <reference path="fourslash.ts" /> // @Filename: /src/vs/test.ts //// import { Parts } from './parts'; //// export class /**/Extended implements Parts { //// } // @Filename: /src/vs/parts.ts //// import { Event } from '../event/event'; //// //// export interface Parts { //// readonly options: Event; //// } // @Filename: /src/event/event.ts //// export interface Event { //// (): string; //// } // @Filename: /src/thing.ts //// import { Event } from './event/event'; //// export { Event }; // @Filename: /src/a.ts //// import './thing' //// declare module './thing' { //// interface Event { //// c: string; //// } //// } verify.codeFix({ description: "Implement interface 'Parts'", newFileContent: `import { Event } from '../event/event'; import { Parts } from './parts'; export class Extended implements Parts { options: Event; }`, preferences: { autoImportFileExcludePatterns: ["src/thing.ts"], } });
{ "end_byte": 950, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportFileExcludePatterns10.ts" }
TypeScript/tests/cases/fourslash/jsxElementMissingOpeningTagNoCrash.ts_0_165
/// <reference path="fourslash.ts" /> //@Filename: file.tsx //// declare function Foo(): any; //// let x = <></Fo/*$*/o>; verify.quickInfoAt("$", "let Foo: any");
{ "end_byte": 165, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsxElementMissingOpeningTagNoCrash.ts" }
TypeScript/tests/cases/fourslash/signatureHelpExpandedRestUnlabeledTuples.ts_0_1073
/// <reference path='fourslash.ts' /> ////export function complex(item: string, another: string, ...rest: [] | [object, (err: Error) => void] | [(err: Error) => void, ...object[]]) { //// ////} //// ////complex(/*1*/); ////complex("ok", "ok", /*2*/); ////complex("ok", "ok", e => void e, {}, /*3*/); verify.signatureHelp( { marker: "1", text: "complex(item: string, another: string): void", overloadsCount: 3, parameterCount: 2, parameterName: "item", parameterSpan: "item: string", isVariadic: false, }, { marker: "2", text: "complex(item: string, another: string, rest_0: object, rest_1: (err: Error) => void): void", overloadsCount: 3, parameterCount: 4, parameterName: "rest_0", parameterSpan: "rest_0: object", isVariadic: false, }, { marker: "3", text: "complex(item: string, another: string, rest_0: (err: Error) => void, ...rest: object[]): void", overloadsCount: 3, isVariadic: true, }, );
{ "end_byte": 1073, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpExpandedRestUnlabeledTuples.ts" }
TypeScript/tests/cases/fourslash/completionListInNamedFunctionExpressionWithShadowing.ts_3_411
/<reference path="fourslash.ts" /> //// function foo() {} //// /*0*/ //// var x = function foo() { //// /*1*/ //// } //// var y = function () { //// /*2*/ //// } verify.completions( { marker: ["0", "2"], includes: { name: "foo", text: "function foo(): void", kind: "function" } }, { marker: "1", includes: { name: "foo", text: "(local function) foo(): void", kind: "local function" } }, );
{ "end_byte": 411, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInNamedFunctionExpressionWithShadowing.ts" }
TypeScript/tests/cases/fourslash/codeFixSpellingJs4.ts_0_508
/// <reference path='fourslash.ts' /> // @allowjs: true // @noEmit: true // @filename: a.js //// var object = { //// spaaace: 3 //// } //// object.spaaaace // error on read //// object.spaace = 12 // error on write //// object.fresh = 12 // OK verify.codeFixAll({ fixId: "fixSpelling", fixAllDescription: "Fix all detected spelling errors", newFileContent: `var object = { spaaace: 3 } object.spaaace // error on read object.spaaace = 12 // error on write object.fresh = 12 // OK`, });
{ "end_byte": 508, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingJs4.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports37-array-spread.ts_0_1243
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true // @Filename: /code.ts ////const Start = [ //// 'A', //// 'B', ////] as const; //// ////const End = [ //// "Y", //// "Z" ////] as const; ////export const All_Part1 = {}; ////function getPart() { //// return ["Z"] ////} //// ////export const All = [ //// 1, //// ...Start, //// 1, //// ...getPart(), //// ...End, //// 1, ////] as const; verify.codeFix({ description: `Add annotation of type '[...typeof All_Part1_1, ...typeof Start, ...typeof All_Part3, ...typeof All_Part4, ...typeof End, ...typeof All_Part6]'` , index: 1, newFileContent: `const Start = [ 'A', 'B', ] as const; const End = [ "Y", "Z" ] as const; export const All_Part1 = {}; function getPart() { return ["Z"] } const All_Part1_1 = [ 1 ] as const; const All_Part3 = [ 1 ] as const; const All_Part4 = getPart() as const; const All_Part6 = [ 1 ] as const; export const All: [ ...typeof All_Part1_1, ...typeof Start, ...typeof All_Part3, ...typeof All_Part4, ...typeof End, ...typeof All_Part6 ] = [ ...All_Part1_1, ...Start, ...All_Part3, ...All_Part4, ...End, ...All_Part6 ] as const;` });
{ "end_byte": 1243, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports37-array-spread.ts" }
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc14.ts_0_269
/// <reference path='fourslash.ts' /> /////** @return {number} */ ////function f() { //// return 12; ////} verify.codeFix({ description: "Annotate with type from JSDoc", newFileContent: `/** @return {number} */ function f(): number { return 12; }`, });
{ "end_byte": 269, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc14.ts" }
TypeScript/tests/cases/fourslash/toggleLineComment1.ts_0_292
// Simple comment and uncomment. //// let var1[| = 1; //// let var2 = 2; //// let var3 |]= 3; //// //// //let var4[| = 1; //// //let var5 = 2; //// //let var6 |]= 3; verify.toggleLineComment( `//let var1 = 1; //let var2 = 2; //let var3 = 3; let var4 = 1; let var5 = 2; let var6 = 3;`);
{ "end_byte": 292, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/toggleLineComment1.ts" }
TypeScript/tests/cases/fourslash/completionsClassMemberImportTypeNodeParameter2.ts_0_675
/// <reference path="fourslash.ts" /> // @module: nodenext // @FileName: /index.d.ts //// export declare class Cls { //// method( //// param: import("./doesntexist.js").Foo, //// ): import("./doesntexist.js").Foo; //// } //// //// export declare class Derived extends Cls { //// /*1*/ //// } verify.completions({ marker: "1", includes: [ { name: "method", insertText: `method(param: import("./doesntexist.js").Foo);`, filterText: "method", hasAction: undefined, }, ], preferences: { includeCompletionsWithClassMemberSnippets: true, includeCompletionsWithInsertText: true, }, isNewIdentifierLocation: true, });
{ "end_byte": 675, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsClassMemberImportTypeNodeParameter2.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports38-unique-symbol-return.ts_0_447
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true // @lib: es2019 // @Filename: /code.ts ////const u: unique symbol = Symbol(); ////export const fn = () => ({ u } as const); verify.codeFix({ description: `Add return type '{ readonly u: typeof u; }'` , index: 0, newFileContent: `const u: unique symbol = Symbol(); export const fn = (): { readonly u: typeof u; } => ({ u } as const);` });
{ "end_byte": 447, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports38-unique-symbol-return.ts" }
TypeScript/tests/cases/fourslash/docCommentTemplateFunctionWithParameters_js.ts_0_197
/// <reference path='fourslash.ts' /> // @Filename: /a.js /////*0*/ ////function f(a, ...b): boolean {} verify.docCommentTemplateAt("0", 7, `/** * * @param {any} a * @param {...any} b */`);
{ "end_byte": 197, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateFunctionWithParameters_js.ts" }
TypeScript/tests/cases/fourslash/incompatibleOverride.ts_0_572
/// <reference path="fourslash.ts"/> // Squiggle for implementing a derived class with an incompatible override is too large //// class Foo { xyz: string; } //// class Bar extends Foo { /*1*/xyz/*2*/: number = 1; } //// class Baz extends Foo { public /*3*/xyz/*4*/: number = 2; } //// class /*5*/Baf/*6*/ extends Foo { //// constructor(public xyz: number) { //// super(); //// } //// } verify.errorExistsBetweenMarkers('1', '2'); verify.errorExistsBetweenMarkers('3', '4'); verify.errorExistsBetweenMarkers('5', '6'); verify.numberOfErrorsInCurrentFile(3);
{ "end_byte": 572, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incompatibleOverride.ts" }
TypeScript/tests/cases/fourslash/completionListAtBeginningOfIdentifierInArrowFunction01.ts_0_112
/// <reference path='fourslash.ts' /> ////xyz => /*1*/x verify.completions({ marker: "1", includes: "xyz" });
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtBeginningOfIdentifierInArrowFunction01.ts" }
TypeScript/tests/cases/fourslash/signatureHelpSuperConstructorOverload.ts_0_868
/// <reference path='fourslash.ts' /> ////class SuperOverloadBase { //// constructor(); //// constructor(test: string); //// constructor(test?: string) { //// } ////} ////class SuperOverLoad1 extends SuperOverloadBase { //// constructor() { //// super(/*superOverload1*/); //// } ////} ////class SuperOverLoad2 extends SuperOverloadBase { //// constructor() { //// super(""/*superOverload2*/); //// } ////} verify.signatureHelp( { marker: "superOverload1", overloadsCount: 2, text: "SuperOverloadBase(): SuperOverloadBase", parameterCount: 0, }, { marker: "superOverload2", overloadsCount: 2, text: "SuperOverloadBase(test: string): SuperOverloadBase", parameterCount: 1, parameterName: "test", parameterSpan: "test: string", }, );
{ "end_byte": 868, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpSuperConstructorOverload.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_noDestructureNonObjectLiteral.ts_0_664
/// <reference path="fourslash.ts" /> // @target: es2015 // @strict: true // @esModuleInterop: true // @Filename: /array.ts ////declare const arr: number[]; ////export = arr; // @Filename: /class-instance-member.ts ////class C { filter() {} } ////export = new C(); // @Filename: /object-literal.ts ////declare function filter(): void; ////export = { filter }; // @Filename: /jquery.d.ts ////interface JQueryStatic { //// filter(): void; ////} ////declare const $: JQueryStatic; ////export = $; // @Filename: /jquery.js ////module.exports = {}; // @Filename: /index.ts ////filter/**/ verify.importFixModuleSpecifiers('', ['./object-literal', './jquery']);
{ "end_byte": 664, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_noDestructureNonObjectLiteral.ts" }
TypeScript/tests/cases/fourslash/genericCloduleCompletionList.ts_0_191
/// <reference path='fourslash.ts'/> ////class D<T> { x: number } ////module D { export function f() { } } ////var d: D<number>; ////d./**/ verify.completions({ marker: "", exact: "x" });
{ "end_byte": 191, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericCloduleCompletionList.ts" }
TypeScript/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames1.ts_0_194
/// <reference path='fourslash.ts'/> ////class Foo { //// /*1*/public /*2*/_bar() { return 0; } ////} //// ////var x: Foo; ////x./*3*/_bar; verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 194, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames1.ts" }
TypeScript/tests/cases/fourslash/quickInfoFunctionKeyword.ts_0_215
/// <reference path='fourslash.ts'/> ////[1].forEach(fu/*1*/nction() {}); ////[1].map(x =/*2*/> x + 1); verify.quickInfoAt("1", "(local function)(): void"); verify.quickInfoAt("2", "function(x: number): number");
{ "end_byte": 215, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoFunctionKeyword.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_namespaceImport.ts_0_723
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: /a.ts ////[|export const x = 0;|] ////export const y = 0; // @Filename: /b.ts ////import * as a from "./a"; ////a.x; ////a.y; // @Filename: /c.ts ////import a = require("./a"); ////a.x; ////a.y; // @Filename: /d.js ////const a = require("./a"); ////a.x; ////a.y; verify.moveToNewFile({ newFileContents: { "/a.ts": `export const y = 0;`, "/x.ts": `export const x = 0; `, "/b.ts": `import * as a from "./a"; import * as x from "./x"; x.x; a.y;`, "/c.ts": `import a = require("./a"); import x = require("./x"); x.x; a.y;`, "/d.js": `const a = require("./a"), x = require("./x"); x.x; a.y;`, }, });
{ "end_byte": 723, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_namespaceImport.ts" }
TypeScript/tests/cases/fourslash/codeFixImportNonExportedMember6.ts_0_446
/// <reference path="fourslash.ts" /> // @module: esnext // @filename: /a.ts ////let a = 1, b = 1; ////type T = number; ////export type { T }; // @filename: /b.ts ////import { b } from "./a"; goTo.file("/b.ts"); verify.codeFix({ description: [ts.Diagnostics.Export_0_from_module_1.message, "b", "./a"], index: 0, newFileContent: { "/a.ts": `let a = 1, b = 1; type T = number; export type { T }; export { b }; `, } });
{ "end_byte": 446, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImportNonExportedMember6.ts" }
TypeScript/tests/cases/fourslash/inlineVariableJsxCallback.ts_0_727
/// <reference path='fourslash.ts'/> //@module: commonjs //@jsx: preserve // @Filename: file.tsx ////function Button() { //// const /*a*/onClick/*b*/ = () => { //// console.log("clicked"); //// }; //// //// return ( //// <button onClick={onClick}> //// Click me! //// </button> //// ); ////} goTo.select("a", "b"); verify.refactorAvailable("Inline variable"); edit.applyRefactor({ refactorName: "Inline variable", actionName: "Inline variable", actionDescription: "Inline variable", newContent: `function Button() { return ( <button onClick={() => { console.log("clicked"); }}> Click me! </button> ); }` });
{ "end_byte": 727, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableJsxCallback.ts" }
TypeScript/tests/cases/fourslash/importTypeCompletions6.ts_0_668
/// <reference path="fourslash.ts" /> // @module: esnext // @Filename: /foo.ts ////export const foo = { }; ////export interface Foo { }; // @Filename: /bar.ts //// [|import type * as f/**/|] goTo.file("/bar.ts") verify.completions({ marker: "", exact: [{ name: "Foo", sourceDisplay: "./foo", source: "./foo", insertText: "import type { Foo } from \"./foo\";", replacementSpan: test.ranges()[0] }], isNewIdentifierLocation: true, preferences: { includeCompletionsForModuleExports: true, includeCompletionsForImportStatements: true, includeCompletionsWithInsertText: true } });
{ "end_byte": 668, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importTypeCompletions6.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_js.ts_0_619
/// <reference path='fourslash.ts' /> // @module: esnext // @allowJs: true // @Filename: /a.js ////const { a, b } = require("./other"); ////const p = 0; ////[|const y = p + b; ////const z = 0; ////exports.z = 0;|] ////a; y; z; // @Filename: /user.ts ////const { x, y } = require("./a"); verify.moveToNewFile({ newFileContents: { "/a.js": `const { a } = require("./other"); const { y, z } = require("./y"); const p = 0; exports.p = p; a; y; z;`, "/y.js": `const { p } = require("./a"); const { b } = require("./other"); const y = p + b; exports.y = y; const z = 0; exports.z = 0; `, }, });
{ "end_byte": 619, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_js.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionShorthandProperty01.ts_0_448
/// <reference path='fourslash.ts' /> //// var /*valueDeclaration1*/name = "hello"; //// var /*valueDeclaration2*/id = 100000; //// declare var /*valueDeclaration3*/id; //// var obj = {[|/*valueDefinition1*/name|], [|/*valueDefinition2*/id|]}; //// obj.[|/*valueReference1*/name|]; //// obj.[|/*valueReference2*/id|]; verify.baselineGoToDefinition( "valueDefinition1", "valueDefinition2", "valueReference1", "valueReference2", );
{ "end_byte": 448, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionShorthandProperty01.ts" }
TypeScript/tests/cases/fourslash/promiseTyping1.ts_0_996
/// <reference path="fourslash.ts" /> //// interface IPromise<T> { //// then<U>(success: (value: T) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void ): IPromise<U>; //// then<U>(success: (value: T) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void ): IPromise<U>; //// then<U>(success: (value: T) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void ): IPromise<U>; //// then<U>(success: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void ): IPromise<U>; //// done? <U>(success: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void ): void; //// } //// var p1: IPromise<string>; //// var p/*1*/2 = p1.then(function (x/*2*/x) { //// return xx; //// }); //// p2.then(function (x/*3*/x) { //// } ); verify.quickInfos({ 1: "var p2: IPromise<string>", 2: "(parameter) xx: string", 3: "(parameter) xx: string" });
{ "end_byte": 996, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/promiseTyping1.ts" }
TypeScript/tests/cases/fourslash/formattingOfExportDefault.ts_0_375
/// <reference path="fourslash.ts"/> ////module Foo { /////*1*/ export default class Test { } ////} /////*2*/export default function bar() { } format.document(); goTo.marker("1"); verify.currentLineContentIs(" export default class Test { }") goTo.marker("2"); verify.currentLineContentIs("export default function bar() { }")
{ "end_byte": 375, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOfExportDefault.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionJsModuleExports.ts_0_269
/// <reference path='fourslash.ts'/> // #33520 // @allowJs: true // @Filename: foo.js ////x./*def*/test = () => { } ////x.[|/*ref*/test|](); ////x./*defFn*/test3 = function () { } ////x.[|/*refFn*/test3|](); verify.baselineGoToDefinition( "ref", "refFn", );
{ "end_byte": 269, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionJsModuleExports.ts" }
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class_falsePositive.ts_0_557
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: /a.js ////function [|f|]() {} ////f.prototype.bar = [|function|](){ //// this.x = 1; ////}; // Only a suggestion for `f`, not for the function expression. See GH#22240 verify.getSuggestionDiagnostics([{ message: "This constructor function may be converted to a class declaration.", code: 80002, }]); verify.codeFix({ description: "Convert function to an ES2015 class", newFileContent: `class f { constructor() { } bar() { this.x = 1; } } `, });
{ "end_byte": 557, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class_falsePositive.ts" }
TypeScript/tests/cases/fourslash/typeParameterListInQuickInfoAfterEdit.ts_0_504
/// <reference path="fourslash.ts" /> //// class Dictionary<V> { //// } //// //// module Maps { //// class C1 extends D/*1*/ictionary<string> { } //// /*2*/ //// } //// // Sanity check: type name here should include the type parameter verify.quickInfoAt("1", "class Dictionary<V>"); // Add a similar class -- name does not match goTo.marker('2'); edit.insert("class C2 extends Dictionary<string> { }"); edit.moveLeft('ictionary<string> { }'.length); verify.quickInfoIs('class Dictionary<V>');
{ "end_byte": 504, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/typeParameterListInQuickInfoAfterEdit.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageVariable3JS.ts_0_325
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @noEmit: true // @noImplicitAny: false // @Filename: important.js ////[|function f(foo) { //// foo += 2 //// return foo ////}|] verify.rangeAfterCodeFix(`/** * @param {number} foo */ function f(foo) { foo += 2 return foo } `);
{ "end_byte": 325, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageVariable3JS.ts" }
TypeScript/tests/cases/fourslash/javascriptModules23.ts_0_228
/// <reference path='fourslash.ts'/> // @Filename: mod.ts //// var foo = {a: "test"}; //// export = foo; // @Filename: app.ts //// import {a} from "./mod" //// a./**/ verify.completions({ marker: "", includes: "toString" });
{ "end_byte": 228, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javascriptModules23.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringAssignmentStatementArrayBindingPatternDefaultValues.ts_0_2237
/// <reference path='fourslash.ts' /> ////declare var console: { //// log(msg: any): void; ////} ////type Robot = [number, string, string]; ////type MultiSkilledRobot = [string, string[]]; //// ////var robotA: Robot = [1, "mower", "mowing"]; ////var robotB: Robot = [2, "trimmer", "trimming"]; ////var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ////var multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; //// ////let nameA: string, numberB: number, nameB: string, skillB: string; ////let robotAInfo: (number | string)[]; //// ////let multiSkillB: string[], nameMB: string, primarySkillB: string, secondarySkillB: string; ////let multiRobotAInfo: (string | string[])[]; //// ////[, nameA = "helloNoName"] = robotA; ////[, nameB = "helloNoName"] = getRobotB(); ////[, nameB = "helloNoName"] = [2, "trimmer", "trimming"]; ////[, multiSkillB = []] = multiRobotB; ////[, multiSkillB = []] = getMultiRobotB(); ////[, multiSkillB = []] = ["roomba", ["vacuum", "mopping"]]; //// ////[numberB = -1] = robotB; ////[numberB = -1] = getRobotB(); ////[numberB = -1] = [2, "trimmer", "trimming"]; ////[nameMB = "helloNoName"] = multiRobotB; ////[nameMB = "helloNoName"] = getMultiRobotB(); ////[nameMB = "helloNoName"] = ["trimmer", ["trimming", "edging"]]; //// ////[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = robotB; ////[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = getRobotB(); ////[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = [2, "trimmer", "trimming"]; ////[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = multiRobotB; ////[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = getMultiRobotB(); ////[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = //// ["trimmer", ["trimming", "edging"]]; //// ////[numberB = -1, ...robotAInfo] = robotB; ////[numberB = -1, ...robotAInfo] = getRobotB(); ////[numberB = -1, ...robotAInfo] = <Robot>[2, "trimmer", "trimming"]; //// ////function getRobotB() { //// return robotB; ////} //// ////function getMultiRobotB() { //// return multiRobotB; ////} verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 2237, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringAssignmentStatementArrayBindingPatternDefaultValues.ts" }
TypeScript/tests/cases/fourslash/mapCodeMethodInsertion.ts_0_342
///<reference path="fourslash.ts"/> // @Filename: /index.ts //// class MyClass {[||] //// x = 1; //// foo() { //// return 1; //// } //// bar() { //// return 2; //// } //// baz() { //// return 3; //// } //// } //// verify.baselineMapCode([test.ranges()], [ ` quux() { return 4; } ` ]);
{ "end_byte": 342, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeMethodInsertion.ts" }
TypeScript/tests/cases/fourslash/codeFixConvertToMappedObjectType2.ts_0_335
/// <reference path='fourslash.ts' /> //// type K = "foo" | "bar"; //// type SomeType = { //// a: string; //// [prop: K]: any; //// } verify.codeFix({ description: `Convert 'SomeType' to mapped object type`, newFileContent: `type K = "foo" | "bar"; type SomeType = { [prop in K]: any; } & { a: string; };` })
{ "end_byte": 335, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToMappedObjectType2.ts" }
TypeScript/tests/cases/fourslash/completionsCommitCharactersAfterDot.ts_0_503
/// <reference path='fourslash.ts' /> //// declare const obj: { banana: 1 }; //// const x = obj./*1*/ //// declare module obj./*2*/ {} //// declare const obj2: { banana: 1 } | undefined; //// const y = obj2?./*3*/ //// declare const obj3: { [x: string]: number }; //// const z = obj3./*4*/ //// declare const obj4: { (): string; [x: string]: number } | undefined; //// const w = obj4?./*5*/ //// declare const obj5: { (): string } | undefined; //// const a = obj5?./*6*/ verify.baselineCompletions();
{ "end_byte": 503, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsCommitCharactersAfterDot.ts" }
TypeScript/tests/cases/fourslash/memberListOfEnumFromExternalModule.ts_0_378
/// <reference path='fourslash.ts' /> // @Filename: memberListOfEnumFromExternalModule_file0.ts ////export enum Topic{ One, Two } ////var topic = Topic.One; // @Filename: memberListOfEnumFromExternalModule_file1.ts ////import t = require('./memberListOfEnumFromExternalModule_file0'); ////var topic = t.Topic./*1*/ verify.completions({ marker: "1", exact: ["One", "Two"] });
{ "end_byte": 378, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberListOfEnumFromExternalModule.ts" }
TypeScript/tests/cases/fourslash/renameImport.ts_0_1311
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: /node_modules/global/index.d.ts ////export const x: number; // @Filename: /a.ts ////export const x = 0; // @Filename: /dir/index.ts ////export const x = 0; // @Filename: /b.ts ////import * as a from "./[|a|]"; ////import a2 = require("./[|a|]"); ////import * as dir from "./[|{| "target": "dir" |}dir|]"; ////import * as dir2 from "./dir/[|{| "target": "dir/index" |}index|]"; // @Filename: /c.js ////const a = require("./[|a|]"); ////const global = require("/*global*/global"); verify.noErrors(); goTo.eachRange(range => { const target = range.marker && range.marker.data && range.marker.data.target; const displayName = target === "dir" ? "./dir" : target === "dir/index" ? "./dir/index" : "./a"; const fileName = target === "dir" ? "/dir" : target === "dir/index" ? "/dir/index.ts" : "/a.ts"; const kind = target === "dir" ? "directory" : "module"; verify.renameInfoSucceeded(/*displayName*/ fileName, /*fullDisplayName*/ displayName, /*kind*/ kind, /*kindModifiers*/ "", /*fileToRename*/ fileName, range); verify.renameInfoFailed("You cannot rename this element.", { allowRenameOfImportPath: false }); }); goTo.marker("global"); verify.renameInfoFailed("You cannot rename a module via a global import.");
{ "end_byte": 1311, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameImport.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_import_nameFromModuleSpecifier.ts_0_381
/// <reference path='fourslash.ts' /> // @allowJs: true // @target: esnext // @Filename: /a.js ////const [] = require("a-b"); ////const [] = require("0a"); ////const [] = require("1a"); verify.codeFix({ description: "Convert to ES module", newFileContent: `import aB from "a-b"; const [] = aB; import A from "0a"; const [] = A; import _A from "1a"; const [] = _A;`, });
{ "end_byte": 381, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_import_nameFromModuleSpecifier.ts" }
TypeScript/tests/cases/fourslash/completionListInMiddleOfIdentifierInArrowFunction01.ts_0_113
/// <reference path='fourslash.ts' /> ////xyz => x/*1*/y verify.completions({ marker: "1", includes: "xyz" });
{ "end_byte": 113, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInMiddleOfIdentifierInArrowFunction01.ts" }
TypeScript/tests/cases/fourslash/jsdocParameterTagSnippetCompletion2.ts_0_549
///<reference path="fourslash.ts" /> // @allowJs: true // @Filename: a.ts //// /** //// * /*b*/ //// */ //// function bb(b: string) {} // @Filename: b.js //// /** //// * /*jb*/ //// */ //// function bb(b) {} //// //// /** //// * //// * @p/*jc*/ //// */ //// function cc({ b: { a, c } = { a: 1, c: 3 } }) { //// //// } //// //// /** //// * //// * @p/*jd*/ //// */ //// function dd(...a) {} //// //// /** //// * @p/*z*/ //// */ //// function zz(a = 3) {} verify.baselineCompletions({ includeCompletionsWithSnippetText: true, });
{ "end_byte": 549, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocParameterTagSnippetCompletion2.ts" }
TypeScript/tests/cases/fourslash/jsDocPropertyDescription1.ts_0_534
///<reference path="fourslash.ts" /> //// interface StringExample { //// /** Something generic */ //// [p: string]: any; //// /** Something specific */ //// property: number; //// } //// function stringExample(e: StringExample) { //// console.log(e./*property*/property); //// console.log(e./*string*/anything); //// } verify.quickInfoAt("property", "(property) StringExample.property: number", 'Something specific'); verify.quickInfoAt("string", "(index) StringExample[string]: any", "Something generic");
{ "end_byte": 534, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocPropertyDescription1.ts" }
TypeScript/tests/cases/fourslash/completionsKeywordsExtends.ts_0_351
/// <reference path="fourslash.ts" /> ////class C/*a*/ /*b*/ { } ////class C e/*c*/ {} // Tests that `isCompletionListBlocker` is true *at* the class name, but false *after* it. verify.completions( { marker: "a", exact: undefined }, { marker: ["b", "c"], includes: { name: "extends", sortText: completion.SortText.GlobalsOrKeywords } }, );
{ "end_byte": 351, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsKeywordsExtends.ts" }
TypeScript/tests/cases/fourslash/documentHighlightInExport1.ts_3_241
/ <reference path='fourslash.ts'/> //// class [|C|] {} //// [|export|] { [|C|] [|as|] [|D|] }; const [classRange, exportKeywordRange, propertyNameRange, asKeywordRange, nameRange] = test.ranges(); verify.baselineDocumentHighlights();
{ "end_byte": 241, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlightInExport1.ts" }
TypeScript/tests/cases/fourslash/convertLiteralTypeToMappedType3.ts_0_497
/// <reference path='fourslash.ts' /> ////type K1 = number | string; ////type T1 = { //// [K1]: number; ////} ////type K2 = number | string; ////type T2 = { //// [K2]: number; ////} verify.codeFixAll({ fixAllDescription: ts.Diagnostics.Convert_all_type_literals_to_mapped_type.message, fixId: 'convertLiteralTypeToMappedType', newFileContent: `type K1 = number | string; type T1 = { [K in K1]: number; } type K2 = number | string; type T2 = { [K in K2]: number; }` });
{ "end_byte": 497, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertLiteralTypeToMappedType3.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts_0_296
/// <reference path='fourslash.ts' /> //// interface I1 { //// x: number; //// } //// interface I2 { //// y: "𣋝ઢȴ¬⏊"; //// } //// //// class C implements I1,I2 {[| //// |]x: number; //// } verify.rangeAfterCodeFix(` y: "𣋝ઢȴ¬⏊"; `); verify.not.codeFixAvailable();
{ "end_byte": 296, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts" }
TypeScript/tests/cases/fourslash/codeFixAddVoidToPromise.2.ts_0_357
/// <reference path='fourslash.ts' /> // @target: esnext // @lib: es2015 // @strict: true ////const p2 = new Promise<number>(resolve => resolve()); verify.codeFix({ errorCode: 2794, description: "Add 'void' to Promise resolved without a value", index: 0, newFileContent: `const p2 = new Promise<number | void>(resolve => resolve());` });
{ "end_byte": 357, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddVoidToPromise.2.ts" }
TypeScript/tests/cases/fourslash/codeFixDeleteUnmatchedParameterJS3.ts_0_599
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @filename: /a.js /////** //// * @param {number} a //// * @param {string} b //// * @param {number} c //// */ ////function foo(a, c) { //// a; //// c; ////} verify.codeFixAvailable([ { description: "Delete unused '@param' tag 'b'" }, { description: "Disable checking for this file" }, ]); verify.codeFix({ description: [ts.Diagnostics.Delete_unused_param_tag_0.message, "b"], index: 0, newFileContent: `/** * @param {number} a * @param {number} c */ function foo(a, c) { a; c; }` });
{ "end_byte": 599, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixDeleteUnmatchedParameterJS3.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements7.ts_0_377
/// <reference path="fourslash.ts" /> // @noUnusedLocals: true // @noUnusedParameters: true ////function foo() { //// return { a: 1 }; ////} ////[|function bar() { //// const { a } = foo(); ////}|] verify.codeFix({ index: 0, description: ts.Diagnostics.Remove_unused_destructuring_declaration.message, newRangeContent: `function bar() { foo(); }`, });
{ "end_byte": 377, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements7.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_refactorAvailableInvoked3.ts_0_409
/// <reference path='fourslash.ts' /> //// export function fn() { //// /*a*/console.log("Hello"); /*b*/ //// } //// fn(); goTo.select("a", "b"); verify.refactorAvailableForTriggerReason("invoked", "Move to a new file", /*actionName*/ undefined, /*actionDescription*/ undefined, /*kind*/ undefined, { allowTextChangesInNewFiles: true }, /*includeInteractiveActions*/ true);
{ "end_byte": 409, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_refactorAvailableInvoked3.ts" }
TypeScript/tests/cases/fourslash/organizeImportsUnicode3.ts_0_637
/// <reference path="fourslash.ts" /> //// import { //// B, //// À, //// A, //// } from './foo'; //// //// console.log(A, À, B); verify.organizeImports( `import { À, A, B, } from './foo'; console.log(A, À, B);`, /*mode*/ undefined, { organizeImportsIgnoreCase: false, organizeImportsCollation: "unicode", organizeImportsAccentCollation: false, }); verify.organizeImports( `import { A, À, B, } from './foo'; console.log(A, À, B);`, /*mode*/ undefined, { organizeImportsIgnoreCase: false, organizeImportsCollation: "unicode", organizeImportsAccentCollation: true, });
{ "end_byte": 637, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsUnicode3.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts_0_671
/// <reference path='fourslash.ts' /> // Should give completions for files that are discovered via the baseUrl compiler option // @baseUrl: tests/cases/fourslash/modules // @Filename: tests/test0.ts //// import * as foo1 from "mod/*import_as0*/ //// import foo2 = require("mod/*import_equals0*/ //// var foo3 = require("mod/*require0*/ // @Filename: modules/module.ts //// export var x = 5; // @Filename: package.json //// { "dependencies": { "module-from-node": "latest" } } // @Filename: node_modules/module-from-node/index.ts //// verify.completions({ marker: test.markers(), exact: ["module", "module-from-node"], isNewIdentifierLocation: true, });
{ "end_byte": 671, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts" }
TypeScript/tests/cases/fourslash/jsObjectDefinePropertyRenameLocations.ts_0_514
/// <reference path="fourslash.ts" /> // @allowJs: true // @checkJs: true // @noEmit: true // @Filename: index.js ////var CircularList = (function () { //// var CircularList = function() {}; //// Object.defineProperty(CircularList.prototype, "[|maxLength|]", { value: 0, writable: true }); //// CircularList.prototype.push = function (value) { //// // ... //// this.[|maxLength|] + this.[|maxLength|] //// } //// return CircularList; ////})() verify.baselineRenameAtRangesWithText();
{ "end_byte": 514, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsObjectDefinePropertyRenameLocations.ts" }
TypeScript/tests/cases/fourslash/findAllRefsInheritedProperties1.ts_3_266
/ <reference path='fourslash.ts'/> //// class class1 extends class1 { //// /*1*/doStuff() { } //// /*2*/propName: string; //// } //// //// var v: class1; //// v./*3*/doStuff(); //// v./*4*/propName; verify.baselineFindAllReferences('1', '2', '3', '4');
{ "end_byte": 266, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsInheritedProperties1.ts" }
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue4.ts_0_117
/// <reference path='fourslash.ts' /> //// function Foo (): any { //// 1 //// } verify.not.codeFixAvailable();
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue4.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_missingInitializer.ts_0_236
/// <reference path='fourslash.ts' /> // @allowJs: true // @target: esnext // @Filename: /a.js ////require("m"); ////let x; x; verify.codeFix({ description: "Convert to ES module", newFileContent: `import "m"; let x; x;` });
{ "end_byte": 236, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_missingInitializer.ts" }
TypeScript/tests/cases/fourslash/consistentContextualTypeErrorsAfterEdits.ts_0_462
/// <reference path='fourslash.ts'/> //// class A { //// foo: string; //// } //// class C { //// foo: string; //// } //// var xs /*1*/ = [(x: A) => { return x.foo; }, (x: C) => { return x.foo; }]; //// xs.forEach(y => y(new /*2*/A())); verify.numberOfErrorsInCurrentFile(0); goTo.marker('1'); edit.insert(': {}[]'); verify.numberOfErrorsInCurrentFile(1); goTo.marker('2'); edit.deleteAtCaret(1); edit.insert('C'); verify.numberOfErrorsInCurrentFile(1);
{ "end_byte": 462, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/consistentContextualTypeErrorsAfterEdits.ts" }
TypeScript/tests/cases/fourslash/findReferencesAcrossMultipleProjects.ts_0_275
/// <reference path="fourslash.ts" /> //@Filename: a.ts /////*1*/var /*2*/x: number; //@Filename: b.ts /////// <reference path="a.ts" /> /////*3*/x++; //@Filename: c.ts /////// <reference path="a.ts" /> /////*4*/x++; verify.baselineFindAllReferences('1', '2', '3', '4');
{ "end_byte": 275, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findReferencesAcrossMultipleProjects.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_refactorAvailableImplicit2.ts_0_411
/// <reference path='fourslash.ts' /> //// export function fn(){ //// console.log('Hello')/*a*//*b*/ //// } //// fn(); goTo.select("a", "b"); verify.not.refactorAvailableForTriggerReason("implicit", "Move to a new file", /*actionName*/ undefined, /*actionDescription*/ undefined, /*kind*/ undefined, { allowTextChangesInNewFiles: true }, /*includeInteractiveActions*/ true);
{ "end_byte": 411, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_refactorAvailableImplicit2.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDocTags14.ts_0_447
/// <reference path="fourslash.ts" /> /////** //// * @param {Object} options the args object //// * @param {number} options.a first number //// * @param {number} options.b second number //// * @param {Object} options.c sub-object //// * @param {number} options.c.d third number //// * @param {Function} callback the callback function //// * @returns {number} //// */ ////function /**/fn(options, callback = null) { } verify.baselineQuickInfo();
{ "end_byte": 447, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTags14.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteral13.ts_0_340
/// <reference path='fourslash.ts'/> ////interface SymbolConstructor { //// readonly species: symbol; ////} ////var Symbol: SymbolConstructor; ////interface PromiseConstructor { //// [Symbol.species]: PromiseConstructor; ////} ////var Promise: PromiseConstructor; ////Promise["/*1*/"]; verify.completions({ marker: "1", exact: [] });
{ "end_byte": 340, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral13.ts" }
TypeScript/tests/cases/fourslash/inlineVariableDestructuredVariableDeclaration2.ts_0_192
/// <reference path="fourslash.ts" /> ////export function func(arr: any) { //// const [foo] = /*a*/arr/*b*/; ////} goTo.select("a", "b"); verify.not.refactorAvailable("Inline variable");
{ "end_byte": 192, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableDestructuredVariableDeclaration2.ts" }
TypeScript/tests/cases/fourslash/completionListOnAliases3.ts_0_257
/// <reference path='fourslash.ts' /> ////declare module 'foobar' { //// interface Q { x: number; } ////} ////declare module 'thing' { //// import x = require('foobar'); //// var m: x./*1*/; ////} verify.completions({ marker: "1", exact: "Q" });
{ "end_byte": 257, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListOnAliases3.ts" }
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc20.ts_0_366
/// <reference path='fourslash.ts' /> // @strict: true /////** //// * @param {number} a //// * @param {T} b //// */ ////function f<T>(a, b) { ////} verify.codeFix({ description: "Annotate with type from JSDoc", errorCode: 80004, // ignore 'unused T' newFileContent: `/** * @param {number} a * @param {T} b */ function f<T>(a: number, b: T) { }`, });
{ "end_byte": 366, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc20.ts" }
TypeScript/tests/cases/fourslash/genericWithSpecializedProperties1.ts_0_404
/// <reference path='fourslash.ts'/> ////interface Foo<T> { //// x: Foo<string>; //// y: Foo<number>; ////} ////var f: Foo<number>; ////var /*1*/xx = f.x; ////var /*2*/yy = f.y; ////var f2: Foo<string>; ////var /*3*/x2 = f2.x; ////var /*4*/y2 = f2.y; verify.quickInfos({ 1: "var xx: Foo<string>", 2: "var yy: Foo<number>", 3: "var x2: Foo<string>", 4: "var y2: Foo<number>" });
{ "end_byte": 404, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericWithSpecializedProperties1.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_js_3.ts_0_490
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: a.js //// class A { //// /*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 { /*RENAME*/_a = 1; get a() { return this._a; } set a(value) { this._a = value; } }`, });
{ "end_byte": 490, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_js_3.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_importType7.ts_0_1124
/// <reference path="fourslash.ts" /> // @module: es2015 // sorting and multiline imports and trailing commas, oh my // @Filename: /exports.ts //// export interface SomeInterface {} //// export class SomePig {} // @Filename: /a.ts //// import { //// type SomeInterface, //// type SomePig, //// } from "./exports.js"; //// new SomePig/**/ goTo.marker(""); // since we cannot detect a type order from the original file, type order defaults to last verify.importFixAtPosition([ `import { SomePig, type SomeInterface, } from "./exports.js"; new SomePig`]); verify.importFixAtPosition([ `import { SomePig, type SomeInterface, } from "./exports.js"; new SomePig`], /*errorCode*/ undefined, { organizeImportsTypeOrder: "last" }); verify.importFixAtPosition([ `import { type SomeInterface, SomePig, } from "./exports.js"; new SomePig`], /*errorCode*/ undefined, { organizeImportsTypeOrder: "inline" } ); verify.importFixAtPosition([ `import { type SomeInterface, SomePig, } from "./exports.js"; new SomePig`], /*errorCode*/ undefined, { organizeImportsTypeOrder: "first" });
{ "end_byte": 1124, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_importType7.ts" }
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsArrowFunctionExpression.ts_0_207
/// <reference path='fourslash.ts'/> ////var /*1*/x = /*5*/a => 10; ////var /*2*/y = (/*6*/a, /*7*/b) => 10; ////var /*3*/z = (/*8*/a: number) => 10; ////var /*4*/z2 = () => 10; verify.baselineQuickInfo();
{ "end_byte": 207, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsArrowFunctionExpression.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesClassExpressionPrivate.ts_0_472
/// <reference path='fourslash.ts' /> ////let A = class Foo { //// [|private|] foo; //// [|private|] private; //// constructor([|private|] y: string, public x: string) { //// } //// [|private|] method() { } //// public method2() { } //// [|private|] static static() { } ////} //// ////let B = class D { //// constructor(private x: number) { //// } //// private test() {} //// public test2() {} ////} verify.baselineDocumentHighlights();
{ "end_byte": 472, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesClassExpressionPrivate.ts" }
TypeScript/tests/cases/fourslash/codeFixClassExtendAbstractMethod_all.ts_0_824
/// <reference path='fourslash.ts' /> // @noImplicitOverride: true ////abstract class A { //// abstract m(): void; //// abstract n(): void; ////} ////class B extends A {} ////class C extends A {} verify.codeFixAll({ fixId: "fixClassDoesntImplementInheritedAbstractMember", fixAllDescription: "Implement all inherited abstract classes", newFileContent: `abstract class A { abstract m(): void; abstract n(): void; } class B extends A { override m(): void { throw new Error("Method not implemented."); } override n(): void { throw new Error("Method not implemented."); } } class C extends A { override m(): void { throw new Error("Method not implemented."); } override n(): void { throw new Error("Method not implemented."); } }`, });
{ "end_byte": 824, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassExtendAbstractMethod_all.ts" }
TypeScript/tests/cases/fourslash/signatureHelpFilteredTriggers01.ts_0_808
/// <reference path="fourslash.ts" /> ////function foo<T>(x: T): T { //// throw null; ////} //// ////foo("/*1*/"); ////foo('/*2*/'); ////foo(` ${100}/*3*/`); ////foo(/* /*4*/ */); ////foo( //// ///*5*/ ////); for (const marker of test.markers()) { goTo.marker(marker); for (const triggerCharacter of ["<", "(", ","]) { edit.insert(triggerCharacter); verify.noSignatureHelpForTriggerReason({ kind: "characterTyped", triggerCharacter, }); verify.signatureHelpPresentForTriggerReason({ kind: "retrigger", triggerCharacter, }); edit.backspace(); } verify.signatureHelpPresentForTriggerReason(/*triggerReason*/ undefined); verify.signatureHelpPresentForTriggerReason({ kind: "invoked" }); }
{ "end_byte": 808, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpFilteredTriggers01.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageSetterWithInaccessibleTypeJS.ts_0_692
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @noEmit: true // @noImplicitAny: true // @Filename: /promise.d.ts ////interface Promise<T> { ////} ////declare var Promise: Promise<any>; // @Filename: /a.js ////export class D {} ////export default new D(); // @Filename: /b.js ////export class C { //// set [|x|](val) { val; } //// method() { this.x = import("./a"); } ////} goTo.file("/b.js"); verify.codeFix({ index: 0, description: "Infer type of 'x' from usage", newFileContent: `export class C { /** * @param {Promise<typeof import("./a")>} val */ set x(val) { val; } method() { this.x = import("./a"); } }`, });
{ "end_byte": 692, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageSetterWithInaccessibleTypeJS.ts" }
TypeScript/tests/cases/fourslash/smartIndentInsideMultilineString.ts_0_559
/// <reference path='fourslash.ts' /> ////window.onload = () => { //// var el = document.getElementById('content\ ////sometext/*1*/'); //// var greeter = new Greeter(el); //// greeter.start(); ////}; //// ////var x = "line1\ ////line2\ ////lin/*2*/e3\ ////line4"; //// ////function foo1() { //// function foo2() { //// function foo3() { //// 'line1\ ////lin/*3*/e2'; //// } //// } ////} goTo.marker("1"); verify.indentationIs(0); goTo.marker("2"); verify.indentationIs(0); goTo.marker("3"); verify.indentationIs(0);
{ "end_byte": 559, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentInsideMultilineString.ts" }
TypeScript/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport4.ts_0_1059
/// <reference path="fourslash.ts" /> //@noEmit: true //@Filename: /package.json ////{ //// "dependencies": { //// "c": "*" //// } ////} //@Filename: /node_modules/a/index.d.ts ////export const foo = 0; //@Filename: /node_modules/a/package.json ////{ //// "name": "a", //// "types": "./index.d.ts" ////} //@Filename: /node_modules/b/index.d.ts ////export * from "a"; //@Filename: /node_modules/b/package.json ////{ //// "name": "b", //// "types": "./index.d.ts" ////} //@Filename: /node_modules/c/index.d.ts ////export * from "a"; //@Filename: /node_modules/c/package.json ////{ //// "name": "c", //// "types": "./index.d.ts" ////} //@Filename: /src/index.ts ////fo/**/ verify.completions({ marker: test.marker(""), includes: [ completion.undefinedVarEntry, { name: "foo", source: "/node_modules/c/index", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, ...completion.statementKeywordsWithTypes ], preferences: { includeCompletionsForModuleExports: true } });
{ "end_byte": 1059, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport4.ts" }