_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/jsSignature-41059.ts_0_242
/// <reference path="fourslash.ts" /> // @lib: esnext // @allowNonTsExtensions: true // @Filename: Foo.js //// a.next(/**/); goTo.marker(); verify.signatureHelp({ overloadsCount: 2, text: "Generator.next(): IteratorResult<T, TReturn>" });
{ "end_byte": 242, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsSignature-41059.ts" }
TypeScript/tests/cases/fourslash/moveToFile_existingImports5.ts_0_664
/// <reference path='fourslash.ts' /> // @filename: /a.ts ////export class Bar {} ////export class Baz {} // @filename: /b.ts ////import { Bar, Baz } from "./a"; //// ////[|const Foo = { //// bar: Bar, //// baz: Baz, ////}|] //// ////export function fn(name: keyof typeof Foo) { //// return Foo[name]; ////} verify.moveToFile({ newFileContents: { "/a.ts": `export class Bar {} export class Baz {} export const Foo = { bar: Bar, baz: Baz, }; `, "/b.ts": `import { Foo } from "./a"; export function fn(name: keyof typeof Foo) { return Foo[name]; }`, }, interactiveRefactorArguments: { targetFile: "/a.ts" }, });
{ "end_byte": 664, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_existingImports5.ts" }
TypeScript/tests/cases/fourslash/codeFixAddOptionalParam_all.ts_0_1096
/// <reference path='fourslash.ts' /> ////[|function f1() {}|] //// ////const a = 1; ////const b = ""; ////f1(a, b, true); //// ////function f2() {} ////f2("", { x: 1 }, [ "" ], true); //// ////class C { //// [|m1() {}|] //// m2(a: boolean) { //// this.m1(a); //// } ////} //// ////function f3(a: string): string; ////function f3(a: string, b?: number): string; ////function f3(a: string, b?: number): string { //// return ""; ////} ////f3("", "", 1); verify.codeFixAll({ fixId: "addOptionalParam", fixAllDescription: ts.Diagnostics.Add_all_optional_parameters.message, newFileContent: `function f1(a?: number, b?: string, p0?: boolean) {} const a = 1; const b = ""; f1(a, b, true); function f2(p0?: string, p1?: { x: number; }, p2?: string[], p3?: boolean) {} f2("", { x: 1 }, [ "" ], true); class C { m1(a?: boolean) {} m2(a: boolean) { this.m1(a); } } function f3(a: string): string; function f3(a: string, p0?: string, b?: number): string; function f3(a: string, p0?: string, b?: number): string { return ""; } f3("", "", 1);` });
{ "end_byte": 1096, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddOptionalParam_all.ts" }
TypeScript/tests/cases/fourslash/extendsKeywordCompletion1.ts_0_196
/// <reference path="fourslash.ts" /> ////export interface B ex/**/ verify.completions({ marker: "", includes: [{ name: "extends", sortText: completion.SortText.GlobalsOrKeywords }] });
{ "end_byte": 196, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extendsKeywordCompletion1.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceNoBody.ts_0_240
/// <reference path="fourslash.ts" /> //// interface I { //// m(): void //// } //// class C/*c*/ implements I verify.errorExistsBeforeMarker("c") goTo.marker("c") verify.codeFixAvailable([{ "description": "Implement interface 'I'" }])
{ "end_byte": 240, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceNoBody.ts" }
TypeScript/tests/cases/fourslash/unusedImportDeclaration_withEmptyPath2.ts_0_433
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////// leading trivia ////import { b } from "./b"; ////import * as foo from ""; ////import { c } from "./c"; // @Filename: /b.ts ////export const b = null; // @Filename: /c.ts ////export const c = null; verify.codeFix({ index: 1, description: "Remove import from ''", newFileContent: `// leading trivia import { b } from "./b"; import { c } from "./c";`, });
{ "end_byte": 433, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedImportDeclaration_withEmptyPath2.ts" }
TypeScript/tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts_0_245
/// <reference path='fourslash.ts' /> ////const obj = { /*1*/a: 1, b: 2 }; ////const filtered: { [P in keyof typeof obj as P extends 'b' ? never : P]: 0; } = { /*2*/a: 0 }; ////filtered./*3*/a; verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 245, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts" }
TypeScript/tests/cases/fourslash/globalThisCompletion.ts_0_295
/// <reference path="fourslash.ts" /> // @allowJs: true // @target: esnext // @Filename: test.js //// (typeof foo !== "undefined" //// ? foo //// : {} //// )./**/; // @Filename: someLib.d.ts //// declare var foo: typeof globalThis; goTo.marker(); verify.completions({ marker: "" });
{ "end_byte": 295, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/globalThisCompletion.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromFunctionThisUsageObjectProperty.ts_0_447
/// <reference path='fourslash.ts' /> // @noImplicitThis: true ////function returnThisMember([| |]) { //// return this.member; //// } //// //// interface Container { //// member: string; //// returnThisMember(): string; //// } //// //// const container: Container = { //// member: "sample", //// returnThisMember: returnThisMember, //// }; //// //// container.returnThisMember(); verify.rangeAfterCodeFix("this: Container");
{ "end_byte": 447, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromFunctionThisUsageObjectProperty.ts" }
TypeScript/tests/cases/fourslash/completionsObjectLiteralMethod2.ts_0_1237
/// <reference path="fourslash.ts" /> // @newline: LF // @Filename: a.ts ////export interface IFoo { //// bar(x: number): void; ////} // @Filename: b.ts ////import { IFoo } from "./a"; ////export interface IBar { //// foo(f: IFoo): void; ////} // @Filename: c.ts ////import { IBar } from "./b"; ////const obj: IBar = { //// /*a*/ ////} verify.completions({ marker: "a", preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithObjectLiteralMethodSnippets: true, useLabelDetailsInCompletionEntries: true, }, includes: [ { name: "foo", sortText: completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "foo"), insertText: undefined, }, { name: "foo", sortText: completion.SortText.SortBelow( completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "foo")), source: completion.CompletionSource.ObjectLiteralMethodSnippet, insertText: "foo(f) {\n},", labelDetails: { detail: "(f)", }, }, ], });
{ "end_byte": 1237, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsObjectLiteralMethod2.ts" }
TypeScript/tests/cases/fourslash/completionListFunctionExpression.ts_0_547
/// <reference path="fourslash.ts"/> ////class DataHandler { //// dataArray: Uint8Array; //// loadData(filename) { //// var xmlReq = new XMLHttpRequest(); //// xmlReq.open("GET", "/" + filename, true); //// xmlReq.responseType = "arraybuffer"; //// xmlReq.onload = function(xmlEvent) { //// /*local*/ //// this./*this*/; //// } //// } ////} goTo.marker("local"); edit.insertLine(""); verify.completions( { includes: "xmlEvent" }, { marker: "this", exact: undefined }, );
{ "end_byte": 547, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListFunctionExpression.ts" }
TypeScript/tests/cases/fourslash/documentHighlightInKeyword.ts_3_202
/ <reference path='fourslash.ts'/> ////export type Foo<T> = { //// [K [|in|] keyof T]: any; ////} //// ////"a" [|in|] {}; //// ////for (let a [|in|] {}) {} verify.baselineDocumentHighlights();
{ "end_byte": 202, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlightInKeyword.ts" }
TypeScript/tests/cases/fourslash/spaceAfterReturn.ts_0_341
/// <reference path='fourslash.ts'/> ////function f( ) { ////return 1;/*1*/ ////return[1];/*2*/ ////return ;/*3*/ ////} format.document(); goTo.marker("1"); verify.currentLineContentIs(" return 1;"); goTo.marker("2"); verify.currentLineContentIs(" return [1];"); goTo.marker("3"); verify.currentLineContentIs(" return;");
{ "end_byte": 341, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/spaceAfterReturn.ts" }
TypeScript/tests/cases/fourslash/navto_excludeLib2.ts_0_592
/// <reference path="fourslash.ts"/> // @filename: /index.ts //// import { [|someName as weirdName|] } from "bar"; // @filename: /tsconfig.json //// {} // @filename: /node_modules/bar/index.d.ts //// export const someName: number; // @filename: /node_modules/bar/package.json //// {} const [weird] = test.ranges(); verify.navigateTo({ pattern: "weirdName", expected: [{ name: "weirdName", kind: "alias", range: weird, matchKind: "exact", }], }); verify.navigateTo({ pattern: "weirdName", excludeLibFiles: true, expected: [], });
{ "end_byte": 592, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navto_excludeLib2.ts" }
TypeScript/tests/cases/fourslash/issue57429.ts_0_591
/// <reference path="fourslash.ts" /> // @strict: true //// function Builder<I>(def: I) { //// return def; //// } //// //// interface IThing { //// doThing: (args: { value: object }) => string //// doAnotherThing: () => void //// } //// //// Builder<IThing>({ //// doThing(args: { value: object }) { //// const { v/*1*/alue } = this.[|args|] //// return `${value}` //// }, //// doAnotherThing() { }, //// }) verify.quickInfoAt("1", "const value: any"); verify.getSemanticDiagnostics([{ message: "Property 'args' does not exist on type 'IThing'.", code: 2339, }]);
{ "end_byte": 591, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/issue57429.ts" }
TypeScript/tests/cases/fourslash/quickInfoForConstAssertions.ts_0_206
/// <reference path="fourslash.ts" /> ////const a = { a: 1 } as /*1*/const; ////const b = 1 as /*2*/const; ////const c = "c" as /*3*/const; ////const d = [1, 2] as /*4*/const; verify.baselineQuickInfo();
{ "end_byte": 206, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForConstAssertions.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingPrivateIdentifierMethodDeclaration.ts_0_328
/// <reference path='fourslash.ts' /> //// class A { //// constructor() { //// this.[|/*pnUse*/#prop|] = 123; //// } //// } verify.codeFix({ description: "Declare property '#prop'", index: 0, newFileContent: `class A { #prop: number; constructor() { this.#prop = 123; } }` });
{ "end_byte": 328, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingPrivateIdentifierMethodDeclaration.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionDecoratorOverloads.ts_0_503
// @Target: ES6 // @experimentaldecorators: true ////async function f() {} //// ////function /*defDecString*/dec(target: any, propertyKey: string): void; ////function /*defDecSymbol*/dec(target: any, propertyKey: symbol): void; ////function dec(target: any, propertyKey: string | symbol) {} //// ////declare const s: symbol; ////class C { //// @[|/*useDecString*/dec|] f() {} //// @[|/*useDecSymbol*/dec|] [s]() {} ////} verify.baselineGoToDefinition( "useDecString", "useDecSymbol", );
{ "end_byte": 503, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionDecoratorOverloads.ts" }
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class-removeConstructor.ts_0_408
// @allowNonTsExtensions: true // @Filename: test123.js /// <reference path="./fourslash.ts" /> //// // Comment //// function /*1*/fn() { //// this.baz = 10; //// } //// fn.prototype = { //// constructor: fn //// } verify.codeFix({ description: "Convert function to an ES2015 class", newFileContent: `// Comment class fn { constructor() { this.baz = 10; } } `, });
{ "end_byte": 408, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class-removeConstructor.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationObjectLiteralExpressions.ts_0_684
/// <reference path='fourslash.ts' /> // @BaselineFile: bpSpan_objectLiteralExpressions.baseline // @Filename: bpSpan_objectLiteralExpressions.ts ////var x = { //// a: 10, //// b: () => 10, //// someMethod() { //// return "Hello"; //// }, //// get y() { //// return 30; //// }, //// set z(x: number) { //// var bar = x; //// } ////}; ////var a = ({ //// a: 10, //// b: () => 10, //// someMethod() { //// return "Hello"; //// }, //// get y() { //// return 30; //// }, //// set z(x: number) { //// var bar = x; //// } ////}).someMethod; ////a(); verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 684, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationObjectLiteralExpressions.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionImportedNames11.ts_0_321
/// <reference path='fourslash.ts' /> // @allowjs: true // @Filename: a.js //// class /*classDefinition*/Class { //// f; //// } //// module.exports = { Class }; // @Filename: b.js ////const { Class } = require("./a"); //// [|/*classAliasDefinition*/Class|]; verify.baselineGoToDefinition("classAliasDefinition");
{ "end_byte": 321, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionImportedNames11.ts" }
TypeScript/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation4.ts_0_312
/// <reference path='fourslash.ts'/> // @strict: true //// interface Serializer { //// set value(v: string | number | boolean); //// get value(): string; //// } //// declare let box: Serializer; //// box.value/*1*/ = true; verify.quickInfoAt('1', '(property) Serializer.value: string | number | boolean');
{ "end_byte": 312, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation4.ts" }
TypeScript/tests/cases/fourslash/autoImportAllowTsExtensions2.ts_0_578
/// <reference path="fourslash.ts" /> // @moduleResolution: bundler // @allowImportingTsExtensions: true // @noEmit: true // @Filename: /node_modules/@types/foo/index.d.ts //// export const fromAtTypesFoo: number; // @Filename: /node_modules/bar/index.d.ts //// export const fromBar: number; // @Filename: /local.ts //// export const fromLocal: number; // @Filename: /Component.tsx //// export function Component() { return null; } // @Filename: /main.ts //// /**/ verify.baselineAutoImports("", /*fullNamesForCodeFix*/ undefined, { importModuleSpecifierEnding: "js" });
{ "end_byte": 578, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportAllowTsExtensions2.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess19.ts_0_198
/// <reference path='fourslash.ts' /> //// class A { //// constructor(/*a*/a/*b*/: string) { } //// } goTo.select("a", "b"); verify.not.refactorAvailable("Generate 'get' and 'set' accessors");
{ "end_byte": 198, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess19.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageContextualImport2.ts_0_520
/// <reference path="fourslash.ts" /> // @strict: true // @noImplicitAny: true // @noLib: true // @Filename: /types.d.ts ////declare function getEmail(user: import('./a').User): string; // @Filename: /a.ts ////export interface User {} // @Filename: /b.ts ////export function f([|user|]) { //// getEmail(user); ////} goTo.file("/b.ts"); verify.codeFix({ description: "Infer parameter types from usage", newFileContent: `import { User } from "./a"; export function f(user: User) { getEmail(user); }` });
{ "end_byte": 520, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageContextualImport2.ts" }
TypeScript/tests/cases/fourslash/completionsJsdocTag.ts_0_200
/// <reference path="fourslash.ts" /> /////** //// * @typedef {object} T //// * /**/ //// */ verify.completions({ marker: "", includes: { name: "@property", text: "@property", kind: "keyword" } });
{ "end_byte": 200, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsJsdocTag.ts" }
TypeScript/tests/cases/fourslash/refactorConvertImport_namespaceToNamed_namespaceUsed.ts_0_379
/// <reference path='fourslash.ts' /> /////*a*/import * as m from "m";/*b*/ ////m.a; ////m; goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert import", actionName: "Convert namespace import to named imports", actionDescription: "Convert namespace import to named imports", newContent: `import * as m from "m"; import { a } from "m"; a; m;`, });
{ "end_byte": 379, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertImport_namespaceToNamed_namespaceUsed.ts" }
TypeScript/tests/cases/fourslash/completionListWithoutVariableinitializer.ts_0_1192
/// <reference path='fourslash.ts' /> //// const a = a/*1*/; //// const b = a && b/*2*/; //// const c = [{ prop: [c/*3*/] }]; //// const d = () => { d/*4*/ }; //// const e = () => expression/*5*/ //// const f = { prop() { e/*6*/ } }; //// const fn = (p = /*7*/) => {} //// const { g, h = /*8*/ } = { ... } //// const [ g1, h1 = /*9*/ ] = [ ... ] verify.completions({ marker: ["1"], excludes: ["a"], isNewIdentifierLocation: true, }); verify.completions({ marker: ["2"], excludes: ["b"], includes: ["a"], }); verify.completions({ marker: ["3"], excludes: ["c"], includes: ["a", "b"], isNewIdentifierLocation: true, }); verify.completions({ marker: ["4"], includes: ["a", "b", "c", "d"], }); verify.completions({ marker: ["5"], includes: ["a", "b", "c", "d", "e"], }); verify.completions({ marker: ["6"], includes: ["a", "b", "c", "d", "e"], }); verify.completions({ marker: ["7"], includes: ["a", "b", "c", "d", "e", "fn"], }); verify.completions({ marker: ["8"], includes: ["a", "b", "c", "d", "e", "fn"], }); verify.completions({ marker: ["9"], includes: ["a", "b", "c", "d", "e", "fn"], });
{ "end_byte": 1192, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListWithoutVariableinitializer.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingAsync2.ts_0_483
/// <reference path="fourslash.ts" /> ////interface Stuff { //// b: () => Promise<string>; ////} //// ////function foo(): Stuff | Date { //// return { //// b: _ => "hello", //// } ////} verify.codeFix({ description: ts.Diagnostics.Add_async_modifier_to_containing_function.message, index: 0, newFileContent: `interface Stuff { b: () => Promise<string>; } function foo(): Stuff | Date { return { b: async (_) => "hello", } }` });
{ "end_byte": 483, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAsync2.ts" }
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction14.ts_0_315
/// <reference path='fourslash.ts' /> // @target: es2015 ////async function fn(): string | symbol {} verify.codeFix({ index: 0, description: [ts.Diagnostics.Replace_0_with_Promise_1.message, "string | symbol", "string | symbol"], newFileContent: `async function fn(): Promise<string | symbol> {}` });
{ "end_byte": 315, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction14.ts" }
TypeScript/tests/cases/fourslash/fixExactOptionalUnassignableProperties16.ts_0_675
/// <reference path='fourslash.ts'/> // @strictNullChecks: true // @exactOptionalPropertyTypes: true //// interface Assignment { //// a?: number //// } //// interface J { //// a?: number | undefined //// } //// declare var j: J //// var assignment/**/: Assignment = j verify.codeFixAvailable([ { description: ts.Diagnostics.Add_undefined_to_optional_property_type.message } ]); verify.codeFix({ description: ts.Diagnostics.Add_undefined_to_optional_property_type.message, index: 0, newFileContent: `interface Assignment { a?: number | undefined } interface J { a?: number | undefined } declare var j: J var assignment: Assignment = j`, });
{ "end_byte": 675, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixExactOptionalUnassignableProperties16.ts" }
TypeScript/tests/cases/fourslash/autoImportTypeOnlyPreferred3.ts_0_1166
// @module: esnext // @moduleResolution: bundler // @Filename: /a.ts //// export class A {} //// export class B {} // @Filename: /b.ts //// let x: A/*b*/; // @Filename: /c.ts //// import { A } from "./a"; //// new A(); //// let x: B/*c*/; // @Filename: /d.ts //// new A(); //// let x: B; // @Filename: /ns.ts //// export * as default from "./a"; // @Filename: /e.ts //// let x: /*e*/ns.A; goTo.marker("b"); verify.importFixAtPosition([ `import type { A } from "./a"; let x: A;`], /*errorCode*/ undefined, { preferTypeOnlyAutoImports: true, } ); goTo.marker("c"); verify.importFixAtPosition([ `import { A, type B } from "./a"; new A(); let x: B;`], /*errorCode*/ undefined, { preferTypeOnlyAutoImports: true, } ); goTo.file("/d.ts"); verify.codeFixAll({ fixId: "fixMissingImport", fixAllDescription: "Add all missing imports", newFileContent: `import { A, type B } from "./a"; new A(); let x: B;`, preferences: { preferTypeOnlyAutoImports: true, }, }); goTo.marker("e"); verify.importFixAtPosition([ `import type ns from "./ns"; let x: ns.A;`], /*errorCode*/ undefined, { preferTypeOnlyAutoImports: true, } );
{ "end_byte": 1166, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportTypeOnlyPreferred3.ts" }
TypeScript/tests/cases/fourslash/organizeImports5.ts_0_409
/// <reference path="fourslash.ts" /> // Regression test for GH#43107 //// import * as something from "path";/** //// * some comment here //// * and there //// */ //// import * as somethingElse from "anotherpath"; //// import * as AnotherThing from "somepath";/** //// * some comment here //// * and there //// */ //// import * as AnotherThingElse from "someotherpath"; verify.organizeImports('');
{ "end_byte": 409, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImports5.ts" }
TypeScript/tests/cases/fourslash/jsxElementExtendsNoCrash1.ts_0_125
/// <reference path="fourslash.ts" /> // @filename: index.tsx //// <const T extends/> verify.getSuggestionDiagnostics([]);
{ "end_byte": 125, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsxElementExtendsNoCrash1.ts" }
TypeScript/tests/cases/fourslash/getEditsForFileRename_symlink.ts_0_327
/// <reference path='fourslash.ts' /> // @Filename: /foo.ts // @Symlink: /node_modules/foo/index.ts ////export const x = 0; // @Filename: /user.ts ////import { x } from 'foo'; verify.noErrors(); verify.getEditsForFileRename({ oldPath: "/user.ts", newPath: "/luser.ts", // no change newFileContents: {}, });
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_symlink.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionThis.ts_0_357
/// <reference path='fourslash.ts'/> ////function f(/*fnDecl*/this: number) { //// return [|/*fnUse*/this|]; ////} ////class /*cls*/C { //// constructor() { return [|/*clsUse*/this|]; } //// get self(/*getterDecl*/this: number) { return [|/*getterUse*/this|]; } ////} verify.baselineGoToDefinition( "fnUse", "clsUse", "getterUse", );
{ "end_byte": 357, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionThis.ts" }
TypeScript/tests/cases/fourslash/completionInJsDoc.ts_0_1252
///<reference path="fourslash.ts" /> // @allowJs: true // @Filename: Foo.js //// /** @/*1*/ */ //// var v1; //// //// /** @p/*2*/ */ //// var v2; //// //// /** @param /*3*/ */ //// var v3; //// //// /** @param { n/*4*/ } bar */ //// var v4; //// //// /** @type { n/*5*/ } */ //// var v5; //// //// // @/*6*/ //// var v6; //// //// // @pa/*7*/ //// var v7; //// //// /** @return { n/*8*/ } */ //// var v8; //// //// /** /*9*/ */ //// //// /** //// /*10*/ //// */ //// //// /** //// * /*11*/ //// */ //// //// /** //// /*12*/ //// */ //// //// /** //// * /*13*/ //// */ //// //// /** //// * some comment /*14*/ //// */ //// //// /** //// * @param /*15*/ //// */ //// //// /** @param /*16*/ */ //// //// /** //// * jsdoc inline tag {@/*17*/} //// */ verify.completions( { marker: ["1", "2"], includes: ["constructor", "param", "type", "method", "template"] }, { marker: ["3", "15", "16"], exact: [] }, { marker: ["4", "5", "8"], includes: { name: "number", sortText: completion.SortText.GlobalsOrKeywords } }, { marker: ["6", "7", "14"], exact: undefined }, { marker: ["9", "10", "11", "12", "13"], includes: ["@argument", "@returns"] }, { marker: ["17"], includes: ["link", "tutorial"] }, );
{ "end_byte": 1252, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionInJsDoc.ts" }
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts_0_492
/// <reference path="./fourslash.ts"/> //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } //// //// f `/*1*/a $/*2*/{ /*3*/g /*4*/`alpha ${ 123 } beta ${ 456 } gamma`/*5*/ }/*6*/ b $/*7*/{ /*8*/g /*9*/`txt`/*10*/ } /*11*/c ${ /*12*/g /*13*/`aleph ${ 123 } beit`/*14*/ } d/*15*/`; verify.signatureHelp({ marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", parameterCount: 4, });
{ "end_byte": 492, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType8.ts_0_478
/// <reference path='fourslash.ts' /> //// function foo(a: number, b?: /*a*/number/*b*/, ...c: number[]): boolean { //// return false as boolean; //// } goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to type alias", actionDescription: "Extract to type alias", newContent: `type /*RENAME*/NewType = number; function foo(a: number, b?: NewType, ...c: number[]): boolean { return false as boolean; }`, });
{ "end_byte": 478, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType8.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptCompletions10.ts_0_290
///<reference path="fourslash.ts" /> // @allowNonTsExtensions: true // @Filename: Foo.js /////** //// * @type {function(this:number)} //// */ ////function f() { this./**/ } verify.completions({ marker: "", includes: { name: "toExponential", kind: "method", kindModifiers: "declare" } });
{ "end_byte": 290, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptCompletions10.ts" }
TypeScript/tests/cases/fourslash/navigationItemsSubStringMatch2.ts_0_2194
/// <reference path="fourslash.ts"/> ////module Shapes { //// export class Point { //// [|private originPointAtTheHorizon = 0.0;|] //// //// [|get distanceFromOrigin(distanceParam): number { //// var [|distanceLocal|]; //// return 0; //// }|] //// } ////} //// ////var [|myPointThatIJustInitiated = new Shapes.Point()|]; ////[|interface IDistance{ //// [|INITIATED123;|] //// [|public horizon(): void;|] ////}|] const [r0, r1, r2, r3, r4, r5, r6] = test.ranges() const horizon: FourSlashInterface.ExpectedNavigateToItem = { name: "horizon", kind: "method", kindModifiers: "public", range: r6, containerName: "IDistance", containerKind: "interface" }; const origin: FourSlashInterface.ExpectedNavigateToItem = { name: "originPointAtTheHorizon", kind: "property", kindModifiers: "private", range: r0, containerName: "Point", containerKind: "class" }; verify.navigateTo( { pattern: "Horizon", expected: [ { ...horizon, isCaseSensitive: false }, { ...origin, matchKind: "substring" }, ], }, { pattern: "horizon", expected: [ horizon, { ...origin, matchKind: "substring", isCaseSensitive: false }, ], }, { pattern: "Distance", expected: [ { name: "distanceFromOrigin", matchKind: "prefix", isCaseSensitive: false, kind: "getter", range: r1, containerName: "Point", containerKind: "class" }, { name: "distanceLocal", matchKind: "prefix", isCaseSensitive: false, kind: "var", range: r2, containerName: "distanceFromOrigin", containerKind: "getter" }, { name: "IDistance", matchKind: "substring", kind: "interface", range: r4 }, ], }, { pattern: "INITIATED", expected: [ { name: "INITIATED123", matchKind: "prefix", kind: "property", range: r5, containerName: "IDistance", containerKind: "interface" }, ], }, { pattern: "mPointThatIJustInitiated wrongKeyWord", expected: [ { name: "myPointThatIJustInitiated", matchKind: "camelCase", kind: "var", range: r3 } ], }, );
{ "end_byte": 2194, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationItemsSubStringMatch2.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteralWithDynamicImport.ts_0_910
/// <reference path='fourslash.ts' /> // Should define spans for replacement that appear after the last directory seperator in dynamic import statements // @typeRoots: my_typings // @Filename: test.ts //// const a = import("./some/*0*/ //// const a = import("./sub/some/*1*/"); //// const a = import("[|some-/*2*/|]"); //// const a = import("..//*3*/"); // @Filename: someFile1.ts //// /*someFile1*/ // @Filename: sub/someFile2.ts //// /*someFile2*/ // @Filename: my_typings/some-module/index.d.ts //// export var x = 9; verify.completions( { marker: "0", exact: ["someFile1", "my_typings", "sub"], isNewIdentifierLocation: true }, { marker: "1", exact: "someFile2", isNewIdentifierLocation: true }, { marker: "2", exact: { name: "some-module", replacementSpan: test.ranges()[0] }, isNewIdentifierLocation: true }, { marker: "3", exact: "fourslash", isNewIdentifierLocation: true }, );
{ "end_byte": 910, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralWithDynamicImport.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess39.ts_0_614
/// <reference path='fourslash.ts' /> // @strict: true ////type Foo = undefined | null; ////class A { //// /*a*/foo?: string | Foo;/*b*/ ////} goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Generate 'get' and 'set' accessors", actionName: "Generate 'get' and 'set' accessors", actionDescription: "Generate 'get' and 'set' accessors", newContent: `type Foo = undefined | null; class A { private /*RENAME*/_foo?: string | Foo; public get foo(): string | Foo { return this._foo; } public set foo(value: string | Foo) { this._foo = value; } }` });
{ "end_byte": 614, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess39.ts" }
TypeScript/tests/cases/fourslash/crossFileQuickInfoExportedTypeDoesNotUseImportType.ts_0_419
/// <reference path="fourslash.ts" /> // @Filename: b.ts ////export interface B {} ////export function foob(): { //// x: B, //// y: B ////} { //// return null as any; ////} // @Filename: a.ts ////import { foob } from "./b"; ////const thing/*1*/ = foob(/*2*/); verify.quickInfoAt("1", "const thing: {\n x: B;\n y: B;\n}"); verify.signatureHelp({ marker: "2", text: "foob(): { x: B; y: B; }" });
{ "end_byte": 419, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/crossFileQuickInfoExportedTypeDoesNotUseImportType.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionImports.ts_0_525
/// <reference path='fourslash.ts'/> // @Filename: /a.ts ////export default function /*fDef*/f() {} ////export const /*xDef*/x = 0; // @Filename: /b.ts /////*bDef*/declare const b: number; ////export = b; // @Filename: /b.ts ////import f, { x } from "./a"; ////import * as /*aDef*/a from "./a"; ////import b = require("./b"); ////[|/*fUse*/f|]; ////[|/*xUse*/x|]; ////[|/*aUse*/a|]; ////[|/*bUse*/b|]; verify.baselineGoToDefinition( "aUse", // Namespace import isn't "skipped" "fUse", "xUse", "bUse", );
{ "end_byte": 525, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionImports.ts" }
TypeScript/tests/cases/fourslash/findAllReferencesDynamicImport3.ts_0_450
/// <reference path='fourslash.ts' /> // @Filename: foo.ts ////[|export function /*0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}bar|]() { return "bar"; }|] ////import('./foo').then(([|{ /*1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}bar|] }|]) => undefined); const [r0Def, r0, r1Def, r1] = test.ranges(); verify.baselineFindAllReferences('0', '1'); verify.baselineRename([r0, r1]);
{ "end_byte": 450, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesDynamicImport3.ts" }
TypeScript/tests/cases/fourslash/jsDocFunctionSignatures4.ts_0_251
///<reference path="fourslash.ts" /> // @allowNonTsExtensions: true // @Filename: Foo.js //// /** @param {function ({OwnerID:string,AwayID:string}):void} x //// * @param {function (string):void} y */ //// function fn(x, y) { } verify.noErrors();
{ "end_byte": 251, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocFunctionSignatures4.ts" }
TypeScript/tests/cases/fourslash/emptyArrayInference.ts_0_196
/// <reference path='fourslash.ts'/> ////var x/*1*/x = true ? [1] : [undefined]; ////var y/*2*/y = true ? [1] : []; verify.quickInfos({ 1: "var xx: number[]", 2: "var yy: number[]" });
{ "end_byte": 196, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/emptyArrayInference.ts" }
TypeScript/tests/cases/fourslash/quickInfoImportedTypesWithMergedMeanings.ts_0_1163
/// <reference path="fourslash.ts" /> // @Filename: quickInfoImportedTypesWithMergedMeanings.ts //// export namespace Original { } //// export type Original<T> = () => T; //// /** some docs */ //// export function Original() { } // @Filename: transient.ts //// export { Original/*1*/ } from './quickInfoImportedTypesWithMergedMeanings'; // @Filename: importer.ts //// import { Original as /*2*/Alias } from './quickInfoImportedTypesWithMergedMeanings'; //// Alias/*3*/; //// let x: Alias/*4*/ verify.quickInfoAt("1", [ "(alias) function Original(): void", "(alias) type Original<T> = () => T", "(alias) namespace Original", "export Original", ].join("\n"), "some docs"); verify.quickInfoAt("2", [ "(alias) function Alias(): void", "(alias) type Alias<T> = () => T", "(alias) namespace Alias", "import Alias", ].join("\n"), "some docs"); verify.quickInfoAt("3", [ "(alias) function Alias(): void", "(alias) namespace Alias", "import Alias", ].join("\n"), "some docs"); verify.quickInfoAt("4", [ "(alias) type Alias<T> = () => T", "(alias) namespace Alias", "import Alias", ].join("\n"), "some docs");
{ "end_byte": 1163, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoImportedTypesWithMergedMeanings.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesIfElse5.ts_0_512
/// <reference path='fourslash.ts' /> ////if/*1*/ (true) { //// if/*2*/ (false) { //// } //// else/*3*/ { //// } //// if/*4*/ (true) { //// } //// else/*5*/ { //// if/*6*/ (false) //// if/*7*/ (true) //// var x = undefined; //// } ////} ////else/*8*/ if (null) { ////} ////else/*9*/ /* whar garbl */ if/*10*/ (undefined) { ////} ////else/*11*/ ////if/*12*/ (false) { ////} ////else/*13*/ { } verify.baselineDocumentHighlights(test.markers());
{ "end_byte": 512, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesIfElse5.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesSwitchCaseDefault2.ts_0_439
/// <reference path='fourslash.ts' /> ////switch (10) { //// case 1: //// case 2: //// case 4: //// case 8: //// foo: [|switch|] (20) { //// [|case|] 1: //// [|case|] 2: //// [|break|]; //// [|default|]: //// [|break|] foo; //// } //// case 0xBEEF: //// default: //// break; //// case 16: ////} verify.baselineDocumentHighlights();
{ "end_byte": 439, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesSwitchCaseDefault2.ts" }
TypeScript/tests/cases/fourslash/smartIndentOnUnclosedConstructorType01.ts_0_214
/// <reference path='fourslash.ts' /> ////var x: new () => { ////{| "indent": 4 |} test.markers().forEach(marker => { verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent); });
{ "end_byte": 214, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentOnUnclosedConstructorType01.ts" }
TypeScript/tests/cases/fourslash/completionListInUnclosedFunction07.ts_3_256
/ <reference path="fourslash.ts" /> ////function foo(x: string, y: number, z: boolean) { //// function bar(a: number, b: string = /*1*/, c: typeof x = "hello" ////} verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a"]})
{ "end_byte": 256, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedFunction07.ts" }
TypeScript/tests/cases/fourslash/moveToFile_expandSelectionRange5.ts_0_427
/// <reference path='fourslash.ts' /> //@Filename: /bar.ts ////import { b } from './other'; ////const t = b; // @Filename: /a.ts ////fu[|nction f|]oo() { } // @Filename: /other.ts ////export const b = 2; verify.moveToFile({ newFileContents: { "/a.ts": ``, "/bar.ts": `import { b } from './other'; const t = b; function foo() { } `, }, interactiveRefactorArguments: { targetFile: "/bar.ts" } });
{ "end_byte": 427, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_expandSelectionRange5.ts" }
TypeScript/tests/cases/fourslash/extract-method42.ts_0_417
/// <reference path='fourslash.ts' /> ////function foo() { //// const x = 10 * /*a*/(10 + 10)/*b*/; ////} goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "function_scope_1", actionDescription: "Extract to function in global scope", newContent: `function foo() { const x = 10 * /*RENAME*/newFunction(); } function newFunction() { return 10 + 10; } ` });
{ "end_byte": 417, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method42.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_removeVariableStatement.ts_0_231
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true ////function f() { //// let a = 1, b = 2, c = 3; ////} verify.codeFix({ description: "Remove variable statement", newFileContent: `function f() { }`, });
{ "end_byte": 231, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_removeVariableStatement.ts" }
TypeScript/tests/cases/fourslash/completionsPathsJsonModuleWithAmd.ts_0_271
/// <reference path="fourslash.ts" /> // @module: amd // @resolveJsonModule: true // @Filename: /project/test.json ////not read // @Filename: /project/index.ts ////import { } from ".//**/"; verify.completions({ marker: "", exact: [], isNewIdentifierLocation: true });
{ "end_byte": 271, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsPathsJsonModuleWithAmd.ts" }
TypeScript/tests/cases/fourslash/renameJsExports01.ts_0_332
/// <reference path='fourslash.ts'/> // @allowJs: true // @Filename: a.js ////[|exports.[|{| "contextRangeIndex": 0 |}area|] = function (r) { return r * r; }|] // @Filename: b.js ////var mod = require('./a'); ////var t = mod./*1*/[|area|](10); verify.baselineFindAllReferences('1'); verify.baselineRenameAtRangesWithText("area");
{ "end_byte": 332, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameJsExports01.ts" }
TypeScript/tests/cases/fourslash/renameParameterPropertyDeclaration2.ts_3_307
/ <reference path='fourslash.ts'/> //// class Foo { //// constructor([|public [|{| "contextRangeIndex": 0 |}publicParam|]: number|]) { //// let publicParam = [|publicParam|]; //// this.[|publicParam|] += 10; //// } //// } verify.baselineRenameAtRangesWithText("publicParam");
{ "end_byte": 307, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameParameterPropertyDeclaration2.ts" }
TypeScript/tests/cases/fourslash/formattingOnNestedStatements.ts_0_289
/// <reference path='fourslash.ts' /> ////{ /////*1*/{ /////*3*/test ////}/*2*/ ////} format.selection("1", "2"); goTo.marker("1"); verify.currentLineContentIs(" {"); goTo.marker("3"); verify.currentLineContentIs(" test"); goTo.marker("2"); verify.currentLineContentIs(" }");
{ "end_byte": 289, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnNestedStatements.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedInterfaceInNamespace1.ts_0_195
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true //// [| namespace greeter { //// interface interface1 { //// } ////} |] verify.rangeAfterCodeFix(` namespace greeter { }`);
{ "end_byte": 195, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedInterfaceInNamespace1.ts" }
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnonymous_Comment1.ts_0_415
/// <reference path='fourslash.ts' /> ////const foo = /*a*/()/*b*/ => /** //// * comment //// */ ////1 goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert arrow function or function expression", actionName: "Convert to anonymous function", actionDescription: "Convert to anonymous function", newContent: `const foo = function() { /** * comment */ return 1; }` });
{ "end_byte": 415, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnonymous_Comment1.ts" }
TypeScript/tests/cases/fourslash/extract-method13.ts_0_1298
/// <reference path='fourslash.ts' /> // Extracting from a static context should make static methods. // Also checks that we correctly find non-conflicting names in static contexts. //// class C { //// static j = /*c*/1 + 1/*d*/; //// constructor(q: string = /*a*/"hello"/*b*/) { //// } //// } goTo.select('a', 'b'); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "function_scope_0", actionDescription: "Extract to method in class 'C'", newContent: `class C { static j = 1 + 1; constructor(q: string = C./*RENAME*/newMethod()) { } private static newMethod(): string { return "hello"; } }` }); verify.currentFileContentIs(`class C { static j = 1 + 1; constructor(q: string = C.newMethod()) { } private static newMethod(): string { return "hello"; } }`); goTo.select('c', 'd'); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "function_scope_0", actionDescription: "Extract to method in class 'C'", newContent: `class C { static j = C./*RENAME*/newMethod_1(); constructor(q: string = C.newMethod()) { } private static newMethod_1() { return 1 + 1; } private static newMethod(): string { return "hello"; } }` });
{ "end_byte": 1298, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method13.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics10.ts_0_140
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: a.js ////function F<T>() { } verify.baselineSyntacticDiagnostics();
{ "end_byte": 140, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics10.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_alias.ts_1_528
/// <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(); //// } //// }|] verify.moveToNewFile({ newFileContents: { "/test.ts": ` class Another {} `, "/Consumer.ts": `import { doit as doit2 } from "./producer"; class Consumer { constructor() { doit2(); } } ` } });
{ "end_byte": 528, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_alias.ts" }
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateMultiExpr.ts_0_463
/// <reference path='fourslash.ts' /> //// const age = 22 //// const name = "Eddy" //// const foo = /*x*/n/*y*/ame + " is " + age + " years old" goTo.select("x", "y"); edit.applyRefactor({ refactorName: "Convert to template string", actionName: "Convert to template string", actionDescription: ts.Diagnostics.Convert_to_template_string.message, newContent: `const age = 22 const name = "Eddy" const foo = \`\${name} is \${age} years old\``, });
{ "end_byte": 463, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateMultiExpr.ts" }
TypeScript/tests/cases/fourslash/jsSpecialAssignmentMerging2.ts_0_487
/// <reference path="fourslash.ts" /> // @noEmit: true // @allowJs: true // @checkJs: true // @Filename: b.d.ts //// declare namespace N { //// class X { } //// } // @Filename: a.js //// var N = {}; //// N.X = function() { }; // @Filename: test.js //// var c = N.X //// /*1*/ // #24015 // This failed with 13 and up on my machine, so 20 is 2**7 more than needed. for (let i = 0; i < 20; i++) { goTo.marker('1'); edit.insertLine('c'); verify.getSemanticDiagnostics([]) }
{ "end_byte": 487, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsSpecialAssignmentMerging2.ts" }
TypeScript/tests/cases/fourslash/navigationItemsExactMatch2.ts_0_1962
/// <reference path="fourslash.ts"/> ////module Shapes { //// [|class Point { //// [|private _origin = 0.0;|] //// [|private distanceFromA = 0.0;|] //// //// [|get distance1(distanceParam): number { //// var [|distanceLocal|]; //// return 0; //// }|] //// }|] ////} //// ////var [|point = new Shapes.Point()|]; ////[|function distance2(distanceParam1): void { //// var [|distanceLocal1|]; ////}|] const [r_Point, r_origin, r_distanceFromA, r_distance1, r_distanceLocal, r_point, r_distance2, r_distanceLocal1] = test.ranges(); verify.navigateTo( { pattern: "point", expected: [ { name: "point", kind: "var", range: r_point }, { name: "Point", kind: "class", isCaseSensitive: false, range: r_Point, containerName: "Shapes", containerKind: "module" }, ], }, { pattern: "distance", expected: [ { name: "distance1", matchKind: "prefix", kind: "getter", range: r_distance1, containerName: "Point", containerKind: "class" }, { name: "distance2", matchKind: "prefix", kind: "function", range: r_distance2 }, { name: "distanceFromA", matchKind: "prefix", kind: "property", kindModifiers: "private", range: r_distanceFromA, containerName: "Point", containerKind: "class" }, { name: "distanceLocal", matchKind: "prefix", kind: "var", range: r_distanceLocal, containerName: "distance1", containerKind: "getter" }, { name: "distanceLocal1", matchKind: "prefix", kind: "var", range: r_distanceLocal1, containerName: "distance2", containerKind: "function" }, ], }, { pattern: "origin", expected: [ { name: "_origin", matchKind: "substring", kind: "property", kindModifiers: "private", range: r_origin, containerName: "Point", containerKind: "class" }, ], }, { pattern: "square", expected: [], } );
{ "end_byte": 1962, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationItemsExactMatch2.ts" }
TypeScript/tests/cases/fourslash/codeFixConvertToTypeOnlyExport1.ts_0_492
/// <reference path="fourslash.ts" /> // @isolatedModules: true // @Filename: /a.ts ////export type A = {}; ////export type B = {}; // @Filename: /b.ts /////* Comment */ ////export { A, B } from './a'; goTo.file("/b.ts"); verify.codeFix({ index: 0, description: ts.Diagnostics.Convert_to_type_only_export.message, errorCode: ts.Diagnostics.Re_exporting_a_type_when_0_is_enabled_requires_using_export_type.code, newFileContent: `/* Comment */ export type { A, B } from './a';` });
{ "end_byte": 492, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToTypeOnlyExport1.ts" }
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString5.ts_0_437
/// <reference path='fourslash.ts' /> ////const foo = 1; ////const bar = /*start*/`1` + "2" + `3` + `${foo}`/*end*/; goTo.select("start", "end"); edit.applyRefactor({ refactorName: "Convert to template string", actionName: "Convert to template string", actionDescription: ts.Diagnostics.Convert_to_template_string.message, newContent: [ "const foo = 1;", "const bar = `123${foo}`;" ].join("\n") });
{ "end_byte": 437, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString5.ts" }
TypeScript/tests/cases/fourslash/smartSelection_JSDocTags3.ts_0_141
/// <reference path="fourslash.ts" /> /////** //// * @param {/**/string} x //// */ ////function foo(x) {} verify.baselineSmartSelection();
{ "end_byte": 141, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_JSDocTags3.ts" }
TypeScript/tests/cases/fourslash/completionsStringLiteral_fromTypeConstraint.ts_0_283
/// <reference path="fourslash.ts" /> ////interface Foo { foo: string; bar: string; } ////type T = Pick<Foo, "[|/**/|]">; verify.completions({ marker: "", exact: [ { name: "foo", replacementSpan: test.ranges()[0] }, { name: "bar", replacementSpan: test.ranges()[0] } ] });
{ "end_byte": 283, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsStringLiteral_fromTypeConstraint.ts" }
TypeScript/tests/cases/fourslash/completionsGenericIndexedAccess3.ts_0_747
/// <reference path="fourslash.ts" /> ////interface CustomElements { //// 'component-one': { //// foo?: string; //// }, //// 'component-two': { //// bar?: string; //// } ////} //// ////interface Options<T extends keyof CustomElements> { //// props: CustomElements[T]; ////} //// ////declare function create<T extends keyof CustomElements>(name: T, options: Options<T>): void; //// ////create('component-one', { props: { /*1*/ } }); ////create('component-two', { props: { /*2*/ } }); verify.completions({ marker: "1", exact: [{ name: "foo", sortText: completion.SortText.OptionalMember }] }); verify.completions({ marker: "2", exact: [{ name: "bar", sortText: completion.SortText.OptionalMember }] });
{ "end_byte": 747, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsGenericIndexedAccess3.ts" }
TypeScript/tests/cases/fourslash/findAllRefs_importType_js.1.ts_0_348
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @Filename: /a.js ////module.exports = class /**/C {}; ////module.exports.D = class D {}; // @Filename: /b.js /////** @type {import("./a")} */ ////const x = 0; /////** @type {import("./a").D} */ ////const y = 0; verify.noErrors(); verify.baselineFindAllReferences("");
{ "end_byte": 348, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefs_importType_js.1.ts" }
TypeScript/tests/cases/fourslash/codefixInferFromUsageNullish.ts_0_208
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////declare const a: string ////function wat([|b |]) { //// b(a ?? 1); ////} verify.rangeAfterCodeFix("b: (arg0: string | number) => void");
{ "end_byte": 208, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codefixInferFromUsageNullish.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionDynamicImport1.ts_3_234
/ <reference path='fourslash.ts' /> // @Filename: foo.ts //// /*Destination*/export function foo() { return "foo"; } //// import([|"./f/*1*/oo"|]) //// var x = import([|"./fo/*2*/o"|]) verify.baselineGoToDefinition("1", "2");
{ "end_byte": 234, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionDynamicImport1.ts" }
TypeScript/tests/cases/fourslash/codeFixAddOptionalParam3.ts_0_315
/// <reference path="fourslash.ts" /> ////class C { //// private a = 1; //// //// [|m1() {}|] //// m2() { //// this.m1(this.a); //// } ////} verify.codeFix({ description: [ts.Diagnostics.Add_optional_parameter_to_0.message, "m1"], index: 1, newRangeContent: "m1(a?: number) {}" });
{ "end_byte": 315, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddOptionalParam3.ts" }
TypeScript/tests/cases/fourslash/extractFunctionContainingThis1.ts_0_651
/// <reference path='fourslash.ts' /> ////function test(this: string, foo: string) { //// /*start*/console.log(this); //// console.log(foo); /*end*/ ////} goTo.select("start", "end"); verify.refactorAvailable("Extract Symbol", "function_scope_0"); goTo.select("start", "end"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "function_scope_1", actionDescription: "Extract to function in global scope", newContent: `function test(this: string, foo: string) { /*RENAME*/newFunction.call(this, foo); } function newFunction(this: string, foo: string) { console.log(this); console.log(foo); } ` });
{ "end_byte": 651, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extractFunctionContainingThis1.ts" }
TypeScript/tests/cases/fourslash/completionCloneQuestionToken.ts_0_840
/// <reference path='fourslash.ts'/> // @Filename: /file2.ts //// type TCallback<T = any> = (options: T) => any; //// type InKeyOf<E> = { [K in keyof E]?: TCallback<E[K]>; }; //// export class Bar<A> { //// baz(a: InKeyOf<A>): void { } //// } // @Filename: /file1.ts //// import { Bar } from './file2'; //// type TwoKeys = Record<'a' | 'b', { thisFails?: any; }> //// class Foo extends Bar<TwoKeys> { //// /**/ //// } verify.completions({ marker: "", includes: { name: "baz", insertText: "baz(a: { a?: (options: { thisFails?: any; }) => any; b?: (options: { thisFails?: any; }) => any; }): void {\n}", filterText: "baz", }, isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithClassMemberSnippets: true, }, });
{ "end_byte": 840, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionCloneQuestionToken.ts" }
TypeScript/tests/cases/fourslash/quickInfoUnionOfNamespaces.ts_0_273
// See GH#18461 /// <reference path='fourslash.ts' /> ////declare const x: typeof A | typeof B; ////x./**/f; //// ////namespace A { //// export function f() {} ////} ////namespace B { //// export function f() {} ////} verify.quickInfoAt("", "(method) f(): void");
{ "end_byte": 273, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoUnionOfNamespaces.ts" }
TypeScript/tests/cases/fourslash/renameForDefaultExport05.ts_0_377
/// <reference path='fourslash.ts'/> // @Filename: foo.ts ////export default class DefaultExportedClass { ////} /////* //// * Commenting DefaultExportedClass //// */ //// ////var x: /**/[|DefaultExportedClass|]; //// ////var y = new DefaultExportedClass; goTo.marker(); verify.renameInfoSucceeded("DefaultExportedClass", '"/tests/cases/fourslash/foo".DefaultExportedClass');
{ "end_byte": 377, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameForDefaultExport05.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingAwait_condition.ts_0_558
/// <reference path="fourslash.ts" /> // @strictNullChecks: true ////async function fn(a: Promise<string[]>) { //// if (a) {}; //// a ? fn.call() : fn.call(); ////} verify.codeFix({ description: ts.Diagnostics.Add_await.message, index: 0, newFileContent: `async function fn(a: Promise<string[]>) { if (await a) {}; a ? fn.call() : fn.call(); }` }); verify.codeFix({ description: ts.Diagnostics.Add_await.message, index: 1, newFileContent: `async function fn(a: Promise<string[]>) { if (a) {}; await a ? fn.call() : fn.call(); }` });
{ "end_byte": 558, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAwait_condition.ts" }
TypeScript/tests/cases/fourslash/incompleteFunctionCallCodefixTypeParameterConstrained.ts_0_443
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////function existing<T extends string>(value: T) { //// added/*1*/(value); ////} goTo.marker("1"); verify.codeFix({ description: "Add missing function declaration 'added'", index: 0, newFileContent: `function existing<T extends string>(value: T) { added(value); } function added<T extends string>(value: T) { throw new Error("Function not implemented."); } `, });
{ "end_byte": 443, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incompleteFunctionCallCodefixTypeParameterConstrained.ts" }
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionTypeParameters.ts_0_476
/// <reference path='fourslash.ts' /> ////function foo<T, S>(/*a*/t: T, s: S/*b*/) { //// return s; ////} ////foo("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<T, S>({ t, s }: { t: T; s: S; }) { return s; } foo({ t: "a", s: "b" });` });
{ "end_byte": 476, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionTypeParameters.ts" }
TypeScript/tests/cases/fourslash/refactorExtractTypeRemoveGrammarError1.ts_0_357
/// <reference path='fourslash.ts' /> // @Filename: a.ts ////type Foo = /*a*/{ x: string = 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 = { x: string; }; type Foo = NewType`, });
{ "end_byte": 357, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractTypeRemoveGrammarError1.ts" }
TypeScript/tests/cases/fourslash/codeFixSpellingPropertyAccess.ts_0_305
/// <reference path='fourslash.ts' /> ////const foo = { //// bar: 1 ////} //// ////const bar = [|foo.#bar|]; verify.codeFixAvailable([ { description: "Change spelling to 'bar'" }, ]); verify.codeFix({ index: 0, description: "Change spelling to 'bar'", newRangeContent: "foo.bar" });
{ "end_byte": 305, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingPropertyAccess.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingNew_all_arguments.ts_0_514
/// <reference path='fourslash.ts' /> ////class C<T = number> { //// x?: T; //// constructor(x: T) { this.x = x; } ////} ////let a = C(1, 2, 3); ////let b = C<string>("hello"); ////let c = C<boolean>(); verify.codeFixAll({ fixId: "addMissingNewOperator", fixAllDescription: "Add missing 'new' operator to all calls", newFileContent: `class C<T = number> { x?: T; constructor(x: T) { this.x = x; } } let a = new C(1, 2, 3); let b = new C<string>("hello"); let c = new C<boolean>();` });
{ "end_byte": 514, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingNew_all_arguments.ts" }
TypeScript/tests/cases/fourslash/formattingElseInsideAFunction.ts_0_304
/// <reference path='fourslash.ts' /> ////var x = function() { //// if (true) { //// /*1*/} else {/*2*/ ////} //// ////// newline at the end of the file goTo.marker("2"); edit.insertLine(""); goTo.marker("1"); // else formating should not be affected verify.currentLineContentIs(' } else {');
{ "end_byte": 304, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingElseInsideAFunction.ts" }
TypeScript/tests/cases/fourslash/jsDocAugments.ts_0_417
///<reference path="fourslash.ts" /> // @allowJs: true // @Filename: dummy.js //// /** //// * @augments {Thing<string>} //// */ //// class MyStringThing extends Thing { //// constructor() { //// var x = this.mine; //// x/**/; //// } //// } // @Filename: declarations.d.ts //// declare class Thing<T> { //// mine: T; //// } goTo.marker(); verify.quickInfoIs("(local var) x: string");
{ "end_byte": 417, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocAugments.ts" }
TypeScript/tests/cases/fourslash/jsdocDeprecated_suggestion12.ts_0_420
///<reference path="fourslash.ts" /> // @filename: foo.ts /////** //// * @deprecated //// */ ////function foo() {}; ////function bar(fn: () => void) { //// fn(); ////} ////bar([|foo|]); goTo.file('foo.ts'); const ranges = test.ranges(); verify.getSuggestionDiagnostics([ { "code": 6385, "message": "'foo' is deprecated.", "reportsDeprecated": true, "range": ranges[0] }, ]);
{ "end_byte": 420, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocDeprecated_suggestion12.ts" }
TypeScript/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf2.ts_0_743
/// <reference path='fourslash.ts' /> ////interface MultiRobot { //// name: string; //// skills: { //// [|[|{| "contextRangeIndex": 0 |}primary|]: string;|] //// secondary: string; //// }; ////} ////let multiRobots: MultiRobot[], [|[|{| "contextRangeIndex": 2 |}primary|]: string|]; ////for ([|{ skills: { [|{| "contextRangeIndex": 4 |}primary|]: primaryA, secondary: secondaryA } } of multiRobots|]) { //// console.log(primaryA); ////} ////for ([|{ skills: { [|{| "contextRangeIndex": 6 |}primary|], secondary } } of multiRobots|]) { //// console.log([|primary|]); ////} const ranges = test.ranges(); const [r0Def, r0, r1Def, r1,r2Def, r2, r3Def, r3, r4] = ranges; verify.baselineRename([r0, r2, r1, r3, r4]);
{ "end_byte": 743, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf2.ts" }
TypeScript/tests/cases/fourslash/autoImportPackageJsonImportsLength1.ts_0_356
/// <reference path="fourslash.ts" /> // @module: nodenext // @Filename: /package.json //// { //// "imports": { //// "#*": "./src/*.ts" //// } //// } // @Filename: /src/a/b/c/something.ts //// export function something(name: string): any; // @Filename: /src/a/b/c/d.ts //// something/**/ verify.importFixModuleSpecifiers("", ["./something"]);
{ "end_byte": 356, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPackageJsonImportsLength1.ts" }
TypeScript/tests/cases/fourslash/findAllRefsOnImportAliases.ts_0_291
/// <reference path="fourslash.ts" /> //@Filename: a.ts ////export class /*0*/Class { ////} //@Filename: b.ts ////import { /*1*/Class } from "./a"; //// ////var c = new /*2*/Class(); //@Filename: c.ts ////export { /*3*/Class } from "./a"; verify.baselineFindAllReferences('0', '1', '2')
{ "end_byte": 291, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsOnImportAliases.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageLiteralTypes.ts_0_256
/// <reference path='fourslash.ts' /> // @noImplicitAny: true //// function foo([|a, m |]) { //// a = 'hi' //// m = 1 //// } verify.rangeAfterCodeFix("a: string, m: number", /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, /*index*/0);
{ "end_byte": 256, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageLiteralTypes.ts" }
TypeScript/tests/cases/fourslash/functionRenamingErrorRecovery.ts_0_248
/// <reference path="fourslash.ts" /> ////class Foo { public bar/*1*//*2*/() { } } goTo.marker("1"); edit.backspace(3); edit.insert("Pizza"); verify.currentLineContentIs("class Foo { public Pizza() { } }"); verify.not.errorExistsAfterMarker("2");
{ "end_byte": 248, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/functionRenamingErrorRecovery.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics24.ts_0_354
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: a.js //// function Person(age) { //// if (age >= 18) { //// this.canVote = true; //// } else { //// this.canVote = 23; //// } //// } //// let x = new Person(100); //// x.canVote/**/; verify.quickInfoAt("", "(property) Person.canVote: number | boolean");
{ "end_byte": 354, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics24.ts" }
TypeScript/tests/cases/fourslash/codeFixCalledES2015Import7.ts_0_421
/// <reference path='fourslash.ts' /> // @esModuleInterop: true // @Filename: foo.d.ts ////declare class foo(): void; ////declare namespace foo {} ////export = foo; // @Filename: index.ts ////[|import * as foo from "./foo";|] ////new foo(); goTo.file(1); verify.codeFix({ description: `Replace import with 'import foo = require("./foo");'.`, newRangeContent: `import foo = require("./foo");`, index: 1, });
{ "end_byte": 421, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCalledES2015Import7.ts" }
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateParenthFromExpr.ts_0_388
/// <reference path='fourslash.ts' /> //// const foo = "foobar is " + (/*x*/42/*y*/ + 6) + " years old" goTo.select("x", "y"); edit.applyRefactor({ refactorName: "Convert to template string", actionName: "Convert to template string", actionDescription: ts.Diagnostics.Convert_to_template_string.message, newContent: `const foo = \`foobar is \${42 + 6} years old\``, });
{ "end_byte": 388, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateParenthFromExpr.ts" }
TypeScript/tests/cases/fourslash/completionListInImportClause04.ts_0_506
/// <reference path='fourslash.ts' /> // @Filename: foo.d.ts //// declare class Foo { //// static prop1(x: number): number; //// static prop1(x: string): string; //// static prop2(x: boolean): boolean; //// } //// export = Foo; /*2*/ // @Filename: app.ts ////import {/*1*/} from './foo'; verify.completions({ marker: "1", unsorted: ["prototype", "prop1", "prop2", { name: "type", sortText: completion.SortText.GlobalsOrKeywords }] }); verify.noErrors(); goTo.marker('2'); verify.noErrors();
{ "end_byte": 506, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInImportClause04.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_moveJsxImport3.ts_0_391
/// <reference path='fourslash.ts' /> // @jsx: preserve // @noLib: true // @libFiles: react.d.ts,lib.d.ts // @Filename: file.tsx //// import React = require('react'); //// [|1;|] //// <div/>; verify.moveToNewFile({ newFileContents: { "/tests/cases/fourslash/file.tsx": `import React = require('react'); <div/>;`, "/tests/cases/fourslash/newFile.tsx": `1; `, } });
{ "end_byte": 391, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_moveJsxImport3.ts" }