_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringParameterArrayBindingPattern2.ts_0_853
/// <reference path='fourslash.ts' /> ////declare var console: { //// log(msg: any): void; ////} ////type Robot = [string, [string, string]]; ////var robotA: Robot = ["trimmer", ["trimming", "edging"]]; ////function foo1([, skillA]: Robot) { //// console.log(skillA); ////} ////function foo2([nameMB]: Robot) { //// console.log(nameMB); ////} ////function foo3([nameMA, [primarySkillA, secondarySkillA]]: Robot) { //// console.log(nameMA); ////} ////function foo4([...multiRobotAInfo]: Robot) { //// console.log(multiRobotAInfo); ////} ////foo1(robotA); ////foo1(["roomba", ["vacuum", "mopping"]]); ////foo2(robotA); ////foo2(["roomba", ["vacuum", "mopping"]]); ////foo3(robotA); ////foo3(["roomba", ["vacuum", "mopping"]]); ////foo4(robotA); ////foo4(["roomba", ["vacuum", "mopping"]]); verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 853, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringParameterArrayBindingPattern2.ts" }
TypeScript/tests/cases/fourslash/findAllRefsForDefaultExport03.ts_0_327
/// <reference path='fourslash.ts'/> /////*1*/function /*2*/f() { //// return 100; ////} //// /////*3*/export default /*4*/f; //// ////var x: typeof /*5*/f; //// ////var y = /*6*/f(); //// /////*7*/namespace /*8*/f { //// var local = 100; ////} verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6', '7', '8');
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForDefaultExport03.ts" }
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_staticMethod.ts_0_572
/// <reference path='fourslash.ts' /> ////class Foo { //// static /*a*/bar/*b*/(t: string, s: string): string { //// return s + t; //// } ////} ////Foo.bar("a", "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: `class Foo { static bar({ t, s }: { t: string; s: string; }): string { return s + t; } } Foo.bar({ t: "a", s: "b" });` });
{ "end_byte": 572, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_staticMethod.ts" }
TypeScript/tests/cases/fourslash/completionListInContextuallyTypedArgument.ts_0_404
/// <reference path='fourslash.ts' /> ////interface MyPoint { //// x1: number; //// y1: number; ////} //// ////function foo(a: (e: MyPoint) => string) { } ////foo((e) => { //// e./*1*/ ////} ); //// ////class test { //// constructor(a: (e: MyPoint) => string) { } ////} ////var t = new test((e) => { //// e./*2*/ ////} ); verify.completions({ marker: ["1", "2"], exact: ["x1", "y1"] });
{ "end_byte": 404, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInContextuallyTypedArgument.ts" }
TypeScript/tests/cases/fourslash/renameInheritedProperties3.ts_3_259
/ <reference path='fourslash.ts'/> //// interface interface1 extends interface1 { //// [|[|{| "contextRangeIndex": 0 |}propName|]: string;|] //// } //// //// var v: interface1; //// v.[|propName|]; verify.baselineRenameAtRangesWithText("propName");
{ "end_byte": 259, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameInheritedProperties3.ts" }
TypeScript/tests/cases/fourslash/findAllRefsInheritedProperties2.ts_3_315
/ <reference path='fourslash.ts'/> //// interface interface1 extends interface1 { //// /*1*/doStuff(): void; // r0 //// /*2*/propName: string; // r1 //// } //// //// var v: interface1; //// v./*3*/doStuff(); // r2 //// v./*4*/propName; // r3 verify.baselineFindAllReferences('1', '2', '3', '4');
{ "end_byte": 315, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsInheritedProperties2.ts" }
TypeScript/tests/cases/fourslash/goToDefinition_untypedModule.ts_0_209
/// <reference path='fourslash.ts' /> // @Filename: /node_modules/foo/index.js ////not read // @Filename: /a.ts ////import { /*def*/f } from "foo"; ////[|/*use*/f|](); verify.baselineGoToDefinition("use");
{ "end_byte": 209, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinition_untypedModule.ts" }
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue7.ts_0_287
/// <reference path='fourslash.ts' /> //// function Foo (a: () => number) { a() } //// Foo(() => { 1 }) verify.codeFixAvailable([ { description: ts.Diagnostics.Add_a_return_statement.message }, { description: ts.Diagnostics.Remove_braces_from_arrow_function_body.message } ]);
{ "end_byte": 287, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue7.ts" }
TypeScript/tests/cases/fourslash/deleteTypeParameter.ts_0_288
/// <reference path="fourslash.ts" /> //// interface Query<T> { //// groupBy(): Query</**/T>; //// } //// interface Query2<T> { //// groupBy(): Query2<Query<T>>; //// } //// var q1: Query<number>; //// var q2: Query2<number>; //// q1 = q2; goTo.marker(); edit.deleteAtCaret(1);
{ "end_byte": 288, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/deleteTypeParameter.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_refactorAvailableImplicit1.ts_0_411
/// <reference path='fourslash.ts' /> //// export /*a*//*b*/function fn() { //// console.log('Hello') //// } //// fn(); goTo.select("a", "b"); verify.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_refactorAvailableImplicit1.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteral10.ts_0_262
/// <reference path='fourslash.ts'/> ////type As = 'arf' | 'abacus' | 'abaddon'; ////let a: As; ////if ('[|/**/|]' != a verify.completions({ marker: "", exact: ["arf", "abacus", "abaddon"].map(name => ({ name, replacementSpan: test.ranges()[0] })) });
{ "end_byte": 262, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral10.ts" }
TypeScript/tests/cases/fourslash/genericWithSpecializedProperties2.ts_0_403
/// <reference path='fourslash.ts'/> ////interface Foo<T> { //// y: Foo<number>; //// x: Foo<string>; ////} ////var f: Foo<string>; ////var /*1*/x = f.x; ////var /*2*/y = f.y; ////var f2: Foo<number>; ////var /*3*/x2 = f2.x; ////var /*4*/y2 = f2.y; verify.quickInfos({ 1: "var x: Foo<string>", 2: "var y: Foo<number>", 3: "var x2: Foo<string>", 4: "var y2: Foo<number>" });
{ "end_byte": 403, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericWithSpecializedProperties2.ts" }
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc23.ts_0_687
/// <reference path='fourslash.ts' /> // @strict: true /////** //// * @typedef Foo //// * @template L, R //// */ /////** //// * @param {function(R): boolean} a //// * @param {function(R): L} b //// * @returns {function(R): Foo.<L, R>} //// * @template L, R //// */ ////function foo(a, b) { ////} verify.codeFix({ description: ts.Diagnostics.Annotate_with_type_from_JSDoc.message, index: 2, newFileContent: `/** * @typedef Foo * @template L, R */ /** * @param {function(R): boolean} a * @param {function(R): L} b * @returns {function(R): Foo.<L, R>} * @template L, R */ function foo<L, R>(a: (arg0: R) => boolean, b: (arg0: R) => L): (arg0: R) => Foo<L, R> { }`, });
{ "end_byte": 687, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc23.ts" }
TypeScript/tests/cases/fourslash/inlineVariableDestructuredVariableDeclaration1.ts_0_203
/// <reference path="fourslash.ts" /> ////export function Component(props: any) { //// const { foo } = /*a*/props/*b*/; ////} goTo.select("a", "b"); verify.not.refactorAvailable("Inline variable");
{ "end_byte": 203, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableDestructuredVariableDeclaration1.ts" }
TypeScript/tests/cases/fourslash/completionsPathsJsonModuleWithoutResolveJsonModule.ts_0_255
/// <reference path="fourslash.ts" /> // @moduleResolution: node // @Filename: /project/test.json ////not read // @Filename: /project/index.ts ////import { } from ".//**/"; verify.completions({ marker: "", exact: [], isNewIdentifierLocation: true });
{ "end_byte": 255, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsPathsJsonModuleWithoutResolveJsonModule.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_importType4.ts_0_432
/// <reference path="fourslash.ts" /> // @preserveValueImports: true // @isolatedModules: true // @module: es2015 // @Filename: /exports.ts //// export interface SomeInterface {} //// export class SomePig {} // @Filename: /a.ts //// import type { SomeInterface } from "./exports.js"; //// new SomePig/**/ goTo.marker(""); verify.importFixAtPosition([ `import { SomePig, type SomeInterface } from "./exports.js"; new SomePig`]);
{ "end_byte": 432, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_importType4.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_importFileExtensions.ts_0_1316
/// <reference path="fourslash.ts"/> // @Filename: /tsconfig.json ////{ //// "compilerOptions": { //// "moduleResolution": "Node16", //// } ////} // @Filename: /package.json //// { "type": "module" } // @Filename: /src/main.ts ////[|export function someLibFn(): string { //// return main(); ////}|] //// ////function main(): string { //// return "hello world!"; ////} ////console.log(someLibFn()); // @Filename: /other.ts ////import { someLibFn } from "./src/main.js"; //// ////function someOtherFn(): string { //// return someLibFn(); ////} // @Filename: /act/action.ts ////import { someLibFn } from "../src/main.js"; //// ////function doAction(): string { //// return someLibFn(); ////} verify.moveToNewFile({ newFileContents: { "/src/main.ts": `import { someLibFn } from "./someLibFn.js"; export function main(): string { return "hello world!"; } console.log(someLibFn());`, "/src/someLibFn.ts": `import { main } from "./main.js"; export function someLibFn(): string { return main(); } `, "/other.ts": `import { someLibFn } from "./src/someLibFn.js"; function someOtherFn(): string { return someLibFn(); }`, "/act/action.ts": `import { someLibFn } from "../src/someLibFn.js"; function doAction(): string { return someLibFn(); }`, } });
{ "end_byte": 1316, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_importFileExtensions.ts" }
TypeScript/tests/cases/fourslash/renameAcrossMultipleProjects.ts_0_289
/// <reference path="fourslash.ts" /> //@Filename: a.ts ////[|var [|{| "contextRangeIndex": 0 |}x|]: number;|] //@Filename: b.ts /////// <reference path="a.ts" /> ////[|x|]++; //@Filename: c.ts /////// <reference path="a.ts" /> ////[|x|]++; verify.baselineRenameAtRangesWithText("x");
{ "end_byte": 289, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameAcrossMultipleProjects.ts" }
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_InnerAsyncFunction3.ts_0_384
/// <reference path='fourslash.ts' /> /////*a*/const fn = () => //// async function*() { }/*b*/ goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert arrow function or function expression", actionName: "Convert to named function", actionDescription: "Convert to named function", newContent: `function fn() { return async function*() { }; }`, });
{ "end_byte": 384, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_InnerAsyncFunction3.ts" }
TypeScript/tests/cases/fourslash/codeFixNoPropertyAccessFromIndexSignature3.ts_0_464
/// <reference path='fourslash.ts'/> // @noPropertyAccessFromIndexSignature: true //// interface C { //// foo: string //// [k: string]: string //// } //// declare const c: C | undefined; //// c?.foo; //// c?.bar; verify.codeFix({ description: [ts.Diagnostics.Use_element_access_for_0.message, 'bar'], index: 0, newFileContent: `interface C { foo: string [k: string]: string } declare const c: C | undefined; c?.foo; c?.["bar"];`, });
{ "end_byte": 464, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixNoPropertyAccessFromIndexSignature3.ts" }
TypeScript/tests/cases/fourslash/calledUnionsOfDissimilarTyeshaveGoodDisplay.ts_0_1653
/// <reference path="fourslash.ts" /> ////declare const callableThing1: //// | ((o1: {x: number}) => void) //// | ((o1: {y: number}) => void) //// ; //// ////callableThing1(/*1*/); //// ////declare const callableThing2: //// | ((o1: {x: number}) => void) //// | ((o2: {y: number}) => void) //// ; //// ////callableThing2(/*2*/); //// ////declare const callableThing3: //// | ((o1: {x: number}) => void) //// | ((o2: {y: number}) => void) //// | ((o3: {z: number}) => void) //// | ((o4: {u: number}) => void) //// | ((o5: {v: number}) => void) //// ; //// ////callableThing3(/*3*/); //// ////declare const callableThing4: //// | ((o1: {x: number}) => void) //// | ((o2: {y: number}) => void) //// | ((o3: {z: number}) => void) //// | ((o4: {u: number}) => void) //// | ((o5: {v: number}) => void) //// | ((o6: {w: number}) => void) //// ; //// ////callableThing4(/*4*/); //// ////declare const callableThing5: //// | (<U>(a1: U) => void) //// | (() => void) //// ; //// ////callableThing5(/*5*/1) //// verify.signatureHelp({ marker: "1", text: "callableThing1(o1: { x: number; } & { y: number; }): void" }, { marker: "2", text: "callableThing2(arg0: { x: number; } & { y: number; }): void" }, { marker: "3", text: "callableThing3(arg0: { x: number; } & { y: number; } & { z: number; } & { u: number; } & { v: number; }): void" }, { marker: "4", text: "callableThing4(arg0: { x: number; } & { y: number; } & { z: number; } & { u: number; } & { v: number; } & { w: number; }): void" }, { marker: "5", text: "callableThing5(a1: number): void" });
{ "end_byte": 1653, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/calledUnionsOfDissimilarTyeshaveGoodDisplay.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts_0_276
/// <reference path='fourslash.ts' /> //// interface I1 { //// x: number; //// } //// interface I2 { //// y: number; //// } //// //// class C implements I1,I2 {[| //// |]y: number; //// } verify.rangeAfterCodeFix(` x: number; `); verify.not.codeFixAvailable();
{ "end_byte": 276, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts" }
TypeScript/tests/cases/fourslash/completionListNewIdentifierFunctionDeclaration.ts_0_232
/// <reference path='fourslash.ts' /> // @noLib: true ////function F(pref: (a/*1*/ verify.completions({ marker: "1", exact: completion.typeKeywords, isNewIdentifierLocation: true, defaultCommitCharacters: [], });
{ "end_byte": 232, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListNewIdentifierFunctionDeclaration.ts" }
TypeScript/tests/cases/fourslash/codeFixAddVoidToPromise.1.ts_0_340
/// <reference path='fourslash.ts' /> // @target: esnext // @lib: es2015 // @strict: true ////const p1 = new Promise(resolve => resolve()); verify.codeFix({ errorCode: 2794, description: "Add 'void' to Promise resolved without a value", index: 0, newFileContent: `const p1 = new Promise<void>(resolve => resolve());` });
{ "end_byte": 340, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddVoidToPromise.1.ts" }
TypeScript/tests/cases/fourslash/codeFixTopLevelAwait_target_missingCompilerOptionsInTsConfig.ts_0_467
/// <reference path="fourslash.ts" /> // @filename: /dir/a.ts ////declare const p: Promise<number>; ////await p; ////export {}; // @filename: /dir/tsconfig.json ////{ ////} verify.codeFix({ description: [ts.Diagnostics.Set_the_target_option_in_your_configuration_file_to_0.message, "es2017"], index: 0, newFileContent: { "/dir/tsconfig.json": `{ "compilerOptions": { "target": "es2017", "module": "commonjs" } }` } });
{ "end_byte": 467, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelAwait_target_missingCompilerOptionsInTsConfig.ts" }
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnon_Typed.ts_0_411
/// <reference path='fourslash.ts' /> //// const increment = /*x*/(/*y*/a: number): number => a + 1; goTo.select("x", "y"); edit.applyRefactor({ refactorName: "Convert arrow function or function expression", actionName: "Convert to anonymous function", actionDescription: "Convert to anonymous function", newContent: `const increment = function(a: number): number { return a + 1; };`, });
{ "end_byte": 411, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnon_Typed.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements4.ts_0_385
/// <reference path="fourslash.ts" /> // @noUnusedLocals: true // @noUnusedParameters: true ////[|function f({ //// a, b, /* comment related to c */ //// c, ////}: any)|] { //// a; //// c; ////} verify.codeFix({ index: 0, description: "Remove unused declaration for: 'b'", newRangeContent: `function f({ a, /* comment related to c */ c, }: any)` });
{ "end_byte": 385, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements4.ts" }
TypeScript/tests/cases/fourslash/completionListForShorthandPropertyAssignment2.ts_0_152
/// <reference path="fourslash.ts" /> //// var person: {name:string; id: number} = { n/**/ verify.completions({ marker: "", exact: ["id", "name"] });
{ "end_byte": 152, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListForShorthandPropertyAssignment2.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts_0_873
/// <reference path='fourslash.ts' /> // Should give completions for all node modules visible to the script // @Filename: dir1/dir2/dir3/dir4/test0.ts //// import * as foo1 from "f/*import_as0*/ //// import foo4 = require("f/*import_equals0*/ //// var foo7 = require("f/*require0*/ // @Filename: package.json //// { "dependencies": { "fake-module": "latest" } } // @Filename: node_modules/fake-module/ts.ts //// // @Filename: dir1/package.json //// { "dependencies": { "fake-module2": "latest" } } // @Filename: dir1/node_modules/fake-module2/index.ts //// // @Filename: dir1/dir2/dir3/package.json //// { "dependencies": { "fake-module3": "latest" } } // @Filename: dir1/dir2/dir3/node_modules/fake-module3/ts.ts //// verify.completions({ marker: test.markers(), exact: ["fake-module3", "fake-module2", "fake-module"], isNewIdentifierLocation: true, });
{ "end_byte": 873, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts" }
TypeScript/tests/cases/fourslash/pathCompletionsTypesVersionsWildcard4.ts_0_932
/// <reference path="fourslash.ts" /> // @module: commonjs // @Filename: /node_modules/foo/package.json //// { //// "types": "index.d.ts", //// "typesVersions": { //// ">=4.3.5": { //// "component-*": ["cjs/components/*"] //// } //// } //// } // @Filename: /node_modules/foo/nope.d.ts //// export const nope = 0; // @Filename: /node_modules/foo/cjs/components/index.d.ts //// export const index = 0; // @Filename: /node_modules/foo/cjs/components/blah.d.ts //// export const blah = 0; // @Filename: /node_modules/foo/cjs/components/subfolder/one.d.ts //// export const one = 0; // @Filename: /a.ts //// import { } from "foo//**/"; verify.completions({ marker: "", isNewIdentifierLocation: true, exact: ["component-blah", "component-index", "component-subfolder", "nope", "cjs"], }); edit.insert("component-subfolder/"); verify.completions({ isNewIdentifierLocation: true, exact: ["one"], });
{ "end_byte": 932, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsTypesVersionsWildcard4.ts" }
TypeScript/tests/cases/fourslash/referencesForStatic.ts_0_661
/// <reference path='fourslash.ts'/> // Reference a class static. // @Filename: referencesOnStatic_1.ts ////var n = 43; //// ////class foo { //// /*1*/static /*2*/n = ''; //// //// public bar() { //// foo./*3*/n = "'"; //// if(foo./*4*/n) { //// var x = foo./*5*/n; //// } //// } ////} //// ////class foo2 { //// private x = foo./*6*/n; //// constructor() { //// foo./*7*/n = x; //// } //// //// function b(n) { //// n = foo./*8*/n; //// } ////} // @Filename: referencesOnStatic_2.ts ////var q = foo./*9*/n; verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6', '7', '8', '9');
{ "end_byte": 661, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForStatic.ts" }
TypeScript/tests/cases/fourslash/completionPropertyShorthandForObjectLiteral4.ts_0_216
/// <reference path="fourslash.ts"/> //// const foo = 1; //// const bar = 2; //// const obj: any = { //// foo b/*1*/ verify.completions({ marker: ["1"], exact: completion.globalsPlus(["bar", "foo"]), });
{ "end_byte": 216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionPropertyShorthandForObjectLiteral4.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_jsExtension.ts_0_842
/// <reference path="fourslash.ts" /> // @moduleResolution: node // @noLib: true // @jsx: preserve // @Filename: /a.ts ////export function a() {} // @Filename: /b.ts ////export function b() {} // @Filename: /c.tsx ////export function c() {} // @Filename: /c.ts ////import * as g from "global"; // Global imports skipped ////import { a } from "./a.js"; ////import { a as a2 } from "./a"; // Ignored, only the first relative import is considered ////b; c; goTo.file("/c.ts"); verify.codeFixAll({ fixId: "fixMissingImport", fixAllDescription: "Add all missing imports", newFileContent: `import * as g from "global"; // Global imports skipped import { a } from "./a.js"; import { a as a2 } from "./a"; // Ignored, only the first relative import is considered import { b } from "./b.js"; import { c } from "./c.jsx"; b; c;`, });
{ "end_byte": 842, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_jsExtension.ts" }
TypeScript/tests/cases/fourslash/thisPredicateFunctionQuickInfo.ts_0_1760
/// <reference path="fourslash.ts" /> //// class RoyalGuard { //// isLeader(): this is LeadGuard { //// return this instanceof LeadGuard; //// } //// isFollower(): this is FollowerGuard { //// return this instanceof FollowerGuard; //// } //// } //// //// class LeadGuard extends RoyalGuard { //// lead(): void {}; //// } //// //// class FollowerGuard extends RoyalGuard { //// follow(): void {}; //// } //// //// let a: RoyalGuard = new FollowerGuard(); //// if (a.is/*1*/Leader()) { //// a./*2*/; //// } //// else if (a.is/*3*/Follower()) { //// a./*4*/; //// } //// //// interface GuardInterface { //// isLeader(): this is LeadGuard; //// isFollower(): this is FollowerGuard; //// } //// //// let b: GuardInterface; //// if (b.is/*5*/Leader()) { //// b./*6*/; //// } //// else if (b.is/*7*/Follower()) { //// b./*8*/; //// } //// //// if (((a.isLeader)())) { //// a./*9*/; //// } //// else if (((a).isFollower())) { //// a./*10*/; //// } //// //// if (((a["isLeader"])())) { //// a./*11*/; //// } //// else if (((a)["isFollower"]())) { //// a./*12*/; //// } //// //// let leader/*13*/Status = a.isLeader(); //// function isLeaderGuard(g: RoyalGuard) { //// return g.isLeader(); //// } //// let checked/*14*/LeaderStatus = isLeader/*15*/Guard(a); verify.quickInfos({ 1: "(method) RoyalGuard.isLeader(): this is LeadGuard", 3: "(method) RoyalGuard.isFollower(): this is FollowerGuard", 5: "(method) GuardInterface.isLeader(): this is LeadGuard", 7: "(method) GuardInterface.isFollower(): this is FollowerGuard", 13: "let leaderStatus: boolean", 14: "let checkedLeaderStatus: boolean", 15: "function isLeaderGuard(g: RoyalGuard): g is LeadGuard" });
{ "end_byte": 1760, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/thisPredicateFunctionQuickInfo.ts" }
TypeScript/tests/cases/fourslash/codeFixSpelling8.ts_0_257
/// <reference path='fourslash.ts' /> ////module Foo { //// export type nums = number; ////} ////let x: Foo.[|num|]; verify.codeFix({ index: 0, description: [ts.Diagnostics.Change_spelling_to_0.message, "nums"], newRangeContent: "nums" });
{ "end_byte": 257, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpelling8.ts" }
TypeScript/tests/cases/fourslash/codeFixConvertToMappedObjectType1.ts_0_338
/// <reference path='fourslash.ts' /> //// type K = "foo" | "bar"; //// interface 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": 338, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToMappedObjectType1.ts" }
TypeScript/tests/cases/fourslash/overloadOnConstCallSignature.ts_0_390
/// <reference path='fourslash.ts'/> ////var foo: { //// (name: string): string; //// (name: 'order'): string; //// (name: 'content'): string; //// (name: 'done'): string; ////} ////var /*2*/x = foo(/*1*/ verify.signatureHelp({ marker: "1", overloadsCount: 4, text: 'foo(name: "order"): string', }) edit.insert('"hi"'); verify.quickInfoAt("2", "var x: string");
{ "end_byte": 390, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/overloadOnConstCallSignature.ts" }
TypeScript/tests/cases/fourslash/codeFixPropertyOverrideAccess3.ts_0_548
/// <reference path='fourslash.ts' /> // @strict: true // @Filename: foo.ts //// import { A } from './source' //// class B extends A { //// get x() { return 2 } //// } // @Filename: source.ts //// export class A { //// x = 1 //// } verify.codeFix({ description: `Generate 'get' and 'set' accessors`, newFileContent: { '/tests/cases/fourslash/source.ts': `export class A { private _x = 1; public get x() { return this._x; } public set x(value) { this._x = value; } }`}, index: 0 })
{ "end_byte": 548, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixPropertyOverrideAccess3.ts" }
TypeScript/tests/cases/fourslash/typeCheckAfterResolve.ts_0_557
/// <reference path="fourslash.ts" /> /////*start*/class Point implements /*IPointRef*/IPoint { //// getDist() { //// ssss; //// } ////}/*end*/ // Edit to invalidate the intial typeCheck state goTo.eof(); edit.insertLine(""); // Attempt to resolve a symbol verify.quickInfoAt("IPointRef", "any"); // not found // trigger typecheck after the partial resolve, we should see errors verify.errorExistsAfterMarker("IPointRef"); goTo.eof(); edit.insertLine(""); // one more time with full typecheck verify.errorExistsAfterMarker("IPointRef");
{ "end_byte": 557, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/typeCheckAfterResolve.ts" }
TypeScript/tests/cases/fourslash/nameOfRetypedClassInModule.ts_0_845
/// <reference path="fourslash.ts" /> //// module M { //// } //// //// module M { //// /*A*/class A {} //// /*B*/export class B {} //// class Check { /*check*/constructor(val) {} } //// export class Check2 { /*check2*/constructor(val) {} } //// } //// edit.disableFormatting(); verify.quickInfos({ check: "constructor Check(val: any): Check", check2: "constructor M.Check2(val: any): Check2" }); goTo.marker('A'); edit.deleteAtCaret('class A {}'.length); edit.insert('class A { constructor(val) {} }'); edit.moveLeft('constructor(val) {} }'.length); verify.quickInfoIs('constructor A(val: any): A'); goTo.marker('B'); edit.deleteAtCaret('export class B {}'.length); edit.insert('export class B { constructor(val) {} }'); edit.moveLeft('constructor(val) {} }'.length); verify.quickInfoIs('constructor M.B(val: any): B');
{ "end_byte": 845, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/nameOfRetypedClassInModule.ts" }
TypeScript/tests/cases/fourslash/jsDocPropertyDescription2.ts_0_278
///<reference path="fourslash.ts" /> //// interface SymbolExample { //// /** Something generic */ //// [key: symbol]: string; //// } //// function symbolExample(e: SymbolExample) { //// console.log(e./*symbol*/anything); //// } verify.quickInfoAt("symbol", "any")
{ "end_byte": 278, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocPropertyDescription2.ts" }
TypeScript/tests/cases/fourslash/jsdocParameterTagSnippetCompletion1.ts_0_2051
///<reference path="fourslash.ts" /> // @allowJs: true // @Filename: a.ts //// /** //// * @para/*0*/ //// */ //// function printValue(value, maximumFractionDigits) {} //// //// /** //// * @p/*a*/ //// */ //// function aa({ a = 1 }, b: string) { //// a; //// } //// //// /** //// * /*b*/ //// */ //// function bb(b: string) {} //// //// /** //// * //// * @p/*c*/ //// */ //// function cc({ b: { a, c } = { a: 1, c: 3 } }) { //// //// } //// //// /** //// * //// * @p/*d*/ //// */ //// function dd({ a: { b, c }, d: [e, f] }: { a: { b: number, c: number }, d: [string, string] }) { //// //// } // @Filename: b.js //// /** //// * @p/*ja*/ //// */ //// function aa({ a = 1 }, b) { //// a; //// } //// //// /** //// * /*jb*/ //// */ //// function bb(b) {} //// //// /** //// * //// * @p/*jc*/ //// */ //// function cc({ b: { a, c } = { a: 1, c: 3 } }) { //// //// } //// //// /** //// * //// * @p/*jd*/ //// */ //// function dd({ a: { b, c }, d: [e, f] }) { //// //// } //// //// const someconst = "aa"; //// /** //// * //// * @p/*je*/ //// */ //// function ee({ [someconst]: b }) { //// //// } //// //// /** //// * //// * @p/*jf*/ //// */ //// function ff({ "a": b }) { //// //// } //// //// /** //// * //// * @p/*jg*/ //// */ //// function gg(a, { b }) { //// //// } //// //// /** //// * //// * @param {boolean} a a's description //// * @p/*jh*/ //// */ //// function hh(a, { b }) { //// //// } //// /** //// * //// * @p/*ji*/ //// */ //// function ii({ b, ...c }, ...a) {} //// //// /** //// * //// * @p/*jj*/ //// */ //// function jj(...{ length }) {} //// //// /** //// * //// * @p/*jk*/ //// */ //// function kk(...a) {} //// //// function reallylongfunctionnameabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl(a) {} //// /** //// * //// * @p/*jl*/ //// */ //// function ll(a = reallylongfunctionnameabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl("")) {} ////} verify.baselineCompletions();
{ "end_byte": 2051, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocParameterTagSnippetCompletion1.ts" }
TypeScript/tests/cases/fourslash/promiseTyping2.ts_0_1216
/// <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<number> = null; //// p/*1*/1.then(function (x/*2*/x) { }); //// var p/*3*/2 = p1.then(function (x/*4*/x) { return "hello"; }) //// var p/*5*/3 = p2.then(function (x/*6*/x) { //// return x/*7*/x; //// }); verify.quickInfos({ 1: "var p1: IPromise<number>", 2: "(parameter) xx: number", 3: "var p2: IPromise<string>", 4: "(parameter) xx: number", 5: "var p3: IPromise<string>", 6: "(parameter) xx: string", 7: "(parameter) xx: string" });
{ "end_byte": 1216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/promiseTyping2.ts" }
TypeScript/tests/cases/fourslash/noImportCompletionsInOtherJavaScriptFile.ts_0_1388
/// <reference path="fourslash.ts" /> // @allowJs: true // @module: esnext // @Filename: /node_modules/foo/index.d.ts //// export const fail: number; // @Filename: /a.js //// export const x = 0; //// export class C {} //// // @Filename: /b.js //// /*1*/ // @Filename: /b2.js //////@ts-check /////*2*/ // @Filename: /b3.ts /////*3*/ // In esnext js files are assumed to be modules goTo.eachMarker(() => { verify.completions({ includes: { name: "fail", source: "/node_modules/foo/index", sourceDisplay: "./node_modules/foo/index", text: "const fail: number", kind: "const", kindModifiers: "export,declare", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, preferences: { includeCompletionsForModuleExports: true }, }); edit.insert("export const k = 10;\r\nf"); verify.completions({ includes: { name: "fail", source: "/node_modules/foo/index", sourceDisplay: "./node_modules/foo/index", text: "const fail: number", kind: "const", kindModifiers: "export,declare", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, preferences: { includeCompletionsForModuleExports: true }, }); });
{ "end_byte": 1388, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/noImportCompletionsInOtherJavaScriptFile.ts" }
TypeScript/tests/cases/fourslash/nodeModulesFileEditStillAllowsResolutionsToWork.ts_0_442
/// <reference path="fourslash.ts" /> // @Filename: /tsconfig.json //// { "compilerOptions": { "module": "nodenext", "strict": true } } // @Filename: /package.json //// { "type": "module", "imports": { "#foo": "./foo.cjs" } } // @Filename: /foo.cts //// export const x = 1; // @Filename: /index.ts //// import * as mod from "#foo"; //// /**/ goTo.marker(""); edit.insert("mod.x"); verify.noErrors(); verify.getSuggestionDiagnostics([]);
{ "end_byte": 442, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/nodeModulesFileEditStillAllowsResolutionsToWork.ts" }
TypeScript/tests/cases/fourslash/commentsLinePreservation.ts_0_4964
/// <reference path='fourslash.ts' /> /////** This is firstLine //// * This is second Line //// * //// * This is fourth Line //// */ ////var /*a*/a: string; /////** //// * This is firstLine //// * This is second Line //// * //// * This is fourth Line //// */ ////var /*b*/b: string; /////** //// * This is firstLine //// * This is second Line //// * //// * This is fourth Line //// * //// */ ////var /*c*/c: string; /////** //// * This is firstLine //// * This is second Line //// * @param param //// * @random tag This should be third line //// */ ////function /*d*/d(param: string) { /*1*/param = "hello"; } /////** //// * This is firstLine //// * This is second Line //// * @param param //// */ ////function /*e*/e(param: string) { /*2*/param = "hello"; } /////** //// * This is firstLine //// * This is second Line //// * @param param1 first line of param //// * //// * param information third line //// * @random tag This should be third line //// */ ////function /*f*/f(param1: string) { /*3*/param1 = "hello"; } /////** //// * This is firstLine //// * This is second Line //// * @param param1 //// * //// * param information first line //// * @random tag This should be third line //// */ ////function /*g*/g(param1: string) { /*4*/param1 = "hello"; } /////** //// * This is firstLine //// * This is second Line //// * @param param1 //// * //// * param information first line //// * //// * param information third line //// * @random tag This should be third line //// */ ////function /*h*/h(param1: string) { /*5*/param1 = "hello"; } /////** //// * This is firstLine //// * This is second Line //// * @param param1 //// * //// * param information first line //// * //// * param information third line //// * //// */ ////function /*i*/i(param1: string) { /*6*/param1 = "hello"; } /////** //// * This is firstLine //// * This is second Line //// * @param param1 //// * //// * param information first line //// * //// * param information third line //// */ ////function /*j*/j(param1: string) { /*7*/param1 = "hello"; } /////** //// * This is firstLine //// * This is second Line //// * @param param1 hello @randomtag //// * //// * random information first line //// * //// * random information third line //// */ ////function /*k*/k(param1: string) { /*8*/param1 = "hello"; } /////** //// * This is firstLine //// * This is second Line //// * @param param1 first Line text //// * //// * @param param1 //// * //// * blank line that shouldnt be shown when starting this //// * second time information about the param again //// */ ////function /*l*/l(param1: string) { /*9*/param1 = "hello"; } //// /** //// * This is firstLine //// This is second Line //// [1]: third * line //// @param param1 first Line text //// second line text //// */ ////function /*m*/m(param1: string) { /*10*/param1 = "hello"; } verify.quickInfos({ a: ["var a: string", "This is firstLine\nThis is second Line\n\nThis is fourth Line"], b: ["var b: string", "This is firstLine\nThis is second Line\n\nThis is fourth Line"], c: ["var c: string", "This is firstLine\nThis is second Line\n\nThis is fourth Line"], d: ["function d(param: string): void", "This is firstLine\nThis is second Line"], 1: "(parameter) param: string", e: ["function e(param: string): void", "This is firstLine\nThis is second Line"], 2: "(parameter) param: string", f: ["function f(param1: string): void", "This is firstLine\nThis is second Line"], 3: ["(parameter) param1: string", "first line of param\n\nparam information third line"], g: ["function g(param1: string): void", "This is firstLine\nThis is second Line"], 4: ["(parameter) param1: string", " param information first line"], h: ["function h(param1: string): void", "This is firstLine\nThis is second Line"], 5: ["(parameter) param1: string", " param information first line\n\n param information third line"], i: ["function i(param1: string): void", "This is firstLine\nThis is second Line"], 6: ["(parameter) param1: string", " param information first line\n\n param information third line"], j: ["function j(param1: string): void", "This is firstLine\nThis is second Line"], 7: ["(parameter) param1: string", " param information first line\n\n param information third line"], k: ["function k(param1: string): void", "This is firstLine\nThis is second Line"], 8: ["(parameter) param1: string", "hello"], l: ["function l(param1: string): void", "This is firstLine\nThis is second Line"], 9: ["(parameter) param1: string", "first Line text\nblank line that shouldnt be shown when starting this \nsecond time information about the param again"], m: ["function m(param1: string): void", "This is firstLine\nThis is second Line\n[1]: third * line"], 10: ["(parameter) param1: string", "first Line text\nsecond line text"] });
{ "end_byte": 4964, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/commentsLinePreservation.ts" }
TypeScript/tests/cases/fourslash/formatTypeArgumentOnNewLine.ts_0_383
/// <reference path="fourslash.ts"/> ////const genericObject = new GenericObject< //// /*1*/{} ////>(); ////const genericObject2 = new GenericObject2< //// /*2*/{}, //// /*3*/{} ////>(); format.document(); goTo.marker("1"); verify.currentLineContentIs(" {}"); goTo.marker("2"); verify.currentLineContentIs(" {},"); goTo.marker("3"); verify.currentLineContentIs(" {}");
{ "end_byte": 383, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatTypeArgumentOnNewLine.ts" }
TypeScript/tests/cases/fourslash/completionsTypeKeywords.ts_0_191
/// <reference path="fourslash.ts" /> // @noLib: true ////type T = /**/ verify.completions({ marker: "", exact: completion.typeKeywordsPlus(["T", completion.globalThisEntry]), });
{ "end_byte": 191, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsTypeKeywords.ts" }
TypeScript/tests/cases/fourslash/codeFixOverrideModifier18.ts_0_227
/// <reference path='fourslash.ts' /> // @noImplicitOverride: true ////class A { //// static foo() {} ////} ////class B extends A { //// [|static foo() {}|] ////} verify.not.codeFixAvailable("fixAddOverrideModifier");
{ "end_byte": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixOverrideModifier18.ts" }
TypeScript/tests/cases/fourslash/javascriptModules20.ts_0_405
/// <reference path='fourslash.ts'/> // @allowJs: true // @Filename: mod.js //// function foo() { return {a: true}; } //// module.exports = foo(); // @Filename: app.js //// import * as mod from "./mod" //// mod./**/ verify.completions({ marker: "", exact: [ { name: "a", kind: "property" }, { name: "mod", kind: "warning", sortText: completion.SortText.JavascriptIdentifiers }] });
{ "end_byte": 405, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javascriptModules20.ts" }
TypeScript/tests/cases/fourslash/tabbingAfterNewlineInsertedBeforeWhile.ts_0_269
/// <reference path='fourslash.ts' /> ////function foo() { //// /**/while (true) { } ////} goTo.marker(); edit.insertLine(''); // Enter' should smart indent such that the current line maintains its indentation verify.currentLineContentIs(' while (true) { }');
{ "end_byte": 269, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tabbingAfterNewlineInsertedBeforeWhile.ts" }
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax24.ts_0_176
/// <reference path='fourslash.ts' /> ////declare class C { //// m(): [|*|]; ////} verify.codeFix({ description: "Change '*' to 'any'", newRangeContent: "any", });
{ "end_byte": 176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax24.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_requireImport1.ts_0_363
/// <reference path="fourslash.ts" /> // @allowJs: true // @filename: /a.js ////module.exports = 1; // @filename: /b.js ////var a = require("./a"); ////[|function f() { //// a; ////}|] verify.noErrors(); verify.moveToNewFile({ newFileContents: { "/b.js": "", "/f.js": `const a = require("./a"); function f() { a; } `, }, });
{ "end_byte": 363, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_requireImport1.ts" }
TypeScript/tests/cases/fourslash/todoComments18.ts_0_195
/// <reference path='fourslash.ts' /> // Tests node_modules name in file still gets todos. // @Filename: /node_modules_todoTest0.ts //// // [|TODO|] verify.todoCommentsInCurrentFile(["TODO"]);
{ "end_byte": 195, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/todoComments18.ts" }
TypeScript/tests/cases/fourslash/refactorKind_rewriteOptionalChain.ts_0_197
/// <reference path='fourslash.ts' /> //// /*a*/foo && foo.bar/*b*/ goTo.select("a", "b"); verify.refactorKindAvailable("refactor.rewrite", [ "refactor.rewrite.expression.optionalChain" ]);
{ "end_byte": 197, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorKind_rewriteOptionalChain.ts" }
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType23.ts_0_378
/// <reference path='fourslash.ts' /> ////const foo = async /*a*//*b*/(a) => { //// return 1; ////} goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Infer function return type", actionName: "Infer function return type", actionDescription: "Infer function return type", newContent: `const foo = async (a): Promise<number> => { return 1; }` });
{ "end_byte": 378, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType23.ts" }
TypeScript/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts_0_505
/// <reference path='fourslash.ts' /> // @Filename: a.ts //// var [x/*variable1*/ // @Filename: b.ts //// var [x, y/*variable2*/ // @Filename: c.ts //// var [./*variable3*/ // @Filename: d.ts //// var [x, ...z/*variable4*/ // @Filename: e.ts //// var {x/*variable5*/ // @Filename: f.ts //// var {x, y/*variable6*/ // @Filename: g.ts //// function func1({ a/*parameter1*/ // @Filename: h.ts //// function func2({ a, b/*parameter2*/ verify.completions({ marker: test.markers(), exact: undefined });
{ "end_byte": 505, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_destructuring.ts" }
TypeScript/tests/cases/fourslash/codeFixTopLevelAwait_target_blankCompilerOptionsInTsConfig.ts_0_506
/// <reference path="fourslash.ts" /> // @filename: /dir/a.ts ////declare const p: Promise<number>; ////await p; ////export {}; // @filename: /dir/tsconfig.json ////{ //// "compilerOptions": { //// } ////} verify.codeFix({ description: [ts.Diagnostics.Set_the_target_option_in_your_configuration_file_to_0.message, "es2017"], index: 0, newFileContent: { "/dir/tsconfig.json": `{ "compilerOptions": { "target": "es2017", "module": "commonjs" } }` } });
{ "end_byte": 506, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelAwait_target_blankCompilerOptionsInTsConfig.ts" }
TypeScript/tests/cases/fourslash/autoImportPackageJsonImports_ts.ts_0_347
/// <reference path="fourslash.ts" /> // @module: nodenext // @Filename: /package.json //// { //// "imports": { //// "#thing": "./src/something.ts" //// } //// } // @Filename: /src/something.ts //// export function something(name: string): any; // @Filename: /a.ts //// something/**/ verify.importFixModuleSpecifiers("", ["#thing"]);
{ "end_byte": 347, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPackageJsonImports_ts.ts" }
TypeScript/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard10.ts_0_556
/// <reference path="fourslash.ts" /> // @module: preserve // @moduleResolution: bundler // @allowImportingTsExtensions: true // @jsx: react // @Filename: /node_modules/repo/package.json //// { //// "name": "repo", //// "exports": { //// "./*": "./src/*" //// } //// } // @Filename: /node_modules/repo/src/card.tsx //// export {}; // @Filename: /main.ts //// import { } from "repo//**/"; verify.completions({ marker: "", isNewIdentifierLocation: true, exact: [ { name: "card.tsx", kind: "script", kindModifiers: ".tsx" }, ], });
{ "end_byte": 556, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard10.ts" }
TypeScript/tests/cases/fourslash/moveToFile_existingImports3.ts_0_538
/// <reference path='fourslash.ts' /> // @allowJs: true // @module: commonjs // @filename: /common.js ////export const x = 1; // @filename: /a.js ////const { x } = require("./common"); ////[|module.exports.b = x;|] // @filename: /b.js ////const { x } = require("./common"); ////module.exports.a = x; verify.moveToFile({ newFileContents: { "/a.js": "", "/b.js": `const { x } = require("./common"); module.exports.a = x; module.exports.b = x; `, }, interactiveRefactorArguments: { targetFile: "/b.js" }, });
{ "end_byte": 538, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_existingImports3.ts" }
TypeScript/tests/cases/fourslash/unusedImportDeclaration_withEmptyPath4.ts_0_657
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////// leading trivia ////import * as a from ""; ////import * as b from ""; ////import * as c from ""; verify.codeFix({ index: 0, description: "Remove import from ''", newFileContent: `// leading trivia import * as b from ""; import * as c from "";`, }); verify.codeFix({ index: 1, description: "Remove import from ''", newFileContent: `// leading trivia import * as a from ""; import * as c from "";`, }); verify.codeFix({ index: 2, description: "Remove import from ''", newFileContent: `// leading trivia import * as a from ""; import * as b from ""; ` });
{ "end_byte": 657, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedImportDeclaration_withEmptyPath4.ts" }
TypeScript/tests/cases/fourslash/quickInfoCallProperty.ts_0_221
/// <reference path="fourslash.ts" /> ////interface I { //// /** Doc */ //// m: () => void; ////} ////function f(x: I): void { //// x./**/m(); ////} verify.quickInfoAt("", "(property) I.m: () => void", "Doc");
{ "end_byte": 221, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoCallProperty.ts" }
TypeScript/tests/cases/fourslash/navigationBarItemsMultilineStringIdentifiers3.ts_1_1353
//// declare module 'MoreThanOneHundredAndFiftyCharacters\ //// MoreThanOneHundredAndFiftyCharacters\ //// MoreThanOneHundredAndFiftyCharacters\ //// MoreThanOneHundredAndFiftyCharacters\ //// MoreThanOneHundredAndFiftyCharacters\ //// MoreThanOneHundredAndFiftyCharacters\ //// MoreThanOneHundredAndFiftyCharacters' { } verify.navigationTree({ "text": "<global>", "kind": "script", "childItems": [ { "text": "'MoreThanOneHundredAndFiftyCharactersMoreThanOneHundredAndFiftyCharactersMoreThanOneHundredAndFiftyCharactersMoreThanOneHundredAndFiftyCharacter...", "kind": "module", "kindModifiers": "declare" } ] }); verify.navigationBar([ { "text": "<global>", "kind": "script", "childItems": [ { "text": "'MoreThanOneHundredAndFiftyCharactersMoreThanOneHundredAndFiftyCharactersMoreThanOneHundredAndFiftyCharactersMoreThanOneHundredAndFiftyCharacter...", "kind": "module", "kindModifiers": "declare" } ] }, { "text": "'MoreThanOneHundredAndFiftyCharactersMoreThanOneHundredAndFiftyCharactersMoreThanOneHundredAndFiftyCharactersMoreThanOneHundredAndFiftyCharacter...", "kind": "module", "kindModifiers": "declare", "indent": 1 } ]);
{ "end_byte": 1353, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsMultilineStringIdentifiers3.ts" }
TypeScript/tests/cases/fourslash/formattingExpressionsInIfCondition.ts_0_214
/// <reference path='fourslash.ts' /> ////if (a === 1 || //// /*0*/b === 2 ||/*1*/ //// c === 3) { ////} goTo.marker("1"); edit.insert("\n"); goTo.marker("0"); verify.currentLineContentIs(" b === 2 ||");
{ "end_byte": 214, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingExpressionsInIfCondition.ts" }
TypeScript/tests/cases/fourslash/findAllRefsJsDocTypeDef_js.ts_0_412
/// <reference path='fourslash.ts'/> // Tests that the scope of @typedef is not just the node immediately below it. // @allowJs: true // @Filename: /a.js /////** /*1*/@typedef {number} /*2*/T */ //// /////** //// * @return {/*3*/T} //// */ ////function f(obj) { return 0; } //// /////** //// * @return {/*4*/T} //// */ ////function f2(obj) { return 0; } verify.baselineFindAllReferences('1', '2', '3', '4');
{ "end_byte": 412, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsJsDocTypeDef_js.ts" }
TypeScript/tests/cases/fourslash/completionsObjectLiteralMethod4.ts_0_1100
/// <reference path="fourslash.ts" /> // @newline: LF // @Filename: a.ts ////interface IFoo { //// bar(this: IFoo): void; ////} ////const obj: IFoo = { //// /*1*/ ////} verify.completions({ marker: "1", preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: true, includeCompletionsWithObjectLiteralMethodSnippets: true, useLabelDetailsInCompletionEntries: true, }, includes: [ { name: "bar", sortText: completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "bar"), insertText: undefined, }, { name: "bar", sortText: completion.SortText.SortBelow( completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "bar")), source: completion.CompletionSource.ObjectLiteralMethodSnippet, isSnippet: true, insertText: "bar() {\n $0\n},", labelDetails: { detail: "()", }, }, ], });
{ "end_byte": 1100, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsObjectLiteralMethod4.ts" }
TypeScript/tests/cases/fourslash/navto_excludeLib4.ts_0_600
/// <reference path="fourslash.ts"/> // @filename: /node_modules/bar/index.d.ts //// import { someOtherName } from "./baz"; //// export const [|someName: number|]; // @filename: /node_modules/bar/baz.d.ts //// export const someOtherName: string; const [some] = test.ranges(); verify.navigateTo({ pattern: "some", excludeLibFiles: true, fileName: "/node_modules/bar/index.d.ts", expected: [ { name: "someName", kind: "const", kindModifiers: "export,declare", range: some, matchKind: "prefix", }, ], });
{ "end_byte": 600, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navto_excludeLib4.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesAsyncAwait.ts_0_431
/// <reference path='fourslash.ts' /> ////[|async|] function f() { //// [|await|] 100; //// [|a/**/wait|] [|await|] 200; ////class Foo { //// async memberFunction() { //// await 1; //// } ////} //// return [|await|] async function () { //// await 300; //// } ////} ////async function g() { //// await 300; //// async function f() { //// await 400; //// } ////} verify.baselineDocumentHighlights();
{ "end_byte": 431, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesAsyncAwait.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionLabels.ts_0_446
/// <reference path='fourslash.ts' /> /////*label1Definition*/label1: while (true) { //// /*label2Definition*/label2: while (true) { //// break [|/*1*/label1|]; //// continue [|/*2*/label2|]; //// () => { break [|/*3*/label1|]; } //// continue /*4*/unknownLabel; //// } ////} verify.baselineGoToDefinition( "1", "2", // labels across function boundaries "3", // undefined label "4", );
{ "end_byte": 446, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionLabels.ts" }
TypeScript/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation2.ts_0_212
/// <reference path='fourslash.ts'/> // @strict: true // @exactOptionalPropertyTypes: true //// declare const xx: { prop?: number }; //// xx.prop/*1*/ += 1; verify.quickInfoAt('1', '(property) prop?: number');
{ "end_byte": 212, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation2.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageContextualImport4.ts_0_768
/// <reference path="fourslash.ts" /> // @strict: true // @noImplicitAny: true // @noLib: true // @Filename: /getEmail.ts ////import { User, Settings } from './a'; ////export declare function getEmail(user: User, settings: Settings): string; // @Filename: /a.ts ////export interface User {} ////export interface Settings {} // @Filename: /b.ts ////import { getEmail } from './getEmail'; //// ////export function f([|user|], settings) { //// getEmail(user, settings); ////} goTo.file("/b.ts"); verify.codeFix({ index: 0, description: "Infer parameter types from usage", newFileContent: `import { User, Settings } from './a'; import { getEmail } from './getEmail'; export function f(user: User, settings: Settings) { getEmail(user, settings); }` });
{ "end_byte": 768, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageContextualImport4.ts" }
TypeScript/tests/cases/fourslash/constructorBraceFormatting.ts_0_274
/// <reference path="fourslash.ts"/> ////class X { //// constructor () {}/*target*/ //// /**/ goTo.marker(); edit.insert("}"); goTo.marker("target"); verify.currentLineContentIs(" constructor() { }"); // <-- Remove the space before LParen, and add one before RBrace.
{ "end_byte": 274, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/constructorBraceFormatting.ts" }
TypeScript/tests/cases/fourslash/autoImportAllowTsExtensions4.ts_0_439
/// <reference path="fourslash.ts" /> // @moduleResolution: bundler // @allowImportingTsExtensions: true // @noEmit: true // @Filename: /local.ts //// export const fromLocal: number; // @Filename: /decl.d.ts //// export const fromDecl: number; // @Filename: /Component.tsx //// export function Component() { return null; } // @Filename: /main.ts //// import { Component } from "./local.js"; //// /**/ verify.baselineAutoImports("");
{ "end_byte": 439, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportAllowTsExtensions4.ts" }
TypeScript/tests/cases/fourslash/quickInfoImportedTypes.ts_0_817
/// <reference path="fourslash.ts" /> // @Filename: quickInfoImportedTypes.ts //// /** This is an interface */ //// export interface Foo { //// a?: number; //// } //// /** One or two */ //// export type Bar = 1 | 2 //// /** This is a class */ //// export class Baz<T extends {}> { //// public x: T = {} as T //// } // @Filename: two.ts //// import { Foo, Bar, Baz } from './quickInfoImportedTypes'; //// let x: Foo/*1*/; //// let y: Bar/*2*/<any>; //// let z: Baz/*3*/; verify.quickInfoAt("1", [ "(alias) interface Foo", "import Foo", ].join("\n"), "This is an interface"); verify.quickInfoAt("2", [ "(alias) type Bar = 1 | 2", "import Bar", ].join("\n"), "One or two"); verify.quickInfoAt("3", [ "(alias) class Baz<T extends {}>", "import Baz", ].join("\n"), "This is a class");
{ "end_byte": 817, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoImportedTypes.ts" }
TypeScript/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts_0_5777
/// <reference path="fourslash.ts"/> ////class Class { //// constructor() { //// function LocalFunctionInConstructor() {} //// interface LocalInterfaceInConstrcutor {} //// enum LocalEnumInConstructor { LocalEnumMemberInConstructor } //// } //// //// method() { //// function LocalFunctionInMethod() { //// function LocalFunctionInLocalFunctionInMethod() {} //// } //// interface LocalInterfaceInMethod {} //// enum LocalEnumInMethod { LocalEnumMemberInMethod } //// } //// //// emptyMethod() { } // Non child functions method should not be duplicated ////} verify.navigationTree({ "text": "<global>", "kind": "script", "childItems": [ { "text": "Class", "kind": "class", "childItems": [ { "text": "constructor", "kind": "constructor", "childItems": [ { "text": "LocalEnumInConstructor", "kind": "enum", "childItems": [ { "text": "LocalEnumMemberInConstructor", "kind": "enum member" } ] }, { "text": "LocalFunctionInConstructor", "kind": "function" }, { "text": "LocalInterfaceInConstrcutor", "kind": "interface" } ] }, { "text": "emptyMethod", "kind": "method" }, { "text": "method", "kind": "method", "childItems": [ { "text": "LocalEnumInMethod", "kind": "enum", "childItems": [ { "text": "LocalEnumMemberInMethod", "kind": "enum member" } ] }, { "text": "LocalFunctionInMethod", "kind": "function", "childItems": [ { "text": "LocalFunctionInLocalFunctionInMethod", "kind": "function" } ] }, { "text": "LocalInterfaceInMethod", "kind": "interface" } ] } ] } ] }); verify.navigationBar([ { "text": "<global>", "kind": "script", "childItems": [ { "text": "Class", "kind": "class" } ] }, { "text": "Class", "kind": "class", "childItems": [ { "text": "constructor", "kind": "constructor" }, { "text": "emptyMethod", "kind": "method" }, { "text": "method", "kind": "method" } ], "indent": 1 }, { "text": "constructor", "kind": "constructor", "childItems": [ { "text": "LocalEnumInConstructor", "kind": "enum" }, { "text": "LocalFunctionInConstructor", "kind": "function" }, { "text": "LocalInterfaceInConstrcutor", "kind": "interface" } ], "indent": 2 }, { "text": "LocalEnumInConstructor", "kind": "enum", "childItems": [ { "text": "LocalEnumMemberInConstructor", "kind": "enum member" } ], "indent": 3 }, { "text": "LocalFunctionInConstructor", "kind": "function", "indent": 3 }, { "text": "LocalInterfaceInConstrcutor", "kind": "interface", "indent": 3 }, { "text": "method", "kind": "method", "childItems": [ { "text": "LocalEnumInMethod", "kind": "enum" }, { "text": "LocalFunctionInMethod", "kind": "function" }, { "text": "LocalInterfaceInMethod", "kind": "interface" } ], "indent": 2 }, { "text": "LocalEnumInMethod", "kind": "enum", "childItems": [ { "text": "LocalEnumMemberInMethod", "kind": "enum member" } ], "indent": 3 }, { "text": "LocalFunctionInMethod", "kind": "function", "childItems": [ { "text": "LocalFunctionInLocalFunctionInMethod", "kind": "function" } ], "indent": 3 }, { "text": "LocalInterfaceInMethod", "kind": "interface", "indent": 3 } ]);
{ "end_byte": 5777, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts" }
TypeScript/tests/cases/fourslash/organizeImports22.ts_0_553
/// <reference path="fourslash.ts" /> //// import {abc, Abc, bc, Bc} from 'b'; //// import { //// I, //// R, //// M, //// } from 'a'; //// console.log(abc, Abc, bc, Bc, I, R, M); verify.organizeImports( `import { I, M, R, } from 'a'; import { abc, Abc, bc, Bc } from 'b'; console.log(abc, Abc, bc, Bc, I, R, M);`); // organize already-organized imports to make sure output is stable verify.organizeImports( `import { I, M, R, } from 'a'; import { abc, Abc, bc, Bc } from 'b'; console.log(abc, Abc, bc, Bc, I, R, M);`);
{ "end_byte": 553, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImports22.ts" }
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction12.ts_0_297
/// <reference path='fourslash.ts' /> // @target: es2015 ////async function fn(): PromiseLike<void> {} verify.codeFix({ index: 0, description: [ts.Diagnostics.Replace_0_with_Promise_1.message, "PromiseLike<void>", "void"], newFileContent: `async function fn(): Promise<void> {}` });
{ "end_byte": 297, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction12.ts" }
TypeScript/tests/cases/fourslash/stringCompletionsUnterminated.ts_0_1969
///<reference path="fourslash.ts" /> // @Filename: file0.ts //// const a = { "foo.bar": 1 } //// a["[|foo.b/*0*/|] // @Filename: file1.ts //// const a = { "foo.bar": 1 } //// a["[|foo.b /*1*/|] // @Filename: file2.ts //// const a = { "foo.bar": 1 } //// a[ "[|foo.b/*2*/|] // @Filename: file3.ts //// const a = { "foo.bar": 1 } //// a["[|foo.b/*3*/|]" // @Filename: file4.ts //// const a = { "foo.bar": 1 } //// a["[|foo./*4*/|]b // @Filename: file5.ts //// const a = { "foo.bar": 1 } //// a['[|foo./*5*/|]b // @Filename: file6.ts //// const a = { "foo.bar": 1 } //// a[`[|foo./*6*/|]b // @Filename: file7.ts //// const a = { "foo.bar": 1 } //// a["[|foo./*7*/|] // @Filename: file8.ts //// const a = { "foo.bar": 1 } //// a["[|foo/*8*/|] // @Filename: file9.ts //// const a = { "foo.bar": 1 } //// a["[|foo./*9*/|]" // @Filename: file10.ts //// const a = { "foo.bar": 1 } //// a["[|foo/*10*/|]" // @Filename: file11.ts //// const a = { "foo.bar": 1 } //// a["[|f/*11*/|]oo.b // @Filename: file12.ts //// const a = { "foo.bar": 1 } //// a["[|f/*12*/oo.b|]" // @Filename: file13.ts //// const a = { "foo.bar": 1 } //// a["[|f/*13*/oo.b|]" // some comment!! // @Filename: file14.ts //// const a = { "foo.bar": 1 } //// a["[|f/*14*/|]oo.b // some comment!! // @Filename: file15.ts //// const a = { "foo.bar": 1 } //// a[`[|foo.b/*15*/|] // @Filename: empty1.ts //// const a = { "foo.bar": 1 } //// a[`/*a*/ // @Filename: empty2.ts //// const a = { "foo.bar": 1 } //// a["/*b*/ // @Filename: empty3.ts //// const a = { "foo.bar": 1 } //// a['/*c*/ // tests a,b,c should return no replacementSpan const markers = test.markers(); const ranges = test.ranges(); for (let i = 0; i < markers.length; i++) { verify.completions({ marker: markers[i], includes: [{ "name": "foo.bar", "kind": "property", "kindModifiers": "", "replacementSpan": ranges[i], }], }); }
{ "end_byte": 1969, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/stringCompletionsUnterminated.ts" }
TypeScript/tests/cases/fourslash/fixExactOptionalUnassignableProperties10.ts_0_686
/// <reference path='fourslash.ts'/> // @strictNullChecks: true // @exactOptionalPropertyTypes: true //// interface IF { //// a?: number //// } //// interface J { //// a?: number | undefined //// } //// declare var j: J //// function fi(if_: IF) { return if_ } //// fi(j/**/) verify.codeFixAvailable([ { description: ts.Diagnostics.Add_undefined_to_optional_property_type.message } ]); verify.codeFix({ description: ts.Diagnostics.Add_undefined_to_optional_property_type.message, index: 0, newFileContent: `interface IF { a?: number | undefined } interface J { a?: number | undefined } declare var j: J function fi(if_: IF) { return if_ } fi(j)`, });
{ "end_byte": 686, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixExactOptionalUnassignableProperties10.ts" }
TypeScript/tests/cases/fourslash/completionsGenericUnconstrained.ts_0_292
/// <reference path="fourslash.ts" /> // @strict: true ////function f<T>(x: T) { //// return x; ////} //// ////f({ /**/ }); verify.completions({ marker: "", isNewIdentifierLocation: true, includes: [{ name: "Object", sortText: completion.SortText.GlobalsOrKeywords }] });
{ "end_byte": 292, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsGenericUnconstrained.ts" }
TypeScript/tests/cases/fourslash/tripleSlashRefPathCompletionExtensionsAllowJSTrue.ts_0_593
/// <reference path='fourslash.ts' /> // Should give completions for relative references to ts and js files when allowJs is true. // @allowJs: true // @Filename: test0.ts //// /// <reference path="/*0*/ //// /// <reference path=".//*1*/ //// /// <reference path="./f/*2*/ // @Filename: f1.ts //// // @Filename: f1.js //// // @Filename: f1.d.ts //// // @Filename: f1.tsx //// // @Filename: f1.js //// // @Filename: f1.jsx //// // @Filename: f1.cs //// verify.completions({ marker: test.markers(), exact: ["f1.d.ts", "f1.js", "f1.jsx", "f1.ts", "f1.tsx"], isNewIdentifierLocation: true });
{ "end_byte": 593, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tripleSlashRefPathCompletionExtensionsAllowJSTrue.ts" }
TypeScript/tests/cases/fourslash/extract-method35.ts_0_711
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////export interface A { //// x: number; ////} ////export const a: A = { x: 1 }; // @Filename: /b.ts ////import { a } from "./a"; //// ////class Foo { //// foo() { //// const arg = a; //// /*a*/console.log(arg);/*b*/ //// } ////} goTo.file("/b.ts"); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "function_scope_1", actionDescription: "Extract to method in class 'Foo'", newContent: `import { A, a } from "./a"; class Foo { foo() { const arg = a; this./*RENAME*/newMethod(arg); } private newMethod(arg: A) { console.log(arg); } }` });
{ "end_byte": 711, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method35.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionJsDocImportTag2.ts_0_248
/// <reference path='fourslash.ts'/> // @allowJS: true // @checkJs: true // @Filename: /b.ts /////*2*/export interface A { } // @Filename: /a.js /////** //// * @import { A } [|from/*1*/|] "./b" //// */ verify.baselineGoToDefinition("1");
{ "end_byte": 248, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionJsDocImportTag2.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_uriStyleNodeCoreModules3.ts_0_1658
/// <reference path="fourslash.ts" /> // @module: commonjs // @Filename: /node_modules/@types/node/index.d.ts //// declare module "path" { function join(...segments: readonly string[]): string; } //// declare module "node:path" { export * from "path"; } //// declare module "fs" { function writeFile(): void } //// declare module "fs/promises" { function writeFile(): Promise<void> } //// declare module "node:fs" { export * from "fs"; } //// declare module "node:fs/promises" { export * from "fs/promises"; } // @Filename: /other.ts //// import "node:fs/promises"; // @Filename: /noPrefix.ts //// import "path"; //// writeFile/*noPrefix*/ // @Filename: /prefix.ts //// import "node:path"; //// writeFile/*prefix*/ // @Filename: /mixed1.ts //// import "path"; //// import "node:path"; //// writeFile/*mixed1*/ // @Filename: /mixed2.ts //// import "node:path"; //// import "path"; //// writeFile/*mixed2*/ // @Filename: /test1.ts //// import "node:test"; //// import "path"; //// writeFile/*test1*/ // @Filename: /test2.ts //// import "node:test"; //// writeFile/*test2*/ verify.importFixModuleSpecifiers("noPrefix", ["fs", "fs/promises"]); verify.importFixModuleSpecifiers("prefix", ["node:fs", "node:fs/promises"]); // Prefixed imports take precedence over non-prefixed imports when mixed verify.importFixModuleSpecifiers("mixed1", ["node:fs", "node:fs/promises"]); verify.importFixModuleSpecifiers("mixed2", ["node:fs", "node:fs/promises"]); // Unless the prefixed import is not available unprefixed verify.importFixModuleSpecifiers("test1", ["fs", "fs/promises"]); verify.importFixModuleSpecifiers("test2", ["node:fs", "node:fs/promises"]);
{ "end_byte": 1658, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_uriStyleNodeCoreModules3.ts" }
TypeScript/tests/cases/fourslash/signatureHelpConstructorCallParamProperties.ts_0_291
/// <reference path='fourslash.ts' /> ////class Circle { //// /** //// * Initialize a circle. //// * @param radius The radius of the circle. //// */ //// constructor(private radius: number) { //// } ////} ////var a = new Circle(/**/ verify.baselineSignatureHelp()
{ "end_byte": 291, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpConstructorCallParamProperties.ts" }
TypeScript/tests/cases/fourslash/spaceBeforeAndAfterBinaryOperators.ts_0_685
/// <reference path="fourslash.ts"/> ////let i = 0; /////*1*/(i++,i++); /////*2*/(i++,++i); /////*3*/(1,2); /////*4*/(i++,2); /////*5*/(i++,i++,++i,i--,2); ////let s = 'foo'; /////*6*/for (var i = 0,ii = 2; i < s.length; ii++,i++) { ////} format.document(); goTo.marker("1"); verify.currentLineContentIs(`(i++, i++);`); goTo.marker("2"); verify.currentLineContentIs(`(i++, ++i);`); goTo.marker("3"); verify.currentLineContentIs(`(1, 2);`); goTo.marker("4"); verify.currentLineContentIs(`(i++, 2);`); goTo.marker("5"); verify.currentLineContentIs(`(i++, i++, ++i, i--, 2);`); goTo.marker("6"); verify.currentLineContentIs(`for (var i = 0, ii = 2; i < s.length; ii++, i++) {`);
{ "end_byte": 685, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/spaceBeforeAndAfterBinaryOperators.ts" }
TypeScript/tests/cases/fourslash/exportClauseErrorReporting0.ts_0_248
/// <reference path="fourslash.ts" /> //// module M { //// /*1*/class C<T> { } //// } //// //// var x = new M.C<string>(); //// edit.disableFormatting(); goTo.marker("1"); edit.insert("export "); goTo.marker("1"); edit.deleteAtCaret(8);
{ "end_byte": 248, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/exportClauseErrorReporting0.ts" }
TypeScript/tests/cases/fourslash/refactorOverloadListToSingleSignature1.ts_0_614
/// <reference path='fourslash.ts' /> /////*a*/declare function foo(): void; ////declare function foo(a: string): void; ////declare function foo(a: number, b: number): void; ////declare function foo(...rest: symbol[]): void;/*b*/ goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert overload list to single signature", actionName: "Convert overload list to single signature", actionDescription: ts.Diagnostics.Convert_overload_list_to_single_signature.message, newContent: `declare function foo(...args: [] | [a: string] | [a: number, b: number] | [...rest: symbol[]]): void;`, });
{ "end_byte": 614, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorOverloadListToSingleSignature1.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports43-expando-functions.ts_0_434
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true // @lib: es2019 // @Filename: /code.ts ////const foo = (): void => {} ////foo.a = "A"; ////foo.b = "C" verify.codeFix({ description: "Add annotation of type '{ (): void; a: string; b: string; }'", index: 0, newFileContent: `const foo: { (): void; a: string; b: string; } = (): void => {} foo.a = "A"; foo.b = "C"` });
{ "end_byte": 434, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports43-expando-functions.ts" }
TypeScript/tests/cases/fourslash/referencesForLabel5.ts_0_464
/// <reference path='fourslash.ts'/> // References to shadowed label /////*1*/label: while (true) { //// if (false) /*2*/break /*3*/label; //// function blah() { /////*4*/label: while (true) { //// if (false) /*5*/break /*6*/label; //// } //// } //// if (false) /*7*/break /*8*/label; //// } verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6', '7', '8');
{ "end_byte": 464, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForLabel5.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportNodeModules6.ts_0_577
/// <reference path="fourslash.ts" /> //// [|f1/*0*/('');|] // @Filename: package.json //// { "dependencies": { "package-name": "latest" } } // @Filename: node_modules/package-name/bin/lib/index.d.ts //// export function f1(text: string): string; // @Filename: node_modules/package-name/bin/lib/index.js //// function f1(text) { } //// exports.f1 = f1; // @Filename: node_modules/package-name/package.json //// { //// "main": "bin/lib/index.js", //// "types": "bin/lib/index.d.ts" //// } verify.importFixAtPosition([ `import { f1 } from "package-name"; f1('');` ]);
{ "end_byte": 577, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportNodeModules6.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesConstructor2.ts_0_466
/// <reference path='fourslash.ts' /> ////class C { //// constructor(); //// constructor(x: number); //// constructor(y: string, x: number); //// constructor(a?: any, ...r: any[]) { //// if (a === undefined && r.length === 0) { //// return; //// } //// //// return; //// } ////} //// ////class D { //// [|con/**/structor|](public x: number, public y: number) { //// } ////} verify.baselineDocumentHighlights();
{ "end_byte": 466, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesConstructor2.ts" }
TypeScript/tests/cases/fourslash/completionsPropertiesWithPromiseUnionType.ts_0_352
/// <reference path="fourslash.ts" /> // @strict: true //// type MyType = { //// foo: string; //// }; //// function fakeTest(cb: () => MyType | Promise<MyType>) {} //// fakeTest(() => { //// return { //// /*a*/ //// }; //// }); verify.completions( { marker: ['a'], exact: [ { name: 'foo', kind: 'property' }, ] } );
{ "end_byte": 352, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsPropertiesWithPromiseUnionType.ts" }
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class3.ts_0_999
/// <reference path='fourslash.ts' /> // @allowNonTsExtensions: true // @Filename: test123.js ////var bar = 10, foo = function() { }; ////foo.prototype.instanceMethod1 = function() { return "this is name"; }; ////foo.prototype.instanceMethod2 = () => { return "this is name"; }; ////foo.prototype.instanceProp1 = "hello"; ////foo.prototype.instanceProp2 = undefined; ////foo.staticProp = "world"; ////foo.staticMethod1 = function() { return "this is static name"; }; ////foo.staticMethod2 = () => "this is static name"; verify.codeFix({ description: "Convert function to an ES2015 class", newFileContent: `var bar = 10; class foo { constructor() { } static staticMethod1() { return "this is static name"; } static staticMethod2() { return "this is static name"; } instanceMethod1() { return "this is name"; } instanceMethod2() { return "this is name"; } } foo.prototype.instanceProp1 = "hello"; foo.prototype.instanceProp2 = undefined; foo.staticProp = "world"; `, });
{ "end_byte": 999, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class3.ts" }
TypeScript/tests/cases/fourslash/signatureHelpFilteredTriggers02.ts_0_752
/// <reference path="fourslash.ts" /> ////function foo<T>(x: T): T { //// throw null; ////} //// ////foo(/*1*/""); ////foo(` ${100/*2*/}`); ////foo(/*3*/); ////foo(100 /*4*/) ////foo([/*5*/]) ////foo({ hello: "hello"/*6*/}) const charMap = { 1: "(", 2: ",", 3: "(", 4: "<", 5: ",", 6: ",", } for (const markerName of Object.keys(charMap)) { const triggerCharacter = charMap[markerName]; goTo.marker(markerName); edit.insert(triggerCharacter); verify.noSignatureHelpForTriggerReason({ kind: "characterTyped", triggerCharacter, }); verify.signatureHelpPresentForTriggerReason({ kind: "retrigger", triggerCharacter, }); edit.backspace(triggerCharacter.length); }
{ "end_byte": 752, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpFilteredTriggers02.ts" }
TypeScript/tests/cases/fourslash/completionListInstanceProtectedMembers2.ts_0_1905
/// <reference path='fourslash.ts'/> ////class Base { //// private privateMethod() { } //// private privateProperty; //// //// protected protectedMethod() { } //// protected protectedProperty; //// //// public publicMethod() { } //// public publicProperty; //// //// protected protectedOverriddenMethod() { } //// protected protectedOverriddenProperty; ////} //// ////class C1 extends Base { //// protected protectedOverriddenMethod() { } //// protected protectedOverriddenProperty; //// //// test() { //// this./*1*/; //// super./*2*/; //// //// var b: Base; //// var c: C1; //// //// b./*3*/; //// c./*4*/; //// } ////} verify.completions( { // Same class, everything is visible marker: "1", includes: ["protectedMethod", "protectedProperty", "publicMethod", "publicProperty", "protectedOverriddenMethod", "protectedOverriddenProperty"], excludes: ["privateMethod", "privateProperty"], }, { // Can not access properties on super marker: "2", includes: ["protectedMethod", "publicMethod", "protectedOverriddenMethod"], excludes: ["privateMethod", "privateProperty", "protectedProperty", "publicProperty", "protectedOverriddenProperty"], }, { // Can not access protected properties through base class marker: "3", includes: ["publicMethod", "publicProperty"], excludes: ["privateMethod", "privateProperty", "protectedMethod", "protectedProperty", "protectedOverriddenMethod", "protectedOverriddenProperty"], }, { // Same class, everything is visible marker: "4", includes: ["protectedMethod", "protectedProperty", "publicMethod", "publicProperty", "protectedOverriddenMethod", "protectedOverriddenProperty"], excludes: ["privateMethod", "privateProperty"], }, );
{ "end_byte": 1905, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInstanceProtectedMembers2.ts" }
TypeScript/tests/cases/fourslash/goToDefinition_super.ts_0_598
///<reference path="fourslash.ts"/> ////class A { //// /*ctr*/constructor() {} //// x() {} ////} ////class /*B*/B extends A {} ////class C extends B { //// constructor() { //// [|/*super*/super|](); //// } //// method() { //// [|/*superExpression*/super|].x(); //// } ////} ////class D { //// constructor() { //// /*superBroken*/super(); //// } ////} verify.baselineGoToDefinition( // Super in call position goes to constructor. "super", // Super in any other position goes to the superclass. "superExpression", "superBroken", );
{ "end_byte": 598, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinition_super.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_importSpecifier2.ts_0_356
/// <reference path="fourslash.ts" /> // @noUnusedLocals: true ////[|import { //// a, b, c, d, //// //// //// //// //// e, f, ////} from "fs";|] //// ////a; ////b; ////c; ////e; ////f; verify.codeFix({ index: 0, description: "Remove unused declaration for: 'd'", newRangeContent: `import { a, b, c, e, f, } from "fs";` });
{ "end_byte": 356, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_importSpecifier2.ts" }
TypeScript/tests/cases/fourslash/addMemberToModule.ts_0_264
/// <reference path="fourslash.ts" /> ////module A { //// /*var*/ ////} ////module /*check*/A { //// var p; ////} goTo.marker('check'); verify.quickInfoExists(); goTo.marker('var'); edit.insert('var o;'); goTo.marker('check'); verify.quickInfoExists();
{ "end_byte": 264, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/addMemberToModule.ts" }