_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/tsxFindAllReferences8.ts_0_1294
/// <reference path='fourslash.ts' /> //@Filename: file.tsx // @jsx: preserve // @noLib: true //// declare module JSX { //// interface Element { } //// interface IntrinsicElements { //// } //// interface ElementAttributesProperty { props; } //// } //// interface ClickableProps { //// children?: string; //// className?: string; //// } //// interface ButtonProps extends ClickableProps { //// onClick(event?: React.MouseEvent<HTMLButtonElement>): void; //// } //// interface LinkProps extends ClickableProps { //// goTo: string; //// } //// /*1*/declare function /*2*/MainButton(buttonProps: ButtonProps): JSX.Element; //// /*3*/declare function /*4*/MainButton(linkProps: LinkProps): JSX.Element; //// /*5*/declare function /*6*/MainButton(props: ButtonProps | LinkProps): JSX.Element; //// let opt = /*7*/</*8*/MainButton />; //// let opt = /*9*/</*10*/MainButton children="chidlren" />; //// let opt = /*11*/</*12*/MainButton onClick={()=>{}} />; //// let opt = /*13*/</*14*/MainButton onClick={()=>{}} ignore-prop />; //// let opt = /*15*/</*16*/MainButton goTo="goTo" />; //// let opt = /*17*/</*18*/MainButton wrong />; verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18');
{ "end_byte": 1294, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxFindAllReferences8.ts" }
TypeScript/tests/cases/fourslash/completionListInUnclosedTaggedTemplate01.ts_0_176
/// <reference path='fourslash.ts' /> ////var x; ////var y = (p) => x `abc ${ /*1*/ verify.completions({ marker: "1", includes: ["p", "x"], isNewIdentifierLocation: true });
{ "end_byte": 176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedTaggedTemplate01.ts" }
TypeScript/tests/cases/fourslash/completionListInFatArrow.ts_0_211
/// <reference path='fourslash.ts' /> ////var items = [0, 1, 2]; ////items.forEach((n) => { //// /**/ //// var q = n; ////}); goTo.marker(); edit.insert('it'); verify.completions({ includes: "items" });
{ "end_byte": 211, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInFatArrow.ts" }
TypeScript/tests/cases/fourslash/completionOfAwaitPromise1.ts_0_375
/// <reference path='fourslash.ts'/> //// async function foo(x: Promise<string>) { //// [|x./**/|] //// } const replacementSpan = test.ranges()[0] verify.completions({ marker: "", includes: [ "then", { name: "trim", insertText: '(await x).trim', replacementSpan }, ], preferences: { includeInsertTextCompletions: true, }, });
{ "end_byte": 375, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionOfAwaitPromise1.ts" }
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToNamed_MultiLine.ts_0_405
/// <reference path='fourslash.ts' /> //// let foo = /*x*/a/*y*/ => { //// let b = 1; //// return a + b; //// }; goTo.select("x", "y"); edit.applyRefactor({ refactorName: "Convert arrow function or function expression", actionName: "Convert to named function", actionDescription: "Convert to named function", newContent: `function foo(a) { let b = 1; return a + b; }`, });
{ "end_byte": 405, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToNamed_MultiLine.ts" }
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization.ts_0_1406
/// <reference path='fourslash.ts' /> // @strict: true //// abstract class A { abstract a (); } //// //// class TT { constructor () {} } //// //// class AT extends A { a () {} } //// //// class Foo {} //// //// class T { //// //// a: boolean; //// //// static b: boolean; //// //// private c: boolean; //// //// d: number | undefined; //// //// e: string | boolean; //// //// f: 1; //// //// g: "123" | "456"; //// //// h: boolean; //// //// i: TT; //// //// j: A; //// //// k: AT; //// //// l: Foo; //// } function fixes(name: string, type: string, options: { isPrivate?: boolean, noInitializer?: boolean } = {}) { return [ `Add 'undefined' type to property '${name}'`, `Add definite assignment assertion to property '${options.isPrivate ? "private " : ""}${name}: ${type};'`, ...(options.noInitializer ? [] : [`Add initializer to property '${name}'`]), ].map(description => ({ description })); } verify.codeFixAvailable([ ...fixes("a", "boolean"), ...fixes("c", "boolean", { isPrivate: true }), ...fixes("e", "string | boolean"), ...fixes("f", "1"), ...fixes("g", '"123" | "456"'), ...fixes("h", "boolean"), ...fixes("i", "TT"), ...fixes("j", "A", { noInitializer: true }), ...fixes("k", "AT"), ...fixes("l", "Foo"), { description: "Remove unused declaration for: 'c'" }, ]);
{ "end_byte": 1406, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization.ts" }
TypeScript/tests/cases/fourslash/codeFixAddVoidToPromiseJS.5.ts_0_314
/// <reference path='fourslash.ts' /> // @target: esnext // @lib: es2015 // @strict: true // @allowJS: true // @checkJS: true // @filename: main.js /////** @type {Promise<number>} */ ////const p2 = new Promise(resolve => resolve()); verify.not.codeFixAvailable("Add 'void' to Promise resolved without a value");
{ "end_byte": 314, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddVoidToPromiseJS.5.ts" }
TypeScript/tests/cases/fourslash/completionListAndMemberListOnCommentedLine.ts_0_114
/// <reference path='fourslash.ts' /> ////// /**/ ////var verify.completions({ marker: "", exact: undefined });
{ "end_byte": 114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAndMemberListOnCommentedLine.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationConst.ts_0_636
/// <reference path='fourslash.ts' /> // @BaselineFile: bpSpan_const.baseline // @Filename: bpSpan_const.ts ////const c1 = false; ////const c2: number = 23; ////const c3 = 0, c4 :string = "", c5 = null; ////for(const c4 = 0; c4 < 9; ) { break; } ////for(const c5 = 0, c6 = 0; c5 < c6; ) { break; } ////module M { //// export const cc1 = false; //// export const cc2: number = 23; //// export const cc3 = 0, cc4 :string = "", cc5 = null; ////} ////const enum E { //// A = 1, //// B = 2, //// C = A | B ////} ////const enum E2 { //// A = 1, //// B, //// C ////} verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 636, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationConst.ts" }
TypeScript/tests/cases/fourslash/formatOnEnterOpenBraceAddNewLine.ts_0_355
/// <reference path="fourslash.ts"/> //// if(true) {/*0*/} //// if(false)/*1*/{ //// } format.setOption("PlaceOpenBraceOnNewLineForControlBlocks", true); goTo.marker("0"); edit.insertLine(""); verify.currentFileContentIs( `if (true) { } if(false){ }`); goTo.marker("1"); edit.insertLine(""); verify.currentFileContentIs( `if (true) { } if (false) { }`);
{ "end_byte": 355, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatOnEnterOpenBraceAddNewLine.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_UnknownSymbol.ts_0_157
/// <reference path='fourslash.ts' /> /////*a*/foo && foo.bar;/*b*/ goTo.select("a", "b"); verify.refactorAvailable("Convert to optional chain expression")
{ "end_byte": 157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_UnknownSymbol.ts" }
TypeScript/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion3.ts_0_3126
/// <reference path="fourslash.ts"/> // @allowNonTsExtensions: true // @Filename: jsFileJsdocTypedefTagTypeExpressionCompletion3_typedef.js //// /** //// * @typedef {{ age: number }} Foo.Namespace.SomeType //// */ //// class Foo { //// constructor(value) { this.property1 = "hello"; } //// static method1() {} //// method3() { return 3; } //// /** //// * @param {string} foo A value. //// * @returns {number} Another value //// * @mytag //// */ //// method4(foo) { return 3; } //// } //// /** //// * @type { /*type1*/Foo./*typeFooMember*/Namespace./*NamespaceMember*/SomeType } //// */ ////var x; /////*globalValue*/ ////x./*valueMemberOfSomeType*/ //// /** //// * @type { /*type2*/Foo } //// */ ////var x1; ////x1./*valueMemberOfFooInstance*/; ////Foo./*valueMemberOfFoo*/; const warnings = (names: ReadonlyArray<string>): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> => names.map(name => ({ name, kind: "warning", sortText: completion.SortText.JavascriptIdentifiers })); verify.completions( { marker: ["type1", "type2"], includes: [ { name: "Foo", kind: "class" }, ...warnings(["Namespace", "SomeType", "x", "x1", "method1", "property1", "method3", "method4", "foo"]), ], }, { marker: "typeFooMember", unsorted: [ { name: "Namespace", kind: "module", kindModifiers: "export" }, ...warnings(["Foo", "value", "property1", "method1", "method3", "method4", "foo", "age", "SomeType", "x", "x1"]), ], }, { marker: "NamespaceMember", unsorted: [ { name: "SomeType", kind: "type" }, ...warnings(["Foo", "value", "property1", "method1", "method3", "method4", "foo", "age", "Namespace", "x", "x1"]), ], }, { marker: "globalValue", includes: [ { name: "Foo", kind: "class" }, { name: "x", kind: "var" }, { name: "x1", kind: "var" }, ...warnings(["Namespace", "SomeType", "method1", "property1", "method3", "method4", "foo"]), ], }, { marker: "valueMemberOfSomeType", unsorted: [ { name: "age", kind: "property" }, ...warnings(["Foo", "value", "property1", "method1", "method3", "method4", "foo", "Namespace", "SomeType", "x", "x1"]), ], }, { marker: "valueMemberOfFooInstance", unsorted: [ { name: "property1", kind: "property" }, { name: "method3", kind: "method" }, { name: "method4", kind: "method" }, ...warnings(["Foo", "value", "method1", "foo", "age", "Namespace", "SomeType", "x", "x1"]), ], }, { marker: "valueMemberOfFoo", unsorted: [ { name: "prototype", kind: "property" }, { name: "method1", kind: "method", kindModifiers: "static" }, ...completion.functionMembers, ...warnings(["Foo", "value", "property1", "method3", "method4", "foo", "age", "Namespace", "SomeType", "x", "x1"]), ], }, );
{ "end_byte": 3126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion3.ts" }
TypeScript/tests/cases/fourslash/formattingOfChainedLambda.ts_0_216
/// <reference path="fourslash.ts"/> //// var fn = (x: string) => ()=> alert(x)/**/ goTo.marker(); edit.insert(";"); verify.currentLineContentIs("var fn = (x: string) => () => alert(x);"); // Space added after '()'
{ "end_byte": 216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOfChainedLambda.ts" }
TypeScript/tests/cases/fourslash/funduleWithRecursiveReference.ts_0_223
/// <reference path='fourslash.ts'/> ////module M { //// export function C() {} //// export module C { //// export var /**/C = M.C //// } ////} verify.quickInfoAt("", "var M.C.C: typeof M.C"); verify.noErrors();
{ "end_byte": 223, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/funduleWithRecursiveReference.ts" }
TypeScript/tests/cases/fourslash/extract-method18.ts_0_578
/// <reference path='fourslash.ts' /> // Don't try to propagate property accessed variables back, // or emit spurious returns when the value is clearly ignored //// function fn() { //// const x = { m: 1 }; //// /*a*/x.m = 3/*b*/; //// } goTo.select('a', 'b') edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "function_scope_1", actionDescription: "Extract to function in global scope", newContent: `function fn() { const x = { m: 1 }; /*RENAME*/newFunction(x); } function newFunction(x: { m: number; }) { x.m = 3; } ` });
{ "end_byte": 578, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method18.ts" }
TypeScript/tests/cases/fourslash/completionsImport_compilerOptionsModule.ts_0_1145
/// <reference path="fourslash.ts" /> // @allowJs: true // @module: commonjs // @Filename: /node_modules/a/index.d.ts ////export const foo = 0; // @Filename: /b.js ////const a = require("./a"); ////fo/*b*/ // @Filename: /c.js ////const x = 0;/*c*/ // @Filename: /c1.js ////// @ts-check ////const x = 0;/*ccheck*/ // @Filename: /c2.ts ////const x = 0;/*cts*/ // @Filename: /d.js ////const a = import("./a"); // Does not make this an external module ////fo/*d*/ // @Filename: /d1.js ////// @ts-check ////const a = import("./a"); // Does not make this an external module ////fo/*dcheck*/ // @Filename: /d2.ts ////const a = import("./a"); // Does not make this an external module ////fo/*dts*/ verify.completions({ marker: ["b", "c", "ccheck", "cts", "d", "dcheck", "dts"], includes: [{ name: "foo", source: "/node_modules/a/index", text: "const foo: 0", kind: "const", kindModifiers: "export,declare", hasAction: true, sourceDisplay: "a", sortText: completion.SortText.AutoImportSuggestions }], preferences: { includeCompletionsForModuleExports: true }, });
{ "end_byte": 1145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_compilerOptionsModule.ts" }
TypeScript/tests/cases/fourslash/extract-unterminated4.ts_0_409
/// <reference path="fourslash.ts" /> // Unterminated template literal: //// /*1*/const foo = /endsinbackslash\/*2*/ goTo.select("1", "2"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "function_scope_0", actionDescription: "Extract to function in global scope", newContent: `const foo = /*RENAME*/newFunction() function newFunction() { return /endsinbackslash\\ /; } ` });
{ "end_byte": 409, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-unterminated4.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType_js1.ts_0_410
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: a.js //// /** @type { /*a*/string/*b*/ } */ //// var x; goTo.file('a.js') goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to typedef", actionDescription: "Extract to typedef", newContent: `/** * @typedef {string} /*RENAME*/NewType */ /** @type { NewType } */ var x;`, });
{ "end_byte": 410, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType_js1.ts" }
TypeScript/tests/cases/fourslash/completionsOverridingMethod22.ts_0_1536
/// <reference path="fourslash.ts" /> // Bug #57333 // @newline: LF // @Filename: b.ts //// export type C = { x: number } //// export interface ExtShape { //// $returnPromise(id: number): Promise<C>; //// $return(id: number): C; //// } // @Filename: test.ts //// import { ExtShape } from './b'; //// abstract class ExtBase implements ExtShape { //// public $/**/ //// } verify.completions({ marker: "", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, includes: [ { name: "$returnPromise", sortText: completion.SortText.LocationPriority, insertText: "public \\$returnPromise(id: number): Promise<C> {\n}", filterText: "$returnPromise", replacementSpan: undefined, hasAction: true, source: completion.CompletionSource.ClassMemberSnippet, } ] }); verify.applyCodeActionFromCompletion("", { preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, name: "$returnPromise", source: completion.CompletionSource.ClassMemberSnippet, description: "Includes imports of types referenced by '$returnPromise'", newFileContent: `import { C, ExtShape } from './b'; abstract class ExtBase implements ExtShape { $ }` });
{ "end_byte": 1536, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingMethod22.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts_0_156
/// <reference path='fourslash.ts' /> ////const { /*1*/x, y } = { /*2*/x: 1, y: 2 }; ////const z = /*3*/x; verify.baselineFindAllReferences('1', '2', '3')
{ "end_byte": 156, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts" }
TypeScript/tests/cases/fourslash/unusedVariableInModule3.ts_0_292
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @noUnusedParameters: true //// export {} //// [|var x = function f1() {} //// export var y: string;|] verify.codeFix({ description: "Remove unused declaration for: 'x'", newRangeContent: "export var y: string;", });
{ "end_byte": 292, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedVariableInModule3.ts" }
TypeScript/tests/cases/fourslash/quickInfoJSDocFunctionNew.ts_0_224
///<reference path="fourslash.ts" /> // @allowJs: true // @Filename: Foo.js /////** @type {function (new: string, string): string} */ ////var f/**/; goTo.marker(); verify.quickInfoIs('var f: new (arg1: string) => string');
{ "end_byte": 224, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJSDocFunctionNew.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesIsDefinitionOfClass.ts_0_222
/// <reference path='fourslash.ts' /> /////*1*/class /*2*/C { //// n: number; //// constructor() { //// this.n = 12; //// } ////} ////let c = new /*3*/C(); verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 222, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesIsDefinitionOfClass.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesSuperNegatives.ts_0_387
/// <reference path='fourslash.ts' /> ////function f(x = [|super|]) { //// [|super|]; ////} //// ////module M { //// [|super|]; //// function f(x = [|super|]) { //// [|super|]; //// } //// //// class A { //// } //// //// class B extends A { //// constructor() { //// super(); //// } //// } ////} verify.baselineDocumentHighlights();
{ "end_byte": 387, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesSuperNegatives.ts" }
TypeScript/tests/cases/fourslash/completionForObjectProperty.ts_0_2362
/// <reference path="fourslash.ts" /> // @Filename: /a.ts //// export const foo = { bar: 'baz' }; // @Filename: /b.ts //// const test = foo/*1*/ // @Filename: /c.ts //// const test2 = {...foo/*2*/} // @Filename: /d.ts //// const test3 = [{...foo/*3*/}] // @Filename: /e.ts //// const test4 = { foo/*4*/ } // @Filename: /f.ts //// const test5 = { foo: /*5*/ } // @Filename: /g.ts //// const test6 = { unrelated: foo/*6*/ } // @Filename: /i.ts //// const test7: { foo/*7*/: "unrelated" } // @Filename: /h.ts //// const test8: { foo: string } = { foo/*8*/ } verify.completions({ marker: "1", includes: { name: "foo", source: "/a", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, isNewIdentifierLocation: true, preferences: { includeCompletionsForModuleExports: true } }, { marker: "2", includes: { name: "foo", source: "/a", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, isNewIdentifierLocation: false, preferences: { includeCompletionsForModuleExports: true } }, { marker: "3", includes: { name: "foo", source: "/a", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, isNewIdentifierLocation: false, preferences: { includeCompletionsForModuleExports: true } }, { marker: "4", includes: { name: "foo", source: "/a", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, isNewIdentifierLocation: true, preferences: { includeCompletionsForModuleExports: true } }, { marker: "5", includes: { name: "foo", source: "/a", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, isNewIdentifierLocation: false, preferences: { includeCompletionsForModuleExports: true } }, { marker: "6", includes: { name: "foo", source: "/a", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, isNewIdentifierLocation: false, preferences: { includeCompletionsForModuleExports: true } }, { marker: "7", excludes: "foo", isNewIdentifierLocation: true, preferences: { includeCompletionsForModuleExports: true } }, { marker: "8", includes: { name: "foo", sortText: completion.SortText.LocationPriority }, isNewIdentifierLocation: false, preferences: { includeCompletionsForModuleExports: true } });
{ "end_byte": 2362, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForObjectProperty.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType3.ts_0_358
/// <reference path='fourslash.ts' /> //// var x: /*a*/string | number | boolean/*b*/ = ''; goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to type alias", actionDescription: "Extract to type alias", newContent: `type /*RENAME*/NewType = string | number | boolean; var x: NewType = '';`, });
{ "end_byte": 358, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType3.ts" }
TypeScript/tests/cases/fourslash/formatOnSemiColonAfterBreak.ts_0_212
/// <reference path='fourslash.ts' /> ////for (var a in b) { ////break/**/ ////} goTo.marker(); edit.insert(";"); // Adding smicolon should format the break statement verify.currentLineContentIs(' break;');
{ "end_byte": 212, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatOnSemiColonAfterBreak.ts" }
TypeScript/tests/cases/fourslash/removeExportedClassFromReopenedModule.ts_0_288
/// <reference path="fourslash.ts" /> //// module multiM { } //// //// module multiM { //// /*1*/export class c { } //// } //// goTo.marker('1'); edit.deleteAtCaret('export class c { }'.length); goTo.eof(); edit.insert("new multiM.c();"); verify.numberOfErrorsInCurrentFile(1);
{ "end_byte": 288, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/removeExportedClassFromReopenedModule.ts" }
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_importedFunction5.ts_0_741
/// <reference path='fourslash.ts' /> // @Filename: f.ts ////export class C { //// /*a*/constructor/*b*/(a: number, b: number) { } ////} // @Filename: a.ts ////import f = require("./f"); ////const c = new f.C(1, 2); ////const c1 = new f["C"](1, 2); 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: `export class C { constructor({ a, b }: { a: number; b: number; }) { } }` }); goTo.file("a.ts"); verify.currentFileContentIs(`import f = require("./f"); const c = new f.C({ a: 1, b: 2 }); const c1 = new f["C"]({ a: 1, b: 2 });`)
{ "end_byte": 741, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_importedFunction5.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess32.ts_0_609
/// <reference path='fourslash.ts' /> //// /** Class comment */ //// class A { //// // Field comment //// public /*a*/a/*b*/: number = 1; //// } goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Generate 'get' and 'set' accessors", actionName: "Generate 'get' and 'set' accessors", actionDescription: "Generate 'get' and 'set' accessors", newContent: `/** Class comment */ class A { // Field comment private /*RENAME*/_a: number = 1; public get a(): number { return this._a; } public set a(value: number) { this._a = value; } }`, });
{ "end_byte": 609, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess32.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType40.ts_0_165
/// <reference path='fourslash.ts' /> //// type A = (v: string | number) => /*a*/typeof v/*b*/ goTo.select("a", "b"); verify.not.refactorAvailable("Extract type")
{ "end_byte": 165, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType40.ts" }
TypeScript/tests/cases/fourslash/codeFixConvertToMappedObjectType13.ts_0_145
/// <reference path='fourslash.ts' /> ////let x: { //// [p: ""]: string; ////} verify.not.codeFixAvailable("fixConvertToMappedObjectType");
{ "end_byte": 145, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToMappedObjectType13.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageCallbackParameter3.ts_0_486
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @noImplicitAny: false // @filename: /foo.js ////function foo(names) { //// return names.filter(function (name) { //// return name === "foo"; //// }); ////} verify.codeFix({ description: "Infer parameter types from usage", index: 1, newFileContent: `function foo(names) { return names.filter(function (/** @type {string} */ name) { return name === "foo"; }); }` });
{ "end_byte": 486, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageCallbackParameter3.ts" }
TypeScript/tests/cases/fourslash/navigationBarItemsClass1.ts_0_772
/// <reference path="fourslash.ts" /> ////function Foo() {} ////class Foo {} verify.navigationTree({ text: "<global>", kind: "script", childItems: [ { text: "Foo", kind: "function" }, { text: "Foo", kind: "class" } ] }); verify.navigationBar([ { text: "<global>", kind: "script", childItems: [ { text: "Foo", kind: "function" }, { text: "Foo", kind: "class" } ] }, { text: "Foo", kind: "function", indent: 1 }, { text: "Foo", kind: "class", indent: 1 } ]);
{ "end_byte": 772, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsClass1.ts" }
TypeScript/tests/cases/fourslash/codeFixOverrideModifier4.ts_0_379
/// <reference path='fourslash.ts' /> // @noImplicitOverride: true //// class B { //// foo (v: string) {} //// fooo (v: string) {} //// } //// class D extends B { //// override foo (v: string) {} //// [|override bar(v: string) {}|] //// } verify.codeFix({ description: "Remove 'override' modifier", newRangeContent: "bar(v: string) {}", index: 0 })
{ "end_byte": 379, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixOverrideModifier4.ts" }
TypeScript/tests/cases/fourslash/signatureHelpImplicitConstructor.ts_0_261
/// <reference path='fourslash.ts' /> ////class ImplicitConstructor { ////} ////var implicitConstructor = new ImplicitConstructor(/**/); verify.signatureHelp({ marker: "", text: "ImplicitConstructor(): ImplicitConstructor", parameterCount: 0, });
{ "end_byte": 261, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpImplicitConstructor.ts" }
TypeScript/tests/cases/fourslash/completionListForGenericInstance1.ts_0_270
/// <reference path='fourslash.ts'/> ////interface Iterator<T, U> { //// (value: T, index: any, list: any): U ////} ////var i: Iterator<string, number>; ////i/**/ verify.completions({ marker: "", includes: { name: "i", text: "var i: Iterator<string, number>" } });
{ "end_byte": 270, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListForGenericInstance1.ts" }
TypeScript/tests/cases/fourslash/extract-const-callback-function-generic.ts_0_449
/// <reference path='fourslash.ts' /> ////declare function fnUnion(fn: <T>(a: T) => T): void ////fnUnion(/*a*/a => a/*b*/); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "constant_scope_0", actionDescription: "Extract to constant in enclosing scope", newContent: `declare function fnUnion(fn: <T>(a: T) => T): void const newLocal: <T>(a: T) => T = a => a; fnUnion(/*RENAME*/newLocal);` });
{ "end_byte": 449, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const-callback-function-generic.ts" }
TypeScript/tests/cases/fourslash/quickInfoNarrowedTypeOfAliasSymbol.ts_0_435
/// <reference path='fourslash.ts' /> // @strict: true // @Filename: modules.ts //// export declare const someEnv: string | undefined; // @Filename: app.ts //// import { someEnv } from "./modules"; //// declare function isString(v: any): v is string; //// //// if (isString(someEnv)) { //// someEnv/*1*/.charAt(0); //// } goTo.file("app.ts"); goTo.marker("1"); verify.quickInfoIs(`(alias) const someEnv: string\nimport someEnv`);
{ "end_byte": 435, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoNarrowedTypeOfAliasSymbol.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsagePropertyAccess.ts_0_412
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////function foo([|a, m, x |]) { //// a.b.c; //// //// var numeric = 0; //// numeric = m.n(); //// //// x.y.z //// x.y.z.push(0); //// return x.y.z ////} verify.rangeAfterCodeFix("a: { b: { c: any; }; }, m: { n: () => number; }, x: { y: { z: number[]; }; }", /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, /*index*/0);
{ "end_byte": 412, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsagePropertyAccess.ts" }
TypeScript/tests/cases/fourslash/completionWritingSpreadLikeArgument.ts_0_644
/// <reference path='fourslash.ts'/> ////const t0 = { //// x: function (./*0*/) {} ////} ////const t1 = { //// x: (./*1*/) => {} ////} ////const t2 = { //// x: function foo(./*2*/) => {} ////} ////const t3 = { //// x(./*3*/) {} ////} //// ////const t4 = function (./*4*/) {} ////const t5 = (./*5*/) => {} ////function t6(./*6*/) {} //// ////class Foo { //// m(./*7*/) {} ////} for (const marker of test.markers()) { goTo.marker(marker); verify.completions({ exact: undefined }); edit.insert("."); verify.completions({ exact: undefined }); edit.insert("."); verify.completions({ exact: undefined }); }
{ "end_byte": 644, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionWritingSpreadLikeArgument.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType11.ts_0_482
/// <reference path='fourslash.ts' /> //// function foo(a: number, b?: number, ...c: number[]): boolean { //// return false as /*a*/boolean/*b*/; //// } goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to type alias", actionDescription: "Extract to type alias", newContent: `function foo(a: number, b?: number, ...c: number[]): boolean { type /*RENAME*/NewType = boolean; return false as NewType; }`, });
{ "end_byte": 482, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType11.ts" }
TypeScript/tests/cases/fourslash/completionsLiteralDirectlyInRestConstrainedToArrayType.ts_0_327
/// <reference path="fourslash.ts" /> // @strict: true //// //// function fn<T extends ('value1' | 'value2' | 'value3')[]>(...values: T): T { return values; } //// //// const value1 = fn('/*1*/'); //// const value2 = fn('value1', '/*2*/'); verify.completions({ marker: ["1", "2"], includes: [`value1`, `value2`, `value3`] })
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsLiteralDirectlyInRestConstrainedToArrayType.ts" }
TypeScript/tests/cases/fourslash/docCommentTemplateReturnsTag1.ts_0_718
/// <reference path='fourslash.ts' /> /////*0*/ ////function f1() {} /////*1*/ ////function f2() { //// return 1; ////} /////*2*/ ////const f3 = () => 1; /////*3*/ ////const f3 = () => { //// return 1; ////} ////class Foo { //// /*4*/ //// m1() {} //// //// /*5*/ //// m2() { //// return 1; //// } ////} verify.docCommentTemplateAt("0", 3, "/** */"); verify.docCommentTemplateAt("1", 7, `/** * * @returns */`); verify.docCommentTemplateAt("2", 7, `/** * * @returns */`); verify.docCommentTemplateAt("3", 7, `/** * * @returns */`); verify.docCommentTemplateAt("4", 3, "/** */"); verify.docCommentTemplateAt("5", 11, `/** * * @returns */`);
{ "end_byte": 718, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateReturnsTag1.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesOfDecorators.ts_0_240
/// <reference path='fourslash.ts' /> // @Filename: b.ts ////@/*1*/decorator ////class C { //// @decorator //// method() {} ////} ////function decorator(target) { //// return target; ////} verify.baselineDocumentHighlights("1");
{ "end_byte": 240, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesOfDecorators.ts" }
TypeScript/tests/cases/fourslash/formatNoSpaceBeforeCloseBrace6.ts_0_158
/// <reference path="fourslash.ts"/> ////new Foo(1, /* comment */ //// ); format.document(); verify.currentFileContentIs(`new Foo(1, /* comment */ );`);
{ "end_byte": 158, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatNoSpaceBeforeCloseBrace6.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType87.ts_0_403
/// <reference path='fourslash.ts' /> //// type A = /*1*/{ a: string } | { b: string } |/*2*/ { c: string }; goTo.select("1", "2"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to type alias", actionDescription: "Extract to type alias", newContent: `type /*RENAME*/NewType = { a: string; } | { b: string; }; type A = NewType | { c: string };`, });
{ "end_byte": 403, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType87.ts" }
TypeScript/tests/cases/fourslash/whiteSpaceBeforeReturnTypeFormatting.ts_0_157
/// <reference path='fourslash.ts' /> //// var x: () => string/**/ goTo.marker(); edit.insert(';'); verify.currentLineContentIs("var x: () => string;");
{ "end_byte": 157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/whiteSpaceBeforeReturnTypeFormatting.ts" }
TypeScript/tests/cases/fourslash/tsxCompletion1.ts_0_309
/// <reference path='fourslash.ts' /> //@Filename: file.tsx //// declare module JSX { //// interface Element { } //// interface IntrinsicElements { //// div: { ONE: string; TWO: number; } //// } //// } //// var x = <div /**//>; verify.completions({ marker: "", exact: ["ONE", "TWO"] });
{ "end_byte": 309, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletion1.ts" }
TypeScript/tests/cases/fourslash/goToImplementationLocal_00.ts_0_210
/// <reference path='fourslash.ts'/> // Should return definition of locally declared functions //// he/*function_call*/llo(); //// function [|hello|]() {} verify.baselineGoToImplementation("function_call");
{ "end_byte": 210, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationLocal_00.ts" }
TypeScript/tests/cases/fourslash/tsxQuickInfo5.ts_3_611
/ <reference path='fourslash.ts' /> //@Filename: file.tsx // @jsx: preserve // @noLib: true //// declare function ComponentWithTwoAttributes<K,V>(l: {key1: K, value: V}): JSX.Element; //// function Baz<T,U>(key1: T, value: U) { //// let a0 = <ComponentWi/*1*/thTwoAttributes k/*2*/ey1={key1} val/*3*/ue={value} /> //// let a1 = <ComponentWithTwoAttributes {...{key1, value: value}} key="Component" /> //// } verify.quickInfos({ 1: "function ComponentWithTwoAttributes<T, U>(l: {\n key1: T;\n value: U;\n}): JSX.Element", 2: "(property) key1: T", 3: "(property) value: U", });
{ "end_byte": 611, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxQuickInfo5.ts" }
TypeScript/tests/cases/fourslash/completionsOverridingMethod0.ts_0_7210
/// <reference path="fourslash.ts" /> // @newline: LF // @Filename: a.ts // Case: Concrete class implements abstract method ////abstract class ABase { //// abstract foo(param1: string, param2: boolean): Promise<void>; ////} //// ////class ASub extends ABase { //// f/*a*/ ////} // @Filename: b.ts // Case: Concrete class overrides concrete method ////class BBase { //// foo(a: string, b: string): string { //// return a + b; //// } ////} //// ////class BSub extends BBase { //// f/*b*/ ////} // @Filename: c.ts // Case: Multiple overrides, concrete class overrides concrete method ////class CBase { //// foo(a: string | number): string { //// return a + ""; //// } ////} //// ////class CSub extends CBase { //// foo(a: string): string { //// return add; //// } ////} //// ////class CSub2 extends CSub { //// f/*c*/ ////} // @Filename: d.ts // Case: Abstract class extends abstract class ////abstract class DBase { //// abstract foo(a: string): string; ////} //// ////abstract class DSub extends DBase { //// f/*d*/ ////} // @Filename: e.ts // Case: Class implements interface ////interface EBase { //// foo(a: string): string; ////} //// ////class ESub implements EBase { //// f/*e*/ ////} // @Filename: f.ts // Case: Abstract class implements interface ////interface FBase { //// foo(a: string): string; ////} //// ////abstract class FSub implements FBase { //// f/*f*/ ////} // @Filename: g.ts // Case: Method has overloads ////interface GBase { //// foo(a: string): string; //// foo(a: undefined, b: number): string; ////} //// ////class GSub implements GBase { //// f/*g*/ ////} // @Filename: h.ts // Case: Static method // Note: static methods are only suggested for completions after the `static` keyword ////class HBase { //// static met(n: number): number { //// return n; //// } ////} //// ////class HSub extends HBase { //// /*h1*/ //// static /*h2*/ ////} // @Filename: i.ts // Case: Generic method ////class IBase { //// met<T>(t: T): T { //// return t; //// } //// metcons<T extends string | number>(t: T): T { //// return t; //// } ////} //// ////class ISub extends IBase { //// /*i*/ ////} verify.completions({ marker: "a", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, includes: [ { name: "foo", sortText: completion.SortText.LocationPriority, insertText: "foo(param1: string, param2: boolean): Promise<void> {\n}", filterText: "foo", } ], }); verify.completions({ marker: "b", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, includes: [ { name: "foo", sortText: completion.SortText.LocationPriority, insertText: "foo(a: string, b: string): string {\n}", filterText: "foo", } ], }); verify.completions({ marker: "c", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, includes: [ { name: "foo", sortText: completion.SortText.LocationPriority, insertText: "foo(a: string): string {\n}", filterText: "foo", } ], }); verify.completions({ marker: "d", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, includes: [ { name: "foo", sortText: completion.SortText.LocationPriority, insertText: "foo(a: string): string {\n}", filterText: "foo", } ], }); verify.completions({ marker: "e", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, includes: [ { name: "foo", sortText: completion.SortText.LocationPriority, insertText: "foo(a: string): string {\n}", filterText: "foo", } ], }); verify.completions({ marker: "f", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, includes: [ { name: "foo", sortText: completion.SortText.LocationPriority, insertText: "foo(a: string): string {\n}", filterText: "foo", } ], }); verify.completions({ marker: "g", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, includes: [ { name: "foo", sortText: completion.SortText.LocationPriority, insertText: `foo(a: string): string; foo(a: undefined, b: number): string; foo(a: unknown, b?: unknown): string { }`, filterText: "foo", } ], }); verify.completions({ marker: "h1", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, excludes: "met", }); verify.completions({ marker: "h2", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, includes: [ { name: "met", sortText: completion.SortText.LocationPriority, insertText: "static met(n: number): number {\n}", filterText: "met", hasAction: true, source: completion.CompletionSource.ClassMemberSnippet, } ], }); verify.completions({ marker: "i", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, includes: [ { name: "met", sortText: completion.SortText.LocationPriority, insertText: "met<T>(t: T): T {\n}", filterText: "met" }, { name: "metcons", sortText: completion.SortText.LocationPriority, insertText: "metcons<T extends string | number>(t: T): T {\n}", filterText: "metcons" } ], });
{ "end_byte": 7210, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingMethod0.ts" }
TypeScript/tests/cases/fourslash/genericCallSignaturesInNonGenericTypes2.ts_0_326
/// <reference path='fourslash.ts'/> ////interface WrappedArray<T> { } ////interface Underscore { //// <T>(list: T[]): WrappedArray<T>; ////} ////var _: Underscore; ////var a: number[]; ////var /**/b = _(a); // WrappedArray<any>, should be WrappedArray<number> verify.quickInfoAt("", "var b: WrappedArray<number>");
{ "end_byte": 326, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericCallSignaturesInNonGenericTypes2.ts" }
TypeScript/tests/cases/fourslash/completionsMergedDeclarations2.ts_0_513
/// <reference path='fourslash.ts'/> ////class point { //// constructor(public x: number, public y: number) { } ////} ////module point { //// export var origin = new point(0, 0); //// export function equals(p1: point, p2: point) { //// return p1.x == p2.x && p1.y == p2.y; //// } ////} ////var p1 = new point(0, 0); ////var p2 = point./*1*/origin; ////var b = point./*2*/equals(p1, p2); verify.completions( { marker: "1", includes: "origin" }, { marker: "2", includes: "equals" }, );
{ "end_byte": 513, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsMergedDeclarations2.ts" }
TypeScript/tests/cases/fourslash/quickInfoLinkCodePlain.ts_0_335
///<reference path="fourslash.ts" /> //// export class C { //// /** //// * @deprecated Use {@linkplain PerspectiveCamera#setFocalLength .setFocalLength()} and {@linkcode PerspectiveCamera#filmGauge .filmGauge} instead. //// */ //// m() { } //// } //// new C().m/**/ verify.noErrors() verify.baselineQuickInfo();
{ "end_byte": 335, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoLinkCodePlain.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptQuickInfo1.ts_0_227
/// <reference path='fourslash.ts'/> // @allowNonTsExtensions: true // @Filename: Foo.js /////** @type {function(new:string,number)} */ ////var /**/v; verify.quickInfoAt("", "var v: new (arg1: number) => string", undefined);
{ "end_byte": 227, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptQuickInfo1.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingParam9.ts_0_306
/// <reference path="fourslash.ts" /> ////[|function f() {}|] ////f("", { x: 1 }, [ "" ], true); verify.codeFix({ description: [ts.Diagnostics.Add_missing_parameters_to_0.message, "f"], index: 0, newRangeContent: "function f(p0: string, p1: { x: number; }, p2: string[], p3: boolean) {}" });
{ "end_byte": 306, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingParam9.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageAllAssignments.ts_0_267
/// <reference path='fourslash.ts' /> // @noImplicitAny: false ////[|let x ////|] ////x ??= 1 ////x ||= "2" ////x &&= true verify.codeFix({ description: "Infer type of 'x' from usage", index: 0, newRangeContent: 'let x: string | number | boolean\n', })
{ "end_byte": 267, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageAllAssignments.ts" }
TypeScript/tests/cases/fourslash/codefixUnreferenceableDecoratorMetadata1.ts_0_1130
/// <reference path="fourslash.ts" /> // @isolatedModules: true // @module: es2015 // @experimentalDecorators: true // @emitDecoratorMetadata: true // @Filename: /mod.ts //// export default interface I1 {} //// export interface I2 {} // @Filename: /index.ts //// [|import { I2 } from "./mod";|] //// //// declare var EventListener: any; //// class HelloWorld { //// @EventListener("1") //// p1!: I2; //// p2!: I2; //// } const diag = ts.Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled; goTo.file("/index.ts"); verify.codeFix({ index: 0, description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message, errorCode: diag.code, applyChanges: false, newFileContent: `import * as mod from "./mod"; declare var EventListener: any; class HelloWorld { @EventListener("1") p1!: mod.I2; p2!: mod.I2; }`, }); verify.codeFix({ index: 1, description: ts.Diagnostics.Use_import_type.message, errorCode: diag.code, newRangeContent: `import type { I2 } from "./mod";`, });
{ "end_byte": 1130, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codefixUnreferenceableDecoratorMetadata1.ts" }
TypeScript/tests/cases/fourslash/completionsOverridingMethod16.ts_0_373
/// <reference path="fourslash.ts" /> // @newline: LF ////declare class B { //// set foo(value: any); //// get foo(): any; ////} ////class A extends B { //// /**/ ////} goTo.marker(""); verify.baselineCompletions({ includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, });
{ "end_byte": 373, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingMethod16.ts" }
TypeScript/tests/cases/fourslash/completionListWithUnresolvedModule.ts_0_264
/// <reference path="fourslash.ts" /> ////module m { //// import foo = module('_foo'); //// var n: num/**/ ////} verify.completions({ marker: "", includes: { name: "number", sortText: completion.SortText.GlobalsOrKeywords } });
{ "end_byte": 264, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListWithUnresolvedModule.ts" }
TypeScript/tests/cases/fourslash/correuptedTryExpressionsDontCrashGettingOutlineSpans.ts_0_220
/// <reference path="fourslash.ts"/> // #33102 //// try[| { //// var x = [ //// {% try[||] %}|][|{% except %}|] //// ] //// } catch (e)[| { //// //// }|] verify.outliningSpansInCurrentFile(test.ranges());
{ "end_byte": 220, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/correuptedTryExpressionsDontCrashGettingOutlineSpans.ts" }
TypeScript/tests/cases/fourslash/extract-const-callback-function-rest.ts_0_513
/// <reference path='fourslash.ts' /> ////function fWithRest(fn: (...a: number[]) => number) { } ////fWithRest(/*a*/(a, b, c) => a + b + c/*b*/); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "constant_scope_0", actionDescription: "Extract to constant in enclosing scope", newContent: `function fWithRest(fn: (...a: number[]) => number) { } const newLocal = (a: number, b: number, c: number): number => a + b + c; fWithRest(/*RENAME*/newLocal);` });
{ "end_byte": 513, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const-callback-function-rest.ts" }
TypeScript/tests/cases/fourslash/getQuickInfoForIntersectionTypes.ts_0_141
////function f(): string & {(): any} { //// return <any>{}; ////} ////let x = f(); ////x/**/(); verify.quickInfoAt("", "let x: () => any");
{ "end_byte": 141, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getQuickInfoForIntersectionTypes.ts" }
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction36.ts_0_460
/// <reference path='fourslash.ts' /> ////const f = /*a*/(param) => { //// return { //// "a": 1, //// "b": 2, //// }[param]; ////}/*b*/; goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Add or remove braces in an arrow function", actionName: "Remove braces from arrow function", actionDescription: "Remove braces from arrow function", newContent: `const f = (param) => ({ "a": 1, "b": 2, }[param]);`, });
{ "end_byte": 460, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction36.ts" }
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToNamed_MultiParam.ts_0_358
/// <reference path='fourslash.ts' /> //// let foo = /*x*/(/*y*/a,b,c) => a + 1; goTo.select("x", "y"); edit.applyRefactor({ refactorName: "Convert arrow function or function expression", actionName: "Convert to named function", actionDescription: "Convert to named function", newContent: `function foo(a, b, c) { return a + 1; }`, });
{ "end_byte": 358, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToNamed_MultiParam.ts" }
TypeScript/tests/cases/fourslash/completionsJsxAttributeGeneric2.ts_0_843
/// <reference path="fourslash.ts" /> // @jsx: preserve // @Filename: index.tsx ////declare namespace JSX { //// interface Element {} //// interface IntrinsicElements {} //// interface ElementAttributesProperty { props } ////} //// ////type Props = { a?: string, b?: string }; ////function Component<T extends Props>(props: T) { return null; } ////const e1 = <Component /*1*/ />; ////const e2 = <Component /*2*/></Component> //// ////declare class Component2<T extends Props> { //// props: T; ////} ////const e3 = <Component2 /*3*/ />; ////const e4 = <Component2 /*4*/></Component2>; ["1", "2", "3", "4"].forEach(marker => { verify.completions({ marker, exact: [{ name: "a", sortText: completion.SortText.OptionalMember }, { name: "b", sortText: completion.SortText.OptionalMember }] }); });
{ "end_byte": 843, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsJsxAttributeGeneric2.ts" }
TypeScript/tests/cases/fourslash/issue57585.ts_0_854
/// <reference path='fourslash.ts'/> // @strict: true // @target: esnext // @lib: esnext //// export interface Result<T, E> { //// mapErr<F>(fn: (error: E) => F): Result<T, F>; //// [Symbol.iterator](): Generator<E, T>; //// } //// //// declare const okIfObject: ( //// value: unknown, //// ) => Result<Record<string, unknown>, "ERR_NOT_AN_OBJECT">; //// //// declare const okIfInt: (value: unknown) => Result<number, "ERR_NOT_AN_INT">; //// //// export declare function Do2<T, E>(job: () => Generator<E, T>): void; //// //// declare let value: unknown; //// //// Do2(function* () { //// const object = yield* okIfObject(value).mapErr((error) => 0); //// const age = yield* okIfInt(object.age).mapErr((error) => 0); //// return { age }; //// }); verify.encodedSemanticClassificationsLength('2020', 132); verify.getSemanticDiagnostics([]);
{ "end_byte": 854, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/issue57585.ts" }
TypeScript/tests/cases/fourslash/completionListInUnclosedCommaExpression02.ts_0_187
/// <reference path='fourslash.ts' /> ////// should NOT see a and b ////foo((a, b) => (a,/*1*/ verify.completions({ marker: "1", includes: ["a", "b"], isNewIdentifierLocation: true });
{ "end_byte": 187, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedCommaExpression02.ts" }
TypeScript/tests/cases/fourslash/inlineVariableTemplateString6.ts_0_352
/// <reference path="fourslash.ts" /> ////const /*a*/x/*b*/ = "\\`"; ////export const y = `${x}`; goTo.select("a", "b"); verify.refactorAvailable("Inline variable"); edit.applyRefactor({ refactorName: "Inline variable", actionName: "Inline variable", actionDescription: "Inline variable", newContent: "export const y = `\\\\\\``;" });
{ "end_byte": 352, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableTemplateString6.ts" }
TypeScript/tests/cases/fourslash/moveToFile_noSelfImports1.ts_0_320
/// <reference path='fourslash.ts' /> //@Filename: /bar.ts ////import { y } from "./a"; // @Filename: /a.ts ////[|export const y = 1;|] verify.moveToFile({ newFileContents: { "/a.ts": "", "/bar.ts": ` export const y = 1; `, }, interactiveRefactorArguments: { targetFile: "/bar.ts" } });
{ "end_byte": 320, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_noSelfImports1.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType25.ts_0_412
/// <reference path='fourslash.ts' /> //// type A<T, U> = () => <T>(v: T) => /*a*/(v: T) => <T>(v: T) => U/*b*/; goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to type alias", actionDescription: "Extract to type alias", newContent: `type /*RENAME*/NewType<T, U> = (v: T) => <T>(v: T) => U; type A<T, U> = () => <T>(v: T) => NewType<T, U>;`, });
{ "end_byte": 412, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType25.ts" }
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts_0_482
/// <reference path='fourslash.ts' /> //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } //// //// f ` qwerty ${ 123 } asdf ${/*1*/ /*2*/ /*3*/41/*4*/234/*5*/ /*6*/} zxcvb ${ g ` ` } ` verify.signatureHelp({ marker: test.markers(), text: "f(templateStrings: any, x: any, y: any, z: any): number", argumentCount: 4, parameterCount: 4, parameterName: "y", parameterSpan: "y: any", });
{ "end_byte": 482, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts" }
TypeScript/tests/cases/fourslash/moveToFile_overloads4.ts_0_594
/// <reference path='fourslash.ts' /> // @Filename: /add.ts //// // @Filename: /a.ts ////function add(x: number, y: number): number; ////[|function add(x: string, y: string): string; ////function add(x: any, y: any) { //// return x + y; ////}|] ////function remove() {} verify.moveToFile({ newFileContents: { "/a.ts": "function remove() {}", "/add.ts": ` function add(x: number, y: number): number; function add(x: string, y: string): string; function add(x: any, y: any) { return x + y; } ` }, interactiveRefactorArguments: { targetFile: "/add.ts" }, });
{ "end_byte": 594, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_overloads4.ts" }
TypeScript/tests/cases/fourslash/smartSelection_JSDocTags8.ts_0_171
/// <reference path="fourslash.ts" /> /////** //// * @this {/*1*/Foo} //// * @param {/*2*/*} e //// */ ////function callback(e) { ////} verify.baselineSmartSelection();
{ "end_byte": 171, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_JSDocTags8.ts" }
TypeScript/tests/cases/fourslash/autoImportSameNameDefaultExported.ts_0_812
/// <reference path="fourslash.ts" /> // @module: commonjs // @Filename: /node_modules/antd/index.d.ts //// declare function Table(): void; //// export default Table; // @Filename: /node_modules/rc-table/index.d.ts //// declare function Table(): void; //// export default Table; // @Filename: /index.ts //// Table/**/ verify.completions({ marker: "", exact: completion.globalsPlus([{ name: "Table", source: "antd", sourceDisplay: "antd", sortText: completion.SortText.AutoImportSuggestions, hasAction: true, }, { name: "Table", source: "rc-table", sourceDisplay: "rc-table", sortText: completion.SortText.AutoImportSuggestions, hasAction: true, }]), preferences: { includeCompletionsForModuleExports: true, allowIncompleteCompletions: true, } });
{ "end_byte": 812, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportSameNameDefaultExported.ts" }
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsConst.ts_0_575
/// <reference path='fourslash.ts'/> ////const /*1*/a = 10; ////function foo() { //// const /*2*/b = /*3*/a; //// if (b) { //// const /*4*/b1 = 10; //// } ////} ////module m { //// const /*5*/c = 10; //// export const /*6*/d = 10; //// if (c) { //// const /*7*/e = 10; //// } ////} ////const /*8*/f: () => number = () => 10; ////const /*9*/g = /*10*/f; /////*11*/f(); ////const /*12*/h: { (a: string): number; (a: number): string; } = a => a; ////const /*13*/i = /*14*/h; /////*15*/h(10); /////*16*/h("hello"); verify.baselineQuickInfo();
{ "end_byte": 575, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsConst.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts_0_400
/// <reference path='fourslash.ts' /> ////namespace N1 { //// export interface I1 { x: number; } ////} ////interface I1 { //// f1(); ////} ////class C1 implements N1.I1 {} verify.codeFix({ description: "Implement interface 'N1.I1'", newFileContent: `namespace N1 { export interface I1 { x: number; } } interface I1 { f1(); } class C1 implements N1.I1 { x: number; }`, });
{ "end_byte": 400, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts" }
TypeScript/tests/cases/fourslash/quickInfoCommentsFunctionDeclaration.ts_0_545
/// <reference path='fourslash.ts' /> /////** This comment should appear for foo*/ ////function f/*1*/oo() { ////} ////f/*2*/oo(); /////** This is comment for function signature*/ ////function fo/*5*/oWithParameters(/** this is comment about a*/a: string, //// /** this is comment for b*/ //// b: number) { //// var /*6*/d = a; ////} ////fooWithParam/*8*/eters("a",10); // ambient declaration /////** ////* Does something ////* @param a a string ////*/ ////declare function fn(a: string); ////fn("hello"); verify.baselineQuickInfo()
{ "end_byte": 545, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoCommentsFunctionDeclaration.ts" }
TypeScript/tests/cases/fourslash/codeFixAddOptionalParam8.ts_0_329
/// <reference path="fourslash.ts" /> ////[|function f(a: number) {}|] //// ////const a = 1; ////const b = 1; ////const c = 1; ////f(a, b, c); verify.codeFix({ description: [ts.Diagnostics.Add_optional_parameters_to_0.message, "f"], index: 1, newRangeContent: "function f(a: number, b?: number, c?: number) {}" });
{ "end_byte": 329, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddOptionalParam8.ts" }
TypeScript/tests/cases/fourslash/extendInterfaceOverloadedMethod.ts_0_346
/// <reference path='fourslash.ts'/> ////interface A<T> { //// foo(a: T): B<T>; //// foo(): void ; //// foo2(): B<number>; ////} ////interface B<T> extends A<T> { //// bar(): void ; ////} ////var b: B<number>; ////var /**/x = b.foo2().foo(5).foo(); // 'x' is of type 'void' verify.quickInfoAt("", "var x: void"); verify.noErrors();
{ "end_byte": 346, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extendInterfaceOverloadedMethod.ts" }
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class11.ts_0_355
/// <reference path='fourslash.ts' /> // @allowNonTsExtensions: true // @Filename: foo.js ////function Foo() { //// this.a = 0; ////} ////Foo[1] = function () { ////} verify.codeFix({ description: "Convert function to an ES2015 class", newFileContent: `class Foo { constructor() { this.a = 0; } static 1() { } } ` });
{ "end_byte": 355, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class11.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringAssignmentStatementArrayBindingPattern.ts_0_2027
/// <reference path='fourslash.ts' /> ////declare var console: { //// log(msg: any): void; ////} ////type Robot = [number, string, string]; ////type MultiSkilledRobot = [string, [string, string]]; //// ////var robotA: Robot = [1, "mower", "mowing"]; ////var robotB: Robot = [2, "trimmer", "trimming"]; ////var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ////var multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; //// ////let nameA: string, numberB: number, nameB: string, skillB: string; ////let robotAInfo: (number | string)[]; //// ////let multiSkillB: [string, string], nameMB: string, primarySkillB: string, secondarySkillB: string; ////let multiRobotAInfo: (string | [string, string])[]; //// ////[, nameA] = robotA; ////[, nameB] = getRobotB(); ////[, nameB] = [2, "trimmer", "trimming"]; ////[, multiSkillB] = multiRobotB; ////[, multiSkillB] = getMultiRobotB(); ////[, multiSkillB] = ["roomba", ["vacuum", "mopping"]]; //// ////[numberB] = robotB; ////[numberB] = getRobotB(); ////[numberB] = [2, "trimmer", "trimming"]; ////[nameMB] = multiRobotB; ////[nameMB] = getMultiRobotB(); ////[nameMB] = ["trimmer", ["trimming", "edging"]]; //// ////[numberB, nameB, skillB] = robotB; ////[numberB, nameB, skillB] = getRobotB(); ////[numberB, nameB, skillB] = [2, "trimmer", "trimming"]; ////[nameMB, [primarySkillB, secondarySkillB]] = multiRobotB; ////[nameMB, [primarySkillB, secondarySkillB]] = getMultiRobotB(); ////[nameMB, [primarySkillB, secondarySkillB]] = ["trimmer", ["trimming", "edging"]]; //// ////[numberB, ...robotAInfo] = robotB; ////[numberB, ...robotAInfo] = getRobotB(); ////[numberB, ...robotAInfo] = <Robot>[2, "trimmer", "trimming"]; ////[...multiRobotAInfo] = multiRobotA; ////[...multiRobotAInfo] = getMultiRobotB(); ////[...multiRobotAInfo] = ["trimmer", ["trimming", "edging"]]; //// ////function getRobotB() { //// return robotB; ////} //// ////function getMultiRobotB() { //// return multiRobotB; ////} verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 2027, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringAssignmentStatementArrayBindingPattern.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType74.ts_0_493
/// <reference path='fourslash.ts' /> // @Filename: a.ts //// interface Foo<T extends { prop: [|T|] }> {} // @Filename: b.ts //// // Some initial comments. //// // We need to ensure these files have different contents, //// // so their ranges differ, so we'll start a few lines below in this file. //// interface Foo<T extends { prop: [|T|] }> {} for (const range of test.ranges()) { goTo.selectRange(range); verify.not.refactorAvailable("Extract type", "Extract to type alias"); }
{ "end_byte": 493, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType74.ts" }
TypeScript/tests/cases/fourslash/referencesForStringLiteralPropertyNames3.ts_0_233
/// <reference path='fourslash.ts'/> ////class Foo2 { //// /*1*/get "/*2*/42"() { return 0; } //// /*3*/set /*4*/42(n) { } ////} //// ////var y: Foo2; ////y[/*5*/42]; verify.baselineFindAllReferences('1', '2', '3', '4', '5');
{ "end_byte": 233, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForStringLiteralPropertyNames3.ts" }
TypeScript/tests/cases/fourslash/renameLabel2.ts_0_111
/// <reference path="fourslash.ts" /> /////**/foo: { //// break foo; ////} verify.baselineRename("", {});
{ "end_byte": 111, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameLabel2.ts" }
TypeScript/tests/cases/fourslash/remoteGetReferences.ts_0_3863
/// <reference path='fourslash.ts'/> // @Filename: remoteGetReferences_1.ts ////// Comment Refence Test: globalVar ////var globalVar: number = 2; //// ////class fooCls { //// static clsSVar = 1; //// //Declare //// clsVar = 1; //// //// constructor (public clsParam: number) { //// //Increments //// globalVar++; //// this.clsVar++; //// fooCls.clsSVar++; //// this.clsParam++; //// modTest.modVar++; //// } ////} //// ////function foo(x: number) { //// //Declare //// var fnVar = 1; //// //// //Increments //// fooCls.clsSVar++; //// globalVar++; //// modTest.modVar++; //// fnVar++; //// //// //Return //// return x++; ////} //// ////module modTest { //// //Declare //// export var modVar:number; //// //// //Increments //// globalVar++; //// fooCls.clsSVar++; //// modVar++; //// //// class testCls { //// static boo = foo; //// } //// //// function testFn(){ //// static boo = foo; //// //// //Increments //// globalVar++; //// fooCls.clsSVar++; //// modVar++; //// } //// //// module testMod { //// var boo = foo; //// } ////} //// //////Type test ////var clsTest: fooCls; //// //////Arguments ////clsTest = new fooCls(globalVar); ////foo(globalVar); //// //////Increments ////fooCls.clsSVar++; ////modTest.modVar++; ////globalVar = globalVar + globalVar; //// //////ETC - Other cases ////globalVar = 3; ////foo = foo + 1; ////err = err++; //// //////Shadowed fn Parameter ////function shdw(globalVar: number) { //// //Increments //// globalVar++; //// return globalVar; ////} //// //////Remotes //////Type test ////var remoteclsTest: /*1*/remotefooCls; //// //////Arguments ////remoteclsTest = new /*2*/remotefooCls(/*3*/remoteglobalVar); ////remotefoo(/*4*/remoteglobalVar); //// //////Increments /////*5*/remotefooCls./*6*/remoteclsSVar++; ////remotemodTest.remotemodVar++; /////*7*/remoteglobalVar = /*8*/remoteglobalVar + /*9*/remoteglobalVar; //// //////ETC - Other cases /////*10*/remoteglobalVar = 3; //// //////Find References misses method param ////var //// //// //// //// array = ["f", "o", "o"]; //// ////array.forEach( //// //// ////function(str) { //// //// //// //// return str + " "; //// ////}); // @Filename: remoteGetReferences_2.ts /////*11*/var /*12*/remoteglobalVar: number = 2; //// /////*13*/class /*14*/remotefooCls { //// //Declare //// /*15*/remoteclsVar = 1; //// /*16*/static /*17*/remoteclsSVar = 1; //// //// constructor(public remoteclsParam: number) { //// //Increments //// /*18*/remoteglobalVar++; //// this./*19*/remoteclsVar++; //// /*20*/remotefooCls./*21*/remoteclsSVar++; //// this.remoteclsParam++; //// remotemodTest.remotemodVar++; //// } ////} //// ////function remotefoo(remotex: number) { //// //Declare //// var remotefnVar = 1; //// //// //Increments //// /*22*/remotefooCls./*23*/remoteclsSVar++; //// /*24*/remoteglobalVar++; //// remotemodTest.remotemodVar++; //// remotefnVar++; //// //// //Return //// return remotex++; ////} //// ////module remotemodTest { //// //Declare //// export var remotemodVar: number; //// //// //Increments //// /*25*/remoteglobalVar++; //// /*26*/remotefooCls./*27*/remoteclsSVar++; //// remotemodVar++; //// //// class remotetestCls { //// static remoteboo = remotefoo; //// } //// //// function remotetestFn(){ //// static remoteboo = remotefoo; //// //// //Increments //// /*28*/remoteglobalVar++; //// /*29*/remotefooCls./*30*/remoteclsSVar++; //// remotemodVar++; //// } //// //// module remotetestMod { //// var remoteboo = remotefoo; //// } ////} verify.baselineFindAllReferences( '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30');
{ "end_byte": 3863, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/remoteGetReferences.ts" }
TypeScript/tests/cases/fourslash/completionsJsxAttributeInitializer2.ts_0_566
/// <reference path="fourslash.ts" /> // @Filename: /a.tsx ////declare namespace JSX { //// interface IntrinsicElements { //// div: { a: string, b: string } //// } ////} ////const foo = 0; ////<div x=[|f/*0*/|] />; //// ////<div a="1" b/*1*/ /> ////<div a /*2*/ /> verify.completions( { marker: "0", includes: { name: "foo", text: "const foo: 0", kind: "const", insertText: "{foo}", replacementSpan: test.ranges()[0] }, preferences: { includeInsertTextCompletions: true }, }, { marker: ["1", "2"], exact: "b" }, );
{ "end_byte": 566, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsJsxAttributeInitializer2.ts" }
TypeScript/tests/cases/fourslash/inlayHintsMultifile1.ts_0_502
/// <reference path="fourslash.ts" /> // @Filename: /a.ts //// export interface Foo { a: string } // @Filename: /b.ts //// async function foo () { //// return {} as any as import('./a').Foo //// } //// function bar () { return import('./a') } //// async function main () { //// const a = await foo() //// const b = await bar() //// } goTo.file('/b.ts') verify.baselineInlayHints(undefined, { includeInlayVariableTypeHints: true, includeInlayFunctionLikeReturnTypeHints: true });
{ "end_byte": 502, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsMultifile1.ts" }
TypeScript/tests/cases/fourslash/outliningSpansForArrowFunctionBody.ts_0_254
/// <reference path="fourslash.ts"/> //// () => 42; //// () => ( 42 ); //// () =>[| { //// 42 //// }|]; //// () => [|( //// 42 //// )|]; //// () =>[| "foo" + //// "bar" + //// "baz"|]; verify.outliningSpansInCurrentFile(test.ranges());
{ "end_byte": 254, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/outliningSpansForArrowFunctionBody.ts" }
TypeScript/tests/cases/fourslash/jsdocDeprecated_suggestion19.ts_0_425
///<reference path="fourslash.ts" /> ////interface I { //// x: number; //// y: number; ////} ////interface I { //// /** @deprecated */ //// x: number; ////} ////const foo: I = { x: 1, y: 1 }; ////foo.[|x|]; const [range] = test.ranges(); verify.getSuggestionDiagnostics([ { "code": 6385, "message": "'x' is deprecated.", "reportsDeprecated": true, "range": range }, ]);
{ "end_byte": 425, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocDeprecated_suggestion19.ts" }
TypeScript/tests/cases/fourslash/unclosedStringLiteralErrorRecovery3.ts_0_172
/// <reference path="fourslash.ts" /> ////function alpha() { //// //// var x = "x\ //// //// /**/var y = 1; //// ////} verify.not.errorExistsAfterMarker();
{ "end_byte": 172, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unclosedStringLiteralErrorRecovery3.ts" }
TypeScript/tests/cases/fourslash/completionsKeyof.ts_0_579
/// <reference path="fourslash.ts" /> ////interface A { a: number; }; ////interface B { a: number; b: number; }; ////function f<T extends keyof A>(key: T) {} ////f("[|/*f*/|]"); ////function g<T extends keyof B>(key: T) {} ////g("[|/*g*/|]"); verify.completions( { marker: "f", exact: [ { name: "a", replacementSpan: test.ranges()[0] } ] }, { marker: "g", exact: [ { name: "a", replacementSpan: test.ranges()[1] }, { name: "b", replacementSpan: test.ranges()[1] }, ] }, );
{ "end_byte": 579, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsKeyof.ts" }
TypeScript/tests/cases/fourslash/genericParameterHelpTypeReferences.ts_0_1156
/// <reference path="fourslash.ts"/> ////interface IFoo { } //// ////class testClass<T extends IFoo, U, M extends IFoo> { //// constructor(a:T, b:U, c:M){ } ////} //// ////// Generic types ////testClass</*type1*/ ////var x : testClass</*type2*/ ////class Bar<T> extends testClass</*type3*/ ////var x : testClass<,, /*type4*/any>; //// ////interface I<T> {} ////let i: I</*interface*/>; //// ////type Ty<T> = T; ////let t: Ty</*typeAlias*/>; verify.signatureHelp( { marker: ["type1", "type2", "type3"], text: "testClass<T extends IFoo, U, M extends IFoo>", parameterName: "T", parameterSpan: "T extends IFoo", triggerReason: { kind: "characterTyped", triggerCharacter: "<" }, }, { marker: "type4", parameterName: "M", parameterSpan: "M extends IFoo", triggerReason: { kind: "characterTyped", triggerCharacter: "," }, }, { marker: "interface", text: "I<T>", parameterName: "T", parameterSpan: "T", }, { marker: "typeAlias", text: "Ty<T>", parameterName: "T", parameterSpan: "T", }, );
{ "end_byte": 1156, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericParameterHelpTypeReferences.ts" }
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue23.ts_0_286
/// <reference path='fourslash.ts' /> //// class Foo { //// bar: () => number = () => { 1 } //// } verify.codeFixAvailable([ { description: ts.Diagnostics.Add_a_return_statement.message }, { description: ts.Diagnostics.Remove_braces_from_arrow_function_body.message } ]);
{ "end_byte": 286, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue23.ts" }
TypeScript/tests/cases/fourslash/getEmitOutputSourceRootMultiFiles.ts_0_494
/// <reference path="fourslash.ts" /> // @BaselineFile: getEmitOutputSourceRootMultiFiles.baseline // @sourceMap: true // @sourceRoot: sourceRootDir/ // @Filename: inputFile1.ts // @emitThisFile: true //// var x = 109; //// var foo = "hello world"; //// class M { //// x: number; //// y: string; //// } // @Filename: inputFile2.ts // @emitThisFile: true //// var bar = "hello world Typescript"; //// class C { //// x: number; //// y: string[]; //// } verify.baselineGetEmitOutput();
{ "end_byte": 494, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputSourceRootMultiFiles.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType64.ts_0_259
/// <reference path='fourslash.ts' /> //// type T = { c: string } & Record<string, string> //// function foo(a: /*a*/{ a: number | string, b: string } & T/*b*/) { } goTo.select("a", "b"); verify.not.refactorAvailable("Extract type", "Extract to interface")
{ "end_byte": 259, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType64.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess16.ts_0_539
/// <reference path='fourslash.ts' /> //// class A { //// constructor(public /*a*/a/*b*/: string) { } //// } goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Generate 'get' and 'set' accessors", actionName: "Generate 'get' and 'set' accessors", actionDescription: "Generate 'get' and 'set' accessors", newContent: `class A { public get a(): string { return this._a; } public set a(value: string) { this._a = value; } constructor(private /*RENAME*/_a: string) { } }`, });
{ "end_byte": 539, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess16.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_add_all_missing_imports.ts_0_467
/// <reference path="fourslash.ts" /> // @Filename: /a.ts ////export const a: number; // @Filename: /b.ts ////export const b: number; // @Filename: /c.ts ////export const c: number; // @Filename: /main.ts ////a; ////b; ////c; goTo.file("/main.ts"); verify.codeFixAll({ fixId: "fixMissingImport", fixAllDescription: "Add all missing imports", newFileContent: `import { a } from "./a"; import { b } from "./b"; import { c } from "./c"; a; b; c;`, });
{ "end_byte": 467, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_add_all_missing_imports.ts" }
TypeScript/tests/cases/fourslash/referencesForInheritedProperties3.ts_3_285
/ <reference path='fourslash.ts'/> //// interface interface1 extends interface1 { //// /*1*/doStuff(): void; //// /*2*/propName: string; //// } //// //// var v: interface1; //// v./*3*/propName; //// v./*4*/doStuff(); verify.baselineFindAllReferences('1', '2', '3', '4');
{ "end_byte": 285, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForInheritedProperties3.ts" }