_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/findAllRefsForDefaultExport08.ts_0_368
/// <reference path='fourslash.ts'/> ////export default class DefaultExportedClass { ////} //// ////var x: DefaultExportedClass; //// ////var y = new DefaultExportedClass; //// ////namespace /*1*/DefaultExportedClass { ////} verify.noErrors(); // The namespace and class do not merge, // so the namespace should be all alone. verify.baselineFindAllReferences('1');
{ "end_byte": 368, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForDefaultExport08.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_expressionToDeclaration.ts_0_433
/// <reference path='fourslash.ts' /> // @allowJs: true // @target: esnext // @Filename: /a.js ////var C = {}; ////console.log(C); ////exports.f = async function* f(p) { p; } ////exports.C = class C extends D { m() {} } verify.codeFix({ description: "Convert to ES module", newFileContent: `var C = {}; console.log(C); export async function* f(p) { p; } const _C = class C extends D { m() { } }; export { _C as C };`, });
{ "end_byte": 433, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_expressionToDeclaration.ts" }
TypeScript/tests/cases/fourslash/completionListInTypeLiteralInTypeParameter8.ts_0_670
/// <reference path="fourslash.ts" /> ////interface Foo { //// one: string; //// two: { //// three: { //// four: number; //// five: string; //// } //// } ////} //// ////interface Bar<T extends Foo> { //// foo: T; ////} //// ////var foobar: Bar<{ //// two: { //// three: { //// five: string, //// /*4*/ //// }, //// /*0*/ //// }, //// /*1*/ ////}>; verify.completions( { marker: "4", exact: "four", isNewIdentifierLocation: true }, { marker: "0", exact: [], isNewIdentifierLocation: true }, { marker: "1", exact: "one", isNewIdentifierLocation: true }, );
{ "end_byte": 670, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInTypeLiteralInTypeParameter8.ts" }
TypeScript/tests/cases/fourslash/getOutliningSpans.ts_0_2382
/// <reference path="fourslash.ts"/> ////// interface ////interface IFoo[| { //// getDist(): number; ////}|] //// ////// class members ////class Foo[| { //// constructor()[| { //// }|] //// //// public foo(): number[| { //// return 0; //// }|] //// //// public get X()[| { //// return 1; //// }|] //// //// public set X(v: number)[| { //// }|] //// //// public member = function f()[| { //// //// }|] ////}|] ////// class expressions //// [|(new class[| { //// bla()[| { //// //// }|] //// }|])|] ////switch(1)[| { //// case 1:[| break;|] ////}|] //// ////var array =[| [ //// 1, //// 2 ////]|] //// ////// modules ////module m1[| { //// module m2[| { }|] //// module m3[| { //// function foo()[| { //// //// }|] //// //// interface IFoo2[| { //// //// }|] //// //// class foo2 implements IFoo2[| { //// //// }|] //// }|] ////}|] //// ////// function declaration ////function foo(): number[| { //// return 0; ////}|] //// ////// function expressions ////[|(function f()[| { //// ////}|])|] //// ////// trivia handeling ////class ClassFooWithTrivia[| /* some comments */ //// /* more trivia */ { //// //// //// /*some trailing trivia */ ////}|] /* even more */ //// ////// object literals ////var x =[|{ //// a:1, //// b:2, //// get foo()[| { //// return 1; //// }|] ////}|] //////outline with deep nesting ////var nest =[| [[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[[|[ //// [|[ //// [ //// [ //// [ //// [ //// 1,2,3 //// ] //// ] //// ] //// ] //// ]|] ////]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]]|]; //// //////outline after a deeply nested node ////class AfterNestedNodes[| { ////}|] ////// function arguments ////function f(x: number[], y: number[])[| { //// return 3; ////}|] ////f[|( ////// single line array literal span won't render in VS //// [|[0]|], //// [|[ //// 1, //// 2 //// ]|] ////)|]; //// ////class C<T>[| { //// foo: T; ////}|] //// ////class D<T> extends C<T>[| { //// constructor(x)[| { //// super<T>(x); //// }|] ////}|] verify.outliningSpansInCurrentFile(test.ranges(), "code");
{ "end_byte": 2382, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOutliningSpans.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_inferQuoteStyle1.ts_0_651
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////import 'unrelated'; //// ////[|export const x = 0;|] ////x; // @Filename: /b.ts ////import { x } from './a' //// ////x; // @Filename: /c.ts //////The same import, but namespace variant ////import * as A from './a' //// ////A.x; verify.moveToNewFile({ newFileContents: { "/a.ts": `import 'unrelated'; import { x } from './x'; x;`, "/x.ts": ` export const x = 0; `, "/b.ts": `import { x } from './x'; x;`, "/c.ts": `//The same import, but namespace variant import * as A from './a' import * as x from './x'; x.x;` }, });
{ "end_byte": 651, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_inferQuoteStyle1.ts" }
TypeScript/tests/cases/fourslash/completionListAtEndOfWordInArrowFunction01.ts_0_112
/// <reference path='fourslash.ts' /> ////xyz => x/*1*/ verify.completions({ marker: "1", includes: "xyz" });
{ "end_byte": 112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtEndOfWordInArrowFunction01.ts" }
TypeScript/tests/cases/fourslash/formatTemplateStringOnPaste.ts_0_157
/// <reference path="fourslash.ts" /> //// const x = `${0}/*0*/abc/*1*/`; format.selection("0", "1"); verify.currentFileContentIs("const x = `${0}abc`;");
{ "end_byte": 157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatTemplateStringOnPaste.ts" }
TypeScript/tests/cases/fourslash/inlayHintsInteractiveFunctionParameterTypes1.ts_0_1318
/// <reference path="fourslash.ts" /> //// type F1 = (a: string, b: number) => void //// const f1: F1 = (a, b) => { } //// const f2: F1 = (a, b: number) => { } //// function foo1 (cb: (a: string) => void) {} //// foo1((a) => { }) //// function foo2 (cb: (a: Exclude<1 | 2 | 3, 1>) => void) {} //// foo2((a) => { }) //// function foo3 (a: (b: (c: (d: Exclude<1 | 2 | 3, 1>) => void) => void) => void) {} //// foo3(a => { //// a(d => {}) //// }) //// function foo4<T>(v: T, a: (v: T) => void) {} //// foo4(1, a => { }) //// type F2 = (a: { //// a: number //// b: string //// readonly c: boolean //// d?: number //// e(): string //// f?(): boolean //// g<T>(): T //// h?<X, Y>(x: X): Y //// <X, Y>(x: X): Y //// [i: string]: number //// }) => void //// const foo5: F2 = (a) => { } // A callable object with no other members gets turned into a function type: //// type F3 = (a: { //// (): 42 //// }) => void //// const foo6: F3 = (a) => { } ////interface Thing {} ////function foo4(callback: (thing: Thing) => void) {} ////foo4(p => {}) //// type F4 = (a: { //// [i in string]: number //// }) => void //// const foo5: F4 = (a) => { } verify.baselineInlayHints(undefined, { includeInlayFunctionParameterTypeHints: true, interactiveInlayHints: true, });
{ "end_byte": 1318, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveFunctionParameterTypes1.ts" }
TypeScript/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts_0_6218
/// <reference path="fourslash.ts" /> ////global.cls = class { }; ////(function() { //// const x = () => { //// // Presence of inner function causes x to be a top-level function. //// function xx() {} //// }; //// const y = { //// // This is not a top-level function (contains nothing, but shows up in childItems of its parent.) //// foo: function() {} //// }; //// (function nest() { //// function moreNest() {} //// })(); ////})(); ////(function() { // Different anonymous functions are not merged //// // These will only show up as childItems. //// function z() {} //// console.log(function() {}) //// describe("this", 'function', `is a function`, `with template literal ${"a"}`, () => {}); //// [].map(() => {}); ////}) ////(function classes() { //// // Classes show up in top-level regardless of whether they have names or inner declarations. //// const cls2 = class { }; //// console.log(class cls3 {}); //// (class { }); ////}) verify.navigationTree({ "text": "<global>", "kind": "script", "childItems": [ { "text": "<function>", "kind": "function", "childItems": [ { "text": "nest", "kind": "function", "childItems": [ { "text": "moreNest", "kind": "function" } ] }, { "text": "x", "kind": "const", "childItems": [ { "text": "xx", "kind": "function" } ] }, { "text": "y", "kind": "const", "childItems": [ { "text": "foo", "kind": "method" } ] } ] }, { "text": "<function>", "kind": "function", "childItems": [ { "text": "console.log() callback", "kind": "function" }, { "text": "describe(\"this\", 'function', `is a function`, `with template literal ${\"a\"}`) callback", "kind": "function" }, { "text": "map() callback", "kind": "function" }, { "text": "z", "kind": "function" } ] }, { "text": "classes", "kind": "function", "childItems": [ { "text": "<class>", "kind": "class" }, { "text": "cls2", "kind": "const" }, { "text": "cls3", "kind": "class" } ] }, { "text": "cls", "kind": "class" } ] }); verify.navigationBar([ { "text": "<global>", "kind": "script", "childItems": [ { "text": "<function>", "kind": "function" }, { "text": "<function>", "kind": "function" }, { "text": "classes", "kind": "function" }, { "text": "cls", "kind": "class" } ] }, { "text": "<function>", "kind": "function", "childItems": [ { "text": "nest", "kind": "function" }, { "text": "x", "kind": "const" }, { "text": "y", "kind": "const" } ], "indent": 1 }, { "text": "nest", "kind": "function", "childItems": [ { "text": "moreNest", "kind": "function" } ], "indent": 2 }, { "text": "x", "kind": "const", "childItems": [ { "text": "xx", "kind": "function" } ], "indent": 2 }, { "text": "y", "kind": "const", "childItems": [ { "text": "foo", "kind": "method" } ], "indent": 2 }, { "text": "<function>", "kind": "function", "childItems": [ { "text": "console.log() callback", "kind": "function" }, { "text": "describe(\"this\", 'function', `is a function`, `with template literal ${\"a\"}`) callback", "kind": "function" }, { "text": "map() callback", "kind": "function" }, { "text": "z", "kind": "function" } ], "indent": 1 }, { "text": "classes", "kind": "function", "childItems": [ { "text": "<class>", "kind": "class" }, { "text": "cls2", "kind": "const" }, { "text": "cls3", "kind": "class" } ], "indent": 1 }, { "text": "<class>", "kind": "class", "indent": 2 }, { "text": "cls3", "kind": "class", "indent": 2 }, { "text": "cls", "kind": "class", "indent": 1 } ]);
{ "end_byte": 6218, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterface_all.ts_0_655
/// <reference path='fourslash.ts' /> ////interface I { i(): void; } ////interface J { j(): void; } ////class C implements I, J {} ////class D implements J {} verify.codeFixAll({ fixId: "fixClassIncorrectlyImplementsInterface", fixAllDescription: "Implement all unimplemented interfaces", newFileContent: `interface I { i(): void; } interface J { j(): void; } class C implements I, J { i(): void { throw new Error("Method not implemented."); } j(): void { throw new Error("Method not implemented."); } } class D implements J { j(): void { throw new Error("Method not implemented."); } }`, });
{ "end_byte": 655, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterface_all.ts" }
TypeScript/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames9.ts_0_154
/// <reference path='fourslash.ts' /> ////(/*1*/function /*2*/___foo() { //// /*3*/___foo(); ////}) verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 154, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames9.ts" }
TypeScript/tests/cases/fourslash/unclosedStringLiteralAutoformating.ts_0_208
/// <reference path='fourslash.ts' /> ////var x = /*1*/"asd/*2*/ ////class Foo { //// /**/ //verify.errorExistsBetweenMarkers("1", "2"); goTo.marker(); edit.insert("}"); verify.currentLineContentIs("}");
{ "end_byte": 208, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unclosedStringLiteralAutoformating.ts" }
TypeScript/tests/cases/fourslash/genericFunctionReturnType2.ts_0_496
/// <reference path='fourslash.ts'/> ////class C<T> { //// constructor(x: T) { } //// foo(x: T) { //// return (a: T) => x; //// } ////} ////var x = new C(1); ////var /*2*/r = x.foo(/*1*/3); ////var /*4*/r2 = r(/*3*/4); verify.signatureHelp({ marker: "1", text: "foo(x: number): (a: number) => number" }); verify.quickInfoAt("2", "var r: (a: number) => number"); verify.signatureHelp({ marker: "3", text: "r(a: number): number" }); verify.quickInfoAt("4", "var r2: number");
{ "end_byte": 496, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericFunctionReturnType2.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts_0_676
/// <reference path='fourslash.ts' /> ////class A { //// method(a: number, b: string): boolean; //// method(a: string | number, b?: string | number): boolean | Function { return a + b as any; } ////} ////class C implements A {} verify.codeFix({ description: "Implement interface 'A'", newFileContent: `class A { method(a: number, b: string): boolean; method(a: string | number, b?: string | number): boolean | Function { return a + b as any; } } class C implements A { method(a: number, b: string): boolean; method(a: string | number, b?: string | number): boolean | Function { throw new Error("Method not implemented."); } }`, });
{ "end_byte": 676, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_selectionOnName.ts_0_374
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////export {}; ////function e[|f|]f() { gee(); } ////function gee() { eff(); } verify.moveToNewFile({ newFileContents: { "/a.ts": `import { eff } from "./eff"; export {}; export function gee() { eff(); }`, "/eff.ts": `import { gee } from "./a"; export function eff() { gee(); } `, }, });
{ "end_byte": 374, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_selectionOnName.ts" }
TypeScript/tests/cases/fourslash/completionPreferredSuggestions1.ts_0_872
/// <reference path="fourslash.ts" /> ////declare let v1: string & {} | "a" | "b" | "c"; ////v1 = "/*1*/"; ////declare let v2: number & {} | 0 | 1 | 2; ////v2 = /*2*/; ////declare let v3: string & Record<never, never> | "a" | "b" | "c"; ////v3 = "/*3*/"; ////type LiteralUnion1<T extends U, U> = T | U & {}; ////type LiteralUnion2<T extends U, U> = T | U & Record<never, never>; ////declare let v4: LiteralUnion1<"a" | "b" | "c", string>; ////v4 = "/*4*/"; ////declare let v5: LiteralUnion2<"a" | "b" | "c", string>; ////v5 = "/*5*/"; verify.completions({ marker: "1", includes: ["a", "b", "c"] }); verify.completions({ marker: "2", includes: ["0", "1", "2"], isNewIdentifierLocation: true }); verify.completions({ marker: "3", includes: ["a", "b", "c"] }); verify.completions({ marker: "4", exact: [] }); verify.completions({ marker: "5", includes: ["a", "b", "c"] });
{ "end_byte": 872, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionPreferredSuggestions1.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportFileQuoteStyleMixed0.ts_0_432
/// <reference path="fourslash.ts" /> //// [|import { v2 } from "./module2"; //// import { v3 } from './module3'; //// //// f1/*0*/();|] // @Filename: module1.ts //// export function f1() {} // @Filename: module2.ts //// export var v2 = 6; // @Filename: module3.ts //// export var v3 = 6; verify.importFixAtPosition([ `import { f1 } from "./module1"; import { v2 } from "./module2"; import { v3 } from './module3'; f1();` ]);
{ "end_byte": 432, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportFileQuoteStyleMixed0.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDocTags6.ts_0_626
/// <reference path="fourslash.ts" /> // @noEmit: true // @allowJs: true // @Filename: quickInfoJsDocTags6.js ////class Foo { //// /** //// * comment //// * @author Me <me@domain.tld> //// * @see x (the parameter) //// * @param {number} x - x comment //// * @param {number} y - y comment //// * @returns The result //// */ //// method(x, y) { //// return x + y; //// } ////} //// ////class Bar extends Foo { //// /** @inheritDoc */ //// /**/method(x, y) { //// const res = super.method(x, y) + 100; //// return res; //// } ////} verify.baselineQuickInfo();
{ "end_byte": 626, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTags6.ts" }
TypeScript/tests/cases/fourslash/completionJSDocNamePath.ts_0_274
// @noLib: true /// <reference path='fourslash.ts'/> // fix crash from #38407 //// /** //// * @returns {modu/*1*/le:ControlFlow} //// */ //// export function cargo() { //// } goTo.marker('1'); verify.completions({ marker: "1", excludes: ["module", "ControlFlow"] });
{ "end_byte": 274, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionJSDocNamePath.ts" }
TypeScript/tests/cases/fourslash/smartIndentArrayBindingPattern01.ts_3_406
/ <reference path="fourslash.ts"/> ////var /*1*/[/*2*/a,/*3*/b,/*4*/ function verifyIndentationAfterNewLine(marker: string, indentation: number): void { goTo.marker(marker); edit.insert("\n"); verify.indentationIs(indentation); } verifyIndentationAfterNewLine("1", 4); verifyIndentationAfterNewLine("2", 8); verifyIndentationAfterNewLine("3", 8); verifyIndentationAfterNewLine("4", 8);
{ "end_byte": 406, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentArrayBindingPattern01.ts" }
TypeScript/tests/cases/fourslash/completionListWithModulesOutsideModuleScope.ts_0_7155
/// <reference path='fourslash.ts'/> ////namespace mod1 { //// var mod1var = 1; //// function mod1fn() { //// var bar = 1; //// function foob() { } //// } //// class mod1cls { //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// interface mod1int { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// } //// namespace mod1mod { //// var m1X = 1; //// function m1Func() { //// var bar = 1; //// function foob() { } //// } //// class m1Class { //// private cVar = 1; //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// interface m1Int { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// } //// export var m1eX = 1; //// export function m1eFunc() { //// } //// export class m1eClass { //// private cVar = 1; //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// export interface m1eInt { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// } //// namespace m1Mod { } //// export namespace m1eMod { } //// } //// export var mod1evar = 1; //// export function mod1efn() { //// var bar = 1; //// function foob() { } //// } //// export class mod1ecls { //// private cVar = 1; //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// export interface mod1eint { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// } //// export namespace mod1emod { //// var mX = 1; //// function mFunc() { //// var bar = 1; //// function foob() { } //// } //// class mClass { //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// interface mInt { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// } //// export var meX = 1; //// export function meFunc() { //// } //// export class meClass { //// private cVar = 1; //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// export interface meInt { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// } //// namespace mMod { } //// export namespace meMod { } //// } ////} //// ////// EXTENDING NAMESPACE 1 ////namespace mod1 { //// export var mod1eexvar = 1; //// var mod1exvar = 2; ////} //// ////namespace mod2 { //// var mod2var = "shadow"; //// function mod2fn() { //// var bar = 1; //// function foob() { } //// } //// class mod2cls { //// private cVar = 1; //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// namespace mod2mod { } //// interface mod2int { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// } //// export var mod2evar = 1; //// export function mod2efn() { //// } //// export class mod2ecls { //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// export interface mod2eint { //// (bar: any): any; //// new (bar: any): any; //// bar: any; //// foob(bar: any): any; //// } //// export namespace mod2emod { } ////} //// ////namespace mod2 { //// export var mod2eexvar = 1; ////} //// ////namespace mod3 { //// var shwvar = "shadow"; //// function shwfn() { //// var bar = 1; //// function foob() { } //// } //// class shwcls { //// constructor(public shadow: any) { } //// private cVar = 1; //// public cFunc() { } //// public ceFunc() { } //// public ceVar = 1; //// static csVar = 1; //// static csFunc() { } //// } //// interface shwint { //// (bar: any): any; //// new (bar: any): any; //// sivar: string; //// sifn(shadow: any): any; //// } ////} //// ////function shwfn() { //// var sfvar = 1; //// function sffn() { } //// /*function*/ ////} //// ////class shwcls { //// private scvar = 1; //// private scfn() { } //// public scpfn() { } //// public scpvar = 1; //// static scsvar = 1; //// static scsfn() { } //// /*class*/ ////} //// ////interface shwint { //// (bar: any): any; //// new (bar: any): any; //// sivar: any; //// sifn(bar: any): any; //// /*interface*/ ////} //// ////var shwvar = 1; /////*global*/ const commonExcludes: ReadonlyArray<string> = [ "mod1var", "mod1fn", "mod1cls", "mod1int", "mod1mod", "mod1evar", "mod1efn", "mod1ecls", "mod1eint", "mod1emod", "mod1eexvar", "scvar", "scfn", "scpfn", "scpvar", "scsvar", "scsfn", "sivar", "sifn", ]; verify.completions( // from global scope { marker: "global", includes: [ { name: "mod1", text: "namespace mod1" }, { name: "mod2", text: "namespace mod2" }, { name: "mod3", text: "namespace mod3" }, { name: "shwvar", text: "var shwvar: number" }, { name: "shwfn", text: "function shwfn(): void" }, { name: "shwcls", text: "class shwcls" }, ], excludes: [...commonExcludes, "shwint", "sfvar", "sffn"], }, // from function scope { marker: "function", includes: [ { name: "sfvar", text: "(local var) sfvar: number" }, { name: "sffn", text: "(local function) sffn(): void" }, ], excludes: commonExcludes, }, // from class scope { marker: "class", exact: completion.classElementKeywords, isNewIdentifierLocation: true, }, // from interface scope { marker: "interface", exact: [{ name: "readonly", sortText: completion.SortText.GlobalsOrKeywords }], isNewIdentifierLocation: true, } );
{ "end_byte": 7155, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListWithModulesOutsideModuleScope.ts" }
TypeScript/tests/cases/fourslash/quickInfoNamedTupleMembers.ts_0_177
/// <reference path='fourslash.ts'/> ////export type /*1*/Segment = [length: number, count: number]; verify.quickInfoAt("1", "type Segment = [length: number, count: number]");
{ "end_byte": 177, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoNamedTupleMembers.ts" }
TypeScript/tests/cases/fourslash/incompleteFunctionCallCodefixTypeParametersNested3D.ts_0_592
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////function outer<O>(o: O) { //// return function middle<M>(m: M) { //// return function inner<I>(i: I) { //// added/*1*/(o, m, i); //// } //// } ////} goTo.marker("1"); verify.codeFix({ description: "Add missing function declaration 'added'", index: 0, newFileContent: `function outer<O>(o: O) { return function middle<M>(m: M) { return function inner<I>(i: I) { added(o, m, i); } } } function added<O, M, I>(o: O, m: M, i: I) { throw new Error("Function not implemented."); } `, });
{ "end_byte": 592, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incompleteFunctionCallCodefixTypeParametersNested3D.ts" }
TypeScript/tests/cases/fourslash/completionListInTypedObjectLiterals4.ts_0_225
/// <reference path="fourslash.ts" /> ////interface MyPoint { //// x1: number; //// y1: number; ////} ////var p15: MyPoint = { //// "x1": 5, //// /*15*/ ////}; verify.completions({ marker: "15", exact: "y1" });
{ "end_byte": 225, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInTypedObjectLiterals4.ts" }
TypeScript/tests/cases/fourslash/findAllRefsJsDocTemplateTag_function_js.ts_0_206
/// <reference path='fourslash.ts'/> // @allowJs: true // @Filename: /a.js /////** //// * @template /*1*/T //// * @return {/*2*/T} //// */ ////function f() {} verify.baselineFindAllReferences('1', '2');
{ "end_byte": 206, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsJsDocTemplateTag_function_js.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_typeParameter1.ts_0_323
/// <reference path="fourslash.ts" /> // @noUnusedLocals: true // @noUnusedParameters: true ////function f< //// T1, T2, //// T3, ////>(a: T1, b: T3) {} verify.codeFix({ index: 0, description: "Remove unused declaration for: 'T2'", newFileContent: `function f< T1, T3, >(a: T1, b: T3) {}` });
{ "end_byte": 323, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_typeParameter1.ts" }
TypeScript/tests/cases/fourslash/callHierarchyExportDefaultClass.ts_0_348
/// <reference path="fourslash.ts" /> // @filename: main.ts //// import Bar from "./other"; //// //// function foo() { //// new Bar(); //// } // @filename: other.ts //// export /**/default class { //// constructor() { //// baz(); //// } //// } //// //// function baz() { //// } goTo.marker(); verify.baselineCallHierarchy();
{ "end_byte": 348, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyExportDefaultClass.ts" }
TypeScript/tests/cases/fourslash/smartIndentInParenthesizedExpression02.ts_3_207
/ <reference path="fourslash.ts"/> ////var y = ( ////{| "indent": 4 |} test.markers().forEach(marker => { verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); });
{ "end_byte": 207, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentInParenthesizedExpression02.ts" }
TypeScript/tests/cases/fourslash/removeExportFromInterfaceError1.ts_0_267
/// <reference path="fourslash.ts" /> //// module M { //// export class C1 { } //// /*1*/export interface I { n: number; } //// } //// module M { //// function f(): I { return null; } } //// edit.disableFormatting(); goTo.marker("1"); edit.deleteAtCaret(6);
{ "end_byte": 267, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/removeExportFromInterfaceError1.ts" }
TypeScript/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts_3_1131
/ <reference path='fourslash.ts' /> // @Filename: /node_modules/@types/three/three-core.d.ts ////export class Vector3 { //// constructor(x?: number, y?: number, z?: number); //// x: number; //// y: number; ////} // @Filename: /node_modules/@types/three/index.d.ts ////export * from "./three-core"; ////export as namespace /*0*/THREE; // @Filename: /typings/global.d.ts ////import * as _THREE from '/*1*/three'; ////declare global { //// const /*2*/THREE: typeof _THREE; ////} // @Filename: /src/index.ts ////export const a = {}; ////let v = new /*3*/THREE.Vector2(); // @Filename: /tsconfig.json ////{ //// "compilerOptions": { //// "esModuleInterop": true, //// "outDir": "./build/js/", //// "noImplicitAny": true, //// "module": "es6", //// "target": "es6", //// "allowJs": true, //// "skipLibCheck": true, //// "lib": ["es2016", "dom"], //// "typeRoots": ["node_modules/@types/"], //// "types": ["three"] //// }, //// "files": ["/src/index.ts", "typings/global.d.ts"] ////} verify.baselineFindAllReferences('0', '1', '2', '3');
{ "end_byte": 1131, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingEnumMember7.ts_0_181
/// <reference path='fourslash.ts' /> ////enum E { ////} ////E.a verify.codeFix({ description: "Add missing enum member 'a'", newFileContent: `enum E { a } E.a` });
{ "end_byte": 181, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingEnumMember7.ts" }
TypeScript/tests/cases/fourslash/smartIndentAfterAlignedFunctionArgument.ts_0_193
/// <reference path='fourslash.ts'/> ////function foo(bar, //// blah, baz, //// /**/ ////) { }; goTo.marker(); // keep indentation of 'blah' verify.indentationIs(13);
{ "end_byte": 193, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentAfterAlignedFunctionArgument.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionDestructuredRequire1.ts_0_263
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: util.js //// class /*2*/Util {} //// module.exports = { Util }; // @Filename: index.js //// const { Util } = require('./util'); //// new [|Util/*1*/|]() verify.baselineGoToDefinition("1");
{ "end_byte": 263, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionDestructuredRequire1.ts" }
TypeScript/tests/cases/fourslash/toggleLineComment9.ts_0_548
// If at least one line is not commented then comment all lines again. // TODO: Not sure about this one. The default behavior for line comment is to add en extra // layer of comments (see toggleLineComment4 test). For jsx this doesn't work right as it's actually // multiline comment. Figure out what to do. //@Filename: file.tsx //// const a = <div> //// {/*[|<div>*/} //// SomeText //// {/*</div>|]*/} //// </div>; verify.toggleLineComment( `const a = <div> {/*<div>*/} {/* SomeText*/} {/*</div>*/} </div>;`);
{ "end_byte": 548, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/toggleLineComment9.ts" }
TypeScript/tests/cases/fourslash/importTypeNodeGoToDefinition.ts_0_478
/// <reference path="fourslash.ts" /> // @Filename: /ns.ts /////*refFile*/export namespace /*refFoo*/Foo { //// export namespace /*refBar*/Bar { //// export class /*refBaz*/Baz {} //// } ////} // @Filename: /usage.ts ////type A = typeof import([|/*1*/"./ns"|]).[|/*2*/Foo|].[|/*3*/Bar|]; ////type B = import([|/*4*/"./ns"|]).[|/*5*/Foo|].[|/*6*/Bar|].[|/*7*/Baz|]; verify.baselineGoToDefinition( "1", "2", "3", "4", "5", "6", "7", );
{ "end_byte": 478, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importTypeNodeGoToDefinition.ts" }
TypeScript/tests/cases/fourslash/formattingDecorators.ts_0_4176
/// <reference path='fourslash.ts' /> /////*1*/ @ decorator1 /////*2*/ @ decorator2 /////*3*/ @decorator3 /////*4*/ @ decorator4 @ decorator5 /////*5*/class C { /////*6*/ @ decorator6 /////*7*/ @ decorator7 /////*8*/ @decorator8 /////*9*/ method1() { } //// /////*10*/ @ decorator9 @ decorator10 @decorator11 method2() { } //// //// method3( /////*11*/ @ decorator12 /////*12*/ @ decorator13 /////*13*/ @decorator14 /////*14*/ x) { } //// //// method4( /////*15*/ @ decorator15 @ decorator16 @decorator17 x) { } //// /////*16*/ @ decorator18 /////*17*/ @ decorator19 /////*18*/ @decorator20 /////*19*/ ["computed1"]() { } //// /////*20*/ @ decorator21 @ decorator22 @decorator23 ["computed2"]() { } //// /////*21*/ @ decorator24 /////*22*/ @ decorator25 /////*23*/ @decorator26 /////*24*/ get accessor1() { } //// /////*25*/ @ decorator27 @ decorator28 @decorator29 get accessor2() { } //// /////*26*/ @ decorator30 /////*27*/ @ decorator31 /////*28*/ @decorator32 /////*29*/ property1; //// /////*30*/ @ decorator33 @ decorator34 @decorator35 property2; /////*31*/function test(@decorator36@decorator37 param) {}; /////*32*/function test2(@decorator38()@decorator39()param) {}; ////} format.document(); goTo.marker("1"); verify.currentLineContentIs("@decorator1"); goTo.marker("2"); verify.currentLineContentIs("@decorator2"); goTo.marker("3"); verify.currentLineContentIs("@decorator3"); goTo.marker("4"); verify.currentLineContentIs("@decorator4 @decorator5"); goTo.marker("5"); verify.currentLineContentIs("class C {"); goTo.marker("6"); verify.currentLineContentIs(" @decorator6"); goTo.marker("7"); verify.currentLineContentIs(" @decorator7"); goTo.marker("8"); verify.currentLineContentIs(" @decorator8"); goTo.marker("9"); verify.currentLineContentIs(" method1() { }"); goTo.marker("10"); verify.currentLineContentIs(" @decorator9 @decorator10 @decorator11 method2() { }"); goTo.marker("11"); verify.currentLineContentIs(" @decorator12"); goTo.marker("12"); verify.currentLineContentIs(" @decorator13"); goTo.marker("13"); verify.currentLineContentIs(" @decorator14"); goTo.marker("14"); verify.currentLineContentIs(" x) { }"); goTo.marker("15"); verify.currentLineContentIs(" @decorator15 @decorator16 @decorator17 x) { }"); goTo.marker("16"); verify.currentLineContentIs(" @decorator18"); goTo.marker("17"); verify.currentLineContentIs(" @decorator19"); goTo.marker("18"); verify.currentLineContentIs(" @decorator20"); goTo.marker("19"); verify.currentLineContentIs(" [\"computed1\"]() { }"); goTo.marker("20"); verify.currentLineContentIs(" @decorator21 @decorator22 @decorator23 [\"computed2\"]() { }"); goTo.marker("21"); verify.currentLineContentIs(" @decorator24"); goTo.marker("22"); verify.currentLineContentIs(" @decorator25"); goTo.marker("23"); verify.currentLineContentIs(" @decorator26"); goTo.marker("24"); verify.currentLineContentIs(" get accessor1() { }"); goTo.marker("25"); verify.currentLineContentIs(" @decorator27 @decorator28 @decorator29 get accessor2() { }"); goTo.marker("26"); verify.currentLineContentIs(" @decorator30"); goTo.marker("27"); verify.currentLineContentIs(" @decorator31"); goTo.marker("28"); verify.currentLineContentIs(" @decorator32"); goTo.marker("29"); verify.currentLineContentIs(" property1;"); goTo.marker("30"); verify.currentLineContentIs(" @decorator33 @decorator34 @decorator35 property2;"); goTo.marker("31"); verify.currentLineContentIs("function test(@decorator36 @decorator37 param) { };"); goTo.marker("32"); verify.currentLineContentIs("function test2(@decorator38() @decorator39() param) { };");
{ "end_byte": 4176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingDecorators.ts" }
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts_0_672
/// <reference path='fourslash.ts' /> //// function f(templateStrings: string[], p1_o1: string): number; //// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; //// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; //// function f(...foo[]: any) { return ""; } //// //// f `${ } ${/*1*/ /*2*/ /*3*/} verify.signatureHelp({ marker: test.markers(), overloadsCount: 3, text: "f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string", argumentCount: 3, parameterCount: 4, parameterName: "p2_o2", parameterSpan: "p2_o2: number", });
{ "end_byte": 672, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts" }
TypeScript/tests/cases/fourslash/completionsJsxAttribute2.ts_0_735
/// <reference path="fourslash.ts" /> // @jsx: preserve // @Filename: /a.tsx ////declare namespace JSX { //// interface Element {} //// interface IntrinsicElements { //// div: { //// /** Doc */ //// foo: boolean; //// bar: string; //// "aria-foo": boolean; //// } //// } ////} //// ////<div foo /*1*/></div>; ////<div foo={true} /*2*/></div>; ////<div bar="test" /*3*/></div>; ////<div aria-foo /*4*/></div>; verify.completions({ marker: "1", exact: ["aria-foo", "bar"] }); verify.completions({ marker: "2", exact: ["aria-foo", "bar"] }); verify.completions({ marker: "3", exact: ["aria-foo", "foo"] }); verify.completions({ marker: "4", exact: ["bar", "foo"] });
{ "end_byte": 735, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsJsxAttribute2.ts" }
TypeScript/tests/cases/fourslash/completionListInvalidMemberNames.ts_0_1555
/// <reference path='fourslash.ts' /> ////var x = { //// "foo ": "space in the name", //// "bar": "valid identifier name", //// "break": "valid identifier name (matches a keyword)", //// "any": "valid identifier name (matches a typescript keyword)", //// "#": "invalid identifier name", //// "$": "valid identifier name", //// "\u0062": "valid unicode identifier name (b)", //// "\u0031\u0062": "invalid unicode identifier name (1b)" ////}; //// ////x[|./*a*/|]; ////x["[|/*b*/|]"]; const replacementSpan = test.ranges()[0]; const replacementSpan1 = test.ranges()[1]; verify.completions( { marker: "b", unsorted: [ { name: "foo ", replacementSpan: replacementSpan1 }, { name: "bar", replacementSpan: replacementSpan1 }, { name: "break", replacementSpan: replacementSpan1 }, { name: "any", replacementSpan: replacementSpan1 }, { name: "#", replacementSpan: replacementSpan1 }, { name: "$", replacementSpan: replacementSpan1 }, { name: "b", replacementSpan: replacementSpan1 }, { name: "1b", replacementSpan: replacementSpan1 }, ] }, { marker: "a", unsorted: [ { name: "foo ", insertText: '["foo "]', replacementSpan }, "bar", "break", "any", { name: "#", insertText: '["#"]', replacementSpan }, "$", "b", { name: "1b", insertText: '["1b"]', replacementSpan }, ], preferences: { includeInsertTextCompletions: true }, }, );
{ "end_byte": 1555, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInvalidMemberNames.ts" }
TypeScript/tests/cases/fourslash/codeFixSpelling3.ts_0_305
/// <reference path='fourslash.ts' /> ////[|class C { //// state = 'hi' //// doStuff() { //// this.start; //// } ////}|] verify.rangeAfterCodeFix(`class C { state = 'hi' doStuff() { this.state; } }`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0);
{ "end_byte": 305, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpelling3.ts" }
TypeScript/tests/cases/fourslash/navigationItemsOverloadsBroken2.ts_0_1510
/// <reference path="fourslash.ts"/> ////function overload1(a: string): boolean; ////function overload1(b: boolean): boolean; ////[|function overload1(x: any, b = (function overload() { return false })): boolean { //// throw overload1; ////}|] ////function overload1(b: number): boolean; ////function overload1(f: typeof overload): boolean; ////function overload2(a: string): boolean; ////function overload2(b: boolean): boolean; ////[|function overload2(x: any, b = (function overload() { return false })): boolean { //// [|function overload2(): boolean;|] //// function overload2(x: any): boolean; //// throw overload2; ////}|] ////[|function overload2(b: number): boolean;|] ////function overload2(f: typeof overload): boolean; const [r0, r1, r2, r3] = test.ranges(); const overload1: ReadonlyArray<FourSlashInterface.ExpectedNavigateToItem> = [ { name: "overload1", kind: "function", range: r0 }, ]; const overload2: ReadonlyArray<FourSlashInterface.ExpectedNavigateToItem> = [ { name: "overload2", kind: "function", range: r1 }, { name: "overload2", kind: "function", range: r2, containerName: "overload2", containerKind: "function" }, { name: "overload2", kind: "function", range: r3 }, ]; verify.navigateTo( { pattern: "overload1", expected: overload1 }, { pattern: "overload2", expected: overload2, }, { pattern: "overload", expected: [...overload1, ...overload2].map(item => ({ ...item, matchKind: "prefix" })), }, );
{ "end_byte": 1510, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationItemsOverloadsBroken2.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageOptionalParam.ts_0_164
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////function f([|a? |]){ //// a; ////} ////f(); ////f(1); verify.rangeAfterCodeFix("a?: number");
{ "end_byte": 164, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageOptionalParam.ts" }
TypeScript/tests/cases/fourslash/moduleMembersOfGenericType.ts_0_210
/// <reference path='fourslash.ts'/> ////module M { //// export var x = <T>(x: T) => x; ////} ////var r = M./**/; verify.completions({ marker: "", exact: { name: "x", text: "var M.x: <T>(x: T) => T" } });
{ "end_byte": 210, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moduleMembersOfGenericType.ts" }
TypeScript/tests/cases/fourslash/renameDestructuringDeclarationInFor.ts_0_550
/// <reference path='fourslash.ts' /> ////interface I { //// [|[|{| "contextRangeIndex": 0 |}property1|]: number;|] //// property2: string; ////} ////var elems: I[]; //// ////var p2: number, property1: number; ////for ([|let { [|{| "contextRangeIndex": 2 |}property1|]: p2 } = elems[0]|]; p2 < 100; p2++) { ////} ////for ([|let { [|{| "contextRangeIndex": 4 |}property1|] } = elems[0]|]; p2 < 100; p2++) { //// [|property1|] = p2; ////} const [r0Def, r0, r1Def, r1, r2Def, r2, r3] = test.ranges(); verify.baselineRename([r0, r1, r2, r3]);
{ "end_byte": 550, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameDestructuringDeclarationInFor.ts" }
TypeScript/tests/cases/fourslash/pathCompletionsPackageJsonExportsBundlerNoNodeCondition.ts_0_664
/// <reference path="fourslash.ts" /> // @moduleResolution: bundler // @Filename: /node_modules/foo/package.json //// { //// "name": "foo", //// "exports": { //// "./only-for-node": { //// "node": "./something.js" //// }, //// "./for-everywhere": "./other.js", //// } //// } // @Filename: /node_modules/foo/something.d.ts //// export const index = 0; // @Filename: /node_modules/foo/other.d.ts //// export const index = 0; // @Filename: /index.ts //// import { } from "foo//**/"; verify.completions({ marker: "", isNewIdentifierLocation: true, exact: [ { name: "for-everywhere", kind: "script", kindModifiers: "" }, ] });
{ "end_byte": 664, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsPackageJsonExportsBundlerNoNodeCondition.ts" }
TypeScript/tests/cases/fourslash/getEmitOutputTsxFile_React.ts_0_617
/// <reference path="fourslash.ts" /> // @BaselineFile: getEmitOutputTsxFile_React.baseline // @declaration: true // @sourceMap: true // @jsx: react // @Filename: inputFile1.ts // @emitThisFile: true ////// regular ts file //// var t: number = 5; //// class Bar { //// x : string; //// y : number //// } //// /*1*/ // @Filename: inputFile2.tsx // @emitThisFile: true //// declare var React: any; //// var y = "my div"; //// var x = <div name= {y} /> //// /*2*/ goTo.marker("1"); verify.numberOfErrorsInCurrentFile(0); goTo.marker("2"); verify.numberOfErrorsInCurrentFile(0); verify.baselineGetEmitOutput();
{ "end_byte": 617, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputTsxFile_React.ts" }
TypeScript/tests/cases/fourslash/jsDocPropertyDescription9.ts_0_741
///<reference path="fourslash.ts" /> //// class LiteralClass { //// /** Something generic */ //// static [key: `prefix${string}`]: any; //// /** Something else */ //// static [key: `prefix${number}`]: number; //// } //// function literalClass(e: typeof LiteralClass) { //// console.log(e./*literal1Class*/prefixMember); //// console.log(e./*literal2Class*/anything); //// console.log(e./*literal3Class*/prefix0); //// } verify.quickInfoAt("literal1Class", "(index) LiteralClass[`prefix${string}`]: any", "Something generic"); verify.quickInfoAt("literal2Class", "any"); verify.quickInfoAt("literal3Class", "(index) LiteralClass[`prefix${string}` | `prefix${number}`]: any", "Something generic\nSomething else")
{ "end_byte": 741, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocPropertyDescription9.ts" }
TypeScript/tests/cases/fourslash/completionEntryInJsFile.ts_0_1020
///<reference path="fourslash.ts" /> // @allowJs: true // @Filename: /Foo.js //// /*global*/ ////class classA { //// /*class*/ ////} ////class Test7 { //// constructor(/*constructorParameter*/){} ////} ////function foo() { /////*insideFunction*/ ////} const warnings = [ { name: "classA", sortText: completion.SortText.JavascriptIdentifiers }, { name: "foo", sortText: completion.SortText.JavascriptIdentifiers }, { name: "Test7", sortText: completion.SortText.JavascriptIdentifiers }, ]; verify.completions( { marker: "global", exact: completion.globalsInJsPlus(["classA", "foo", "Test7"]) }, { marker: "class", isNewIdentifierLocation: true, exact: [ ...completion.classElementInJsKeywords, ...warnings, ] }, { marker: "constructorParameter", isNewIdentifierLocation: true, exact: warnings }, { marker: "insideFunction", exact: completion.globalsInJsInsideFunction(["classA", "foo", "Test7"]) }, );
{ "end_byte": 1020, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionEntryInJsFile.ts" }
TypeScript/tests/cases/fourslash/findAllRefsReExport_broken2.ts_0_148
/// <reference path='fourslash.ts' /> // @Filename: /a.ts /////*1*/export { /*2*/x } from "nonsense"; verify.baselineFindAllReferences('1', '2');
{ "end_byte": 148, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsReExport_broken2.ts" }
TypeScript/tests/cases/fourslash/codeFixRenameUnmatchedParameter3.ts_0_1551
/// <reference path='fourslash.ts' /> // @filename: a.ts /////** //// * @param {number} notDefined1 //// * @param {number} notDefined2 //// * @param {number} a //// * @param {number} b //// */ ////function foo(a: number, b: string, typo1: string, typo2: string) { //// a; //// b; //// typo1; //// typo2; ////} verify.codeFixAvailable([ { description: "Delete unused '@param' tag 'notDefined1'" }, { description: "Rename '@param' tag name 'notDefined1' to 'typo1'" }, { description: "Delete unused '@param' tag 'notDefined2'" }, { description: "Rename '@param' tag name 'notDefined2' to 'typo1'" }, ]); verify.codeFix({ description: [ts.Diagnostics.Rename_param_tag_name_0_to_1.message, "notDefined1", "typo1"], index: 1, newFileContent: `/** * @param {number} typo1 * @param {number} notDefined2 * @param {number} a * @param {number} b */ function foo(a: number, b: string, typo1: string, typo2: string) { a; b; typo1; typo2; }`, applyChanges: true }); verify.codeFixAvailable([ { description: "Delete unused '@param' tag 'notDefined2'" }, { description: "Rename '@param' tag name 'notDefined2' to 'typo2'" }, ]); verify.codeFix({ description: [ts.Diagnostics.Rename_param_tag_name_0_to_1.message, "notDefined2", "typo2"], index: 1, newFileContent: `/** * @param {number} typo1 * @param {number} typo2 * @param {number} a * @param {number} b */ function foo(a: number, b: string, typo1: string, typo2: string) { a; b; typo1; typo2; }`, });
{ "end_byte": 1551, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRenameUnmatchedParameter3.ts" }
TypeScript/tests/cases/fourslash/linkedEditingJsxTag12.ts_0_1107
/// <reference path='fourslash.ts' /> // @Filename: /incomplete.tsx //// function Test() { //// return <div> //// </*0*/ //// <div {...{}}> //// </div> //// </div> //// } // @Filename: /incompleteMismatched.tsx //// function Test() { //// return <div> //// <T //// <div {...{}}> //// </div> //// </div> //// } // @Filename: /incompleteMismatched2.tsx //// function Test() { //// return <div> //// <T //// <div {...{}}> //// T</div> //// </div> //// } // @Filename: /incompleteMismatched3.tsx //// function Test() { //// return <div> //// <div {...{}}> //// </div> //// <T //// </div> //// } // @Filename: /mismatched.tsx //// function Test() { //// return <div> //// <T> //// <div {...{}}> //// </div> //// </div> //// } // @Filename: /matched.tsx //// function Test() { //// return <div> //// //// <div {...{}}> //// </div> //// </div> //// } verify.linkedEditing({ 0 : undefined }); verify.baselineLinkedEditing();
{ "end_byte": 1107, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/linkedEditingJsxTag12.ts" }
TypeScript/tests/cases/fourslash/moveToFile_expandSelectionRange12.ts_0_649
/// <reference path='fourslash.ts' /> //@Filename: /bar.ts ////const b = 2; // @Filename: /a.ts ////const a = 1;[| ////function add(x: number, y: number): number; ////function add(x: string, y: string): string; ////function add(x: any, y: any) { //// return x + y; ////} ////function foo() {} ////|] verify.moveToFile({ newFileContents: { "/a.ts": `const a = 1; `, "/bar.ts": `const b = 2; function add(x: number, y: number): number; function add(x: string, y: string): string; function add(x: any, y: any) { return x + y; } function foo() { } `, }, interactiveRefactorArguments: { targetFile: "/bar.ts" } });
{ "end_byte": 649, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_expandSelectionRange12.ts" }
TypeScript/tests/cases/fourslash/formattingWithLimitedSpan.ts_0_391
/// <reference path="fourslash.ts" /> ////if (true) ////{ /////*1*/debugger;/*end1*/ ////if (true) /////*2*/debugger;/*end2*/ ////if (true) { /////*3*/debugger;/*end3*/ ////} ////} for (var i = 1; i < 4; i++) { var markerString = i.toString(); goTo.marker(markerString); format.selection(markerString, "end" + markerString); verify.currentLineContentIs(" debugger;"); }
{ "end_byte": 391, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingWithLimitedSpan.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts_0_452
/// <reference path='fourslash.ts' /> ////interface I { //// f(i: any): i is I; //// f(): this is I; ////} //// ////class C implements I {} verify.codeFix({ description: "Implement interface 'I'", newFileContent: `interface I { f(i: any): i is I; f(): this is I; } class C implements I { f(i: any): i is I; f(): this is I; f(i?: unknown): boolean { throw new Error("Method not implemented."); } }`, });
{ "end_byte": 452, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts" }
TypeScript/tests/cases/fourslash/inlayHintsInteractiveMultifileFunctionCalls.ts_0_528
/// <reference path="fourslash.ts" /> // @Target: esnext // @module: nodenext // @Filename: aaa.mts ////import { helperB } from "./bbb.mjs"; ////helperB("hello, world!"); // @Filename: bbb.mts ////import { helperC } from "./ccc.mjs"; ////export function helperB(bParam: string) { //// helperC(bParam); ////} // @Filename: ccc.mts ////export function helperC(cParam: string) {} goTo.file("./aaa.mts"); verify.baselineInlayHints(undefined, { includeInlayParameterNameHints: "all", interactiveInlayHints: true });
{ "end_byte": 528, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveMultifileFunctionCalls.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingParam_all.ts_0_1082
/// <reference path='fourslash.ts' /> ////[|function f1() {}|] //// ////const a = 1; ////const b = ""; ////f1(a, b, true); //// ////function f2() {} ////f2("", { x: 1 }, [ "" ], true); //// ////class C { //// [|m1() {}|] //// m2(a: boolean) { //// this.m1(a); //// } ////} //// ////function f3(a: string): string; ////function f3(a: string, b: number): string; ////function f3(a: string, b?: number): string { //// return ""; ////} ////f3("", "", 1); verify.codeFixAll({ fixId: "addMissingParam", fixAllDescription: ts.Diagnostics.Add_all_missing_parameters.message, newFileContent: `function f1(a: number, b: string, p0: boolean) {} const a = 1; const b = ""; f1(a, b, true); function f2(p0: string, p1: { x: number; }, p2: string[], p3: boolean) {} f2("", { x: 1 }, [ "" ], true); class C { m1(a: boolean) {} m2(a: boolean) { this.m1(a); } } function f3(a: string): string; function f3(a: string, p0: string, b: number): string; function f3(a: string, p0: string, b?: number): string { return ""; } f3("", "", 1);` });
{ "end_byte": 1082, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingParam_all.ts" }
TypeScript/tests/cases/fourslash/unusedParameterInLambda1.ts_0_332
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @noUnusedParameters: true ////[|/*~a*/(/*~b*/x/*~c*/:/*~d*/number/*~e*/)/*~f*/ => /*~g*/{/*~h*/}/*~i*/|] verify.codeFix({ description: "Remove unused declaration for: 'x'", index: 0, newRangeContent: "/*~a*/(/*~e*/)/*~f*/ => /*~g*/{/*~h*/}/*~i*/", });
{ "end_byte": 332, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedParameterInLambda1.ts" }
TypeScript/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions3.ts_0_2093
/// <reference path="fourslash.ts"/> ////describe('foo', () => { //// test(`a ${1} b ${2}`, () => {}) ////}) //// ////const a = 1; ////const b = 2; ////describe('foo', () => { //// test(`a ${a} b {b}`, () => {}) ////}) verify.navigationTree({ "text": "<global>", "kind": "script", "childItems": [ { "text": "a", "kind": "const" }, { "text": "b", "kind": "const" }, { "text": "describe('foo') callback", "kind": "function", "childItems": [ { "text": "test(`a ${1} b ${2}`) callback", "kind": "function" } ] }, { "text": "describe('foo') callback", "kind": "function", "childItems": [ { "text": "test(`a ${a} b {b}`) callback", "kind": "function" } ] } ] }); verify.navigationBar([ { "text": "<global>", "kind": "script", "childItems": [ { "text": "a", "kind": "const" }, { "text": "b", "kind": "const" }, { "text": "describe('foo') callback", "kind": "function" }, { "text": "describe('foo') callback", "kind": "function" } ] }, { "text": "describe('foo') callback", "kind": "function", "childItems": [ { "text": "test(`a ${1} b ${2}`) callback", "kind": "function" } ], "indent": 1 }, { "text": "describe('foo') callback", "kind": "function", "childItems": [ { "text": "test(`a ${a} b {b}`) callback", "kind": "function" } ], "indent": 1 } ]);
{ "end_byte": 2093, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions3.ts" }
TypeScript/tests/cases/fourslash/syntheticImportFromBabelGeneratedFile2.ts_0_466
/// <reference path='fourslash.ts'/> // @allowJs: true // @allowSyntheticDefaultImports: true // @Filename: /a.js ////Object.defineProperty(exports, "__esModule", { //// value: true ////}); ////exports.default = f; /////** //// * Run this function //// * @param {string} t //// */ ////function f(t) {} // @Filename: /b.js ////import f from "./a" /////**/f verify.quickInfoAt("", `(alias) function f(t: string): void import f`, "Run this function"); // Passes
{ "end_byte": 466, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntheticImportFromBabelGeneratedFile2.ts" }
TypeScript/tests/cases/fourslash/completionInTypeOf2.ts_0_180
/// <reference path='fourslash.ts'/> ////module m1c { //// export class C { foo(): void; } ////} ////var x: typeof m1c./*1*/; verify.completions({ marker: "1", exact: "C" });
{ "end_byte": 180, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionInTypeOf2.ts" }
TypeScript/tests/cases/fourslash/completionListInObjectBindingPattern06.ts_0_238
/// <reference path='fourslash.ts'/> ////interface I { //// property1: number; //// property2: string; ////} //// ////var foo: I; ////var { property1, property2, /**/ } = foo; verify.completions({ marker: "", exact: undefined });
{ "end_byte": 238, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectBindingPattern06.ts" }
TypeScript/tests/cases/fourslash/codeFixOverrideModifier13.ts_0_296
/// <reference path='fourslash.ts' /> // @noImplicitOverride: true ////class A { //// foo() {} ////} //// ////class B extends A { //// [|public foo() {}|] ////} verify.codeFix({ description: "Add 'override' modifier", newRangeContent: "public override foo() {}", index: 0 })
{ "end_byte": 296, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixOverrideModifier13.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromFunctionUsage.ts_0_334
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////function wrap( [| arr |] ) { //// arr.other(function (a: number, b: number) { return a < b ? -1 : 1 }); //// } // https://github.com/Microsoft/TypeScript/issues/29330 verify.rangeAfterCodeFix("arr: { other: (arg0: (a: number, b: number) => 1 | -1) => void; }");
{ "end_byte": 334, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromFunctionUsage.ts" }
TypeScript/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature01.ts_0_359
/// <reference path="fourslash.ts" /> ////interface I<TString, TNumber> { //// [s: string]: TString; //// [s: number]: TNumber; ////} //// ////declare function foo<TString, TNumber>(obj: I<TString, TNumber>): { str: T/*1*/ verify.completions({ marker: "1", includes: ["I", "TString", "TNumber"], excludes: ["foo", "obj"], // not types });
{ "end_byte": 359, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature01.ts" }
TypeScript/tests/cases/fourslash/completionListsThroughTransitiveBaseClasses2.ts_0_488
/// <reference path='fourslash.ts'/> ////declare class A { //// foo; ////} ////declare class B extends A { //// bar; ////} ////declare class C extends B { //// baz; ////} //// ////var c = new C(); ////c./*1*/ ////var b = new B(); ////b./*2*/ ////var a = new A(); ////a./*3*/ goTo.eachMarker((_, i) => { const all = ["foo", "bar", "baz"]; verify.completions({ includes: all.slice(0, 3 - i), excludes: all.slice(3 - i) }); edit.insert("foo;"); }); verify.noErrors();
{ "end_byte": 488, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListsThroughTransitiveBaseClasses2.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionJsModuleName.ts_0_205
/// <reference path='fourslash.ts'/> // @allowJs: true // @Filename: foo.js /////*2*/module.exports = {}; // @Filename: bar.js ////var x = require([|/*1*/"./foo"|]); verify.baselineGoToDefinition("1");
{ "end_byte": 205, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionJsModuleName.ts" }
TypeScript/tests/cases/fourslash/smartSelection_behindCaret.ts_0_181
/// <reference path="fourslash.ts" /> ////let/**/ x: string // Verifies that the selection goes to 'let' first even though it’s behind the caret verify.baselineSmartSelection();
{ "end_byte": 181, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_behindCaret.ts" }
TypeScript/tests/cases/fourslash/exhaustiveCaseCompletions6.ts_0_675
/// <reference path="fourslash.ts" /> // Quote preferences. // @newline: LF //// declare const p: 'A' | 'B' | 'C'; //// //// switch (p) { //// /*1*/ //// } verify.completions( { marker: "1", isNewIdentifierLocation: false, includes: [ { name: `case 'A': ...`, source: completion.CompletionSource.SwitchCases, sortText: completion.SortText.GlobalsOrKeywords, insertText: `case 'A': case 'B': case 'C':`, }, ], preferences: { includeCompletionsWithInsertText: true, quotePreference: "single", }, }, );
{ "end_byte": 675, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/exhaustiveCaseCompletions6.ts" }
TypeScript/tests/cases/fourslash/renameInheritedProperties8.ts_3_324
/ <reference path='fourslash.ts'/> //// class C implements D { //// [|[|{| "contextRangeIndex": 0 |}prop1|]: string;|] //// } //// //// interface D extends C { //// [|[|{| "contextRangeIndex": 2 |}prop1|]: string;|] //// } //// //// var c: C; //// c.[|prop1|]; verify.baselineRenameAtRangesWithText("prop1");
{ "end_byte": 324, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameInheritedProperties8.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringParameterObjectBindingPatternDefaultValues.ts_0_833
/// <reference path='fourslash.ts' /> ////interface Robot { //// name?: string; //// skill?: string; ////} ////declare var console: { //// log(msg: string): void; ////} ////var hello = "hello"; ////var robotA: Robot = { name: "mower", skill: "mowing" }; ////function foo1({ name: nameA = "<NoName>" }: Robot = { }) { //// console.log(nameA); ////} ////function foo2({ name: nameB = "<NoName>", skill: skillB = "noSkill" }: Robot = {}) { //// console.log(nameB); ////} ////function foo3({ name = "<NoName>" }: Robot = {}) { //// console.log(name); ////} ////foo1(robotA); ////foo1({ name: "Edger", skill: "cutting edges" }); ////foo2(robotA); ////foo2({ name: "Edger", skill: "cutting edges" }); ////foo3(robotA); ////foo3({ name: "Edger", skill: "cutting edges" }); verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 833, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringParameterObjectBindingPatternDefaultValues.ts" }
TypeScript/tests/cases/fourslash/moduleDeclarationDeprecated_suggestion1.ts_0_918
///<reference path="fourslash.ts" /> // @Filename: a.ts ////[|module|] mod1 { export let x: number } ////declare [|module|] mod2 { export let x: number } ////export [|module|] mod3 { export let x: number } ////export declare [|module|] mod4 { export let x: number } ////namespace mod5 { export let x: number } ////declare namespace mod6 { export let x: number } ////declare module "module-augmentation" {} ////declare global {} ////mod1.x = 1; ////mod2.x = 1; ////mod5.x = 1; ////mod6.x = 1; // @Filename: b.ts ////module "global-ambient-module" {} goTo.file("a.ts") const diagnostics = test.ranges().map(range => ({ code: 1540, message: "A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead.", reportsDeprecated: true, range, })); verify.getSuggestionDiagnostics(diagnostics) goTo.file("b.ts") verify.getSuggestionDiagnostics([])
{ "end_byte": 918, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moduleDeclarationDeprecated_suggestion1.ts" }
TypeScript/tests/cases/fourslash/quickInfoOnCircularTypes.ts_0_345
/// <reference path='fourslash.ts' /> ////interface A { (): B; }; ////declare var a: A; ////var xx = a(); //// ////interface B { (): C; }; ////declare var b: B; ////var yy = b(); //// ////interface C { (): A; }; ////declare var c: C; ////var zz = c(); //// ////x/*B*/x = y/*C*/y; verify.quickInfos({ B: "var xx: B", C: "var yy: C" });
{ "end_byte": 345, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnCircularTypes.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesClassExpressionConstructor.ts_0_327
/// <reference path='fourslash.ts' /> ////let A = class Foo { //// [|constructor|](); //// [|constructor|](x: number); //// [|constructor|](y: string); //// [|constructor|](a?: any) { //// } ////} //// ////let B = class D { //// constructor(x: number) { //// } ////} verify.baselineDocumentHighlights();
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesClassExpressionConstructor.ts" }
TypeScript/tests/cases/fourslash/getMatchingBraces.ts_0_977
/// <reference path="fourslash.ts"/> //////curly braces ////module Foo [|{ //// class Bar [|{ //// private f() [|{ //// }|] //// //// private f2() [|{ //// if (true) [|{ }|] [|{ }|]; //// }|] //// }|] ////}|] //// //////parenthesis ////class FooBar { //// private f[|()|] { //// return [|([|(1 + 1)|])|]; //// } //// //// private f2[|()|] { //// if [|(true)|] { } //// } ////} //// //////square brackets ////class Baz { //// private f() { //// var a: any[|[]|] = [|[[|[1, 2]|], [|[3, 4]|], 5]|]; //// } ////} //// ////// angular brackets ////class TemplateTest [|<T1, T2 extends Array>|] { //// public foo(a, b) { //// return [|<any>|] a; //// } ////} ////const x: Array[|<() => void>|] = []; for (const range of test.ranges()) { verify.matchingBracePositionInCurrentFile(range.pos, range.end - 1); verify.matchingBracePositionInCurrentFile(range.end - 1, range.pos); }
{ "end_byte": 977, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getMatchingBraces.ts" }
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction6.ts_0_291
/// <reference path='fourslash.ts' /> // @target: es2015 ////async function fn(): undefined {} verify.codeFix({ index: 0, description: [ts.Diagnostics.Replace_0_with_Promise_1.message, "undefined", "undefined"], newFileContent: `async function fn(): Promise<undefined> {}` });
{ "end_byte": 291, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction6.ts" }
TypeScript/tests/cases/fourslash/codeFixAddOptionalParam11.ts_0_312
/// <reference path="fourslash.ts" /> ////class C { //// [|private p = () => {}|] //// m(a: boolean) { //// this.p(a); //// } ////} verify.codeFix({ description: [ts.Diagnostics.Add_optional_parameter_to_0.message, "p"], index: 1, newRangeContent: "private p = (a?: boolean) => {}" });
{ "end_byte": 312, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddOptionalParam11.ts" }
TypeScript/tests/cases/fourslash/quickInfoPropertyTag.ts_0_304
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: /a.js /////** //// * @typedef I //// * @property {number} x Doc //// * More doc //// */ //// /////** @type {I} */ ////const obj = { /**/x: 10 }; verify.quickInfoAt("", "(property) x: number", "Doc\nMore doc");
{ "end_byte": 304, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoPropertyTag.ts" }
TypeScript/tests/cases/fourslash/formattingFatArrowFunctions.ts_0_7195
/// <reference path="fourslash.ts" /> ////// valid //// ( ) => 1 ;/*1*/ //// ( arg ) => 2 ;/*2*/ //// arg => 2 ;/*3*/ //// arg=>2 ;/*3a*/ //// ( arg = 1 ) => 3 ;/*4*/ //// ( arg ? ) => 4 ;/*5*/ //// ( arg : number ) => 5 ;/*6*/ //// ( arg : number = 0 ) => 6 ;/*7*/ //// ( arg ? : number ) => 7 ;/*8*/ //// ( ... arg : number [ ] ) => 8 ;/*9*/ //// ( arg1 , arg2 ) => 12 ;/*10*/ //// ( arg1 = 1 , arg2 =3 ) => 13 ;/*11*/ //// ( arg1 ? , arg2 ? ) => 14 ;/*12*/ //// ( arg1 : number , arg2 : number ) => 15 ;/*13*/ //// ( arg1 : number = 0 , arg2 : number = 1 ) => 16 ;/*14*/ //// ( arg1 ? : number , arg2 ? : number ) => 17 ;/*15*/ //// ( arg1 , ... arg2 : number [ ] ) => 18 ;/*16*/ //// ( arg1 , arg2 ? : number ) => 19 ;/*17*/ //// ////// in paren //// ( ( ) => 21 ) ;/*18*/ //// ( ( arg ) => 22 ) ;/*19*/ //// ( ( arg = 1 ) => 23 ) ;/*20*/ //// ( ( arg ? ) => 24 ) ;/*21*/ //// ( ( arg : number ) => 25 ) ;/*22*/ //// ( ( arg : number = 0 ) => 26 ) ;/*23*/ //// ( ( arg ? : number ) => 27 ) ;/*24*/ //// ( ( ... arg : number [ ] ) => 28 ) ;/*25*/ //// ////// in multiple paren //// ( ( ( ( ( arg ) => { return 32 ; } ) ) ) ) ;/*26*/ //// ////// in ternary exression //// false ? ( ) => 41 : null ;/*27*/ //// false ? ( arg ) => 42 : null ;/*28*/ //// false ? ( arg = 1 ) => 43 : null ;/*29*/ //// false ? ( arg ? ) => 44 : null ;/*30*/ //// false ? ( arg : number ) => 45 : null ;/*31*/ //// false ? ( arg ? : number ) => 46 : null ;/*32*/ //// false ? ( arg ? : number = 0 ) => 47 : null ;/*33*/ //// false ? ( ... arg : number [ ] ) => 48 : null ;/*34*/ //// ////// in ternary exression within paren //// false ? ( ( ) => 51 ) : null ;/*35*/ //// false ? ( ( arg ) => 52 ) : null ;/*36*/ //// false ? ( ( arg = 1 ) => 53 ) : null ;/*37*/ //// false ? ( ( arg ? ) => 54 ) : null ;/*38*/ //// false ? ( ( arg : number ) => 55 ) : null ;/*39*/ //// false ? ( ( arg ? : number ) => 56 ) : null ;/*40*/ //// false ? ( ( arg ? : number = 0 ) => 57 ) : null ;/*41*/ //// false ? ( ( ... arg : number [ ] ) => 58 ) : null ;/*42*/ //// ////// ternary exression's else clause //// false ? null : ( ) => 61 ;/*43*/ //// false ? null : ( arg ) => 62 ;/*44*/ //// false ? null : ( arg = 1 ) => 63 ;/*45*/ //// false ? null : ( arg ? ) => 64 ;/*46*/ //// false ? null : ( arg : number ) => 65 ;/*47*/ //// false ? null : ( arg ? : number ) => 66 ;/*48*/ //// false ? null : ( arg ? : number = 0 ) => 67 ;/*49*/ //// false ? null : ( ... arg : number [ ] ) => 68 ;/*50*/ //// //// ////// nested ternary expressions //// (( a ? ) => { return a ; }) ? ( b ? ) => { return b ; } : ( c ? ) => { return c ; } ;/*51*/ //// //////multiple levels //// (( a ? ) => { return a ; }) ? ( b ) => ( c ) => 81 : ( c ) => ( d ) => 82 ;/*52*/ //// //// ////// In Expressions //// ( ( arg ) => 90 ) instanceof Function ;/*53*/ //// ( ( arg = 1 ) => 91 ) instanceof Function ;/*54*/ //// ( ( arg ? ) => 92 ) instanceof Function ;/*55*/ //// ( ( arg : number ) => 93 ) instanceof Function ;/*56*/ //// ( ( arg : number = 1 ) => 94 ) instanceof Function ;/*57*/ //// ( ( arg ? : number ) => 95 ) instanceof Function ;/*58*/ //// ( ( ... arg : number [ ] ) => 96 ) instanceof Function ;/*59*/ //// ////'' + (( arg ) => 100) ;/*60*/ //// ( ( arg ) => 0 ) + '' + (( arg ) => 101) ;/*61*/ //// ( ( arg = 1 ) => 0 ) + '' + (( arg = 2 ) => 102) ;/*62*/ //// ( ( arg ? ) => 0 ) + '' + (( arg ? ) => 103) ;/*63*/ //// ( ( arg : number ) => 0 ) + '' + (( arg : number ) => 104) ;/*64*/
{ "end_byte": 7195, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingFatArrowFunctions.ts" }
TypeScript/tests/cases/fourslash/formattingFatArrowFunctions.ts_7196_13818
//// ( ( arg : number = 1 ) => 0 ) + '' + (( arg : number = 2 ) => 105) ;/*65*/ //// ( ( arg ? : number ) => 0 ) + '' + (( arg ? : number ) => 106) ;/*66*/ //// ( ( ... arg : number [ ] ) => 0 ) + '' + (( ... arg : number [ ] ) => 107) ;/*67*/ //// ( ( arg1 , arg2 ? ) => 0 ) + '' + (( arg1 , arg2 ? ) => 108) ;/*68*/ //// ( ( arg1 , ... arg2 : number [ ] ) => 0 ) + '' + (( arg1 , ... arg2 : number [ ] ) => 108) ;/*69*/ //// //// ////// Function Parameters /////*70*/function foo ( ... arg : any [ ] ) { } //// /////*71*/foo ( /////*72*/ ( a ) => 110 , /////*73*/ ( ( a ) => 111 ) , /////*74*/ ( a ) => { //// return /*75*/112 ; /////*76*/ } , /////*77*/ ( a ? ) => 113 , /////*78*/ ( a , b ? ) => 114 , /////*79*/ ( a : number ) => 115 , /////*80*/ ( a : number = 0 ) => 116 , /////*81*/ ( a = 0 ) => 117 , /////*82*/ ( a : number = 0 ) => 118 , /////*83*/ ( a ? , b ? : number ) => 118 , /////*84*/ ( ... a : number [ ] ) => 119 , /////*85*/ ( a , b = 0 , ... c : number [ ] ) => 120 , /////*86*/ ( a ) => ( b ) => ( c ) => 121 , /////*87*/ false ? ( a ) => 0 : ( b ) => 122 //// /*88*/) ; format.document(); goTo.marker("1"); verify.currentLineContentIs("() => 1;"); goTo.marker("2"); verify.currentLineContentIs("(arg) => 2;"); goTo.marker("3"); verify.currentLineContentIs("arg => 2;"); goTo.marker("3a"); verify.currentLineContentIs("arg => 2;"); goTo.marker("4"); verify.currentLineContentIs("(arg = 1) => 3;"); goTo.marker("5"); verify.currentLineContentIs("(arg?) => 4;"); goTo.marker("6"); verify.currentLineContentIs("(arg: number) => 5;"); goTo.marker("7"); verify.currentLineContentIs("(arg: number = 0) => 6;"); goTo.marker("8"); verify.currentLineContentIs("(arg?: number) => 7;"); goTo.marker("9"); verify.currentLineContentIs("(...arg: number[]) => 8;"); goTo.marker("10"); verify.currentLineContentIs("(arg1, arg2) => 12;"); goTo.marker("11"); verify.currentLineContentIs("(arg1 = 1, arg2 = 3) => 13;"); goTo.marker("12"); verify.currentLineContentIs("(arg1?, arg2?) => 14;"); goTo.marker("13"); verify.currentLineContentIs("(arg1: number, arg2: number) => 15;"); goTo.marker("14"); verify.currentLineContentIs("(arg1: number = 0, arg2: number = 1) => 16;"); goTo.marker("15"); verify.currentLineContentIs("(arg1?: number, arg2?: number) => 17;"); goTo.marker("16"); verify.currentLineContentIs("(arg1, ...arg2: number[]) => 18;"); goTo.marker("17"); verify.currentLineContentIs("(arg1, arg2?: number) => 19;"); goTo.marker("18"); verify.currentLineContentIs("(() => 21);"); goTo.marker("19"); verify.currentLineContentIs("((arg) => 22);"); goTo.marker("20"); verify.currentLineContentIs("((arg = 1) => 23);"); goTo.marker("21"); verify.currentLineContentIs("((arg?) => 24);"); goTo.marker("22"); verify.currentLineContentIs("((arg: number) => 25);"); goTo.marker("23"); verify.currentLineContentIs("((arg: number = 0) => 26);"); goTo.marker("24"); verify.currentLineContentIs("((arg?: number) => 27);"); goTo.marker("25"); verify.currentLineContentIs("((...arg: number[]) => 28);"); goTo.marker("26"); verify.currentLineContentIs("(((((arg) => { return 32; }))));"); goTo.marker("27"); verify.currentLineContentIs("false ? () => 41 : null;"); goTo.marker("28"); verify.currentLineContentIs("false ? (arg) => 42 : null;"); goTo.marker("29"); verify.currentLineContentIs("false ? (arg = 1) => 43 : null;"); goTo.marker("30"); verify.currentLineContentIs("false ? (arg?) => 44 : null;"); goTo.marker("31"); verify.currentLineContentIs("false ? (arg: number) => 45 : null;"); goTo.marker("32"); verify.currentLineContentIs("false ? (arg?: number) => 46 : null;"); goTo.marker("33"); verify.currentLineContentIs("false ? (arg?: number = 0) => 47 : null;"); goTo.marker("34"); verify.currentLineContentIs("false ? (...arg: number[]) => 48 : null;"); goTo.marker("35"); verify.currentLineContentIs("false ? (() => 51) : null;"); goTo.marker("36"); verify.currentLineContentIs("false ? ((arg) => 52) : null;"); goTo.marker("37"); verify.currentLineContentIs("false ? ((arg = 1) => 53) : null;"); goTo.marker("38"); verify.currentLineContentIs("false ? ((arg?) => 54) : null;"); goTo.marker("39"); verify.currentLineContentIs("false ? ((arg: number) => 55) : null;"); goTo.marker("40"); verify.currentLineContentIs("false ? ((arg?: number) => 56) : null;"); goTo.marker("41"); verify.currentLineContentIs("false ? ((arg?: number = 0) => 57) : null;"); goTo.marker("42"); verify.currentLineContentIs("false ? ((...arg: number[]) => 58) : null;"); goTo.marker("43"); verify.currentLineContentIs("false ? null : () => 61;"); goTo.marker("44"); verify.currentLineContentIs("false ? null : (arg) => 62;"); goTo.marker("45"); verify.currentLineContentIs("false ? null : (arg = 1) => 63;"); goTo.marker("46"); verify.currentLineContentIs("false ? null : (arg?) => 64;"); goTo.marker("47"); verify.currentLineContentIs("false ? null : (arg: number) => 65;"); goTo.marker("48"); verify.currentLineContentIs("false ? null : (arg?: number) => 66;"); goTo.marker("49"); verify.currentLineContentIs("false ? null : (arg?: number = 0) => 67;"); goTo.marker("50"); verify.currentLineContentIs("false ? null : (...arg: number[]) => 68;"); goTo.marker("51"); verify.currentLineContentIs("((a?) => { return a; }) ? (b?) => { return b; } : (c?) => { return c; };"); goTo.marker("52");
{ "end_byte": 13818, "start_byte": 7196, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingFatArrowFunctions.ts" }
TypeScript/tests/cases/fourslash/formattingFatArrowFunctions.ts_13819_16895
verify.currentLineContentIs("((a?) => { return a; }) ? (b) => (c) => 81 : (c) => (d) => 82;"); goTo.marker("53"); verify.currentLineContentIs("((arg) => 90) instanceof Function;"); goTo.marker("54"); verify.currentLineContentIs("((arg = 1) => 91) instanceof Function;"); goTo.marker("55"); verify.currentLineContentIs("((arg?) => 92) instanceof Function;"); goTo.marker("56"); verify.currentLineContentIs("((arg: number) => 93) instanceof Function;"); goTo.marker("57"); verify.currentLineContentIs("((arg: number = 1) => 94) instanceof Function;"); goTo.marker("58"); verify.currentLineContentIs("((arg?: number) => 95) instanceof Function;"); goTo.marker("59"); verify.currentLineContentIs("((...arg: number[]) => 96) instanceof Function;"); goTo.marker("60"); verify.currentLineContentIs("'' + ((arg) => 100);"); goTo.marker("61"); verify.currentLineContentIs("((arg) => 0) + '' + ((arg) => 101);"); goTo.marker("62"); verify.currentLineContentIs("((arg = 1) => 0) + '' + ((arg = 2) => 102);"); goTo.marker("63"); verify.currentLineContentIs("((arg?) => 0) + '' + ((arg?) => 103);"); goTo.marker("64"); verify.currentLineContentIs("((arg: number) => 0) + '' + ((arg: number) => 104);"); goTo.marker("65"); verify.currentLineContentIs("((arg: number = 1) => 0) + '' + ((arg: number = 2) => 105);"); goTo.marker("66"); verify.currentLineContentIs("((arg?: number) => 0) + '' + ((arg?: number) => 106);"); goTo.marker("67"); verify.currentLineContentIs("((...arg: number[]) => 0) + '' + ((...arg: number[]) => 107);"); goTo.marker("68"); verify.currentLineContentIs("((arg1, arg2?) => 0) + '' + ((arg1, arg2?) => 108);"); goTo.marker("69"); verify.currentLineContentIs("((arg1, ...arg2: number[]) => 0) + '' + ((arg1, ...arg2: number[]) => 108);"); goTo.marker("70"); verify.currentLineContentIs("function foo(...arg: any[]) { }"); goTo.marker("71"); verify.currentLineContentIs("foo("); goTo.marker("72"); verify.currentLineContentIs(" (a) => 110,"); goTo.marker("73"); verify.currentLineContentIs(" ((a) => 111),"); goTo.marker("74"); verify.currentLineContentIs(" (a) => {"); goTo.marker("75"); verify.currentLineContentIs(" return 112;"); goTo.marker("76"); verify.currentLineContentIs(" },"); goTo.marker("77"); verify.currentLineContentIs(" (a?) => 113,"); goTo.marker("78"); verify.currentLineContentIs(" (a, b?) => 114,"); goTo.marker("79"); verify.currentLineContentIs(" (a: number) => 115,"); goTo.marker("80"); verify.currentLineContentIs(" (a: number = 0) => 116,"); goTo.marker("81"); verify.currentLineContentIs(" (a = 0) => 117,"); goTo.marker("82"); verify.currentLineContentIs(" (a: number = 0) => 118,"); goTo.marker("83"); verify.currentLineContentIs(" (a?, b?: number) => 118,"); goTo.marker("84"); verify.currentLineContentIs(" (...a: number[]) => 119,"); goTo.marker("85"); verify.currentLineContentIs(" (a, b = 0, ...c: number[]) => 120,"); goTo.marker("86"); verify.currentLineContentIs(" (a) => (b) => (c) => 121,"); goTo.marker("87"); verify.currentLineContentIs(" false ? (a) => 0 : (b) => 122");
{ "end_byte": 16895, "start_byte": 13819, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingFatArrowFunctions.ts" }
TypeScript/tests/cases/fourslash/removeDuplicateIdentifier.ts_0_146
/// <reference path="fourslash.ts" /> ////class foo{} ////function foo() { return null; } goTo.bof(); edit.deleteAtCaret("class foo{}".length);
{ "end_byte": 146, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/removeDuplicateIdentifier.ts" }
TypeScript/tests/cases/fourslash/renameThis.ts_0_403
/// <reference path='fourslash.ts'/> ////function f([|this|]) { //// return [|this|]; ////} ////this/**/; ////const _ = { [|[|{| "contextRangeIndex": 2 |}this|]: 0|] }.[|this|]; const [r0, r1, r2Def, r2, r3] = test.ranges() // Trying to rename a non-parameter 'this' should fail goTo.marker(); verify.renameInfoFailed("You cannot rename this element."); verify.baselineRename([r0, r1, r2, r3]);
{ "end_byte": 403, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameThis.ts" }
TypeScript/tests/cases/fourslash/renameFromNodeModulesDep3.ts_0_1091
/// <reference path="fourslash.ts" /> // @Filename: /packages/first/index.d.ts ////import { /*ok*/[|Foo|] } from "foo"; ////declare type FooBar = Foo[/*ok2*/"[|bar|]"]; // @Filename: /packages/foo/package.json //// { "types": "index.d.ts" } // @Filename: /packages/foo/index.d.ts ////export interface Foo { //// /*ok3*/[|bar|]: string; ////} // @link: /packages/foo -> /packages/first/node_modules/foo const [ okRange, ok2Range, ok3Range ] = test.ranges(); goTo.marker("ok"); verify.renameInfoSucceeded( undefined, undefined, undefined, undefined, undefined, okRange, { providePrefixAndSuffixTextForRename: true }); verify.renameInfoSucceeded( undefined, undefined, undefined, undefined, undefined, okRange, { providePrefixAndSuffixTextForRename: false }); goTo.marker("ok2"); verify.renameInfoSucceeded( undefined, undefined, undefined, undefined, undefined, ok2Range); goTo.marker("ok3"); verify.renameInfoSucceeded(undefined, undefined, undefined, undefined, undefined, ok3Range);
{ "end_byte": 1091, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameFromNodeModulesDep3.ts" }
TypeScript/tests/cases/fourslash/codeFixConvertToTypeOnlyImport4.ts_0_512
/// <reference path="fourslash.ts" /> // @module: esnext // @verbatimModuleSyntax: true // @filename: /b.ts ////export interface I {} ////export const foo = {}; // @filename: /a.ts ////import { I, foo } from "./b"; goTo.file("/a.ts"); verify.codeFix({ index: 0, description: ts.Diagnostics.Use_import_type.message, newFileContent: `import type { I, foo } from "./b";` }); verify.codeFix({ index: 1, description: `Use 'type I'`, newFileContent: `import { type I, foo } from "./b";` });
{ "end_byte": 512, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToTypeOnlyImport4.ts" }
TypeScript/tests/cases/fourslash/formattingCommentsBeforeErrors.ts_0_375
/// <reference path='fourslash.ts' /> ////module A { //// interface B { //// // a //// // b //// baz(); /////*0*/ // d /*1*/asd a //// // e //// foo(); //// // f asd //// // g as //// bar(); //// } ////} goTo.marker("1"); edit.insert("\n"); goTo.marker("0"); verify.currentLineContentIs(" // d ");
{ "end_byte": 375, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingCommentsBeforeErrors.ts" }
TypeScript/tests/cases/fourslash/getNavigationBarItems.ts_0_1067
/// <reference path="fourslash.ts" /> ////class C { //// foo; //// ["bar"]: string; ////} verify.navigationTree({ "text": "<global>", "kind": "script", "childItems": [ { "text": "C", "kind": "class", "childItems": [ { "text": "[\"bar\"]", "kind": "property" }, { "text": "foo", "kind": "property" } ] } ] }); verify.navigationBar([ { "text": "<global>", "kind": "script", "childItems": [ { "text": "C", "kind": "class" } ] }, { "text": "C", "kind": "class", "childItems": [ { "text": "[\"bar\"]", "kind": "property" }, { "text": "foo", "kind": "property" } ], "indent": 1 } ]);
{ "end_byte": 1067, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getNavigationBarItems.ts" }
TypeScript/tests/cases/fourslash/getEmitOutputWithDeclarationFile.ts_0_363
/// <reference path="fourslash.ts" /> // @BaselineFile: getEmitOutputWithDeclarationFile.baseline // @Filename: decl.d.ts // @emitThisFile: true //// interface I { a: string; } // @Filename: inputFile2.ts // @emitThisFile: true //// var x1: string = "hello world"; //// class Foo{ //// x : string; //// y : number; //// } verify.baselineGetEmitOutput();
{ "end_byte": 363, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputWithDeclarationFile.ts" }
TypeScript/tests/cases/fourslash/commentsUnion.ts_0_269
/// <reference path='fourslash.ts' /> ////var a: Array<string> | Array<number>; ////a./*1*/length verify.quickInfoAt("1", "(property) Array<T>.length: number", "Gets or sets the length of the array. This is a number one higher than the highest index in the array.");
{ "end_byte": 269, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/commentsUnion.ts" }
TypeScript/tests/cases/fourslash/editJsdocType.ts_0_214
/// <reference path='fourslash.ts' /> // @allowJs: true // @noLib: true // @Filename: /a.js /////** @type/**/ */ ////const x = 0; goTo.marker(); verify.quickInfoIs(""); edit.insert(" "); verify.quickInfoIs("");
{ "end_byte": 214, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/editJsdocType.ts" }
TypeScript/tests/cases/fourslash/documentHighlightDefaultInKeyword.ts_3_108
/ <reference path='fourslash.ts'/> ////[|case|] ////[|default|] verify.baselineDocumentHighlights();
{ "end_byte": 108, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlightDefaultInKeyword.ts" }
TypeScript/tests/cases/fourslash/errorConsistency.ts_0_374
/// <reference path="fourslash.ts"/> ////interface Int<T> { ////val<U>(f: (t: T) => U): Int<U>; ////} ////declare var v1: Int<string>; ////var /*1*/v2/*2*/: Int<number> = v1; goTo.eof(); verify.errorExistsBetweenMarkers("1", "2"); verify.numberOfErrorsInCurrentFile(1); edit.backspace(1); verify.errorExistsBetweenMarkers("1", "2"); verify.numberOfErrorsInCurrentFile(1);
{ "end_byte": 374, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/errorConsistency.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_importType.ts_0_300
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @Filename: /a.js ////export {}; /////** @typedef {number} T */ // @Filename: /b.js /////** @type {T} */ ////const x = 0; goTo.file("/b.js"); verify.importFixAtPosition([ `/** @type {import("./a").T} */ const x = 0;`]);
{ "end_byte": 300, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_importType.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportAllowSyntheticDefaultImports1.ts_0_322
/// <reference path="fourslash.ts" /> // @Module: system // @Filename: a/f1.ts //// [|export var x = 0; //// bar/*0*/();|] // @Filename: a/foo.d.ts //// declare function bar(): number; //// export = bar; //// export as namespace bar; verify.importFixAtPosition([ `import bar from "./foo"; export var x = 0; bar();` ]);
{ "end_byte": 322, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportAllowSyntheticDefaultImports1.ts" }
TypeScript/tests/cases/fourslash/semicolonFormattingAfterArrayLiteral.ts_0_184
/// <reference path='fourslash.ts' /> ////[1,2]/**/ goTo.marker(); edit.insert(";"); // Adding smicolon should format the innermost statement verify.currentLineContentIs('[1, 2];');
{ "end_byte": 184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semicolonFormattingAfterArrayLiteral.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingParam16.ts_0_600
/// <reference path="fourslash.ts" /> ////function f(a: string, b: string): string ////function f(a: number, b: number): number ////function f(a: number | string, b: number | string): number | string { //// return a + b; ////} ////f(1, 2, "") verify.codeFix({ description: [ts.Diagnostics.Add_missing_parameter_to_0.message, "f"], index: 0, newFileContent: `function f(a: string, b: string, p0: string): string function f(a: number, b: number, p0: string): number function f(a: number | string, b: number | string, p0: string): number | string { return a + b; } f(1, 2, "")` });
{ "end_byte": 600, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingParam16.ts" }
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization18.ts_0_285
/// <reference path='fourslash.ts' /> // @strict: true //// class T { //// a: string; // comment //// } verify.codeFix({ description: `Add definite assignment assertion to property 'a: string;'`, newFileContent: `class T { a!: string; // comment }`, index: 1 })
{ "end_byte": 285, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization18.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementClassAbstractGettersAndSetters.ts_0_982
/// <reference path='fourslash.ts' /> ////abstract class A { //// abstract get a(): string; //// abstract set a(newName: string); //// //// abstract get b(): number; //// //// abstract set c(arg: number | string); //// //// abstract accessor d: string; ////} //// ////class C implements A {} verify.codeFix({ description: "Implement interface 'A'", newFileContent: `abstract class A { abstract get a(): string; abstract set a(newName: string); abstract get b(): number; abstract set c(arg: number | string); abstract accessor d: string; } class C implements A { get a(): string { throw new Error("Method not implemented."); } set a(newName: string) { throw new Error("Method not implemented."); } get b(): number { throw new Error("Method not implemented."); } set c(arg: string | number) { throw new Error("Method not implemented."); } accessor d: string; }`, });
{ "end_byte": 982, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementClassAbstractGettersAndSetters.ts" }
TypeScript/tests/cases/fourslash/completionsImport_ambient.ts_0_1123
/// <reference path="fourslash.ts" /> // @module: commonjs // @Filename: a.d.ts //// declare namespace foo { class Bar {} } //// declare module 'path1' { //// import Bar = foo.Bar; //// export default Bar; //// } //// declare module 'path2longer' { //// import Bar = foo.Bar; //// export {Bar}; //// } //// // @Filename: b.ts //// Ba/**/ verify.completions({ marker: "", exact: completion.globalsPlus([ { name: "foo", sortText: completion.SortText.GlobalsOrKeywords }, { name: "Bar", source: "path1", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, { name: "Bar", source: "path2longer", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, ]), preferences: { includeCompletionsForModuleExports: true } }); verify.applyCodeActionFromCompletion("", { name: "Bar", source: "path2longer", description: `Add import from "path2longer"`, newFileContent: `import { Bar } from "path2longer";\n\nBa`, preferences: { includeCompletionsForModuleExports: true } });
{ "end_byte": 1123, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_ambient.ts" }
TypeScript/tests/cases/fourslash/quickInfoCircularInstantiationExpression.ts_0_135
/// <reference path="fourslash.ts" /> ////declare function foo<T>(t: T): typeof foo<T>; /////**/foo(""); verify.baselineQuickInfo();
{ "end_byte": 135, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoCircularInstantiationExpression.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_decorators3.ts_0_506
/// <reference path='fourslash.ts' /> // @experimentalDecorators: true // @Filename: /a.ts ////const decorator1: any = () => {}; ////const decorator2: any = () => {}; ////[|@decorator1 @decorator2 class Foo { ////}|] verify.noErrors(); verify.moveToNewFile({ newFileContents: { "/a.ts": `export const decorator1: any = () => {}; export const decorator2: any = () => {}; `, "/Foo.ts": `import { decorator1, decorator2 } from "./a"; @decorator1 @decorator2 class Foo { } ` } });
{ "end_byte": 506, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_decorators3.ts" }