_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/codeFixTopLevelAwait_notAModule.ts_0_461
/// <reference path="fourslash.ts" /> // @filename: /dir/a.ts ////declare const p: Promise<number>; ////await p; // @filename: /dir/tsconfig.json ////{ //// "compilerOptions": { //// "target": "esnext", //// "module": "esnext" //// } ////} verify.codeFix({ description: ts.Diagnostics.Add_export_to_make_this_file_into_a_module.message, index: 0, newFileContent: `declare const p: Promise<number>; await p; export { }; ` });
{ "end_byte": 461, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelAwait_notAModule.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_parameter_all.ts_0_1626
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @noUnusedParameters: true ////function f(a, b, { x, y }) { b; } ////f(0, 1, { x: 1, y: 1 }); ////function g(a, b, { x, y }: { x: number, y: number }) { b; } ////g(); ////function h(a, b?) { a; } ////h(1); ////function i(x = 1) { } ////i(); //// ////function container(o) { //// const { x, y } = { x: 1, y: 2 } //// const { a, b } = o //// const [ z, ka ] = [ 3, 4 ] //// const [ c, d ] = o ////} //// ////class C { //// m(a, b, c) { b; } //// n(a, b, c) { b; } ////} ////new C().m(0, 1, 2); ////new C().n(); //// ////// Test of deletedAncestors ////function a(a: any, unused: any) { a; } ////function b(a: any, unused: any) { a; } ////function c(a: any, unused: any) { a; } //// ////b(1, { //// prop: a(2, [ //// b(3, a(4, undefined)), //// ]), ////}); ////b(1, { prop: c() }); verify.codeFixAll({ fixId: "unusedIdentifier_delete", fixAllDescription: ts.Diagnostics.Delete_all_unused_declarations.message, newFileContent: `function f(a, b, { x, y }) { b; } f(0, 1, { x: 1, y: 1 }); function g(b) { b; } g(); function h(a) { a; } h(1); function i(x = 1) { } i(); function container(o) { const { x, y } = { x: 1, y: 2 } const { a, b } = o const [ z, ka ] = [ 3, 4 ] const [ c, d ] = o } class C { m(a, b, c) { b; } n(b) { b; } } new C().m(0, 1, 2); new C().n(); // Test of deletedAncestors function a(a: any, unused: any) { a; } function b(a: any, unused: any) { a; } function c(a: any) { a; } b(1, { prop: a(2, [ b(3, a(4, undefined)), ]), }); b(1, { prop: c() });`, });
{ "end_byte": 1626, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_parameter_all.ts" }
TypeScript/tests/cases/fourslash/codeFixImportNonExportedMember_all3.ts_0_484
/// <reference path="fourslash.ts" /> // @module: esnext // @filename: /a.ts ////let a = 1, b = 1; ////let c = 1, d = 1; ////export const e = 1; // @filename: /b.ts ////import { b, d } from "./a"; goTo.file("/b.ts"); verify.codeFixAll({ fixId: "fixImportNonExportedMember", fixAllDescription: ts.Diagnostics.Export_all_referenced_locals.message, newFileContent: { "/a.ts": `let a = 1, b = 1; let c = 1, d = 1; export const e = 1; export { b, d }; ` }, });
{ "end_byte": 484, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImportNonExportedMember_all3.ts" }
TypeScript/tests/cases/fourslash/completionsUnion.ts_0_403
/// <reference path="fourslash.ts" /> ////interface I { x: number; } ////interface Many<T> extends ReadonlyArray<T> { extra: number; } ////class C { private priv: number; } ////const x: I | I[] | Many<string> | C = { /**/ }; // We specifically filter out any array-like types. // Private members will be excluded by `createUnionOrIntersectionProperty`. verify.completions({ marker: "", exact: "x" });
{ "end_byte": 403, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsUnion.ts" }
TypeScript/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_Generics.ts_0_277
/// <reference path='fourslash.ts' /> ////interface A</*genericName1*/ ////class A</*genericName2*/ ////class B<T, /*genericName3*/ ////class A{ //// f</*genericName4*/ ////function A</*genericName5*/ verify.completions({ marker: test.markers(), exact: undefined });
{ "end_byte": 277, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_Generics.ts" }
TypeScript/tests/cases/fourslash/chainedFunctionFunctionArgIndent.ts_0_321
/// <reference path='fourslash.ts' /> //// declare var $: any; //// $(".contentDiv").each(function (index, element) {/**/ //// // <-- ensure cursor is here after return on above //// }); goTo.marker(); edit.insert("\n"); verify.indentationIs(4); edit.insert("}"); verify.indentationIs(4); // keep arguments indented
{ "end_byte": 321, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/chainedFunctionFunctionArgIndent.ts" }
TypeScript/tests/cases/fourslash/unusedTypeParametersWithTrivia4.ts_0_310
/// <reference path="fourslash.ts" /> // @noUnusedParameters: true ////export type Foo< //// T1 extends any, //// T2 extends any //// /* comment */> = () => void; verify.codeFix({ description: ts.Diagnostics.Remove_type_parameters.message, newFileContent: "export type Foo = () => void;" });
{ "end_byte": 310, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedTypeParametersWithTrivia4.ts" }
TypeScript/tests/cases/fourslash/genericInterfacePropertyInference1.ts_0_3997
/// <reference path='fourslash.ts'/> ////interface I { //// x: number; ////} //// ////var anInterface: I; ////interface IG<T> { //// x: T; ////} ////var aGenericInterface: IG<number>; //// ////class C<T> implements IG<T> { //// x: T; ////} //// ////interface Foo<T> { //// prim1: number; //// prim2: string; //// ofT: T; //// ofFooNum: Foo<number>; //// ofInterface: I; //// ofIG4: { x: number }; //// ofIG6: { x: T }; //// ofC2: C<number>; //// ofC4: C<{ x: T }> ////} //// ////var f: Foo<any>; ////var f2: Foo<number>; ////var f3: Foo<I>; ////var f4: Foo<{ x: number }>; ////var f5: Foo<Foo<number>>; //// ////// T is any ////var f_/*a1*/r1 = f.prim1; ////var f_/*a2*/r2 = f.prim2; ////var f_/*a3*/r3 = f.ofT; ////var f_/*a4*/r5 = f.ofFooNum; ////var f_/*a5*/r8 = f.ofInterface; ////var f_/*a6*/r12 = f.ofIG4; ////var f_/*a7*/r14 = f.ofIG6; ////var f_/*a8*/r18 = f.ofC2; ////var f_/*a9*/r20 = f.ofC4; //// ////// T is number ////var f2_/*b1*/r1 = f2.prim1; ////var f2_/*b2*/r2 = f2.prim2; ////var f2_/*b3*/r3 = f2.ofT; ////var f2_/*b4*/r5 = f2.ofFooNum; ////var f2_/*b5*/r8 = f2.ofInterface; ////var f2_/*b6*/r12 = f2.ofIG4; ////var f2_/*b7*/r14 = f2.ofIG6; ////var f2_/*b8*/r18 = f2.ofC2; ////var f2_/*b9*/r20 = f2.ofC4; //// ////// T is I ////var f3_/*c1*/r1 = f3.prim1; ////var f3_/*c2*/r2 = f3.prim2; ////var f3_/*c3*/r3 = f3.ofT; ////var f3_/*c4*/r5 = f3.ofFooNum; ////var f3_/*c5*/r8 = f3.ofInterface; ////var f3_/*c6*/r12 = f3.ofIG4; ////var f3_/*c7*/r14 = f3.ofIG6; ////var f3_/*c8*/r18 = f3.ofC2; ////var f3_/*c9*/r20 = f3.ofC4; //// ////// T is {x: number} ////var f4_/*d1*/r1 = f4.prim1; ////var f4_/*d2*/r2 = f4.prim2; ////var f4_/*d3*/r3 = f4.ofT; ////var f4_/*d4*/r5 = f4.ofFooNum; ////var f4_/*d5*/r8 = f4.ofInterface; ////var f4_/*d6*/r12 = f4.ofIG4; ////var f4_/*d7*/r14 = f4.ofIG6; ////var f4_/*d8*/r18 = f4.ofC2; ////var f4_/*d9*/r20 = f4.ofC4; //// ////// T is Foo<number> ////var f5_/*e1*/r1 = f5.prim1; ////var f5_/*e2*/r2 = f5.prim2; ////var f5_/*e3*/r3 = f5.ofT; ////var f5_/*e4*/r5 = f5.ofFooNum; ////var f5_/*e5*/r8 = f5.ofInterface; ////var f5_/*e6*/r12 = f5.ofIG4; ////var f5_/*e7*/r14 = f5.ofIG6; ////var f5_/*e8*/r18 = f5.ofC2; ////var f5_/*e9*/r20 = f5.ofC4; verify.noErrors(); verify.quickInfos({ "a1": "var f_r1: number", "a2": "var f_r2: string", "a3": "var f_r3: any", "a4": "var f_r5: Foo<number>", "a5": "var f_r8: I", "a6": "var f_r12: {\n x: number;\n}", "a7": "var f_r14: {\n x: any;\n}", "a8": "var f_r18: C<number>", "a9": "var f_r20: C<{\n x: any;\n}>", "b1": "var f2_r1: number", "b2": "var f2_r2: string", "b3": "var f2_r3: number", "b4": "var f2_r5: Foo<number>", "b5": "var f2_r8: I", "b6": "var f2_r12: {\n x: number;\n}", "b7": "var f2_r14: {\n x: number;\n}", "b8": "var f2_r18: C<number>", "b9": "var f2_r20: C<{\n x: number;\n}>", "c1": "var f3_r1: number", "c2": "var f3_r2: string", "c3": "var f3_r3: I", "c4": "var f3_r5: Foo<number>", "c5": "var f3_r8: I", "c6": "var f3_r12: {\n x: number;\n}", "c7": "var f3_r14: {\n x: I;\n}", "c8": "var f3_r18: C<number>", "c9": "var f3_r20: C<{\n x: I;\n}>", "d1": "var f4_r1: number", "d2": "var f4_r2: string", "d3": "var f4_r3: {\n x: number;\n}", "d4": "var f4_r5: Foo<number>", "d5": "var f4_r8: I", "d6": "var f4_r12: {\n x: number;\n}", "d7": "var f4_r14: {\n x: {\n x: number;\n };\n}", "d8": "var f4_r18: C<number>", "d9": "var f4_r20: C<{\n x: {\n x: number;\n };\n}>", "e1": "var f5_r1: number", "e2": "var f5_r2: string", "e3": "var f5_r3: Foo<number>", "e4": "var f5_r5: Foo<number>", "e5": "var f5_r8: I", "e6": "var f5_r12: {\n x: number;\n}", "e7": "var f5_r14: {\n x: Foo<number>;\n}", "e8": "var f5_r18: C<number>", "e9": "var f5_r20: C<{\n x: Foo<number>;\n}>" });
{ "end_byte": 3997, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericInterfacePropertyInference1.ts" }
TypeScript/tests/cases/fourslash/augmentedTypesModule2.ts_0_537
/// <reference path='fourslash.ts'/> ////function /*11*/m2f(x: number) { }; ////namespace m2f { export interface I { foo(): void } } ////var x: m2f./*1*/ ////var /*2*/r = m2f/*3*/; verify.quickInfoAt("11", "function m2f(x: number): void\nnamespace m2f"); verify.completions({ marker: "1", exact: "I" }); edit.insert('I.'); verify.completions({ exact: undefined }); edit.backspace(1); verify.quickInfoAt("2", "var r: (x: number) => void"); goTo.marker('3'); edit.insert('('); verify.signatureHelp({ text: "m2f(x: number): void" });
{ "end_byte": 537, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/augmentedTypesModule2.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingMember26.ts_0_297
/// <reference path='fourslash.ts' /> ////[|type Foo = {};|] ////function f(foo: Foo) { //// foo.x = 1; ////} verify.codeFix({ description: [ts.Diagnostics.Add_index_signature_for_property_0.message, "x"], index: 1, newRangeContent: `type Foo = { [x: string]: number; };` });
{ "end_byte": 297, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember26.ts" }
TypeScript/tests/cases/fourslash/todoComments5.ts_0_98
//// /* //// [|TODO 1|] //// [|TODO 2|] //// */ verify.todoCommentsInCurrentFile(["TODO"]);
{ "end_byte": 98, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/todoComments5.ts" }
TypeScript/tests/cases/fourslash/completionListForTransitivelyExportedMembers02.ts_3_745
/<reference path="fourslash.ts" /> // @Filename: A.ts ////export interface I1 { one: number } ////export interface I2 { two: string } ////export type I1_OR_I2 = I1 | I2; //// ////export class C1 { //// one: string; ////} //// ////export module Inner { //// export interface I3 { //// three: boolean //// } //// //// export var varVar = 100; //// export let letVar = 200; //// export const constVar = 300; ////} // @Filename: B.ts ////export var bVar = "bee!"; // @Filename: C.ts ////export var cVar = "see!"; ////export * from "./A"; ////export * from "./B" // @Filename: D.ts ////import * as c from "./C"; ////var x = c.Inner./**/ verify.completions({ marker: "", exact: ["constVar", "letVar", "varVar"] });
{ "end_byte": 745, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListForTransitivelyExportedMembers02.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_barrelExport4.ts_0_692
/// <reference path="fourslash.ts" /> // @module: preserve // @moduleResolution: bundler // @Filename: /foo/a.ts //// export const A = 0; // @Filename: /foo/b.ts //// export {}; //// A/*sibling*/ // @Filename: /foo/index.ts //// export * from "./a"; //// export * from "./b"; // @Filename: /index.ts //// export * from "./foo"; //// export * from "./src"; // @Filename: /src/a.ts //// export {}; //// A/*parent*/ // @Filename: /src/index.ts //// export * from "./a"; // Module specifiers made up of only "." and ".." components are deprioritized verify.importFixModuleSpecifiers("sibling", ["./a", ".", ".."]); verify.importFixModuleSpecifiers("parent", ["../foo", "../foo/a", ".."]);
{ "end_byte": 692, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_barrelExport4.ts" }
TypeScript/tests/cases/fourslash/importFixesWithSymlinkInSiblingRushPnpm.ts_0_1729
/// <reference path="fourslash.ts" /> // @experimentalDecorators: true // @Filename: /project/libraries/dtos/tsconfig.json // { } // @Filename: /project/libraries/dtos/src/book.entity.ts ////@Entity() ////export class BookEntity { //// id: number ////} // @Filename: /project/libraries/dtos/src/user.entity.ts ////import { Entity } from "mikro-orm" ////@Entity() ////export class UserEntity { //// id: number ////} // @Filename: /project/common/temp/node_modules/.registry.npmjs.org/mikro-orm/3.4.1_pg@7.18.2/node_modules/mikro-orm/package.json ////{ "name": "mikro-orm", "version": "3.4.1", "typings": "dist/index.d.ts" } // @Filename: /project/common/temp/node_modules/.registry.npmjs.org/mikro-orm/3.4.1_pg@7.18.2/node_modules/mikro-orm/dist/index.d.ts ////export * from "./decorators"; // @Filename: /project/common/temp/node_modules/.registry.npmjs.org/mikro-orm/3.4.1_pg@7.18.2/node_modules/mikro-orm/dist/decorators/index.d.ts ////export * from "./entity"; // @Filename: /project/common/temp/node_modules/.registry.npmjs.org/mikro-orm/3.4.1_pg@7.18.2/node_modules/mikro-orm/dist/decorators/entity.d.ts ////export declare function Entity(): Function; // @link: /project/common/temp/node_modules/.registry.npmjs.org/mikro-orm/3.4.1_pg@7.18.2/node_modules/mikro-orm -> /project/libraries/dtos/node_modules/mikro-orm goTo.file("/project/libraries/dtos/src/book.entity.ts"); verify.importFixAtPosition([ getImportFixContent("mikro-orm"), getImportFixContent("mikro-orm/dist/decorators"), getImportFixContent("mikro-orm/dist/decorators/entity"), ]); function getImportFixContent(from: string) { return `import { Entity } from "${from}"; @Entity() export class BookEntity { id: number }`; }
{ "end_byte": 1729, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importFixesWithSymlinkInSiblingRushPnpm.ts" }
TypeScript/tests/cases/fourslash/extract-method3.ts_0_464
/// <reference path='fourslash.ts' /> //// namespace NS { //// class Q { //// foo() { //// console.log('100'); //// const m = 10, j = "hello", k = {x: "what"}; //// const q = /*a*/m/*b*/; //// } //// } //// } // Don't offer to 'extract symbol' a single identifier goTo.marker('a'); verify.not.refactorAvailable('Extract Symbol'); goTo.select('a', 'b'); verify.not.refactorAvailable('Extract Symbol');
{ "end_byte": 464, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method3.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType53.ts_0_396
/// <reference path='fourslash.ts' /> //// interface I { f: /*a*/(this: O, b: number) => typeof this.a/*b*/ }; goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to type alias", actionDescription: "Extract to type alias", newContent: `type /*RENAME*/NewType = (this: O, b: number) => typeof this.a; interface I { f: NewType };`, });
{ "end_byte": 396, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType53.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess21.ts_0_572
/// <reference path='fourslash.ts' /> //// class A { //// public a_2: number; //// /*a*/public a_1: string;/*b*/ //// } goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Generate 'get' and 'set' accessors", actionName: "Generate 'get' and 'set' accessors", actionDescription: "Generate 'get' and 'set' accessors", newContent: `class A { public a_2: number; private /*RENAME*/_a_1: string; public get a_1(): string { return this._a_1; } public set a_1(value: string) { this._a_1 = value; } }`, });
{ "end_byte": 572, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess21.ts" }
TypeScript/tests/cases/fourslash/codeFixOverrideModifier_js2.ts_0_454
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @noEmit: true // @noImplicitOverride: true // @filename: a.js //// class B { } //// class D extends B { //// /** //// * @public //// * @override //// */ //// foo (v) {} //// } verify.codeFix({ description: "Remove 'override' modifier", index: 0, newFileContent: `class B { } class D extends B { /** * */ foo (v) {} }`, })
{ "end_byte": 454, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixOverrideModifier_js2.ts" }
TypeScript/tests/cases/fourslash/selfReferencedExternalModule2.ts_0_315
/// <reference path='fourslash.ts' /> // @Filename: app.ts ////export import A = require('./app2'); ////export var I = 1; ////A./*1*/Y; ////A.B.A.B./*2*/I; // @Filename: app2.ts ////export import B = require('./app'); ////export var Y = 1; verify.quickInfos({ 1: "var A.Y: number", 2: "var I: number" });
{ "end_byte": 315, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/selfReferencedExternalModule2.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportFile4.ts_0_281
/// <reference path="fourslash.ts" /> //// [|let t: A/*0*/.B.I;|] // @Filename: ./module.ts //// export namespace A { //// export namespace B { //// export interface I { } //// } //// } verify.importFixAtPosition([ `import { A } from "./module"; let t: A.B.I;` ]);
{ "end_byte": 281, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportFile4.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_SubexpressionsWithPrefix2.ts_0_485
/// <reference path='fourslash.ts' /> ////let a = { b: 0 }; ////let x = { y: 0 }; ////a && a.b && /*a*/x && x.y;/*b*/ // Verify that we stop at a prefix sequence that is otherwise valid. goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert to optional chain expression", actionName: "Convert to optional chain expression", actionDescription: "Convert to optional chain expression", newContent: `let a = { b: 0 }; let x = { y: 0 }; a && a.b && x?.y;` });
{ "end_byte": 485, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_SubexpressionsWithPrefix2.ts" }
TypeScript/tests/cases/fourslash/completionsNewTarget.ts_0_334
/// <reference path='fourslash.ts' /> ////class C { //// constructor() { //// if (C === new./*1*/) //// } ////} ////class D { //// constructor() { //// if (D === new.target./*2*/) //// } ////} verify.completions({ marker: "1", exact: "target" }); verify.completions({ marker: "2", excludes: ["target"] });
{ "end_byte": 334, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsNewTarget.ts" }
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue14.ts_0_325
/// <reference path='fourslash.ts' /> //// interface A { //// bar: string //// } //// //// const a: () => A = () => { //// bar: '1' //// } verify.codeFixAvailable([ { description: 'Wrap the following body with parentheses which should be an object literal' }, { description: 'Remove unused label' }, ]);
{ "end_byte": 325, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue14.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceSingle.ts_0_695
/// <reference path='fourslash.ts' /> ////interface I { //// a(): void; //// b(x: 'x', y: 'a' | 'b'): 'b'; //// //// c: 'c'; //// d: { e: 'e'; }; ////} ////class Foo implements I {} verify.codeFix({ description: [ts.Diagnostics.Implement_interface_0.message, "I"], index: 0, newFileContent: `interface I { a(): void; b(x: 'x', y: 'a' | 'b'): 'b'; c: 'c'; d: { e: 'e'; }; } class Foo implements I { a(): void { throw new Error('Method not implemented.'); } b(x: 'x', y: 'a' | 'b'): 'b' { throw new Error('Method not implemented.'); } c: 'c'; d: { e: 'e'; }; }`, preferences: { quotePreference: "single" } });
{ "end_byte": 695, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceSingle.ts" }
TypeScript/tests/cases/fourslash/completionEntryForArrayElementConstrainedToString.ts_0_242
/// <reference path="fourslash.ts" /> //// declare function test<T extends 'a' | 'b'>(a: { foo: T[] }): void //// //// test({ foo: [/*ts*/] }) verify.completions({ marker: ["ts"], includes: ['"a"', '"b"'], isNewIdentifierLocation: true });
{ "end_byte": 242, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionEntryForArrayElementConstrainedToString.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_parameter_callback1.ts_0_297
/// <reference path='fourslash.ts' /> // @noUnusedParameters: true ////declare function f(cb: (x: number, y: string) => void): void; ////f((x, y) => { y; }); // No codefix to remove a non-last parameter in a callback verify.codeFixAvailable([{ description: "Prefix 'x' with an underscore" }]);
{ "end_byte": 297, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_parameter_callback1.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDoc.ts_0_1027
/// <reference path="fourslash.ts" /> // @target: esnext /////** //// * A constant //// * @deprecated //// */ ////var foo = "foo"; //// /////** //// * A function //// * @deprecated //// */ ////function fn() { } //// /////** //// * A class //// * @deprecated //// */ ////class C { //// /** //// * A field //// * @deprecated //// */ //// field = "field"; //// //// /** //// * A getter //// * @deprecated //// */ //// get getter() { //// return; //// } //// //// /** //// * A method //// * @deprecated //// */ //// m() { } //// //// get a() { //// this.field/*0*/; //// this.getter/*1*/; //// this.m/*2*/; //// foo/*3*/; //// C/*4*//; //// fn()/*5*/; //// //// return 1; //// } //// //// set a(value: number) { //// this.field/*6*/; //// this.getter/*7*/; //// this.m/*8*/; //// foo/*9*/; //// C/*10*/; //// fn/*11*/(); //// } ////} verify.baselineQuickInfo();
{ "end_byte": 1027, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDoc.ts" }
TypeScript/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts_0_295
/// <reference path='fourslash.ts'/> ////function f() { //// ////} ////var x = [|function [|{| "contextRangeIndex": 0 |}f|](g: any, h: any) { //// //// let helper = function f(): any { f(); } //// //// let foo = () => [|f|]([|f|], g); ////}|] verify.baselineRenameAtRangesWithText("f");
{ "end_byte": 295, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts" }
TypeScript/tests/cases/fourslash/moveToFile_alias3.ts_1_782
/// <reference path='fourslash.ts' /> // @filename: /producer.ts //// export function doit() {}; // @filename: /test.ts //// import { doit as doit2 } from "./producer"; //// //// class Another {} //// //// [|class Consumer { //// constructor() { //// doit2(); //// } //// }|] // @filename: /consumer.ts //// import { doit } from "./producer"; // existing import does not change when alias imported //// doit(); verify.moveToFile({ newFileContents: { "/test.ts": ` class Another {} `, "/consumer.ts": `import { doit } from "./producer"; // existing import does not change when alias imported doit(); class Consumer { constructor() { doit2(); } } ` }, interactiveRefactorArguments: { targetFile: "/consumer.ts" }, });
{ "end_byte": 782, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_alias3.ts" }
TypeScript/tests/cases/fourslash/formatAsyncClassMethod2.ts_0_193
///<reference path="fourslash.ts"/> ////class Foo { //// private async foo() {} ////} format.document(); verify.currentFileContentIs( `class Foo { private async foo() { } }` );
{ "end_byte": 193, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatAsyncClassMethod2.ts" }
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization7.ts_0_228
/// <reference path='fourslash.ts' /> // @strict: true //// class T { //// a: 2; //// } verify.codeFix({ description: `Add initializer to property 'a'`, newFileContent: `class T { a: 2 = 2; }`, index: 2 })
{ "end_byte": 228, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization7.ts" }
TypeScript/tests/cases/fourslash/referencesForClassMembersExtendingAbstractClass.ts_0_388
/// <reference path='fourslash.ts'/> ////abstract class Base { //// abstract /*a1*/a: number; //// abstract /*method1*/method(): void; ////} ////class MyClass extends Base { //// /*a2*/a; //// /*method2*/method() { } ////} //// ////var c: MyClass; ////c./*a3*/a; ////c./*method3*/method(); verify.baselineFindAllReferences('a1', 'a2', 'a3', 'method1', 'method2', 'method3')
{ "end_byte": 388, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForClassMembersExtendingAbstractClass.ts" }
TypeScript/tests/cases/fourslash/goToTypeDefinition4.ts_0_296
/// <reference path='fourslash.ts' /> // @Filename: foo.ts ////export type /*def0*/T = string; ////export const /*def1*/T = ""; // @Filename: bar.ts ////import { T } from "./foo"; ////let x: [|/*reference*/T|]; verify.baselineGoToType("reference"); verify.baselineGoToDefinition("reference");
{ "end_byte": 296, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToTypeDefinition4.ts" }
TypeScript/tests/cases/fourslash/findAllRefsJsDocImportTag5.ts_0_232
/// <reference path="fourslash.ts" /> // @checkJs: true // @Filename: /a.js //// export default function /*0*/a() {} // @Filename: /b.js //// /** @import /*1*/a, * as ns from "./a" */ verify.baselineFindAllReferences("0", "1");
{ "end_byte": 232, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsJsDocImportTag5.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_require_addToExisting.ts_0_641
/// <reference path="fourslash.ts" /> // @allowJs: true // @checkJs: true // @Filename: blah.js ////export default class Blah {} ////export const Named1 = 0; ////export const Named2 = 1; // @Filename: index.js ////var path = require('path') //// , { promisify } = require('util') //// , { Named1 } = require('./blah') //// ////new Blah goTo.file("index.js"); verify.codeFix({ index: 0, errorCode: ts.Diagnostics.Cannot_find_name_0.code, description: `Update import from "./blah"`, newFileContent: `var path = require('path') , { promisify } = require('util') , { Named1, default: Blah } = require('./blah') new Blah` });
{ "end_byte": 641, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_require_addToExisting.ts" }
TypeScript/tests/cases/fourslash/renameNumericalIndexSingleQuoted.ts_0_163
/// <reference path="fourslash.ts" /> ////const foo = { [|0|]: true }; ////foo[[|0|]]; verify.baselineRenameAtRangesWithText("0", { quotePreference: "single" });
{ "end_byte": 163, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameNumericalIndexSingleQuoted.ts" }
TypeScript/tests/cases/fourslash/codeFixAwaitInSyncFunction1.ts_0_256
/// <reference path='fourslash.ts' /> ////function f() { //// await Promise.resolve(); ////} verify.codeFix({ description: "Add async modifier to containing function", newFileContent: `async function f() { await Promise.resolve(); }`, });
{ "end_byte": 256, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAwaitInSyncFunction1.ts" }
TypeScript/tests/cases/fourslash/stringCompletionsFromGenericConditionalTypesUsingTemplateLiteralTypes.ts_0_1038
/// <reference path="fourslash.ts" /> // @strict: true //// type keyword = "foo" | "bar" | "baz" //// //// type validateString<s> = s extends keyword //// ? s //// : s extends `${infer left extends keyword}|${infer right}` //// ? right extends keyword //// ? s //// : `${left}|${keyword}` //// : keyword //// //// type isUnknown<t> = unknown extends t //// ? [t] extends [{}] //// ? false //// : true //// : false //// //// type validate<def> = def extends string //// ? validateString<def> //// : isUnknown<def> extends true //// ? keyword //// : { //// [k in keyof def]: validate<def[k]> //// } //// const parse = <def>(def: validate<def>) => def //// const shallowExpression = parse("foo|/*ts*/") //// const nestedExpression = parse({ prop: "foo|/*ts2*/" }) verify.completions({ marker: ["ts"], exact: ["foo", "bar", "baz", "foo|foo", "foo|bar", "foo|baz"] }); verify.completions({ marker: ["ts2"], exact: ["foo|foo", "foo|bar", "foo|baz"] });
{ "end_byte": 1038, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/stringCompletionsFromGenericConditionalTypesUsingTemplateLiteralTypes.ts" }
TypeScript/tests/cases/fourslash/jsDocGenerics1.ts_0_561
///<reference path="fourslash.ts" /> // @allowNonTsExtensions: true // @Filename: ref.d.ts //// namespace Thing { //// export interface Thung { //// a: number; //// ] //// ] // @Filename: Foo.js //// //// /** @type {Array<number>} */ //// var v; //// v[0]./*1*/ //// //// /** @type {{x: Array<Array<number>>}} */ //// var w; //// w.x[0][0]./*2*/ //// //// /** @type {Array<Thing.Thung>} */ //// var x; //// x[0].a./*3*/ verify.completions({ marker: test.markers(), includes: { name: "toFixed", kind: "method", kindModifiers: "declare" } });
{ "end_byte": 561, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocGenerics1.ts" }
TypeScript/tests/cases/fourslash/completionsJSDocImportTagEmptyModuleSpecifier1.ts_0_369
/// <reference path='fourslash.ts' /> // @strict: true // @checkJs: true // @allowJs: true // @moduleResolution: nodenext // @filename: node_modules/pkg/index.d.ts //// export type MyUnion = string | number; // @filename: index.js //// /** @import { MyUnion } from "/**/" */ verify.completions({ marker: "", exact: ["pkg"], isNewIdentifierLocation: true, });
{ "end_byte": 369, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsJSDocImportTagEmptyModuleSpecifier1.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports16.ts_1_658
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true //// function foo() { //// return { x: 1, y: {42: {dd: "45"}, b: 2} }; //// } //// function foo3(): "42" { //// return "42"; //// } //// export const { x: a , y: { [foo3()]: {dd: e} } } = foo(); verify.codeFix({ description: ts.Diagnostics.Extract_binding_expressions_to_variable.message, index: 0, newFileContent: `function foo() { return { x: 1, y: {42: {dd: "45"}, b: 2} }; } function foo3(): "42" { return "42"; } const dest = foo(); export const a: number = dest.x; const _a = foo3(); export const e: string = (dest.y)[_a].dd;` });
{ "end_byte": 658, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports16.ts" }
TypeScript/tests/cases/fourslash/goToImplementationNamespace_06.ts_0_262
/// <reference path='fourslash.ts'/> // Should handle type queries //// namespace [|F/*declaration*/oo|] { //// declare function hello(): void; //// } //// //// //// let x: typeof Foo = [|{ hello() {} }|]; verify.baselineGoToImplementation("declaration");
{ "end_byte": 262, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationNamespace_06.ts" }
TypeScript/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile_tsIgnore_indent.ts_0_253
/// <reference path='fourslash.ts' /> // @allowjs: true // @checkJs: true // @Filename: /a.js ////{ //// a; ////} verify.codeFix({ description: "Ignore this error message", index: 0, newFileContent: `{ // @ts-ignore a; }`, });
{ "end_byte": 253, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile_tsIgnore_indent.ts" }
TypeScript/tests/cases/fourslash/codeFixAddParameterNames3.ts_0_158
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////type Rest = ([|public string|]) => void; verify.rangeAfterCodeFix("public arg0: string");
{ "end_byte": 158, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddParameterNames3.ts" }
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax5.ts_0_261
// @strict: true /// <reference path='fourslash.ts' /> //// var x: [|?number|] = 12; verify.codeFix({ description: "Change '?number' to 'number | null | undefined'", errorCode: 17020, index: 0, newRangeContent: "number | null | undefined", });
{ "end_byte": 261, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax5.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports47.ts_0_1233
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true // @moduleResolution: node // @target: es2018 // @jsx: react-jsx // @filename: node_modules/react/package.json ////{ //// "name": "react", //// "types": "index.d.ts", ////} // @filename: node_modules/react/index.d.ts ////export = React; ////declare namespace JSX { //// interface Element extends GlobalJSXElement { } //// interface IntrinsicElements extends GlobalJSXIntrinsicElements { } ////} ////declare namespace React { } ////declare global { //// namespace JSX { //// interface Element { } //// interface IntrinsicElements { [x: string]: any; } //// } ////} ////interface GlobalJSXElement extends JSX.Element {} ////interface GlobalJSXIntrinsicElements extends JSX.IntrinsicElements {} // @filename: node_modules/react/jsx-runtime.d.ts ////import './'; // @filename: node_modules/react/jsx-dev-runtime.d.ts ////import './'; // @filename: /a.tsx ////export const x = <div aria-label="label text" />; goTo.file("/a.tsx"); verify.codeFix({ description: `Add annotation of type 'JSX.Element'`, index: 0, newFileContent: 'export const x: JSX.Element = <div aria-label="label text" />;', });
{ "end_byte": 1233, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports47.ts" }
TypeScript/tests/cases/fourslash/formattingKeywordAsIdentifier.ts_0_154
/// <reference path='fourslash.ts'/> ////declare var module/*1*/ goTo.marker("1"); edit.insert(";"); verify.currentLineContentIs("declare var module;");
{ "end_byte": 154, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingKeywordAsIdentifier.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteralFromSignature.ts_0_269
/// <reference path='fourslash.ts'/> ////declare function f(a: "x"): void; ////declare function f(a: string): void; ////f("[|/**/|]"); verify.completions({ marker: "", exact: { name: "x", replacementSpan: test.ranges()[0] }, isNewIdentifierLocation: true });
{ "end_byte": 269, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralFromSignature.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionMultipleDefinitions.ts_0_696
/// <reference path='fourslash.ts' /> // @Filename: a.ts ////interface /*interfaceDefinition1*/IFoo { //// instance1: number; ////} // @Filename: b.ts ////interface /*interfaceDefinition2*/IFoo { //// instance2: number; ////} //// ////interface /*interfaceDefinition3*/IFoo { //// instance3: number; ////} //// ////var ifoo: [|IFo/*interfaceReference*/o|]; // @Filename: c.ts ////module /*moduleDefinition1*/Module { //// export class c1 { } ////} // @Filename: d.ts ////module /*moduleDefinition2*/Module { //// export class c2 { } ////} // @Filename: e.ts ////[|Modul/*moduleReference*/e|]; verify.baselineGoToDefinition( "interfaceReference", "moduleReference" );
{ "end_byte": 696, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionMultipleDefinitions.ts" }
TypeScript/tests/cases/fourslash/completionListGenericConstraints.ts_0_1760
/// <reference path="fourslash.ts" /> ////// Simple constraint ////class Foo<T extends Object> { //// private v: T; //// public value(): void { //// this.v./*objectMembers*/ //// } ////} ////// Inheritance in constraints ////interface IBar1 { //// bar11: number; //// bar12: string; ////} //// ////interface IBar2 extends IBar1 { //// bar21: boolean; //// bar22: IBar2; ////} //// ////class BarWrapper<T extends IBar2> { //// private value: T; //// public getValue(){ //// this.value./*interfaceMembers*/; //// } ////} ////// Interface with call signature ////interface ICallable { //// (n: number): string; //// name: string; ////} //// ////class CallableWrapper<T extends ICallable> { //// public call(value: T) { //// value./*callableMembers*/ //// } ////} ////// Only public members of a constraint should be shown ////class Base { //// public publicProperty: number; //// private privateProperty: number; //// public publicMethod(): void { } //// private privateMethod(): void { } //// public static publicStaticMethod(): void { } //// private static privateStaticMethod(): void { } ////} //// ////class BaseWrapper<T extends Base> { //// public test(value: T) { //// value./*publicOnlyMembers*/ //// } ////} verify.completions( { marker: "objectMembers", unsorted: ["constructor", "toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable"] }, { marker: "interfaceMembers", unsorted: ["bar21", "bar22", "bar11", "bar12"] }, { marker: "callableMembers", unsorted: ["name", ...completion.functionMembersWithPrototype] }, { marker: "publicOnlyMembers", unsorted: ["publicProperty", "publicMethod"] }, );
{ "end_byte": 1760, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListGenericConstraints.ts" }
TypeScript/tests/cases/fourslash/completionListInTypeLiteralInTypeParameter9.ts_0_548
/// <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:/*g*/ } & {/*4*/}, //// } ////}>; verify.completions({ marker: "g", includes: ["Foo", "Bar", ...completion.globalTypes] }); verify.completions({ marker: "4", exact: "four", isNewIdentifierLocation: true });
{ "end_byte": 548, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInTypeLiteralInTypeParameter9.ts" }
TypeScript/tests/cases/fourslash/findAllRefsForDefaultExport09.ts_0_820
/// <reference path="fourslash.ts" /> // @filename: /tsconfig.json ////{ //// "compilerOptions": { //// "target": "esnext", //// "strict": true, //// "outDir": "./out", //// "allowSyntheticDefaultImports": true //// } ////} // @filename: /a.js ////module.exports = []; // @filename: /b.js ////module.exports = 1; // @filename: /c.ts ////export = []; // @filename: /d.ts ////export = 1; // @filename: /foo.ts ////import * as /*0*/a from "./a.js" ////import /*1*/aDefault from "./a.js" ////import * as /*2*/b from "./b.js" ////import /*3*/bDefault from "./b.js" //// ////import * as /*4*/c from "./c" ////import /*5*/cDefault from "./c" ////import * as /*6*/d from "./d" ////import /*7*/dDefault from "./d" verify.baselineFindAllReferences("0", "1", "2", "3", "4", "5", "6", "7");
{ "end_byte": 820, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForDefaultExport09.ts" }
TypeScript/tests/cases/fourslash/signatureHelpConstructExpression.ts_0_468
/// <reference path='fourslash.ts'/> ////class sampleCls { constructor(str: string, num: number) { } } ////var x = new sampleCls(/*1*/"", /*2*/5); verify.signatureHelp( { marker: "1", text: "sampleCls(str: string, num: number): sampleCls", parameterCount: 2, parameterName: "str", parameterSpan: "str: string", }, { marker: "2", parameterName: "num", parameterSpan: "num: number", }, )
{ "end_byte": 468, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpConstructExpression.ts" }
TypeScript/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts_0_1024
/// <reference path="fourslash.ts" /> // @noLib: true // @Filename: /a.ts ////export function Test1() {} ////export function Test2() {} // @Filename: /b.ts ////import { Test2 } from "./a"; ////t/**/ verify.completions({ marker: "", exact: completion.globalsPlus([ { name: "Test2", text: "(alias) function Test2(): void\nimport Test2", kind: "alias", kindModifiers: "export" }, { name: "Test1", source: "/a", sourceDisplay: "./a", text: "function Test1(): void", kind: "function", kindModifiers: "export", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, ], { noLib: true }), preferences: { includeCompletionsForModuleExports: true }, }).andApplyCodeAction({ name: "Test1", source: "/a", description: `Update import from "./a"`, newFileContent: `import { Test1, Test2 } from "./a"; t`, });
{ "end_byte": 1024, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesIsDefinitionOfFunction.ts_0_152
/// <reference path='fourslash.ts' /> /////*1*/function /*2*/func(x: number) { ////} /////*3*/func(x) verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 152, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesIsDefinitionOfFunction.ts" }
TypeScript/tests/cases/fourslash/completionInIncompleteCallExpression.ts_0_200
/// <reference path='fourslash.ts'/> ////var array = [1, 2, 4] ////function a4(x, y, z) { } ////a4(...<crash>/**/ verify.completions({ marker: "", exact: completion.globalsPlus(["a4", "array"]) });
{ "end_byte": 200, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionInIncompleteCallExpression.ts" }
TypeScript/tests/cases/fourslash/completionsNamespaceMergedWithObject.ts_0_257
/// <reference path='fourslash.ts'/> ////namespace N { //// export type T = number; ////} ////const N = { m() {} }; ////let x: N./*type*/; ////N./*value*/; verify.completions( { marker: "type", exact: "T" }, { marker: "value", exact: "m" }, );
{ "end_byte": 257, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsNamespaceMergedWithObject.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_quoteStyle.ts_0_274
/// <reference path="fourslash.ts" /> // @Filename: /a.ts ////export const foo: number; // @Filename: /b.ts ////[|foo;|] goTo.file("/b.ts"); verify.importFixAtPosition([ `import { foo } from './a'; foo;`, ], /*errorCode*/ undefined, { quotePreference: "single", });
{ "end_byte": 274, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_quoteStyle.ts" }
TypeScript/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames8.ts_0_152
/// <reference path='fourslash.ts' /> ////(/*1*/function /*2*/__foo() { //// /*3*/__foo(); ////}) verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 152, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames8.ts" }
TypeScript/tests/cases/fourslash/completionListInReturnWithContextualThis.ts_0_560
/// <reference path="fourslash.ts" /> ////interface Ctx { //// foo(): { //// x: number //// }; ////} //// ////declare function wrap(cb: (this: Ctx) => any): void; //// ////wrap(function () { //// const xs = this.foo(); //// return xs./*inReturn*/ ////}); //// ////wrap(function () { //// const xs = this.foo(); //// const y = xs./*involvedInReturn*/ //// return y; ////}); verify.completions( { marker: "inReturn", exact: ["x"], }, { marker: "involvedInReturn", exact: ["x"], }, );
{ "end_byte": 560, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInReturnWithContextualThis.ts" }
TypeScript/tests/cases/fourslash/inlineVariableNoReplacementValue.ts_0_153
/// <reference path="fourslash.ts" /> ////let /*a*/x/*b*/; ////const y = x + 1; goTo.select("a", "b"); verify.not.refactorAvailable("Inline variable");
{ "end_byte": 153, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableNoReplacementValue.ts" }
TypeScript/tests/cases/fourslash/formatRemoveSemicolons4.ts_0_894
/// <reference path="fourslash.ts" /> ////declare const opt: number | undefined; //// ////const a = 1; ////const b = 2; ////;[1, 2, 3] //// ////const c = opt ? 1 : 2; ////const d = opt ? 1 : 2; ////;[1, 2, 3] //// ////const e = opt ?? 1; ////const f = opt ?? 1; ////;[1, 2, 3] //// ////type a = 1; ////type b = 2; ////;[1, 2, 3] //// ////type c = typeof opt extends 1 ? 1 : 2; ////type d = typeof opt extends 1 ? 1 : 2; ////;[1, 2, 3] format.setFormatOptions({ ...format.copyFormatOptions(), semicolons: ts.SemicolonPreference.Remove }); format.document(); verify.currentFileContentIs( `declare const opt: number | undefined const a = 1 const b = 2 ;[1, 2, 3] const c = opt ? 1 : 2 const d = opt ? 1 : 2 ;[1, 2, 3] const e = opt ?? 1 const f = opt ?? 1 ;[1, 2, 3] type a = 1 type b = 2 ;[1, 2, 3] type c = typeof opt extends 1 ? 1 : 2 type d = typeof opt extends 1 ? 1 : 2 ;[1, 2, 3]`);
{ "end_byte": 894, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatRemoveSemicolons4.ts" }
TypeScript/tests/cases/fourslash/completionListWithMeanings.ts_0_1923
/// <reference path="fourslash.ts" /> // @noLib: true ////namespace m { export interface point2 { } } ////namespace m2 { export var zz = 10; } ////namespace m3 { export var zz2 = 10; export interface point3 { } } ////interface point { //// x: number; //// y: number; ////} ////var xx = 10; ////var tt = /*valueExpr*/xx; ////var yy: /*typeExpr*/point = { x: 4, y: 3 + /*valueExprInObjectLiteral*/tt }; ////var kk: m3.point3/*membertypeExpr*/ = m3.zz2/*membervalueExpr*/; ////var zz = </*typeExpr2*/point>{ x: 4, y: 3 }; const values: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> = completion.globalsPlus([ { name: "m2", text: "namespace m2" }, // With no type side, allowed only in value { name: "m3", text: "namespace m3" }, { name: "xx", text: "var xx: number" }, { name: "tt", text: "var tt: number" }, { name: "yy", text: "var yy: point" }, { name: "kk", text: "var kk: m3.point3" }, { name: "zz", text: "var zz: point" }, ], { noLib: true }); const types: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> = completion.sorted([ completion.globalThisEntry, { name: "m", text: "namespace m" }, { name: "m3", text: "namespace m3" }, { name: "point", text: "interface point" }, ...completion.typeKeywords, ]); const filterValuesByName = (name: string) => { return values.filter(entry => { if (typeof entry === 'string') { return entry !== name; } return entry.name !== name; }) } verify.completions( { marker: "valueExpr", exact: filterValuesByName('tt'), isNewIdentifierLocation: true }, { marker: "typeExpr", exact: types, }, { marker: "valueExprInObjectLiteral", exact: filterValuesByName('yy') }, { marker: "membertypeExpr", exact: [{ name: "point3", text: "interface m3.point3" }] }, { marker: "membervalueExpr", exact: [{ name: "zz2", text: "var m3.zz2: number" }] }, );
{ "end_byte": 1923, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListWithMeanings.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDocTags7.ts_0_313
/// <reference path="fourslash.ts" /> // @noEmit: true // @allowJs: true // @Filename: quickInfoJsDocTags7.js /////** //// * @typedef {{ [x: string]: any, y: number }} Foo //// */ //// /////** //// * @type {(t: T) => number} //// * @template T //// */ ////const /**/foo = t => t.y; verify.baselineQuickInfo();
{ "end_byte": 313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTags7.ts" }
TypeScript/tests/cases/fourslash/getEditsForFileRename_directory.ts_0_1559
/// <reference path='fourslash.ts' /> // @Filename: /a.ts /////// <reference path="./src/old/file.ts" /> ////import old from "./src/old"; ////import old2 from "./src/old/file"; ////export default 0; // @Filename: /src/b.ts /////// <reference path="./old/file.ts" /> ////import old from "./old"; ////import old2 from "./old/file"; ////export default 0; // @Filename: /src/foo/c.ts /////// <reference path="../old/file.ts" /> ////import old from "../old"; ////import old2 from "../old/file"; ////export default 0; // @Filename: /src/old/index.ts ////import a from "../../a"; ////import a2 from "../b"; ////import a3 from "../foo/c"; ////import f from "./file"; ////export default 0; // @Filename: /src/old/file.ts ////export default 0; // @Filename: /tsconfig.json ////{ "files": ["a.ts", "src/b.ts", "src/foo/c.ts", "src/old/index.ts", "src/old/file.ts"] } verify.getEditsForFileRename({ oldPath: "/src/old", newPath: "/src/new", newFileContents: { "/a.ts": `/// <reference path="./src/new/file.ts" /> import old from "./src/new"; import old2 from "./src/new/file"; export default 0;`, "/src/b.ts": `/// <reference path="./new/file.ts" /> import old from "./new"; import old2 from "./new/file"; export default 0;`, "/src/foo/c.ts": `/// <reference path="../new/file.ts" /> import old from "../new"; import old2 from "../new/file"; export default 0;`, // No change to /src/new "/tsconfig.json": `{ "files": ["a.ts", "src/b.ts", "src/foo/c.ts", "src/new/index.ts", "src/new/file.ts"] }`, }, });
{ "end_byte": 1559, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_directory.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportFileQuoteStyleMixed1.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/importNameCodeFixNewImportFileQuoteStyleMixed1.ts" }
TypeScript/tests/cases/fourslash/incrementalParsingTopLevelAwait.1.ts_0_313
/// <reference path="fourslash.ts"/> // @target: esnext // @module: esnext // @Filename: ./foo.ts //// await(1); //// /*1*/ verify.numberOfErrorsInCurrentFile(1); goTo.marker("1"); edit.insert("export {};"); verify.numberOfErrorsInCurrentFile(0); edit.replaceLine(1, ""); verify.numberOfErrorsInCurrentFile(1);
{ "end_byte": 313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incrementalParsingTopLevelAwait.1.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_onlyStatements.ts_0_270
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////console.log("hello"); ////[|console.log("goodbye");|] verify.moveToNewFile({ newFileContents: { "/a.ts": `console.log("hello"); `, "/newFile.ts": `console.log("goodbye"); `, }, });
{ "end_byte": 270, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_onlyStatements.ts" }
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_FunctionFnArgIndent.ts_0_652
/// <reference path='fourslash.ts' /> ////function foo() { //// const a = { //// b: builder.create(function /*a*/()/*b*/ { //// console.log(1); //// console.log(2); //// return 3; //// }) //// } ////} goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert arrow function or function expression", actionName: "Convert to arrow function", actionDescription: "Convert to arrow function", newContent: `function foo() { const a = { b: builder.create(() => { console.log(1); console.log(2); return 3; }) } }`, });
{ "end_byte": 652, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_FunctionFnArgIndent.ts" }
TypeScript/tests/cases/fourslash/inlayHintsQuotePreference2.ts_0_290
/// <reference path="fourslash.ts" /> ////const a1: "'" = "'"; ////const b1: "\\" = "\\"; ////export function fn(a = a1, b = b1) {} verify.baselineInlayHints(undefined, { includeInlayFunctionParameterTypeHints: true, interactiveInlayHints: true, quotePreference: "single" });
{ "end_byte": 290, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsQuotePreference2.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingEnumMember6.ts_0_216
/// <reference path='fourslash.ts' /> ////enum E { //// a = "b" ////} ////E.b verify.codeFix({ description: "Add missing enum member 'b'", newFileContent: `enum E { a = "b", b = "b" } E.b` });
{ "end_byte": 216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingEnumMember6.ts" }
TypeScript/tests/cases/fourslash/quickInfoTypeOnlyEnum.ts_0_403
/// <reference path="fourslash.ts" /> // @Filename: /a.ts ////export enum SyntaxKind { //// SourceFile ////} // @Filename: /b.ts ////import type { SyntaxKind } from './a'; ////let x: SyntaxKind/*1*/; ////let y: SyntaxKind./*2*/SourceFile; verify.quickInfoAt("1", [ "(alias) enum SyntaxKind", "import SyntaxKind" ].join("\n")); verify.quickInfoAt("2", "(enum member) SyntaxKind.SourceFile = 0");
{ "end_byte": 403, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoTypeOnlyEnum.ts" }
TypeScript/tests/cases/fourslash/removeExportFromInterfaceError0.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/removeExportFromInterfaceError0.ts" }
TypeScript/tests/cases/fourslash/completionBeforeSemanticDiagnosticsInArrowFunction1.ts_0_528
/// <reference path='fourslash.ts' /> //// var f4 = <T>(x: T/**/ ) => { //// } goTo.marker(); // Replace the "T" type with the non-existent type 'V'. edit.backspace(1); edit.insert("A"); // Bring up completion to force a pull resolve. This will end up resolving several symbols and // producing unreported diagnostics (i.e. that 'V' wasn't found). verify.completions({ includes: { name: "T", text: "(type parameter) T in <T>(x: A): void" } }); // There should now be a single error. verify.numberOfErrorsInCurrentFile(1);
{ "end_byte": 528, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionBeforeSemanticDiagnosticsInArrowFunction1.ts" }
TypeScript/tests/cases/fourslash/formatRemoveNewLineAfterOpenBrace.ts_0_187
/// <reference path="fourslash.ts"/> //// function foo() //// { //// } //// if (true) //// { //// } format.document(); verify.currentFileContentIs( `function foo() { } if (true) { }`);
{ "end_byte": 187, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatRemoveNewLineAfterOpenBrace.ts" }
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts_0_728
/// <reference path='fourslash.ts' /> //// function f(templateStrings: TemplateStringsArray, p1_o1: string): number; //// function f(templateStrings: TemplateStringsArray, p1_o2: number, p2_o2: number, p3_o2: number): string; //// function f(templateStrings: TemplateStringsArray, p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; //// function f(...foo[]: any) { return ""; } //// //// f `${ } ${/*1*/ fa/*2*/lse /*3*/} verify.signatureHelp({ marker: test.markers(), overloadsCount: 3, text: "f(templateStrings: TemplateStringsArray, p1_o3: string, p2_o3: boolean, p3_o3: number): boolean", argumentCount: 3, parameterCount: 4, parameterName: "p2_o3", parameterSpan: "p2_o3: boolean", });
{ "end_byte": 728, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts" }
TypeScript/tests/cases/fourslash/toggleLineComment8.ts_0_591
// When indentation is different between lines it should get the left most indentation // and use that for all lines. // When uncommeting, doesn't matter what indentation the line has. //@Filename: file.tsx //// const a = <div> //// [|<div> //// SomeText //// </div>|] //// </div>; //// //// const b = <div> //// {/*[|<div>*/} //// {/* SomeText*/} //// {/*</div>|]*/} //// </div>; verify.toggleLineComment( `const a = <div> {/*<div>*/} {/* SomeText*/} {/*</div>*/} </div>; const b = <div> <div> SomeText </div> </div>;`);
{ "end_byte": 591, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/toggleLineComment8.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionTypePredicate.ts_0_321
/// <reference path='fourslash.ts'/> //// class /*classDeclaration*/A {} //// function f(/*parameterDeclaration*/parameter: any): [|/*parameterName*/parameter|] is [|/*typeReference*/A|] { //// return typeof parameter === "string"; //// } verify.baselineGoToDefinition( "parameterName", "typeReference", );
{ "end_byte": 321, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionTypePredicate.ts" }
TypeScript/tests/cases/fourslash/formatMultilineComment.ts_0_1112
/// <reference path='fourslash.ts' /> /////*1*//** 1 //// */*2*/2 /////*3*/ 3*/ //// ////class Foo { /////*4*//**4 //// */*5*/5 /////*6*/ *6 /////*7*/ 7*/ //// bar() { /////*8*/ /**8 //// */*9*/9 /////*10*/ *10 /////*11*/ *11 /////*12*/ 12*/ //// } ////} format.document(); goTo.marker('1'); verify.currentLineContentIs("/** 1"); goTo.marker('2'); verify.currentLineContentIs(" *2"); goTo.marker('3'); verify.currentLineContentIs(" 3*/"); goTo.marker('4'); verify.currentLineContentIs(" /**4"); goTo.marker('5'); verify.currentLineContentIs(" *5"); goTo.marker('6'); verify.currentLineContentIs(" *6"); goTo.marker('7'); verify.currentLineContentIs(" 7*/"); goTo.marker('8'); verify.currentLineContentIs(" /**8"); goTo.marker('9'); verify.currentLineContentIs("*9"); goTo.marker('10'); verify.currentLineContentIs(" *10"); goTo.marker('11'); verify.currentLineContentIs(" *11"); goTo.marker('12'); verify.currentLineContentIs(" 12*/");
{ "end_byte": 1112, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatMultilineComment.ts" }
TypeScript/tests/cases/fourslash/unusedEnumInFunction1.ts_0_187
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true //// [| function f1 () { //// enum Directions { Up, Down} //// } |] verify.rangeAfterCodeFix(`function f1 () { } `);
{ "end_byte": 187, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedEnumInFunction1.ts" }
TypeScript/tests/cases/fourslash/codeFixCorrectQualifiedNameToIndexedAccessType_all.ts_0_391
/// <reference path='fourslash.ts' /> ////interface Foo { //// bar: string; ////} ////const x: Foo.bar = ""; ////const y: Foo.bar = ""; verify.codeFixAll({ fixId: "correctQualifiedNameToIndexedAccessType", fixAllDescription: "Rewrite all as indexed access types", newFileContent: `interface Foo { bar: string; } const x: Foo["bar"] = ""; const y: Foo["bar"] = "";`, });
{ "end_byte": 391, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectQualifiedNameToIndexedAccessType_all.ts" }
TypeScript/tests/cases/fourslash/quickInfoUnion_discriminated.ts_0_698
/// <reference path='fourslash.ts'/> // @Filename: quickInfoJsDocTags.ts ////type U = A | B; //// ////interface A { //// /** Kind A */ //// kind: "a"; //// /** Prop A */ //// prop: number; ////} //// ////interface B { //// /** Kind B */ //// kind: "b"; //// /** Prop B */ //// prop: string; ////} //// ////const u: U = { //// /*uKind*/kind: "a", //// /*uProp*/prop: 0, ////} ////const u2: U = { //// /*u2Kind*/kind: "bogus", //// /*u2Prop*/prop: 1, ////}; verify.quickInfos({ uKind: ['(property) A.kind: "a"', "Kind A"], uProp: ["(property) A.prop: number", "Prop A"], u2Kind: '(property) kind: "bogus"', u2Prop: "(property) prop: number", });
{ "end_byte": 698, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoUnion_discriminated.ts" }
TypeScript/tests/cases/fourslash/codeFixSpelling2.ts_0_301
/// <reference path='fourslash.ts' /> ////[|function foo<T extends number | string>(x: T) { //// return x.toStrang(); ////}|] verify.rangeAfterCodeFix(`function foo<T extends number | string>(x: T) { return x.toString(); }`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0);
{ "end_byte": 301, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpelling2.ts" }
TypeScript/tests/cases/fourslash/codeFixRenameUnmatchedParameter2.ts_0_668
/// <reference path='fourslash.ts' /> // @filename: a.ts /////** //// * @param {number} d //// * @param {number} a //// * @param {number} b //// */ ////function foo(a: number, b: string, c: string) { //// a; //// b; //// c; ////} verify.codeFixAvailable([ { description: "Delete unused '@param' tag 'd'" }, { description: "Rename '@param' tag name 'd' to 'c'" }, ]); verify.codeFix({ description: [ts.Diagnostics.Rename_param_tag_name_0_to_1.message, "d", "c"], index: 1, newFileContent: `/** * @param {number} c * @param {number} a * @param {number} b */ function foo(a: number, b: string, c: string) { a; b; c; }` });
{ "end_byte": 668, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRenameUnmatchedParameter2.ts" }
TypeScript/tests/cases/fourslash/getEmitOutputSourceRoot.ts_0_330
/// <reference path="fourslash.ts" /> // @BaselineFile: getEmitOutputSourceRoot.baseline // @sourceMap: true // @sourceRoot: sourceRootDir/ // @Filename: inputFile.ts // @emitThisFile: true //// var x = 109; //// var foo = "hello world"; //// class M { //// x: number; //// y: string; //// } verify.baselineGetEmitOutput();
{ "end_byte": 330, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputSourceRoot.ts" }
TypeScript/tests/cases/fourslash/moveToFile_expandSelectionRange13.ts_0_982
/// <reference path='fourslash.ts' /> //@Filename: /bar.ts ////const b = 2; // @Filename: /a.ts ////const a = 1; ////function add1(x: number, y: number): number; ////functi[|on add1(x: string, y: string): string; ////function add1(x: any, y: any) { //// return x + y; ////} ////function foo() {} ////function add2(x: number, y: number): number; ////function add2(x: string, y: string): string; ////function add2(x: any, y: any) { //// return x + y; ////}|] ////const c = 3; verify.moveToFile({ newFileContents: { "/a.ts": `const a = 1; const c = 3;`, "/bar.ts": `const b = 2; function add1(x: number, y: number): number; function add1(x: string, y: string): string; function add1(x: any, y: any) { return x + y; } function foo() { } function add2(x: number, y: number): number; function add2(x: string, y: string): string; function add2(x: any, y: any) { return x + y; } `, }, interactiveRefactorArguments: { targetFile: "/bar.ts" } });
{ "end_byte": 982, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_expandSelectionRange13.ts" }
TypeScript/tests/cases/fourslash/completionImportModuleSpecifierEndingTsxReact.ts_0_444
/// <reference path='fourslash.ts'/> //@jsx:react //@Filename:test.tsx //// export class Test { } //@Filename:module.tsx ////import { Test } from ".//**/" verify.completions({ marker: "", includes:{name:"test.js"}, preferences: {importModuleSpecifierEnding: "js"}, isNewIdentifierLocation: true}); verify.completions({ marker: "", includes:{name:"test"}, preferences: {importModuleSpecifierEnding: "index" }, isNewIdentifierLocation: true});
{ "end_byte": 444, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionImportModuleSpecifierEndingTsxReact.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAndSetAccessForTriggerReason.ts_0_370
/// <reference path='fourslash.ts' /> //// class A { //// public /*a*//*b*/a: string; //// } // Only offer refactor for empty span if explicity requested goTo.select("a", "b"); verify.not.refactorAvailableForTriggerReason("implicit", "Generate 'get' and 'set' accessors"); verify.refactorAvailableForTriggerReason("invoked", "Generate 'get' and 'set' accessors");
{ "end_byte": 370, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAndSetAccessForTriggerReason.ts" }
TypeScript/tests/cases/fourslash/jsDocPropertyDescription8.ts_0_287
///<reference path="fourslash.ts" /> //// class SymbolClass { //// /** Something generic */ //// static [p: symbol]: any; //// } //// function symbolClass(e: typeof SymbolClass) { //// console.log(e./*symbolClass*/anything); //// } verify.quickInfoAt("symbolClass", "any");
{ "end_byte": 287, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocPropertyDescription8.ts" }
TypeScript/tests/cases/fourslash/smartIndentStatementFor.ts_0_407
/// <reference path='fourslash.ts'/> ////function Foo() { //// for (var i = 0; i < 10; i++) { //// /*insideStatement*/ //// } //// /*afterStatement*/ //// for (var i = 0;;) //// /*insideStatement2*/ ////} goTo.marker('insideStatement'); verify.indentationIs(8); goTo.marker('afterStatement'); verify.indentationIs(4); goTo.marker('insideStatement2'); verify.indentationIs(8);
{ "end_byte": 407, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentStatementFor.ts" }
TypeScript/tests/cases/fourslash/codeFixForgottenThisPropertyAccess01.ts_0_575
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////export const foo = 0; // @Filename: /b.ts ////const fooo = 0; ////class C { //// foo: number; //// constructor() {[| //// foo = 10; //// |]} ////} goTo.file("/b.ts"); verify.codeFixAvailable([ { description: `Add import from "./a"` }, { description: "Change spelling to 'fooo'" }, { description: "Add 'this.' to unresolved variable" }, ]); verify.codeFix({ index: 2, description: "Add 'this.' to unresolved variable", newRangeContent: ` this.foo = 10; ` });
{ "end_byte": 575, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixForgottenThisPropertyAccess01.ts" }
TypeScript/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions2.ts_0_1900
/// <reference path="fourslash.ts" /> ////console.log(console.log(class Y {}, class X {}), console.log(class B {}, class A {})); ////console.log(class Cls { meth() {} }); verify.navigationTree({ "text": "<global>", "kind": "script", "childItems": [ { "text": "A", "kind": "class" }, { "text": "B", "kind": "class" }, { "text": "Cls", "kind": "class", "childItems": [ { "text": "meth", "kind": "method" } ] }, { "text": "X", "kind": "class" }, { "text": "Y", "kind": "class" } ] }); verify.navigationBar([ { "text": "<global>", "kind": "script", "childItems": [ { "text": "A", "kind": "class" }, { "text": "B", "kind": "class" }, { "text": "Cls", "kind": "class" }, { "text": "X", "kind": "class" }, { "text": "Y", "kind": "class" } ] }, { "text": "A", "kind": "class", "indent": 1 }, { "text": "B", "kind": "class", "indent": 1 }, { "text": "Cls", "kind": "class", "childItems": [ { "text": "meth", "kind": "method" } ], "indent": 1 }, { "text": "X", "kind": "class", "indent": 1 }, { "text": "Y", "kind": "class", "indent": 1 } ]);
{ "end_byte": 1900, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions2.ts" }
TypeScript/tests/cases/fourslash/findAllRefsGlobalThisKeywordInModule.ts_0_133
/// <reference path='fourslash.ts' /> // @noLib: true /////*1*/this; ////export const c = 1; verify.baselineFindAllReferences('1')
{ "end_byte": 133, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsGlobalThisKeywordInModule.ts" }
TypeScript/tests/cases/fourslash/completionsBigIntShowNoCompletions.ts_0_176
/// <reference path="fourslash.ts" /> //// declare const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number //// const foo = 0n/*1*/; verify.completions({ marker: '1', exact: [] });
{ "end_byte": 176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsBigIntShowNoCompletions.ts" }
TypeScript/tests/cases/fourslash/findAllRefsDefaultImportThroughNamespace.ts_0_848
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////[|export /*0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}default|] function /*1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|]() {}|] // @Filename: /b.ts ////export import a = require("./a"); // @Filename: /c.ts ////import { a } from "./b"; ////a./*2*/[|default|](); //// ////declare const x: { [|/*3*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}default|]: number|] }; ////x./*4*/[|default|]; const [r0Def, r0, r1, r2, r3Def, r3, r4] = test.ranges(); // Can't rename a default import. goTo.rangeStart(r2); verify.renameInfoFailed(); verify.baselineFindAllReferences('0', '1', '2', '3', '4'); verify.baselineRename(r1); // Can rename a default property. verify.baselineRename([r3, r4])
{ "end_byte": 848, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsDefaultImportThroughNamespace.ts" }
TypeScript/tests/cases/fourslash/completionsInExport.ts_0_997
/// <reference path="fourslash.ts" /> ////const a = "a"; ////type T = number; ////export { /**/ }; const type = { name: "type", sortText: completion.SortText.GlobalsOrKeywords } verify.completions({ marker: "", exact: ["a", "T", type] }); // Deprioritize 'a' since it has been exported already. // (Keep it in the list because you can still do 'a as b'.) edit.insert("a, "); verify.completions({ exact: ["T", { name: "a", sortText: completion.SortText.OptionalMember }, type] }); // No completions for new name edit.insert("T as "); verify.completions({ exact: [] }); // 'T' still hasn't been exported by name edit.insert("U, "); verify.completions({ exact: ["T", { name: "a", sortText: completion.SortText.OptionalMember }, type] }); // 'a' and 'T' are back to the same priority edit.insert("T, "); verify.completions({ exact: [ { name: "a", sortText: completion.SortText.OptionalMember }, { name: "T", sortText: completion.SortText.OptionalMember }, type, ] });
{ "end_byte": 997, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsInExport.ts" }
TypeScript/tests/cases/fourslash/smartIndentOnUnclosedComputedProperty01.ts_0_305
/// <reference path='fourslash.ts' /> ////var x = { //// [1123123123132 ////{| "indent": 4 |} ////} // Note that we currently do NOT indent further in a computed property. test.markers().forEach(marker => { verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); });
{ "end_byte": 305, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentOnUnclosedComputedProperty01.ts" }
TypeScript/tests/cases/fourslash/formatSelectionDocCommentInBlock.ts_0_575
/// <reference path="fourslash.ts" /> //// { //// /*1*//** //// * Some doc comment //// *//*2*/ //// const a = 1; //// } //// //// while (true) { //// /*3*//** //// * Some doc comment //// *//*4*/ //// } format.selection("1", "2"); verify.currentFileContentIs( `{ /** * Some doc comment */ const a = 1; } while (true) { /** * Some doc comment */ }`); format.selection("3", "4"); verify.currentFileContentIs( `{ /** * Some doc comment */ const a = 1; } while (true) { /** * Some doc comment */ }`);
{ "end_byte": 575, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatSelectionDocCommentInBlock.ts" }
TypeScript/tests/cases/fourslash/codeFixOverrideModifier12.ts_0_331
/// <reference path='fourslash.ts' /> // @noImplicitOverride: true //// abstract class Base { //// abstract bar(): void; //// } //// class Sub extends Base { //// [|abstract bar() {}|] //// } verify.codeFix({ description: "Add 'override' modifier", newRangeContent: "abstract override bar() {}", index: 0 })
{ "end_byte": 331, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixOverrideModifier12.ts" }
TypeScript/tests/cases/fourslash/completionListInObjectBindingPattern07.ts_0_337
/// <reference path='fourslash.ts'/> ////interface I { //// propertyOfI_1: number; //// propertyOfI_2: string; ////} ////interface J { //// property1: I; //// property2: string; ////} //// ////var foo: J; ////var { property1: { /**/ } } = foo; verify.completions({ marker: "", exact: ["propertyOfI_1", "propertyOfI_2"] });
{ "end_byte": 337, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectBindingPattern07.ts" }