_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/extract-method27.ts_0_734
/// <reference path='fourslash.ts' /> // Repro https://github.com/Microsoft/TypeScript/issues/19395 // @Filename: test.ts //// export const b = 2; //// interface Interface { } //// //// async function handle(i: Interface) { //// /*a*/const x = 3, y = i;/*b*/ //// } // @Filename: library.d.ts //// export as namespace NS; //// export const a = 1; goTo.select('a', 'b') edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "function_scope_1", actionDescription: "Extract to function in module scope", newContent: `export const b = 2; interface Interface { } async function handle(i: Interface) { /*RENAME*/newFunction(i); } function newFunction(i: Interface) { const x = 3, y = i; } ` });
{ "end_byte": 734, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method27.ts" }
TypeScript/tests/cases/fourslash/navigationItemsPrefixMatch2.ts_0_1940
/// <reference path="fourslash.ts"/> ////module Shapes { //// export class Point { //// [|private originality = 0.0;|] //// [|private distanceFromOrig = 0.0;|] //// [|get distanceFarFarAway(distanceFarFarAwayParam: number): number { //// var [|distanceFarFarAwayLocal|]; //// return 0; //// }|] //// } ////} ////var pointsSquareBox = new Shapes.Point(); ////function PointsFunc(): void { //// var pointFuncLocal; ////} ////[|interface OriginI { //// 123; //// [|origin1;|] //// [|public _distance(distanceParam): void;|] ////}|] const [r0, r1, r2, r3, r4, r5, r6] = test.ranges(); verify.navigateTo( { pattern: "origin", expected: [ { name: "origin1", matchKind: "prefix", kind: "property", range: r5, containerName: "OriginI", containerKind: "interface" }, { name: "originality", matchKind: "prefix", kind: "property", kindModifiers: "private", range: r0, containerName: "Point", containerKind: "class" }, { name: "OriginI", matchKind: "prefix", isCaseSensitive: false, kind: "interface", range: r4 }, ], }, { pattern: "distance", expected: [ { name: "distanceFarFarAway", matchKind: "prefix", kind: "getter", range: r2, containerName: "Point", containerKind: "class" }, { name: "distanceFarFarAwayLocal", matchKind: "prefix", kind: "var", range: r3, containerName: "distanceFarFarAway", containerKind: "getter" }, { name: "distanceFromOrig", matchKind: "prefix", kind: "property", kindModifiers: "private", range: r1, containerName: "Point", containerKind: "class" }, { name: "_distance", matchKind: "substring", kind: "method", kindModifiers: "public", range: r6, containerName: "OriginI", containerKind: "interface" }, ], }, { pattern: "mPointThatIJustInitiated wrongKeyWord", expected: [], }, );
{ "end_byte": 1940, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationItemsPrefixMatch2.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingParam2.ts_0_294
/// <reference path="fourslash.ts" /> ////[|function f(a: number) {}|] //// ////const a = 1; ////const b = 1; ////f(a, b); verify.codeFix({ description: [ts.Diagnostics.Add_missing_parameter_to_0.message, "f"], index: 0, newRangeContent: "function f(a: number, b: number) {}" });
{ "end_byte": 294, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingParam2.ts" }
TypeScript/tests/cases/fourslash/addFunctionAboveMultiLineLambdaExpression.ts_0_143
/// <reference path="fourslash.ts" /> //// /**/ //// () => //// // do something //// 0; goTo.marker(); edit.insert("function Foo() { }");
{ "end_byte": 143, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/addFunctionAboveMultiLineLambdaExpression.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringForOfObjectBindingPattern.ts_0_2495
/// <reference path='fourslash.ts' /> ////declare var console: { //// log(msg: any): void; ////} ////interface Robot { //// name: string; //// skill: string; ////} ////interface MultiRobot { //// name: string; //// skills: { //// primary: string; //// secondary: string; //// }; ////} ////let robots: Robot[] = [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]; ////let multiRobots: MultiRobot[] = [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, //// { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]; ////function getRobots() { //// return robots; ////} ////function getMultiRobots() { //// return multiRobots; ////} ////for (let {name: nameA } of robots) { //// console.log(nameA); ////} ////for (let {name: nameA } of getRobots()) { //// console.log(nameA); ////} ////for (let {name: nameA } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) { //// console.log(nameA); ////} ////for (let { skills: { primary: primaryA, secondary: secondaryA } } of multiRobots) { //// console.log(primaryA); ////} ////for (let { skills: { primary: primaryA, secondary: secondaryA } } of getMultiRobots()) { //// console.log(primaryA); ////} ////for (let { skills: { primary: primaryA, secondary: secondaryA } } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, //// { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) { //// console.log(primaryA); ////} ////for (let {name: nameA, skill: skillA } of robots) { //// console.log(nameA); ////} ////for (let {name: nameA, skill: skillA } of getRobots()) { //// console.log(nameA); ////} ////for (let {name: nameA, skill: skillA } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) { //// console.log(nameA); ////} ////for (let {name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of multiRobots) { //// console.log(nameA); ////} ////for (let {name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of getMultiRobots()) { //// console.log(nameA); ////} ////for (let {name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, //// { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) { //// console.log(nameA); ////} verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 2495, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringForOfObjectBindingPattern.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceDouble.ts_0_695
/// <reference path='fourslash.ts' /> ////interface I { //// a(): void; //// b(x: "x", y: "a" | "b"): "b"; //// //// c: "c"; //// d: { e: "e"; }; ////} ////class Foo implements I {} verify.codeFix({ description: [ts.Diagnostics.Implement_interface_0.message, "I"], index: 0, newFileContent: `interface I { a(): void; b(x: "x", y: "a" | "b"): "b"; c: "c"; d: { e: "e"; }; } class Foo implements I { a(): void { throw new Error("Method not implemented."); } b(x: "x", y: "a" | "b"): "b" { throw new Error("Method not implemented."); } c: "c"; d: { e: "e"; }; }`, preferences: { quotePreference: "double" } });
{ "end_byte": 695, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceDouble.ts" }
TypeScript/tests/cases/fourslash/quickInfoAtPropWithAmbientDeclarationInJs.ts_0_277
/// <reference path="fourslash.ts" /> // @allowJs: true // @filename: /a.js ////class C { //// constructor() { //// this.prop = ""; //// } //// declare prop: string; //// method() { //// this.prop.foo/**/ //// } ////} verify.baselineQuickInfo();
{ "end_byte": 277, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoAtPropWithAmbientDeclarationInJs.ts" }
TypeScript/tests/cases/fourslash/autoImportSortCaseSensitivity2.ts_0_933
/// <reference path="fourslash.ts" /> // @Filename: /a.ts ////export interface HasBar { bar: number } ////export function hasBar(x: unknown): x is HasBar { return x && typeof x.bar === "number" } ////export function foo() {} ////export type __String = string; // @Filename: /b.ts ////import { __String, HasBar, hasBar } from "./a"; ////f/**/; verify.completions({ marker: "", includes: { name: "foo", source: "/a", sourceDisplay: "./a", text: "function foo(): void", kind: "function", kindModifiers: "export", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, preferences: { includeCompletionsForModuleExports: true }, }); verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", description: `Update import from "./a"`, newFileContent: `import { __String, foo, HasBar, hasBar } from "./a"; f;`, });
{ "end_byte": 933, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportSortCaseSensitivity2.ts" }
TypeScript/tests/cases/fourslash/indentationBlock.ts_0_3468
/// <reference path="fourslash.ts"/> //// ////module classes { ////{| "indent": 0 |} //// class Bar { ////{| "indent": 4 |} //// //// constructor() { ////{| "indent": 8 |} //// } //// //// private foo: string = ""; ////{| "indent": 8 |} //// //// private f() { //// var a: any[] = [[1, 2], [3, 4], 5]; ////{| "indent": 12 |} //// return ((1 + 1)); //// } //// ////{| "indent": 8 |} //// private f2() { //// if (true) { } { }; //// } //// } ////} //// //// ////module interfaces { ////{| "indent": 0 |} //// interface Foo { ////{| "indent": 4 |} //// //// x: number; ////{| "indent": 8 |} //// //// foo(): number; ////{| "indent": 8 |} //// } ////} //// //// ////module nestedModules { //// module Foo2 { ////{| "indent": 4 |} //// function f() { //// } ////{| "indent": 8 |} //// var x: number; ////{| "indent": 8 |} //// } ////} //// //// ////module Enums { //// enum Foo3 { ////{| "indent": 4 |} //// val1, ////{| "indent": 8 |} //// val2, ////{| "indent": 8 |} //// } ////{| "indent": 4 |} ////} //// //// ////function controlStatements() { //// for (var i = 0; i < 10; i++) { ////{| "indent": 4 |} //// } //// //// for (var e in foo.bar) { ////{| "indent": 4 |} //// } //// //// with (foo.bar) { ////{| "indent": 4 |} //// } //// //// while (false) { ////{| "indent": 4 |} //// } //// //// do { ////{| "indent": 4 |} //// } while (false); //// //// switch (foo.bar) { ////{| "indent": 4 |} //// } //// //// switch (foo.bar) { ////{| "indent": 4 |} //// case 1: ////{| "indent": 8 |} //// break; //// default: ////{| "indent": 8 |} //// break; //// } ////} //// //// ////function tryCatch() { ////{| "indent": 0 |} //// try { ////{| "indent": 4 |} //// } ////{| "indent": 4 |} //// catch (err) { ////{| "indent": 4 |} //// } ////{| "indent": 4 |} ////} //// //// ////function tryFinally() { ////{| "indent": 0 |} //// try { ////{| "indent": 4 |} //// } ////{| "indent": 4 |} //// finally { ////{| "indent": 4 |} //// } ////{| "indent": 4 |} ////} //// //// ////function tryCatchFinally() { ////{| "indent": 0 |} //// try { ////{| "indent": 4 |} //// } ////{| "indent": 4 |} //// catch (err) { ////{| "indent": 4 |} //// } ////{| "indent": 4 |} //// finally { ////{| "indent": 4 |} //// } ////{| "indent": 4 |} ////} //// //// ////class indentBeforeCurly ////{| "indent": 0 |} ////{| "indent": 0 |}{ ////{| "indent": 0 |} ////} //// //// ////function argumentsListIndentation(bar, //// blah, //// {| "indent": 13 |} ////); //// //// ////function blockIndentAfterIndentedParameter1(bar, //// blah) { ////{| "indent": 13 |} ////} //// //// ////function blockIndentAfterIndentedParameter2(bar, //// blah) { //// if (foo) { ////{| "indent": 4 |} //// } ////} //// //// ////// Note: Do not add more tests at the end of this file, as ////// the purpose of this test is to verity smart indent ////// works for unterminated function arguments at the end of a file. ////function unterminatedListIndentation(a, ////{| "indent": 0 |} test.markers().forEach(marker => { verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent, ts.IndentStyle.Block); });
{ "end_byte": 3468, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indentationBlock.ts" }
TypeScript/tests/cases/fourslash/memberListOnContextualThis.ts_0_323
/// <reference path='fourslash.ts'/> ////interface A { //// a: string; ////} ////declare function ctx(callback: (this: A) => string): string; ////ctx(function () { return th/*1*/is./*2*/a }); verify.quickInfoAt("1", "this: A"); verify.completions({ marker: "2", exact: { name: "a", text: "(property) A.a: string" } });
{ "end_byte": 323, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberListOnContextualThis.ts" }
TypeScript/tests/cases/fourslash/quickInfoLink7.ts_0_143
/// <reference path="fourslash.ts" /> /////** //// * See {@link | } instead //// */ ////const /**/B = 456; verify.baselineQuickInfo();
{ "end_byte": 143, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoLink7.ts" }
TypeScript/tests/cases/fourslash/callSignatureHelp.ts_0_166
/// <reference path='fourslash.ts'/> ////interface C { //// (): number; ////} ////var c: C; ////c(/**/ verify.signatureHelp({ marker: "", text: "c(): number" });
{ "end_byte": 166, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callSignatureHelp.ts" }
TypeScript/tests/cases/fourslash/navigationBarItemsFunctionsBroken2.ts_0_1058
/// <reference path="fourslash.ts"/> ////function; ////function f() { //// function; ////} verify.navigationTree({ "text": "<global>", "kind": "script", "childItems": [ { "text": "<function>", "kind": "function" }, { "text": "f", "kind": "function", "childItems": [ { "text": "<function>", "kind": "function" } ] } ] }); verify.navigationBar([ { "text": "<global>", "kind": "script", "childItems": [ { "text": "<function>", "kind": "function" }, { "text": "f", "kind": "function" } ] }, { "text": "f", "kind": "function", "childItems": [ { "text": "<function>", "kind": "function" } ], "indent": 1 } ]);
{ "end_byte": 1058, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsFunctionsBroken2.ts" }
TypeScript/tests/cases/fourslash/navbar_contains-no-duplicates.ts_0_5669
/// <reference path="fourslash.ts" /> //// declare module Windows { //// export module Foundation { //// export var A; //// export class Test { //// public wow(); //// } //// } //// } //// //// declare module Windows { //// export module Foundation { //// export var B; //// export module Test { //// export function Boom(): number; //// } //// } //// } //// //// class ABC { //// public foo() { //// return 3; //// } //// } //// //// module ABC { //// export var x = 3; //// } verify.navigationTree({ "text": "<global>", "kind": "script", "childItems": [ { "text": "ABC", "kind": "class", "childItems": [ { "text": "foo", "kind": "method", "kindModifiers": "public" } ] }, { "text": "ABC", "kind": "module", "childItems": [ { "text": "x", "kind": "var", "kindModifiers": "export" } ] }, { "text": "Windows", "kind": "module", "kindModifiers": "declare", "childItems": [ { "text": "Foundation", "kind": "module", "kindModifiers": "export,declare", "childItems": [ { "text": "A", "kind": "var", "kindModifiers": "export,declare" }, { "text": "B", "kind": "var", "kindModifiers": "export,declare" }, { "text": "Test", "kind": "class", "kindModifiers": "export,declare", "childItems": [ { "text": "wow", "kind": "method", "kindModifiers": "public,declare" } ] }, { "text": "Test", "kind": "module", "kindModifiers": "export,declare", "childItems": [ { "text": "Boom", "kind": "function", "kindModifiers": "export,declare" } ] } ] } ] } ] }); verify.navigationBar([ { "text": "<global>", "kind": "script", "childItems": [ { "text": "ABC", "kind": "class" }, { "text": "ABC", "kind": "module" }, { "text": "Windows", "kind": "module", "kindModifiers": "declare" } ] }, { "text": "ABC", "kind": "class", "childItems": [ { "text": "foo", "kind": "method", "kindModifiers": "public" } ], "indent": 1 }, { "text": "ABC", "kind": "module", "childItems": [ { "text": "x", "kind": "var", "kindModifiers": "export" } ], "indent": 1 }, { "text": "Windows", "kind": "module", "kindModifiers": "declare", "childItems": [ { "text": "Foundation", "kind": "module", "kindModifiers": "export,declare" } ], "indent": 1 }, { "text": "Foundation", "kind": "module", "kindModifiers": "export,declare", "childItems": [ { "text": "A", "kind": "var", "kindModifiers": "export,declare" }, { "text": "B", "kind": "var", "kindModifiers": "export,declare" }, { "text": "Test", "kind": "class", "kindModifiers": "export,declare" }, { "text": "Test", "kind": "module", "kindModifiers": "export,declare" } ], "indent": 2 }, { "text": "Test", "kind": "class", "kindModifiers": "export,declare", "childItems": [ { "text": "wow", "kind": "method", "kindModifiers": "public,declare" } ], "indent": 3 }, { "text": "Test", "kind": "module", "kindModifiers": "export,declare", "childItems": [ { "text": "Boom", "kind": "function", "kindModifiers": "export,declare" } ], "indent": 3 } ]);
{ "end_byte": 5669, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navbar_contains-no-duplicates.ts" }
TypeScript/tests/cases/fourslash/nodeArrayCloneCrash.ts_0_901
/// <reference path="fourslash.ts" /> // @module: preserve // @Filename: /TLLineShape.ts //// import { createShapePropsMigrationIds } from "./TLShape"; //// createShapePropsMigrationIds/**/ // @Filename: /TLShape.ts //// import { T } from "@tldraw/validate"; //// //// /** //// * @public //// */ //// export function createShapePropsMigrationIds<T>(): { [k in keyof T]: any } { //// return; //// } verify.completions({ marker: "", includes: [ { name: "createShapePropsMigrationIds", text: "(alias) function createShapePropsMigrationIds<T>(): { [k in keyof T]: any; }\nimport createShapePropsMigrationIds", tags: [{ name: "public", text: undefined }] } ] }); goTo.file("/TLShape.ts"); verify.organizeImports( ` /** * @public */ export function createShapePropsMigrationIds<T>(): { [k in keyof T]: any } { return; }`);
{ "end_byte": 901, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/nodeArrayCloneCrash.ts" }
TypeScript/tests/cases/fourslash/navigationBarFunctionPrototypeNested.ts_0_4536
/// <reference path="fourslash.ts"/> // @Filename: foo.js ////function A() {} ////A.B = function () { } ////A.B.prototype.d = function () { } ////Object.defineProperty(A.B.prototype, "x", { //// get() {} ////}) ////A.prototype.D = function () { } ////A.prototype.D.prototype.d = function () { } verify.navigationTree({ "text": "<global>", "kind": "script", "spans": [ { "start": 0, "length": 216 } ], "childItems": [ { "text": "A", "kind": "class", "spans": [ { "start": 0, "length": 215 } ], "nameSpan": { "start": 9, "length": 1 }, "childItems": [ { "text": "constructor", "kind": "constructor", "spans": [ { "start": 0, "length": 15 } ] }, { "text": "B", "kind": "class", "spans": [ { "start": 22, "length": 114 } ], "nameSpan": { "start": 18, "length": 1 }, "childItems": [ { "text": "constructor", "kind": "constructor", "spans": [ { "start": 22, "length": 16 } ] }, { "text": "d", "kind": "function", "spans": [ { "start": 58, "length": 16 } ], "nameSpan": { "start": 54, "length": 1 } }, { "text": "x", "spans": [ { "start": 77, "length": 59 } ], "nameSpan": { "start": 114, "length": 3 }, "childItems": [ { "text": "get", "kind": "method", "spans": [ { "start": 125, "length": 8 } ], "nameSpan": { "start": 125, "length": 3 } } ] } ] }, { "text": "D", "kind": "class", "spans": [ { "start": 153, "length": 62 } ], "nameSpan": { "start": 149, "length": 1 }, "childItems": [ { "text": "constructor", "kind": "constructor", "spans": [ { "start": 153, "length": 16 } ] }, { "text": "d", "kind": "function", "spans": [ { "start": 199, "length": 16 } ], "nameSpan": { "start": 195, "length": 1 } } ] } ] } ] }, { checkSpans: true }); verify.navigationBar([ { "text": "<global>", "kind": "script", "childItems": [ { "text": "A", "kind": "class" } ] }, { "text": "A", "kind": "class", "childItems": [ { "text": "constructor", "kind": "constructor" }, { "text": "B", "kind": "class" }, { "text": "D", "kind": "class" } ], "indent": 1 }, { "text": "B", "kind": "class", "childItems": [ { "text": "constructor", "kind": "constructor" }, { "text": "d", "kind": "function" }, { "text": "x" } ], "indent": 2 }, { "text": "x", "childItems": [ { "text": "get", "kind": "method" } ], "indent": 3 }, { "text": "D", "kind": "class", "childItems": [ { "text": "constructor", "kind": "constructor" }, { "text": "d", "kind": "function" } ], "indent": 2 } ]);
{ "end_byte": 4536, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarFunctionPrototypeNested.ts" }
TypeScript/tests/cases/fourslash/extract-const_jsxAttribute1.ts_0_581
/// <reference path='fourslash.ts' /> // @jsx: preserve // @filename: a.tsx ////function Foo() { //// return ( //// <div> //// <a href=/*a*/"string"/*b*/></a>; //// </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 = "string"; function Foo() { return ( <div> <a href={newLocal}></a>; </div> ); }` });
{ "end_byte": 581, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const_jsxAttribute1.ts" }
TypeScript/tests/cases/fourslash/referencesForMergedDeclarations6.ts_0_310
/// <reference path='fourslash.ts'/> ////interface Foo { } /////*1*/module /*2*/Foo { //// export interface Bar { } //// export module Bar { export interface Baz { } } //// export function Bar() { } ////} //// ////// module ////import a1 = /*3*/Foo; verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 310, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForMergedDeclarations6.ts" }
TypeScript/tests/cases/fourslash/quickInfoStaticPrototypePropertyOnClass.ts_0_551
/// <reference path='fourslash.ts'/> ////class c1 { ////} ////class c2<T> { ////} ////class c3 { //// constructor() { //// } ////} ////class c4 { //// constructor(param: string); //// constructor(param: number); //// constructor(param: any) { //// } ////} ////c1./*1*/prototype; ////c2./*2*/prototype; ////c3./*3*/prototype; ////c4./*4*/prototype; verify.quickInfos({ 1: "(property) c1.prototype: c1", 2: "(property) c2<T>.prototype: c2<any>", 3: "(property) c3.prototype: c3", 4: "(property) c4.prototype: c4" });
{ "end_byte": 551, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoStaticPrototypePropertyOnClass.ts" }
TypeScript/tests/cases/fourslash/memberOverloadEdits.ts_0_402
/// <reference path='fourslash.ts' /> //// module M { //// export class A { //// public m(n: number) { //// return 0; //// } //// public n() { //// return this.m(0); //// } //// } //// export class B extends A { /*1*/ } //// } verify.noErrors(); goTo.marker('1'); edit.insert("public m(n: number) { return 0; }"); verify.noErrors();
{ "end_byte": 402, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberOverloadEdits.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingMember6.ts_0_416
/// <reference path='fourslash.ts' /> // @checkJs: true // @allowJs: true // @Filename: a.js ////class C { //// constructor() { //// } //// prop = ()=>{ this.foo === 10 }; ////} verify.codeFix({ description: "Initialize property 'foo' in the constructor", index: 0, newFileContent: `class C { constructor() { this.foo = undefined; } prop = ()=>{ this.foo === 10 }; }` });
{ "end_byte": 416, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember6.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixExistingImport11.ts_0_314
/// <reference path="fourslash.ts" /> ////import [|{ //// v1, v2, //// v3 ////}|] from "./module"; ////f1/*0*/(); // @Filename: module.ts //// export function f1() {} //// export var v1 = 5; //// export var v2 = 5; //// export var v3 = 5; verify.importFixAtPosition([ `{ f1, v1, v2, v3 }` ]);
{ "end_byte": 314, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixExistingImport11.ts" }
TypeScript/tests/cases/fourslash/refactorConvertExport_onlyValidIdentifiers.ts_0_627
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: /a.js /////*[| |]*/ /** x */ export default 1; // @Filename: /b.js /////*[| |]*/ /** x */ export default (1); // @Filename: /c.js /////*[| |]*/ /** x */ export default x; goTo.eachRange(r => { goTo.selectRange(r); verify.not.refactorAvailable("Convert export"); }); // goTo.selectRange(test.ranges()[0]); // edit.applyRefactor({ // refactorName: "Convert export", // actionName: "Convert default export to named export", // actionDescription: "Convert default export to named export", // newContent: { "/a.js": `...` }, // });
{ "end_byte": 627, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertExport_onlyValidIdentifiers.ts" }
TypeScript/tests/cases/fourslash/codeFixEnableJsxFlag_disabledInCompilerOptionsInJsConfig.ts_0_456
/// <reference path='fourslash.ts' /> // @Filename: /dir/a.tsx ////export const Component = () => <></>; // @Filename: /dir/jsconfig.json ////{ //// "compilerOptions": { //// "jsx": false, //// } ////} goTo.file("/dir/a.tsx"); verify.codeFix({ description: "Enable the '--jsx' flag in your configuration file", newFileContent: { "/dir/jsconfig.json": `{ "compilerOptions": { "jsx": "react", } }`, }, });
{ "end_byte": 456, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixEnableJsxFlag_disabledInCompilerOptionsInJsConfig.ts" }
TypeScript/tests/cases/fourslash/completionEntryForClassMembers_StaticWhenBaseTypeIsNotResolved.ts_0_1067
/// <reference path="fourslash.ts" /> // @Filename: /node_modules/@types/react/index.d.ts //// export = React; //// export as namespace React; //// declare namespace React { //// function createElement(): any; //// interface Component<P = {}, S = {}, SS = any> { } //// class Component<P, S> { //// static contextType?: any; //// context: any; //// constructor(props: Readonly<P>); //// setState<K extends keyof S>( //// state: ((prevState: Readonly<S>, props: Readonly<P>) => (Pick<S, K> | S | null)) | (Pick<S, K> | S | null), //// callback?: () => void //// ): void; //// } //// } // @Filename: /a.ts //// import React from 'react' //// class Slider extends React.Component { //// static defau/**/ltProps = { //// onMouseDown: () => { }, //// onMouseUp: () => { }, //// unit: 'px', //// } //// handleChange = () => 10; //// } verify.completions({ marker: "", isNewIdentifierLocation: true, exact: completion.classElementKeywords, });
{ "end_byte": 1067, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionEntryForClassMembers_StaticWhenBaseTypeIsNotResolved.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterface.ts_0_172
/// <reference path='fourslash.ts' /> /////*1*/interface /*2*/I { //// p: number; ////} ////let i: /*3*/I = { p: 12 }; verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 172, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterface.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImportsReExports.ts_0_630
/// <reference path='fourslash.ts' /> // @Filename: node_modules/test-module/index.d.ts ////declare namespace e { //// interface Foo {} ////} ////export = e; // @Filename: a.ts ////import { Foo } from "test-module"; ////export interface A { //// foo(): Foo; ////} // @Filename: b.ts ////import { A } from "./a"; ////export class B implements A {} goTo.file("b.ts"); verify.codeFix({ description: "Implement interface 'A'", newFileContent: `import { Foo } from "test-module"; import { A } from "./a"; export class B implements A { foo(): Foo { throw new Error("Method not implemented."); } }` });
{ "end_byte": 630, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImportsReExports.ts" }
TypeScript/tests/cases/fourslash/tsxRename8.ts_0_719
/// <reference path='fourslash.ts' /> /// <reference path='fourslash.ts' /> //@Filename: file.tsx // @jsx: preserve // @noLib: true //// declare module JSX { //// interface Element { } //// interface IntrinsicElements { //// } //// interface ElementAttributesProperty { props; } //// } //// interface OptionPropBag { //// propx: number //// propString: string //// optional?: boolean //// } //// declare function Opt(attributes: OptionPropBag): JSX.Element; //// let opt = <Opt />; //// let opt1 = <Opt propx={100} propString />; //// let opt2 = <Opt propx={100} optional/>; //// let opt3 = <Opt [|wrong|] />; //// let opt4 = <Opt propx={100} propString="hi" />; verify.baselineRename();
{ "end_byte": 719, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxRename8.ts" }
TypeScript/tests/cases/fourslash/goToImplementationThis_01.ts_0_275
/// <reference path='fourslash.ts'/> // Should go to class declaration when invoked on a this type reference //// class [|Bar|] extends Foo { //// hello(): th/*this_type*/is { //// return this; //// } //// } verify.baselineGoToImplementation("this_type");
{ "end_byte": 275, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationThis_01.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionRest.ts_1_243
/// <reference path='fourslash.ts'/> ////interface Gen { //// x: number; //// /*1*/parent: Gen; //// millenial: string; ////} ////let t: Gen; ////var { x, ...rest } = t; ////rest.[|/*2*/parent|]; verify.baselineGoToDefinition('2');
{ "end_byte": 243, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionRest.ts" }
TypeScript/tests/cases/fourslash/completionListInComments2.ts_0_183
/// <reference path='fourslash.ts' /> //// // */{| "name" : "1" |} // Completion list should not be available within comments verify.completions({ marker: "1", exact: undefined });
{ "end_byte": 183, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInComments2.ts" }
TypeScript/tests/cases/fourslash/goToImplementationClassMethod_01.ts_0_417
/// <reference path='fourslash.ts'/> // Should handle calls made on member declared in an abstract class //// abstract class AbstractBar { //// abstract he/*declaration*/llo(): void; //// } //// //// class Bar extends AbstractBar{ //// [|hello|]() {} //// } //// //// function whatever(x: AbstractBar) { //// x.he/*reference*/llo(); //// } verify.baselineGoToImplementation("reference", "declaration");
{ "end_byte": 417, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationClassMethod_01.ts" }
TypeScript/tests/cases/fourslash/completionListAtEOF.ts_0_224
/// <reference path='fourslash.ts' /> ////var a; goTo.eof(); verify.completions({ includes: "a" }); edit.insertLine(""); verify.completions({ includes: "a" }); edit.insertLine(""); verify.completions({ includes: "a" });
{ "end_byte": 224, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtEOF.ts" }
TypeScript/tests/cases/fourslash/completionsImportModuleAugmentationWithJS.ts_0_670
// #37833 /// <reference path="fourslash.ts" /> // @allowJs: true // @checkJs: true // @noEmit: true // @Filename: /test.js ////class Abcde { //// x ////} //// ////module.exports = { //// Abcde ////}; // @Filename: /index.ts ////export {}; ////declare module "./test" { //// interface Abcde { b: string } ////} //// ////Abcde/**/ verify.applyCodeActionFromCompletion("", { name: "Abcde", source: "/test", description: `Add import from "./test"`, newFileContent: `import { Abcde } from "./test"; export {}; declare module "./test" { interface Abcde { b: string } } Abcde`, preferences: { includeCompletionsForModuleExports: true } });
{ "end_byte": 670, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImportModuleAugmentationWithJS.ts" }
TypeScript/tests/cases/fourslash/syntacticClassificationsDocComment1.ts_0_530
/// <reference path="fourslash.ts"/> //// /** @type {number} */ //// var v; const c = classification("original"); verify.syntacticClassificationsAre( c.comment("/** "), c.punctuation("@"), c.docCommentTagName("type"), c.punctuation("{"), c.keyword("number"), c.punctuation("}"), c.comment("*/"), c.keyword("var"), c.identifier("v"), c.punctuation(";")); const c2 = classification("2020"); verify.semanticClassificationsAre("2020", c2.semanticToken("variable.declaration", "v"), );
{ "end_byte": 530, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsDocComment1.ts" }
TypeScript/tests/cases/fourslash/smartSelection_comment1.ts_0_112
/// <reference path="fourslash.ts" /> ////const a = 1; ///**/comment content verify.baselineSmartSelection();
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_comment1.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionExternalModuleName8.ts_0_213
/// <reference path='fourslash.ts'/> // @Filename: b.ts ////export {Foo, Bar} from [|'e/*1*/'|]; // @Filename: a.ts ////declare module /*2*/"e" { //// class Foo { } ////} verify.baselineGoToDefinition("1");
{ "end_byte": 213, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionExternalModuleName8.ts" }
TypeScript/tests/cases/fourslash/jsconfig.ts_0_289
/// <reference path="fourslash.ts" /> // @Filename: /a.js ////function f(/**/x) { ////} // @Filename: /jsconfig.json ////{ //// "compilerOptions": { //// "checkJs": true, //// "noImplicitAny": true //// } ////} goTo.file("/a.js"); verify.errorExistsAfterMarker("");
{ "end_byte": 289, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsconfig.ts" }
TypeScript/tests/cases/fourslash/goToTypeDefinition.ts_0_265
/// <reference path='fourslash.ts' /> // @Filename: goToTypeDefinition_Definition.ts ////class /*definition*/C { //// p; ////} ////var c: C; // @Filename: goToTypeDefinition_Consumption.ts /////*reference*/c = undefined; verify.baselineGoToType("reference");
{ "end_byte": 265, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToTypeDefinition.ts" }
TypeScript/tests/cases/fourslash/codeFixImportNonExportedMember11.ts_0_400
/// <reference path="fourslash.ts" /> // @module: esnext // @isolatedModules: true // @filename: /a.ts ////type T = {}; ////export {}; // @filename: /b.ts ////import { T } from "./a"; goTo.file("/b.ts"); verify.codeFix({ description: [ts.Diagnostics.Export_0_from_module_1.message, "T", "./a"], index: 0, newFileContent: { "/a.ts": `type T = {}; export { type T };`, } });
{ "end_byte": 400, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImportNonExportedMember11.ts" }
TypeScript/tests/cases/fourslash/renameStringLiteralTypes5.ts_0_205
/// <reference path="fourslash.ts" /> ////type T = { //// "Prop 1": string; ////} //// ////declare const fn: <K extends keyof T>(p: K) => void //// ////fn("Prop 1"/**/) verify.baselineRename("", {});
{ "end_byte": 205, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameStringLiteralTypes5.ts" }
TypeScript/tests/cases/fourslash/completionsJSDocNoCrash2.ts_0_827
/// <reference path='fourslash.ts' /> // @strict: true // @filename: index.ts //// /** //// * @example //// <file name="glyphicons.css"> //// @import url(//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css); //// </file> //// <example module="ngAnimate" deps="angular-animate.js" animations="true"> //// <file name="animations.css"> //// .animate-show.ng-hide-add.ng-hide-add-active, //// .animate-show.ng-hide-remove.ng-hide-remove-active { //// transition:all linear 0./**/5s; //// } //// </file> //// </example> //// */ //// var ngShowDirective = ['$animate', function($animate) {}]; verify.completions({ marker: "", exact: completion.globalTypes, isNewIdentifierLocation: false, preferences: { includeCompletionsWithInsertText: true } });
{ "end_byte": 827, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsJSDocNoCrash2.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess3.ts_0_508
/// <reference path='fourslash.ts' /> //// class A { //// /*a*/private a: string;/*b*/ //// } goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Generate 'get' and 'set' accessors", actionName: "Generate 'get' and 'set' accessors", actionDescription: "Generate 'get' and 'set' accessors", newContent: `class A { private /*RENAME*/_a: string; public get a(): string { return this._a; } public set a(value: string) { this._a = value; } }`, });
{ "end_byte": 508, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess3.ts" }
TypeScript/tests/cases/fourslash/completionsImport_matching.ts_0_856
/// <reference path="fourslash.ts" /> // @module: esnext // @Filename: /a.ts // Not included: ////export function abcde() {} ////export function dbf() {} ////export function bdf() {} ////export function abcdef() {} // Included: ////export function aBcdef() {} ////export function a_bcdef() {} ////export function BDF() {} // @Filename: /b.ts ////bdf/**/ verify.completions({ marker: "", includes: ["aBcdef", "a_bcdef", "BDF"].map(name => ({ name, source: "/a", text: `function ${name}(): void`, hasAction: true, kind: "function", kindModifiers: "export", sourceDisplay: "./a", sortText: completion.SortText.AutoImportSuggestions })), excludes: ["abcde", "dbf"], preferences: { includeCompletionsForModuleExports: true }, })
{ "end_byte": 856, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_matching.ts" }
TypeScript/tests/cases/fourslash/insertVarAfterEmptyTypeParamList.ts_0_131
/// <reference path="fourslash.ts" /> //// class Dictionary<> { } //// var x; //// /**/ goTo.marker(); edit.insert("var y;\n");
{ "end_byte": 131, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/insertVarAfterEmptyTypeParamList.ts" }
TypeScript/tests/cases/fourslash/completionsUniqueSymbol1.ts_0_515
/// <reference path="fourslash.ts" /> ////declare const Symbol: () => symbol; ////namespace M { //// export const sym = Symbol(); ////} ////namespace N { //// const sym = Symbol(); //// export interface I { //// [sym]: number; //// [M.sym]: number; //// } ////} //// ////declare const i: N.I; ////i[|./**/|]; verify.completions({ marker: "", exact: { name: "M", insertText: "[M]", replacementSpan: test.ranges()[0] }, preferences: { includeInsertTextCompletions: true }, });
{ "end_byte": 515, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsUniqueSymbol1.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageVariable2JS.ts_0_347
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @noEmit: true // @noImplicitAny: true // @Filename: important.js ////[|var x; ////function f() { //// x++; ////}|] verify.rangeAfterCodeFix(`/** * @type {number} */ var x; function f() { x++; } `, /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, 0);
{ "end_byte": 347, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageVariable2JS.ts" }
TypeScript/tests/cases/fourslash/duplicateIndexers.ts_0_199
/// <reference path='fourslash.ts'/> ////interface I { //// [x: number]: string; //// [x: number]: number; ////} ////var i: I; ////var /**/r = i[1]; verify.quickInfoAt("", "var r: string");
{ "end_byte": 199, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/duplicateIndexers.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingCallParentheses12.ts_0_450
/// <reference path='fourslash.ts'/> // @strictNullChecks: true ////function foo(fn: () => boolean) { //// fn/**/ && console.log('test'); ////} verify.codeFixAvailable([ { description: ts.Diagnostics.Add_missing_call_parentheses.message } ]); verify.codeFix({ description: ts.Diagnostics.Add_missing_call_parentheses.message, index: 0, newFileContent: `function foo(fn: () => boolean) { fn() && console.log('test'); }`, });
{ "end_byte": 450, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingCallParentheses12.ts" }
TypeScript/tests/cases/fourslash/removeDeclareFunctionExports.ts_0_245
/// <reference path="fourslash.ts" /> ////declare module M { //// function RegExp2(pattern: string): RegExp2; //// export function RegExp2(pattern: string, flags: string): RegExp2; ////} goTo.bof(); edit.deleteAtCaret('declare '.length);
{ "end_byte": 245, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/removeDeclareFunctionExports.ts" }
TypeScript/tests/cases/fourslash/completionsWithDeprecatedTag4.ts_0_476
/// <reference path="fourslash.ts" /> // @noLib: true ////f({ //// a/**/ //// xyz: ``, ////}); ////declare function f(options: { //// /** @deprecated abc */ //// abc?: number, //// xyz?: string ////}): void; verify.completions({ marker: "", exact: [{ name: "abc", kind: "property", kindModifiers: "deprecated,declare,optional", sortText: completion.SortText.Deprecated(completion.SortText.OptionalMember), }], });
{ "end_byte": 476, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsWithDeprecatedTag4.ts" }
TypeScript/tests/cases/fourslash/stringLiteralCompletionsForOpenEndedTemplateLiteralType.ts_0_282
/// <reference path="fourslash.ts" /> //// function conversionTest(groupName: | "downcast" | "dataDowncast" | "editingDowncast" | `${string}Downcast` & {}) {} //// conversionTest("/**/"); verify.completions({ marker: "", exact: ["downcast", "dataDowncast", "editingDowncast"] });
{ "end_byte": 282, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/stringLiteralCompletionsForOpenEndedTemplateLiteralType.ts" }
TypeScript/tests/cases/fourslash/getEmitOutputWithEmitterErrors2.ts_0_295
/// <reference path="fourslash.ts" /> // @BaselineFile: getEmitOutputWithEmitterErrors2.baseline // @declaration: true // @module: AMD // @Filename: inputFile.ts // @emitThisFile: true ////class C { } ////export module M { //// export var foo = new C(); ////} verify.baselineGetEmitOutput();
{ "end_byte": 295, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputWithEmitterErrors2.ts" }
TypeScript/tests/cases/fourslash/uncommentSelection4.ts_0_958
// Remove all comments in jsx. //@Filename: file.tsx //// const var1 = <div>Tex{/*t1</div>; //// const var2 = <div>Text2[|</div>; //// const var3 = <div>Tex*/}t3</div>;|] //// //// [|const var4 = <div>Tex{/*t4</div>; //// const var5 = <div|]>Text5</div>; //// const var6 = <div>Tex*/}t6</div>; //// //// [|const var7 = <div>Tex{/*t7</div>; //// const var8 = <div>Text8</div>; //// const var9 = <div>Tex*/}t9</div>;|] //// //// const var10 = <div> //// {/*<div>T[|ext</div>*/} //// <div>Text</div> //// {/*<div>Text|]</div>*/} //// </div>; verify.uncommentSelection( `const var1 = <div>Text1</div>; const var2 = <div>Text2</div>; const var3 = <div>Text3</div>; const var4 = <div>Text4</div>; const var5 = <div>Text5</div>; const var6 = <div>Text6</div>; const var7 = <div>Text7</div>; const var8 = <div>Text8</div>; const var9 = <div>Text9</div>; const var10 = <div> <div>Text</div> <div>Text</div> <div>Text</div> </div>;` );
{ "end_byte": 958, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/uncommentSelection4.ts" }
TypeScript/tests/cases/fourslash/codeFixSpellingCaseSensitive4.ts_0_591
/// <reference path='fourslash.ts' /> //// declare let a: numbers; //// declare let b: Numbers; //// declare let c: objects; //// declare let d: Objects; //// declare let e: RegEx; //// namespace yadda { //// export type Thing = string; //// } //// let f: yaddas.Thing; verify.codeFixAll({ fixId: "fixSpelling", fixAllDescription: "Fix all detected spelling errors", newFileContent: `declare let a: number; declare let b: Number; declare let c: object; declare let d: Object; declare let e: RegExp; namespace yadda { export type Thing = string; } let f: yadda.Thing;`, });
{ "end_byte": 591, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingCaseSensitive4.ts" }
TypeScript/tests/cases/fourslash/arrayConcatTypeCheck0.ts_0_250
/// <reference path="fourslash.ts" /> //// var a = []; //// a.concat("hello"/*1*/); //// //// a.concat('Hello'); //// //// var b = new Array(); //// b.concat('hello'); //// edit.disableFormatting(); goTo.marker('1'); edit.insert(", 'world'");
{ "end_byte": 250, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/arrayConcatTypeCheck0.ts" }
TypeScript/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType.ts_0_635
/// <reference path='fourslash.ts' /> // @Filename: a.ts ////export interface A { //// x: number; ////} ////export function create(fn: (args: A) => void) {} // @Filename: b.ts ////import { create } from "./a"; ////class B { //// bar() { //// create(args => this.foo(args)); //// } ////} goTo.file("b.ts"); verify.codeFix({ description: [ts.Diagnostics.Declare_method_0.message, "foo"], index: 0, newFileContent: `import { A, create } from "./a"; class B { bar() { create(args => this.foo(args)); } foo(args: A): void { throw new Error("Method not implemented."); } }` });
{ "end_byte": 635, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType.ts" }
TypeScript/tests/cases/fourslash/completionsRecommended_equals.ts_0_249
/// <reference path="fourslash.ts" /> ////enum Enu {} ////declare const e: Enu; ////e === /*a*/; ////e === E/*b*/ verify.completions({ marker: ["a", "b"], includes: { name: "Enu", text: "enum Enu", kind: "enum", isRecommended: true }, });
{ "end_byte": 249, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsRecommended_equals.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics7.ts_0_133
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: a.js ////module M { } verify.baselineSyntacticDiagnostics();
{ "end_byte": 133, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics7.ts" }
TypeScript/tests/cases/fourslash/constraintRegionCheck.ts_0_671
/// <reference path="fourslash.ts" /> // @strict: true // @Filename: index.ts //// export {}; //// interface JsonArray extends Array<JsonValue> {} //// interface JsonObject { //// [prop: string]: JsonValue; //// } //// type JsonValue = boolean | string | number | JsonArray | JsonObject | null; //// type Cons<T extends JsonValue> = T; //// [|function foo<I extends any>(): Cons<I> { //// return {} as any; //// }|] //// /*e*/ const [r0] = test.ranges(); // Baseline const expected = test.getSemanticDiagnostics(); // Reset checker goTo.marker("e"); edit.insert(" "); verify.getRegionSemanticDiagnostics([r0], expected); verify.getSemanticDiagnostics(expected);
{ "end_byte": 671, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/constraintRegionCheck.ts" }
TypeScript/tests/cases/fourslash/codeFixIncorrectNamedTupleSyntax2.ts_0_254
/// <reference path='fourslash.ts' /> ////type Tup = [first: string, elem: any[]?]; verify.codeFix({ description: "Move labeled tuple element modifiers to labels", index: 0, newFileContent: `type Tup = [first: string, elem?: any[]];` });
{ "end_byte": 254, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixIncorrectNamedTupleSyntax2.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationBreakOrContinue.ts_0_353
/// <reference path='fourslash.ts' /> // @BaselineFile: bpSpan_breakOrContinue.baseline // @Filename: bpSpan_breakOrContinue.ts ////while (true) { //// break; ////} ////y: while (true) { //// break y; ////} ////while (true) { //// continue; ////} ////z: while (true) { //// continue z; ////} verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 353, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationBreakOrContinue.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesExport3.ts_0_1580
/// <reference path='fourslash.ts' /> //// ////declare var x; ////[|export|] declare var y, z; //// ////module m { //// export class C1 { //// public pub1; //// public pub2; //// private priv1; //// private priv2; //// protected prot1; //// protected prot2; //// //// public public; //// private private; //// protected protected; //// //// public constructor(public a, private b, protected c, public d, private e, protected f) { //// this.public = 10; //// this.private = 10; //// this.protected = 10; //// } //// //// public get x() { return 10; } //// public set x(value) { } //// //// public static statPub; //// private static statPriv; //// protected static statProt; //// } //// //// export interface I1 { //// } //// //// export declare module ma.m1.m2.m3 { //// interface I2 { //// } //// } //// //// export module mb.m1.m2.m3 { //// declare var foo; //// //// export class C2 { //// public pub1; //// private priv1; //// protected prot1; //// //// protected constructor(public public, protected protected, private private) { //// } //// } //// } //// //// declare var ambientThing: number; //// export var exportedThing = 10; //// declare function foo(): string; ////} //// ////declare [|export|] var v1, v2; ////declare module dm { } ////[|export|] class EC { } verify.baselineDocumentHighlights();
{ "end_byte": 1580, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesExport3.ts" }
TypeScript/tests/cases/fourslash/importJsNodeModule2.ts_0_711
///<reference path="fourslash.ts" /> // @allowJs: true // @Filename: node_modules/myMod/package.json //// {"main": "entry.js"} // @Filename: node_modules/myMod/entry.js //// module.exports = { n: 3, s: 'foo', b: true }; // @Filename: consumer.js //// var x = require('myMod'); //// x/**/; goTo.file('consumer.js'); goTo.marker(); edit.insert('.'); verify.completions({ unsorted: [ ...["n", "s", "b"].map(name => ({ name, kind: "property" })), ...["x", "require"].map(name => ({ name, kind: "warning", sortText: completion.SortText.JavascriptIdentifiers })), ], }); edit.insert('n.'); verify.completions({ includes: { name: "toFixed", kind: "method", kindModifiers: "declare" } });
{ "end_byte": 711, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importJsNodeModule2.ts" }
TypeScript/tests/cases/fourslash/codeFixSpellingCaseWeight1.ts_0_181
/// <reference path='fourslash.ts' /> ////let ABCDEFGHIJKLMNOPQR = 1; ////let abcdefghijklmnopqrs = 1; ////[|abcdefghijklmnopqr|] verify.rangeAfterCodeFix('abcdefghijklmnopqrs');
{ "end_byte": 181, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingCaseWeight1.ts" }
TypeScript/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts_0_323
/// <reference path='fourslash.ts'/> // @Filename: file1.ts ////var foo = /*1*/function /*2*/foo(a = /*3*/foo(), b = () => /*4*/foo) { //// /*5*/foo(/*6*/foo, /*7*/foo); ////} // @Filename: file2.ts /////// <reference path="file1.ts" /> ////foo(); verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6', '7');
{ "end_byte": 323, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixExistingImport9.ts_0_242
/// <reference path="fourslash.ts" /> //// import [|{ //// v1 //// }|] from "./module"; //// f1/*0*/(); // @Filename: module.ts //// export function f1() {} //// export var v1 = 5; verify.importFixAtPosition([ `{ f1, v1 }` ]);
{ "end_byte": 242, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixExistingImport9.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionOverriddenMember14.ts_0_235
/// <reference path="./fourslash.ts"/> // @noImplicitOverride: true ////class A { //// /*2*/m() {} ////} ////class B extends A {} ////class C extends B { //// [|/*1*/override|] m() {} ////} verify.baselineGoToDefinition("1");
{ "end_byte": 235, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionOverriddenMember14.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_HeaderComment1.ts_0_465
/// <reference path="fourslash.ts" /> // @Filename: /a.ts ////export const foo = 0; // @Filename: /b.ts ////export const bar = 0; // @Filename: /c.ts /////*-------------------- //// * Copyright Header //// *--------------------*/ //// ////import { bar } from "./b"; ////foo; goTo.file("/c.ts"); verify.importFixAtPosition([ `/*-------------------- * Copyright Header *--------------------*/ import { foo } from "./a"; import { bar } from "./b"; foo;`, ]);
{ "end_byte": 465, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_HeaderComment1.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageMethodSignature.ts_0_948
/// <reference path='fourslash.ts' /> ////interface Options { //// run(a, b, c, d, e, f): void; ////} //// ////interface I { //// x: number; ////} //// ////enum E { //// X ////} //// ////function foo(options: Options) { //// const a = 1; //// const b = ""; //// const c = { x: 1, y: 1 }; //// const d = [1, 2, 3]; //// const e: I = { x: 1 }; //// const f: E = E.X; //// //// options.run(a, b, c, d, e, f); ////} verify.codeFixAll({ fixId: "inferFromUsage", fixAllDescription: "Infer all types from usage", newFileContent: `interface Options { run(a: number, b: string, c: { x: number; y: number; }, d: number[], e: I, f: E): void; } interface I { x: number; } enum E { X } function foo(options: Options) { const a = 1; const b = ""; const c = { x: 1, y: 1 }; const d = [1, 2, 3]; const e: I = { x: 1 }; const f: E = E.X; options.run(a, b, c, d, e, f); }`, });
{ "end_byte": 948, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageMethodSignature.ts" }
TypeScript/tests/cases/fourslash/javaScriptClass1.ts_0_865
///<reference path="fourslash.ts" /> // Classes have their shape inferred from assignments // to properties of 'this' in the constructor // @allowNonTsExtensions: true // @Filename: Foo.js //// class Foo { //// constructor() { //// this.bar = 'world'; //// this.thing = () => 0; //// this.union = 'foo'; //// this.union = 100; //// } //// } //// var x = new Foo(); //// x/**/ goTo.marker(); edit.insert('.'); verify.completions({ exact: [ "bar", "thing", "union", { name: "Foo", sortText: completion.SortText.JavascriptIdentifiers }, { name: "x", sortText: completion.SortText.JavascriptIdentifiers } ] }); edit.insert('bar.'); verify.completions({ includes: ["substring"] }); edit.backspace('bar.'.length); edit.insert('union.'); verify.completions({ includes: "toString" });
{ "end_byte": 865, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javaScriptClass1.ts" }
TypeScript/tests/cases/fourslash/unusedVariableInBlocks.ts_0_302
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true ////function f1 () { //// [|let x = 10; //// { //// let x = 11; //// } //// x;|] ////} verify.codeFix({ description: "Remove unused declaration for: 'x'", newRangeContent: `let x = 10; { } x;`, });
{ "end_byte": 302, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedVariableInBlocks.ts" }
TypeScript/tests/cases/fourslash/mapCodeNestedForOfReplacement.ts_0_366
///<reference path="fourslash.ts"/> // @Filename: /index.ts //// function foo() { //// for (const x of [1, 2, 3]) [||]{ //// console.log("hello"); //// console.log("you"); //// } //// return 1; //// } //// verify.baselineMapCode([test.ranges()], [ ` for (const x of [1, 2, 3]) { console.log("goodbye"); console.log("world"); } ` ]);
{ "end_byte": 366, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeNestedForOfReplacement.ts" }
TypeScript/tests/cases/fourslash/restParamsContextuallyTyped.ts_0_213
/// <reference path='fourslash.ts' /> ////var foo: Function = function (/*1*/a, /*2*/b, /*3*/c) { }; verify.quickInfos({ 1: "(parameter) a: any", 2: "(parameter) b: any", 3: "(parameter) c: any" });
{ "end_byte": 213, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/restParamsContextuallyTyped.ts" }
TypeScript/tests/cases/fourslash/refactorConvertImport_namedToNamespace2.ts_0_640
/// <reference path='fourslash.ts' /> ////import foo, /*a*/{ a, b, c as d }/*b*/ from "./foo"; ////a; ////b; ////d; ////foo; ////export default a; ////export { b }; ////export { d }; ////export { foo }; goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert import", actionName: "Convert named imports to namespace import", actionDescription: "Convert named imports to namespace import", triggerReason: "invoked", newContent: `import foo, * as foo_1 from "./foo"; import { b, c as d } from "./foo"; foo_1.a; foo_1.b; foo_1.c; foo; export default foo_1.a; export { b }; export { d }; export { foo };`, });
{ "end_byte": 640, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertImport_namedToNamespace2.ts" }
TypeScript/tests/cases/fourslash/formattingCrash.ts_0_284
/// <reference path='fourslash.ts' /> /////**/module Default{ ////} format.setOption("PlaceOpenBraceOnNewLineForFunctions", true); format.setOption("PlaceOpenBraceOnNewLineForControlBlocks", true); format.document(); goTo.marker(); verify.currentLineContentIs('module Default');
{ "end_byte": 284, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingCrash.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportPaths2.ts_0_507
/// <reference path="fourslash.ts" /> //// [|foo/*0*/();|] // @Filename: folder_b/index.ts //// export function foo() {}; // @Filename: tsconfig.path.json //// { //// "compilerOptions": { //// "baseUrl": ".", //// "paths": { //// "b": [ "folder_b/index" ] //// } //// } //// } // @Filename: tsconfig.json //// { //// "extends": "./tsconfig.path", //// "compilerOptions": { } //// } verify.importFixAtPosition([ `import { foo } from "b"; foo();` ]);
{ "end_byte": 507, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportPaths2.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesThis5.ts_0_2935
/// <reference path='fourslash.ts' /> ////this; ////this; //// ////function f() { //// this; //// this; //// () => this; //// () => { //// if (this) { //// this; //// } //// else { //// this.this; //// } //// } //// function inside() { //// this; //// (function (_) { //// this; //// })(this); //// } ////} //// ////module m { //// function f() { //// this; //// this; //// () => this; //// () => { //// if (this) { //// this; //// } //// else { //// this.this; //// } //// } //// function inside() { //// this; //// (function (_) { //// this; //// })(this); //// } //// } ////} //// ////class A { //// public b = this.method1; //// //// public method1() { //// this; //// this; //// () => this; //// () => { //// if (this) { //// this; //// } //// else { //// this.this; //// } //// } //// function inside() { //// this; //// (function (_) { //// this; //// })(this); //// } //// } //// //// private method2() { //// this; //// this; //// () => this; //// () => { //// if (this) { //// this; //// } //// else { //// this.this; //// } //// } //// function inside() { //// this; //// (function (_) { //// this; //// })(this); //// } //// } //// //// public static staticB = [|this|].staticMethod1; //// //// public static staticMethod1() { //// [|this|]; //// [|this|]; //// () => [|this|]; //// () => { //// if ([|this|]) { //// [|this|]; //// } //// else { //// [|this|].this; //// } //// } //// function inside() { //// this; //// (function (_) { //// this; //// })(this); //// } //// } //// //// private static staticMethod2() { //// [|this|]; //// [|this|]; //// () => [|this|]; //// () => { //// if ([|this|]) { //// [|this|]; //// } //// else { //// [|t/**/his|].this; //// } //// } //// function inside() { //// this; //// (function (_) { //// this; //// })(this); //// } //// } ////} //// ////var x = { //// f() { //// this; //// }, //// g() { //// this; //// } ////} verify.baselineDocumentHighlights();
{ "end_byte": 2935, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesThis5.ts" }
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsClassAutoAccessors.ts_0_1270
/// <reference path='fourslash.ts'/> ////class c { //// public accessor /*1a*/publicProperty: string; //// private accessor /*2a*/privateProperty: string; //// protected accessor /*3a*/protectedProperty: string; //// static accessor /*4a*/staticProperty: string; //// private static accessor /*5a*/privateStaticProperty: string; //// protected static accessor /*6a*/protectedStaticProperty: string; //// method() { //// var x: string; //// x = this./*1g*/publicProperty; //// x = this./*2g*/privateProperty; //// x = this./*3g*/protectedProperty; //// x = c./*4g*/staticProperty; //// x = c./*5g*/privateStaticProperty; //// x = c./*6g*/protectedStaticProperty; //// this./*1s*/publicProperty = ""; //// this./*2s*/privateProperty = ""; //// this./*3s*/protectedProperty = ""; //// c./*4s*/staticProperty = ""; //// c./*5s*/privateStaticProperty = ""; //// c./*6s*/protectedStaticProperty = ""; //// } ////} ////var cInstance = new c(); ////var y: string; ////y = /*7g*/cInstance./*8g*/publicProperty; ////y = /*9g*/c./*10g*/staticProperty; /////*7s*/cInstance./*8s*/publicProperty = y; /////*9s*/c./*10s*/staticProperty = y; verify.baselineQuickInfo();
{ "end_byte": 1270, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsClassAutoAccessors.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties7.ts_0_396
/// <reference path='fourslash.ts' /> ////enum E1 { //// A, B ////} ////enum E2 { //// A ////} ////enum E3 { ////} ////interface I { //// x: E1; //// y: E2; //// z: E3; ////} ////[|const foo: I = {};|] verify.codeFix({ index: 0, description: ts.Diagnostics.Add_missing_properties.message, newRangeContent: `const foo: I = { x: E1.A, y: E2.A, z: 0 };` });
{ "end_byte": 396, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties7.ts" }
TypeScript/tests/cases/fourslash/codeCompletionEscaping.ts_0_359
/// <reference path="fourslash.ts" /> // @Filename: a.js // @allowJs: true ////___foo; __foo;/**/ verify.completions({ marker: "", includes: [ { name: "__foo", kind: "warning", sortText: completion.SortText.JavascriptIdentifiers }, { name: "___foo", kind: "warning", sortText: completion.SortText.JavascriptIdentifiers }, ], });
{ "end_byte": 359, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeCompletionEscaping.ts" }
TypeScript/tests/cases/fourslash/extract-const1.ts_0_320
/// <reference path='fourslash.ts' /> ////const x = /*a*/0/*b*/; goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "constant_scope_0", actionDescription: "Extract to constant in enclosing scope", newContent: `const newLocal = 0; const x = /*RENAME*/newLocal;` });
{ "end_byte": 320, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const1.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts_0_383
/// <reference path='fourslash.ts' /> ////interface I { //// f(x: number, y: this): I ////} //// ////class C implements I {[| |]} verify.codeFix({ description: "Implement interface 'I'", newFileContent: `interface I { f(x: number, y: this): I } class C implements I { f(x: number, y: this): I { throw new Error("Method not implemented."); } }`, });
{ "end_byte": 383, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts" }
TypeScript/tests/cases/fourslash/getEditsForFileRename_unresolvableNodeModule.ts_0_354
/// <reference path="fourslash.ts" /> // @allowJs: true // @checkJs: true // @Filename: /modules/@app/something/index.js //// import "doesnt-exist"; // @Filename: /modules/@local/foo.js //// import "doesnt-exist"; verify.getEditsForFileRename({ oldPath: "/modules/@app/something", newPath: "/modules/@app/something-2", newFileContents: {} });
{ "end_byte": 354, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_unresolvableNodeModule.ts" }
TypeScript/tests/cases/fourslash/formatOnEnterFunctionDeclaration.ts_0_239
/// <reference path="fourslash.ts"/> /////*0*/function listAPIFiles(path: string): string[] {/*1*/ } goTo.marker("1"); edit.insertLine(""); goTo.marker("0"); verify.currentLineContentIs("function listAPIFiles(path: string): string[] {");
{ "end_byte": 239, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatOnEnterFunctionDeclaration.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingCallParentheses1.ts_0_472
/// <reference path='fourslash.ts'/> // @strictNullChecks: true ////function foo(fn: () => boolean) { //// fn/**/ ? console.log('test') : undefined; ////} verify.codeFixAvailable([ { description: ts.Diagnostics.Add_missing_call_parentheses.message } ]); verify.codeFix({ description: ts.Diagnostics.Add_missing_call_parentheses.message, index: 0, newFileContent: `function foo(fn: () => boolean) { fn() ? console.log('test') : undefined; }`, });
{ "end_byte": 472, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingCallParentheses1.ts" }
TypeScript/tests/cases/fourslash/linkedEditingJsxTag5.ts_0_1310
/// <reference path='fourslash.ts' /> // @FileName: /unclosedElement.tsx ////const jsx = ( //// <div/*0*/> //// <div/*1*/> //// </div/*2*/>/*3*/ ////);/*4*/ // @FileName: /mismatchedElement.tsx ////const jsx = ( //// /*5*/<div/*6*/> //// </div/*7*/> //// </*8*//div/*9*/>/*10*/ ////); // @Filename: /invalidClosing.tsx ////const jsx = ( //// <di/*11*/v> //// </*12*/ //*13*/div> ////); const wordPattern = "[a-zA-Z0-9:\\-\\._$]*"; const startPos1 = test.markerByName("1").position - 3; const endPos1 = test.markerByName("2").position - 3; const linkedCursors1 = { ranges: [{ start: startPos1, length: 3 }, { start: endPos1, length: 3 }], wordPattern, }; const startPos2 = test.markerByName("6").position - 3; const endPos2 = test.markerByName("7").position - 3; const linkedCursors2 = { ranges: [{ start: startPos2, length: 3 }, { start: endPos2, length: 3 }], wordPattern, }; verify.linkedEditing( { "0": undefined, "1": linkedCursors1, "2": linkedCursors1, "3": undefined, "4": undefined, "5": undefined, "6": linkedCursors2, "7": linkedCursors2, "8": undefined, "9": undefined, "10": undefined, "11": undefined, // this tag does not parse as a closing tag "12": undefined, "13": undefined, });
{ "end_byte": 1310, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/linkedEditingJsxTag5.ts" }
TypeScript/tests/cases/fourslash/tsxFindAllReferences3.ts_0_414
/// <reference path='fourslash.ts' /> //@Filename: file.tsx //// declare module JSX { //// interface Element { } //// interface IntrinsicElements { //// } //// interface ElementAttributesProperty { props } //// } //// class MyClass { //// props: { //// /*1*/name?: string; //// size?: number; //// } //// //// //// var x = <MyClass name='hello'/>; verify.baselineFindAllReferences('1')
{ "end_byte": 414, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxFindAllReferences3.ts" }
TypeScript/tests/cases/fourslash/indentationInJsx1.ts_0_294
/// <reference path='fourslash.ts' /> //@Filename: file.tsx ////(function () { //// return ( //// <div> //// <div> //// </div> //// /*indent2*/ //// </div> //// ) ////}) format.document(); goTo.marker("indent2"); verify.indentationIs(12);
{ "end_byte": 294, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indentationInJsx1.ts" }
TypeScript/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts_3_272
/ <reference path='fourslash.ts'/> //// class Foo { //// constructor(public /*0*/publicParam: number) { //// let localPublic = /*1*/publicParam; //// this./*2*/publicParam += 10; //// } //// } verify.baselineFindAllReferences('0', '1', '2')
{ "end_byte": 272, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts" }
TypeScript/tests/cases/fourslash/unusedClassInNamespaceWithTrivia2.ts_0_291
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true //// [| namespace greeter { //// // Do not remove //// /** //// * JSDoc Comment //// */ //// class /* comment2 */ class1 { //// } //// } |] verify.rangeAfterCodeFix(`namespace greeter { // Do not remove }`);
{ "end_byte": 291, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedClassInNamespaceWithTrivia2.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionImportedNames6.ts_0_353
/// <reference path='fourslash.ts' /> // @Filename: b.ts ////import [|/*moduleAliasDefinition*/alias|] = require("./a"); // @Filename: a.ts /////*moduleDefinition*/export module Module { ////} ////export class Class { //// private f; ////} ////export interface Interface { //// x; ////} verify.baselineGoToDefinition("moduleAliasDefinition");
{ "end_byte": 353, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionImportedNames6.ts" }
TypeScript/tests/cases/fourslash/quickInfoForObjectBindingElementName05.ts_0_265
/// <reference path="fourslash.ts" /> ////interface A { //// /** //// * A description of a //// */ //// a: number; ////} ////interface B { //// a: string; ////} //// ////function f({ a }: A | B) { //// a/**/; ////} verify.baselineQuickInfo();
{ "end_byte": 265, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForObjectBindingElementName05.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingEnumMember14.ts_0_370
/// <reference path="fourslash.ts" /> ////const a = 1; //// ////export const enum E { //// A = 0, //// B = 1, ////} //// ////const foo = E.Foo/**/; goTo.marker(""); verify.codeFix({ index: 0, description: "Add missing enum member 'Foo'", newFileContent: `const a = 1; export const enum E { A = 0, B = 1, Foo, } const foo = E.Foo;`, });
{ "end_byte": 370, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingEnumMember14.ts" }
TypeScript/tests/cases/fourslash/completionsClassMembers5.ts_0_384
/// <reference path="fourslash.ts" /> ////export const SOME_CONSTANT = 'SOME_TEXT'; ////export class Base { //// [SOME_CONSTANT]: boolean; ////} ////export class Derived extends Base { //// /**/ ////} verify.baselineCompletions({ includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: true, includeCompletionsWithClassMemberSnippets: true, });
{ "end_byte": 384, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsClassMembers5.ts" }
TypeScript/tests/cases/fourslash/completionListInClosedFunction07.ts_3_402
/ <reference path="fourslash.ts" /> ////interface MyType { ////} //// ////function foo(x: string, y: number, z: boolean) { //// function bar(a: number, b: string = "hello", c: typeof x = "hello") { //// var v = (p: MyType) => /*1*/; //// } ////} verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"], excludes: "MyType", });
{ "end_byte": 402, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInClosedFunction07.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_export_namedFunctionExpression.ts_0_327
/// <reference path='fourslash.ts' /> // @allowJs: true // @target: esnext // @Filename: /a.js ////exports.f = function g() { g(); } ////exports.h = function h() { h(); } verify.codeFix({ description: "Convert to ES module", newFileContent: `export const f = function g() { g(); } export function h() { h(); }`, });
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_export_namedFunctionExpression.ts" }
TypeScript/tests/cases/fourslash/signatureHelpLeadingRestTuple.ts_0_788
/// <reference path='fourslash.ts' /> ////export function leading(...args: [...names: string[], allCaps: boolean]): void { ////} //// ////leading(/*1*/); ////leading("ok", /*2*/); ////leading("ok", "ok", /*3*/); verify.signatureHelp( { marker: "1", text: "leading(...names: string[], allCaps: boolean): void", overloadsCount: 1, parameterCount: 2, isVariadic: true, }, { marker: "2", text: "leading(...names: string[], allCaps: boolean): void", overloadsCount: 1, parameterCount: 2, isVariadic: true, }, { marker: "3", text: "leading(...names: string[], allCaps: boolean): void", overloadsCount: 1, parameterCount: 2, isVariadic: true, }, );
{ "end_byte": 788, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpLeadingRestTuple.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts_0_715
/// <reference path='fourslash.ts' /> // Should respect the types compiler option when giving completions // @typeRoots: my_typings,my_other_typings // @types: module-x,module-z // @Filename: tests/test0.ts //// /// <reference types="m/*types_ref0*/" /> //// import * as foo1 from "m/*import_as0*/ //// import foo2 = require("m/*import_equals0*/ //// var foo3 = require("m/*require0*/ // @Filename: my_typings/module-x/index.d.ts //// export var x = 9; // @Filename: my_typings/module-y/index.d.ts //// export var y = 9; // @Filename: my_other_typings/module-z/index.d.ts //// export var z = 9; verify.completions({ marker: test.markers(), exact: ["module-x", "module-z"], isNewIdentifierLocation: true });
{ "end_byte": 715, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts" }
TypeScript/tests/cases/fourslash/gotoDefinitionLinkTag1.ts_0_848
///<reference path="fourslash.ts" /> // @Filename: foo.ts //// interface [|/*def1*/Foo|] { //// foo: string //// } //// namespace NS { //// export interface [|/*def2*/Bar|] { //// baz: Foo //// } //// } //// /** {@link /*use1*/[|Foo|]} foooo*/ //// const a = "" //// /** {@link NS./*use2*/[|Bar|]} ns.bar*/ //// const b = "" //// /** {@link /*use3*/[|Foo|] f1}*/ //// const c = "" //// /** {@link NS./*use4*/[|Bar|] ns.bar}*/ //// const [|/*def3*/d|] = "" //// /** {@link /*use5*/[|d|] }dd*/ //// const e = "" // Without lookahead, ambiguous between suffix type and link tag //// /** @param x {@link /*use6*/[|Foo|]} */ //// function foo(x) { } // @Filename: bar.ts //// /** {@link /*use7*/[|Foo|] }dd*/ //// const f = "" verify.baselineGetDefinitionAtPosition("use1", "use2", "use3", "use4", "use5", "use6", "use7");
{ "end_byte": 848, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/gotoDefinitionLinkTag1.ts" }