_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/mapCodeNestedForInsertion.ts_0_430
///<reference path="fourslash.ts"/> // @Filename: /index.ts //// function foo() { //// const x: number = 1; //// const y: number = 2; //// for (let i = 0; i < 10; i++) [||]{ //// console.log("hello"); //// console.log("you"); //// } //// return 1; //// } //// verify.baselineMapCode([test.ranges()], [ ` for (let j = 0; j < 10; j++) { console.log("goodbye"); console.log("world"); } ` ]);
{ "end_byte": 430, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeNestedForInsertion.ts" }
TypeScript/tests/cases/fourslash/quickInfoForRequire.ts_0_307
/// <reference path='fourslash.ts'/> //@Filename: AA/BB.ts ////export class a{} //@Filename: quickInfoForRequire_input.ts ////import a = require("./AA/B/*1*/B"); ////import b = require(`./AA/B/*2*/B`); goTo.marker("1"); verify.quickInfoIs("module a"); goTo.marker("2"); verify.quickInfoIs("module a");
{ "end_byte": 307, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForRequire.ts" }
TypeScript/tests/cases/fourslash/formatNoSpaceBeforeCloseBrace4.ts_0_162
/// <reference path="fourslash.ts"/> ////new Foo(1 ////, /* comment */ ); format.document(); verify.currentFileContentIs(`new Foo(1 , /* comment */);`);
{ "end_byte": 162, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatNoSpaceBeforeCloseBrace4.ts" }
TypeScript/tests/cases/fourslash/completionListEnumValues.ts_0_680
/// <reference path='fourslash.ts' /> ////enum Colors { //// Red, //// Green ////} //// ////Colors./*enumVariable*/; //// ////var x = Colors.Red; ////x./*variableOfEnumType*/; //// ////function foo(): Colors { return null; } ////foo()./*callOfEnumReturnType*/ verify.completions( // Should only have the enum's own members, and nothing else { marker: "enumVariable", exact: ["Green", "Red"] }, // Should have number members, and not enum members { marker: ["variableOfEnumType", "callOfEnumReturnType"], exact: [ "toExponential", "toFixed", "toLocaleString", "toPrecision", "toString", "valueOf", ] } );
{ "end_byte": 680, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListEnumValues.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageMember3.ts_0_190
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////class C { //// constructor([|public p)|] { } ////} ////new C("string"); verify.rangeAfterCodeFix("public p: string)");
{ "end_byte": 190, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageMember3.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType13.ts_0_431
/// <reference path='fourslash.ts' /> //// interface A<T = string> { //// a: /*a*/boolean/*b*/ //// b: number //// c: T //// } goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to type alias", actionDescription: "Extract to type alias", newContent: `type /*RENAME*/NewType = boolean interface A<T = string> { a: NewType b: number c: T }`, });
{ "end_byte": 431, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType13.ts" }
TypeScript/tests/cases/fourslash/codeFixChangeExtendsToImplementsWithDecorator.ts_0_427
/// <reference path='fourslash.ts' /> //// interface I1 { } //// interface I2 { } //// function sealed(constructor: Function) { //// Object.seal(constructor); //// Object.seal(constructor.prototype); //// } //// @sealed //// [|class A extends I1 implements I2 { }|] verify.codeFix({ description: "Change 'extends' to 'implements'", // TODO: GH#18794 newRangeContent: "class A implements I1, I2 { }", });
{ "end_byte": 427, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeExtendsToImplementsWithDecorator.ts" }
TypeScript/tests/cases/fourslash/commentSelection1.ts_0_400
// Simple comment selection cases. //// let var1[| = 1; //// let var2 = 2; //// let var3 |]= 3; //// //// let var4[| = 4;|] //// //// let [||]var5 = 5; //// //// //let var6[| = 6; //// //let var7 = 7; //// //let var8 |]= 8; verify.commentSelection( `//let var1 = 1; //let var2 = 2; //let var3 = 3; let var4/* = 4;*/ //let var5 = 5; ////let var6 = 6; ////let var7 = 7; ////let var8 = 8;`);
{ "end_byte": 400, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/commentSelection1.ts" }
TypeScript/tests/cases/fourslash/codeFixUndeclaredPropertyThisType.ts_0_318
/// <reference path='fourslash.ts' /> //// [|class A { //// constructor() { //// this.mythis = this; //// } //// }|] verify.rangeAfterCodeFix(` class A { mythis: this; constructor() { this.mythis = this; } } `, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
{ "end_byte": 318, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUndeclaredPropertyThisType.ts" }
TypeScript/tests/cases/fourslash/formattingOnCloseBrace.ts_0_161
/// <reference path='fourslash.ts' /> ////class foo { //// /**/ goTo.marker(); edit.insert('}'); goTo.bof(); verify.currentLineContentIs('class foo {');
{ "end_byte": 161, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnCloseBrace.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptCompletions19.ts_0_573
/// <reference path="fourslash.ts" /> // @allowNonTsExtensions: true // @Filename: file.js //// function fn() { //// if (foo) { //// return 0; //// } else { //// return '0'; //// } //// } //// let x = fn(); //// if(typeof x === 'string') { //// x/*str*/ //// } else { //// x/*num*/ //// } goTo.marker('str'); edit.insert('.'); verify.completions({ includes: { name: "substring", kind: "method", kindModifiers: "declare" } }); goTo.marker('num'); edit.insert('.'); verify.completions({ includes: { name: "toFixed", kind: "method", kindModifiers: "declare" } });
{ "end_byte": 573, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptCompletions19.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType1.ts_0_371
/// <reference path='fourslash.ts' /> //// var x: /*a*/{ a?: number, b?: string }/*b*/ = { }; goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to type alias", actionDescription: "Extract to type alias", newContent: `type /*RENAME*/NewType = { a?: number; b?: string; }; var x: NewType = { };`, });
{ "end_byte": 371, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType1.ts" }
TypeScript/tests/cases/fourslash/formatFunctionAndConstructorType.ts_0_827
/// <reference path='fourslash.ts' /> ////function renderElement( //// element: Element, //// renderNode: ////(/*funcAutoformat*/ //// node: Node/*funcParamAutoformat*/ /////*funcIndent*/ //// ) => void, ////newNode: ////new(/*constrAutoformat*/ //// name: string/*constrParamAutoformat*/ /////*constrIndent*/ ////) => Node ////): void { ////} format.document(); goTo.marker("funcAutoformat"); verify.currentLineContentIs(" ("); goTo.marker("funcParamAutoformat"); verify.currentLineContentIs(" node: Node"); goTo.marker("funcIndent"); verify.indentationIs(12); goTo.marker("constrAutoformat"); verify.currentLineContentIs(" new ("); goTo.marker("constrParamAutoformat"); verify.currentLineContentIs(" name: string"); goTo.marker("constrIndent"); verify.indentationIs(12);
{ "end_byte": 827, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatFunctionAndConstructorType.ts" }
TypeScript/tests/cases/fourslash/smartIndentAfterFatArrowVar.ts_0_116
/// <reference path='fourslash.ts' /> //// var x = r => r => r; //// /**/ goTo.marker(); verify.indentationIs(0);
{ "end_byte": 116, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentAfterFatArrowVar.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts_0_715
/// <reference path='fourslash.ts' /> ////interface I { //// method(a: number, b: string): boolean; //// method(a: string, b: number): Function; //// method(a: string): Function; ////} //// ////class C implements I {} verify.codeFix({ description: "Implement interface 'I'", newFileContent: `interface I { method(a: number, b: string): boolean; method(a: string, b: number): Function; method(a: string): Function; } class C implements I { method(a: number, b: string): boolean; method(a: string, b: number): Function; method(a: string): Function; method(a: unknown, b?: unknown): boolean | Function { throw new Error("Method not implemented."); } }`, });
{ "end_byte": 715, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDocTagsFunctionOverload02.ts_0_1892
/// <reference path='fourslash.ts'/> // @Filename: quickInfoJsDocTagsFunctionOverload02.ts /////** //// * Doc foo //// */ ////declare function /*1*/foo(): void; //// /////** //// * Doc foo overloaded //// */ ////declare function /*2*/foo(x: number): void goTo.marker("1"); verify.verifyQuickInfoDisplayParts( "function", "declare", { start: 36, length: 3 }, [ {text:"function",kind:"keyword"}, {text:" ",kind:"space"}, {text:"foo",kind:"functionName"}, {text:"(",kind:"punctuation"}, {text:")",kind:"punctuation"}, {text:":",kind:"punctuation"}, {text:" ",kind:"space"}, {text:"void",kind:"keyword"}, {text:" ",kind:"space"}, {text:"(",kind:"punctuation"}, {text:"+",kind:"operator"}, {text:"1",kind:"numericLiteral"}, {text:" ",kind:"space"}, {text:"overload",kind:"text"}, {text:")",kind:"punctuation"} ], [{ text: "Doc foo", kind: "text" }]); goTo.marker("2"); verify.verifyQuickInfoDisplayParts( "function", "declare", { start: 97, length: 3 }, [ {text:"function",kind:"keyword"}, {text:" ",kind:"space"}, {text:"foo",kind:"functionName"}, {text:"(",kind:"punctuation"}, {text:"x",kind:"parameterName"}, {text:":",kind:"punctuation"}, {text:" ",kind:"space"}, {text:"number",kind:"keyword"}, {text:")",kind:"punctuation"}, {text:":",kind:"punctuation"}, {text:" ",kind:"space"}, {text:"void",kind:"keyword"}, {text:" ",kind:"space"}, {text:"(",kind:"punctuation"}, {text:"+",kind:"operator"}, {text:"1",kind:"numericLiteral"}, {text:" ",kind:"space"}, {text:"overload",kind:"text"}, {text:")",kind:"punctuation"} ], [{ text: "Doc foo overloaded", kind: "text" }]);
{ "end_byte": 1892, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTagsFunctionOverload02.ts" }
TypeScript/tests/cases/fourslash/codeFixAddVoidToPromise_all.ts_0_792
/// <reference path='fourslash.ts' /> // @target: esnext // @lib: es2015 // @strict: true ////const p1 = new Promise(resolve => resolve()); ////const p2 = new Promise<number>(resolve => resolve()); ////const p3 = new Promise<number | string>(resolve => resolve()); ////const p4 = new Promise<{ x: number } & { y: string }>(resolve => resolve()); verify.codeFixAll({ fixId: "addVoidToPromise", fixAllDescription: ts.Diagnostics.Add_void_to_all_Promises_resolved_without_a_value.message, newFileContent: `const p1 = new Promise<void>(resolve => resolve()); const p2 = new Promise<number | void>(resolve => resolve()); const p3 = new Promise<number | string | void>(resolve => resolve()); const p4 = new Promise<({ x: number } & { y: string }) | void>(resolve => resolve());` });
{ "end_byte": 792, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddVoidToPromise_all.ts" }
TypeScript/tests/cases/fourslash/inheritedModuleMembersForClodule2.ts_0_303
/// <reference path="fourslash.ts" /> ////module M { //// export module A { //// var o; //// } ////} ////module M { //// export class A { a = 1;} ////} ////module M { //// export class A { /**/b } ////} goTo.marker(); verify.quickInfoExists(); verify.numberOfErrorsInCurrentFile(4);
{ "end_byte": 303, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inheritedModuleMembersForClodule2.ts" }
TypeScript/tests/cases/fourslash/navbar_let.ts_0_441
/// <reference path="fourslash.ts" /> ////let c = 0; verify.navigationTree({ "text": "<global>", "kind": "script", "childItems": [ { "text": "c", "kind": "let" } ] }); verify.navigationBar([ { "text": "<global>", "kind": "script", "childItems": [ { "text": "c", "kind": "let" } ] } ]);
{ "end_byte": 441, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navbar_let.ts" }
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnon_MultiLine.ts_0_424
/// <reference path='fourslash.ts' /> //// const 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 anonymous function", actionDescription: "Convert to anonymous function", newContent: `const foo = function(a) { let b = 1; return a + b; };`, });
{ "end_byte": 424, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnon_MultiLine.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteralInIndexedAccess01.ts_0_306
/// <reference path='fourslash.ts'/> ////interface Foo { //// foo: string; //// bar: string; ////} //// ////let x: Foo["[|/*1*/|]"] const replacementSpan = test.ranges()[0] verify.completions({ marker: "1", exact: [ { name: "bar", replacementSpan }, { name: "foo", replacementSpan }, ] });
{ "end_byte": 306, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralInIndexedAccess01.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageCallbackParameter1.ts_0_484
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @noImplicitAny: false // @filename: /foo.js ////function foo(names) { //// return names.filter((name, index) => name === "foo" && index === 1); ////} verify.codeFix({ description: "Infer parameter types from usage", index: 1, newFileContent: `function foo(names) { return names.filter((/** @type {string} */ name, /** @type {number} */ index) => name === "foo" && index === 1); }` });
{ "end_byte": 484, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageCallbackParameter1.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_avoidRelativeNodeModules.ts_0_682
/// <reference path="fourslash.ts" /> // @Filename: /a/index.d.ts // @Symlink: /b/node_modules/a/index.d.ts // @Symlink: /c/node_modules/a/index.d.ts ////export const a: number; // @Filename: /b/index.ts // @Symlink: /c/node_modules/b/index.d.ts ////import { a } from 'a' ////export const b: number; // @Filename: /c/a_user.ts // Importing from "a" to get /c/node_modules/a in the project. // Must do this in a separate file to avoid import fixes attempting to share the import. ////import { a } from "a"; // @Filename: /c/foo.ts ////[|import { b } from "b"; ////a;|] goTo.file("/c/foo.ts"); verify.importFixAtPosition([ `import { a } from "a"; import { b } from "b"; a;`, ]);
{ "end_byte": 682, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_avoidRelativeNodeModules.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType42.ts_0_397
/// <reference path='fourslash.ts' /> //// const a = 1; //// type A = (v: string | number) => /*a*/typeof a/*b*/; goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to type alias", actionDescription: "Extract to type alias", newContent: `const a = 1; type /*RENAME*/NewType = typeof a; type A = (v: string | number) => NewType;`, });
{ "end_byte": 397, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType42.ts" }
TypeScript/tests/cases/fourslash/navigationBarItemsModules1.ts_0_4780
/// <reference path="fourslash.ts"/> ////declare module "X.Y.Z" {} //// ////declare module 'X2.Y2.Z2' {} //// ////declare module "foo"; //// ////module A.B.C { //// export var x; ////} //// ////module A.B { //// export var y; ////} //// ////module A { //// export var z; ////} //// ////module A { //// module B { //// module C { //// declare var x; //// } //// } ////} verify.navigationTree({ "text": "<global>", "kind": "script", "childItems": [ { "text": "'X2.Y2.Z2'", "kind": "module", "kindModifiers": "declare" }, { "text": "\"foo\"", "kind": "module", "kindModifiers": "declare" }, { "text": "\"X.Y.Z\"", "kind": "module", "kindModifiers": "declare" }, { "text": "A", "kind": "module", "childItems": [ { "text": "B", "kind": "module", "childItems": [ { "text": "C", "kind": "module", "childItems": [ { "text": "x", "kind": "var", "kindModifiers": "declare" } ] } ] }, { "text": "z", "kind": "var", "kindModifiers": "export" } ] }, { "text": "A.B", "kind": "module", "childItems": [ { "text": "y", "kind": "var", "kindModifiers": "export" } ] }, { "text": "A.B.C", "kind": "module", "childItems": [ { "text": "x", "kind": "var", "kindModifiers": "export" } ] } ] }); verify.navigationBar([ { "text": "<global>", "kind": "script", "childItems": [ { "text": "'X2.Y2.Z2'", "kind": "module", "kindModifiers": "declare" }, { "text": "\"foo\"", "kind": "module", "kindModifiers": "declare" }, { "text": "\"X.Y.Z\"", "kind": "module", "kindModifiers": "declare" }, { "text": "A", "kind": "module" }, { "text": "A.B", "kind": "module" }, { "text": "A.B.C", "kind": "module" } ] }, { "text": "'X2.Y2.Z2'", "kind": "module", "kindModifiers": "declare", "indent": 1 }, { "text": "\"foo\"", "kind": "module", "kindModifiers": "declare", "indent": 1 }, { "text": "\"X.Y.Z\"", "kind": "module", "kindModifiers": "declare", "indent": 1 }, { "text": "A", "kind": "module", "childItems": [ { "text": "B", "kind": "module" }, { "text": "z", "kind": "var", "kindModifiers": "export" } ], "indent": 1 }, { "text": "B", "kind": "module", "childItems": [ { "text": "C", "kind": "module" } ], "indent": 2 }, { "text": "C", "kind": "module", "childItems": [ { "text": "x", "kind": "var", "kindModifiers": "declare" } ], "indent": 3 }, { "text": "A.B", "kind": "module", "childItems": [ { "text": "y", "kind": "var", "kindModifiers": "export" } ], "indent": 1 }, { "text": "A.B.C", "kind": "module", "childItems": [ { "text": "x", "kind": "var", "kindModifiers": "export" } ], "indent": 1 } ]);
{ "end_byte": 4780, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsModules1.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess30.ts_0_473
/// <reference path='fourslash.ts' /> //// const A = { //// /*a*/'a'/*b*/: 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: `const A = { /*RENAME*/"_a": 1, get "a"() { return this["_a"]; }, set "a"(value) { this["_a"] = value; }, };`, });
{ "end_byte": 473, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess30.ts" }
TypeScript/tests/cases/fourslash/renameStringLiteralOk.ts_0_239
/// <reference path='fourslash.ts'/> //// interface Foo { //// f: '[|foo|]' | 'bar' //// } //// const d: 'foo' = 'foo' //// declare const f: Foo //// f.f = '[|foo|]' //// f.f = `[|foo|]` verify.baselineRenameAtRangesWithText("foo");
{ "end_byte": 239, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameStringLiteralOk.ts" }
TypeScript/tests/cases/fourslash/codeFixConvertToMappedObjectType11.ts_0_526
/// <reference path='fourslash.ts' /> //// type K = "foo" | "bar"; //// interface Foo { } //// interface Bar<T> { bar: T; } //// interface SomeType<T> extends Foo, Bar<T> { //// a: number; //// b: T; //// readonly [prop: K]: any; //// } verify.codeFix({ description: `Convert 'SomeType' to mapped object type`, newFileContent: `type K = "foo" | "bar"; interface Foo { } interface Bar<T> { bar: T; } type SomeType<T> = Foo & Bar<T> & { readonly [prop in K]: any; } & { a: number; b: T; };` })
{ "end_byte": 526, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToMappedObjectType11.ts" }
TypeScript/tests/cases/fourslash/unusedVariableInModule1.ts_0_282
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @noUnusedParameters: true //// export {} //// [|var x: string; //// export var y: string;|] verify.codeFix({ description: "Remove unused declaration for: 'x'", newRangeContent: "export var y: string;", });
{ "end_byte": 282, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedVariableInModule1.ts" }
TypeScript/tests/cases/fourslash/overloadObjectLiteralCrash.ts_0_246
/// <reference path="fourslash.ts" /> //// interface Foo { //// extend<T>(...objs: any[]): T; //// extend<T>(deep, target: T): T; //// } //// var $: Foo; //// $.extend({ /**/foo: 0 }, ""); //// goTo.marker(); verify.quickInfoExists();
{ "end_byte": 246, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/overloadObjectLiteralCrash.ts" }
TypeScript/tests/cases/fourslash/completionsOverridingMethod20.ts_0_1281
/// <reference path="fourslash.ts" /> // @Filename: a.ts // @newline: LF //// abstract class AFoo { //// abstract bar(): Promise<void>; //// } //// class Foo extends AFoo { //// async b/*a*/ //// } verify.completions({ marker: "a", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, includes: [ { name: "bar", sortText: completion.SortText.LocationPriority, insertText: "async bar(): Promise<void> {\n}", filterText: "bar", replacementSpan: undefined, hasAction: true, source: completion.CompletionSource.ClassMemberSnippet, }, ] }); verify.applyCodeActionFromCompletion("a", { preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, name: "bar", source: completion.CompletionSource.ClassMemberSnippet, description: "Update modifiers of 'bar'", newFileContent: `abstract class AFoo { abstract bar(): Promise<void>; } class Foo extends AFoo { b }` });
{ "end_byte": 1281, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingMethod20.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesLoopBreakContinue5.ts_0_1853
/// <reference path='fourslash.ts' /> ////var arr = [1, 2, 3, 4]; ////label1: for (var n in arr) { //// break; //// continue; //// break label1; //// continue label1; //// //// label2: for (var i = 0; i < arr[n]; i++) { //// break label1; //// continue label1; //// //// break; //// continue; //// break label2; //// continue label2; //// //// function foo() { //// label3: while (true) { //// break; //// continue; //// break label3; //// continue label3; //// //// // these cross function boundaries //// break label1; //// continue label1; //// break label2; //// continue label2; //// //// label4: do { //// break; //// continue; //// break label4; //// continue label4; //// //// break label3; //// continue label3; //// //// switch (10) { //// case 1: //// case 2: //// break; //// break label4; //// default: //// continue; //// } //// //// // these cross function boundaries //// break label1; //// continue label1; //// break label2; //// continue label2; //// () => { break; } //// } while (true) //// } //// } //// } ////} //// ////label5: [|while|] (true) [|br/**/eak|] label5; //// ////label7: while (true) continue label5; verify.baselineDocumentHighlights();
{ "end_byte": 1853, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesLoopBreakContinue5.ts" }
TypeScript/tests/cases/fourslash/codeFixRemoveAccidentalCallParentheses.ts_0_859
/// <reference path='fourslash.ts' /> //// class Test24554 { //// get property(): number { return 1; } //// } //// function test24554(x: Test24554) { //// return x.property(); //// } //// function test_2(x: { y: Test24554 }) { //// return x.y.property ( /* bye */ ); //// } verify.codeFix({ description: "Remove parentheses", index: 0, newFileContent: `class Test24554 { get property(): number { return 1; } } function test24554(x: Test24554) { return x.property; } function test_2(x: { y: Test24554 }) { return x.y.property ( /* bye */ ); }` }); verify.codeFix({ description: "Remove parentheses", index: 1, newFileContent: `class Test24554 { get property(): number { return 1; } } function test24554(x: Test24554) { return x.property(); } function test_2(x: { y: Test24554 }) { return x.y.property; }` });
{ "end_byte": 859, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRemoveAccidentalCallParentheses.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType_js3.ts_0_428
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: a.js //// /** @type { /*a*/string | number/*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 | number} /*RENAME*/NewType */ /** @type { NewType } */ var x;`, });
{ "end_byte": 428, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType_js3.ts" }
TypeScript/tests/cases/fourslash/codeFixSpelling14.ts_0_581
/// <reference path='fourslash.ts' /> // @noImplicitOverride: true ////type Foo = abstract new(...args: any) => any; ////declare function CreateMixin<C extends Foo, T extends Foo>(Context: C, Base: T): T & { //// new (...args: any[]): { context: InstanceType<C> } ////} ////class Context {} ////class A { //// doSomething() {} ////} ////class B extends CreateMixin(Context, A) { //// override [|doSomethang|]() {} ////} verify.codeFix({ index: 0, description: [ts.Diagnostics.Change_spelling_to_0.message, "doSomething"], newRangeContent: "doSomething" });
{ "end_byte": 581, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpelling14.ts" }
TypeScript/tests/cases/fourslash/inlayHintsFunctionParameterTypes4.ts_0_377
/// <reference path="fourslash.ts" /> // @allowJs: true // @checkJs: true // @Filename: /a.js ////class Foo { //// #value = 0; //// get foo() { return this.#value; } //// /** //// * @param {number} value //// */ //// set foo(value) { this.#value = value; } ////} verify.baselineInlayHints(undefined, { includeInlayFunctionParameterTypeHints: true });
{ "end_byte": 377, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsFunctionParameterTypes4.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics19.ts_0_131
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: a.js ////enum E { } verify.baselineSyntacticDiagnostics();
{ "end_byte": 131, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics19.ts" }
TypeScript/tests/cases/fourslash/getOutliningSpansForUnbalancedEndRegion.ts_0_225
/// <reference path="fourslash.ts"/> ////// bottom-heavy region balance ////[|// #region matched //// ////// #endregion matched|] //// ////// #endregion unmatched verify.outliningSpansInCurrentFile(test.ranges(), "region");
{ "end_byte": 225, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOutliningSpansForUnbalancedEndRegion.ts" }
TypeScript/tests/cases/fourslash/docCommentTemplate_insideEmptyComment.ts_0_275
/// <reference path='fourslash.ts' /> /////** /**/ */ ////function f(p) { return p; } //// /////** Doc/*1*/ */ ////function g(p) { return p; } verify.docCommentTemplateAt("", /*newTextOffset*/ 7, `/** * * @param p * @returns */`); verify.noDocCommentTemplateAt("1");
{ "end_byte": 275, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplate_insideEmptyComment.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_withJson.ts_0_259
/// <reference path="fourslash.ts" /> // @Filename: /a.ts ////export const a = 'a'; // @Filename: /b.ts ////import "./anything.json"; //// ////a/**/ goTo.file("/b.ts"); verify.importFixAtPosition([`import { a } from "./a"; import "./anything.json"; a`]);
{ "end_byte": 259, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_withJson.ts" }
TypeScript/tests/cases/fourslash/quickInfoGenericTypeArgumentInference1.ts_0_1367
/// <reference path='fourslash.ts'/> ////module Underscore { //// export interface Iterator<T, U> { //// (value: T, index: any, list: any): U; //// } //// //// export interface Static { //// all<T>(list: T[], iterator?: Iterator<T, boolean>, context?: any): T; //// identity<T>(value: T): T; //// } ////} //// ////declare var _: Underscore.Static; ////var /*1*/r = _./*11*/all([true, 1, null, 'yes'], x => !x); ////var /*2*/r2 = _./*21*/all([true], _.identity); ////var /*3*/r3 = _./*31*/all([], _.identity); ////var /*4*/r4 = _./*41*/all([<any>true], _.identity); verify.quickInfos({ 1: "var r: string | number | boolean", 11: "(method) Underscore.Static.all<string | number | boolean>(list: (string | number | boolean)[], iterator?: Underscore.Iterator<string | number | boolean, boolean>, context?: any): string | number | boolean", 2: "var r2: boolean", 21: "(method) Underscore.Static.all<boolean>(list: boolean[], iterator?: Underscore.Iterator<boolean, boolean>, context?: any): boolean", 3: "var r3: any", 31: "(method) Underscore.Static.all<any>(list: any[], iterator?: Underscore.Iterator<any, boolean>, context?: any): any", 4: "var r4: any", 41: "(method) Underscore.Static.all<any>(list: any[], iterator?: Underscore.Iterator<any, boolean>, context?: any): any" }); verify.noErrors();
{ "end_byte": 1367, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoGenericTypeArgumentInference1.ts" }
TypeScript/tests/cases/fourslash/completionsImport_reExportDefault.ts_0_907
/// <reference path="fourslash.ts" /> // @module: esnext // @moduleResolution: node // @Filename: /a/b/impl.ts ////export default function foo() {} // @Filename: /a/index.ts ////export { default as foo } from "./b/impl"; // @Filename: /use.ts ////fo/**/ verify.completions({ marker: "", exact: completion.globalsPlus([ { name: "foo", source: "/a/b/impl", sourceDisplay: "./a", text: "function foo(): void", kind: "function", kindModifiers: "export", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, ]), preferences: { includeCompletionsForModuleExports: true }, }); verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a/b/impl", description: `Add import from "./a"`, newFileContent: `import { foo } from "./a"; fo`, });
{ "end_byte": 907, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_reExportDefault.ts" }
TypeScript/tests/cases/fourslash/extract-method-generics-inside-extraction1.ts_0_460
/// <reference path='fourslash.ts' /> ////function f() { //// let g = /*start*/<T>(x: T) => x/*end*/; //// return g; ////} goTo.select('start', 'end'); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "function_scope_1", actionDescription: "Extract to function in global scope", newContent: `function f() { let g = /*RENAME*/newFunction(); return g; } function newFunction() { return <T>(x: T) => x; } `});
{ "end_byte": 460, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method-generics-inside-extraction1.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationConditionalExpressions.ts_0_410
/// <reference path='fourslash.ts' /> // @BaselineFile: bpSpan_conditionalExpressions.baseline // @Filename: bpSpan_conditionalExpressions.ts ////var x = 10; ////var y = x ? x + 10 : 30; ////var z = (function foo() { //// return x; ////})() ? y : function bar() { //// return x; ////} (); ////x = y ? (function () { //// return z; ////})() : 10; verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 410, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationConditionalExpressions.ts" }
TypeScript/tests/cases/fourslash/findAllRefsReExports2.ts_0_216
/// <reference path="fourslash.ts" /> // @Filename: /a.ts ////export function /*1*/foo(): void {} // @Filename: /b.ts ////import { foo as oof } from "./a"; verify.noErrors(); verify.baselineFindAllReferences('1')
{ "end_byte": 216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsReExports2.ts" }
TypeScript/tests/cases/fourslash/completionAfterGlobalThis.ts_0_540
/// <reference path='fourslash.ts'/> ////globalThis./**/ verify.completions({ marker: "", unsorted: [ completion.globalThisEntry, ...completion.globalsVars, completion.undefinedVarEntry ].map(e => { if (e.sortText === completion.SortText.Deprecated(completion.SortText.GlobalsOrKeywords)) { return { ...e, sortText: completion.SortText.Deprecated(completion.SortText.LocationPriority) }; } return { ...e, sortText: completion.SortText.LocationPriority }; }) });
{ "end_byte": 540, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionAfterGlobalThis.ts" }
TypeScript/tests/cases/fourslash/addDeclareToFunction.ts_0_189
/// <reference path="fourslash.ts" /> //// /*1*/function parseInt(s/*2*/:string):number; goTo.marker('2'); edit.deleteAtCaret(':string'.length); goTo.marker('1'); edit.insert('declare ');
{ "end_byte": 189, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/addDeclareToFunction.ts" }
TypeScript/tests/cases/fourslash/stringLiteralCompletionsForStringEnumContextualType.ts_0_154
/// <reference path="fourslash.ts" /> ////const enum E { //// A = "A", ////} ////const e: E = "/**/"; verify.completions({ marker: "", exact: [] });
{ "end_byte": 154, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/stringLiteralCompletionsForStringEnumContextualType.ts" }
TypeScript/tests/cases/fourslash/findAllRefsEnumAsNamespace.ts_0_137
/// <reference path='fourslash.ts' /> /////*1*/enum /*2*/E { A } ////let e: /*3*/E.A; verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 137, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsEnumAsNamespace.ts" }
TypeScript/tests/cases/fourslash/smartIndentStatementWith.ts_0_302
/// <reference path='fourslash.ts'/> ////function Foo() { //// var obj = { a: 'foo' }; //// with (obj) { //// /*insideStatement*/ //// } //// /*afterStatement*/ ////} goTo.marker('insideStatement'); verify.indentationIs(8); goTo.marker('afterStatement'); verify.indentationIs(4);
{ "end_byte": 302, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentStatementWith.ts" }
TypeScript/tests/cases/fourslash/extract-const_jsxElement2.ts_0_570
/// <reference path='fourslash.ts' /> // @jsx: preserve // @filename: a.tsx ////function Foo() { //// return ( //// <div> //// /*a*/<span></span>/*b*/ //// </div> //// ); ////} goTo.file("a.tsx"); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "constant_scope_0", actionDescription: "Extract to constant in enclosing scope", newContent: `function Foo() { const /*RENAME*/newLocal = <span></span>; return ( <div> {newLocal} </div> ); }` });
{ "end_byte": 570, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const_jsxElement2.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType76.ts_0_401
/// <reference path='fourslash.ts' /> // @Filename: a.ts ////type Deep<T> = /*a*/{ [K in keyof T]: Deep<T[K]> }/*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> = { [K in keyof T]: Deep<T[K]>; }; type Deep<T> = NewType<T>`, });
{ "end_byte": 401, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType76.ts" }
TypeScript/tests/cases/fourslash/formattingOnConstructorSignature.ts_0_297
/// <reference path='fourslash.ts' /> /////*1*/interface Gourai { new () {} } /////*2*/type Stylet = { new () {} } format.document(); goTo.marker("1"); verify.currentLineContentIs("interface Gourai { new() { } }"); goTo.marker("2"); verify.currentLineContentIs("type Stylet = { new() { } }");
{ "end_byte": 297, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnConstructorSignature.ts" }
TypeScript/tests/cases/fourslash/parameterWithNestedDestructuring.ts_0_361
/// <reference path='fourslash.ts'/> ////[[{ a: 'hello', b: [1] }]] //// .map(([{ a, b: [c] }]) => /*1*/a + /*2*/c); ////function f([[/*3*/a]]: [[string]], { b1: { /*4*/b2 } }: { b1: { b2: string; } }) {} verify.quickInfos({ 1: "(parameter) a: string", 2: "(parameter) c: number", 3: "(parameter) a: string", 4: "(parameter) b2: string" });
{ "end_byte": 361, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/parameterWithNestedDestructuring.ts" }
TypeScript/tests/cases/fourslash/completionListInNamedClassExpression.ts_0_390
///<reference path="fourslash.ts" /> //// var x = class myClass { //// getClassName (){ //// m/*0*/ //// } //// /*1*/ //// } verify.completions( { marker: "0", includes: { name: "myClass", text: "(local class) myClass", kind: "local class" } }, { marker: "1", exact: completion.classElementKeywords, isNewIdentifierLocation: true, } );
{ "end_byte": 390, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInNamedClassExpression.ts" }
TypeScript/tests/cases/fourslash/findAllRefsDestructureGetter.ts_0_274
/// <reference path="fourslash.ts" /> ////class Test { //// get /*x0*/x() { return 0; } //// //// set /*y0*/y(a: number) {} ////} ////const { /*x1*/x, /*y1*/y } = new Test(); /////*x2*/x; /*y2*/y; verify.baselineFindAllReferences('x0', 'x1', 'x2', 'y0', 'y1', 'y2')
{ "end_byte": 274, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsDestructureGetter.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_all_prefix.ts_0_698
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @noUnusedParameters: true /////** //// * @param a First parameter. //// * @param b Second parameter. //// */ ////function f(a, b) { //// const x = 0; // Can't be prefixed, ignored ////} ////type Length<T> = T extends ArrayLike<infer U> ? number : never; verify.codeFixAll({ fixId: "unusedIdentifier_prefix", fixAllDescription: "Prefix all unused declarations with '_' where possible", newFileContent: `/** * @param _a First parameter. * @param _b Second parameter. */ function f(_a, _b) { const x = 0; // Can't be prefixed, ignored } type Length<T> = T extends ArrayLike<infer _U> ? number : never;`, });
{ "end_byte": 698, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_all_prefix.ts" }
TypeScript/tests/cases/fourslash/quickInfoParameter_skipThisParameter.ts_0_169
/// <reference path='fourslash.ts'/> ////function f(cb: (x: number) => void) {} ////f(function(this: any, /**/x) {}); verify.quickInfoAt("", "(parameter) x: number");
{ "end_byte": 169, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoParameter_skipThisParameter.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType27.ts_0_406
/// <reference path='fourslash.ts' /> //// type A<T, U> = /*a*/() => <T>(v: T) => (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<U> = () => <T>(v: T) => (v: T) => <T>(v: T) => U; type A<T, U> = NewType<U>;`, });
{ "end_byte": 406, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType27.ts" }
TypeScript/tests/cases/fourslash/mapCodeFocusLocationReplacement.ts_0_774
///<reference path="fourslash.ts"/> // @Filename: /index.ts //// function foo() { //// const x: number = 1; //// const y: number = 2; //// if (x === y) { //// console.log("hello"); //// console.log("world"); //// } //// return 1; //// } //// function bar() { //// const x: number = 1; //// const y: number = 2; //// if (x === y)[||] { //// console.log("x"); //// console.log("y"); //// } //// return 2; //// } //// function baz() { //// const x: number = 1; //// const y: number = 2; //// if (x === y) { //// console.log(x); //// console.log(y); //// } //// return 3; //// } //// verify.baselineMapCode([test.ranges()], [ ` if (x === y) { return x + y; } ` ]);
{ "end_byte": 774, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeFocusLocationReplacement.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_moveImport.ts_0_276
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////[|import { a, b } from "m"; ////let l; ////a;|] ////b; verify.moveToNewFile({ newFileContents: { "/a.ts": `import { b } from "m"; b;`, "/l.ts": `import { a } from "m"; let l; a; `, } });
{ "end_byte": 276, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_moveImport.ts" }
TypeScript/tests/cases/fourslash/codeFixClassExtendAbstractMethodModifiersAlreadyIncludeOverride.ts_0_649
/// <reference path='fourslash.ts' /> // @noImplicitOverride: true //// abstract class A { //// abstract foo(n: number | string): number | string; //// } //// //// abstract class B extends A { //// abstract override foo(n: number): number; //// } //// //// class C extends B { } verify.codeFix({ description: "Implement inherited abstract class", newFileContent: `abstract class A { abstract foo(n: number | string): number | string; } abstract class B extends A { abstract override foo(n: number): number; } class C extends B { override foo(n: number): number { throw new Error("Method not implemented."); } }`, });
{ "end_byte": 649, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassExtendAbstractMethodModifiersAlreadyIncludeOverride.ts" }
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts_0_495
/// <reference path='fourslash.ts' /> //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } //// //// f ` qwerty ${ 123 } asdf ${ 41234 } zxcvb ${ g `/*1*/ /*2*/ /*3*/` } ` verify.signatureHelp({ marker: test.markers(), text: "g(templateStrings: any, x: any, y: any, z: any): string", argumentCount: 1, parameterCount: 4, parameterName: "templateStrings", parameterSpan: "templateStrings: any", });
{ "end_byte": 495, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts" }
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateOnlyStr.ts_0_382
/// <reference path='fourslash.ts' /> //// const foo = "/*x*/f/*y*/oobar " + "rocks" + " fantastically" 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 rocks fantastically`", });
{ "end_byte": 382, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateOnlyStr.ts" }
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class13.ts_0_357
/// <reference path='fourslash.ts' /> // @allowNonTsExtensions: true // @Filename: foo.js ////function Foo() { //// this.a = 0; ////} ////Foo[`b`] = function () { ////} verify.codeFix({ description: "Convert function to an ES2015 class", newFileContent: `class Foo { constructor() { this.a = 0; } static b() { } } ` });
{ "end_byte": 357, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class13.ts" }
TypeScript/tests/cases/fourslash/quickInfoForDerivedGenericTypeWithConstructor.ts_0_356
/// <reference path='fourslash.ts'/> ////class A<T> { //// foo() { } ////} ////class B<T> extends A<T> { //// bar() { } //// constructor() { super() } ////} ////class B2<T> extends A<T> { //// bar() { } ////} ////var /*1*/b: B<number>; ////var /*2*/b2: B<number>; verify.quickInfos({ 1: "var b: B<number>", 2: "var b2: B<number>" });
{ "end_byte": 356, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForDerivedGenericTypeWithConstructor.ts" }
TypeScript/tests/cases/fourslash/smartIndentNestedModule.ts_0_433
/// <reference path='fourslash.ts'/> ////module Foo { //// module Foo2 { //// {| "indentation": 8 |} //// function f() { //// } //// {| "indentation": 8 |} //// var x: number; //// {| "indentation": 8 |} //// } //// {| "indentation": 4 |} ////} test.markers().forEach((marker) => { verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); });
{ "end_byte": 433, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentNestedModule.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_deleteWrite.ts_0_233
/// <reference path='fourslash.ts' /> // @noLib: true // @noUnusedLocals: true ////let x = 0; ////x = 1; ////export {}; verify.codeFix({ description: "Remove unused declaration for: 'x'", newFileContent: `export {};`, });
{ "end_byte": 233, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_deleteWrite.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageVariable.ts_0_221
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////[|var x;|] ////function f() { //// x++; ////} verify.rangeAfterCodeFix("var x: number;", /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, 0);
{ "end_byte": 221, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageVariable.ts" }
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction34.ts_0_471
/// <reference path='fourslash.ts' /> ////const a = /*a*/()/*b*/ => ( //// /* //// multi-line comment //// */ //// 1 ////); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Add or remove braces in an arrow function", actionName: "Add braces to arrow function", actionDescription: "Add braces to arrow function", newContent: `const a = () => { return ( /* multi-line comment */ 1 ); };`, });
{ "end_byte": 471, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction34.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionImplicitConstructor.ts_0_248
/// <reference path='fourslash.ts' /> ////class /*constructorDefinition*/ImplicitConstructor { ////} ////var implicitConstructor = new /*constructorReference*/ImplicitConstructor(); verify.baselineGetDefinitionAtPosition("constructorReference");
{ "end_byte": 248, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionImplicitConstructor.ts" }
TypeScript/tests/cases/fourslash/codeFixTopLevelAwait_target_noTsConfig.ts_0_161
/// <reference path="fourslash.ts" /> // @filename: /dir/a.ts ////declare const p: Promise<number>; ////await p; ////export {}; verify.not.codeFixAvailable();
{ "end_byte": 161, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelAwait_target_noTsConfig.ts" }
TypeScript/tests/cases/fourslash/completionListClassThisJS.ts_0_567
/// <reference path="fourslash.ts" /> // @Filename: completionListClassThisJS.js // @allowJs: true /////** @typedef {number} CallbackContext */ ////class Foo { //// bar() { //// this/**/ //// } //// /** @param {function (this: CallbackContext): any} cb */ //// baz(cb) { //// } ////} verify.completions({ marker: "", isNewIdentifierLocation: false, includes: [{ name: "this", // kind: "warning", kind: "keyword", sortText: completion.SortText.GlobalsOrKeywords, // sortText: completion.SortText.JavascriptIdentifiers, }] });
{ "end_byte": 567, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListClassThisJS.ts" }
TypeScript/tests/cases/fourslash/inlineVariableTemplateString4.ts_0_444
/// <reference path="fourslash.ts" /> ////const /*a*/pizza/*b*/ = "🍕"; ////export const prompt = `Hello, would you like some ${pizza} or ${pizza}?`; goTo.select("a", "b"); verify.refactorAvailable("Inline variable"); edit.applyRefactor({ refactorName: "Inline variable", actionName: "Inline variable", actionDescription: "Inline variable", newContent: "export const prompt = `Hello, would you like some 🍕 or 🍕?`;" });
{ "end_byte": 444, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableTemplateString4.ts" }
TypeScript/tests/cases/fourslash/findAllRefsDefinition.ts_0_117
/// <reference path='fourslash.ts' /> ////const /*1*/x = 0; /////*2*/x; verify.baselineFindAllReferences('1', '2')
{ "end_byte": 117, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsDefinition.ts" }
TypeScript/tests/cases/fourslash/renameModuleExportsProperties2.ts_3_199
/ <reference path='fourslash.ts' /> ////[|class [|{| "contextRangeIndex": 0 |}A|] {}|] ////module.exports = { B: [|A|] } const [r0Def, r0, r1] = test.ranges(); verify.baselineRename([r0, r1]);
{ "end_byte": 199, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameModuleExportsProperties2.ts" }
TypeScript/tests/cases/fourslash/completionsOverridingMethod2.ts_0_1655
/// <reference path="fourslash.ts" /> // @newline: LF // @Filename: a.ts // Case: Snippet text needs escaping ////interface DollarSign { //// "$usd"(a: number): number; //// $cad(b: number): number; //// cla$$y(c: number): number; //// isDollarAmountString(s: string): s is `$${number}` ////} ////class USD implements DollarSign { //// /*a*/ ////} verify.completions({ marker: "a", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: true, includeCompletionsWithClassMemberSnippets: true, }, includes: [ { name: "$usd", sortText: completion.SortText.LocationPriority, isSnippet: true, insertText: "\"\\$usd\"(a: number): number {\n $0\n}", filterText: "$usd", }, { name: "$cad", sortText: completion.SortText.LocationPriority, isSnippet: true, insertText: "\\$cad(b: number): number {\n $0\n}", filterText: "$cad", }, { name: "cla$$y", sortText: completion.SortText.LocationPriority, isSnippet: true, insertText: "cla\\$\\$y(c: number): number {\n $0\n}", filterText: "cla$$y", }, { name: "isDollarAmountString", sortText: completion.SortText.LocationPriority, isSnippet: true, insertText: "isDollarAmountString(s: string): s is `\\$\\${number}` {\n $0\n}", filterText: "isDollarAmountString", }, ], });
{ "end_byte": 1655, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingMethod2.ts" }
TypeScript/tests/cases/fourslash/tsxQuickInfo7.ts_3_1991
/ <reference path='fourslash.ts' /> //@Filename: file.tsx // @jsx: preserve // @noLib: true //// declare function OverloadComponent<U>(attr: {b: U, a?: string, "ignore-prop": boolean}): JSX.Element; //// declare function OverloadComponent<T, U>(attr: {b: U, a: T}): JSX.Element; //// declare function OverloadComponent(): JSX.Element; // effective argument type of `{}`, needs to be last //// function Baz<T extends {b: number}, U extends {a: boolean, b:string}>(arg1: T, arg2: U) { //// let a0 = <Overloa/*1*/dComponent {...arg1} a="hello" ignore-prop />; //// let a1 = <Overloa/*2*/dComponent {...arg2} ignore-pro="hello world" />; //// let a2 = <Overloa/*3*/dComponent {...arg2} />; //// let a3 = <Overloa/*4*/dComponent {...arg1} ignore-prop />; //// let a4 = <Overloa/*5*/dComponent />; //// let a5 = <Overloa/*6*/dComponent {...arg2} ignore-prop="hello" {...arg1} />; //// let a6 = <Overloa/*7*/dComponent {...arg1} ignore-prop {...arg2} />; //// } verify.quickInfos({ 1: "function OverloadComponent<number>(attr: {\n b: number;\n a?: string;\n \"ignore-prop\": boolean;\n}): JSX.Element (+2 overloads)", 2: "function OverloadComponent<boolean, string>(attr: {\n b: string;\n a: boolean;\n}): JSX.Element (+2 overloads)", 3: "function OverloadComponent<boolean, string>(attr: {\n b: string;\n a: boolean;\n}): JSX.Element (+2 overloads)", 4: "function OverloadComponent(): JSX.Element (+2 overloads)", // Subtype pass chooses this overload, since `a` is missing from the top overload, and `ignore-prop` is missing from the second (while T & {ignore-prop: true} is a proper subtype of `{}`) 5: "function OverloadComponent(): JSX.Element (+2 overloads)", 6: "function OverloadComponent<boolean, never>(attr: {\n b: never;\n a: boolean;\n}): JSX.Element (+2 overloads)", 7: "function OverloadComponent<boolean, never>(attr: {\n b: never;\n a: boolean;\n}): JSX.Element (+2 overloads)", });
{ "end_byte": 1991, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxQuickInfo7.ts" }
TypeScript/tests/cases/fourslash/navto_emptyPattern.ts_0_464
/// <reference path="fourslash.ts"/> // @filename: foo.ts //// const [|x: number = 1|]; //// [|function y(x: string): string { return x; }|] const [x, y] = test.ranges(); verify.navigateTo({ pattern: "", fileName: "foo.ts", expected: [{ name: "x", kind: "const", range: x, matchKind: "substring", }, { name: "y", kind: "function", range: y, matchKind: "substring", }], });
{ "end_byte": 464, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navto_emptyPattern.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType85.ts_0_408
/// <reference path='fourslash.ts' /> //// type A = { a: string } /*1*/| { b: string } | { c: string }/*2*/; 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; } | { c: string; }; type A = NewType;`, });
{ "end_byte": 408, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType85.ts" }
TypeScript/tests/cases/fourslash/jsQuickInfoGenerallyAcceptableSize.ts_0_7791
/// <reference path="fourslash.ts" /> // @allowJs: true // @checkJs: true // @Filename: index.js ////// Data table /////** //// @typedef DataTableThing //// @type {Object} //// @property {function(TagCollection, Location, string, string, Infotable):void} AddDataTableEntries - (arg0: tags, arg1: location, arg2: source, arg3: sourceType, arg4: values) Add multiple data table entries. //// @property {function(TagCollection, Location, string, string, Infotable):string} AddDataTableEntry - (arg0: tags, arg1: location, arg2: source, arg3: sourceType, arg4: values) Add a new data table entry. //// @property {function(TagCollection, Location, string, string, Infotable):void} AddOrUpdateDataTableEntries - (arg0: tags, arg1: location, arg2: source, arg3: sourceType, arg4: values) Add or update multiple data table entries. //// @property {function(TagCollection, Location, string, string, Infotable):string} AddOrUpdateDataTableEntry - (arg0: tags, arg1: location, arg2: source, arg3: sourceType, arg4: values) Add a new data table entry, or if it exists, update an existing entry. //// @property {function(TagCollection, Location, string, string, Infotable):void} AssignDataTableEntries - (arg0: tags, arg1: location, arg2: source, arg3: sourceType, arg4: values) Replaces existing data table entries. //// @property {function():Infotable} CreateValues - Create an empty info table of the correct datashape for this data table. //// @property {function(*):Infotable} CreateValuesWithData - (arg0: values as JSONObject) Create an info table of the correct datashape for this stream and include data values. //// @property {function(Infotable):void} DeleteDataTableEntries - (arg0: values as Infotable) Delete all table entries that match the provided values. //// @property {function(TagCollection, Location, string, string, Infotable, *):void} DeleteDataTableEntriesWithQuery - (arg0: tags, arg1: location, arg2: source, arg3: sourceType, arg4: values, arg5: query as JSONObject) Delete multiple data table entries based on a query. //// @property {function(Infotable):void} DeleteDataTableEntry - (arg0: values as Infotable) Delete an existing data table entry //// @property {function(string):void} DeleteDataTableEntryByKey - (arg0: key) Delete an existing data table entry using its key value. //// @property {function(Infotable):Infotable} FindDataTableEntries - (arg0: values as Infotable) Retrieve all table entries that match the provided values. //// @property {function():DataShapeDefinition} getDataShape //// @property {function():string} GetDataShape - Get the currently assigned data shape. //// @property {function():string} getDataShapeName //// @property {function(number):Infotable} GetDataTableEntries - (arg0: maxItems) Retrieve all table entries up to max items number. //// @property {function(Infotable):Infotable} GetDataTableEntry - (arg0: values as Infotable) Get an existing data table entry. //// @property {function(string):Infotable} GetDataTableEntryByKey - (arg0: key) Get an existing data table entry using its key value. //// @property {function():number} GetDataTableEntryCount - Get an count of data table entries. //// @property {function():ThingworxRelationshipTypes} getDataType //// @property {function():EntityReferenceTypeMap} getDependencies //// @property {function():IDataEntryCloseableIterator} getEntryIterator - Returns an iterator over all entries inside this data table thing. //// @property {function():Infotable} GetFieldNames - Retrieve a list of field names for the data shape associated with this stream. //// @property {function(string):Infotable} GetFieldNamesByType - (arg0: key) Retrieve a list of field names for the data shape associated with this stream, of a specific type. //// @property {function():string} getItemCollectionName //// @property {function():string} getItemEntityName //// @property {function():ThingworxRelationshipTypes} getItemEntityType //// @property {function():void} initializeEntity //// @property {function():void} initializeThing //// @property {function():boolean} isStoredAsEncrypted //// @property {function():void} PurgeDataTableEntries - Remove all data table entries. //// @property {function(Infotable, number, TagCollection, string, *):Infotable} QueryDataTableEntries - (arg0: values, arg1: maxItems, arg2: tags, arg3: source, arg4: query as JSONObject) Retrieve all table entries that match the query parameters. //// @property {function():void} Reindex - Reindex the custom indexes on the data table. //// @property {function(number, string, TagCollection, *, string):Infotable} SearchDataTableEntries - (arg0: maxItems, arg1: searchExpression, arg2: tags, arg3: query as JSONObject, arg4: source) Retrieve all table entries that match the search query parameters. //// @property {function(string):void} SetDataShape - (arg0: name) Sets the data shape. //// @property {function(TagCollection, Location, string, string, Infotable):void} UpdateDataTableEntries - (arg0: tags, arg1: location, arg2: source, arg3: sourceType, arg4: values) Update multiple data table entries. //// @property {function(TagCollection, Location, string, string, Infotable, *, Infotable):void} UpdateDataTableEntriesWithQuery - (arg0: tags, arg1: location, arg2: source, arg3: sourceType, arg4: values, arg5: query as JSONObject, arg6: updatValues) Add or update multiple data table entries based on a query. //// @property {function(TagCollection, Location, string, string, Infotable):void} UpdateDataTableEntry - (arg0: tags, arg1: location, arg2: source, arg3: sourceType, arg4: values) update an existing data table entry. //// @property {function(ImportedEntityCollection):void} validateConfiguration - (arg0: importedEntityCollections) ////*/ //// /////** //// @typedef Infotable //// @type {object} //// @property {boolean} isCompressed //// @property {DataShape} dataShape //// @property {function(FieldDefinition):int} addField - Adds a field to the DataShapeDefinition of this InfoTable, given a FieldDefinition //// @property {function(*):void} AddField - *FROM SNIPPET* adds a new field definition to the datashape (arg0 is an object that should match with datashape) //// @property {function(object):void} AddRow - *FROM SNIPPET* adds a row to the infotable (arg0 is an object that should match with datashape) //// @property {function(ValueCollection):int} addRow - Adds a row to this InfoTable's ValueCollectionList given a ValueCollection //// @property {ValueCollectionList} rows - returns the ValueCollectionList of the rows in this InfoTable //// @property {function(Infotable, boolean):int} addRowsFrom - Adds the rows from an InfoTable to this InfoTable given: the InfoTable to be copied from and a Boolean indicating whether the copied values should be references or cloned values. (arg 0: infotable, arg1: clone) //// @property {function():Infotable} clone //// @property {function():Infotable} cloneStructure //// @property {function():ValueCollection} currentRow - Returns the current row in this InfoTable as a ValueCollection //// @property {function(object):void} Delete - *FROM SNIPPET* delete rows by value filter (arg0 is an object that should match with datashape) //// @property {function(IFilter):int} delete //// @property {function(ValueCollection):int} delete - Creates an AndFilterCollection based on the given ValueCollection and deletes all rows falling within the parameters of that filter //// @property {function(IFilter):Infotable} deleteRowsToNewTable //// @property {function(object):void} Filter - *FROM SNIPPET* filters the infotable (arg0 is an object that should match with datashape)
{ "end_byte": 7791, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsQuickInfoGenerallyAcceptableSize.ts" }
TypeScript/tests/cases/fourslash/jsQuickInfoGenerallyAcceptableSize.ts_7792_16289
//// @property {function(ValueCollection):void} filter - Creates an AndFilterCollection based on the given ValueCollection and applies it to this InfoTable //// @property {function(IFilter):void} filterRows //// @property {function(IFilter):Infotable} filterRowsToNewTable //// @property {function(*):Infotable} FilterToNewTable - Finds rows in this InfoTable with values that match the values given as a JSONObject and returns them as a new InfoTable //// @property {function(object):void} Find - *FROM SNIPPET* retrieve rows by value filter (arg0 is an object that should match with datashape) //// @property {function(IFilter):ValueCollection} find - Finds and returns a row from this InfoTable that falls within the parameters of the given IFilter //// @property {function(ValueCollection):ValueCollection} find - Finds and returns a row from this InfoTable that matches the values of all fields given as a (ValueCollection) //// @property {function(ValueCollection, string[]):ValueCollection} find - Finds and returns a row in this InfoTable given the fields to search as a String Array and the values to match as a ( ValueCollection) //// @property {function(ValueCollection):int} findIndex - Finds and returns the index of a row from this InfoTable that matches the values of all fields given as a ( ValueCollection) //// @property {function(*):Infotable} fromJSON //// @property {function():DataShapeDefinition} getDataShape - Returns the DataShapeDefinition for this InfoTable //// @property {function(string):FieldDefinition} getField - Returns a FieldDefinition from this InfoTable's DataShapeDefinition, given the name of the field as a String //// @property {function():int} getFieldCount - Returns the number of fields in this InfoTable's DataShape as an int //// @property {function():ValueCollection} getFirstRow - Returns the first row (ValueCollection) of this InfoTable //// @property {function():InfoTableRowIndex} getIndex - //// @property {function():ValueCollection} getLastRow - Returns the last row in this InfoTable as a ValueCollection //// @property {function():number} getLength - Returns the number of rows in this InfoTable as an Integer //// @property {function():DataShapeDefinition} getPublicDataShape - Returns a DataShapeDefinition for this InfoTable containing only the public fields //// @property {function():*} getReturnValue - Returns the first value of the first field in the first row of this InfoTable //// @property {function(number):ValueCollection} getRow - *FROM SNIPPET* retrieves a row by index //// @property {function():number} getRowCount - *FROM SNIPPET* gets the count of rows //// @property {function():ValueCollectionList} getRows - Returns a ValueCollectionList of the rows in this InfoTable //// @property {function(string):IPrimitiveType} getRowValue - Returns a value as an IPrimitiveType from the first row of this InfoTable, given a field name as a String //// @property {function(string):boolean} hasField - Verifies a field exists in this InfoTable's DataShape given the field name as a String //// @property {function(string[],boolean):void} indexOn //// @property {function(string, boolean):void} indexOn //// @property {function():boolean} isEmpty - Returns a boolean indicating whether this InfoTable has a size of zero //// @property {function(BaseTypes):boolean} isType //// @property {function():void} moveToFirst - Moves to the first row of this InfoTable. //// @property {function():ValueCollection} nextRow - Returns the row after the current row in this InfoTable as a ValueCollection //// @property {function(string):void} quickSort - (arg0: fieldName) //// @property {function(string, boolean):void} quickSort - (arg0: fieldName, arg1: isAscending) //// @property {function():void} RemoveAllRows - *FROM SNIPPET* remove all rows from infotable //// @property {function():void} removeAllRows - remove all rows from infotable //// @property {function(string):void} RemoveField - *FROM SNIPPET* remove a datashape field by name //// @property {function(number):void} RemoveRow - *FROM SNIPPET* removes a row by index //// @property {function(number):void} removeRow - Removes a ValueCollection from the InfoTable given the row as an int //// @property {function(DataShapeDefinition):void} setDataShape - Sets DataShapeDefinition for this InfoTable //// @property {function():void} setRow - Sets a single row in this InfoTable given a ValueCollection as a row and the index of the row to be replaced //// @property {function(ValueCollectionList):void} setRows - Sets the rows in this InfoTable given a ValueCollectionList //// @property {function(Sort):void} Sort - *FROM SNIPPET* sorts the table //// @property {function(ISort):void} sortRows //// @property {function():Infotable} sortRowsToNewTable //// @property {function():*} toJSON //// @property {function():JsonInfotable} ToJSON - *FROM SNIPPET* returns the table as JsonInfotable //// @property {function(number):void} topN - (arg0: maxItems) //// @property {function(number):Infotable} topNToNewTable - (arg0: maxItems) //// @property {function(IFIlter, ValueCollection):Infotable} updateRowsToNewTable - (arg0: filters, arg1: values) ////*/ //// /////** //// @typedef DataShapeDefinition //// @type {object} //// @property {function(FieldDefinition):void} addFieldDefinition - Adds a new field definition to this data shape definition. //// @property {function():DataShapeDefinition} clone - Creates a deep clone of this data shape definition //// @property {function():FieldDefinition} getFieldDefinition - Returns the field definition with the specified name. //// @property {function():FieldDefinitionCollection} getFields - Returns the collection of field definitions belonging to this data shape definition. //// @property {function():boolean} hasField - Tests if the field named exists in this definition. //// @property {function():boolean} hasPrimaryKey - Tests if this definition contains any fields that are designated as primary keys. //// @property {function():boolean} matches - Determines if this data shape definition has the same fields with the same base types as the provided data shape definition. //// @property {function():void} setFields - Replaces the fields belonging to this data shape definition with the fields provided in the specified collection. //// @property {function():*} toJSON - Serializes this data shape definition into JSON format. ////*/ //// /////** //// @typedef FieldDefinition //// @type {object} //// @property {function(AspectCollection):boolean} aspectsMatch - Determines whether or not the aspects assigned to this field are equivalent to the aspects in the provided collection. //// @property {function():FieldDefinition} clone - Creates a deep clone of this field definition. //// @property {function():AspectCollection} getAspects - Returns the collection of aspects belonging to this field. //// @property {function():BaseTypes} getBaseType - Returns the base type assigned to this field. //// @property {function():string} getDataShapeName - Returns the data shape name assigned to the ASPECT_DATASHAPE aspect, if the base type for this field is set to INFOTABLE. //// @property {function():IPrimitiveType} getDefaultValue - Returns the default value assigned to this field, if one has been defined according to the ASPECT_DEFAULTVALUE aspect. //// @property {function():number} getOrdinal - Returns the ordinal value assigned to this field. //// @property {function():boolean} hasDataShape - Determines if, when the base type of this field is an INFOTABLE, a data shape has been assigned. //// @property {function():boolean} hasDefaultValue - Determines if this field has a default value according to the ASPECT_DEFAULTVALUE aspect. //// @property {function():boolean} isDataTableEntry - Determines if, when the base type of this field is an INFOTABLE, the contents of the info table will be derived from a data table entry. //// @property {function():boolean} isPrimaryKey - Determines if this field has the ASPECT_ISPRIMARYKEY aspect set to true. //// @property {function():boolean} isPrivate - Determines if this field has the ASPECT_ISPRIVATE aspect set to true. //// @property {function():boolean} isRequired - Determines if this field has the ASPECT_ISREQUIRED aspect set to true.
{ "end_byte": 16289, "start_byte": 7792, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsQuickInfoGenerallyAcceptableSize.ts" }
TypeScript/tests/cases/fourslash/jsQuickInfoGenerallyAcceptableSize.ts_16290_19096
//// @property {function():boolean} isStreamEntry - Determines if, when the base type of this field is an INFOTABLE, the contents of the info table will be derived from a stream entry. //// @property {function(AspectCollection):void} setAspects - Replaces all aspects on this field with the aspects in the specified collection. //// @property {function(BaseTypes):void} setBaseType - Assigns the specified base type to this field. //// @property {function(number):void} setOrdinal - Sets the ordinal value for this field. ////*/ //// /////** //// @typedef ValueCollectionList //// @type {ArrayList} //// @property {function():Infotable} convertToTypedInfoTable //// @property {function():ValueCollection} currentRow //// @property {function(ValueCollection):ValueCollection} find - arg0: values //// @property {function(ValueCollection, string[]):ValueCollection} find - arg0: values, arg1: columns //// @property {function(ValueCollection):number} findIndex //// @property {function():ValueCollection} getFirstRow //// @property {function():ValueCollection} getLastRow //// @property {function():number} getLength //// @property {function(number):ValueCollection} getRow - arg0: index //// @property {function():number} getRowCount //// @property {function(string):IPrimitiveType} getRowValue - arg0: name //// @property {function():void} moveToFirst //// @property {function():ValueCollection} nextRow ////*/ //// /////** //// @typedef ValueCollection //// @type {NamedObject} //// @property {function():ValueCollection} clone //// @property {function(*,DataShapeDefinition):ValueCollection} fromJSONTyped //// @property {function(string):*} getJSONSerializedValue //// @property {function(string):IPrimitiveType} getPrimitive //// @property {function(string):string} getStringValue //// @property {function(string):*} getValue //// @property {function(string):boolean} has //// @property {function(ValueCollection):boolean} matches //// @property {function():Infotable} toInfoTable //// @property {function():*} toJSON //// @property {function(DataShapeDefinition):*} toJSONTyped //// @property {function():NamedValueCollection} toNamedValueCollection ////*/ //// //// /////** //// * Do something //// * @param {DataTableThing} dataTable //// */ ////var doSome/*1*/thing = function (dataTable) { ////}; //// /////** //// * @callback SomeCallback //// * @param {number} foo //// * @param {string} bar //// */ //// //// /** //// * Another thing //// * @type {SomeCallback} //// */ ////var anotherThing/*2*/ = function(a, b) {} verify.quickInfoAt("1", "var doSomething: (dataTable: DataTableThing) => void", "Do something"); verify.quickInfoAt("2", "var anotherThing: SomeCallback", "Another thing");
{ "end_byte": 19096, "start_byte": 16290, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsQuickInfoGenerallyAcceptableSize.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedLabel.ts_0_309
/// <reference path='fourslash.ts' /> /////* a */[|label|]/* b */:/* c */while (1) {} verify.getSuggestionDiagnostics([{ message: "Unused label.", code: 7028, reportsUnnecessary: true, }]); verify.codeFix({ description: "Remove unused label", newFileContent: `/* a */while (1) {}`, });
{ "end_byte": 309, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedLabel.ts" }
TypeScript/tests/cases/fourslash/tsxCompletion3.ts_0_284
/// <reference path='fourslash.ts' /> //@Filename: file.tsx //// declare module JSX { //// interface Element { } //// interface IntrinsicElements { //// div: { one; two; } //// } //// } //// <div one={1} /**//>; verify.completions({ marker: "", exact: "two" });
{ "end_byte": 284, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletion3.ts" }
TypeScript/tests/cases/fourslash/goToImplementationLocal_02.ts_0_174
/// <reference path='fourslash.ts'/> //// const x = { [|hello|]: () => {} }; //// //// x.he/*function_call*/llo(); //// verify.baselineGoToImplementation("function_call");
{ "end_byte": 174, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationLocal_02.ts" }
TypeScript/tests/cases/fourslash/completionAmbientPropertyDeclaration.ts_0_330
/// <reference path="fourslash.ts" /> //// class C { //// /*1*/ declare property: number; //// /*2*/ //// } verify.completions({marker: "1", exact: completion.classElementKeywords, isNewIdentifierLocation: true}); verify.completions({marker: "2", exact: completion.classElementKeywords, isNewIdentifierLocation: true});
{ "end_byte": 330, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionAmbientPropertyDeclaration.ts" }
TypeScript/tests/cases/fourslash/formattingOnSemiColon.ts_0_153
/// <reference path='fourslash.ts' /> ////var a=b+c^d-e*++f goTo.eof(); edit.insert(";"); verify.currentFileContentIs("var a = b + c ^ d - e * ++f;");
{ "end_byte": 153, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnSemiColon.ts" }
TypeScript/tests/cases/fourslash/localGetReferences.ts_0_4506
/// <reference path='fourslash.ts'/> // @Filename: localGetReferences_1.ts ////// Comment Refence Test: g/*43*/lobalVar ////// References to a variable declared in global. /////*1*/var /*2*/globalVar: number = 2; //// ////class fooCls { //// // References to static variable declared in a class. //// /*3*/static /*4*/clsSVar = 1; //// // References to a variable declared in a class. //// /*5*/clsVar = 1; //// //// constructor (/*6*/public /*7*/clsParam: number) { //// //Increments //// /*8*/globalVar++; //// this./*9*/clsVar++; //// fooCls./*10*/clsSVar++; //// // References to a class parameter. //// this./*11*/clsParam++; //// modTest.modVar++; //// } ////} //// ////// References to a function parameter. /////*12*/function /*13*/foo(/*14*/x: number) { //// // References to a variable declared in a function. //// /*15*/var /*16*/fnVar = 1; //// //// //Increments //// fooCls./*17*/clsSVar++; //// /*18*/globalVar++; //// modTest.modVar++; //// /*19*/fnVar++; //// //// //Return //// return /*20*/x++; ////} //// ////module modTest { //// //Declare //// export var modVar:number; //// //// //Increments //// /*21*/globalVar++; //// fooCls./*22*/clsSVar++; //// modVar++; //// //// class testCls { //// static boo = /*23*/foo; //// } //// //// function testFn(){ //// static boo = /*24*/foo; //// //// //Increments //// /*25*/globalVar++; //// fooCls./*26*/clsSVar++; //// modVar++; //// } //// //// module testMod { //// var boo = /*27*/foo; //// } ////} //// //////Type test ////var clsTest: fooCls; //// //////Arguments ////// References to a class argument. ////clsTest = new fooCls(/*28*/globalVar); ////// References to a function argument. /////*29*/foo(/*30*/globalVar); //// //////Increments ////fooCls./*31*/clsSVar++; ////modTest.modVar++; /////*32*/globalVar = /*33*/globalVar + /*34*/globalVar; //// //////ETC - Other cases /////*35*/globalVar = 3; ////// References to illegal assignment. /////*36*/foo = /*37*/foo + 1; /////*44*/err = err++; /////*45*/ //////Shadowed fn Parameter ////function shdw(/*38*/globalVar: number) { //// //Increments //// /*39*/globalVar++; //// return /*40*/globalVar; ////} //// //////Remotes //////Type test ////var remoteclsTest: remotefooCls; //// //////Arguments ////remoteclsTest = new remotefooCls(remoteglobalVar); ////remotefoo(remoteglobalVar); //// //////Increments ////remotefooCls.remoteclsSVar++; ////remotemodTest.remotemodVar++; ////remoteglobalVar = remoteglobalVar + remoteglobalVar; //// //////ETC - Other cases ////remoteglobalVar = 3; //// //////Find References misses method param ////var //// //// //// //// array = ["f", "o", "o"]; //// ////array.forEach( //// //// ////function(/*41*/str) { //// //// //// //// // Reference misses function parameter. //// return /*42*/str + " "; //// ////}); // @Filename: localGetReferences_2.ts ////var remoteglobalVar: number = 2; //// ////class remotefooCls { //// //Declare //// remoteclsVar = 1; //// static remoteclsSVar = 1; //// //// constructor(public remoteclsParam: number) { //// //Increments //// remoteglobalVar++; //// this.remoteclsVar++; //// remotefooCls.remoteclsSVar++; //// this.remoteclsParam++; //// remotemodTest.remotemodVar++; //// } ////} //// ////function remotefoo(remotex: number) { //// //Declare //// var remotefnVar = 1; //// //// //Increments //// remotefooCls.remoteclsSVar++; //// remoteglobalVar++; //// remotemodTest.remotemodVar++; //// remotefnVar++; //// //// //Return //// return remotex++; ////} //// ////module remotemodTest { //// //Declare //// export var remotemodVar: number; //// //// //Increments //// remoteglobalVar++; //// remotefooCls.remoteclsSVar++; //// remotemodVar++; //// //// class remotetestCls { //// static remoteboo = remotefoo; //// } ////` //// function remotetestFn(){ //// static remoteboo = remotefoo; //// //// //Increments //// remoteglobalVar++; //// remotefooCls.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', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45');
{ "end_byte": 4506, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/localGetReferences.ts" }
TypeScript/tests/cases/fourslash/cloduleAsBaseClass2.ts_0_1075
/// <reference path='fourslash.ts'/> // @Filename: cloduleAsBaseClass2_0.ts ////class A { //// constructor(x: number) { } //// foo() { } //// static bar() { } ////} //// ////module A { //// export var x = 1; //// export function baz() { } ////} //// ////export = A; // @Filename: cloduleAsBaseClass2_1.ts ////import B = require('./cloduleAsBaseClass2_0'); ////class D extends B { //// constructor() { //// super(1); //// } //// foo2() { } //// static bar2() { } ////} //// ////var d: D; ////d./*1*/ ////D./*2*/ verify.completions({ marker: "1", exact: ["foo", "foo2"] }); edit.insert('foo()'); verify.completions({ marker: "2", includes: [ { name: "bar", sortText: completion.SortText.LocalDeclarationPriority }, { name: "bar2", sortText: completion.SortText.LocalDeclarationPriority }, { name: "baz", sortText: completion.SortText.LocationPriority }, { name: "x", sortText: completion.SortText.LocationPriority } ], excludes: ["foo", "foo2"] }); edit.insert('bar()'); verify.noErrors();
{ "end_byte": 1075, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/cloduleAsBaseClass2.ts" }
TypeScript/tests/cases/fourslash/completionsOverridingMethod14.ts_0_690
/// <reference path="fourslash.ts" /> // @Filename: a.ts // @strictNullChecks: true // @newline: LF ////interface IFoo { //// foo?(arg: string): number; ////} ////class Foo implements IFoo { //// /**/ ////} verify.completions({ marker: "", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, includes: [ { name: "foo", sortText: completion.SortText.LocationPriority, insertText: "foo(arg: string): number {\n}", filterText: "foo", }, ], });
{ "end_byte": 690, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingMethod14.ts" }
TypeScript/tests/cases/fourslash/codefixUnreferenceableDecoratorMetadata3.ts_0_1389
/// <reference path="fourslash.ts" /> // @isolatedModules: true // @module: es2015 // @experimentalDecorators: true // @emitDecoratorMetadata: true // @Filename: /mod.ts //// export default interface I1 {} //// export interface I2 {} //// export class C1 {} // @Filename: /index.ts //// import I1, { I2 } from "./mod"; //// //// declare var EventListener: any; //// export class HelloWorld { //// @EventListener("1") //// p1!: I1; //// p2!: I2; //// } // @Filename: /index2.ts //// import { C1, I2 } from "./mod"; //// //// declare var EventListener: any; //// export class HelloWorld { //// @EventListener("1") //// p1!: I2; //// p2!: C1; //// } 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.not.codeFixAvailable(); // Mostly verifying that the type-only fix is not available // (if both were available you'd have to specify `index` // in `verify.codeFix`). goTo.file("/index2.ts"); verify.codeFix({ 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; export class HelloWorld { @EventListener("1") p1!: mod.I2; p2!: mod.C1; }`, });
{ "end_byte": 1389, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codefixUnreferenceableDecoratorMetadata3.ts" }
TypeScript/tests/cases/fourslash/codeFixClassExtendAbstractMethod_comment.ts_0_447
/// <reference path='fourslash.ts' /> // @noImplicitOverride: true ////abstract class A { //// abstract m() : void; ////} //// ////class B extends A { //// // comment ////} verify.codeFix({ description: "Implement inherited abstract class", newFileContent: `abstract class A { abstract m() : void; } class B extends A { override m(): void { throw new Error("Method not implemented."); } // comment }`, });
{ "end_byte": 447, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassExtendAbstractMethod_comment.ts" }
TypeScript/tests/cases/fourslash/jsxAttributeCompletionStyleBraces.ts_0_2232
/// <reference path="fourslash.ts" /> // @Filename: foo.tsx //// declare namespace JSX { //// interface Element { } //// interface IntrinsicElements { //// foo: { //// prop_a: boolean; //// prop_b: string; //// prop_c: any; //// prop_d: { p1: string; } //// prop_e: string | undefined; //// prop_f: boolean | undefined | { p1: string; }; //// prop_g: { p1: string; } | undefined; //// prop_h?: string; //// prop_i?: boolean; //// prop_j?: { p1: string; }; //// } //// } //// } //// //// <foo [|prop_/**/|] /> verify.completions({ marker: "", exact: [ { name: "prop_a", insertText: "prop_a={$1}", isSnippet: true, }, { name: "prop_b", insertText: "prop_b={$1}", isSnippet: true, }, { name: "prop_c", insertText: "prop_c={$1}", isSnippet: true, }, { name: "prop_d", insertText: "prop_d={$1}", isSnippet: true, }, { name: "prop_e", insertText: "prop_e={$1}", isSnippet: true, }, { name: "prop_f", insertText: "prop_f={$1}", isSnippet: true, }, { name: "prop_g", insertText: "prop_g={$1}", isSnippet: true, }, { name: "prop_h", insertText: "prop_h={$1}", isSnippet: true, sortText: completion.SortText.OptionalMember, }, { name: "prop_i", insertText: "prop_i={$1}", isSnippet: true, sortText: completion.SortText.OptionalMember, }, { name: "prop_j", insertText: "prop_j={$1}", isSnippet: true, sortText: completion.SortText.OptionalMember, } ], preferences: { jsxAttributeCompletionStyle: "braces", includeCompletionsWithSnippetText: true, includeCompletionsWithInsertText: true, } });
{ "end_byte": 2232, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsxAttributeCompletionStyleBraces.ts" }
TypeScript/tests/cases/fourslash/autoImportAllowImportingTsExtensionsPackageJsonImports2.ts_0_740
/// <reference path="fourslash.ts" /> // @Filename: /tsconfig.json //// { //// "compilerOptions": { //// "module": "nodenext", //// "allowImportingTsExtensions": true, //// "rootDir": "src", //// "outDir": "dist", //// "declarationDir": "types", //// "declaration": true //// } //// } // @Filename: /package.json //// { //// "name": "self", //// "type": "module", //// "imports": { //// "#*": { //// "types": "./types/*", //// "default": "./dist/*" //// } //// } //// } // @Filename: /src/add.ts //// export function add(a: number, b: number) {} // @Filename: /src/index.ts //// add/*imports*/; //// external/*exports*/; verify.importFixModuleSpecifiers("imports", ["#add.js"]);
{ "end_byte": 740, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportAllowImportingTsExtensionsPackageJsonImports2.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptQuickInfo3.ts_0_207
/// <reference path='fourslash.ts'/> // @allowNonTsExtensions: true // @Filename: Foo.js /////** @param {number[]} [a] */ ////function /**/f(a) { } verify.quickInfoAt("", "function f(a?: number[]): void");
{ "end_byte": 207, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptQuickInfo3.ts" }
TypeScript/tests/cases/fourslash/completionsLiteralOverload.ts_0_737
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: /a.tsx //// interface Events { //// "": any; //// drag: any; //// dragenter: any; //// } //// declare function addListener<K extends keyof Events>(type: K, listener: (ev: Events[K]) => any): void; //// //// declare function ListenerComponent<K extends keyof Events>(props: { type: K, onWhatever: (ev: Events[K]) => void }): JSX.Element; //// //// addListener("/*ts*/"); //// (<ListenerComponent type="/*tsx*/" />); // @Filename: /b.js //// addListener("/*js*/"); verify.completions({ marker: ["ts", "tsx", "js"], exact: ["", "drag", "dragenter"] }); edit.insert("drag"); verify.completions({ marker: ["ts", "tsx", "js"], exact: ["", "drag", "dragenter"] });
{ "end_byte": 737, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsLiteralOverload.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingMember13.ts_0_270
/// <reference path='fourslash.ts' /> //// class C {} //// const x: number = new C().x; verify.codeFix({ description: "Add index signature for property 'x'", index: 1, newFileContent: `class C { [x: string]: number; } const x: number = new C().x;` });
{ "end_byte": 270, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember13.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports50-generics-with-default.ts_0_344
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true // @lib: es2015 ////let x: Iterator<number>; ////export const y = x; verify.codeFix({ description: "Add annotation of type 'Iterator<number>'", index: 0, newFileContent: `let x: Iterator<number>; export const y: Iterator<number> = x;`, });
{ "end_byte": 344, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports50-generics-with-default.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts_0_386
/// <reference path='fourslash.ts' /> ////interface I { //// f<T extends number>(x: T): T; ////} ////class C implements I {} verify.codeFix({ description: "Implement interface 'I'", newFileContent: `interface I { f<T extends number>(x: T): T; } class C implements I { f<T extends number>(x: T): T { throw new Error("Method not implemented."); } }`, });
{ "end_byte": 386, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts" }