_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts_0_353 | /// <reference path='fourslash.ts' />
//// const foo = /*a*/a/*b*/ => { return; };
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Add or remove braces in an arrow function",
actionName: "Remove braces from arrow function",
actionDescription: "Remove braces from arrow function",
newContent: `const foo = a => void 0;`,
});
| {
"end_byte": 353,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction21.ts"
} |
TypeScript/tests/cases/fourslash/completionListInScope_doesNotIncludeAugmentations.ts_0_226 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////import * as self from "./a";
////
////declare module "a" {
//// export const a: number;
////}
////
/////**/
verify.completions({ marker: "", excludes: "a" });
| {
"end_byte": 226,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInScope_doesNotIncludeAugmentations.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringParameterArrayBindingPatternDefaultValues2.ts_0_872 | /// <reference path='fourslash.ts' />
////declare var console: {
//// log(msg: any): void;
////}
////type Robot = [string, string[]];
////var robotA: Robot = ["trimmer", ["trimming", "edging"]];
////function foo1([, skillA = ["noSkill", "noSkill"]]: Robot= ["name", ["skill1", "skill2"]]) {
//// console.log(skillA);
////}
////function foo2([nameMB = "noName"]: Robot = ["name", ["skill1", "skill2"]]) {
//// console.log(nameMB);
////}
////function foo3([nameMA = "noName", [
//// primarySkillA = "primary",
//// secondarySkillA = "secondary"
////] = ["noSkill", "noSkill"]]: Robot) {
//// console.log(nameMA);
////}
////foo1(robotA);
////foo1(["roomba", ["vacuum", "mopping"]]);
////foo2(robotA);
////foo2(["roomba", ["vacuum", "mopping"]]);
////foo3(robotA);
////foo3(["roomba", ["vacuum", "mopping"]]);
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 872,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringParameterArrayBindingPatternDefaultValues2.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteralExport.ts_0_925 | /// <reference path='fourslash.ts' />
// Should define spans for replacement that appear after the last directory seperator in export statements
// @typeRoots: my_typings
// @Filename: test.ts
//// export * from "./some/*0*/
//// export * from "./sub/some/*1*/";
//// export * from "[|some-/*2*/|]";
//// export * from "..//*3*/";
//// export {} from ".//*4*/";
// @Filename: someFile1.ts
//// /*someFile1*/
// @Filename: sub/someFile2.ts
//// /*someFile2*/
// @Filename: my_typings/some-module/index.d.ts
//// export var x = 9;
verify.completions(
{ marker: ["0", "4"], exact: ["someFile1", "my_typings", "sub"], isNewIdentifierLocation: true },
{ marker: "1", exact: "someFile2", isNewIdentifierLocation: true },
{ marker: "2", exact: { name: "some-module", replacementSpan: test.ranges()[0] }, isNewIdentifierLocation: true },
{ marker: "3", exact: "fourslash", isNewIdentifierLocation: true },
);
| {
"end_byte": 925,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralExport.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingMember16.ts_0_471 | /// <reference path='fourslash.ts' />
////interface Foo {}
////namespace Foo {
//// export function bar() { }
////}
////Foo.test();
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "test"],
applyChanges: true,
newFileContent:
`interface Foo {}
namespace Foo {
export function bar() { }
export function test() {
throw new Error("Function not implemented.");
}
}
Foo.test();`
});
| {
"end_byte": 471,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember16.ts"
} |
TypeScript/tests/cases/fourslash/extract-method_jsxFragment1.ts_0_575 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: a.tsx
////function Foo() {
//// return (
//// <div>
//// /*a*/<></>/*b*/
//// </div>
//// );
////}
goTo.file("a.tsx");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_1",
actionDescription: "Extract to function in global scope",
newContent:
`function Foo() {
return (
<div>
{newFunction()}
</div>
);
}
function /*RENAME*/newFunction() {
return <></>;
}
`
});
| {
"end_byte": 575,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method_jsxFragment1.ts"
} |
TypeScript/tests/cases/fourslash/formattingOnSingleLineBlocks.ts_0_157 | /// <reference path='fourslash.ts' />
////class C
////{}
////if (true)
////{}
format.document();
verify.currentFileContentIs(
`class C { }
if (true) { }`); | {
"end_byte": 157,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnSingleLineBlocks.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportNodeModules8.ts_0_612 | /// <reference path="fourslash.ts" />
//// [|f1/*0*/('');|]
// @Filename: package.json
//// { "dependencies": { "@scope/package-name": "latest" } }
// @Filename: node_modules/@scope/package-name/bin/lib/index.d.ts
//// export function f1(text: string): string;
// @Filename: node_modules/@scope/package-name/bin/lib/index.js
//// function f1(text) { }
//// exports.f1 = f1;
// @Filename: node_modules/@scope/package-name/package.json
//// {
//// "main": "bin/lib/index.js",
//// "types": "bin/lib/index.d.ts"
//// }
verify.importFixAtPosition([
`import { f1 } from "@scope/package-name";
f1('');`
]);
| {
"end_byte": 612,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportNodeModules8.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForDestructuringShorthandInitializer.ts_0_146 | /// <reference path='fourslash.ts' />
////let a = '';
////let b: string;
////({b = /**/a} = {b: 'b'});
verify.quickInfoAt("", "let a: string");
| {
"end_byte": 146,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForDestructuringShorthandInitializer.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_differentDirectories.ts_0_622 | /// <reference path='fourslash.ts' />
//@moduleResolution: bundler
//@module: esnext
// @Filename: /src/dir1/a.ts
////import { b } from './other';
////[|const y = b + 10;|]
////y;
// @Filename: /src/dir1/other.ts
////export const b = 1;
//@Filename: /src/dir2/bar.ts
////import './blah';
////const a = 2;
verify.moveToFile({
newFileContents: {
"/src/dir1/a.ts":
`import { y } from '../dir2/bar';
y;`,
"/src/dir2/bar.ts":
`import { b } from '../dir1/other';
import './blah';
const a = 2;
export const y = b + 10;
`,
},
interactiveRefactorArguments: { targetFile: "/src/dir2/bar.ts" },
});
| {
"end_byte": 622,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_differentDirectories.ts"
} |
TypeScript/tests/cases/fourslash/jsdocImportTagCompletion3.ts_0_298 | ///<reference path="fourslash.ts" />
// @allowJS: true
// @checkJs: true
// @module: esnext
// @filename: ./a.ts
////export interface A {}
// @filename: ./b.ts
////export interface B {}
// @filename: ./c.js
/////**
//// * @import * as types from ".//**/"
//// */
verify.baselineCompletions();
| {
"end_byte": 298,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocImportTagCompletion3.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_constructor.ts_0_686 | /// <reference path='fourslash.ts' />
////class Foo {
//// t: string;
//// s: string;
//// /*a*/constructor/*b*/(t: string, s: string) {
//// this.t = t;
//// this.s = s;
//// }
////}
////var foo = new Foo("a", "b");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `class Foo {
t: string;
s: string;
constructor({ t, s }: { t: string; s: string; }) {
this.t = t;
this.s = s;
}
}
var foo = new Foo({ t: "a", s: "b" });`
}); | {
"end_byte": 686,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_constructor.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue24.ts_0_326 | /// <reference path='fourslash.ts' />
//// function Foo (a: () => number) { a() }
//// Foo(() => { /* leading */ 1 /* trailing */ })
verify.codeFix({
description: "Add a return statement",
index: 0,
newFileContent:
`function Foo (a: () => number) { a() }
Foo(() => { /* leading */ return 1 /* trailing */ })`
}) | {
"end_byte": 326,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue24.ts"
} |
TypeScript/tests/cases/fourslash/formattingSkippedTokens.ts_0_533 | /// <reference path='fourslash.ts' />
/////*1*/foo(): Bar { }
/////*2*/function Foo () # { }
/////*3*/4+:5
//// module M {
////function a(
/////*4*/ : T) { }
////}
/////*5*/var x =
format.document();
goTo.marker('1');
verify.currentLineContentIs('foo(): Bar { }');
goTo.marker('2');
verify.currentLineContentIs('function Foo() # { }');
goTo.marker('3');
verify.currentLineContentIs('4 +: 5');
goTo.marker('4');
verify.currentLineContentIs(' : T) { }');
goTo.marker('5');
verify.currentLineContentIs('var x =');
| {
"end_byte": 533,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingSkippedTokens.ts"
} |
TypeScript/tests/cases/fourslash/formattingOnVariety.ts_0_1605 | /// <reference path='fourslash.ts'/>
// dummy content to satisfy fourslash for a blank file
////function f(a,b,c,d){/*1*/
////for(var i=0;i<10;i++){/*2*/
////var a=0;/*3*/
////var b=a+a+a*a%a/2-1;/*4*/
////b+=a;/*5*/
////++b;/*6*/
////f(a,b,c,d);/*7*/
////if(1===1){/*8*/
////var m=function(e,f){/*9*/
////return e^f;/*10*/
////}/*11*/
////}/*12*/
////}/*13*/
////}/*14*/
////
////for (var i = 0 ; i < this.foo(); i++) {/*15*/
////}/*16*/
format.document();
goTo.marker("1");
verify.currentLineContentIs("function f(a, b, c, d) {");
goTo.marker("2");
verify.currentLineContentIs(" for (var i = 0; i < 10; i++) {");
goTo.marker("3");
verify.currentLineContentIs(" var a = 0;");
goTo.marker("4");
verify.currentLineContentIs(" var b = a + a + a * a % a / 2 - 1;");
goTo.marker("5");
verify.currentLineContentIs(" b += a;");
goTo.marker("6");
verify.currentLineContentIs(" ++b;");
goTo.marker("7");
verify.currentLineContentIs(" f(a, b, c, d);");
goTo.marker("8");
verify.currentLineContentIs(" if (1 === 1) {");
goTo.marker("9");
verify.currentLineContentIs(" var m = function(e, f) {");
goTo.marker("10");
verify.currentLineContentIs(" return e ^ f;");
goTo.marker("11");
verify.currentLineContentIs(" }");
goTo.marker("12");
verify.currentLineContentIs(" }");
goTo.marker("13");
verify.currentLineContentIs(" }");
goTo.marker("14");
verify.currentLineContentIs("}");
goTo.marker("15");
verify.currentLineContentIs("for (var i = 0; i < this.foo(); i++) {");
goTo.marker("16");
verify.currentLineContentIs("}"); | {
"end_byte": 1605,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnVariety.ts"
} |
TypeScript/tests/cases/fourslash/tsxGoToDefinitionClassInDifferentFile.ts_0_259 | /// <reference path="fourslash.ts" />
// @jsx: preserve
// @Filename: C.tsx
////export default class /*def*/C {}
// @Filename: a.tsx
////import C from "./C";
////const foo = </*use*/C />;
verify.noErrors();
verify.baselineGetDefinitionAtPosition("use");
| {
"end_byte": 259,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxGoToDefinitionClassInDifferentFile.ts"
} |
TypeScript/tests/cases/fourslash/jsDocFunctionSignatures12.ts_0_620 | ///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: jsDocFunctionSignatures.js
/////**
//// * @param {{
//// * stringProp: string,
//// * numProp: number,
//// * boolProp: boolean,
//// * anyProp: *,
//// * anotherAnyProp:
//// * *,
//// * functionProp:
//// * function(string,
//// * *):
//// * *
//// * }} o
//// */
////function f1(o) {
//// o/**/;
////}
goTo.marker();
verify.quickInfoIs(`(parameter) o: {
stringProp: string;
numProp: number;
boolProp: boolean;
anyProp: any;
anotherAnyProp: any;
functionProp: (arg0: string, arg1: any) => any;
}`);
| {
"end_byte": 620,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocFunctionSignatures12.ts"
} |
TypeScript/tests/cases/fourslash/yieldKeywordFormatting.ts_0_706 | /// <reference path="fourslash.ts"/>
////function* g3() {
/////*1*/ yield ;
/////*2*/ g3().next( yield );
/////*3*/ yield new Bar;
/////*4*/ yield * new Bar;
/////*5*/ yield * [new Bar];
/////*6*/ yield+ 1;
/////*7*/ yield++ 1;
////}
format.document();
let expected =
[
" yield;",
" g3().next(yield);",
" yield new Bar;",
" yield* new Bar;",
" yield* [new Bar];",
" yield + 1;", // Should be "yield +1". This case is covered by bug 3028.
" yield ++1;"
];
for (let i = 0; i < expected.length; i++) {
goTo.marker("" + (i + 1));
verify.currentLineContentIs(expected[i]);
}
| {
"end_byte": 706,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/yieldKeywordFormatting.ts"
} |
TypeScript/tests/cases/fourslash/completionListInObjectLiteralAssignmentPattern2.ts_1_153 | /// <reference path="fourslash.ts" />
////let x = { a: 1, b: 2 };
////let y = ({ a, /**/ } = x, 1);
verify.completions({ marker: "", exact: ["b"] });
| {
"end_byte": 153,
"start_byte": 1,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectLiteralAssignmentPattern2.ts"
} |
TypeScript/tests/cases/fourslash/referencesForInheritedProperties4.ts_3_266 | / <reference path='fourslash.ts'/>
//// class class1 extends class1 {
//// /*1*/doStuff() { }
//// /*2*/propName: string;
//// }
////
//// var c: class1;
//// c./*3*/doStuff();
//// c./*4*/propName;
verify.baselineFindAllReferences('1', '2', '3', '4');
| {
"end_byte": 266,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForInheritedProperties4.ts"
} |
TypeScript/tests/cases/fourslash/formattingChangeSettings.ts_0_450 | /// <reference path='fourslash.ts'/>
////module M {
/////*1*/var x=1;
////}
var originalOptions = format.copyFormatOptions();
format.document();
goTo.marker("1");
verify.currentLineContentIs(" var x = 1;");
var copy = format.copyFormatOptions();
copy.TabSize = 2;
copy.IndentSize = 2;
format.setFormatOptions(copy);
format.document();
goTo.marker("1");
verify.currentLineContentIs(" var x = 1;");
format.setFormatOptions(originalOptions); | {
"end_byte": 450,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingChangeSettings.ts"
} |
TypeScript/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction1.ts_0_784 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface OptionPropBag {
//// /*pt1*/propx: number
//// propString: "hell"
//// /*pt2*/optional?: boolean
//// }
//// declare function /*opt*/Opt(attributes: OptionPropBag): JSX.Element;
//// let opt = <[|O/*one*/pt|] />;
//// let opt1 = <[|Op/*two*/t|] [|pr/*p1*/opx|]={100} />;
//// let opt2 = <[|Op/*three*/t|] propx={100} [|opt/*p2*/ional|] />;
//// let opt3 = <[|Op/*four*/t|] wr/*p3*/ong />;
verify.baselineGoToDefinition(
"one",
"two",
"three",
"four",
"p1",
"p2",
);
| {
"end_byte": 784,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction1.ts"
} |
TypeScript/tests/cases/fourslash/importFixesWithPackageJsonInSideAnotherPackage.ts_0_1046 | /// <reference path="fourslash.ts" />
// @Filename: /project/tsconfig.json
////{
//// "compilerOptions": {
//// "jsx": "react",
//// "jsxFactory": "h"
//// }
////}
// @Filename: /project/app.tsx
////const state = useMemo(() => 'Hello', []);
// @Filename: /project/component.tsx
////import { useEffect } from "preact/hooks";
// @Filename: /project/node_modules/preact/package.json
////{ "name": "preact", "version": "10.3.4", "types": "src/index.d.ts" }
// @Filename: /project/node_modules/preact/hooks/package.json
////{ "name": "hooks", "version": "0.1.0", "types": "src/index.d.ts" }
// @Filename: /project/node_modules/preact/hooks/src/index.d.ts
////export function useEffect(): void;
////export function useMemo<T>(factory: () => T, inputs: ReadonlyArray<unknown> | undefined): T;
goTo.file("/project/app.tsx");
verify.importFixAtPosition([
getImportFixContent("preact/hooks"),
]);
function getImportFixContent(from: string) {
return `import { useMemo } from "${from}";
const state = useMemo(() => 'Hello', []);`;
}
| {
"end_byte": 1046,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importFixesWithPackageJsonInSideAnotherPackage.ts"
} |
TypeScript/tests/cases/fourslash/tsxCompletionOnClosingTagWithoutJSX2.ts_3_219 | / <reference path='fourslash.ts' />
//@Filename: file.tsx
//// var x1 = <div>
//// <h1> Hello world </ /*2*/>
//// </ /*1*/>
verify.completions({ marker: "1", exact: "div" }, { marker: "2", exact: "h1" });
| {
"end_byte": 219,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletionOnClosingTagWithoutJSX2.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType63.ts_0_251 | /// <reference path='fourslash.ts' />
//// type T = { c: string } & { d: boolean }
//// function foo(a: /*a*/{ a: number | string, b: string } & T/*b*/) { }
goTo.select("a", "b");
verify.not.refactorAvailable("Extract type", "Extract to interface")
| {
"end_byte": 251,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType63.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess11.ts_0_525 | /// <reference path='fourslash.ts' />
//// class A {
//// /*a*/public a!: string = "foo";/*b*/
//// }
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Generate 'get' and 'set' accessors",
actionName: "Generate 'get' and 'set' accessors",
actionDescription: "Generate 'get' and 'set' accessors",
newContent: `class A {
private /*RENAME*/_a!: string = "foo";
public get a(): string {
return this._a;
}
public set a(value: string) {
this._a = value;
}
}`,
});
| {
"end_byte": 525,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess11.ts"
} |
TypeScript/tests/cases/fourslash/autoImportPathsAliasesAndBarrels.ts_0_1312 | /// <reference path="fourslash.ts" />
// @Filename: /tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "commonjs",
//// "paths": {
//// "~/*": ["src/*"]
//// }
//// }
////}
// @Filename: /src/dirA/index.ts
//// export * from "./thing1A";
//// export * from "./thing2A";
// @Filename: /src/dirA/thing1A.ts
//// export class Thing1A {}
//// Thing/**/
// @Filename: /src/dirA/thing2A.ts
//// export class Thing2A {}
// @Filename: /src/dirB/index.ts
//// export * from "./thing1B";
//// export * from "./thing2B";
// @Filename: /src/dirB/thing1B.ts
//// export class Thing1B {}
// @Filename: /src/dirB/thing2B.ts
//// export class Thing2B {}
verify.completions({
marker: "",
includes: [{
name: "Thing2A",
source: "./thing2A",
sourceDisplay: "./thing2A",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
}, {
name: "Thing1B",
source: "~/dirB",
sourceDisplay: "~/dirB",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
}, {
name: "Thing2B",
source: "~/dirB",
sourceDisplay: "~/dirB",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
}],
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: true,
},
});
| {
"end_byte": 1312,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPathsAliasesAndBarrels.ts"
} |
TypeScript/tests/cases/fourslash/organizeImportsAttributes2.ts_0_650 | /// <reference path="fourslash.ts" />
////import { A } from "./a";
////import { C } from "./a" assert { type: "a" };
////import { Z } from "./z";
////import { A as D } from "./a" assert { type: "b" };
////import { E } from "./a" with { type: "a" };
////import { F } from "./a" assert { type: "a" };
////import { B } from "./a";
////
////export type G = A | B | C | D | E | F | Z;
verify.organizeImports(
`import { A, B } from "./a";
import { C, F } from "./a" assert { type: "a" };
import { A as D } from "./a" assert { type: "b" };
import { E } from "./a" with { type: "a" };
import { Z } from "./z";
export type G = A | B | C | D | E | F | Z;`); | {
"end_byte": 650,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsAttributes2.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_varArrowFunction.ts_0_207 | /// <reference path='fourslash.ts' />
////var foo = /*a*/(a: number, b: number)/*b*/ => {};
////foo(1, 2);
goTo.select("a", "b");
verify.not.refactorAvailable("Convert parameters to destructured object");
| {
"end_byte": 207,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_varArrowFunction.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionObjectLiteralProperties.ts_0_637 | /// <reference path='fourslash.ts' />
////var o = {
//// /*valueDefinition*/value: 0,
//// get /*getterDefinition*/getter() {return 0 },
//// set /*setterDefinition*/setter(v: number) { },
//// /*methodDefinition*/method: () => { },
//// /*es6StyleMethodDefinition*/es6StyleMethod() { }
////};
////
////o./*valueReference*/value;
////o./*getterReference*/getter;
////o./*setterReference*/setter;
////o./*methodReference*/method;
////o./*es6StyleMethodReference*/es6StyleMethod;
verify.baselineGetDefinitionAtPosition("valueReference", "getterReference", "setterReference", "methodReference", "es6StyleMethodReference");
| {
"end_byte": 637,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionObjectLiteralProperties.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixDefaultExport1.ts_0_341 | /// <reference path="fourslash.ts" />
// @Filename: /foo-bar.ts
////export default function fooBar();
// @Filename: /b.ts
////[|import * as fb from "./foo-bar";
////foo/**/Bar|]
goTo.file("/b.ts");
// No suggestion to use `fb.fooBar` (which would be wrong)
verify.importFixAtPosition([`import fooBar, * as fb from "./foo-bar";
fooBar`]);
| {
"end_byte": 341,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixDefaultExport1.ts"
} |
TypeScript/tests/cases/fourslash/todoComments16.ts_0_80 | //// //// [|HACK 1|]
verify.todoCommentsInCurrentFile(["TODO(jason)", "HACK"]); | {
"end_byte": 80,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/todoComments16.ts"
} |
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType4.ts_0_400 | /// <reference path='fourslash.ts' />
////const foo = /*a*/()/*b*/ => {
//// return { x: 1, y: 1 };
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Infer function return type",
actionName: "Infer function return type",
actionDescription: "Infer function return type",
newContent:
`const foo = (): { x: number; y: number; } => {
return { x: 1, y: 1 };
}`
});
| {
"end_byte": 400,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType4.ts"
} |
TypeScript/tests/cases/fourslash/jsdocTypedefTagTypeExpressionCompletion.ts_0_2513 | /// <reference path="fourslash.ts"/>
////interface I {
//// age: number;
////}
//// class Foo {
//// property1: string;
//// constructor(value: number) { this.property1 = "hello"; }
//// static method1() {}
//// method3(): number { return 3; }
//// /**
//// * @param {string} foo A value.
//// * @returns {number} Another value
//// * @mytag
//// */
//// method4(foo: string) { return 3; }
//// }
//// namespace Foo.Namespace { export interface SomeType { age2: number } }
//// /**
//// * @type { /*type1*/Foo./*typeFooMember*/Namespace./*NamespaceMember*/SomeType }
//// */
////var x;
/////*globalValue*/
////x./*valueMemberOfSomeType*/
////var x1: Foo;
////x1./*valueMemberOfFooInstance*/;
////Foo./*valueMemberOfFoo*/;
//// /**
//// * @type { {/*propertyName*/ageX: number} }
//// */
////var y;
verify.completions(
{
marker: "type1",
includes: [
{ name: "Foo", kind: "class" },
{ name: "I", kind: "interface" },
],
excludes: ["Namespace", "SomeType", "x", "x1", "y", "method1", "property1", "method3", "method4", "foo"],
},
{
marker: "typeFooMember",
exact: { name: "Namespace", kind: "module", kindModifiers: "export" },
},
{
marker: "NamespaceMember",
exact: { name: "SomeType", kind: "interface", kindModifiers: "export" },
},
{
marker: "globalValue",
includes: [
{ name: "Foo", kind: "class" },
{ name: "x", kind: "var" },
{ name: "x1", kind: "var" },
{ name: "y", kind: "var" },
],
excludes: ["I", "Namespace", "SomeType", "method1", "property1", "method3", "method4", "foo"],
},
// This is TypeScript code, so the @type tag doesn't change the type of `x`.
{ marker: "valueMemberOfSomeType", exact: undefined },
{
marker: "valueMemberOfFooInstance",
exact: [
{ name: "method3", kind: "method" },
{ name: "method4", kind: "method" },
{ name: "property1", kind: "property" },
],
},
{
marker: "valueMemberOfFoo",
exact: completion.functionMembersPlus([
{ name: "method1", kind: "method", kindModifiers: "static", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "prototype", sortText: completion.SortText.LocationPriority },
]),
},
{
marker: "propertyName",
exact: undefined,
},
);
| {
"end_byte": 2513,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocTypedefTagTypeExpressionCompletion.ts"
} |
TypeScript/tests/cases/fourslash/codeFixConvertTypedefToType1.ts_0_291 | /// <reference path='fourslash.ts' />
////
//// /**
//// * @typedef {Object}Foo
//// * @property {number}bar
//// */
////
verify.codeFix({
description: ts.Diagnostics.Convert_typedef_to_TypeScript_type.message,
index: 0,
newFileContent: `
interface Foo {
bar: number;
}
`,
}); | {
"end_byte": 291,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertTypedefToType1.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType32.ts_0_172 | /// <reference path='fourslash.ts' />
//// type Item<T> = T extends (/*a*/infer P/*b*/)[] ? P : never
goTo.select("a", "b");
verify.not.refactorAvailable('Extract type')
| {
"end_byte": 172,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType32.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess40.ts_0_516 | /// <reference path='fourslash.ts' />
// @strict: true
////class A {
//// /*a*/foo?: any;/*b*/
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Generate 'get' and 'set' accessors",
actionName: "Generate 'get' and 'set' accessors",
actionDescription: "Generate 'get' and 'set' accessors",
newContent:
`class A {
private /*RENAME*/_foo?: any;
public get foo(): any {
return this._foo;
}
public set foo(value: any) {
this._foo = value;
}
}`
});
| {
"end_byte": 516,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess40.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptCompletions5.ts_0_339 | ///<reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: Foo.js
//// /**
//// * @template T
//// * @param {T} a
//// * @return {T} */
//// function foo(a) { }
//// let x = foo;
//// foo(1)./**/
verify.completions({ marker: "", includes: { name: "toExponential", kind: "method", kindModifiers: "declare" } });
| {
"end_byte": 339,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptCompletions5.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnElementAccessInWriteLocation5.ts_0_294 | /// <reference path='fourslash.ts'/>
// @strict: true
//// interface Serializer {
//// set value(v: string | number);
//// get value(): string;
//// }
//// declare let box: Serializer;
//// box['value'/*1*/] += 10;
verify.quickInfoAt('1', '(property) Serializer.value: string | number');
| {
"end_byte": 294,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnElementAccessInWriteLocation5.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpWithTriggers02.ts_0_804 | /// <reference path="fourslash.ts" />
////declare function foo<T>(x: T, y: T): T;
////declare function bar<U>(x: U, y: U): U;
////
////foo(bar/*1*/)
goTo.marker("1");
edit.insert("(");
verify.signatureHelp({
text: "bar(x: unknown, y: unknown): unknown",
triggerReason: {
kind: "characterTyped",
triggerCharacter: "(",
}
});
edit.backspace();
edit.insert("<");
verify.signatureHelp({
text: "bar<U>(x: U, y: U): U",
triggerReason: {
kind: "characterTyped",
triggerCharacter: "(",
}
});
edit.backspace();
edit.insert(",");
verify.signatureHelp({
text: "foo(x: <U>(x: U, y: U) => U, y: <U>(x: U, y: U) => U): <U>(x: U, y: U) => U",
triggerReason: {
kind: "characterTyped",
triggerCharacter: "(",
}
});
edit.backspace(); | {
"end_byte": 804,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpWithTriggers02.ts"
} |
TypeScript/tests/cases/fourslash/functionProperty.ts_0_903 | /// <reference path='fourslash.ts'/>
////var a = {
//// x(a: number) { }
////};
////
////var b = {
//// x: function (a: number) { }
////};
////
////var c = {
//// x: (a: number) => { }
////};
////a.x(/*signatureA*/1);
////b.x(/*signatureB*/1);
////c.x(/*signatureC*/1);
////a./*completionA*/;
////b./*completionB*/;
////c./*completionC*/;
////a./*quickInfoA*/x;
////b./*quickInfoB*/x;
////c./*quickInfoC*/x;
verify.signatureHelp({ marker: ["signatureA", "signatureB", "signatureC"], text: "x(a: number): void" });
const method = "(method) x(a: number): void";
const property = "(property) x: (a: number) => void";
verify.completions(
{ marker: "completionA", exact: { name: "x", text: method } },
{ marker: ["completionB", "completionC"], exact: { name: "x", text: property } },
);
verify.quickInfos({
quickInfoA: method,
quickInfoB: property,
quickInfoC: property,
});
| {
"end_byte": 903,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/functionProperty.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUndeclaredAcrossFiles1.ts_0_887 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @Filename: f2.js
//// import * as X from "./f1";
//// X.C.m0(1, "", []);
//// X.C.x;
//// let c = new X.C;
//// c.m1();
//// c.y = {};
//// c.m2(c);
// @Filename: f1.ts
//// export class C {[|
//// |]x: number;
//// }
verify.getAndApplyCodeFix(/*errorCode*/undefined, 0);
verify.getAndApplyCodeFix(/*errorCode*/undefined, 0);
verify.getAndApplyCodeFix(/*errorCode*/undefined, 0);
verify.getAndApplyCodeFix(/*errorCode*/undefined, 0);
verify.getAndApplyCodeFix(/*errorCode*/undefined, 0);
verify.rangeIs(`
m2(c: C) {
throw new Error("Method not implemented.");
}
y: {};
m1() {
throw new Error("Method not implemented.");
}
static x: any;
static m0(arg0: number, arg1: string, arg2: undefined[]) {
throw new Error("Method not implemented.");
}
`);
| {
"end_byte": 887,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUndeclaredAcrossFiles1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixOverrideModifier_fixAll2.ts_0_1489 | /// <reference path='fourslash.ts' />
// @noImplicitOverride: true
//// class B {
//// foo (v: string) {}
//// fooo (v: string) {}
//// }
//// class D extends B {
//// override foo (v: string) {}
//// fooo (v: string) {}
//// override bar(v: string) {}
//// }
//// class C {
//// override foo(v: string) {}
//// }
//// function f () {
//// return class extends B {
//// override foo (v: string) {}
//// fooo (v: string) {}
//// override bar(v: string) {}
//// }
//// }
//// class E extends (class {
//// foo () { }
//// bar () { }
//// }) {
//// override foo () { }
//// bar () { }
//// baz() {}
//// override bazz () {}
//// }
//// function ff () {
//// return class {
//// override foo () {}
//// }
//// }
verify.codeFixAll({
fixId: "fixRemoveOverrideModifier",
fixAllDescription: "Remove all unnecessary 'override' modifiers",
newFileContent: `class B {
foo (v: string) {}
fooo (v: string) {}
}
class D extends B {
override foo (v: string) {}
fooo (v: string) {}
bar(v: string) {}
}
class C {
foo(v: string) {}
}
function f () {
return class extends B {
override foo (v: string) {}
fooo (v: string) {}
bar(v: string) {}
}
}
class E extends (class {
foo () { }
bar () { }
}) {
override foo () { }
bar () { }
baz() {}
bazz () {}
}
function ff () {
return class {
foo () {}
}
}`
})
| {
"end_byte": 1489,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixOverrideModifier_fixAll2.ts"
} |
TypeScript/tests/cases/fourslash/typeKeywordInFunction.ts_0_203 | /// <reference path="fourslash.ts" />
////function a() {
//// ty/**/
////}
verify.completions({
marker: "",
includes: [{ name: "type", sortText: completion.SortText.GlobalsOrKeywords }]
});
| {
"end_byte": 203,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/typeKeywordInFunction.ts"
} |
TypeScript/tests/cases/fourslash/completionListInObjectBindingPattern03.ts_0_258 | /// <reference path='fourslash.ts'/>
////interface I {
//// property1: number;
//// property2: string;
////}
////
////var foo: I;
////var { property1: /**/ } = foo;
verify.completions({ marker: "", exact: undefined, isNewIdentifierLocation: true });
| {
"end_byte": 258,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectBindingPattern03.ts"
} |
TypeScript/tests/cases/fourslash/codeFixOverrideModifier16.ts_0_469 | /// <reference path='fourslash.ts' />
// @experimentalDecorators: true
// @noImplicitOverride: true
////function decorator() {
//// return (target: any, key: any, descriptor: PropertyDescriptor) => descriptor;
////}
////class A {
//// foo() {}
////}
////class B extends A {
//// @decorator()
//// // comment
//// [|foo() {}|]
////}
verify.codeFix({
description: "Add 'override' modifier",
newRangeContent: "override foo() {}",
index: 0
})
| {
"end_byte": 469,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixOverrideModifier16.ts"
} |
TypeScript/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature02.ts_0_338 | /// <reference path="fourslash.ts" />
////interface I<TString, TNumber> {
//// [s: string]: TString;
//// [s: number]: TNumber;
////}
////
////declare function foo<TString, TNumber>(obj: I<TString, TNumber>): { str: TStr/*1*/ }
verify.completions({ marker: "1", includes: ["I", "TString", "TNumber"], excludes: ["foo", "obj"] });
| {
"end_byte": 338,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature02.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature04.ts_0_384 | /// <reference path="fourslash.ts" />
////interface I<TString, TNumber> {
//// [s: string]: TString;
//// [s: number]: TNumber;
////}
////
////declare function foo<TString, TNumber>(obj: I<TString, TNumber>): { /*1*/
verify.completions({
marker: "1",
exact: { name: "readonly", sortText: completion.SortText.GlobalsOrKeywords } ,
isNewIdentifierLocation: true
});
| {
"end_byte": 384,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedObjectTypeLiteralInSignature04.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionTypeOnlyImport.ts_0_332 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////enum /*1*/SyntaxKind { SourceFile }
////export type { SyntaxKind }
// @Filename: /b.ts
//// export type { SyntaxKind } from './a';
// @Filename: /c.ts
////import type { SyntaxKind } from './b';
////let kind: [|/*2*/SyntaxKind|];
verify.baselineGoToDefinition("2");
| {
"end_byte": 332,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionTypeOnlyImport.ts"
} |
TypeScript/tests/cases/fourslash/docCommentTemplateClassDecl01.ts_0_322 | /// <reference path='fourslash.ts' />
/////*decl*/class C {
//// private p;
//// constructor(a, b, c, d);
//// constructor(public a, private b, protected c, d, e?) {
//// }
////
//// foo();
//// foo(a?, b?, ...args) {
//// }
////}
verify.docCommentTemplateAt("decl", /*newTextOffset*/ 3,
"/** */");
| {
"end_byte": 322,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateClassDecl01.ts"
} |
TypeScript/tests/cases/fourslash/tripleSlashRefPathCompletionBackandForwardSlash.ts_0_2191 | /// <reference path='fourslash.ts' />
// Exercises completions for hidden files (ie: those beginning with '.')
// @Filename: f.ts
//// /*f1*/
// @Filename: d1/g.ts
//// /*g1*/
// @Filename: d1/d2/h.ts
//// /*h1*/
// @Filename: d1/d2/d3/i.ts
//// /// <reference path=".\..\..\/*28*/
// @Filename: test.ts
//// /// <reference path="/*0*/
//// /// <reference path=".//*1*/
//// /// <reference path=".\/*2*/
//// /// <reference path="[|./*3*/|]
//// /// <reference path="d1//*4*/
//// /// <reference path="d1/.//*5*/
//// /// <reference path="d1/.\/*6*/
//// /// <reference path="d1/[|./*7*/|]
//// /// <reference path="d1\/*8*/
//// /// <reference path="d1\.//*9*/
//// /// <reference path="d1\.\/*10*/
//// /// <reference path="d1\[|./*11*/|]
//// /// <reference path="d1/d2//*12*/
//// /// <reference path="d1/d2/.//*13*/
//// /// <reference path="d1/d2/.\/*14*/
//// /// <reference path="d1/d2/[|./*15*/|]
//// /// <reference path="d1/d2\/*16*/
//// /// <reference path="d1/d2\.//*17*/
//// /// <reference path="d1/d2\.\/*18*/
//// /// <reference path="d1/d2\[|./*19*/|]
//// /// <reference path="d1\d2//*20*/
//// /// <reference path="d1\d2/.//*21*/
//// /// <reference path="d1\d2/.\/*22*/
//// /// <reference path="d1\d2/[|./*23*/|]
//// /// <reference path="d1\d2\/*24*/
//// /// <reference path="d1\d2\.//*25*/
//// /// <reference path="d1\d2\.\/*26*/
//// /// <reference path="d1\d2\[|./*27*/|]
testBlock(0, 'f.ts', "d1");
testBlock(4, 'g.ts', "d2");
testBlock(8, 'g.ts', "d2");
testBlock(12, 'h.ts', "d3");
testBlock(16, 'h.ts', "d3");
testBlock(20, 'h.ts', "d3");
testBlock(24, 'h.ts', "d3");
verify.completions({ marker: "28", exact: ["g.ts", "d2"], isNewIdentifierLocation: true });
function testBlock(offset: number, fileName: string, dir: string) {
const names = [fileName, dir];
verify.completions(
{
marker: [offset, offset + 1, offset + 2].map(String),
exact: names,
isNewIdentifierLocation: true,
},
{
marker: String(offset + 3),
exact: names.map(name => ({ name, replacementSpan: test.ranges()[offset / 4] })),
isNewIdentifierLocation: true,
});
}
| {
"end_byte": 2191,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tripleSlashRefPathCompletionBackandForwardSlash.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsVariableTypes1.ts_0_551 | /// <reference path="fourslash.ts" />
////class C {}
////namespace N { export class Foo {} }
////interface Foo {}
////const a = "a";
////const b = 1;
////const c = true;
////const d = {} as Foo;
////const e = <Foo>{};
////const f = {} as const;
////const g = (({} as const));
////const h = new C();
////const i = new N.C();
////const j = ((((new C()))));
////const k = { a: 1, b: 1 };
////const l = ((({ a: 1, b: 1 })));
//// const m = () => 123;
//// const n;
verify.baselineInlayHints(undefined, {
includeInlayVariableTypeHints: true
});
| {
"end_byte": 551,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsVariableTypes1.ts"
} |
TypeScript/tests/cases/fourslash/extendArrayInterfaceMember.ts_0_556 | /// <reference path="fourslash.ts"/>
////var x = [1, 2, 3];
////var /*y*/y = x.pop(/*1*/5/*2*/);
////
verify.errorExistsBetweenMarkers("1", "2");
verify.numberOfErrorsInCurrentFile(1);
// Expected errors exact:
// - Supplied parameters do not match any signature of call target.
// - Could not select overload for 'call' expression.
verify.quickInfoAt("y", "var y: number");
goTo.eof();
edit.insert("interface Array<T> { pop(def: T): T; }");
verify.not.errorExistsBetweenMarkers("1", "2");
verify.quickInfoAt("y", "var y: number");
verify.noErrors();
| {
"end_byte": 556,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extendArrayInterfaceMember.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_overloads.ts_0_254 | /// <reference path='fourslash.ts' />
////function f(a: number, b: number);
////function f(/*a*/a: number, b = 1/*b*/) {
//// return b;
////}
////f(2);
goTo.select("a", "b");
verify.not.refactorAvailable("Convert parameters to destructured object"); | {
"end_byte": 254,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_overloads.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpelling6.ts_0_460 | /// <reference path='fourslash.ts' />
// @Filename: a.ts
////export class SomeClass {}
// @Filename: b.ts
////import { SomeClass } from "./a";
////[|SomeClas|]
goTo.file("b.ts")
verify.codeFixAvailable([
{ description: "Change spelling to 'SomeClass'" },
{ description: "Remove import from './a'" }
]);
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Change_spelling_to_0.message, "SomeClass"],
newRangeContent: "SomeClass"
}); | {
"end_byte": 460,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpelling6.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionUnionTypeProperty_discriminated.ts_0_504 | /// <reference path='fourslash.ts'/>
////type U = A | B;
////
////interface A {
//// /*aKind*/kind: "a";
//// /*aProp*/prop: number;
////};
////
////interface B {
//// /*bKind*/kind: "b";
//// /*bProp*/prop: string;
////}
////
////const u: U = {
//// [|/*kind*/kind|]: "a",
//// [|/*prop*/prop|]: 0,
////};
////const u2: U = {
//// [|/*kindBogus*/kind|]: "bogus",
//// [|/*propBogus*/prop|]: 0,
////};
verify.baselineGoToDefinition(
"kind",
"prop",
"kindBogus",
"propBogus",
);
| {
"end_byte": 504,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionUnionTypeProperty_discriminated.ts"
} |
TypeScript/tests/cases/fourslash/inlineVariableTemplateString10.ts_0_384 | /// <reference path="fourslash.ts" />
////const /*a*/message/*b*/ = "Hello, World!";
////await $`echo ${((message))}`;
goTo.select("a", "b");
verify.refactorAvailable("Inline variable");
edit.applyRefactor({
refactorName: "Inline variable",
actionName: "Inline variable",
actionDescription: "Inline variable",
newContent: 'await $`echo ${(("Hello, World!"))}`;',
}); | {
"end_byte": 384,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableTemplateString10.ts"
} |
TypeScript/tests/cases/fourslash/completionListInExportClause03.ts_0_385 | /// <reference path="fourslash.ts" />
////declare module "M1" {
//// export var abc: number;
//// export var def: string;
////}
////
////declare module "M2" {
//// export { abc/**/ } from "M1";
////}
// Ensure we don't filter out the current item.
verify.completions({ marker: "", exact: ["abc", "def", { name: "type", sortText: completion.SortText.GlobalsOrKeywords }] });
| {
"end_byte": 385,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInExportClause03.ts"
} |
TypeScript/tests/cases/fourslash/jsxAttributeSnippetCompletionAfterTypeArgs.ts_0_1230 | /// <reference path="fourslash.ts" />
//@Filename: file.tsx
////declare const React: any;
////
////namespace JSX {
//// export interface IntrinsicElements {
//// div: any;
//// }
////}
////
////function GenericElement<T>(props: {xyz?: T}) {
//// return <></>
////}
////
////function fn1() {
//// return <div>
//// <GenericElement<number> /*1*/ />
//// </div>
////}
////
////function fn2() {
//// return <>
//// <GenericElement<number> /*2*/ />
//// </>
////}
////function fn3() {
//// return <div>
//// <GenericElement<number> /*3*/ ></GenericElement>
//// </div>
////}
////
////function fn4() {
//// return <>
//// <GenericElement<number> /*4*/ ></GenericElement>
//// </>
////}
verify.completions(
{
marker: test.markers(),
includes: {
name: "xyz",
insertText: "xyz={$1}",
text: "(property) xyz?: number",
isSnippet: true,
sortText: completion.SortText.OptionalMember
},
preferences: {
jsxAttributeCompletionStyle: "braces",
includeCompletionsWithSnippetText: true,
includeCompletionsWithInsertText: true,
},
},
)
| {
"end_byte": 1230,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsxAttributeSnippetCompletionAfterTypeArgs.ts"
} |
TypeScript/tests/cases/fourslash/renameJSDocNamepath.ts_0_173 | // @noLib: true
/// <reference path='fourslash.ts'/>
//// /**
//// * @type {module:foo/A} x
//// */
//// var x = 1
//// var /*0*/A = 0;
verify.baselineRename("0", {});
| {
"end_byte": 173,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameJSDocNamepath.ts"
} |
TypeScript/tests/cases/fourslash/completionsAfterAsyncInObjectLiteral.ts_0_142 | /// <reference path="fourslash.ts" />
////const x: { m(): Promise<void> } = { async /**/ };
verify.completions({ marker: "", exact: "m" });
| {
"end_byte": 142,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsAfterAsyncInObjectLiteral.ts"
} |
TypeScript/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias2.ts_0_306 | /// <reference path='fourslash.ts'/>
////type Map1<K, /*0*/
////type Map1<K, /*1*/V> = [];
////type Map1<K,V> = /*2*/[];
////type Map1<K1, V1> = </*3*/
verify.completions(
{ marker: ["0", "1"], exact: undefined },
{ marker: "2", includes: ["K", "V"], },
{ marker: "3", exact: undefined },
);
| {
"end_byte": 306,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias2.ts"
} |
TypeScript/tests/cases/fourslash/memberListOnFunctionParameter.ts_0_230 | /// <reference path='fourslash.ts' />
////module Test10 {
//// var x: string[] = [];
//// x.forEach(function (y) { y./**/} );
////}
verify.completions({
marker: "",
includes: "charAt",
excludes: "toFixed",
});
| {
"end_byte": 230,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberListOnFunctionParameter.ts"
} |
TypeScript/tests/cases/fourslash/completionEntryAfterASIExpressionInClass.ts_0_560 | /// <reference path='fourslash.ts'/>
//// class Parent {
//// protected shouldWork() {
//// console.log();
//// }
//// }
////
//// class Child extends Parent {
//// // this assumes ASI, but on next line wants to
//// x = () => 1
//// shoul/*insideid*/
//// }
////
//// class ChildTwo extends Parent {
//// // this assumes ASI, but on next line wants to
//// x = () => 1
//// /*root*/ //nothing
//// }
verify.completions({ marker: ["insideid", "root"], includes: "shouldWork", isNewIdentifierLocation: true });
| {
"end_byte": 560,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionEntryAfterASIExpressionInClass.ts"
} |
TypeScript/tests/cases/fourslash/renameStringLiteralOk1.ts_0_248 | /// <reference path='fourslash.ts'/>
//// declare function f(): '[|foo|]' | 'bar'
//// class Foo {
//// f = f()
//// }
//// const d: 'foo' = 'foo'
//// declare const ff: Foo
//// ff.f = '[|foo|]'
verify.baselineRenameAtRangesWithText("foo");
| {
"end_byte": 248,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameStringLiteralOk1.ts"
} |
TypeScript/tests/cases/fourslash/completionsExternalModuleRenamedExports.ts_0_354 | /// <reference path="fourslash.ts" />
// @Filename: other.ts
//// export {};
// @Filename: index.ts
//// const c = 0;
//// export { c as yeahThisIsTotallyInScopeHuh };
//// export * as alsoNotInScope from "./other";
////
//// /**/
verify.completions({
marker: "",
includes: "c",
excludes: ["yeahThisIsTotallyInScopeHuh", "alsoNotInScope"],
});
| {
"end_byte": 354,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsExternalModuleRenamedExports.ts"
} |
TypeScript/tests/cases/fourslash/jsxWithTypeParametershasInstantiatedSignatureHelp.tsx_0_497 | /// <reference path="./fourslash.ts" />
//// declare namespace JSX {
//// interface Element {
//// render(): Element | string | false;
//// }
//// }
////
//// function SFC<T>(_props: Record<string, T>) {
//// return '';
//// }
////
//// (</*1*/SFC/>);
//// (</*2*/SFC<string>/>);
goTo.marker("1");
verify.signatureHelp({ text: "SFC(_props: Record<string, unknown>): string" });
goTo.marker("2");
verify.signatureHelp({ text: "SFC(_props: Record<string, string>): string" });
| {
"end_byte": 497,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsxWithTypeParametershasInstantiatedSignatureHelp.tsx"
} |
TypeScript/tests/cases/fourslash/getOccurrencesReturnBroken.ts_0_954 | /// <reference path='fourslash.ts' />
////ret/*1*/urn;
////retu/*2*/rn;
////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;
////}
////
////class A {
//// ret/*3*/urn;
//// r/*4*/eturn 8675309;
////}
// Note: For this test, these 'return's get highlighted as a result of a parse recovery
// where if an arrow function starts with a statement, we try to parse a body
// as if it was missing curly braces. If the behavior changes in the future,
// a change to this test is very much welcome.
verify.baselineDocumentHighlights();
verify.baselineDocumentHighlights(test.markers());
| {
"end_byte": 954,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesReturnBroken.ts"
} |
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction3.ts_0_279 | /// <reference path='fourslash.ts' />
// @target: es2015
////async function fn(): string {}
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Replace_0_with_Promise_1.message, "string", "string"],
newFileContent: `async function fn(): Promise<string> {}`
});
| {
"end_byte": 279,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction3.ts"
} |
TypeScript/tests/cases/fourslash/getEmitOutputWithSemanticErrors.ts_0_216 | /// <reference path="fourslash.ts" />
// @BaselineFile: getEmitOutputWithSemanticErrors.baseline
// @Filename: inputFile.ts
// @emitThisFile: true
//// var x:number = "hello world";
verify.baselineGetEmitOutput(); | {
"end_byte": 216,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputWithSemanticErrors.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddOptionalParam14.ts_0_261 | /// <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.not.codeFixAvailable("addOptionalParam");
| {
"end_byte": 261,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddOptionalParam14.ts"
} |
TypeScript/tests/cases/fourslash/errorsAfterResolvingVariableDeclOfMergedVariableAndClassDecl.ts_0_375 | /// <reference path="fourslash.ts" />
////module M {
//// export class C {
//// foo() { }
//// }
//// export module C {
//// export var /*1*/C = M.C;
//// }
////}
verify.noErrors();
// Edit and bind and resolve only var decl
goTo.marker("1");
edit.backspace(1);
edit.insert(" ");
verify.quickInfoIs("var M.C.C: typeof M.C");
verify.noErrors();
| {
"end_byte": 375,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/errorsAfterResolvingVariableDeclOfMergedVariableAndClassDecl.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsClassExpression1.ts_0_234 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: /a.js
////module.exports = class /*0*/A {};
// @Filename: /b.js
////import /*1*/A = require("./a");
/////*2*/A;
verify.baselineFindAllReferences('0', '1', '2')
| {
"end_byte": 234,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsClassExpression1.ts"
} |
TypeScript/tests/cases/fourslash/quickfixAddMissingConstraint4.ts_0_514 | /// <reference path="fourslash.ts" />
// @filename: /bar.ts
////export type Bar = Record<string, string>
////export function bar<T extends Bar>(obj: { prop: T }) {}
// @filename: /foo.ts
////import { bar } from "./bar";
////
////export function foo<T>(x: T) {
//// bar({ prop: x/**/ })
////}
goTo.marker("");
verify.codeFix({
index: 0,
description: "Add `extends` constraint.",
newFileContent:
`import { bar } from "./bar";
export function foo<T extends Bar>(x: T) {
bar({ prop: x })
}`
});
| {
"end_byte": 514,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickfixAddMissingConstraint4.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue9.ts_0_262 | /// <reference path='fourslash.ts' />
//// const a: () => number = () => { 1 }
verify.codeFixAvailable([
{ description: ts.Diagnostics.Add_a_return_statement.message },
{ description: ts.Diagnostics.Remove_braces_from_arrow_function_body.message }
]);
| {
"end_byte": 262,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue9.ts"
} |
TypeScript/tests/cases/fourslash/renameTemplateLiteralsComputedProperties.ts_0_887 | /// <reference path='fourslash.ts' />
// @Filename: a.ts
////interface Obj {
//// [|[`[|{| "contextRangeIndex": 0 |}num|]`]: number;|]
//// [|['[|{| "contextRangeIndex": 2 |}bool|]']: boolean;|]
////}
////
////let o: Obj = {
//// [|[`[|{| "contextRangeIndex": 4 |}num|]`]: 0|],
//// [|['[|{| "contextRangeIndex": 6 |}bool|]']: true|],
////};
////
////o = {
//// [|['[|{| "contextRangeIndex": 8 |}num|]']: 1|],
//// [|[`[|{| "contextRangeIndex": 10 |}bool|]`]: false|],
////};
////
////o.[|num|];
////o['[|num|]'];
////o["[|num|]"];
////o[`[|num|]`];
////
////o.[|bool|];
////o['[|bool|]'];
////o["[|bool|]"];
////o[`[|bool|]`];
////
////export { o };
// @allowJs: true
// @Filename: b.js
////import { o as obj } from './a';
////
////obj.[|num|];
////obj[`[|num|]`];
////
////obj.[|bool|];
////obj[`[|bool|]`];
verify.baselineRenameAtRangesWithText(["num", "bool"]);
| {
"end_byte": 887,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameTemplateLiteralsComputedProperties.ts"
} |
TypeScript/tests/cases/fourslash/exhaustiveCaseCompletions3.ts_0_2423 | /// <reference path="fourslash.ts" />
// Where the exhaustive case completion appears or not.
// @newline: LF
// @Filename: /main.ts
//// enum E {
//// A = 0,
//// B = "B",
//// C = "C",
//// }
//// declare const u: E;
//// switch (u) {
//// case/*1*/
//// }
//// switch (u) {
//// /*2*/
//// }
//// switch (u) {
//// case 1:
//// /*3*/
//// }
//// switch (u) {
//// c/*4*/
//// }
//// switch (u) {
//// case /*5*/
//// }
//// /*6*/
//// switch (u) {
//// /*7*/
////
//// switch (u) {
//// case E./*8*/
//// }
const exhaustiveCaseCompletion = {
name: "case E.A: ...",
source: completion.CompletionSource.SwitchCases,
sortText: completion.SortText.GlobalsOrKeywords,
insertText:
`case E.A:
case E.B:
case E.C:`,
};
verify.completions(
{
marker: "1",
isNewIdentifierLocation: false,
includes: [
exhaustiveCaseCompletion,
],
preferences: {
includeCompletionsWithInsertText: true,
},
},
{
marker: "2",
includes: [
exhaustiveCaseCompletion,
],
preferences: {
includeCompletionsWithInsertText: true,
}
},
{
marker: "3",
includes: [
exhaustiveCaseCompletion,
],
preferences: {
includeCompletionsWithInsertText: true,
}
},
{
marker: "4",
includes: [
exhaustiveCaseCompletion,
],
preferences: {
includeCompletionsWithInsertText: true,
}
},
{
marker: "5",
includes: [
exhaustiveCaseCompletion,
],
preferences: {
includeCompletionsWithInsertText: true,
}
},
{
marker: "6",
exact: [
"E",
"u",
...completion.globals,
exhaustiveCaseCompletion,
],
preferences: {
includeCompletionsWithInsertText: true,
}
},
{
marker: "7",
includes: [
exhaustiveCaseCompletion,
],
preferences: {
includeCompletionsWithInsertText: true,
}
},
{
marker: "8",
exact: [
"A",
"B",
"C"
],
preferences: {
includeCompletionsWithInsertText: true,
}
},
); | {
"end_byte": 2423,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/exhaustiveCaseCompletions3.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertExport_defaultToNamed3.ts_0_502 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
/////*a*/export default class A {}/*b*/
// @Filename: /b.ts
////export type A = typeof import("./a").default;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert export",
actionName: "Convert default export to named export",
actionDescription: "Convert default export to named export",
newContent: {
"/a.ts": "export class A {}",
"/b.ts": "export type A = typeof import(\"./a\").A;"
},
});
| {
"end_byte": 502,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertExport_defaultToNamed3.ts"
} |
TypeScript/tests/cases/fourslash/completionsWithGenericStringLiteral.ts_0_244 | /// <reference path="fourslash.ts" />
// @strict: true
//// declare function get<T, K extends keyof T>(obj: T, key: K): T[K];
//// get({ hello: 123, world: 456 }, "/**/");
verify.completions({
marker: "",
includes: ["hello", "world"]
});
| {
"end_byte": 244,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsWithGenericStringLiteral.ts"
} |
TypeScript/tests/cases/fourslash/completionsOverridingProperties1.ts_0_679 | /// <reference path="fourslash.ts" />
// @newline: LF
// @Filename: a.ts
// Case: Properties
////class Base {
//// protected foo: string = "bar";
////}
////
////class Sub extends Base {
//// /*a*/
////}
verify.completions({
marker: "a",
isNewIdentifierLocation: true,
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithClassMemberSnippets: true,
},
includes: [
{
name: "foo",
sortText: completion.SortText.LocationPriority,
insertText: "protected foo: string;",
filterText: "foo"
}
],
}); | {
"end_byte": 679,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingProperties1.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoFromContextualType.ts_0_273 | /// <reference path='fourslash.ts' />
// @Filename: quickInfoExportAssignmentOfGenericInterface_0.ts
////interface I {
//// /** Documentation */
//// x: number;
////}
////const i: I = { /**/x: 0 };
verify.quickInfoAt("", "(property) I.x: number", "Documentation");
| {
"end_byte": 273,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoFromContextualType.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesIsDefinitionOfNumberNamedProperty.ts_0_134 | /// <reference path='fourslash.ts' />
////let o = { /*1*/1: 12 };
////let y = o[/*2*/1];
verify.baselineFindAllReferences('1', '2');
| {
"end_byte": 134,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesIsDefinitionOfNumberNamedProperty.ts"
} |
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax1.ts_0_152 | /// <reference path='fourslash.ts' />
//// var x: [|?|] = 12;
verify.codeFix({
description: "Change '?' to 'any'",
newRangeContent: "any",
});
| {
"end_byte": 152,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax1.ts"
} |
TypeScript/tests/cases/fourslash/extract-const-callback-function-this2.ts_0_587 | /// <reference path='fourslash.ts' />
////declare function fWithThis(fn: (this: { a: string }, a: string) => string): void;
////fWithThis(/*a*/function (a) { return this.a; }/*b*/);
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "constant_scope_0",
actionDescription: "Extract to constant in enclosing scope",
newContent:
`declare function fWithThis(fn: (this: { a: string }, a: string) => string): void;
const newLocal = function(this: { a: string; }, a: string): string { return this.a; };
fWithThis(/*RENAME*/newLocal);`
});
| {
"end_byte": 587,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const-callback-function-this2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageVariable5.ts_0_439 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
// @Filename: /a.ts
////var foobarfoobarfoobarfoobar;
// @Filename: /b.ts
////function bar() {
//// let y = foobarfoobarfoobarfoobar/**/;
////}
goTo.file("/b.ts");
goTo.marker("");
verify.codeFix({
description: "Infer type of 'foobarfoobarfoobarfoobar' from usage",
index: 0,
newFileContent: {
"/a.ts": "var foobarfoobarfoobarfoobar: any;"
}
});
| {
"end_byte": 439,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageVariable5.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports8.ts_0_443 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
////function foo() {return 42;}
////export const g = function () { return foo(); };
verify.codeFixAvailable([
{ description: "Add return type 'number'" },
]);
verify.codeFix({
description: "Add return type 'number'",
index: 0,
newFileContent:
`function foo() {return 42;}
export const g = function (): number { return foo(); };`,
});
| {
"end_byte": 443,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports8.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_export_invalidName.ts_0_357 | /// <reference path='fourslash.ts' />
// Test that we leave it alone if the name is a keyword.
// @allowJs: true
// @target: esnext
// @Filename: /a.js
////exports.class = 0;
////exports.async = 1;
verify.codeFix({
description: "Convert to ES module",
newFileContent:
`const _class = 0;
export { _class as class };
export const async = 1;`,
});
| {
"end_byte": 357,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_export_invalidName.ts"
} |
TypeScript/tests/cases/fourslash/renameCrossJsTs01.ts_0_363 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: a.js
////[|exports.[|{| "contextRangeIndex": 0 |}area|] = function (r) { return r * r; }|]
// @Filename: b.ts
////[|import { [|{| "contextRangeIndex": 2 |}area|] } from './a';|]
////var t = [|area|](10);
const [r0Def, r0, r1Def, r1, r2] = test.ranges();
verify.baselineRename([r0, r1, r2]);
| {
"end_byte": 363,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameCrossJsTs01.ts"
} |
TypeScript/tests/cases/fourslash/autoFormattingOnPasting.ts_0_818 | /// <reference path='fourslash.ts' />
////module TestModule {
/////**/
////}
goTo.marker("");
edit.paste(` class TestClass{
private foo;
public testMethod( )
{}
}`);
// We're missing scenarios of formatting option settings due to bug 693273 - [TypeScript] Need to improve fourslash support for formatting options.
// Missing scenario ** Uncheck Tools->Options->Text Editor->TypeScript->Formatting->General->Format on paste **
//verify.currentFileContentIs("module TestModule {\n\
// class TestClass{\n\
//private foo;\n\
//public testMethod( )\n\
//{}\n\
//}\n\
//}");
// Missing scenario ** Check Tools->Options->Text Editor->TypeScript->Formatting->General->Format on paste **
verify.currentFileContentIs(`module TestModule {
class TestClass {
private foo;
public testMethod() { }
}
}`); | {
"end_byte": 818,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoFormattingOnPasting.ts"
} |
TypeScript/tests/cases/fourslash/objectAssignabilityRegionCheck.ts_0_518 | /// <reference path="fourslash.ts" />
// @strict: true
// @Filename: index.ts
//// interface Foo {
//// a: number;
//// }
//// interface Bar {
//// b: string;
//// }
//// declare let b: Bar;
//// [|function f(): Foo {
//// [|return|] b;
//// }|]
//// /*e*/
const [r0, r1] = test.ranges();
// Baseline
const expected = test.getSemanticDiagnostics();
// Reset checker
goTo.marker("e");
edit.insert(" ");
verify.getRegionSemanticDiagnostics([r0], [expected[0]]);
verify.getSemanticDiagnostics(expected); | {
"end_byte": 518,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/objectAssignabilityRegionCheck.ts"
} |
TypeScript/tests/cases/fourslash/renameNoDefaultLib.ts_0_241 | /// <reference path="fourslash.ts" />
// @checkJs: true
// @allowJs: true
// @Filename: /foo.js
//// // @ts-check
//// /// <reference no-default-lib="true" />
//// const [|/**/foo|] = 1;
goTo.marker("");
verify.renameInfoSucceeded("foo")
| {
"end_byte": 241,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameNoDefaultLib.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsExternalModuleAlias.ts_0_497 | /// <reference path='fourslash.ts'/>
// @Filename: quickInfoDisplayPartsExternalModuleAlias_file0.ts
////export namespace m1 {
//// export class c {
//// }
////}
// @Filename: quickInfoDisplayPartsExternalModuleAlias_file1.ts
////import /*1*/a1 = require(/*mod1*/"./quickInfoDisplayPartsExternalModuleAlias_file0");
////new /*2*/a1.m1.c();
////export import /*3*/a2 = require(/*mod2*/"./quickInfoDisplayPartsExternalModuleAlias_file0");
////new /*4*/a2.m1.c();
verify.baselineQuickInfo(); | {
"end_byte": 497,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsExternalModuleAlias.ts"
} |
TypeScript/tests/cases/fourslash/codeFixDeleteUnmatchedParameter3.ts_0_539 | /// <reference path='fourslash.ts' />
// @filename: a.ts
/////**
//// * @param {number} a
//// * @param {string} b
//// * @param {number} c
//// */
////function foo(a: number, c: number) {
//// a;
//// c;
////}
verify.codeFixAvailable([
{ description: "Delete unused '@param' tag 'b'" },
]);
verify.codeFix({
description: [ts.Diagnostics.Delete_unused_param_tag_0.message, "b"],
index: 0,
newFileContent:
`/**
* @param {number} a
* @param {number} c
*/
function foo(a: number, c: number) {
a;
c;
}`
});
| {
"end_byte": 539,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixDeleteUnmatchedParameter3.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionOverriddenMember9.ts_0_266 | /// <reference path="./fourslash.ts"/>
// @noImplicitOverride: true
////interface I {
//// m(): void;
////}
////class A {
//// /*2*/m() {};
////}
////class B extends A implements I {
//// [|/*1*/override|] m() {}
////}
verify.baselineGoToDefinition("1");
| {
"end_byte": 266,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionOverriddenMember9.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesReturn4.ts_0_512 | /// <reference path='fourslash.ts' />
////function f(a: number) {
//// if (a > 0) {
//// return (function () {
//// return/*1*/;
//// return/*2*/;
//// return/*3*/;
////
//// if (false) {
//// return/*4*/ true;
//// }
//// })() || true;
//// }
////
//// var unusued = [1, 2, 3, 4].map(x => { return/*5*/ 4 })
////
//// return/*6*/;
//// return/*7*/ true;
////}
verify.baselineDocumentHighlights(test.markers()); | {
"end_byte": 512,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesReturn4.ts"
} |
TypeScript/tests/cases/fourslash/codeFixOverrideModifier22.ts_0_665 | /// <reference path='fourslash.ts' />
// @noImplicitOverride: true
////const Foo: C1 & C2 =
//// class {
//// m1() { }
//// m2() { }
//// }
////
////interface I1 {
//// m1(): void;
////}
////
////interface I2 {
//// m1(): void;
//// m2(): void;
////}
////
////interface C1 {
//// new(...args: any[]): I1;
////}
////
////interface C2 {
//// new(...args: any[]): I2;
////}
////
////class Bar extends Foo {
//// [|m1()|] {
//// super.m1();
//// }
//// m2() {
//// super.m2();
//// }
////}
verify.codeFix({
description: "Add 'override' modifier",
newRangeContent: "override m1()",
index: 0
})
| {
"end_byte": 665,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixOverrideModifier22.ts"
} |
TypeScript/tests/cases/fourslash/completionListSuperMembers.ts_0_993 | /// <reference path="fourslash.ts" />
////class Base {
//// private privateInstanceMethod() { }
//// public publicInstanceMethod() { }
////
//// private privateProperty = 1;
//// public publicProperty = 1;
////
//// private static privateStaticProperty = 1;
//// public static publicStaticProperty = 1;
////
//// private static privateStaticMethod() { }
//// public static publicStaticMethod() {
//// Class./*staticsInsideClassScope*/publicStaticMethod();
//// var c = new Class();
//// c./*instanceMembersInsideClassScope*/privateProperty;
//// }
////}
////class Class extends Base {
//// private test() {
//// super./**/
//// }
////}
verify.completions({
marker: "",
includes: "publicInstanceMethod",
excludes: [
"publicProperty",
// No statics
"publicStaticProperty",
"publicStaticMethod",
// No privates
"privateProperty",
"privateInstanceMethod",
]
});
| {
"end_byte": 993,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListSuperMembers.ts"
} |
TypeScript/tests/cases/fourslash/jsxAttributeCompletionStyleNoSnippet.ts_0_1842 | /// <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",
isSnippet: undefined,
},
{
name: "prop_b",
isSnippet: undefined,
},
{
name: "prop_c",
isSnippet: undefined,
},
{
name: "prop_d",
isSnippet: undefined,
},
{
name: "prop_e",
isSnippet: undefined,
},
{
name: "prop_f",
isSnippet: undefined,
},
{
name: "prop_g",
isSnippet: undefined,
},
{
name: "prop_h",
isSnippet: undefined,
sortText: completion.SortText.OptionalMember,
},
{
name: "prop_i",
isSnippet: undefined,
sortText: completion.SortText.OptionalMember,
},
{
name: "prop_j",
isSnippet: undefined,
sortText: completion.SortText.OptionalMember,
}
],
preferences: {
jsxAttributeCompletionStyle: "auto",
includeCompletionsWithSnippetText: false
}
}); | {
"end_byte": 1842,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsxAttributeCompletionStyleNoSnippet.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_templateStrings.ts_0_113 | /// <reference path="fourslash.ts" />
////`a /*1*/b ${
//// '/*2*/c'
////} d`
verify.baselineSmartSelection(); | {
"end_byte": 113,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_templateStrings.ts"
} |
TypeScript/tests/cases/fourslash/functionFormatting.ts_0_199 | /// <reference path="fourslash.ts"/>
////var foo = foo(function () {
//// /**/function foo () {}} );
format.document();
goTo.marker();
verify.currentLineContentIs(" function foo() { }"); | {
"end_byte": 199,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/functionFormatting.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.