_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/refactorKind_extract.ts_0_338
/// <reference path='fourslash.ts' /> //// const foo: /*a*/string/*b*/ = /*c*/1/*d*/; goTo.select("a", "b"); verify.refactorKindAvailable("refactor.extract", [ "refactor.extract.type" ]); goTo.select("c", "d"); verify.refactorKindAvailable("refactor.extract", [ "refactor.extract.constant", "refactor.extract.function" ]);
{ "end_byte": 338, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorKind_extract.ts" }
TypeScript/tests/cases/fourslash/codeFixCannotFindModule_suggestion.ts_0_690
/// <reference path='fourslash.ts' /> // @moduleResolution: node // @Filename: /node_modules/abs/subModule.js ////export const x = 0; // @Filename: /a.ts ////import * as abs from [|"abs/subModule"|]; ////abs; test.setTypesRegistry({ "abs": undefined, }); verify.noErrors(); goTo.file("/a.ts"); verify.getSuggestionDiagnostics([{ message: "Could not find a declaration file for module 'abs/subModule'. '/node_modules/abs/subModule.js' implicitly has an 'any' type.", code: 7016, }]); verify.codeFixAvailable([{ description: "Install '@types/abs'", commands: [{ type: "install package", file: "/a.ts", packageName: "@types/abs", }], }]);
{ "end_byte": 690, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCannotFindModule_suggestion.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsage_noCrashOnMissingParens.ts_0_276
/// <reference path='fourslash.ts' /> // @noImplicitAny: true // @target: esnext ////class C { //// m() { this.x * 2; } //// get x { return null; } ////} // Just testing that we don't crash in `insertTypeAnnotation` from inferFromUsage verify.not.codeFixAvailable();
{ "end_byte": 276, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsage_noCrashOnMissingParens.ts" }
TypeScript/tests/cases/fourslash/findAllRefsMappedType_nonHomomorphic.ts_0_188
/// <reference path="fourslash.ts" /> // @strict: true ////function f(x: { [K in "m"]: number; }) { //// x./*1*/m; //// x./*2*/m ////} verify.baselineFindAllReferences('1', '2');
{ "end_byte": 188, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsMappedType_nonHomomorphic.ts" }
TypeScript/tests/cases/fourslash/completionListNewIdentifierVariableDeclaration.ts_0_177
/// <reference path='fourslash.ts' /> ////var y : (s:string, list/*2*/ // Parameter name verify.completions({ marker: "2", exact: undefined, isNewIdentifierLocation: true });
{ "end_byte": 177, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListNewIdentifierVariableDeclaration.ts" }
TypeScript/tests/cases/fourslash/inlayHintsInteractiveFunctionParameterTypes3.ts_0_501
/// <reference path="fourslash.ts" /> ////interface IFoo { //// bar(x?: boolean): void; ////} //// ////const a: IFoo = { //// bar: function (x?): void { //// throw new Error("Function not implemented."); //// } ////} ////class Foo { //// #value = 0; //// get foo(): number { return this.#value; } //// set foo(value) { this.#value = value; } ////} verify.baselineInlayHints(undefined, { includeInlayFunctionParameterTypeHints: true, interactiveInlayHints: true });
{ "end_byte": 501, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveFunctionParameterTypes3.ts" }
TypeScript/tests/cases/fourslash/symbolNameAtUnparseableFunctionOverload.ts_0_291
/// <reference path="fourslash.ts" /> //// class TestClass { //// public function foo(x: string): void; //// public function foo(): void; //// foo(x: any): void { //// this.bar(/**/x); // should not error //// } //// } //// goTo.marker(); verify.quickInfoExists();
{ "end_byte": 291, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/symbolNameAtUnparseableFunctionOverload.ts" }
TypeScript/tests/cases/fourslash/functionIndentation.ts_0_1240
/// <reference path="fourslash.ts"/> ////module M { ////export = ////C; ////class C { ////constructor(b ////) { ////} ////foo(a ////: string) { ////return a ////|| true; ////} ////get bar( ////) { ////return 1; ////} ////} ////function foo(a, ////b?) { ////new M.C( ////"hello"); ////} ////{ ////{ ////} ////} ////foo( ////function() { ////"hello"; ////}); ////foo( ////() => { ////"hello"; ////}); ////var t, ////u = 1, ////v; ////} format.document(); verify.currentFileContentIs( "module M {\n" + " export =\n" + " C;\n" + " class C {\n" + " constructor(b\n" + " ) {\n" + " }\n" + " foo(a\n" + " : string) {\n" + " return a\n" + " || true;\n" + " }\n" + " get bar(\n" + " ) {\n" + " return 1;\n" + " }\n" + " }\n" + " function foo(a,\n" + " b?) {\n" + " new M.C(\n" + " \"hello\");\n" + " }\n" + " {\n" + " {\n" + " }\n" + " }\n" + " foo(\n" + " function() {\n" + " \"hello\";\n" + " });\n" + " foo(\n" + " () => {\n" + " \"hello\";\n" + " });\n" + " var t,\n" + " u = 1,\n" + " v;\n" + "}");
{ "end_byte": 1240, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/functionIndentation.ts" }
TypeScript/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts_0_624
/// <reference path='fourslash.ts'/> ////interface IFoo { /*xy*/xy: number; } //// ////// Assignment ////var a1: IFoo = { xy: 0 }; ////var a2: IFoo = { xy: 0 }; //// ////// Function call ////function consumer(f: IFoo) { } ////consumer({ xy: 1 }); //// ////// Type cast ////var c = <IFoo>{ xy: 0 }; //// ////// Array literal ////var ar: IFoo[] = [{ xy: 1 }, { xy: 2 }]; //// ////// Nested object literal ////var ob: { ifoo: IFoo } = { ifoo: { xy: 0 } }; //// ////// Widened type ////var w: IFoo = { xy: undefined }; //// ////// Untped -- should not be included ////var u = { xy: 0 }; verify.baselineFindAllReferences('xy')
{ "end_byte": 624, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts" }
TypeScript/tests/cases/fourslash/completionsGenericTypeWithMultipleBases1.ts_0_592
/// <reference path='fourslash.ts'/> ////export interface iBaseScope { //// watch: () => void; ////} ////export interface iMover { //// moveUp: () => void; ////} ////export interface iScope<TModel> extends iBaseScope, iMover { //// family: TModel; ////} ////var x: iScope<number>; ////x./**/ verify.completions({ marker: "", exact: [ { name: "family", text: "(property) iScope<number>.family: number" }, { name: "moveUp", text: "(property) iMover.moveUp: () => void" }, { name: "watch", text: "(property) iBaseScope.watch: () => void" }, ], });
{ "end_byte": 592, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsGenericTypeWithMultipleBases1.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDocTags4.ts_0_611
/// <reference path="fourslash.ts" /> // @Filename: quickInfoJsDocTags4.ts ////class Foo { //// /** //// * comment //// * @author Me <me@domain.tld> //// * @see x (the parameter) //// * @param {number} x - x comment //// * @param {number} y - y comment //// * @returns The result //// */ //// method(x: number, y: number): number { //// return x + y; //// } ////} //// ////class Bar extends Foo { //// /**/method(x: number, y: number): number { //// const res = super.method(x, y) + 100; //// return res; //// } ////} verify.baselineQuickInfo();
{ "end_byte": 611, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTags4.ts" }
TypeScript/tests/cases/fourslash/completionSatisfiesKeyword.ts_0_265
/// <reference path="fourslash.ts" /> ////const x = { a: 1 } /*1*/ ////function foo() { //// const x = { a: 1 } /*2*/ ////} verify.completions({ marker: ["1", "2"], includes: [{ name: "satisfies", sortText: completion.SortText.GlobalsOrKeywords }] });
{ "end_byte": 265, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionSatisfiesKeyword.ts" }
TypeScript/tests/cases/fourslash/incrementalParsingTopLevelAwait.2.ts_0_313
/// <reference path="fourslash.ts"/> // @target: esnext // @module: esnext // @Filename: ./foo.ts //// export {}; //// /*1*/ verify.numberOfErrorsInCurrentFile(0); goTo.marker("1"); edit.insert("await(1);"); verify.numberOfErrorsInCurrentFile(0); edit.replaceLine(1, ""); verify.numberOfErrorsInCurrentFile(0);
{ "end_byte": 313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incrementalParsingTopLevelAwait.2.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptCompletions_tsCheck.ts_0_361
///<reference path="fourslash.ts" /> // @allowJs: true // With 'ts-check' on, we return the same completions we do for TypeScript code. // @Filename: /a.js ////// @ts-check ////interface I { a: number; b: number; } ////interface J { b: number; c: number; } ////declare const ij: I | J; ////ij./**/ verify.completions({ marker: "", exact: ["b"], });
{ "end_byte": 361, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptCompletions_tsCheck.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageVariable2.ts_0_249
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////[|var x; ////function f() { //// x++; ////}|] verify.rangeAfterCodeFix(`var x: number; function f() { x++; } `, /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, 1);
{ "end_byte": 249, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageVariable2.ts" }
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax6.ts_0_225
// @strict: true /// <reference path='fourslash.ts' /> //// var x: [|number?|] = 12; verify.codeFix({ description: "Change 'number?' to 'number | undefined'", index: 1, newRangeContent: "number | undefined", });
{ "end_byte": 225, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax6.ts" }
TypeScript/tests/cases/fourslash/formatTsx.ts_0_260
/// <reference path="fourslash.ts"/> // @Filename: foo.tsx ////<div><p>'</p><p>{function(){return 1;}]}</p></div> format.document(); verify.currentFileContentIs("<div><p>'</p><p>{function() { return 1; }]}</p></div>"); /* < 0 p 1 > 2 ' 3 < 4 / 5 p 6 > 7 */
{ "end_byte": 260, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatTsx.ts" }
TypeScript/tests/cases/fourslash/quickInfoOnMergedInterfacesWithIncrementalEdits.ts_0_634
/// <reference path='fourslash.ts'/> ////module MM { //// interface B<T> { //// foo: number; //// } //// interface B<T> { //// bar: string; //// } //// var b: B<string>; //// var r3 = b.foo; // number //// var r/*2*/4 = b.b/*1*/ar; // string ////} goTo.marker('1'); verify.quickInfoIs("(property) B<string>.bar: string"); edit.deleteAtCaret(1); edit.insert('z'); verify.quickInfoIs("any"); verify.numberOfErrorsInCurrentFile(1); edit.backspace(1); edit.insert('a'); verify.quickInfoIs("(property) B<string>.bar: string"); goTo.marker('2'); verify.quickInfoIs("var r4: string"); verify.noErrors();
{ "end_byte": 634, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnMergedInterfacesWithIncrementalEdits.ts" }
TypeScript/tests/cases/fourslash/codeFixDeleteUnmatchedParameter4.ts_0_364
/// <reference path='fourslash.ts' /> // @filename: a.ts /////** //// * @param {number} a //// */ ////function foo() {} verify.codeFixAvailable([ { description: "Delete unused '@param' tag 'a'" }, ]); verify.codeFix({ description: [ts.Diagnostics.Delete_unused_param_tag_0.message, "a"], index: 0, newFileContent: `/** */ function foo() {}` });
{ "end_byte": 364, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixDeleteUnmatchedParameter4.ts" }
TypeScript/tests/cases/fourslash/quickInfoForUMDModuleAlias.ts_3_361
/ <reference path='fourslash.ts' /> // @Filename: 0.d.ts //// export function doThing(): string; //// export function doTheOtherThing(): void; //// export as namespace /*0*/myLib; // @Filename: 1.ts //// /// <reference path="0.d.ts" /> //// /*1*/myLib.doThing(); verify.quickInfos({ 0: "export namespace myLib", 1: "export namespace myLib" });
{ "end_byte": 361, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForUMDModuleAlias.ts" }
TypeScript/tests/cases/fourslash/completionListAtEndOfWordInArrowFunction03.ts_0_377
/// <reference path='fourslash.ts' /> ////(d, defaultIsAnInvalidParameterName) => default/*1*/ verify.completions({ marker: "1", includes: [ "defaultIsAnInvalidParameterName", // This should probably stop working in the future. { name: "default", text: "default", kind: "keyword", sortText: completion.SortText.GlobalsOrKeywords }, ], });
{ "end_byte": 377, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtEndOfWordInArrowFunction03.ts" }
TypeScript/tests/cases/fourslash/formatTryCatch.ts_0_417
/// <reference path="fourslash.ts"/> ////function test() { //// /*try*/try { //// } //// /*catch*/catch (e) { //// } ////} // Running formatting multiple times should not affect the formating of try/catch blocks format.document(); format.document(); format.document(); goTo.marker("try"); verify.currentLineContentIs(" try {"); goTo.marker("catch"); verify.currentLineContentIs(" catch (e) {");
{ "end_byte": 417, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatTryCatch.ts" }
TypeScript/tests/cases/fourslash/formattingArrowFunctionParenthesizedExpression.ts_0_956
/// <reference path="fourslash.ts" /> // @Filename: Bar.tsx //// export const Bar = ({ //// foo, //// bar, //// }: any) => ( //// <div>Hello world</div> //// ) //// //// export const Bar2 = ({ //// foo, //// bar, //// }) => (<div>Hello world</div>) //// //// export const Bar2 = ({ //// foo, //// bar, //// }) => <div>Hello world</div> //// //// export const Bar3 = ({ //// foo, //// bar, //// }) => //// (<div>Hello world</div>) //// //// export const Bar4 = ({ //// foo, //// bar, //// }) => //// <div>Hello world</div> //// //// export const Bar5 = () => ( //// <div>Hello world</div> //// ) //// //// export const Bar6 = () => (<div>Hello world</div>) //// //// export const Bar7 = () => <div>Hello world</div> //// //// export const Bar8 = () => //// (<div>Hello world</div>) //// //// export const Bar9 = () => //// <div>Hello world</div> verify.formatDocumentChangesNothing();
{ "end_byte": 956, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingArrowFunctionParenthesizedExpression.ts" }
TypeScript/tests/cases/fourslash/smartIndentOnAccessors.ts_0_840
/// <reference path='fourslash.ts' /> ////class Foo { //// get foo(a, //// /*1*/b,/*0*/ //// //comment/*2*/ //// /*3*/c //// ) { //// } //// set foo(a, //// /*5*/b,/*4*/ //// //comment/*6*/ //// /*7*/c //// ) { //// } ////} goTo.marker("0"); edit.insert("\n"); verify.indentationIs(8); goTo.marker("1"); verify.currentLineContentIs(" b,"); goTo.marker("2"); verify.currentLineContentIs(" //comment"); goTo.marker("3"); verify.currentLineContentIs(" c"); goTo.marker("4"); edit.insert("\n"); verify.indentationIs(8); goTo.marker("5"); verify.currentLineContentIs(" b,"); goTo.marker("6"); verify.currentLineContentIs(" //comment"); goTo.marker("7"); verify.currentLineContentIs(" c");
{ "end_byte": 840, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentOnAccessors.ts" }
TypeScript/tests/cases/fourslash/jsDocInheritDoc.ts_0_2049
///<reference path="fourslash.ts" /> // @Filename: inheritDoc.ts ////class Foo { //// /** //// * Foo constructor documentation //// */ //// constructor(value: number) {} //// /** //// * Foo#method1 documentation //// */ //// static method1() {} //// /** //// * Foo#method2 documentation //// */ //// method2() {} //// /** //// * Foo#property1 documentation //// */ //// property1: string; //// /** //// * Foo#property3 documentation //// */ //// property3 = "instance prop"; ////} ////interface Baz { //// /** Baz#property1 documentation */ //// property1: string; //// /** //// * Baz#property2 documentation //// */ //// property2: object; ////} ////class Bar extends Foo implements Baz { //// ctorValue: number; //// /** @inheritDoc */ //// constructor(value: number) { //// super(value); //// this.ctorValue = value; //// } //// /** @inheritDoc */ //// static method1() {} //// method2() {} //// /** @inheritDoc */ //// property1: string; //// /** //// * Bar#property2 //// * @inheritDoc //// */ //// property2: object; //// //// static /*6*/property3 = "class prop"; ////} ////const b = new Bar/*1*/(5); ////b.method2/*2*/(); ////Bar.method1/*3*/(); ////const p1 = b.property1/*4*/; ////const p2 = b.property2/*5*/; verify.quickInfoAt("1", "constructor Bar(value: number): Bar", undefined); // constructors aren't actually inherited verify.quickInfoAt("2", "(method) Bar.method2(): void", "Foo#method2 documentation"); // use inherited docs only verify.quickInfoAt("3", "(method) Bar.method1(): void", 'Foo#method1 documentation'); // use inherited docs too verify.quickInfoAt("4", "(property) Bar.property1: string", "Foo#property1 documentation"); // use inherited docs only verify.quickInfoAt("5", "(property) Bar.property2: object", "Baz#property2 documentation\nBar#property2"); // include local and inherited docs verify.quickInfoAt("6", "(property) Bar.property3: string", undefined);
{ "end_byte": 2049, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocInheritDoc.ts" }
TypeScript/tests/cases/fourslash/jsDocGenerics2.ts_0_503
///<reference path="fourslash.ts" /> // @allowNonTsExtensions: true // @Filename: Foo.js /////** //// * @param {T[]} arr //// * @param {(function(T):T)} valuator //// * @template T //// */ ////function SortFilter(arr,valuator) ////{ //// return arr; ////} ////var a/*1*/ = SortFilter([0, 1, 2], q/*2*/ => q); ////var b/*3*/ = SortFilter([0, 1, 2], undefined); verify.quickInfoAt('1', "var a: number[]"); verify.quickInfoAt('2', '(parameter) q: number'); verify.quickInfoAt('3', "var b: number[]");
{ "end_byte": 503, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocGenerics2.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports15.ts_0_521
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true //// function foo() { //// return { x: 1, y: 1 } as const; //// } //// export const { x, y = 0 } = foo(); verify.codeFix({ description: ts.Diagnostics.Extract_binding_expressions_to_variable.message, index: 0, newFileContent: `function foo() { return { x: 1, y: 1 } as const; } const dest = foo(); export const x: 1 = dest.x; const temp = dest.y; export const y: 1 | 0 = temp === undefined ? 0 : dest.y;` });
{ "end_byte": 521, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports15.ts" }
TypeScript/tests/cases/fourslash/goToImplementationNamespace_05.ts_0_561
/// <reference path='fourslash.ts'/> // Should handle namespace and module implementations with qualified names //// namespace /*implementation0*/Foo./*implementation2*/Baz { //// export function hello() {} //// } //// //// module /*implementation1*/Bar./*implementation3*/Baz { //// export function sure() {} //// } //// //// let x = Fo/*reference0*/o; //// let y = Ba/*reference1*/r; //// let x1 = Foo.B/*reference2*/az; //// let y1 = Bar.B/*reference3*/az; verify.baselineGoToImplementation("reference0", "reference1", "reference2", "reference3");
{ "end_byte": 561, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationNamespace_05.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesReturn3.ts_0_468
/// <reference path='fourslash.ts' /> ////function f(a: number) { //// if (a > 0) { //// return (function () { //// return; //// return; //// return; //// //// if (false) { //// return true; //// } //// })() || true; //// } //// //// var unusued = [1, 2, 3, 4].map(x => { [|return|] 4 }) //// //// return; //// return true; ////} verify.baselineDocumentHighlights();
{ "end_byte": 468, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesReturn3.ts" }
TypeScript/tests/cases/fourslash/getEmitOutputMapRoot.ts_0_354
/// <reference path="fourslash.ts" /> // @BaselineFile: getEmitOutputMapRoots.baseline // @outFile: declSingleFile.js // @sourceMap: true // @mapRoot: mapRootDir/ // @Filename: inputFile.ts // @emitThisFile: true //// var x = 109; //// var foo = "hello world"; //// class M { //// x: number; //// y: string; //// } verify.baselineGetEmitOutput();
{ "end_byte": 354, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputMapRoot.ts" }
TypeScript/tests/cases/fourslash/navigationBarItemsItemsModuleVariables.ts_0_2205
/// <reference path="fourslash.ts"/> // @Filename: navigationItemsModuleVariables_0.ts //// /*file1*/ ////module Module1 { //// export var x = 0; ////} // @Filename: navigationItemsModuleVariables_1.ts //// /*file2*/ ////module Module1.SubModule { //// export var y = 0; ////} // @Filename: navigationItemsModuleVariables_2.ts //// /*file3*/ ////module Module1 { //// export var z = 0; ////} goTo.marker("file1"); // nothing else should show up verify.navigationTree({ "text": "<global>", "kind": "script", "childItems": [ { "text": "Module1", "kind": "module", "childItems": [ { "text": "x", "kind": "var", "kindModifiers": "export" } ] } ] }); verify.navigationBar([ { "text": "<global>", "kind": "script", "childItems": [ { "text": "Module1", "kind": "module" } ] }, { "text": "Module1", "kind": "module", "childItems": [ { "text": "x", "kind": "var", "kindModifiers": "export" } ], "indent": 1 } ]); goTo.marker("file2"); verify.navigationTree({ "text": "<global>", "kind": "script", "childItems": [ { "text": "Module1.SubModule", "kind": "module", "childItems": [ { "text": "y", "kind": "var", "kindModifiers": "export" } ] } ] }); verify.navigationBar([ { "text": "<global>", "kind": "script", "childItems": [ { "text": "Module1.SubModule", "kind": "module" } ] }, { "text": "Module1.SubModule", "kind": "module", "childItems": [ { "text": "y", "kind": "var", "kindModifiers": "export" } ], "indent": 1 } ]);
{ "end_byte": 2205, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsItemsModuleVariables.ts" }
TypeScript/tests/cases/fourslash/completionsOptionalMethod.ts_0_163
/// <reference path="fourslash.ts" /> // @strictNullChecks: true ////declare const x: { m?(): void }; ////x./**/ verify.completions({ marker: "", exact: "m" });
{ "end_byte": 163, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOptionalMethod.ts" }
TypeScript/tests/cases/fourslash/formattingOnClasses.ts_0_12116
/// <reference path='fourslash.ts' /> /////*1*/ class a { /////*2*/ constructor ( n : number ) ; /////*3*/ constructor ( s : string ) ; /////*4*/ constructor ( ns : any ) { //// /////*5*/ } //// /////*6*/ public pgF ( ) { } //// /////*7*/ public pv ; /////*8*/ public get d ( ) { /////*9*/ return 30 ; /////*10*/ } /////*11*/ public set d ( number ) { /////*12*/ } //// /////*13*/ public static get p2 ( ) { /////*14*/ return { x : 30 , y : 40 } ; /////*15*/ } //// /////*16*/ private static d2 ( ) { /////*17*/ } /////*18*/ private static get p3 ( ) { /////*19*/ return "string" ; /////*20*/ } /////*21*/ private pv3 ; //// /////*22*/ private foo ( n : number ) : string ; /////*23*/ private foo ( s : string ) : string ; /////*24*/ private foo ( ns : any ) { /////*25*/ return ns.toString ( ) ; /////*26*/ } /////*27*/} //// /////*28*/ class b extends a { /////*29*/} //// /////*30*/ class m1b { //// /////*31*/} //// /////*32*/ interface m1ib { //// /////*33*/ } /////*34*/ class c extends m1b { /////*35*/} //// /////*36*/ class ib2 implements m1ib { /////*37*/} //// /////*38*/ declare class aAmbient { /////*39*/ constructor ( n : number ) ; /////*40*/ constructor ( s : string ) ; /////*41*/ public pgF ( ) : void ; /////*42*/ public pv ; /////*43*/ public d : number ; /////*44*/ static p2 : { x : number ; y : number ; } ; /////*45*/ static d2 ( ) ; /////*46*/ static p3 ; /////*47*/ private pv3 ; /////*48*/ private foo ( s ) ; /////*49*/} //// /////*50*/ class d { /////*51*/ private foo ( n : number ) : string ; /////*52*/ private foo ( s : string ) : string ; /////*53*/ private foo ( ns : any ) { /////*54*/ return ns.toString ( ) ; /////*55*/ } /////*56*/} //// /////*57*/ class e { /////*58*/ private foo ( s : string ) : string ; /////*59*/ private foo ( n : number ) : string ; /////*60*/ private foo ( ns : any ) { /////*61*/ return ns.toString ( ) ; /////*62*/ } /////*63*/ protected bar ( ) { } /////*64*/ protected static bar2 ( ) { } /////*65*/ private pv4 : number = /////*66*/ {}; /////*END*/} format.document(); goTo.marker("1"); verify.currentLineContentIs("class a {"); goTo.marker("2"); verify.currentLineContentIs(" constructor(n: number);"); goTo.marker("3"); verify.currentLineContentIs(" constructor(s: string);"); goTo.marker("4"); verify.currentLineContentIs(" constructor(ns: any) {"); goTo.marker("5"); verify.currentLineContentIs(" }"); goTo.marker("6"); verify.currentLineContentIs(" public pgF() { }"); goTo.marker("7"); verify.currentLineContentIs(" public pv;"); goTo.marker("8"); verify.currentLineContentIs(" public get d() {"); goTo.marker("9"); verify.currentLineContentIs(" return 30;"); goTo.marker("10"); verify.currentLineContentIs(" }"); goTo.marker("11"); verify.currentLineContentIs(" public set d(number) {"); goTo.marker("12"); verify.currentLineContentIs(" }"); goTo.marker("13"); verify.currentLineContentIs(" public static get p2() {"); goTo.marker("14"); verify.currentLineContentIs(" return { x: 30, y: 40 };"); goTo.marker("15"); verify.currentLineContentIs(" }"); goTo.marker("16"); verify.currentLineContentIs(" private static d2() {"); goTo.marker("17"); verify.currentLineContentIs(" }"); goTo.marker("18"); verify.currentLineContentIs(" private static get p3() {"); goTo.marker("19"); verify.currentLineContentIs(' return "string";'); goTo.marker("20"); verify.currentLineContentIs(" }"); goTo.marker("21"); verify.currentLineContentIs(" private pv3;"); goTo.marker("22"); verify.currentLineContentIs(" private foo(n: number): string;"); goTo.marker("23"); verify.currentLineContentIs(" private foo(s: string): string;"); goTo.marker("24"); verify.currentLineContentIs(" private foo(ns: any) {"); goTo.marker("25"); verify.currentLineContentIs(" return ns.toString();"); goTo.marker("26"); verify.currentLineContentIs(" }"); goTo.marker("27"); verify.currentLineContentIs("}"); goTo.marker("28"); verify.currentLineContentIs("class b extends a {"); goTo.marker("29"); verify.currentLineContentIs("}"); goTo.marker("30"); verify.currentLineContentIs("class m1b {"); goTo.marker("31"); verify.currentLineContentIs("}"); goTo.marker("32"); verify.currentLineContentIs("interface m1ib {"); goTo.marker("33"); verify.currentLineContentIs("}"); goTo.marker("34"); verify.currentLineContentIs("class c extends m1b {"); goTo.marker("35"); verify.currentLineContentIs("}"); goTo.marker("36"); verify.currentLineContentIs("class ib2 implements m1ib {"); goTo.marker("37"); verify.currentLineContentIs("}"); goTo.marker("38"); verify.currentLineContentIs("declare class aAmbient {"); goTo.marker("39"); verify.currentLineContentIs(" constructor(n: number);"); goTo.marker("40"); verify.currentLineContentIs(" constructor(s: string);"); goTo.marker("41"); verify.currentLineContentIs(" public pgF(): void;"); goTo.marker("42"); verify.currentLineContentIs(" public pv;"); goTo.marker("43"); verify.currentLineContentIs(" public d: number;"); goTo.marker("44"); verify.currentLineContentIs(" static p2: { x: number; y: number; };"); goTo.marker("45"); verify.currentLineContentIs(" static d2();"); goTo.marker("46"); verify.currentLineContentIs(" static p3;"); goTo.marker("47"); verify.currentLineContentIs(" private pv3;"); goTo.marker("48"); verify.currentLineContentIs(" private foo(s);"); goTo.marker("49"); verify.currentLineContentIs("}"); goTo.marker("50"); verify.currentLineContentIs("class d {"); goTo.marker("51"); verify.currentLineContentIs(" private foo(n: number): string;"); goTo.marker("52"); verify.currentLineContentIs(" private foo(s: string): string;"); goTo.marker("53"); verify.currentLineContentIs(" private foo(ns: any) {"); goTo.marker("54"); verify.currentLineContentIs(" return ns.toString();"); goTo.marker("55"); verify.currentLineContentIs(" }"); goTo.marker("56"); verify.currentLineContentIs("}"); goTo.marker("57"); verify.currentLineContentIs("class e {"); goTo.marker("58");
{ "end_byte": 12116, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnClasses.ts" }
TypeScript/tests/cases/fourslash/formattingOnClasses.ts_12117_12839
verify.currentLineContentIs(" private foo(s: string): string;"); goTo.marker("59"); verify.currentLineContentIs(" private foo(n: number): string;"); goTo.marker("60"); verify.currentLineContentIs(" private foo(ns: any) {"); goTo.marker("61"); verify.currentLineContentIs(" return ns.toString();"); goTo.marker("62"); verify.currentLineContentIs(" }"); goTo.marker("63"); verify.currentLineContentIs(" protected bar() { }"); goTo.marker("64"); verify.currentLineContentIs(" protected static bar2() { }"); goTo.marker("65"); verify.currentLineContentIs(" private pv4: number ="); goTo.marker("66"); verify.currentLineContentIs(" {};"); goTo.marker("END"); verify.currentLineContentIs("}");
{ "end_byte": 12839, "start_byte": 12117, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnClasses.ts" }
TypeScript/tests/cases/fourslash/renameForStringLiteral.ts_0_250
/// <reference path="fourslash.ts" /> // @filename: /a.ts ////interface Foo { //// property: /**/"foo"; ////} /////** //// * @type {{ property: "foo"}} //// */ ////const obj: Foo = { //// property: "foo", ////} verify.baselineRename("", {});
{ "end_byte": 250, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameForStringLiteral.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_pathsWithExtension.ts_0_613
/// <reference path="fourslash.ts" /> // @Filename: /tsconfig.json //// { //// "compilerOptions": { //// "target": "ESNext", //// "module": "Node16", //// "moduleResolution": "Node16", //// "rootDir": "./src", //// "outDir": "./dist", //// "paths": { //// "#internals/*": ["./src/internals/*.ts"] //// } //// }, //// "include": ["src"] //// } // @Filename: /src/internals/example.ts //// export function helloWorld() {} // @Filename: /src/index.ts //// helloWorld/**/ verify.importFixModuleSpecifiers("", ["#internals/example"], { importModuleSpecifierEnding: "js" });
{ "end_byte": 613, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_pathsWithExtension.ts" }
TypeScript/tests/cases/fourslash/indexSignatureWithoutAnnotation.ts_0_205
/// <reference path="fourslash.ts" /> //// interface B { //// 1: any; //// } //// interface C { //// [s]: any; //// } //// interface D extends B, C /**/ { //// } goTo.marker(); edit.insert(" ");
{ "end_byte": 205, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indexSignatureWithoutAnnotation.ts" }
TypeScript/tests/cases/fourslash/refactorKind_moveToNewFile.ts_0_219
/// <reference path='fourslash.ts' /> //// /*a*/const moveMe = 1;/*b*/ goTo.select("a", "b"); verify.refactorKindAvailable("refactor.move", [ "refactor.move.newFile" ], { allowTextChangesInNewFiles: true });
{ "end_byte": 219, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorKind_moveToNewFile.ts" }
TypeScript/tests/cases/fourslash/contextualTypingOfArrayLiterals.ts_0_985
/// <reference path='fourslash.ts'/> ////class C { //// name: string; //// age: number; ////} ////interface I { //// [x: number]: C; ////} ////var /*1*/x = [null, null]; ////var x2: I = [null, null]; ////var /*2*/r = x2[0]; ////var a = { name: 'bob', age: 20 }; ////var b = { name: 'jim', age: 20, dob: new Date() }; ////var c: C; ////var d = { name: 'jim', age: 20, address: 'springfield' }; ////var x3: I = [a, b]; ////var /*3*/r3 = x3[1]; ////var x4: I = [a, b, c]; ////var /*4*/r4 = x4[1]; ////var /*5*/x5 = [a, b]; ////var /*6*/r5 = x5[1]; // the above code should have a couple errors that will need to be updated with appropriate new (non-error) code and quick info checks verify.not.errorExistsBetweenMarkers('1', '6'); verify.quickInfos({ 1: "var x: any[]", 2: "var r: C", 3: "var r3: C", 4: "var r4: C", 5: "var x5: {\n\ name: string;\n\ age: number;\n\ }[]", 6: "var r5: {\n\ name: string;\n\ age: number;\n\ }" });
{ "end_byte": 985, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/contextualTypingOfArrayLiterals.ts" }
TypeScript/tests/cases/fourslash/codeFixAddOptionalParam13.ts_0_519
/// <reference path="fourslash.ts" /> ////function f(a: string): string; ////function f(a: string, b: number): string; ////function f(a: string, b?: number): string { //// return ""; ////} ////f("", 1, ""); verify.codeFix({ description: [ts.Diagnostics.Add_optional_parameter_to_0.message, "f"], index: 1, newFileContent: `function f(a: string): string; function f(a: string, b: number, p0?: string): string; function f(a: string, b?: number, p0?: string): string { return ""; } f("", 1, "");` });
{ "end_byte": 519, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddOptionalParam13.ts" }
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction4.ts_0_271
/// <reference path='fourslash.ts' /> // @target: es2015 ////async function fn(): void {} verify.codeFix({ index: 0, description: [ts.Diagnostics.Replace_0_with_Promise_1.message, "void", "void"], newFileContent: `async function fn(): Promise<void> {}` });
{ "end_byte": 271, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction4.ts" }
TypeScript/tests/cases/fourslash/renameFromNodeModulesDep1.ts_0_787
/// <reference path="fourslash.ts" /> // @Filename: /index.ts ////import { /*okWithAlias*/[|Foo|] } from "foo"; ////declare const f: Foo; ////f./*notOk*/bar; // @Filename: /tsconfig.json //// { } // @Filename: /node_modules/foo/package.json //// { "types": "index.d.ts" } // @Filename: /node_modules/foo/index.d.ts ////export interface Foo { //// bar: string; ////} goTo.marker("okWithAlias"); verify.renameInfoSucceeded( undefined, undefined, undefined, undefined, undefined, undefined, { providePrefixAndSuffixTextForRename: true }); verify.renameInfoFailed( undefined, { providePrefixAndSuffixTextForRename: false }); goTo.marker("notOk"); verify.renameInfoFailed("You cannot rename elements that are defined in a 'node_modules' folder.");
{ "end_byte": 787, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameFromNodeModulesDep1.ts" }
TypeScript/tests/cases/fourslash/completionListInUnclosedIndexSignature02.ts_0_222
/// <reference path='fourslash.ts' /> ////class C { //// [foo: /*1*/ ////} verify.completions({ marker: "1", includes: "C", excludes: "foo" }); edit.insert("typeof "); verify.completions({ includes: ["C", "foo"] });
{ "end_byte": 222, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedIndexSignature02.ts" }
TypeScript/tests/cases/fourslash/quickfixAddMissingConstraint3.ts_0_412
/// <reference path="fourslash.ts" /> // @Filename: file.ts ////function f<T = `${number}`>(x: T) { //// const y: `${number}` = x/**/; ////} goTo.marker(""); verify.codeFix({ index: 0, description: "Add `extends` constraint.", newFileContent: { "/tests/cases/fourslash/file.ts": `function f<T extends \`$\{number}\` = \`$\{number}\`>(x: T) { const y: \`$\{number}\` = x; }` } });
{ "end_byte": 412, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickfixAddMissingConstraint3.ts" }
TypeScript/tests/cases/fourslash/documentHighlights_33722.ts_0_328
/// <reference path="fourslash.ts" /> // @Filename: /y.ts ////class Foo { //// private foo() {} ////} //// ////const f = () => new Foo(); ////export default f; // @Filename: /x.ts ////import y from "./y"; //// ////y().[|foo|](); const [r] = test.ranges(); verify.baselineDocumentHighlights(r, { filesToSearch: ["/x.ts"] });
{ "end_byte": 328, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlights_33722.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts_0_537
/// <reference path="fourslash.ts" /> // @Filename: a/f1.ts //// [|foo/*0*/();|] // @Filename: types/random/index.ts //// export function foo() {}; // @Filename: tsconfig.json //// { //// "compilerOptions": { //// "baseUrl": ".", //// "typeRoots": [ //// "./types" //// ] //// } //// } // "typeRoots" does not affect module resolution, though "baseUrl" does. Importing from "random" would be a compile error. verify.importFixAtPosition([ `import { foo } from "types/random"; foo();`, ]);
{ "end_byte": 537, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots1.ts" }
TypeScript/tests/cases/fourslash/getEmitOutputWithDeclarationFile3.ts_0_457
/// <reference path="fourslash.ts" /> // @BaselineFile: getEmitOutputWithDeclarationFile3.baseline // @outFile: declSingle.js // @Filename: decl.d.ts //// interface I { a: string; } // @Filename: inputFile2.ts //// export class Foo { } // @Filename: inputFile3.ts // @emitThisFile: true //// var x:string = "hello"; // @Filename: inputFile4.ts //// var x1:number = 1000; // @Filename: inputFile5.js //// var x2 = 1000; verify.baselineGetEmitOutput();
{ "end_byte": 457, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputWithDeclarationFile3.ts" }
TypeScript/tests/cases/fourslash/completionListStaticProtectedMembers2.ts_0_3214
/// <reference path='fourslash.ts'/> ////class Base { //// private static privateMethod() { } //// private static privateProperty; //// //// protected static protectedMethod() { } //// protected static protectedProperty; //// //// public static publicMethod() { } //// public static publicProperty; //// //// protected static protectedOverriddenMethod() { } //// protected static protectedOverriddenProperty; ////} //// ////class C2 extends Base { //// protected static protectedOverriddenMethod() { } //// protected static protectedOverriddenProperty; //// //// static test() { //// Base./*1*/; //// C2./*2*/; //// this./*3*/; //// super./*4*/; //// } ////} verify.completions( { // Same class, everything is visible marker: ["1"], exact: completion.functionMembersPlus([ { name: "protectedMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "protectedOverriddenMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "protectedOverriddenProperty", sortText: completion.SortText.LocalDeclarationPriority}, { name: "protectedProperty", sortText: completion.SortText.LocalDeclarationPriority }, { name: "publicMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "publicProperty", sortText: completion.SortText.LocalDeclarationPriority }, { name: "prototype", sortText: completion.SortText.LocationPriority }, ]), }, { marker: ["2", "3"], exact: completion.functionMembersPlus([ { name: "protectedMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "protectedOverriddenMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "protectedOverriddenProperty", sortText: completion.SortText.LocalDeclarationPriority }, { name: "protectedProperty", sortText: completion.SortText.LocalDeclarationPriority }, { name: "publicMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "publicProperty", sortText: completion.SortText.LocalDeclarationPriority }, { name: "test", sortText: completion.SortText.LocalDeclarationPriority }, { name: "prototype", sortText: completion.SortText.LocationPriority }, ]), }, { // only public and protected methods of the base class are accessible through super marker: "4", exact: [ { name: "protectedMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "protectedOverriddenMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "publicMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "apply", sortText: completion.SortText.LocationPriority }, { name: "bind", sortText: completion.SortText.LocationPriority }, { name: "call", sortText: completion.SortText.LocationPriority }, { name: "toString", sortText: completion.SortText.LocationPriority }, ], }, );
{ "end_byte": 3214, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListStaticProtectedMembers2.ts" }
TypeScript/tests/cases/fourslash/mapCodeReplaceUsingRange.ts_0_258
///<reference path="fourslash.ts"/> // @Filename: /index.ts //// [|function foo() { //// return 1; //// }[||] //// function bar() { //// return [|2;|] //// }|] //// verify.baselineMapCode([test.ranges()], [ ` function foo() { return 3; } ` ]);
{ "end_byte": 258, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeReplaceUsingRange.ts" }
TypeScript/tests/cases/fourslash/constructorFindAllReferences2.ts_0_192
/// <reference path="fourslash.ts" /> ////export class C { //// /**/private constructor() { } //// public foo() { } ////} //// ////new C().foo(); verify.baselineFindAllReferences("");
{ "end_byte": 192, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/constructorFindAllReferences2.ts" }
TypeScript/tests/cases/fourslash/exhaustiveCaseCompletions4.ts_0_4132
/// <reference path="fourslash.ts" /> // Filter existing values. // @newline: LF //// enum E { //// A = 0, //// B = "B", //// C = "C", //// } //// // Filtering existing literals //// declare const u: E.A | E.B | 1 | 1n | "1"; //// switch (u) { //// case E.A: //// case 1: //// case 1n: //// case 0x1n: //// case "1": //// case `1`: //// case `1${u}`: //// case/*1*/ //// } //// declare const v: E.A | "1" | "2"; //// switch (v) { //// case 0: //// case `1`: //// /*2*/ //// } //// // Filtering repreated enum members //// enum F { //// A = "A", //// B = "B", //// C = A, //// } //// declare const x: F; //// switch (x) { //// /*3*/ //// } //// // Enum with computed elements //// enum G { //// C = 0, //// D = 1 << 1, //// E = 1 << 2, //// OtherD = D, //// DorE = D | E, //// } //// declare const y: G; //// switch (y) { //// /*4*/ //// } //// switch (y) { //// case 0: // same as G.C //// case 1: // same as G.D, but we don't know it //// case 3: // same as G.DorE, but we don't know //// /*5*/ //// } //// //// // Already exhaustive switch //// enum H { //// A = "A", //// B = "B", //// C = "C", //// } //// declare const z: H; //// switch (z) { //// case H.A: //// case H.B: //// case H.C: //// /*6*/ //// } verify.completions( { marker: "1", isNewIdentifierLocation: false, includes: [ { name: "case E.B: ...", source: completion.CompletionSource.SwitchCases, sortText: completion.SortText.GlobalsOrKeywords, insertText: `case E.B:`, }, ], preferences: { includeCompletionsWithInsertText: true, }, }, { marker: "2", isNewIdentifierLocation: false, includes: [ { name: `case "2": ...`, source: completion.CompletionSource.SwitchCases, sortText: completion.SortText.GlobalsOrKeywords, insertText: `case "2":`, }, ], preferences: { includeCompletionsWithInsertText: true, }, }, { marker: "3", isNewIdentifierLocation: false, includes: [ { name: "case F.A: ...", source: completion.CompletionSource.SwitchCases, sortText: completion.SortText.GlobalsOrKeywords, insertText: `case F.A: case F.B:`, // no C because C's value is the same as A's }, ], preferences: { includeCompletionsWithInsertText: true, }, }, { marker: "4", isNewIdentifierLocation: false, includes: [ { name: "case G.C: ...", source: completion.CompletionSource.SwitchCases, sortText: completion.SortText.GlobalsOrKeywords, insertText: `case G.C: case G.D: case G.E: case G.DorE:`, }, ], preferences: { includeCompletionsWithInsertText: true, }, }, { marker: "5", isNewIdentifierLocation: false, includes: [ { name: "case G.D: ...", source: completion.CompletionSource.SwitchCases, sortText: completion.SortText.GlobalsOrKeywords, insertText: `case G.D: case G.E: case G.DorE:`, }, ], preferences: { includeCompletionsWithInsertText: true, }, }, { marker: "6", isNewIdentifierLocation: false, // No exhaustive case completion offered here because the switch is already exhaustive exact: [ "E", "F", "G", "H", "u", "v", "x", "y", "z", ...completion.globals, ], preferences: { includeCompletionsWithInsertText: true, }, }, );
{ "end_byte": 4132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/exhaustiveCaseCompletions4.ts" }
TypeScript/tests/cases/fourslash/memberConstructorEdits.ts_0_560
/// <reference path='fourslash.ts' /> //// module M { //// export class A { //// constructor(a: string) {} //// public m(n: number) { //// return 0; //// } //// public n() { //// return this.m(0); //// } //// } //// export class B extends A { //// constructor(a: string) { //// super(a); //// } //// /*1*/ //// } //// var a = new A("s"); //// var b = new B("s"); //// } verify.noErrors(); goTo.marker('1'); edit.insert("public m(n: number) { return 0; }"); verify.noErrors();
{ "end_byte": 560, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberConstructorEdits.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_js_9.ts_0_512
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: a.js //// class A { //// static /*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: `class A { static /*RENAME*/_a = 1; static get a() { return A._a; } static set a(value) { A._a = value; } }`, });
{ "end_byte": 512, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_js_9.ts" }
TypeScript/tests/cases/fourslash/completionsRecommended_switch.ts_0_283
/// <reference path="fourslash.ts" /> ////enum Enu {} ////declare const e: Enu; ////switch (e) { //// case E/*0*/: //// case /*1*/: ////} verify.completions({ marker: test.markers(), includes: { name: "Enu", text: "enum Enu", kind: "enum", isRecommended: true }, });
{ "end_byte": 283, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsRecommended_switch.ts" }
TypeScript/tests/cases/fourslash/deleteModifierBeforeVarStatement1.ts_0_1358
/// <reference path="../fourslash.ts" /> //// //// //// ///////////////////////////// //// /// Windows Script Host APIS //// ///////////////////////////// //// //// declare var ActiveXObject: { new (s: string): any; }; //// //// interface ITextWriter { //// WriteLine(s): void; //// } //// //// declare var WScript: { //// Echo(s): void; //// StdErr: ITextWriter; //// Arguments: { length: number; Item(): string; }; //// ScriptFullName: string; //// Quit(): number; //// } //// goTo.file(0); // : // : |--- go here // 1: // 2: goTo.position(0); // : // : |--- delete "\n\n///..." // 1: // 2: edit.deleteAtCaret(100); // 12: // : |--- go here // 13: declare var WScript: { // 14: Echo(s): void; goTo.position(198); // 12: // : |--- delete "declare..." // 13: declare var WScript: { // 14: Echo(s): void; edit.deleteAtCaret(16); // 9: StdErr: ITextWriter; // : |--- go here // 10: Arguments: { length: number; Item(): string; }; // 11: ScriptFullName: string; goTo.position(198); // 9: StdErr: ITextWriter; // : |--- insert "Item(): string; " // 10: Arguments: { length: number; Item(): string; }; // 11: ScriptFullName: string; edit.insert("Item(): string; ");
{ "end_byte": 1358, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/deleteModifierBeforeVarStatement1.ts" }
TypeScript/tests/cases/fourslash/formatConflictDiff3Marker1.ts_0_341
/// <reference path='fourslash.ts' /> ////class C { ////<<<<<<< HEAD ////v = 1; ////||||||| merged common ancestors ////v = 3; ////======= ////v = 2; ////>>>>>>> Branch - a ////} format.document(); verify.currentFileContentIs(`class C { <<<<<<< HEAD v = 1; ||||||| merged common ancestors v = 3; ======= v = 2; >>>>>>> Branch - a }`);
{ "end_byte": 341, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatConflictDiff3Marker1.ts" }
TypeScript/tests/cases/fourslash/staticGenericOverloads1.ts_0_607
/// <reference path='fourslash.ts'/> ////class A<T> { //// static B<S>(v: A<S>): A<S>; //// static B<S>(v: S): A<S>; //// static B<S>(v: any): A<S> { //// return null; //// } ////} ////var a = new A<number>(); ////A.B(/**/ verify.signatureHelp({ marker: "", overloadsCount: 2 }); edit.insert('a'); verify.signatureHelp({ overloadsCount: 2, text: "B(v: A<number>): A<number>" }); edit.insert('); A.B('); verify.signatureHelp({ overloadsCount: 2, text: "B(v: A<unknown>): A<unknown>" }); edit.insert('a'); verify.signatureHelp({ overloadsCount: 2, text: "B(v: A<number>): A<number>" });
{ "end_byte": 607, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/staticGenericOverloads1.ts" }
TypeScript/tests/cases/fourslash/codeFixForgottenThisPropertyAccess02.ts_0_264
/// <reference path='fourslash.ts' /> ////class C { //// constructor(public foo) { //// } //// bar() { [|foo = 10|] }; ////} verify.codeFix({ description: "Add 'this.' to unresolved variable", index: 0, newRangeContent: "this.foo = 10", });
{ "end_byte": 264, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixForgottenThisPropertyAccess02.ts" }
TypeScript/tests/cases/fourslash/unusedParameterInLambda3.ts_0_398
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @noUnusedParameters: true ////[|/*~a*/(/*~b*/x/*~c*/,/*~d*/y/*~e*/)/*~f*/ => /*~g*/x/*~h*/|] // In a perfect world, /*~c*/ would probably be retained, rather than /*~e*/. verify.codeFix({ description: "Remove unused declaration for: 'y'", index: 0, newRangeContent: "/*~a*/(/*~b*/x/*~e*/)/*~f*/ => /*~g*/x/*~h*/", });
{ "end_byte": 398, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedParameterInLambda3.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesIsWriteAccess.ts_0_866
/// <reference path='fourslash.ts' /> ////var [|{| "isWriteAccess": true |}x|] = 0; ////var assignmentRightHandSide = [|{| "isWriteAccess": false |}x|]; ////var assignmentRightHandSide2 = 1 + [|{| "isWriteAccess": false |}x|]; //// ////[|{| "isWriteAccess": true |}x|] = 1; ////[|{| "isWriteAccess": true |}x|] = [|{| "isWriteAccess": false |}x|] + [|{| "isWriteAccess": false |}x|]; //// ////[|{| "isWriteAccess": false |}x|] == 1; ////[|{| "isWriteAccess": false |}x|] <= 1; //// ////var preIncrement = ++[|{| "isWriteAccess": true |}x|]; ////var postIncrement = [|{| "isWriteAccess": true |}x|]++; ////var preDecrement = --[|{| "isWriteAccess": true |}x|]; ////var postDecrement = [|{| "isWriteAccess": true |}x|]--; //// ////[|{| "isWriteAccess": true |}x|] += 1; ////[|{| "isWriteAccess": true |}x|] <<= 1; verify.baselineDocumentHighlights(test.ranges()[0]);
{ "end_byte": 866, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesIsWriteAccess.ts" }
TypeScript/tests/cases/fourslash/findAllRefsReExportLocal.ts_0_1083
/// <reference path='fourslash.ts' /> // @noLib: true // @Filename: /a.ts ////[|var /*ax0*/[|{| "isDefinition": true, "contextRangeIndex": 0 |}x|];|] ////[|export { /*ax1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|] };|] ////[|export { /*ax2*/[|{| "contextRangeIndex": 4 |}x|] as /*ay*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}y|] };|] // @Filename: /b.ts ////[|import { /*bx0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 7 |}x|], /*by0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 7 |}y|] } from "./a";|] /////*bx1*/[|x|]; /*by1*/[|y|]; verify.noErrors(); const [ax0Def, ax0, ax1Def, ax1, ax2Def, ax2, ay, bx0Def, bx0, by0, bx1, by1] = test.ranges(); const bxRanges = [bx0, bx1]; const byRanges = [by0, by1]; verify.baselineFindAllReferences('ax0', 'ax1', 'ax2', 'bx0', 'bx1', 'ay', 'by0', 'by1'); verify.baselineRename([ax0, ax2]); verify.baselineRename(ax1); verify.baselineRename(bxRanges); verify.baselineRename(ay); verify.baselineRename(byRanges);
{ "end_byte": 1083, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsReExportLocal.ts" }
TypeScript/tests/cases/fourslash/goToTypeDefinition_arrayType.ts_0_471
/// <reference path='fourslash.ts' /> //// type User = { name: string }; //// declare const users: User[] //// /*reference*/users //// //// type UsersArr = Array<User> //// declare const users2: UsersArr //// /*reference2*/users2 //// //// class CustomArray<T> extends Array<T> { immutableReverse() { return [...this].reverse() } } //// declare const users3: CustomArray<User> //// /*reference3*/users3 verify.baselineGoToType("reference", "reference2", "reference3");
{ "end_byte": 471, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToTypeDefinition_arrayType.ts" }
TypeScript/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature03.ts_0_365
/// <reference path="fourslash.ts" /> ////interface I<TString, TNumber> { //// [s: string]: TString; //// [s: number]: TNumber; ////} //// ////declare function foo<TString, TNumber>(obj: I<TString, TNumber>): { str: TString/*1*/ verify.completions({ marker: "1", includes: ["I", "TString", "TNumber"], excludes: ["foo", "obj"], // not types });
{ "end_byte": 365, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature03.ts" }
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_typedRestParam.ts_0_810
/// <reference path='fourslash.ts' /> ////function /*a*/buildName/*b*/(firstName: string, middleName?: string, ...restOfName: string[]) { } ////let employeeName = buildName("Joseph", "Samuel", "Lucas", "MacKinzie"); ////let myName = buildName("Joseph"); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert parameters to destructured object", actionName: "Convert parameters to destructured object", actionDescription: "Convert parameters to destructured object", newContent: `function buildName({ firstName, middleName, restOfName = [] }: { firstName: string; middleName?: string; restOfName?: string[]; }) { } let employeeName = buildName({ firstName: "Joseph", middleName: "Samuel", restOfName: ["Lucas", "MacKinzie"] }); let myName = buildName({ firstName: "Joseph" });` });
{ "end_byte": 810, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_typedRestParam.ts" }
TypeScript/tests/cases/fourslash/completionListInObjectBindingPattern04.ts_0_238
/// <reference path='fourslash.ts'/> ////interface I { //// property1: number; //// property2: string; ////} //// ////var foo: I; ////var { prope/**/ } = foo; verify.completions({ marker: "", exact: ["property1", "property2"] });
{ "end_byte": 238, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectBindingPattern04.ts" }
TypeScript/tests/cases/fourslash/codeFixOverrideModifier11.ts_0_235
/// <reference path='fourslash.ts' /> // @noImplicitOverride: true //// abstract class Base { //// abstract bar(): void; //// } //// class Sub extends Base { //// [|override bar() {}|] //// } verify.not.refactorAvailable();
{ "end_byte": 235, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixOverrideModifier11.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_require_importVsRequire_addToExistingWins.ts_0_816
/// <reference path="fourslash.ts" /> // If a file has both `require` and `import` declarations, // prefer whichever can be used for an "add to existing" action. // @allowJs: true // @checkJs: true // @Filename: blah.js ////export default class Blah {} ////export const Named1 = 0; ////export const Named2 = 1; // @Filename: index.js ////var path = require('path') //// , { promisify } = require('util') //// , { Named1 } = require('./blah') //// ////import fs from 'fs' //// ////new Blah goTo.file("index.js"); verify.codeFix({ index: 0, errorCode: ts.Diagnostics.Cannot_find_name_0.code, description: `Update import from "./blah"`, newFileContent: `var path = require('path') , { promisify } = require('util') , { Named1, default: Blah } = require('./blah') import fs from 'fs' new Blah` });
{ "end_byte": 816, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_require_importVsRequire_addToExistingWins.ts" }
TypeScript/tests/cases/fourslash/completionsImport_defaultFalsePositive.ts_0_914
/// <reference path="fourslash.ts" /> // @Filename: /node_modules/foo/index.ts ////export default function f(): void; // @Filename: /node_modules/bar/concat.d.ts ////export const concat = 0; // @Filename: /a.ts ////export {}; ////conca/**/ goTo.file("/a.ts"); verify.completions({ marker: "", includes: { name: "concat", source: "/node_modules/bar/concat", sourceDisplay: "bar/concat", text: "const concat: 0", kind: "const", kindModifiers: "export,declare", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, preferences: { includeCompletionsForModuleExports: true }, }); verify.applyCodeActionFromCompletion("", { name: "concat", source: "/node_modules/bar/concat", description: `Add import from "bar/concat"`, newFileContent: `import { concat } from "bar/concat"; export {}; conca`, });
{ "end_byte": 914, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_defaultFalsePositive.ts" }
TypeScript/tests/cases/fourslash/completionEntryForPropertyFromUnionOfModuleType.ts_0_328
///<reference path="fourslash.ts" /> ////module E { //// export var n = 1; //// export var x = 0; ////} ////module F { //// export var n = 1; //// export var y = 0; ////} ////var q: typeof E | typeof F; ////var j = q./*1*/ verify.completions({ marker: "1", exact: [{ name: "n", text: "(property) n: number" }] });
{ "end_byte": 328, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionEntryForPropertyFromUnionOfModuleType.ts" }
TypeScript/tests/cases/fourslash/codeFixConvertToMappedObjectType8.ts_0_449
/// <reference path='fourslash.ts' /> //// type K = "foo" | "bar"; //// interface Foo { } //// interface Bar { } //// interface SomeType extends Foo, Bar { //// a: number; //// [prop: K]: any; //// } verify.codeFix({ description: `Convert 'SomeType' to mapped object type`, newFileContent: `type K = "foo" | "bar"; interface Foo { } interface Bar { } type SomeType = Foo & Bar & { [prop in K]: any; } & { a: number; };` })
{ "end_byte": 449, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToMappedObjectType8.ts" }
TypeScript/tests/cases/fourslash/codeFixSpelling1.ts_0_257
/// <reference path='fourslash.ts' /> ////[|function foo(s: string) { //// return s.toStrang(); ////}|] verify.rangeAfterCodeFix(`function foo(s: string) { return s.toString(); }`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0);
{ "end_byte": 257, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpelling1.ts" }
TypeScript/tests/cases/fourslash/completionsImport_shadowedByLocal.ts_0_399
/// <reference path="fourslash.ts" /> // @noLib: true // @Filename: /a.ts ////export const foo = 0; // @Filename: /b.ts ////const foo = 1; ////fo/**/ verify.completions({ marker: "", exact: completion.globalsPlus([ { name: "foo", text: "const foo: 1", }, ], { noLib: true }), preferences: { includeCompletionsForModuleExports: true }, });
{ "end_byte": 399, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_shadowedByLocal.ts" }
TypeScript/tests/cases/fourslash/goToImplementationInterfaceMethod_11.ts_0_326
/// <reference path='fourslash.ts'/> // Should handle members of object literals in type assertion expressions //// interface Foo { //// hel/*reference*/lo(): void; //// } //// //// var x = <Foo> { [|hello|]: () => {} }; //// var y = <Foo> (((({ [|hello|]: () => {} })))); verify.baselineGoToImplementation("reference");
{ "end_byte": 326, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationInterfaceMethod_11.ts" }
TypeScript/tests/cases/fourslash/linkedEditingJsxTag10.ts_0_1208
/// <reference path='fourslash.ts' /> // @Filename: /jsx0.tsx ////const jsx = </*0*/> // @Filename: /jsx1.tsx ////const jsx = <//*1*/> // @Filename: /jsx2.tsx ////const jsx = </*2*/div> // @Filename: /jsx3.tsx ////const jsx = <//*3*/div> // @Filename: /jsx4.tsx ////const jsx = </*4*/div> <//*4a*/>; // @Filename: /jsx5.tsx ////const jsx = </*5*/> <//*5a*/div>; // @Filename: /jsx6.tsx ////const jsx = /*6*/div> <//*6a*/div>; // @Filename: /jsx7.tsx ////const jsx = </*7*/div> //*7a*/div>; // @Filename: /jsx8.tsx ////const jsx = </*8*/div <//*8a*/div>; // @Filename: /jsx9.tsx ////const jsx = </*9*/div> <//*9a*/div; // @Filename: /jsx10.tsx ////const jsx = </*10*/> <//*10a*/; // @Filename: /jsx11.tsx ////const jsx = </*11*/ <//*11a*/>; // @Filename: /jsx12.tsx ////const jsx = /*12*/> <//*12a*/>; // @Filename: /jsx13.tsx ////const jsx = </*13*/> //*13a*/>; // @Filename: /jsx14.tsx ////const jsx = </*14*/> </*14a*/div> <//*14b*/> <//*14c*/div>; // @Filename: /jsx15.tsx ////const jsx = </*15*/div> </*15a*/> <//*15b*/div> <//*15c*/>; // as of #57132 none of these cases should have linked editing because the tags are mismatched or missing either < or > verify.baselineLinkedEditing();
{ "end_byte": 1208, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/linkedEditingJsxTag10.ts" }
TypeScript/tests/cases/fourslash/codeFixRenameUnmatchedParameter1.ts_0_582
/// <reference path='fourslash.ts' /> // @filename: a.ts /////** //// * @param {number} a //// * @param {number} c //// */ ////function foo(a: number, b: string) { //// a; //// b; ////} verify.codeFixAvailable([ { description: "Delete unused '@param' tag 'c'" }, { description: "Rename '@param' tag name 'c' to 'b'" }, ]); verify.codeFix({ description: [ts.Diagnostics.Rename_param_tag_name_0_to_1.message, "c", "b"], index: 1, newFileContent: `/** * @param {number} a * @param {number} b */ function foo(a: number, b: string) { a; b; }` });
{ "end_byte": 582, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRenameUnmatchedParameter1.ts" }
TypeScript/tests/cases/fourslash/moveToFile_expandSelectionRange10.ts_0_643
/// <reference path='fourslash.ts' /> //@Filename: /bar.ts //// // @Filename: /a.ts ////const b = 2;[| ////const a = 1; ////function add(x: number, y: number): number; ////function add(x: string, y: string): string; ////function add(x: any, y: any) { //// return x + y; ////} ////|] ////const c = 3; verify.moveToFile({ newFileContents: { "/a.ts": `const b = 2; const c = 3;`, "/bar.ts": ` const a = 1; 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: "/bar.ts" } });
{ "end_byte": 643, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_expandSelectionRange10.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteral.ts_0_804
/// <reference path='fourslash.ts'/> ////type Options = "Option 1" | "Option 2" | "Option 3"; ////var x: Options = "[|/*1*/Option 3|]"; //// ////function f(a: Options) { }; ////f("/*2*/ verify.completions( { marker: "1", exact: [ { name: "Option 1", replacementSpan: test.ranges()[0], commitCharacters: [] }, { name: "Option 2", replacementSpan: test.ranges()[0], commitCharacters: [] }, { name: "Option 3", replacementSpan: test.ranges()[0], commitCharacters: [] } ] }, { marker: "2", exact: [ { name: "Option 1", replacementSpan: test.ranges()[1], commitCharacters: [] }, { name: "Option 2", replacementSpan: test.ranges()[1], commitCharacters: [] }, { name: "Option 3", replacementSpan: test.ranges()[1], commitCharacters: [] } ] } );
{ "end_byte": 804, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesSuper.ts_0_1232
/// <reference path='fourslash.ts' /> ////class SuperType { //// superMethod() { //// } //// //// static superStaticMethod() { //// return 10; //// } ////} //// ////class SubType extends SuperType { //// public prop1 = [|s/**/uper|].superMethod; //// private prop2 = [|super|].superMethod; //// //// constructor() { //// [|super|](); //// } //// //// public method1() { //// return [|super|].superMethod(); //// } //// //// private method2() { //// return [|super|].superMethod(); //// } //// //// public method3() { //// var x = () => [|super|].superMethod(); //// //// // Bad but still gets highlighted //// function f() { //// [|super|].superMethod(); //// } //// } //// //// // Bad but still gets highlighted. //// public static statProp1 = super.superStaticMethod; //// //// public static staticMethod1() { //// return super.superStaticMethod(); //// } //// //// private static staticMethod2() { //// return super.superStaticMethod(); //// } //// //// // Are not actually 'super' keywords. //// super = 10; //// static super = 20; ////} verify.baselineDocumentHighlights();
{ "end_byte": 1232, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesSuper.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportAllowSyntheticDefaultImports0.ts_0_344
/// <reference path="fourslash.ts" /> // @AllowSyntheticDefaultImports: true // @Filename: a/f1.ts //// [|export var x = 0; //// bar/*0*/();|] // @Filename: a/foo.d.ts //// declare function bar(): number; //// export = bar; //// export as namespace bar; verify.importFixAtPosition([ `import bar from "./foo"; export var x = 0; bar();` ]);
{ "end_byte": 344, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportAllowSyntheticDefaultImports0.ts" }
TypeScript/tests/cases/fourslash/navigationBarItemsSymbols4.ts_0_2114
/// <reference path="fourslash.ts"/> // @checkJs: true // @allowJs: true // @target: es6 // @Filename: file.js ////const _sym = Symbol("_sym"); ////class MyClass { //// constructor() { //// // Dynamic assignment properties can't show up in navigation, //// // as they're not syntactic members //// // Additonally, late bound members are always filtered out, besides //// this[_sym] = "ok"; //// } //// //// method() { //// this[_sym] = "yep"; //// const x = this[_sym]; //// } ////} verify.navigationTree({ "text": "<global>", "kind": "script", "childItems": [ { "text": "_sym", "kind": "const" }, { "text": "MyClass", "kind": "class", "childItems": [ { "text": "constructor", "kind": "constructor" }, { "text": "method", "kind": "method", "childItems": [ { "text": "x", "kind": "const" } ] } ] } ] }); verify.navigationBar([ { "text": "<global>", "kind": "script", "childItems": [ { "text": "_sym", "kind": "const" }, { "text": "MyClass", "kind": "class" } ] }, { "text": "MyClass", "kind": "class", "childItems": [ { "text": "constructor", "kind": "constructor" }, { "text": "method", "kind": "method", } ], "indent": 1 }, { "text": "method", "kind": "method", "childItems": [ { "text": "x", "kind": "const" } ], "indent": 2 } ]);
{ "end_byte": 2114, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsSymbols4.ts" }
TypeScript/tests/cases/fourslash/inlayHintsWithClosures.ts_0_365
/// <reference path="fourslash.ts" /> //// function foo1(a: number) { //// return (b: number) => { //// return a + b //// } //// } //// foo1(1)(2); //// function foo2(a: (b: number) => number) { //// return a(1) + 2 //// } //// foo2((c: number) => c + 1); verify.baselineInlayHints(undefined, { includeInlayParameterNameHints: "all", });
{ "end_byte": 365, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsWithClosures.ts" }
TypeScript/tests/cases/fourslash/codeFixConvertToTypeOnlyImport5.ts_0_615
/// <reference path="fourslash.ts" /> // @module: esnext // @verbatimModuleSyntax: true // @filename: /b.ts ////export interface I {} ////export const foo = {}; // @filename: /a.ts ////import { I, foo } from "./b"; ////foo; ////export declare const i: I; // ^ usage prevents 'Remove unused declaration' fix, // so that lack of `index` option asserts only one fix is available. // Specifically, we ensure no `Use 'import type'` fix is offered. goTo.file("/a.ts"); verify.codeFix({ description: `Use 'type I'`, newFileContent: `import { type I, foo } from "./b"; foo; export declare const i: I;`, });
{ "end_byte": 615, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToTypeOnlyImport5.ts" }
TypeScript/tests/cases/fourslash/inlayHintsInteractiveImportType1.ts_0_310
/// <reference path="fourslash.ts" /> // @allowJs: true // @checkJs: true // @Filename: /a.js //// module.exports.a = 1 // @Filename: /b.js //// const a = require('./a'); goTo.file('/b.js') verify.baselineInlayHints(undefined, { includeInlayVariableTypeHints: true, interactiveInlayHints: true });
{ "end_byte": 310, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveImportType1.ts" }
TypeScript/tests/cases/fourslash/codeFixClassExtendAbstractExpressionWithTypeArgs.ts_0_491
/// <reference path='fourslash.ts' /> ////function foo<T>(a: T) { //// a; //// abstract class C<U> { //// abstract a: T | U; //// } //// return C; ////} //// ////class B extends foo("s")<number> {[| |]} verify.codeFix({ description: "Implement inherited abstract class", newFileContent: `function foo<T>(a: T) { a; abstract class C<U> { abstract a: T | U; } return C; } class B extends foo("s")<number> { a: string | number; }` });
{ "end_byte": 491, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassExtendAbstractExpressionWithTypeArgs.ts" }
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization19.ts_0_264
/// <reference path='fourslash.ts' /> // @strict: true //// class T { //// // comment //// a: 2; //// } verify.codeFix({ description: `Add initializer to property 'a'`, newFileContent: `class T { // comment a: 2 = 2; }`, index: 2 })
{ "end_byte": 264, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization19.ts" }
TypeScript/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers.ts_0_155
/// <reference path='fourslash.ts' /> ////var aa = 1; ////enum a { /*enumValueName1*/ verify.completions({ marker: test.markers(), exact: undefined });
{ "end_byte": 155, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enumMembers.ts" }
TypeScript/tests/cases/fourslash/syntacticClassificationForJSDocTemplateTag.ts_0_818
/// <reference path="fourslash.ts"/> /////** @template T baring strait */ ////function ident<T>: T { ////} const c = classification("original"); verify.syntacticClassificationsAre( c.comment("/** "), c.punctuation("@"), c.docCommentTagName("template"), c.typeParameterName("T"), c.comment("baring strait "), c.comment("*/"), c.keyword("function"), c.identifier("ident"), c.punctuation("<"), c.typeParameterName("T"), c.punctuation(">"), c.punctuation(":"), c.identifier("T"), c.punctuation("{"), c.punctuation("}")); const c2 = classification("2020"); verify.semanticClassificationsAre("2020", c2.semanticToken("function.declaration", "ident"), c2.semanticToken("typeParameter.declaration", "T"), c2.semanticToken("typeParameter", "T"), );
{ "end_byte": 818, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationForJSDocTemplateTag.ts" }
TypeScript/tests/cases/fourslash/callHierarchyDecorator.ts_0_242
/// <reference path="fourslash.ts" /> // @experimentalDecorators: true //// @bar //// class Foo { //// } //// //// function /**/bar() { //// baz(); //// } //// //// function baz() { //// } goTo.marker(); verify.baselineCallHierarchy();
{ "end_byte": 242, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyDecorator.ts" }
TypeScript/tests/cases/fourslash/smartSelection_simple2.ts_0_220
/// <reference path="fourslash.ts" /> ////export interface IService { //// _serviceBrand: any; //// //// open(ho/*1*/st: number, data: any): Promise<any>; //// bar(): void/*2*/ ////} verify.baselineSmartSelection();
{ "end_byte": 220, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_simple2.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingParam17.ts_0_487
/// <reference path="fourslash.ts" /> // @filename: /a.ts //// export class A {} // @filename: /b.ts //// export function f(a: any) {} // @filename: /c.ts //// import { A } from './a'; //// import { f } from './b'; //// //// f({}, new A()); goTo.file("/c.ts"); verify.codeFix({ description: [ts.Diagnostics.Add_missing_parameter_to_0.message, "f"], index: 0, newFileContent: { "/b.ts": `import { A } from "./a"; export function f(a: any, p0: A) {}`, }, });
{ "end_byte": 487, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingParam17.ts" }
TypeScript/tests/cases/fourslash/findAllRefsImportStarOfExportEquals.ts_0_1262
/// <reference path="fourslash.ts" /> // @allowSyntheticDefaultimports: true // @Filename: /node_modules/a/index.d.ts ////[|declare function /*a0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}a|](): void;|] ////[|declare namespace /*a1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}a|] { //// export const x: number; ////}|] ////[|export = /*a2*/[|{| "contextRangeIndex": 4 |}a|];|] // Import with different name and we find local refs // @Filename: /b.ts ////[|import /*b0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}b|] from "a";|] /////*b1*/[|b|](); ////[|b|].x; // Import with same name and we find all refs // @Filename: /c.ts ////[|import /*c0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 10 |}a|] from "a";|] /////*c1*/[|a|](); /////*c2*/[|a|].x; verify.noErrors(); const [a0Def, a0, a1Def, a1, a2Def, a2, b0Def, b0, b1, b2, c0Def, c0, c1, c2] = test.ranges(); const aRanges = [a0, a1, a2]; const bRanges = [b0, b1, b2]; const cRanges = [c0, c1, c2]; verify.baselineFindAllReferences('a0', 'a1', 'a2', 'b0', 'b1', 'c0', 'c1', 'c2'); verify.baselineRename(aRanges); verify.baselineRename(bRanges); verify.baselineRename(cRanges);
{ "end_byte": 1262, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsImportStarOfExportEquals.ts" }
TypeScript/tests/cases/fourslash/suggestionNoDuplicates.ts_0_439
// @strict: false /// <reference path="fourslash.ts" /> // @Filename: foo.ts //// import { f } from [|'m'|] //// f // @Filename: node_modules/m/index.js //// module.exports.f = function (x) { return x } verify.getSemanticDiagnostics([]) verify.getSuggestionDiagnostics([{ code: 7016, message: "Could not find a declaration file for module 'm'. '/tests/cases/fourslash/node_modules/m/index.js' implicitly has an 'any' type.", }])
{ "end_byte": 439, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/suggestionNoDuplicates.ts" }
TypeScript/tests/cases/fourslash/typeReferenceAndImportDeprecated.ts_0_1210
/// <reference path="fourslash.ts" /> // @filename: types.ts //// /** @deprecated */ //// export type SelectorMap<T extends Record<string, (...params: unknown[]) => unknown>> = { //// [key in keyof T]: T[key]; //// }; // @filename: index.ts //// /** @deprecated */ //// export type SelectorMap<T extends Record<string, (...params: unknown[]) => unknown>> = { //// [key in keyof T]: T[key]; //// }; //// //// export declare const value2: { //// sliceSelectors: <FuncMap extends [|import('./types').SelectorMap<FuncMap>|]>(selectorsBySlice: FuncMap) => { [P in keyof FuncMap]: Parameters<FuncMap[P]> }; //// }; //// //// export declare const value3: { //// sliceSelectors: <FuncMap extends [|SelectorMap<FuncMap>|]>(selectorsBySlice: FuncMap) => { [P in keyof FuncMap]: Parameters<FuncMap[P]> }; //// }; goTo.file("index.ts"); const ranges = test.ranges(); verify.getSuggestionDiagnostics([ { "code": 6385, "message": "'SelectorMap' is deprecated.", "reportsDeprecated": true, "range": ranges[0] }, { "code": 6385, "message": "'SelectorMap' is deprecated.", "reportsDeprecated": true, "range": ranges[1] }, ]);
{ "end_byte": 1210, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/typeReferenceAndImportDeprecated.ts" }
TypeScript/tests/cases/fourslash/semanticClassificationConstAssertion.ts_0_467
/// <reference path="fourslash.ts"/> ////1 as const; const c1 = classification("original"); verify.syntacticClassificationsAre( c1.numericLiteral("1"), c1.keyword("as"), c1.keyword("const"), c1.punctuation(";") ); const c2 = classification("2020"); verify.syntacticClassificationsAre( c2.semanticToken("number", "1"), c2.semanticToken("keyword", "as"), c2.semanticToken("keyword", "const"), c2.semanticToken("punctuation", ";") );
{ "end_byte": 467, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semanticClassificationConstAssertion.ts" }
TypeScript/tests/cases/fourslash/codeFixConstToLet2.ts_0_202
/// <reference path='fourslash.ts' /> ////const a = 1, b = 1; ////b = 2; verify.codeFix({ description: "Convert 'const' to 'let'", index: 0, newFileContent: `let a = 1, b = 1; b = 2;` });
{ "end_byte": 202, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConstToLet2.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties20.ts_0_266
/// <reference path='fourslash.ts' /> ////type T = { foo: number }; ////const foo: T[] = []; ////[|foo.push({ })|] verify.codeFix({ index: 0, description: ts.Diagnostics.Add_missing_properties.message, newRangeContent: `foo.push({ foo: 0 })`, });
{ "end_byte": 266, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties20.ts" }
TypeScript/tests/cases/fourslash/inlineVariableTypeof.ts_0_188
/// <reference path="fourslash.ts" /> ////const /*a*/Foo/*b*/ = class Foo {} ////type FooConstructor = typeof Foo; goTo.select("a", "b"); verify.not.refactorAvailable("Inline variable");
{ "end_byte": 188, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableTypeof.ts" }
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_interface.ts_0_608
/// <reference path='fourslash.ts' /> ////interface IFoo { //// method(x: string, y: string): void; ////} ////const x: IFoo = { //// method(/*a*/x: string, y: string/*b*/): void {}, ////}; 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: `interface IFoo { method({ x, y }: { x: string; y: string; }): void; } const x: IFoo = { method({ x, y }: { x: string; y: string; }): void {}, };` });
{ "end_byte": 608, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_interface.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_decorators2.ts_0_391
/// <reference path='fourslash.ts' /> // @experimentalDecorators: true // @Filename: /a.ts ////const decorator1: any = () => {}; ////[|@decorator1 class Foo { ////}|] verify.noErrors(); verify.moveToNewFile({ newFileContents: { "/a.ts": `export const decorator1: any = () => {}; `, "/Foo.ts": `import { decorator1 } from "./a"; @decorator1 class Foo { } ` } });
{ "end_byte": 391, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_decorators2.ts" }
TypeScript/tests/cases/fourslash/incrementalParsingWithJsDoc.ts_0_421
/// <reference path="fourslash.ts"/> ////[|import a from 'a/aaaaaaa/aaaaaaa/aaaaaa/aaaaaaa'; /////**/import b from 'b'; ////import c from 'c';|] //// ////[|/** @internal */|] ////export class LanguageIdentifier[| { }|] // Force a syntax tree ot be created. verify.outliningSpansInCurrentFile(test.ranges()); goTo.marker(""); edit.backspace(test.marker("").position); verify.outliningSpansInCurrentFile(test.ranges());
{ "end_byte": 421, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incrementalParsingWithJsDoc.ts" }