_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_suggestion.ts_0_882
/// <reference path='fourslash.ts' /> ////function f([|p|]) { //// const [|x|] = 0; ////} const [r0, r1] = test.ranges(); verify.getSuggestionDiagnostics([ { message: "Parameter 'p' implicitly has an 'any' type, but a better type may be inferred from usage.", range: r0, code: 7044, }, { message: "'p' is declared but its value is never read.", range: r0, code: 6133, reportsUnnecessary: true, }, { message: "'x' is declared but its value is never read.", range: r1, code: 6133, reportsUnnecessary: true, } ]); verify.codeFixAvailable( [ "Infer parameter types from usage", "Remove unused declaration for: 'p'", "Prefix 'p' with an underscore", "Remove unused declaration for: 'x'" ].map(description => ({ description })));
{ "end_byte": 882, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_suggestion.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_namedExport1.ts_0_288
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////const a = 1; ////[|const b = a + 1;|] ////export { a }; verify.moveToNewFile({ newFileContents: { "/a.ts": `const a = 1; export { a };`, "/b.ts": `import { a } from "./a"; const b = a + 1; `, } });
{ "end_byte": 288, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_namedExport1.ts" }
TypeScript/tests/cases/fourslash/unusedImports2FS.ts_0_464
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @Filename: file2.ts //// [|import {test} from "./file1" //// import {Calculator} from "./file1"|] //// var x = new Calculator(); //// x.handleChar(); // @Filename: file1.ts //// export class Calculator { //// handleChar() {} //// } //// export function test() { //// //// } verify.rangeAfterCodeFix(`import {Calculator} from "./file1"`, /*includeWhiteSpace*/ true, /*errorCode*/ undefined);
{ "end_byte": 464, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedImports2FS.ts" }
TypeScript/tests/cases/fourslash/extract-unterminated2.ts_0_379
/// <reference path="fourslash.ts" /> // Unterminated string literal: //// /*1*/const foo = "foo/*2*/ goTo.select("1", "2"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "function_scope_0", actionDescription: "Extract to function in global scope", newContent: `const foo = /*RENAME*/newFunction() function newFunction() { return "foo"; } ` });
{ "end_byte": 379, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-unterminated2.ts" }
TypeScript/tests/cases/fourslash/chainedFatArrowFormatting.ts_0_220
/// <reference path='fourslash.ts' /> //// var fn = () => () => null/**/ goTo.marker(); edit.insert(';'); // spacing around arrow in chained fat arrow syntax verify.currentLineContentIs('var fn = () => () => null;');
{ "end_byte": 220, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/chainedFatArrowFormatting.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType_js7.ts_0_420
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: a.js ////function a(/** @type {/*a*/string/*b*/} */ b) {} goTo.file('a.js') goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to typedef", actionDescription: "Extract to typedef", newContent: `/** * @typedef {string} /*RENAME*/NewType */ function a(/** @type {NewType} */ b) {}`, });
{ "end_byte": 420, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType_js7.ts" }
TypeScript/tests/cases/fourslash/completionListAfterFunction2.ts_0_341
/// <reference path='fourslash.ts' /> ////// Outside the function expression ////declare var f1: (a: number) => void; /*1*/ //// ////declare var f1: (b: number, b2: /*2*/) => void; verify.completions( { marker: "1", excludes: "a" }, { marker: "2", excludes: "b" }, ); edit.insert("typeof "); verify.completions({ includes: "b" });
{ "end_byte": 341, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAfterFunction2.ts" }
TypeScript/tests/cases/fourslash/removeVarFromModuleWithReopenedEnums.ts_0_217
/// <reference path="fourslash.ts" /> //// module A { //// /**/var o; //// } //// enum A { //// } //// enum A { //// } //// module A { //// var p; //// } goTo.marker(); edit.deleteAtCaret('var o;'.length);
{ "end_byte": 217, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/removeVarFromModuleWithReopenedEnums.ts" }
TypeScript/tests/cases/fourslash/completionsInterfaceElement.ts_0_449
/// <reference path="fourslash.ts" /> ////const foo = 0; ////interface I { //// m(): void; //// fo/*i*/ ////} ////interface J { /*j*/ } ////interface K { f; /*k*/ } ////type T = { fo/*t*/ }; ////type U = { /*u*/ }; ////interface EndOfFile { f; /*e*/ verify.completions({ marker: test.markers(), exact: { name: "readonly", sortText: completion.SortText.GlobalsOrKeywords }, isNewIdentifierLocation: true });
{ "end_byte": 449, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsInterfaceElement.ts" }
TypeScript/tests/cases/fourslash/restArgSignatureHelp.ts_0_161
/// <reference path='fourslash.ts' /> ////function f(...x: any[]) { } ////f(/**/); verify.signatureHelp({ marker: "", parameterName: "x", isVariadic: true });
{ "end_byte": 161, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/restArgSignatureHelp.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused.ts_0_271
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @noUnusedParameters: true ////export {}; ////const { x, y } = o; verify.codeFix({ description: ts.Diagnostics.Remove_unused_destructuring_declaration.message, newFileContent: `export {}; `, });
{ "end_byte": 271, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01.ts_0_244
/// <reference path='fourslash.ts' /> ////namespace Foo { //// export var x; ////} //// ////class Foo { //// /*definition*/constructor() { //// } ////} //// ////var x = new [|/*usage*/Foo|](); verify.baselineGoToDefinition("usage");
{ "end_byte": 244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01.ts" }
TypeScript/tests/cases/fourslash/codefixClassImplementInterface_omit.ts_0_483
/// <reference path="fourslash.ts" /> ////interface One { //// a: number; //// b: string; ////} //// ////interface Two extends Omit<One, "a"> { //// c: boolean; ////} //// ////class TwoStore implements Two {[| |]} verify.codeFix({ description: "Implement interface 'Two'", newFileContent: `interface One { a: number; b: string; } interface Two extends Omit<One, "a"> { c: boolean; } class TwoStore implements Two { c: boolean; b: string; }`, });
{ "end_byte": 483, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codefixClassImplementInterface_omit.ts" }
TypeScript/tests/cases/fourslash/commentsMultiModuleSingleFileFourslash.ts_0_671
/// <reference path='fourslash.ts' /> /////** this is multi declare namespace*/ ////namespace mult/*3*/iM { //// /** class b*/ //// export class b { //// } ////} /////** thi is multi namespace 2*/ ////namespace mu/*2*/ltiM { //// /** class c comment*/ //// export class c { //// } ////} //// ////new /*1*/mu/*4*/ltiM.b(); ////new mu/*5*/ltiM.c(); const comment = "this is multi declare namespace\nthi is multi namespace 2"; verify.completions({ marker: "1", includes: { name: "multiM", text: "namespace multiM", documentation: comment } }); for (const marker of ["2", "3", "4", "5"]) { verify.quickInfoAt(marker, "namespace multiM", comment); }
{ "end_byte": 671, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/commentsMultiModuleSingleFileFourslash.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts_0_1197
/// <reference path='fourslash.ts' /> // Should give completions for directories that are merged via the rootDirs compiler option // @rootDirs: /sub/src1,/src2 // @Filename: /src2/test0.ts //// import * as foo1 from "./mo/*import_as0*/ //// import foo2 = require("./mo/*import_equals0*/ //// var foo3 = require("./mo/*require0*/ // @Filename: /src2/inner/inner0.ts ////import * as s from ".//*inner*/"; // @Filename: /src2/inner/inner1.ts ////export const x = 0; // @Filename: /src2/module0.ts //// export var w = 0; // @Filename: /sub/src1/module1.ts //// export var x = 0; // @Filename: /sub/src1/module2.ts //// export var y = 0; // @Filename: /sub/src1/more/module3.ts //// export var z = 0; // @Filename: f1.ts //// // @Filename: f2.tsx //// // @Filename: folder/f1.ts //// // @Filename: f3.js //// // @Filename: f4.jsx //// // @Filename: e1.ts //// // @Filename: e2.js //// verify.completions( { marker: ["import_as0", "import_equals0", "require0"], exact: ["module1", "module2", "more", "module0", "inner"], isNewIdentifierLocation: true, }, { marker: "inner", exact: "inner1", isNewIdentifierLocation: true, } );
{ "end_byte": 1197, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingMember_all.ts_0_1198
/// <reference path='fourslash.ts' /> ////class C { //// method() { //// this.x = 0; //// this.y(); //// this.x = ""; //// } ////} //// ////class D extends C {} ////class E extends D { //// method() { //// this.x = 0; //// this.ex = 0; //// } ////} //// ////class Unrelated { //// method() { //// this.x = 0; //// } ////} //// ////enum En {} ////En.A; //// ////type T = {}; ////function foo(t: T) { //// t.x; //// t.y = 1; //// t.test(1, 2); ////} verify.codeFixAll({ fixId: "fixMissingMember", fixAllDescription: "Add all missing members", newFileContent: `class C { x: number; method() { this.x = 0; this.y(); this.x = ""; } y() { throw new Error("Method not implemented."); } } class D extends C {} class E extends D { ex: number; method() { this.x = 0; this.ex = 0; } } class Unrelated { x: number; method() { this.x = 0; } } enum En { A } En.A; type T = { x: any; y: number; test(arg0: number, arg1: number): unknown; }; function foo(t: T) { t.x; t.y = 1; t.test(1, 2); }`, });
{ "end_byte": 1198, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember_all.ts" }
TypeScript/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName02.ts_0_232
/// <reference path='fourslash.ts'/> ////interface I { //// property1: number; //// property2: string; ////} //// ////var foo: I; ////var { /**/property1: {} } = foo; verify.quickInfoAt("", "(property) I.property1: number");
{ "end_byte": 232, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName02.ts" }
TypeScript/tests/cases/fourslash/completionListInvalidMemberNames_startWithSpace.ts_0_430
/// <reference path='fourslash.ts' /> ////declare const x: { " foo": 0, "foo ": 1 }; ////x[|./**/|]; const replacementSpan = test.ranges()[0]; // No completion for " foo" because it starts with a space. See https://github.com/Microsoft/TypeScript/pull/20547 verify.completions({ marker: "", exact: [{ name: "foo ", insertText: '["foo "]', replacementSpan }], preferences: { includeInsertTextCompletions: true }, });
{ "end_byte": 430, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInvalidMemberNames_startWithSpace.ts" }
TypeScript/tests/cases/fourslash/quickInfoInWithBlock.ts_0_184
/// <reference path='fourslash.ts'/> ////with (x) { //// function /*1*/f() { } //// var /*2*/b = /*3*/f; ////} verify.quickInfos({ 1: "any", 2: "any", 3: "any" });
{ "end_byte": 184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoInWithBlock.ts" }
TypeScript/tests/cases/fourslash/codeFixImportNonExportedMember_all6.ts_0_688
/// <reference path="fourslash.ts" /> // @module: esnext // @isolatedModules: true // @filename: /a.ts ////type T1 = {}; ////const a = 1; ////const b = 1; ////export { a }; // @filename: /b.ts ////type T2 = {}; ////type T3 = {}; ////export type { T2 }; // @filename: /c.ts ////import { b, T1 } from "./a"; ////import { T3 } from "./b"; goTo.file("/c.ts"); verify.codeFixAll({ fixId: "fixImportNonExportedMember", fixAllDescription: ts.Diagnostics.Export_all_referenced_locals.message, newFileContent: { "/a.ts": `type T1 = {}; const a = 1; const b = 1; export { a, b, type T1 };`, "/b.ts": `type T2 = {}; type T3 = {}; export type { T2, T3 };`, }, });
{ "end_byte": 688, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImportNonExportedMember_all6.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesThrow.ts_0_942
/// <reference path='fourslash.ts' /> ////function f(a: number) { //// try { //// throw "Hello"; //// //// try { //// throw 10; //// } //// catch (x) { //// [|return|] 100; //// } //// finally { //// throw 10; //// } //// } //// catch (x) { //// [|throw|] "Something"; //// } //// finally { //// [|throw|] "Also something"; //// } //// if (a > 0) { //// [|return|] (function () { //// return; //// return; //// return; //// //// if (false) { //// return true; //// } //// throw "Hello!"; //// })() || true; //// } //// //// [|th/**/row|] 10; //// //// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) //// //// [|return|]; //// [|return|] true; //// [|throw|] false; ////} verify.baselineDocumentHighlights();
{ "end_byte": 942, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesThrow.ts" }
TypeScript/tests/cases/fourslash/unusedTypeParametersWithTrivia1.ts_0_294
/// <reference path="fourslash.ts" /> // @noUnusedParameters: true ////export type Foo< //// T1 extends any, //// T2 extends any ////> = () => void; verify.codeFix({ description: ts.Diagnostics.Remove_type_parameters.message, newFileContent: "export type Foo = () => void;" });
{ "end_byte": 294, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedTypeParametersWithTrivia1.ts" }
TypeScript/tests/cases/fourslash/formatTsxClosingAfterJsxText.ts_0_408
/// <reference path="fourslash.ts"/> // @Filename: foo.tsx //// ////const a = ( //// <div> //// text //// </div> ////) ////const b = ( //// <div> //// text //// twice //// </div> ////) //// format.document(); verify.currentFileContentIs(` const a = ( <div> text </div> ) const b = ( <div> text twice </div> ) `);
{ "end_byte": 408, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatTsxClosingAfterJsxText.ts" }
TypeScript/tests/cases/fourslash/callHierarchyContainerName.ts_0_613
/// <reference path="fourslash.ts" /> ////function /**/f() {} //// ////class A { //// static sameName() { //// f(); //// } ////} //// ////class B { //// sameName() { //// A.sameName(); //// } ////} //// ////const Obj = { //// get sameName() { //// return new B().sameName; //// } ////}; //// ////namespace Foo { //// function sameName() { //// return Obj.sameName; //// } //// //// export class C { //// constructor() { //// sameName(); //// } //// } ////} //// ////module Foo.Bar { //// const sameName = () => new Foo.C(); ////} goTo.marker(); verify.baselineCallHierarchy();
{ "end_byte": 613, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyContainerName.ts" }
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc9.ts_0_303
/// <reference path='fourslash.ts' /> /////** //// * @param {?} x //// * @returns {number} //// */ ////var f = x => x verify.codeFix({ index: 0, description: "Annotate with type from JSDoc", newFileContent: `/** * @param {?} x * @returns {number} */ var f = (x: any): number => x`, });
{ "end_byte": 303, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc9.ts" }
TypeScript/tests/cases/fourslash/findAllRefsOnDefinition.ts_0_535
/// <reference path="fourslash.ts" /> //@Filename: findAllRefsOnDefinition-import.ts ////export class Test{ //// //// constructor(){ //// //// } //// //// /*1*/public /*2*/start(){ //// return this; //// } //// //// public stop(){ //// return this; //// } ////} //@Filename: findAllRefsOnDefinition.ts ////import Second = require("./findAllRefsOnDefinition-import"); //// ////var second = new Second.Test() ////second./*3*/start(); ////second.stop(); verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 535, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsOnDefinition.ts" }
TypeScript/tests/cases/fourslash/renameDestructuringAssignment.ts_0_244
/// <reference path='fourslash.ts' /> ////interface I { //// [|[|{| "contextRangeIndex": 0 |}x|]: number;|] ////} ////var a: I; ////var x; ////([|{ [|{| "contextRangeIndex": 2 |}x|]: x } = a|]); verify.baselineRenameAtRangesWithText("x");
{ "end_byte": 244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameDestructuringAssignment.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingMember23.ts_0_271
/// <reference path='fourslash.ts' /> ////[|type Foo = {};|] ////function f(foo: Foo) { //// foo.y = 1; ////} verify.codeFix({ description: [ts.Diagnostics.Declare_property_0.message, "y"], index: 0, newRangeContent: `type Foo = { y: number; };` });
{ "end_byte": 271, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember23.ts" }
TypeScript/tests/cases/fourslash/hoverOverPrivateName.ts_0_814
/// <reference path="fourslash.ts" /> //// class A { //// #f/*1*/oo = 3; //// #b/*2*/ar: number; //// #b/*3*/az = () => "hello"; //// #q/*4*/ux(n: number): string { //// return "" + n; //// } //// static #staticF/*5*/oo = 3; //// static #staticB/*6*/ar: number; //// static #staticB/*7*/az = () => "hello"; //// static #staticQ/*8*/ux(n: number): string { //// return "" + n; //// } //// } verify.quickInfos({ 1: "(property) A.#foo: number", 2: "(property) A.#bar: number", 3: "(property) A.#baz: () => string", 4: "(method) A.#qux(n: number): string", 5: "(property) A.#staticFoo: number", 6: "(property) A.#staticBar: number", 7: "(property) A.#staticBaz: () => string", 8: "(method) A.#staticQux(n: number): string", });
{ "end_byte": 814, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/hoverOverPrivateName.ts" }
TypeScript/tests/cases/fourslash/quickInfoJSDocFunctionThis.ts_1_264
///<reference path="fourslash.ts" /> // @allowJs: true // @Filename: Foo.js /////** @type {function (this: string, string): string} */ ////var f/**/ = function (s) { return s; } goTo.marker(); verify.quickInfoIs('var f: (this: string, arg1: string) => string');
{ "end_byte": 264, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJSDocFunctionThis.ts" }
TypeScript/tests/cases/fourslash/referencesForAmbients2.ts_0_454
/// <reference path='fourslash.ts'/> // @Filename: /defA.ts ////declare module "a" { //// /*1*/export type /*2*/T = number; ////} // @Filename: /defB.ts ////declare module "b" { //// export import a = require("a"); //// export const x: a./*3*/T; ////} // @Filename: /defC.ts ////declare module "c" { //// import b = require("b"); //// const x: b.a./*4*/T; ////} verify.noErrors(); verify.baselineFindAllReferences('1', '2', '3', '4');
{ "end_byte": 454, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForAmbients2.ts" }
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction14.ts_0_366
/// <reference path='fourslash.ts' /> //// const foo = /*a*/a/*b*/ => { return undefined; }; goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Add or remove braces in an arrow function", actionName: "Remove braces from arrow function", actionDescription: "Remove braces from arrow function", newContent: `const foo = a => undefined;`, });
{ "end_byte": 366, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction14.ts" }
TypeScript/tests/cases/fourslash/completionListInUnclosedElementAccessExpression01.ts_0_123
/// <reference path='fourslash.ts' /> ////var x; ////var y = x[/*1*/ verify.completions({ marker: "1", includes: "x" });
{ "end_byte": 123, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedElementAccessExpression01.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration8.ts_0_504
/// <reference path='fourslash.ts' /> ////namespace Foo { //// export const x = 0; ////} //// ////Foo.test(1, "", { x: 1, y: 1 }); verify.codeFix({ index: 0, description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "test"], newFileContent: `namespace Foo { export const x = 0; export function test(arg0: number, arg1: string, arg2: { x: number; y: number; }) { throw new Error("Function not implemented."); } } Foo.test(1, "", { x: 1, y: 1 });` });
{ "end_byte": 504, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration8.ts" }
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class-propertyMember.ts_0_556
// @allowNonTsExtensions: true // @Filename: test123.js /// <reference path="./fourslash.ts" /> //// // Comment //// function /*1*/fn() { //// this.baz = 10; //// } //// fn.prototype = { //// /** JSDoc */ //// bar: function () { //// console.log('hello world'); //// } //// } verify.codeFix({ description: "Convert function to an ES2015 class", newFileContent: `// Comment class fn { constructor() { this.baz = 10; } /** JSDoc */ bar() { console.log('hello world'); } } `, });
{ "end_byte": 556, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class-propertyMember.ts" }
TypeScript/tests/cases/fourslash/textChangesPreserveNewlines7.ts_0_1030
/// <reference path="fourslash.ts" /> // @Filename: /index.tsx ////[|function Foo({ label }: { label: string }) { //// return ( //// <div //// id="time-label-top-container"> //// <div //// id="time-label-container" //// style={{ //// marginRight: '10px', //// border: 'none', //// }} //// > //// <div className="currentTimeLabel">{label}</div> //// </div> //// </div> //// ); ////}|] verify.moveToNewFile({ newFileContents: { "/index.tsx": "", "/Foo.tsx": `function Foo({ label }: { label: string; }) { return ( <div id="time-label-top-container"> <div id="time-label-container" style={{ marginRight: '10px', border: 'none', }} > <div className="currentTimeLabel">{label}</div> </div> </div> ); } ` } });
{ "end_byte": 1030, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/textChangesPreserveNewlines7.ts" }
TypeScript/tests/cases/fourslash/formatSelectionWithTrivia6.ts_0_250
/// <reference path="fourslash.ts" /> // Tests comment indentation with range ending before next token (end of file) /////*begin*/ // test comment /////*end*/ format.selection('begin', 'end'); verify.currentFileContentIs("// test comment\n");
{ "end_byte": 250, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatSelectionWithTrivia6.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionReturn1.ts_0_146
/// <reference path="fourslash.ts" /> ////function /*end*/foo() { //// [|/*start*/return|] 10; ////} verify.baselineGoToDefinition("start");
{ "end_byte": 146, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionReturn1.ts" }
TypeScript/tests/cases/fourslash/completionsImport_notFromIndex.ts_0_994
/// <reference path="fourslash.ts" /> // @Filename: /src/a.ts ////export const x = 0; // @Filename: /src/index.ts ////export { x } from "./a"; // @Filename: /0.ts ////x/*0*/ // @Filename: /src/1.ts ////x/*1*/ // @Filename: /src/inner/2.ts ////x/*2*/ for (const [marker, sourceDisplay] of [["0", "./src"], ["1", "./a"], ["2", "../a"]]) { verify.completions({ marker, includes: { name: "x", source: "/src/a", sourceDisplay, text: "const x: 0", kind: "const", kindModifiers: "export", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, preferences: { includeCompletionsForModuleExports: true }, }); verify.applyCodeActionFromCompletion(marker, { name: "x", source: "/src/a", description: `Add import from "${sourceDisplay}"`, newFileContent: `import { x } from "${sourceDisplay}";\n\nx`, }); }
{ "end_byte": 994, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_notFromIndex.ts" }
TypeScript/tests/cases/fourslash/codeFixInvalidJsxCharacters4.ts_0_483
/// <reference path='fourslash.ts' /> // @jsx: react // @filename: main.tsx //// let foo = <div>{"foo"}></div>; verify.codeFix({ description: ts.Diagnostics.Wrap_invalid_character_in_an_expression_container.message, newFileContent: `let foo = <div>{"foo"}{">"}</div>;`, index: 0, }); verify.codeFix({ description: ts.Diagnostics.Convert_invalid_character_to_its_html_entity_code.message, newFileContent: `let foo = <div>{"foo"}&gt;</div>;`, index: 1, });
{ "end_byte": 483, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInvalidJsxCharacters4.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionSignatureAlias_require.ts_0_314
/// <reference path='fourslash.ts'/> // @allowJs: true // @Filename: /a.js ////module.exports = function /*f*/f() {} // @Filename: /b.js ////const f = require("./a"); ////[|/*use*/f|](); // @Filename: /bar.ts ////import f = require("./a"); ////[|/*useTs*/f|](); verify.baselineGoToDefinition("use", "useTs");
{ "end_byte": 314, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionSignatureAlias_require.ts" }
TypeScript/tests/cases/fourslash/incrementalParsingDynamicImport3.ts_0_280
/// <reference path="fourslash.ts"/> // @lib: es2015 // @Filename: ./foo.ts //// export function bar() { return 1; } // @Filename: ./0.ts //// var x = import/*1*/ verify.numberOfErrorsInCurrentFile(0); goTo.marker("1"); edit.insert("("); verify.numberOfErrorsInCurrentFile(1);
{ "end_byte": 280, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incrementalParsingDynamicImport3.ts" }
TypeScript/tests/cases/fourslash/renameReExportDefault.ts_0_647
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////export { default } from "./b"; ////[|export { default as [|{| "contextRangeIndex": 0 |}b|] } from "./b";|] ////export { default as bee } from "./b"; ////[|import { default as [|{| "contextRangeIndex": 2 |}b|] } from "./b";|] ////import { default as bee } from "./b"; ////[|import [|{| "contextRangeIndex": 4 |}b|] from "./b";|] // @Filename: /b.ts ////[|const [|{| "contextRangeIndex": 6 |}b|] = 0;|] ////[|export default [|{| "contextRangeIndex": 8 |}b|];|] const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3, r4Def, r4] = test.ranges(); verify.baselineRename([r0, r1, r2, r3, r4]);
{ "end_byte": 647, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameReExportDefault.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesOfAnonymousFunction.ts_0_161
/// <reference path='fourslash.ts' /> ////(function [|foo|](): number { //// var x = [|foo|]; //// return 0; ////}) verify.baselineDocumentHighlights();
{ "end_byte": 161, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesOfAnonymousFunction.ts" }
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization2.ts_0_262
/// <reference path='fourslash.ts' /> // @strict: true //// class T { //// a: string; //// } verify.codeFix({ description: `Add definite assignment assertion to property 'a: string;'`, newFileContent: `class T { a!: string; }`, index: 1 })
{ "end_byte": 262, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization2.ts" }
TypeScript/tests/cases/fourslash/quickInfoLink11.ts_0_282
///<reference path="fourslash.ts" /> /////** //// * {@link https://vscode.dev} //// * [link text]{https://vscode.dev} //// * {@link https://vscode.dev|link text} //// * {@link https://vscode.dev link text} //// */ ////function f() {} //// /////**/f(); verify.baselineQuickInfo();
{ "end_byte": 282, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoLink11.ts" }
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToNamed_MultiDecl_Modifier_Comment.ts_0_445
/// <reference path='fourslash.ts' /> //// // Do not add me second time //// export let foo, bar = /*x*/(/*y*/) => 1 + 1; goTo.select("x", "y"); edit.applyRefactor({ refactorName: "Convert arrow function or function expression", actionName: "Convert to named function", actionDescription: "Convert to named function", newContent: `// Do not add me second time export let foo; export function bar() { return 1 + 1; } `, });
{ "end_byte": 445, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToNamed_MultiDecl_Modifier_Comment.ts" }
TypeScript/tests/cases/fourslash/documentHighlightsInvalidGlobalThis.ts_0_148
/// <reference path="fourslash.ts" /> ////declare global { //// export { globalThis as [|global|] } ////} verify.baselineDocumentHighlights();
{ "end_byte": 148, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlightsInvalidGlobalThis.ts" }
TypeScript/tests/cases/fourslash/findAllRefsForStaticInstanceMethodInheritance.ts_0_428
/// <reference path='fourslash.ts'/> ////class X{ //// /*0*/foo(): void{} ////} //// ////class Y extends X{ //// static /*1*/foo(): void{} ////} //// ////class Z extends Y{ //// static /*2*/foo(): void{} //// /*3*/foo(): void{} ////} //// ////const x = new X(); ////const y = new Y(); ////const z = new Z(); ////x.foo(); ////y.foo(); ////z.foo(); ////Y.foo(); ////Z.foo(); verify.baselineFindAllReferences('0', '1', '2', '3')
{ "end_byte": 428, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForStaticInstanceMethodInheritance.ts" }
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType18.ts_0_826
/// <reference path='fourslash.ts' /> ////const f1 = /*a*//*b*/function () { //// return { x: 1, y: 1 }; ////} ////const f2 = func/*c*//*d*/tion() { //// return { x: 1, y: 1 }; ////} ////const f3 = function (/*e*//*f*/) { //// return { x: 1, y: 1 }; ////} ////const f4 = function () {/*g*//*h*/ //// return { x: 1, y: 1 }; ////} ////const f5 = function () { //// return { x: 1, y: 1 /*i*//*j*/}; ////} goTo.select("a", "b"); verify.refactorAvailable("Infer function return type"); goTo.select("c", "d"); verify.refactorAvailable("Infer function return type"); goTo.select("e", "f"); verify.refactorAvailable("Infer function return type"); goTo.select("g", "h"); verify.not.refactorAvailable("Infer function return type"); goTo.select("i", "j"); verify.not.refactorAvailable("Infer function return type");
{ "end_byte": 826, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType18.ts" }
TypeScript/tests/cases/fourslash/codeFixAwaitInSyncFunction4.ts_0_162
/// <reference path='fourslash.ts' /> ////class Foo { //// constructor { //// await Promise.resolve(); //// } ////} verify.not.codeFixAvailable();
{ "end_byte": 162, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAwaitInSyncFunction4.ts" }
TypeScript/tests/cases/fourslash/extract-const_jsxFragment1.ts_0_547
/// <reference path='fourslash.ts' /> // @jsx: preserve // @filename: a.tsx ////function Foo() { //// return ( //// <div> //// /*a*/<></>/*b*/ //// </div> //// ); ////} goTo.file("a.tsx"); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "constant_scope_1", actionDescription: "Extract to constant in global scope", newContent: `const /*RENAME*/newLocal = <></>; function Foo() { return ( <div> {newLocal} </div> ); }` });
{ "end_byte": 547, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const_jsxFragment1.ts" }
TypeScript/tests/cases/fourslash/documentHighlightAtInheritedProperties2.ts_3_200
/ <reference path='fourslash.ts'/> // @Filename: file1.ts //// class class1 extends class1 { //// [|doStuff|]() { } //// [|propName|]: string; //// } verify.baselineDocumentHighlights();
{ "end_byte": 200, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlightAtInheritedProperties2.ts" }
TypeScript/tests/cases/fourslash/extract-method6.ts_0_394
/// <reference path='fourslash.ts' /> // Cannot extract globally-declared functions or // those with non-selected local references //// /*f1a*/function f() { //// /*g1a*/function g() { } //// g();/*g1b*/ //// g(); //// }/*f1b*/ goTo.select('f1a', 'f1b'); verify.not.refactorAvailable('Extract Symbol'); goTo.select('g1a', 'g1b'); verify.not.refactorAvailable('Extract Symbol');
{ "end_byte": 394, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method6.ts" }
TypeScript/tests/cases/fourslash/autoImportJsDocImport1.ts_0_735
/// <reference path="fourslash.ts" /> // @verbatimModuleSyntax: true // @target: esnext // @allowJs: true // @checkJs: true // @Filename: /foo.ts //// export const A = 1; //// export type B = { x: number }; //// export type C = 1; //// export class D { y: string } // @Filename: /test.js /////** //// * @import { A, D, C } from "./foo" //// */ //// /////** //// * @param { typeof A } a //// * @param { B/**/ | C } b //// * @param { C } c //// * @param { D } d //// */ ////export function f(a, b, c, d) { } goTo.marker(""); verify.importFixAtPosition([ `/** * @import { A, D, C, B } from "./foo" */ /** * @param { typeof A } a * @param { B | C } b * @param { C } c * @param { D } d */ export function f(a, b, c, d) { }` ]);
{ "end_byte": 735, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportJsDocImport1.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportAmbient2.ts_0_358
/// <reference path="fourslash.ts" /> ////[|/*! //// * I'm a license or something //// */ ////f1/*0*/();|] // @Filename: ambientModule.ts //// declare module "ambient-module" { //// export function f1(); //// export var v1; //// } verify.importFixAtPosition([ `/*! * I'm a license or something */ import { f1 } from "ambient-module"; f1();` ]);
{ "end_byte": 358, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportAmbient2.ts" }
TypeScript/tests/cases/fourslash/autoImportPackageJsonImportsPattern_js_ts.ts_0_345
/// <reference path="fourslash.ts" /> // @module: nodenext // @Filename: /package.json //// { //// "imports": { //// "#*.js": "./src/*.ts" //// } //// } // @Filename: /src/something.ts //// export function something(name: string): any; // @Filename: /a.ts //// something/**/ verify.importFixModuleSpecifiers("", ["#something.js"]);
{ "end_byte": 345, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPackageJsonImportsPattern_js_ts.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceWithAmbientSignatures2.ts_0_351
/// <reference path='fourslash.ts' /> ////declare class A { //// method(): void; ////} ////class B implements A {} verify.codeFix({ description: "Implement interface 'A'", newFileContent: `declare class A { method(): void; } class B implements A { method(): void { throw new Error("Method not implemented."); } }` });
{ "end_byte": 351, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceWithAmbientSignatures2.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess24.ts_0_730
/// <reference path='fourslash.ts' /> //// class A { //// /*a*/public a: number = 1;/*b*/ //// public _a: string = "foo"; //// public _a_1: string = "bar"; //// public _a_2: string = "baz"; //// } goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Generate 'get' and 'set' accessors", actionName: "Generate 'get' and 'set' accessors", actionDescription: "Generate 'get' and 'set' accessors", newContent: `class A { private /*RENAME*/_a_3: number = 1; public get a(): number { return this._a_3; } public set a(value: number) { this._a_3 = value; } public _a: string = "foo"; public _a_1: string = "bar"; public _a_2: string = "baz"; }`, });
{ "end_byte": 730, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess24.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType56.ts_0_237
/// <reference path='fourslash.ts' /> // typeof other parameters within function signature? //// function f(a: string, b: /*a*/typeof a/*b*/): typeof b { return ''; } goTo.select("a", "b"); verify.not.refactorAvailable("Extract type")
{ "end_byte": 237, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType56.ts" }
TypeScript/tests/cases/fourslash/getPropertySymbolsFromBaseTypesDoesntCrash.ts_0_184
/// <reference path='fourslash.ts'/> // @Filename: file1.ts //// class ClassA implements IInterface { //// private [|value|]: number; //// } verify.baselineDocumentHighlights();
{ "end_byte": 184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getPropertySymbolsFromBaseTypesDoesntCrash.ts" }
TypeScript/tests/cases/fourslash/organizeImports19.ts_0_267
/// <reference path="fourslash.ts" /> ////const a = 1; ////export { a }; //// ////const b = 1; ////export { b }; //// ////const c = 1; ////export { c }; verify.organizeImports( `const a = 1; export { a }; const b = 1; export { b }; const c = 1; export { c }; `);
{ "end_byte": 267, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImports19.ts" }
TypeScript/tests/cases/fourslash/extract-method-two-type-literals.ts_0_389
/// <reference path='fourslash.ts' /> ////(x: {}, y: {}) => (/*1*/x + y/*2*/); goTo.select("1", "2"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "function_scope_0", actionDescription: "Extract to function in global scope", newContent: `(x: {}, y: {}) => (/*RENAME*/newFunction(x, y)); function newFunction(x: {}, y: {}) { return x + y; } ` });
{ "end_byte": 389, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method-two-type-literals.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingAttributes5.ts_0_391
/// <reference path='fourslash.ts' /> // @jsx: preserve // @filename: foo.tsx ////interface P { //// a: number; //// b: string; //// c: number[]; //// d: any; ////} //// ////const A = ({ a, b, c, d }: P) => //// <div>{a}{b}{c}{d}</div>; //// ////const Bar = () => //// [|<A a={100} b={""} c={[]} d={undefined}></A>|] verify.not.codeFixAvailable("fixMissingAttributes");
{ "end_byte": 391, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAttributes5.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportFile1.ts_0_383
/// <reference path="fourslash.ts" /> //// [|/// <reference path="./tripleSlashReference.ts" /> //// f1/*0*/();|] // @Filename: Module.ts //// export function f1() {} //// export var v1 = 5; // @Filename: tripleSlashReference.ts //// var x = 5;/*dummy*/ verify.importFixAtPosition([ `/// <reference path="./tripleSlashReference.ts" /> import { f1 } from "./Module"; f1();` ]);
{ "end_byte": 383, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportFile1.ts" }
TypeScript/tests/cases/fourslash/findAllRefsInsideTemplates1.ts_0_157
/// <reference path='fourslash.ts'/> /////*1*/var /*2*/x = 10; ////var y = `${ /*3*/x } ${ /*4*/x }` verify.baselineFindAllReferences('1', '2', '3', '4');
{ "end_byte": 157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsInsideTemplates1.ts" }
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue11.ts_0_270
/// <reference path='fourslash.ts' /> //// interface A { //// bar: string //// } //// //// function Foo (): A { //// { bar: '123' } //// } verify.codeFixAvailable([ { description: 'Add a return statement' }, { description: 'Remove unused label' }, ]);
{ "end_byte": 270, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue11.ts" }
TypeScript/tests/cases/fourslash/completionsImport_umdModules3_script.ts_0_856
/// <reference path="./fourslash.ts" /> // @filename: /package.json //// { "dependencies": { "@types/classnames": "*" } } // @filename: /tsconfig.json //// { "compilerOptions": { "module": "es2015" }} // @filename: /node_modules/@types/classnames/package.json //// { "name": "@types/classnames", "types": "index.d.ts" } // @filename: /node_modules/@types/classnames/index.d.ts //// declare const classNames: () => string; //// export = classNames; //// export as namespace classNames; // @filename: /SomeReactComponent.tsx //// //// const el1 = <div className={class/*1*/}>foo</div> goTo.marker("1"); verify.completions({ includes: [{ name: "classNames", hasAction: undefined, // Asserts to have no actions sortText: completion.SortText.GlobalsOrKeywords, }], preferences: { includeCompletionsForModuleExports: true, } });
{ "end_byte": 856, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_umdModules3_script.ts" }
TypeScript/tests/cases/fourslash/getEditsForFileRename_tsconfig.ts_0_890
/// <reference path='fourslash.ts' /> // @Filename: /src/tsconfig.json ////{ //// "compilerOptions": { //// "baseUrl": "./old", //// "paths": { //// "foo": ["old"], //// }, //// "rootDir": "old", //// "rootDirs": ["old"], //// "typeRoots": ["old"], //// }, //// "files": ["old/a.ts"], //// "include": ["old/*.ts"], //// "exclude": ["old"], ////} // @Filename: /src/old/someFile.ts //// verify.getEditsForFileRename({ oldPath: "/src/old", newPath: "/src/new", newFileContents: { "/src/tsconfig.json": `{ "compilerOptions": { "baseUrl": "new", "paths": { "foo": ["new"], }, "rootDir": "new", "rootDirs": ["new"], "typeRoots": ["new"], }, "files": ["new/a.ts"], "include": ["new/*.ts"], "exclude": ["new"], }`, }, });
{ "end_byte": 890, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_tsconfig.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionSwitchCase4.ts_0_237
/// <reference path="fourslash.ts" /> //// switch (null) { //// case null: break; //// } //// //// switch (null) { //// [|/*start*/case|] null: break; //// } verify.baselineGoToDefinition("start");
{ "end_byte": 237, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionSwitchCase4.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionSignatureAlias.ts_0_1501
/// <reference path='fourslash.ts'/> // @jsx: preserve // @Filename: /a.tsx ////function /*f*/f() {} ////const /*g*/g = f; ////const /*h*/h = g; ////[|/*useF*/f|](); ////[|/*useG*/g|](); ////[|/*useH*/h|](); ////const /*i*/i = () => 0; ////const /*iFn*/iFn = function () { return 0; }; ////const /*j*/j = i; ////[|/*useI*/i|](); ////[|/*useIFn*/iFn|](); ////[|/*useJ*/j|](); ////const o = { /*m*/m: () => 0 }; ////o.[|/*useM*/m|](); ////const oFn = { /*mFn*/mFn: function () { return 0; } }; ////oFn.[|/*useMFn*/mFn|](); ////class Component { /*componentCtr*/constructor(props: {}) {} } ////type ComponentClass = /*ComponentClass*/new () => Component; ////interface ComponentClass2 { /*ComponentClass2*/new(): Component; } //// ////class /*MyComponent*/MyComponent extends Component {} ////<[|/*jsxMyComponent*/MyComponent|] />; ////new [|/*newMyComponent*/MyComponent|]({}); //// ////declare const /*MyComponent2*/MyComponent2: ComponentClass; ////<[|/*jsxMyComponent2*/MyComponent2|] />; ////new [|/*newMyComponent2*/MyComponent2|](); //// ////declare const /*MyComponent3*/MyComponent3: ComponentClass2; ////<[|/*jsxMyComponent3*/MyComponent3|] />; ////new [|/*newMyComponent3*/MyComponent3|](); verify.noErrors(); verify.baselineGoToDefinition( "useF", "useG", "useH", "useI", "useIFn", "useJ", "useM", "useMFn", "jsxMyComponent", "newMyComponent", "jsxMyComponent2", "newMyComponent2", "jsxMyComponent3", "newMyComponent3", );
{ "end_byte": 1501, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionSignatureAlias.ts" }
TypeScript/tests/cases/fourslash/importFixesWithExistingDottedRequire.ts_0_537
/// <reference path="./fourslash.ts" /> // @module: commonjs // @checkJs: true // @Filename: ./library.js //// module.exports.aaa = function() {} //// module.exports.bbb = function() {} // @Filename: ./foo.js //// var aaa = require("./library.js").aaa; //// aaa(); //// /*$*/bbb goTo.marker("$") verify.codeFixAvailable([ { description: "Add import from \"./library.js\"" }, { description: "Ignore this error message" }, { description: "Disable checking for this file" }, { description: "Convert to ES module" }, ]);
{ "end_byte": 537, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importFixesWithExistingDottedRequire.ts" }
TypeScript/tests/cases/fourslash/refactorConvertImportForTriggerReason2.ts_0_310
/// <reference path='fourslash.ts' /> ////import d, * as /*a*/n/*b*/ from "m"; // Only offer refactor for sub span if explicity requested goTo.select("a", "b"); verify.not.refactorAvailableForTriggerReason("implicit", "Convert import"); verify.refactorAvailableForTriggerReason("invoked", "Convert import");
{ "end_byte": 310, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertImportForTriggerReason2.ts" }
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction20.ts_0_413
/// <reference path='fourslash.ts' /> //// const foo = /*a*/a/*b*/ => { //// // return comment //// return a; //// }; goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Add or remove braces in an arrow function", actionName: "Remove braces from arrow function", actionDescription: "Remove braces from arrow function", newContent: `const foo = a => /* return comment*/ a;`, });
{ "end_byte": 413, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction20.ts" }
TypeScript/tests/cases/fourslash/extract-const-callback-function-no-context2.ts_0_559
/// <reference path='fourslash.ts' /> ////declare function fnUnion(fn: ((a: number) => number) | ((a: string) => string)): void ////fnUnion(/*a*/(a) => a/*b*/); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "constant_scope_0", actionDescription: "Extract to constant in enclosing scope", newContent: `declare function fnUnion(fn: ((a: number) => number) | ((a: string) => string)): void const newLocal: ((a: number) => number) | ((a: string) => string) = (a) => a; fnUnion(/*RENAME*/newLocal);` });
{ "end_byte": 559, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const-callback-function-no-context2.ts" }
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplatePlusExprSeq.ts_0_387
/// <reference path='fourslash.ts' /> //// const foo = "/*x*/f/*y*/oobar is " + 42 + 6 + " years old" goTo.select("x", "y"); edit.applyRefactor({ refactorName: "Convert to template string", actionName: "Convert to template string", actionDescription: ts.Diagnostics.Convert_to_template_string.message, newContent: `const foo = \`foobar is \${42}\${6} years old\``, });
{ "end_byte": 387, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplatePlusExprSeq.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageAlwaysInferJS.ts_0_352
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @noEmit: true // @noImplicitAny: false // @Filename: important.js ////function coll(callback) { ////} verify.codeFix({ description: "Infer parameter types from usage", index: 0, newFileContent: `/** * @param {any} callback */ function coll(callback) { }`, });
{ "end_byte": 352, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageAlwaysInferJS.ts" }
TypeScript/tests/cases/fourslash/codeFixAddConvertToUnknownForNonOverlappingTypes8.ts_0_199
/// <reference path='fourslash.ts' /> ////<object>"words" verify.codeFix({ description: "Add 'unknown' conversion for non-overlapping types", newFileContent: `<object><unknown>"words"` });
{ "end_byte": 199, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddConvertToUnknownForNonOverlappingTypes8.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDocTagsCallback.ts_0_340
/// <reference path='fourslash.ts'/> // @noEmit: true // @allowJs: true // @Filename: quickInfoJsDocTagsCallback.js /////** //// * @callback cb/*1*/ //// * @param {string} x - x comment //// */ //// /////** //// * @param {/*2*/cb} bar -callback comment //// */ ////function foo(bar) { //// bar(bar); ////} verify.baselineQuickInfo();
{ "end_byte": 340, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTagsCallback.ts" }
TypeScript/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile_all.ts_0_374
/// <reference path='fourslash.ts' /> // @allowjs: true // @checkJs: true // @noEmit: true // @Filename: a.js ////let x = ""; ////x = 1; x = true; ////x = []; verify.codeFixAll({ fixId: "disableJsDiagnostics", fixAllDescription: "Add '@ts-ignore' to all error messages", newFileContent: `let x = ""; // @ts-ignore x = 1; x = true; // @ts-ignore x = [];`, });
{ "end_byte": 374, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile_all.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingMember17.ts_0_528
/// <reference path='fourslash.ts' /> ////class A { //// constructor() { //// this._x = 10; //// } ////} verify.codeFixAvailable([ { description: "Declare private property '_x'" }, { description: "Declare property '_x'" }, { description: "Add index signature for property '_x'" } ]) verify.codeFix({ description: [ts.Diagnostics.Declare_private_property_0.message, "_x"], index: 0, newFileContent: `class A { private _x: number; constructor() { this._x = 10; } }` });
{ "end_byte": 528, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember17.ts" }
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_Availability_Anon_FnArgument.ts_0_2258
/// <reference path='fourslash.ts' /> //// function foo(a){} //// /*z*/f/*y*/oo/*x*/(/*w*//*v*/f/*u*/unction/*t*/(/*s*//*r*/b/*q*/,c){/*p*/r/*o*/eturn 42;}) goTo.select("z", "y"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function"); goTo.select("x", "w"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function"); goTo.select("v", "u"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function"); verify.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function"); goTo.select("t", "s"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function"); verify.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function"); goTo.select("r", "q"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function"); verify.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function"); goTo.select("p", "o"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
{ "end_byte": 2258, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_Availability_Anon_FnArgument.ts" }
TypeScript/tests/cases/fourslash/formattingWithMultilineComments.ts_0_193
/// <reference path="fourslash.ts"/> ////f(/* /////*2*/ */() => { /*1*/ }); goTo.marker("1"); edit.insertLine(""); goTo.marker("2"); verify.currentLineContentIs(" */() => {");
{ "end_byte": 193, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingWithMultilineComments.ts" }
TypeScript/tests/cases/fourslash/jsdocImportTagCompletion2.ts_0_224
///<reference path="fourslash.ts" /> // @allowJS: true // @checkJs: true // @filename: /a.ts ////export interface A {} // @filename: /b.js /////** //// * @import { /**/ } from "./a" //// */ verify.baselineCompletions();
{ "end_byte": 224, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocImportTagCompletion2.ts" }
TypeScript/tests/cases/fourslash/regexp.ts_0_103
/// <reference path="fourslash.ts" /> ////var /**/x = /aa/; verify.quickInfoAt("", "var x: RegExp");
{ "end_byte": 103, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/regexp.ts" }
TypeScript/tests/cases/fourslash/formatConflictMarker1.ts_0_255
/// <reference path='fourslash.ts' /> ////class C { ////<<<<<<< HEAD ////v = 1; ////======= ////v = 2; ////>>>>>>> Branch - a ////} format.document(); verify.currentFileContentIs(`class C { <<<<<<< HEAD v = 1; ======= v = 2; >>>>>>> Branch - a }`);
{ "end_byte": 255, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatConflictMarker1.ts" }
TypeScript/tests/cases/fourslash/moveToFile_consistentQuoteStyle.ts_1_568
/// <reference path='fourslash.ts' /> // @Filename: /bar.ts ////export const tt = 2; // @Filename: /a.ts ////import { b } from './other'; ////const a = 1; ////[|const c = a + b;|] // @Filename: /other.ts ////export const b = 2; verify.moveToFile({ newFileContents: { "/a.ts": `export const a = 1; `, "/bar.ts": `import { a } from './a'; import { b } from './other'; export const tt = 2; const c = a + b; `, }, interactiveRefactorArguments: { targetFile: "/bar.ts" }, preferences: { quotePreference: "single", } });
{ "end_byte": 568, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_consistentQuoteStyle.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsagePropertyAccessJS.ts_0_653
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @noImplicitAny: true // @Filename: important.js ////function foo([|a, m, x|]) { //// a.b.c; //// //// var numeric = 0; //// numeric = m.n(); //// //// x.y.z //// x.y.z.push(0); //// return x.y.z ////} verify.codeFix({ description: "Infer parameter types from usage", index: 0, newFileContent: `/** * @param {{ b: { c: any; }; }} a * @param {{ n: () => number; }} m * @param {{ y: { z: number[]; }; }} x */ function foo(a, m, x) { a.b.c; var numeric = 0; numeric = m.n(); x.y.z x.y.z.push(0); return x.y.z }`, });
{ "end_byte": 653, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsagePropertyAccessJS.ts" }
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue25.ts_0_352
/// <reference path='fourslash.ts' /> //// function Foo (a: () => number) { a() } //// Foo(() => { /* leading */ 1 /* trailing */ }) verify.codeFix({ description: ts.Diagnostics.Remove_braces_from_arrow_function_body.message, index: 1, newFileContent: `function Foo (a: () => number) { a() } Foo(() => /* leading */ 1 /* trailing */)` })
{ "end_byte": 352, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue25.ts" }
TypeScript/tests/cases/fourslash/completionListAfterFunction.ts_0_491
/// <reference path='fourslash.ts' /> ////// Outside the function ////declare function f1(a: number);/*1*/ //// ////// inside the function ////declare function f2(b: number, b2 = /*2*/ //// ////// Outside the function ////function f3(c: number) { }/*3*/ //// ////// inside the function ////function f4(d: number) { /*4*/} verify.completions( { marker: "1", excludes: "a" }, { marker: "2", includes: "b" }, { marker: "3", excludes: "c" }, { marker: "4", includes: "d" }, );
{ "end_byte": 491, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAfterFunction.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess10.ts_0_525
/// <reference path='fourslash.ts' /> //// class A { //// /*a*/public a?: string = "foo";/*b*/ //// } goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Generate 'get' and 'set' accessors", actionName: "Generate 'get' and 'set' accessors", actionDescription: "Generate 'get' and 'set' accessors", newContent: `class A { private /*RENAME*/_a?: string = "foo"; public get a(): string { return this._a; } public set a(value: string) { this._a = value; } }`, });
{ "end_byte": 525, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess10.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType62.ts_0_234
/// <reference path='fourslash.ts' /> //// type T = { c: string } //// function foo(a: /*a*/{ a: number | string, b: string } & T/*b*/) { } goTo.select("a", "b"); verify.not.refactorAvailable("Extract type", "Extract to interface")
{ "end_byte": 234, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType62.ts" }
TypeScript/tests/cases/fourslash/referencesForInheritedProperties5.ts_3_369
/ <reference path='fourslash.ts'/> //// interface interface1 extends interface1 { //// /*1*/doStuff(): void; //// /*2*/propName: string; //// } //// interface interface2 extends interface1 { //// doStuff(): void; //// propName: string; //// } //// //// var v: interface1; //// v.propName; //// v.doStuff(); verify.baselineFindAllReferences('1', '2')
{ "end_byte": 369, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForInheritedProperties5.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_import_multipleVariableDeclarations.ts_0_375
/// <reference path='fourslash.ts' /> // Test that we leave it alone if the name is a keyword. // @allowJs: true // @target: esnext // @Filename: /a.js ////const x = require("x"), y = 0, { z } = require("z"); ////x; y; z; verify.codeFix({ description: "Convert to ES module", newFileContent: `import x from "x"; const y = 0; import { z } from "z"; x; y; z;`, });
{ "end_byte": 375, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_import_multipleVariableDeclarations.ts" }
TypeScript/tests/cases/fourslash/jsDocFunctionSignatures13.ts_0_192
///<reference path="fourslash.ts" /> //// /** //// * @template {string} K/**/ a golden opportunity //// */ //// function Multimap(iv) { //// }; goTo.marker(''); verify.quickInfoIs("any");
{ "end_byte": 192, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocFunctionSignatures13.ts" }
TypeScript/tests/cases/fourslash/squiggleFunctionExpression.ts_0_328
/// <reference path="fourslash.ts"/> ////function takesCallback(callback: (n) => any) { } ////takesCallback(function inner(n) { var /*1*/k/*2*/: string = 10; }); verify.errorExistsBetweenMarkers("1", "2"); verify.not.errorExistsBeforeMarker("1"); verify.not.errorExistsAfterMarker("2"); verify.numberOfErrorsInCurrentFile(1);
{ "end_byte": 328, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/squiggleFunctionExpression.ts" }
TypeScript/tests/cases/fourslash/todoComments17.ts_0_86
//// /**** [|HACK 1 |]*/ a verify.todoCommentsInCurrentFile(["TODO(jason)", "HACK"]);
{ "end_byte": 86, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/todoComments17.ts" }
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classDeclarationAliasing.ts_0_589
/// <reference path='fourslash.ts' /> ////class Foo { //// /*a*/constructor/*b*/(a: number, b: number) { } ////} ////const fooAlias = Foo; ////const newFoo = new fooAlias(1, 2); goTo.select("a", "b"); // Refactor should not make changes edit.applyRefactor({ refactorName: "Convert parameters to destructured object", actionName: "Convert parameters to destructured object", actionDescription: "Convert parameters to destructured object", newContent: `class Foo { constructor(a: number, b: number) { } } const fooAlias = Foo; const newFoo = new fooAlias(1, 2);` });
{ "end_byte": 589, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classDeclarationAliasing.ts" }
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType5.ts_0_349
/// <reference path='fourslash.ts' /> ////function /*a*/foo/*b*/() { //// return 1; ////} goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Infer function return type", actionName: "Infer function return type", actionDescription: "Infer function return type", newContent: `function foo(): number { return 1; }` });
{ "end_byte": 349, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType5.ts" }
TypeScript/tests/cases/fourslash/completionListInUnclosedForLoop01.ts_0_118
/// <reference path='fourslash.ts' /> ////for (let i = 0; /*1*/ verify.completions({ marker: "1", includes: "i" });
{ "end_byte": 118, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedForLoop01.ts" }