_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/codeFixConstToLet3.ts_0_212
/// <reference path='fourslash.ts' /> ////for (const i = 0; i < 10; i++) {} verify.codeFix({ description: "Convert 'const' to 'let'", index: 0, newFileContent: `for (let i = 0; i < 10; i++) {}` });
{ "end_byte": 212, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConstToLet3.ts" }
TypeScript/tests/cases/fourslash/getEditsForFileRename_jsExtension.ts_0_325
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: /src/a.js ////export const a = 0; // @Filename: /b.js ////import { a } from "./src/a.js"; verify.getEditsForFileRename({ oldPath: "/b.js", newPath: "/src/b.js", newFileContents: { "/b.js": `import { a } from "./a.js";`, }, });
{ "end_byte": 325, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_jsExtension.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties21.ts_0_610
/// <reference path='fourslash.ts' /> // @filename: /a.ts ////export type A = { x: string }; // @filename: /b.ts ////import { A } from "./a"; ////export type Foo = { x: string }; ////export interface B { //// b(a: A): Foo; ////} // @filename: /c.ts ////import { B } from "./b"; ////const b: B = {}; goTo.file("/c.ts"); verify.codeFix({ index: 0, description: ts.Diagnostics.Add_missing_properties.message, newFileContent: `import { A } from "./a"; import { B, Foo } from "./b"; const b: B = { b: function(a: A): Foo { throw new Error("Function not implemented."); } };`, });
{ "end_byte": 610, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties21.ts" }
TypeScript/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts_0_925
/// <reference path='fourslash.ts'/> ////module FindRef4 { //// module MixedStaticsClassTest { //// export class Foo { //// /*1*/bar: Foo; //// /*2*/static /*3*/bar: Foo; //// //// /*4*/public /*5*/foo(): void { //// } //// /*6*/public static /*7*/foo(): void { //// } //// } //// } //// //// function test() { //// // instance function //// var x = new MixedStaticsClassTest.Foo(); //// x./*8*/foo(); //// x./*9*/bar; //// //// // static function //// MixedStaticsClassTest.Foo./*10*/foo(); //// MixedStaticsClassTest.Foo./*11*/bar; //// } ////} // References to a member method with the same name as a static. // References to a static method with the same name as a member. // References to a member property with the same name as a static. // References to a static property with the same name as a member. verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11');
{ "end_byte": 925, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts" }
TypeScript/tests/cases/fourslash/completionEntryForArrayElementConstrainedToString2.ts_0_247
/// <reference path="fourslash.ts" /> //// declare function test<T extends 'a' | 'b'>(a: { foo: T[] }): void //// //// test({ foo: ['a', /*ts*/] }) verify.completions({ marker: ["ts"], includes: ['"a"', '"b"'], isNewIdentifierLocation: true });
{ "end_byte": 247, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionEntryForArrayElementConstrainedToString2.ts" }
TypeScript/tests/cases/fourslash/autoImportFileExcludePatterns2.ts_0_994
/// <reference path="fourslash.ts" /> // @Filename: /lib/components/button/Button.ts //// export function Button() {} // @Filename: /lib/components/button/index.ts //// export * from "./Button"; // @Filename: /lib/components/index.ts //// export * from "./button"; // @Filename: /lib/main.ts //// export { Button } from "./components"; // @Filename: /lib/index.ts //// export * from "./main"; // @Filename: /i-hate-index-files.ts //// Button/**/ verify.completions({ marker: "", exact: completion.globalsPlus([{ name: "Button", source: "./lib/main", sourceDisplay: "./lib/main", hasAction: true, sortText: completion.SortText.AutoImportSuggestions, }]), preferences: { allowIncompleteCompletions: true, includeCompletionsForModuleExports: true, autoImportFileExcludePatterns: ["/**/index.*"], }, }); verify.importFixModuleSpecifiers("", ["./lib/main", "./lib/components/button/Button"], { autoImportFileExcludePatterns: ["/**/index.*"] });
{ "end_byte": 994, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportFileExcludePatterns2.ts" }
TypeScript/tests/cases/fourslash/docCommentTemplateInMultiLineComment.ts_0_123
/// <reference path='fourslash.ts' /> // @Filename: justAComment.ts //// /* /*0*/ */ verify.noDocCommentTemplateAt("0");
{ "end_byte": 123, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateInMultiLineComment.ts" }
TypeScript/tests/cases/fourslash/jsdocDeprecated_suggestion5.ts_0_521
///<reference path="fourslash.ts" /> // @checkJs: true // @allowJs: true // @Filename: jsdocDeprecated_suggestion5.js //// /** @typedef {{ email: string, nickName?: string }} U2 */ //// /** @type {U2} */ //// const u2 = { email: "" } //// /** //// * @callback K //// * @param {any} ctx //// * @return {void} //// */ //// /** @type {K} */ //// const cc = _k => {} //// /** @enum {number} */ //// const DOOM = { e: 1, m: 1 } //// /** @type {DOOM} */ //// const kneeDeep = DOOM.e verify.getSuggestionDiagnostics([])
{ "end_byte": 521, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocDeprecated_suggestion5.ts" }
TypeScript/tests/cases/fourslash/codeFixSpelling_all.ts_0_497
/// <reference path='fourslash.ts' /> ////function f(s: string) { //// s.toStrang(); //// s.toStrong(); ////} //// ////type A = { "foo-bar": number; "barbaz": string; }; ////var a: A; ////a.foobar; ////a.barbz verify.codeFixAll({ fixId: "fixSpelling", fixAllDescription: "Fix all detected spelling errors", newFileContent: `function f(s: string) { s.toString(); s.toString(); } type A = { "foo-bar": number; "barbaz": string; }; var a: A; a["foo-bar"]; a.barbaz`, });
{ "end_byte": 497, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpelling_all.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportExportEqualsESNextInteropOn.ts_0_310
/// <reference path="fourslash.ts" /> // @EsModuleInterop: true // @Module: es2015 // @Filename: /foo.d.ts ////declare module "foo" { //// const foo: number; //// export = foo; ////} // @Filename: /index.ts ////[|foo|] goTo.file('/index.ts'); verify.importFixAtPosition([`import foo from "foo"; foo`]);
{ "end_byte": 310, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportExportEqualsESNextInteropOn.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_super.ts_0_894
/// <reference path='fourslash.ts' /> // @noUnusedParameters: true //// class B { //// fromBase(x: number) { return x } //// } //// //// class C extends B { //// fromDerived(keep1: number, remove1: number) {} //// fromBase(keep2: number, remove2: any) {} //// m(keep3: number, remove3: number) {} //// } //// //// class D extends C { //// fromDerived(x: number) { return x } //// caller() { //// super.m(1); //// } //// } //// verify.codeFixAll({ fixId: "unusedIdentifier_delete", fixAllDescription: ts.Diagnostics.Delete_all_unused_declarations.message, newFileContent: `class B { fromBase(x: number) { return x } } class C extends B { fromDerived(keep1: number) {} fromBase(keep2: number) {} m(keep3: number) {} } class D extends C { fromDerived(x: number) { return x } caller() { super.m(1); } } `});
{ "end_byte": 894, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_super.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties9.ts_0_380
/// <reference path='fourslash.ts' /> ////interface I { //// a: { //// x: number; //// y: { z: string; }; //// } ////} ////[|const foo: I = {};|] verify.codeFix({ index: 0, description: ts.Diagnostics.Add_missing_properties.message, newRangeContent: `const foo: I = { a: { x: 0, y: { z: "" } } };` });
{ "end_byte": 380, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties9.ts" }
TypeScript/tests/cases/fourslash/syntacticClassificationsTripleSlash12.ts_0_557
/// <reference path="fourslash.ts"/> //// /// <reference path="./module.ts" bad types="node" /> const c = classification("original"); verify.syntacticClassificationsAre( c.comment("/// "), c.punctuation("<"), c.jsxSelfClosingTagName("reference"), c.comment(" "), c.jsxAttribute("path"), c.operator("="), c.jsxAttributeStringLiteralValue("\"./module.ts\""), c.comment(" bad "), c.jsxAttribute("types"), c.operator("="), c.jsxAttributeStringLiteralValue("\"node\""), c.comment(" "), c.punctuation("/>"));
{ "end_byte": 557, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsTripleSlash12.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration10.ts_0_441
/// <reference path='fourslash.ts' /> ////namespace Foo { //// export const x = 0; ////} //// ////Foo.test<string, number>(); verify.codeFix({ index: 0, description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "test"], newFileContent: `namespace Foo { export const x = 0; export function test<T, U>() { throw new Error("Function not implemented."); } } Foo.test<string, number>();` });
{ "end_byte": 441, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration10.ts" }
TypeScript/tests/cases/fourslash/formattingChainingMethods.ts_0_923
/// <reference path="fourslash.ts" /> //// z$ = this.store.select(this.fake()) //// .ofType( //// 'ACTION', //// 'ACTION-2' //// ) //// .pipe( //// filter(x => !!x), //// switchMap(() => //// this.store.select(this.menuSelector.getAll('x')) //// .pipe( //// tap(x => { //// this.x = !x; //// }) //// ) //// ) //// ); //// ////1 //// .toFixed( //// 2); format.document(); verify.currentFileContentIs(`z$ = this.store.select(this.fake()) .ofType( 'ACTION', 'ACTION-2' ) .pipe( filter(x => !!x), switchMap(() => this.store.select(this.menuSelector.getAll('x')) .pipe( tap(x => { this.x = !x; }) ) ) ); 1 .toFixed( 2);` );
{ "end_byte": 923, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingChainingMethods.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_NoInitialIdentifier.ts_0_372
/// <reference path='fourslash.ts' /> ////let a = { b: { c: 0 } }; /////*a*/a.b && a.b.c;/*b*/ 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: { c: 0 } }; a.b?.c;` });
{ "end_byte": 372, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_NoInitialIdentifier.ts" }
TypeScript/tests/cases/fourslash/signatureHelpFunctionOverload.ts_0_629
/// <reference path='fourslash.ts' /> ////function functionOverload(); ////function functionOverload(test: string); ////function functionOverload(test?: string) { } ////functionOverload(/*functionOverload1*/); ////functionOverload(""/*functionOverload2*/); verify.signatureHelp( { marker: "functionOverload1", overloadsCount: 2, text: "functionOverload(): any", parameterCount: 0, }, { marker: "functionOverload2", overloadsCount: 2, text: "functionOverload(test: string): any", parameterName: "test", parameterSpan: "test: string", }, );
{ "end_byte": 629, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpFunctionOverload.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports24-heritage-formatting-2.ts_0_754
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true ////function mixin<T extends new (...a: any) => any>(ctor: T): T { //// return ctor; ////} ////class Point2D { x = 0; y = 0; } ////export class Point3D2 extends mixin(Point2D) { //// z = 0; ////} verify.codeFixAvailable([ { description: ts.Diagnostics.Extract_base_class_to_variable.message } ]); verify.codeFix({ description: ts.Diagnostics.Extract_base_class_to_variable.message, index: 0, newFileContent: `function mixin<T extends new (...a: any) => any>(ctor: T): T { return ctor; } class Point2D { x = 0; y = 0; } const Point3D2Base: typeof Point2D = mixin(Point2D); export class Point3D2 extends Point3D2Base { z = 0; }` });
{ "end_byte": 754, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports24-heritage-formatting-2.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesThrow3.ts_0_918
/// <reference path='fourslash.ts' /> ////function f(a: number) { //// try { //// [|throw|] "Hello"; //// //// try { //// throw 10; //// } //// catch (x) { //// return 100; //// } //// finally { //// [|thr/**/ow|] 10; //// } //// } //// catch (x) { //// throw "Something"; //// } //// finally { //// throw "Also something"; //// } //// if (a > 0) { //// return (function () { //// return; //// return; //// return; //// //// if (false) { //// return true; //// } //// throw "Hello!"; //// })() || true; //// } //// //// throw 10; //// //// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) //// //// return; //// return true; //// throw false; ////} verify.baselineDocumentHighlights();
{ "end_byte": 918, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesThrow3.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_all2.ts_0_457
/// <reference path="fourslash.ts" /> // @Filename: /path.ts ////export declare function join(): void; // @Filename: /os.ts ////export declare function homedir(): void; // @Filename: /index.ts //// ////join(); ////homedir(); goTo.file("/index.ts"); verify.codeFixAll({ fixId: "fixMissingImport", fixAllDescription: "Add all missing imports", newFileContent: `import { homedir } from "./os"; import { join } from "./path"; join(); homedir();` });
{ "end_byte": 457, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_all2.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionImportedNames8.ts_0_299
/// <reference path='fourslash.ts' /> // @allowjs: true // @Filename: b.js ////import { [|/*classAliasDefinition*/Class|] } from "./a"; // @Filename: a.js ////class /*classDefinition*/Class { //// private f; ////} //// export { Class }; verify.baselineGoToDefinition("classAliasDefinition");
{ "end_byte": 299, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionImportedNames8.ts" }
TypeScript/tests/cases/fourslash/formatMultilineTypesWithMapped.ts_0_1076
/// <reference path="fourslash.ts" /> //// type Z = 'z' //// type A = { //// a: 'a' //// } | { //// [index in Z]: string //// } //// type B = { //// b: 'b' //// } & { //// [index in Z]: string //// } //// //// const c = { //// c: 'c' //// } as const satisfies { //// [index in Z]: string //// } //// //// const d = { //// d: 'd' //// } as const satisfies { //// [index: string]: string //// } //// //// const e = { //// e: 'e' //// } satisfies { //// [index in Z]: string //// } //// //// const f = { //// f: 'f' //// } satisfies { //// [index: string]: string //// } format.document(); verify.currentFileContentIs( `type Z = 'z' type A = { a: 'a' } | { [index in Z]: string } type B = { b: 'b' } & { [index in Z]: string } const c = { c: 'c' } as const satisfies { [index in Z]: string } const d = { d: 'd' } as const satisfies { [index: string]: string } const e = { e: 'e' } satisfies { [index in Z]: string } const f = { f: 'f' } satisfies { [index: string]: string }` )
{ "end_byte": 1076, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatMultilineTypesWithMapped.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesTryCatchFinally.ts_0_287
/// <reference path='fourslash.ts' /> /////*1*/[|try|] { //// try { //// } //// catch (x) { //// } //// //// try { //// } //// finally { //// } ////} ////[|cat/*2*/ch|] (e) { ////} ////[|fina/*3*/lly|] { ////} verify.baselineDocumentHighlights(test.markers());
{ "end_byte": 287, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesTryCatchFinally.ts" }
TypeScript/tests/cases/fourslash/goToTypeDefinitionEnumMembers.ts_0_189
/// <reference path='fourslash.ts' /> ////enum E { //// value1, //// /*definition*/value2 ////} ////var x = E.value2; //// /////*reference*/x; verify.baselineGoToType("reference");
{ "end_byte": 189, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToTypeDefinitionEnumMembers.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixUMDGlobalJavaScript.ts_0_423
/// <reference path="fourslash.ts" /> // @AllowSyntheticDefaultImports: false // @Module: commonjs // @CheckJs: true // @AllowJs: true // @Filename: a/f1.js //// [|export function test() { }; //// bar1/*0*/.bar;|] // @Filename: a/foo.d.ts //// export declare function bar(): number; //// export as namespace bar1; verify.importFixAtPosition([ `import * as bar1 from "./foo"; export function test() { }; bar1.bar;` ]);
{ "end_byte": 423, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixUMDGlobalJavaScript.ts" }
TypeScript/tests/cases/fourslash/getEditsForFileRename_preservePathEnding.ts_0_935
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @strict: true // @jsx: preserve // @resolveJsonModule: true // @Filename: /index.js ////export const x = 0; // @Filename: /jsx.jsx ////export const y = 0; // @Filename: /j.jonah.json ////{ "j": 0 } // @Filename: /a.js ////import { x as x0 } from "."; ////import { x as x1 } from "./index"; ////import { x as x2 } from "./index.js"; ////import { y } from "./jsx.jsx"; ////import { j } from "./j.jonah.json"; verify.noErrors(); verify.getEditsForFileRename({ oldPath: "/a.js", newPath: "/b.js", newFileContents: {}, // No change }); verify.getEditsForFileRename({ oldPath: "/b.js", newPath: "/src/b.js", newFileContents: { "/b.js": `import { x as x0 } from ".."; import { x as x1 } from "../index"; import { x as x2 } from "../index.js"; import { y } from "../jsx.jsx"; import { j } from "../j.jonah.json";`, }, });
{ "end_byte": 935, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_preservePathEnding.ts" }
TypeScript/tests/cases/fourslash/completionOfAwaitPromise4.ts_0_305
/// <reference path='fourslash.ts'/> //// function foo(x: Promise<string>) { //// [|x./**/|] //// } const replacementSpan = test.ranges()[0] verify.completions({ marker: "", includes: ["then"], excludes: ["trim"], preferences: { includeInsertTextCompletions: true, }, });
{ "end_byte": 305, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionOfAwaitPromise4.ts" }
TypeScript/tests/cases/fourslash/goToImplementationInterface_01.ts_0_587
/// <reference path='fourslash.ts'/> //// interface Fo/*interface_definition*/o { hello(): void } //// //// class [|SuperBar|] implements Foo { //// hello () {} //// } //// //// abstract class [|AbstractBar|] implements Foo { //// abstract hello (): void; //// } //// //// class [|Bar|] extends SuperBar { //// } //// //// class [|NotAbstractBar|] extends AbstractBar { //// hello () {} //// } //// //// var x = new SuperBar(); //// var y: SuperBar = new SuperBar(); //// var z: AbstractBar = new NotAbstractBar(); verify.baselineGoToImplementation("interface_definition");
{ "end_byte": 587, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationInterface_01.ts" }
TypeScript/tests/cases/fourslash/getEditsForFileRename_caseInsensitive.ts_0_290
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////export const a = 0; // @Filename: /b.ts ////import { a } from "./A"; verify.getEditsForFileRename({ oldPath: "/a.ts", newPath: "/eh.ts", newFileContents: { "/b.ts": 'import { a } from "./eh";', }, });
{ "end_byte": 290, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_caseInsensitive.ts" }
TypeScript/tests/cases/fourslash/signatureHelpThis.ts_0_930
/// <reference path='fourslash.ts' /> ////class Foo<T> { //// public implicitAny(n: number) { //// } //// public explicitThis(this: this, n: number) { //// console.log(this); //// } //// public explicitClass(this: Foo<T>, n: number) { //// console.log(this); //// } ////} //// ////function implicitAny(x: number): void { //// return this; ////} ////function explicitVoid(this: void, x: number): void { //// return this; ////} ////function explicitLiteral(this: { n: number }, x: number): void { //// console.log(this); ////} ////let foo = new Foo<number>(); ////foo.implicitAny(/*1*/); ////foo.explicitThis(/*2*/); ////foo.explicitClass(/*3*/); ////implicitAny(/*4*/12); ////explicitVoid(/*5*/13); ////let o = { n: 14, m: explicitLiteral }; ////o.m(/*6*/); verify.signatureHelp( { marker: ["1", "2", "3"], parameterName: "n" }, { marker: ["4", "5", "6"], parameterName: "x" }, );
{ "end_byte": 930, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpThis.ts" }
TypeScript/tests/cases/fourslash/quickInfoTypedGenericPrototypeMember.ts_0_274
/// <reference path='fourslash.ts'/> ////class C<T> { //// foo(x: T) { } ////} ////var /*1*/x = new C<any>(); // Quick Info for x is C<any> ////var /*2*/y = C.prototype; // Quick Info for y is C<{}> verify.quickInfos({ 1: "var x: C<any>", 2: "var y: C<any>" });
{ "end_byte": 274, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoTypedGenericPrototypeMember.ts" }
TypeScript/tests/cases/fourslash/formatColonAndQMark.ts_0_474
/// <reference path='fourslash.ts' /> ////class foo {/*1*/ //// constructor (n?: number, m = 5, o?: string) { }/*2*/ //// x:number = 1?2:3;/*3*/ ////}/*4*/ format.document(); goTo.marker("1"); verify.currentLineContentIs("class foo {"); goTo.marker("2"); verify.currentLineContentIs(" constructor(n?: number, m = 5, o?: string) { }"); goTo.marker("3"); verify.currentLineContentIs(" x: number = 1 ? 2 : 3;"); goTo.marker("4"); verify.currentLineContentIs("}");
{ "end_byte": 474, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatColonAndQMark.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionShadowVariableInsideModule.ts_0_230
/// <reference path='fourslash.ts'/> ////module shdModule { //// var /*shadowVariableDefinition*/shdVar; //// /*shadowVariableReference*/shdVar = 1; ////} verify.baselineGetDefinitionAtPosition("shadowVariableReference");
{ "end_byte": 230, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionShadowVariableInsideModule.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_ConditionalWithBinaryCondition1.ts_0_410
/// <reference path='fourslash.ts' /> ////let a = { b: { c: 0 } }; /////*a*/a && a.b/*b*/ ? a.b.c : "whenFalse"; 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: { c: 0 } }; a?.b ? a.b.c : "whenFalse";` });
{ "end_byte": 410, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_ConditionalWithBinaryCondition1.ts" }
TypeScript/tests/cases/fourslash/quickInfoCloduleWithRecursiveReference.ts_0_249
/// <reference path='fourslash.ts'/> ////module M { //// export class C { //// foo() { } //// } //// export module C { //// export var /**/C = M.C //// } ////} verify.quickInfoAt("", "var M.C.C: typeof M.C"); verify.noErrors();
{ "end_byte": 249, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoCloduleWithRecursiveReference.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_nonRelativePaths.ts_0_653
/// <reference path="fourslash.ts" /> // @Filename: /tsconfig.json //// { //// "compilerOptions": { //// "moduleResolution": "Bundler", //// "baseUrl": "." //// "paths": { //// "@foo/*": ["src/*"] //// } //// } //// } // @Filename: /src/a.ts ////export function a() { //// b(); ////} ////[|export function b() { ////}|] verify.moveToNewFile({ newFileContents: { "/src/a.ts": `import { b } from "@foo/b"; export function a() { b(); } `, "/src/b.ts": `export function b() { } `, }, preferences: { importModuleSpecifierPreference: "non-relative", } });
{ "end_byte": 653, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_nonRelativePaths.ts" }
TypeScript/tests/cases/fourslash/tsxParsing.ts_0_110
//// var x = <div id="foo" master="bar"></div>; //// var y = /**/x; goTo.marker(); verify.quickInfoExists();
{ "end_byte": 110, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxParsing.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_import_objectBindingPattern_plain.ts_0_268
/// <reference path='fourslash.ts' /> // @allowJs: true // @target: esnext // @Filename: /a.js ////const { x, y: z } = require("x"); ////x; z; verify.codeFix({ description: "Convert to ES module", newFileContent: `import { x, y as z } from "x"; x; z;`, });
{ "end_byte": 268, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_import_objectBindingPattern_plain.ts" }
TypeScript/tests/cases/fourslash/completionsECMAPrivateMember.ts_0_276
/// <reference path="fourslash.ts" /> // @target: esnext ////class K { //// #value: number; //// //// foo() { //// this.#va/**/ //// } ////} verify.completions({ marker: "", exact: [{ name: "#value", insertText: undefined }, { name: "foo" }] });
{ "end_byte": 276, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsECMAPrivateMember.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixExistingImport7.ts_0_240
/// <reference path="fourslash.ts" /> //// import [|{ v1 }|] from "../other_dir/module"; //// f1/*0*/(); // @Filename: ../other_dir/module.ts //// export var v1 = 5; //// export function f1(); verify.importFixAtPosition([`{ f1, v1 }`]);
{ "end_byte": 240, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixExistingImport7.ts" }
TypeScript/tests/cases/fourslash/indentAfterImport.ts_0_132
/// <reference path="fourslash.ts"/> //// import f = module('foo');/**/ goTo.marker(); edit.insert("\n"); verify.indentationIs(0);
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indentAfterImport.ts" }
TypeScript/tests/cases/fourslash/referencesForExternalModuleNames.ts_0_281
/// <reference path='fourslash.ts'/> // @Filename: referencesForGlobals_1.ts /////*1*/declare module "/*2*/foo" { //// var f: number; ////} // @Filename: referencesForGlobals_2.ts /////*3*/import f = require("/*4*/foo"); verify.baselineFindAllReferences('1', '2', '3', '4');
{ "end_byte": 281, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForExternalModuleNames.ts" }
TypeScript/tests/cases/fourslash/navigationBarPropertyDeclarations.ts_0_7492
/// <reference path="fourslash.ts"/> ////class A { //// public A1 = class { //// public x = 1; //// private y() {} //// protected z() {} //// } //// //// public A2 = { //// x: 1, //// y() {}, //// z() {} //// } //// //// public A3 = function () {} //// public A4 = () => {} //// public A5 = 1; //// public A6 = "A6"; //// //// public ["A7"] = class { //// public x = 1; //// private y() {} //// protected z() {} //// } //// //// public [1] = { //// x: 1, //// y() {}, //// z() {} //// } //// //// public [1 + 1] = 1; ////} verify.navigationTree({ text: "<global>", kind: "script", childItems: [ { text: "A", kind: "class", childItems: [ { text: "[1]", kind: "property", kindModifiers: "public", childItems: [ { text: "x", kind: "property" }, { text: "y", kind: "method" }, { text: "z", kind: "method" } ] }, { text: "A1", kind: "property", kindModifiers: "public", childItems: [ { text: "x", kind: "property", kindModifiers: "public" }, { text: "y", kind: "method", kindModifiers: "private" }, { text: "z", kind: "method", kindModifiers: "protected" } ] }, { text: "A2", kind: "property", kindModifiers: "public", childItems: [ { text: "x", kind: "property" }, { text: "y", kind: "method" }, { text: "z", kind: "method" } ] }, { text: "A3", kind: "property", kindModifiers: "public" }, { text: "A4", kind: "property", kindModifiers: "public" }, { text: "A5", kind: "property", kindModifiers: "public" }, { text: "A6", kind: "property", kindModifiers: "public" }, { text: "[\"A7\"]", kind: "property", kindModifiers: "public", childItems: [ { text: "x", kind: "property", kindModifiers: "public" }, { text: "y", kind: "method", kindModifiers: "private" }, { text: "z", kind: "method", kindModifiers: "protected" } ] } ] } ] }); verify.navigationBar([ { text: "<global>", kind: "script", childItems: [ { text: "A", kind: "class" } ] }, { text: "A", kind: "class", childItems: [ { text: "[1]", kind: "property", kindModifiers: "public" }, { text: "A1", kind: "property", kindModifiers: "public" }, { text: "A2", kind: "property", kindModifiers: "public" }, { text: "A3", kind: "property", kindModifiers: "public" }, { text: "A4", kind: "property", kindModifiers: "public" }, { text: "A5", kind: "property", kindModifiers: "public" }, { text: "A6", kind: "property", kindModifiers: "public" }, { text: "[\"A7\"]", kind: "property", kindModifiers: "public" } ], indent: 1 }, { text: "[1]", kind: "property", kindModifiers: "public", childItems: [ { text: "x", kind: "property" }, { text: "y", kind: "method" }, { text: "z", kind: "method" } ], indent: 2 }, { text: "A1", kind: "property", kindModifiers: "public", childItems: [ { text: "x", kind: "property", kindModifiers: "public" }, { text: "y", kind: "method", kindModifiers: "private" }, { text: "z", kind: "method", kindModifiers: "protected" } ], indent: 2 }, { text: "A2", kind: "property", kindModifiers: "public", childItems: [ { text: "x", kind: "property" }, { text: "y", kind: "method" }, { text: "z", kind: "method" } ], indent: 2 }, { text: "[\"A7\"]", kind: "property", kindModifiers: "public", childItems: [ { text: "x", kind: "property", kindModifiers: "public" }, { text: "y", kind: "method", kindModifiers: "private" }, { text: "z", kind: "method", kindModifiers: "protected" } ], indent: 2 } ]);
{ "end_byte": 7492, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarPropertyDeclarations.ts" }
TypeScript/tests/cases/fourslash/navigationBarWithLocalVariables.ts_0_431
/// <reference path="fourslash.ts"/> //// function x(){ //// const x = Object() //// x.foo = "" //// } verify.navigationTree({ "text": "<global>", "kind": "script", "childItems": [ { "text": "x", "kind": "function", "childItems": [ { "text": "x", "kind": "const" } ] } ] });
{ "end_byte": 431, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarWithLocalVariables.ts" }
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_Availability_Arrow_nested_this.ts_0_787
/// <reference path='fourslash.ts' /> //// const zoo = /*x*/(/*w*/) => { //// class Animal { //// weight = 42 //// askWeight() { return this.weight } //// } //// const Insect = class { //// weight = 42 //// askWeight() { return this.weight } //// } //// function callTaxi() { this.no = "054 xxx xx xx" } //// const callPizzaDelivery = function() { this.phone = "064 yyy yy yy"} //// }; goTo.select("x", "w"); verify.refactorAvailable("Convert arrow function or function expression", "Convert to named function"); verify.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function"); verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
{ "end_byte": 787, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_Availability_Arrow_nested_this.ts" }
TypeScript/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard4.ts_0_1622
/// <reference path="fourslash.ts" /> // @module: nodenext // @Filename: /node_modules/foo/package.json //// { //// "types": "index.d.ts", //// "exports": { //// "./*": "dist/*", //// "./foo/*": "dist/*", //// "./bar/*": "dist/*", //// "./exact-match": "dist/index.d.ts" //// } //// } // @Filename: /node_modules/foo/nope.d.ts //// export const nope = 0; // @Filename: /node_modules/foo/dist/index.d.ts //// export const index = 0; // @Filename: /node_modules/foo/dist/blah.d.ts //// export const blah = 0; // @Filename: /node_modules/foo/dist/foo/onlyInFooFolder.d.ts //// export const foo = 0; // @Filename: /node_modules/foo/dist/subfolder/one.d.ts //// export const one = 0; // @Filename: /a.mts //// import { } from "foo//**/"; verify.completions({ marker: "", isNewIdentifierLocation: true, exact: [ { name: "blah.js", kind: "script", kindModifiers: ".js" }, { name: "index.js", kind: "script", kindModifiers: ".js" }, { name: "foo", kind: "directory" }, { name: "subfolder", kind: "directory" }, { name: "bar", kind: "directory" }, { name: "exact-match", kind: "script" }, ], }); edit.insert("foo/"); verify.completions({ isNewIdentifierLocation: true, exact: [ { name: "blah.js", kind: "script", kindModifiers: ".js" }, { name: "index.js", kind: "script", kindModifiers: ".js" }, { name: "foo", kind: "directory" }, { name: "subfolder", kind: "directory" }, ], }); edit.insert("foo/"); verify.completions({ isNewIdentifierLocation: true, exact: [{ name: "onlyInFooFolder.js", kind: "script", kindModifiers: ".js" }], });
{ "end_byte": 1622, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard4.ts" }
TypeScript/tests/cases/fourslash/completionListInObjectLiteral5.ts_0_806
/// <reference path="fourslash.ts" /> ////const o = 'something' ////const obj = { //// prop: o/*1*/, //// pro() { //// const obj1 = { //// p:{ //// s: { //// h: { //// hh: o/*2*/ //// }, //// someFun() { //// o/*3*/ //// } //// } //// } //// } //// }, //// o/*4*/ ////} verify.completions({ marker: ["1"], excludes: ['obj'], includes: ['o'] }); verify.completions({ marker: ["2"], excludes: ['obj1'], includes: ['o', 'obj'] }); verify.completions({ marker: ["3"], includes: ['o', 'obj', 'obj1'] }); verify.completions({ marker: ["4"], includes: ['o'], excludes: ['obj'], isNewIdentifierLocation: true });
{ "end_byte": 806, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectLiteral5.ts" }
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class_noQuickInfoForIIFE.ts_0_235
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: /a.js ////(/*1*/function () { //// const foo = () => { //// this.x = 10; //// }; //// foo; ////})(); goTo.marker("1"); verify.not.codeFixAvailable()
{ "end_byte": 235, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class_noQuickInfoForIIFE.ts" }
TypeScript/tests/cases/fourslash/codeFixAwaitInSyncFunction15.ts_0_311
/// <reference path='fourslash.ts' /> ////const f = (): number[] => { //// await Promise.resolve([1]); ////} verify.codeFix({ index: 2, description: "Add async modifier to containing function", newFileContent: `const f = async (): Promise<number[]> => { await Promise.resolve([1]); }`, });
{ "end_byte": 311, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAwaitInSyncFunction15.ts" }
TypeScript/tests/cases/fourslash/docCommentTemplateExportAssignmentJS.ts_0_217
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @Filename: index.js //// /** /**/ */ //// exports.foo = (a) => {}; verify.docCommentTemplateAt("", 7, `/** * * @param {any} a */`);
{ "end_byte": 217, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateExportAssignmentJS.ts" }
TypeScript/tests/cases/fourslash/completionListInObjectBindingPattern11.ts_0_217
/// <reference path='fourslash.ts'/> ////interface I { //// property1: number; //// property2: string; ////} //// ////var { property1: prop1, /**/ }: I; verify.completions({ marker: "", exact: "property2" });
{ "end_byte": 217, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectBindingPattern11.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics9.ts_0_144
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: a.js ////public function F() { } verify.baselineSyntacticDiagnostics();
{ "end_byte": 144, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics9.ts" }
TypeScript/tests/cases/fourslash/completionsUnionStringLiteralProperty.ts_0_1211
/// <reference path="fourslash.ts" /> //// type Foo = { a: 0, b: 'x' } | { a: 0, b: 'y' } | { a: 1, b: 'z' }; //// const foo: Foo = { a: 0, b: '/*1*/' } //// //// type Bar = { a: 0, b: 'fx' } | { a: 0, b: 'fy' } | { a: 1, b: 'fz' }; //// const bar: Bar = { a: 0, b: 'f/*2*/' } //// //// type Baz = { x: 0, y: 0, z: 'a' } | { x: 0, y: 1, z: 'b' } | { x: 1, y: 0, z: 'c' } | { x: 1, y: 1, z: 'd' }; //// const baz1: Baz = { z: '/*3*/' }; //// const baz2: Baz = { x: 0, z: '/*4*/' }; //// const baz3: Baz = { x: 0, y: 1, z: '/*5*/' }; //// const baz4: Baz = { x: 2, y: 1, z: '/*6*/' }; verify.completions({ marker: "1", triggerCharacter: "'", includes: [ "x", "y" ], excludes: [ "z" ] }); verify.completions({ marker: "2", triggerCharacter: "'", includes: [ "fx", "fy" ], excludes: [ "fz" ] }); verify.completions({ marker: "3", triggerCharacter: "'", includes: [ "a", "b", "c", "d" ] }); verify.completions({ marker: "4", triggerCharacter: "'", includes: [ "a", "b" ], excludes: [ "c", "d" ] }); verify.completions({ marker: "5", triggerCharacter: "'", includes: [ "b" ], excludes: [ "a", "c", "d" ] }); verify.completions({ marker: "6", triggerCharacter: "'", includes: [ "b", "d" ], excludes: [ "a", "c" ] });
{ "end_byte": 1211, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsUnionStringLiteralProperty.ts" }
TypeScript/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts_0_238
/// <reference path='fourslash.ts'/> ////interface I { //// /*1*/property1: number; //// property2: string; ////} //// ////var foo: I; /////*2*/var { /*3*/property1: prop1 } = foo; verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 238, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts" }
TypeScript/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment2.ts_0_577
/// <reference path='fourslash.ts'/> //// export interface Config { //// files: ConfigFiles //// } //// export interface ConfigFiles { //// jspm: string; //// 'jspm:browser': string; //// } //// let config: Config; //// config = { //// files: { //// /*0*/: '', //// '[|/*1*/|]': '' //// } //// } const replacementSpan = test.ranges()[0] verify.completions( { marker: "0", exact: ['"jspm:browser"', "jspm"] }, { marker: "1", exact: [ { name: "jspm", replacementSpan }, { name: "jspm:browser", replacementSpan } ] }, );
{ "end_byte": 577, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment2.ts" }
TypeScript/tests/cases/fourslash/completionsObjectLiteralExpressions1.ts_0_1005
/// <reference path="fourslash.ts" /> //// interface ColorPalette { //// primary?: string; //// secondary?: string; //// } //// let colors: ColorPalette = { //// primary: "red" //// /**/ //// }; verify.completions({ marker: "", includes: [{ name: "secondary", sortText: completion.SortText.OptionalMember, hasAction: true, source: completion.CompletionSource.ObjectLiteralMemberWithComma, }], preferences: { allowIncompleteCompletions: true, includeInsertTextCompletions: true, }, }); verify.applyCodeActionFromCompletion("", { name: "secondary", description: `Add missing comma for object member completion 'secondary'.`, source: completion.CompletionSource.ObjectLiteralMemberWithComma, newFileContent: `interface ColorPalette { primary?: string; secondary?: string; } let colors: ColorPalette = { primary: "red", };`, preferences: { allowIncompleteCompletions: true, includeInsertTextCompletions: true, }, });
{ "end_byte": 1005, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsObjectLiteralExpressions1.ts" }
TypeScript/tests/cases/fourslash/transitiveExportImports.ts_0_902
/// <reference path='fourslash.ts'/> // @Filename: a.ts ////[|class /*1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}A|] { ////}|] ////[|export = [|{| "contextRangeIndex": 2 |}A|];|] // @Filename: b.ts ////[|export import /*2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}b|] = require('./a');|] // @Filename: c.ts ////[|import /*3*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}b|] = require('./b');|] ////var a = new /*4*/[|b|]./**/[|b|](); goTo.marker(); verify.quickInfoExists(); verify.noErrors(); const [a0Def, a0, a1Def, a1, b0Def, b0, c0Def, c0, c1, c2] = test.ranges(); const aRanges = [a0, a1]; const bRanges = [b0, c2]; const cRanges = [c0, c1]; verify.baselineFindAllReferences('1', '2', '3', '4'); verify.baselineRename(aRanges); verify.baselineRename(bRanges); verify.baselineRename(cRanges);
{ "end_byte": 902, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/transitiveExportImports.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionImport2.ts_0_193
/// <reference path='fourslash.ts'/> // @Filename: /b.ts /////*2*/export const foo = 1; // @Filename: /a.ts ////import { foo } [|from/*1*/|] "./b"; verify.baselineGoToDefinition("1");
{ "end_byte": 193, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionImport2.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties15.ts_0_294
/// <reference path='fourslash.ts' /> ////interface Foo { //// 1: number; //// 2: number; ////} ////[|const foo: Foo = {}|] verify.codeFix({ index: 0, description: ts.Diagnostics.Add_missing_properties.message, newRangeContent: `const foo: Foo = { 1: 0, 2: 0 }` });
{ "end_byte": 294, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties15.ts" }
TypeScript/tests/cases/fourslash/completionListNewIdentifierBindingElement.ts_0_117
/// <reference path='fourslash.ts' /> ////var { x:html/*1*/ verify.completions({ marker: "1", exact: undefined });
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListNewIdentifierBindingElement.ts" }
TypeScript/tests/cases/fourslash/completionListClassPrivateFields.ts_0_249
/// <reference path="fourslash.ts" /> ////class A { //// #private = 1; ////} //// ////class B extends A { //// /**/ ////} verify.completions({ marker: "", exact: completion.classElementKeywords, isNewIdentifierLocation: true });
{ "end_byte": 249, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListClassPrivateFields.ts" }
TypeScript/tests/cases/fourslash/goToImplementationInterfaceMethod_04.ts_0_527
/// <reference path='fourslash.ts'/> // Should return implementation in class and all sub-classes of target //// interface Foo { //// hello (): void; //// } //// //// class Bar extends SuperBar { //// [|hello|]() {} //// } //// //// class SuperBar implements Foo { //// [|hello|]() {} //// } //// //// class OtherBar implements Foo { //// hello() {} // should not show up //// } //// //// function (x: SuperBar) { //// x.he/*function_call*/llo() //// } verify.baselineGoToImplementation("function_call");
{ "end_byte": 527, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationInterfaceMethod_04.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionExternalModuleName6.ts_0_204
/// <reference path='fourslash.ts'/> // @Filename: b.ts ////import * from [|'e/*1*/'|]; // @Filename: a.ts ////declare module /*2*/"e" { //// class Foo { } ////} verify.baselineGoToDefinition("1");
{ "end_byte": 204, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionExternalModuleName6.ts" }
TypeScript/tests/cases/fourslash/quickInfoInheritDoc.ts_0_1721
/// <reference path="fourslash.ts" /> // @noEmit: true // @allowJs: true // @Filename: quickInfoInheritDoc.ts ////abstract class BaseClass { //// /** //// * Useful description always applicable //// * //// * @returns {string} Useful description of return value always applicable. //// */ //// public static doSomethingUseful(stuff?: any): string { //// throw new Error('Must be implemented by subclass'); //// } //// //// /** //// * BaseClass.func1 //// * @param {any} stuff1 BaseClass.func1.stuff1 //// * @returns {void} BaseClass.func1.returns //// */ //// public static func1(stuff1: any): void { //// } //// //// /** //// * Applicable description always. //// */ //// public static readonly someProperty: string = 'general value'; ////} //// //// //// //// ////class SubClass extends BaseClass { //// //// /** //// * @inheritDoc //// * //// * @param {{ tiger: string; lion: string; }} [mySpecificStuff] Description of my specific parameter. //// */ //// public static /*1*/doSomethingUseful(mySpecificStuff?: { tiger: string; lion: string; }): string { //// let useful = ''; //// //// // do something useful to useful //// //// return useful; //// } //// //// /** //// * @inheritDoc //// * @param {any} stuff1 SubClass.func1.stuff1 //// * @returns {void} SubClass.func1.returns //// */ //// public static /*2*/func1(stuff1: any): void { //// } //// //// /** //// * text over tag //// * @inheritDoc //// * text after tag //// */ //// public static readonly /*3*/someProperty: string = 'specific to this class value' ////} verify.baselineQuickInfo();
{ "end_byte": 1721, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoInheritDoc.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts_0_681
/// <reference path='fourslash.ts' /> ////interface I1 { //// x: number, //// y: number //// z: number; //// f(): number, //// g(): any //// h(); ////} //// ////class C1 implements I1 {} verify.codeFix({ description: "Implement interface 'I1'", newFileContent: `interface I1 { x: number, y: number z: number; f(): number, g(): any h(); } class C1 implements I1 { x: number; y: number; z: number; f(): number { throw new Error("Method not implemented."); } g() { throw new Error("Method not implemented."); } h() { throw new Error("Method not implemented."); } }`, });
{ "end_byte": 681, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesLoopBreakContinue.ts_0_1873
/// <reference path='fourslash.ts' /> ////var arr = [1, 2, 3, 4]; ////label1: [|for|] (var n in arr) { //// [|break|]; //// [|continue|]; //// [|br/**/eak|] label1; //// [|continue|] label1; //// //// label2: for (var i = 0; i < arr[n]; i++) { //// [|break|] label1; //// [|continue|] label1; //// //// break; //// continue; //// break label2; //// continue label2; //// //// function foo() { //// label3: while (true) { //// break; //// continue; //// break label3; //// continue label3; //// //// // these cross function boundaries //// break label1; //// continue label1; //// break label2; //// continue label2; //// //// label4: do { //// break; //// continue; //// break label4; //// continue label4; //// //// break label3; //// continue label3; //// //// switch (10) { //// case 1: //// case 2: //// break; //// break label4; //// default: //// continue; //// } //// //// // these cross function boundaries //// break label1; //// continue label1; //// break label2; //// continue label2; //// () => { break; } //// } while (true) //// } //// } //// } ////} //// ////label5: while (true) break label5; //// ////label7: while (true) continue label5; verify.baselineDocumentHighlights();
{ "end_byte": 1873, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesLoopBreakContinue.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationModule.ts_0_698
/// <reference path='fourslash.ts' /> // @BaselineFile: bpSpan_module.baseline // @Filename: bpSpan_module.ts ////module m2 { //// var a = 10; //// a++; ////} ////module m3 { //// module m4 { //// export var x = 30; //// } //// //// export function foo() { //// return m4.x; //// } ////} ////module m4 { //// interface I { } ////} ////module m12 ////{ //// var a = 10; //// a++; ////} ////module m13 ////{ //// module m14 //// { //// export var x = 30; //// } //// //// export function foo() { //// return m4.x; //// } ////} ////module m14 ////{ //// interface I { } ////} verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 698, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationModule.ts" }
TypeScript/tests/cases/fourslash/incompleteFunctionCallCodefixTypeParameter.ts_0_398
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////function existing<T>(value: T) { //// added/*1*/(value); ////} goTo.marker("1"); verify.codeFix({ description: "Add missing function declaration 'added'", index: 0, newFileContent: `function existing<T>(value: T) { added(value); } function added<T>(value: T) { throw new Error("Function not implemented."); } `, });
{ "end_byte": 398, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incompleteFunctionCallCodefixTypeParameter.ts" }
TypeScript/tests/cases/fourslash/completionsLiteralFromInferenceWithinInferredType3.ts_0_495
/// <reference path="fourslash.ts" /> //// declare function test<T>(a: { //// [K in keyof T]: { //// b?: (keyof T)[]; //// }; //// }): void; //// //// test({ //// foo: {}, //// bar: { //// b: ["/*ts*/"], //// }, //// }); //// //// test({ //// foo: {}, //// bar: { //// b: [/*ts2*/], //// }, //// }); verify.completions({ marker: ["ts"], exact: ["foo", "bar"] }); verify.completions({ marker: ["ts2"], includes: ['"foo"', '"bar"'], isNewIdentifierLocation: true });
{ "end_byte": 495, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsLiteralFromInferenceWithinInferredType3.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_prologueDirectives1.ts_0_337
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////"use strict"; ////[|function b() { //// return this; ////}|] ////b(); verify.moveToNewFile({ newFileContents: { "/a.ts": `"use strict"; import { b } from "./b"; b();`, "/b.ts": `"use strict"; export function b() { return this; } `, }, });
{ "end_byte": 337, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_prologueDirectives1.ts" }
TypeScript/tests/cases/fourslash/signatureHelpJSX.ts_0_301
/// <reference path="fourslash.ts" /> //@Filename: test.tsx //@jsx: react ////declare var React: any; ////const z = <div>{[].map(x => </**/ // This test exists because it used to crash: #31347 goTo.marker(); verify.noSignatureHelpForTriggerReason({ kind: "characterTyped", triggerCharacter: "<" });
{ "end_byte": 301, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpJSX.ts" }
TypeScript/tests/cases/fourslash/smartIndentReturn.ts_0_327
/// <reference path='fourslash.ts'/> //// function foo() { //// if (true) { //// {| "indentation": 8|} //// return; //// {| "indentation": 8|} //// } //// } for (const marker of test.markers()) { verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); }
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentReturn.ts" }
TypeScript/tests/cases/fourslash/removeInterfaceUsedAsGenericTypeArgument.ts_0_197
/// <reference path="fourslash.ts" /> //// /**/interface A { a: string; } //// interface G<T, U> { } //// var v1: G<A, C>; goTo.marker(); edit.deleteAtCaret('interface A { a: string; }'.length);
{ "end_byte": 197, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/removeInterfaceUsedAsGenericTypeArgument.ts" }
TypeScript/tests/cases/fourslash/callHierarchyConstNamedClassExpression.ts_0_267
/// <reference path="fourslash.ts" /> //// function foo() { //// new Bar(); //// } //// //// const /**/Bar = class { //// constructor() { //// baz(); //// } //// } //// //// function baz() { //// } goTo.marker(); verify.baselineCallHierarchy();
{ "end_byte": 267, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyConstNamedClassExpression.ts" }
TypeScript/tests/cases/fourslash/codeFixCorrectQualifiedNameToIndexedAccessType01.ts_0_173
/// <reference path='fourslash.ts' /> //// export interface Foo { //// bar: string; //// } //// export const x: [|Foo.bar|] = "" verify.rangeAfterCodeFix(`Foo["bar"]`);
{ "end_byte": 173, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectQualifiedNameToIndexedAccessType01.ts" }
TypeScript/tests/cases/fourslash/tsxRename6.ts_0_915
/// <reference path='fourslash.ts' /> //@Filename: file.tsx // @jsx: preserve // @noLib: true //// declare module JSX { //// interface Element { } //// interface IntrinsicElements { //// } //// interface ElementAttributesProperty { props; } //// } //// interface OptionPropBag { //// propx: number //// propString: string //// optional?: boolean //// } //// [|declare function [|{| "contextRangeIndex": 0 |}Opt|](attributes: OptionPropBag): JSX.Element;|] //// let opt = [|<[|{| "contextRangeIndex": 2 |}Opt|] />|]; //// let opt1 = [|<[|{| "contextRangeIndex": 4 |}Opt|] propx={100} propString />|]; //// let opt2 = [|<[|{| "contextRangeIndex": 6 |}Opt|] propx={100} optional/>|]; //// let opt3 = [|<[|{| "contextRangeIndex": 8 |}Opt|] wrong />|]; //// let opt4 = [|<[|{| "contextRangeIndex": 10 |}Opt|] propx={100} propString="hi" />|]; verify.baselineRenameAtRangesWithText("Opt");
{ "end_byte": 915, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxRename6.ts" }
TypeScript/tests/cases/fourslash/mapCodeNestedIfReplace.ts_0_398
///<reference path="fourslash.ts"/> // @Filename: /index.ts //// function foo() { //// const x: number = 1; //// const y: number = 2; //// if (x === y) [||]{ //// console.log("hello"); //// console.log("you"); //// } //// return 1; //// } //// verify.baselineMapCode([test.ranges()], [ ` if (x === y) { console.log("goodbye"); console.log("world"); } ` ]);
{ "end_byte": 398, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeNestedIfReplace.ts" }
TypeScript/tests/cases/fourslash/renameReferenceFromLinkTag5.ts_0_131
/// <reference path="fourslash.ts" /> ////enum E { //// /** {@link E./**/A} */ //// A ////} verify.baselineRename("", {});
{ "end_byte": 131, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameReferenceFromLinkTag5.ts" }
TypeScript/tests/cases/fourslash/quickinfoExpressionTypeNotChangedViaDeletion.ts_0_497
/// <reference path="fourslash.ts" /> ////type TypeEq<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false; //// ////const /*2*/test1: TypeEq<number[], [number, ...number[]]> = false; //// ////declare const foo: [number, ...number[]]; ////declare const bar: number[]; //// ////const /*1*/test2: TypeEq<typeof foo, typeof bar> = false; goTo.marker("1"); verify.quickInfoIs("const test2: false"); goTo.marker("2"); verify.quickInfoIs("const test1: false");
{ "end_byte": 497, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickinfoExpressionTypeNotChangedViaDeletion.ts" }
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization_all_2.ts_0_1184
/// <reference path='fourslash.ts' /> // @strict: true //// abstract class A { abstract a (); } //// //// class TT { constructor () {} } //// //// class AT extends A { a () {} } //// //// class Foo {} //// //// class T { //// //// a: string; //// //// static b: string; //// //// private c: string; //// //// d: number | undefined; //// //// e: string | number; //// //// f: 1; //// //// g: "123" | "456"; //// //// h: boolean; //// //// i: TT; //// //// j: A; //// //// k: AT; //// //// l: Foo; //// } verify.codeFixAll({ fixId: 'addMissingPropertyUndefinedType', fixAllDescription: "Add undefined type to all uninitialized properties", newFileContent: `abstract class A { abstract a (); } class TT { constructor () {} } class AT extends A { a () {} } class Foo {} class T { a: string | undefined; static b: string; private c: string | undefined; d: number | undefined; e: string | number | undefined; f: 1 | undefined; g: "123" | "456" | undefined; h: boolean | undefined; i: TT | undefined; j: A | undefined; k: AT | undefined; l: Foo | undefined; }` });
{ "end_byte": 1184, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization_all_2.ts" }
TypeScript/tests/cases/fourslash/formattingObjectLiteralOpenCurlyNewline.ts_0_627
/// <reference path='fourslash.ts' /> //// //// var clear = //// { //// outerKey: //// { //// innerKey: 1, //// innerKey2: //// 2 //// } //// }; //// format.document(); verify.currentFileContentIs( ` var clear = { outerKey: { innerKey: 1, innerKey2: 2 } }; ` ); format.setOption("indentMultiLineObjectLiteralBeginningOnBlankLine", true); format.document(); verify.currentFileContentIs( ` var clear = { outerKey: { innerKey: 1, innerKey2: 2 } }; ` );
{ "end_byte": 627, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingObjectLiteralOpenCurlyNewline.ts" }
TypeScript/tests/cases/fourslash/quickInfoOnThis2.ts_0_310
/// <reference path='fourslash.ts' /> ////class Bar<T> { //// public explicitThis(this: this) { //// console.log(th/*1*/is); //// } //// public explicitClass(this: Bar<T>) { //// console.log(thi/*2*/s); //// } ////} verify.quickInfos({ 1: "this: this", 2: "this: Bar<T>" });
{ "end_byte": 310, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnThis2.ts" }
TypeScript/tests/cases/fourslash/completionsImport_promoteTypeOnly5.ts_0_818
/// <reference path="fourslash.ts" /> // @module: es2015 // @Filename: /exports.ts //// export interface SomeInterface {} //// export class SomePig {} // @Filename: /a.ts //// import { type SomePig as Babe } from "./exports.js"; //// new Babe/**/ verify.completions({ marker: "", includes: [{ name: "Babe", source: completion.CompletionSource.TypeOnlyAlias, hasAction: true, }] }); verify.applyCodeActionFromCompletion("", { name: "Babe", source: completion.CompletionSource.TypeOnlyAlias, description: `Remove 'type' from import of 'Babe' from "./exports.js"`, newFileContent: `import { SomePig as Babe } from "./exports.js"; new Babe`, preferences: { includeCompletionsForModuleExports: true, allowIncompleteCompletions: true, includeInsertTextCompletions: true, }, });
{ "end_byte": 818, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_promoteTypeOnly5.ts" }
TypeScript/tests/cases/fourslash/completionListForImportAttributes.ts_0_555
///<reference path="fourslash.ts" /> // @module: esnext // @target: esnext // @filename: ./a.ts ////export default {}; // @filename: ./b.ts ////declare global { //// interface ImportAttributes { //// type: "json", //// "resolution-mode": "import" //// } ////} ////const str = "hello"; //// ////import * as t1 from "./a" with { /*1*/ }; ////import * as t2 from "./a" with { type: "/*2*/" }; ////import * as t3 from "./a" with { type: "json", /*3*/ }; ////import * as t4 from "./a" with { type: /*4*/ }; verify.baselineCompletions();
{ "end_byte": 555, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListForImportAttributes.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesTryCatchFinallyBroken.ts_0_474
/// <reference path='fourslash.ts' /> ////t /*1*/ry { //// t/*2*/ry { //// } //// ctch (x) { //// } //// //// tr { //// } //// fin/*3*/ally { //// } ////} ////c/*4*/atch (e) { ////} ////f/*5*/inally { ////} //// ////// Missing catch variable ////t/*6*/ry { ////} ////catc/*7*/h { ////} /////*8*/finally { ////} //// ////// Missing try entirely ////cat/*9*/ch (x) { ////} ////final/*10*/ly { ////} verify.baselineDocumentHighlights(test.markers());
{ "end_byte": 474, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesTryCatchFinallyBroken.ts" }
TypeScript/tests/cases/fourslash/definitionNameOnEnumMember.ts_0_211
/// <reference path="fourslash.ts"/> ////enum e { //// firstMember, //// secondMember, //// thirdMember ////} ////var enumMember = e.[|/*1*/thirdMember|]; verify.baselineGetDefinitionAtPosition("1");
{ "end_byte": 211, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/definitionNameOnEnumMember.ts" }
TypeScript/tests/cases/fourslash/organizeImportsType5.ts_0_799
/// <reference path="fourslash.ts" /> //// import { //// d, //// type d as D, //// type c, //// c as C, //// b, //// b as B, //// type A, //// a //// } from './foo'; //// console.log(A, a, B, b, c, C, d, D); verify.organizeImports(`import { type A, a, b, b as B, type c, c as C, d, type d as D } from './foo'; console.log(A, a, B, b, c, C, d, D);`, /*mode*/ undefined, { organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "inline" } ); verify.organizeImports(`import { type A, a, b, b as B, type c, c as C, d, type d as D } from './foo'; console.log(A, a, B, b, c, C, d, D);`, /*mode*/ undefined, { organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "inline" } );
{ "end_byte": 799, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsType5.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingMember8.ts_0_126
/// <reference path='fourslash.ts' /> // @Filename: a.ts ////declare var x: [1, 2]; ////x.b; verify.not.codeFixAvailable();
{ "end_byte": 126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember8.ts" }
TypeScript/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts_0_381
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @noUnusedParameters: true ////class greeter { //// [|constructor() { //// var unused = 20; //// var used = "dummy"; //// used = used + "second part"; //// }|] ////} verify.rangeAfterCodeFix(` constructor() { var used = "dummy"; used = used + "second part"; } `);
{ "end_byte": 381, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts" }
TypeScript/tests/cases/fourslash/jsxAttributeSnippetCompletionUnclosed.ts_0_3512
/// <reference path="fourslash.ts" /> //@Filename: file.tsx ////interface NestedInterface { //// Foo: NestedInterface; //// (props: {className?: string}): any; ////} //// ////declare const Foo: NestedInterface; //// ////function fn1() { //// return <Foo> //// <Foo /*1*/ //// </Foo> ////} ////function fn2() { //// return <Foo> //// <Foo.Foo /*2*/ //// </Foo> ////} ////function fn3() { //// return <Foo> //// <Foo.Foo cla/*3*/ //// </Foo> ////} ////function fn4() { //// return <Foo> //// <Foo.Foo cla/*4*/ something //// </Foo> ////} ////function fn5() { //// return <Foo> //// <Foo.Foo something /*5*/ //// </Foo> ////} ////function fn6() { //// return <Foo> //// <Foo.Foo something cla/*6*/ //// </Foo> ////} ////function fn7() { //// return <Foo /*7*/ ////} ////function fn8() { //// return <Foo cla/*8*/ ////} ////function fn9() { //// return <Foo cla/*9*/ something ////} ////function fn10() { //// return <Foo something /*10*/ ////} ////function fn11() { //// return <Foo something cla/*11*/ ////} var preferences: FourSlashInterface.UserPreferences = { jsxAttributeCompletionStyle: "braces", includeCompletionsWithSnippetText: true, includeCompletionsWithInsertText: true, }; verify.completions( { marker: "1", preferences, includes: { name: "className", insertText: "className={$1}", text: "(property) className?: string", isSnippet: true, sortText: completion.SortText.OptionalMember } }, { marker: "2", preferences, includes: { name: "className", insertText: "className={$1}", text: "(property) className?: string", isSnippet: true, sortText: completion.SortText.OptionalMember } }, { marker: "3", preferences, includes: { name: "className", insertText: "className={$1}", text: "(property) className?: string", isSnippet: true, sortText: completion.SortText.OptionalMember } }, { marker: "4", preferences, includes: { name: "className", insertText: "className={$1}", text: "(property) className?: string", isSnippet: true, sortText: completion.SortText.OptionalMember } }, { marker: "5", preferences, includes: { name: "className", insertText: "className={$1}", text: "(property) className?: string", isSnippet: true, sortText: completion.SortText.OptionalMember } }, { marker: "6", preferences, includes: { name: "className", insertText: "className={$1}", text: "(property) className?: string", isSnippet: true, sortText: completion.SortText.OptionalMember } }, { marker: "7", preferences, includes: { name: "className", insertText: "className={$1}", text: "(property) className?: string", isSnippet: true, sortText: completion.SortText.OptionalMember } }, { marker: "8", preferences, includes: { name: "className", insertText: "className={$1}", text: "(property) className?: string", isSnippet: true, sortText: completion.SortText.OptionalMember } }, { marker: "9", preferences, includes: { name: "className", insertText: "className={$1}", text: "(property) className?: string", isSnippet: true, sortText: completion.SortText.OptionalMember } }, { marker: "10", preferences, includes: { name: "className", insertText: "className={$1}", text: "(property) className?: string", isSnippet: true, sortText: completion.SortText.OptionalMember } }, { marker: "11", preferences, includes: { name: "className", insertText: "className={$1}", text: "(property) className?: string", isSnippet: true, sortText: completion.SortText.OptionalMember } }, )
{ "end_byte": 3512, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsxAttributeSnippetCompletionUnclosed.ts" }
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionComments2.ts_0_575
/// <reference path='fourslash.ts' /> ////function /*a*/foo/*b*/(// comment //// // a comment //// a: number, //// // b comment //// b: number ////) { //// return a + b; ////} goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert parameters to destructured object", actionName: "Convert parameters to destructured object", actionDescription: "Convert parameters to destructured object", newContent: `function foo(// comment { a, b }: { // a comment a: number; // b comment b: number; }) { return a + b; }` });
{ "end_byte": 575, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionComments2.ts" }
TypeScript/tests/cases/fourslash/completionInfoWithExplicitTypeArguments.ts_0_625
/// <reference path='fourslash.ts'/> // Note: Giving the functions two parameters means that the checker cannot resolve their signatures normally, // so it makes a best guess. ////interface I { x: number; y: number; } //// ////declare function f<T>(x: T, y: number): void; ////f<I>({ /*f*/ }); //// ////declare function g<T>(x: keyof T, y: number): void; ////g<I>("[|/*g*/|]"); verify.completions({ marker: "f", exact: [ { name: "x" }, { name: "y" }, ] }); verify.completions({ marker: "g", exact: [ { name: "x", replacementSpan: test.ranges()[0] }, { name: "y", replacementSpan: test.ranges()[0] }, ] });
{ "end_byte": 625, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionInfoWithExplicitTypeArguments.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_parameter3.ts_0_398
/// <reference path="fourslash.ts" /> // @noUnusedLocals: true // @noUnusedParameters: true ////[|function f( //// a: number, b: number, //// //// // comment //// c: number, ////)|] { //// a; //// c; ////} verify.codeFix({ index: 0, description: "Remove unused declaration for: 'b'", newRangeContent: `function f( a: number, // comment c: number, )` });
{ "end_byte": 398, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_parameter3.ts" }
TypeScript/tests/cases/fourslash/referencesForMergedDeclarations8.ts_0_318
/// <reference path='fourslash.ts'/> ////interface Foo { } ////module Foo { //// export interface Bar { } //// /*1*/export module /*2*/Bar { export interface Baz { } } //// export function Bar() { } ////} //// ////// module ////import a3 = Foo./*3*/Bar.Baz; verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 318, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForMergedDeclarations8.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration24.ts_0_441
/// <reference path="fourslash.ts" /> ////interface Foo { //// a: (e: any) => void; ////} //// ////const foo: Foo = { //// a: fn ////} verify.codeFix({ index: 0, description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "fn"], newFileContent: `interface Foo { a: (e: any) => void; } const foo: Foo = { a: fn } function fn(e: any): void { throw new Error("Function not implemented."); } ` });
{ "end_byte": 441, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration24.ts" }
TypeScript/tests/cases/fourslash/formattingJsxElements.ts_0_5305
/// <reference path='fourslash.ts' /> //@Filename: file.tsx ////function foo0() { //// return ( //// <div className="commentBox" > ////Hello, World!/*autoformat*/ /////*indent*/ //// </div> //// ) ////} //// ////function foo1() { //// return ( //// <div className="commentBox" data-id="test"> ////Hello, World!/*autoformat1*/ /////*indent1*/ //// </div> //// ) ////} //// ////function foo2() { //// return ( //// <div data-name="commentBox" ////class1= {/*1*/ ////}>/*2*/ ////Hello, World!/*autoformat2*/ /////*indent2*/ //// </div> //// ) ////} ////function foo3() { //// return ( //// <jsx-element className="commentBox" //// class2= {/*3*/ //// }>/*4*/ //// Hello, World!/*autoformat3*/ //// /*indent3*/ //// </jsx-element> //// ) ////} ////function foo4() { //// return ( //// <jsx-element className="commentBox" //// class3= {/*5*/ //// }/>/*6*/ //// ) ////} //// ////const bar = ( //// <> //// /*fragmentChildIndent*/<p>text</p> //// </> ////); //// ////const bar2 = <> //// <p>text</p> //// /*fragmentClosingTagIndent*/</>; //// ////(function () { //// return <div ////className=""/*attrAutoformat*/ /////*attrIndent*/ ////id={ ////"abc" + "cde"/*expressionAutoformat*/ /////*expressionIndent*/ ////} //// >/*danglingBracketAutoformat*/ //// </div>/*closingTagAutoformat*/ ////}) //// ////let h5 = <h5> ////<span>/*childJsxElementAutoformat*/ /////*childJsxElementIndent*/ ////<span></span>/*grandchildJsxElementAutoformat*/ ////</span>/*containedClosingTagAutoformat*/ ////</h5>; //// ////<div>,{integer}</div>;/*commaInJsxElement*/ ////<div>, {integer}</div>;/*commaInJsxElement2*/ ////<>,{integer}</>;/*commaInJsxFragment*/ ////<>, {integer}</>;/*commaInJsxFragment2*/ ////<span>)</span>;/*closingParenInJsxElement*/ ////<span>) </span>;/*closingParenInJsxElement2*/ ////<>)</>;/*closingParenInJsxFragment*/ ////<>) </>;/*closingParenInJsxFragment2*/ ////<Router routes = { 3 } / >;/*jsxExpressionSpaces*/ ////<Router routes={ (3) } />;/*jsxExpressionSpaces2*/ ////<Router routes={() => {}}/*jsxExpressionSpaces3*/ /////>;/*jsxDanglingSelfClosingToken*/ format.document(); goTo.marker("autoformat"); verify.currentLineContentIs(' Hello, World!'); goTo.marker("indent"); verify.indentationIs(12); goTo.marker("autoformat1"); verify.currentLineContentIs(' Hello, World!'); goTo.marker("indent1"); verify.indentationIs(12); goTo.marker("1"); verify.currentLineContentIs(' class1={'); goTo.marker("2"); verify.currentLineContentIs(' }>'); goTo.marker("autoformat2"); verify.currentLineContentIs(' Hello, World!'); goTo.marker("indent2"); verify.indentationIs(12); goTo.marker("3"); verify.currentLineContentIs(' class2={'); goTo.marker("4"); verify.currentLineContentIs(' }>'); goTo.marker("autoformat3"); verify.currentLineContentIs(' Hello, World!'); goTo.marker("indent3"); verify.indentationIs(12); goTo.marker("5"); verify.currentLineContentIs(' class3={'); goTo.marker("6"); verify.currentLineContentIs(' } />'); goTo.marker("fragmentChildIndent"); verify.currentLineContentIs(" <p>text</p>"); goTo.marker("fragmentClosingTagIndent"); verify.currentLineContentIs("</>;"); goTo.marker("attrAutoformat"); verify.currentLineContentIs(' className=""'); goTo.marker("attrIndent"); verify.indentationIs(8); goTo.marker("expressionAutoformat"); verify.currentLineContentIs(' "abc" + "cde"'); goTo.marker("expressionIndent"); verify.indentationIs(12); goTo.marker("danglingBracketAutoformat") verify.currentLineContentIs(" >"); goTo.marker("closingTagAutoformat"); verify.currentLineContentIs(" </div>"); goTo.marker("childJsxElementAutoformat"); verify.currentLineContentIs(" <span>"); goTo.marker("childJsxElementIndent"); verify.indentationIs(8); goTo.marker("grandchildJsxElementAutoformat"); verify.currentLineContentIs(" <span></span>"); goTo.marker("containedClosingTagAutoformat"); verify.currentLineContentIs(" </span>"); goTo.marker("commaInJsxElement"); verify.currentLineContentIs("<div>,{integer}</div>;"); goTo.marker("commaInJsxElement2"); verify.currentLineContentIs("<div>, {integer}</div>;"); goTo.marker("commaInJsxFragment"); verify.currentLineContentIs("<>,{integer}</>;"); goTo.marker("commaInJsxFragment2"); verify.currentLineContentIs("<>, {integer}</>;"); goTo.marker("closingParenInJsxElement"); verify.currentLineContentIs("<span>)</span>;"); goTo.marker("closingParenInJsxElement2"); verify.currentLineContentIs("<span>) </span>;"); goTo.marker("closingParenInJsxFragment"); verify.currentLineContentIs("<>)</>;"); goTo.marker("closingParenInJsxFragment2"); verify.currentLineContentIs("<>) </>;"); goTo.marker("jsxExpressionSpaces"); verify.currentLineContentIs("<Router routes={3} />;"); goTo.marker("jsxExpressionSpaces2"); verify.currentLineContentIs("<Router routes={(3)} />;"); goTo.marker("jsxExpressionSpaces3"); verify.currentLineContentIs("<Router routes={() => { }}"); goTo.marker("jsxDanglingSelfClosingToken"); verify.currentLineContentIs("/>;");
{ "end_byte": 5305, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingJsxElements.ts" }
TypeScript/tests/cases/fourslash/formattingOnChainedCallbacksAndPropertyAccesses.ts_0_769
/// <reference path='fourslash.ts'/> ////var x = 1; ////x /////*1*/.toFixed ////x /////*2*/.toFixed() ////x /////*3*/.toFixed() /////*4*/.length /////*5*/.toString(); ////x /////*6*/.toFixed /////*7*/.toString() /////*8*/.length; format.document(); goTo.marker('1'); verify.currentLineContentIs(' .toFixed'); goTo.marker('2'); verify.currentLineContentIs(' .toFixed()'); goTo.marker('3'); verify.currentLineContentIs(' .toFixed()'); goTo.marker('4'); verify.currentLineContentIs(' .length'); goTo.marker('5'); verify.currentLineContentIs(' .toString();'); goTo.marker('6'); verify.currentLineContentIs(' .toFixed'); goTo.marker('7'); verify.currentLineContentIs(' .toString()'); goTo.marker('8'); verify.currentLineContentIs(' .length;');
{ "end_byte": 769, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnChainedCallbacksAndPropertyAccesses.ts" }
TypeScript/tests/cases/fourslash/quickInfoImportNonunicodePath.ts_0_242
/// <reference path="fourslash.ts" /> // @Filename: /江南今何在/tmp.ts //// export const foo = 1; // @Filename: /test.ts //// import { foo } from "./江南/*1*/今何在/tmp"; verify.quickInfoAt("1", 'module "/江南今何在/tmp"');
{ "end_byte": 242, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoImportNonunicodePath.ts" }
TypeScript/tests/cases/fourslash/syntacticClassificationsCancellation1.ts_0_670
/// <reference path="fourslash.ts" /> ////module M { ////} ////module N { ////} const c = classification("original"); cancellation.setCancelled(1); verifyOperationIsCancelled(() => verify.syntacticClassificationsAre()); cancellation.resetCancelled(); verify.syntacticClassificationsAre( c.keyword("module"), c.moduleName("M"), c.punctuation("{"), c.punctuation("}"), c.keyword("module"), c.moduleName("N"), c.punctuation("{"), c.punctuation("}")); const c2 = classification("2020"); verify.semanticClassificationsAre("2020", c2.semanticToken("namespace.declaration", "M"), c2.semanticToken("namespace.declaration", "N"), );
{ "end_byte": 670, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsCancellation1.ts" }
TypeScript/tests/cases/fourslash/formattingObjectLiteralOpenCurlySingleLine.ts_0_279
/// <reference path='fourslash.ts' /> //// //// let obj1 = //// { x: 10 }; //// //// let obj2 = //// // leading trivia //// { y: 10 }; //// format.document(); verify.currentFileContentIs( ` let obj1 = { x: 10 }; let obj2 = // leading trivia { y: 10 }; ` );
{ "end_byte": 279, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingObjectLiteralOpenCurlySingleLine.ts" }