_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/renameLocationsForClassExpression01.ts_0_421 | /// <reference path='fourslash.ts'/>
////class Foo {
////}
////
////var x = [|class [|{| "contextRangeIndex": 0 |}Foo|] {
//// doIt() {
//// return [|Foo|];
//// }
////
//// static doItStatically() {
//// return [|Foo|].y;
//// }
////}|]
////
////var y = class {
//// getSomeName() {
//// return Foo
//// }
////}
////var z = class Foo {}
verify.baselineRenameAtRangesWithText("Foo");
| {
"end_byte": 421,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameLocationsForClassExpression01.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedTypeArguments.ts_0_1444 | /// <reference path='fourslash.ts'/>
////let x = 10;
////type Type = void;
////declare function f<T>(): void;
////declare function f2<T, U>(): void;
////f</*1a*/T/*2a*/y/*3a*/
////f</*1b*/T/*2b*/y/*3b*/;
////f</*1c*/T/*2c*/y/*3c*/>
////f</*1d*/T/*2d*/y/*3d*/>
////f</*1e*/T/*2e*/y/*3e*/>();
////
////f2</*1k*/T/*2k*/y/*3k*/,
////f2</*1l*/T/*2l*/y/*3l*/,{| "newId": true |}T{| "newId": true |}y{| "newId": true |}
////f2</*1m*/T/*2m*/y/*3m*/,{| "newId": true |}T{| "newId": true |}y{| "newId": true |};
////f2</*1n*/T/*2n*/y/*3n*/,{| "newId": false |}T{| "newId": false |}y{| "newId": false |}>
////f2</*1o*/T/*2o*/y/*3o*/,{| "newId": false |}T{| "newId": false |}y{| "newId": false |}>
////f2</*1p*/T/*2p*/y/*3p*/,{| "newId": true, "typeOnly": true |}T{| "newId": true, "typeOnly": true |}y{| "newId": true, "typeOnly": true |}>();
////
////f2<typeof /*1uValueOnly*/x, {| "newId": true |}T{| "newId": true |}y{| "newId": true |}
////
////f2</*1x*/T/*2x*/y/*3x*/, () =>/*4x*/T/*5x*/y/*6x*/
////f2<() =>/*1y*/T/*2y*/y/*3y*/, () =>/*4y*/T/*5y*/y/*6y*/
////f2<any, () =>/*1z*/T/*2z*/y/*3z*/
goTo.eachMarker(marker => {
const markerName = test.markerName(marker) || "";
const valueOnly = markerName.endsWith("ValueOnly");
verify.completions({
marker,
includes: valueOnly ? "x" : "Type",
excludes: valueOnly ? "Type" : "x",
isNewIdentifierLocation: marker.data && marker.data.newId || false,
});
});
| {
"end_byte": 1444,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedTypeArguments.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_Single_If.ts_0_382 | /// <reference path='fourslash.ts' />
//// const foo = /*x*/f/*y*/unction() {
//// if (true) { }
//// };
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to arrow function",
actionDescription: "Convert to arrow function",
newContent: `const foo = () => {
if (true) { }
};`,
});
| {
"end_byte": 382,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_Single_If.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingMember_generator_function.ts_0_385 | /// <reference path='fourslash.ts' />
////class C {
//// *method() {
//// yield* this.y();
//// }
////}
verify.codeFix({
index: 0,
description: ignoreInterpolations(ts.Diagnostics.Declare_method_0),
newFileContent:
`class C {
*method() {
yield* this.y();
}
*y() {
throw new Error("Method not implemented.");
}
}`,
});
| {
"end_byte": 385,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember_generator_function.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_requireImport2.ts_0_732 | /// <reference path='fourslash.ts' />
// @verbatimModuleSyntax: true
// @module: commonjs
// @allowJs: true
//@Filename: /a.js
////const { a, b } = require("./other");
////const p = 0;
////[|const y = p;
////const z = 0;
////exports.z = 0;|]
////a; y; z;
//@Filename: /other.js
////const a = 1;
////exports.a = a;
//@Filename: /user.ts
////const { x, y } = require("./a");
verify.moveToFile({
newFileContents: {
"/a.js":
`const { y, z } = require("./bar");
const { a, b } = require("./other");
const p = 0;
exports.p = p;
a; y; z;`,
"/bar.js":
`const { p } = require("./a");
const y = p;
exports.y = y;
const z = 0;
exports.z = 0;
`,
},
interactiveRefactorArguments: { targetFile: "/bar.js" }
});
| {
"end_byte": 732,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_requireImport2.ts"
} |
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class12.ts_0_367 | /// <reference path='fourslash.ts' />
// @allowNonTsExtensions: true
// @Filename: foo.js
////function Foo() {
//// this.a = 0;
////}
////Foo[`a b c`] = function () {
////}
verify.codeFix({
description: "Convert function to an ES2015 class",
newFileContent:
`class Foo {
constructor() {
this.a = 0;
}
static "a b c"() {
}
}
`
});
| {
"end_byte": 367,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class12.ts"
} |
TypeScript/tests/cases/fourslash/completionInFunctionLikeBody.ts_0_676 | /// <reference path='fourslash.ts'/>
//// class Foo {
//// bar () {
//// /*1*/
//// class Foo1 {
//// bar1 () {
//// /*2*/
//// }
//// /*3*/
//// }
//// }
//// /*4*/
//// }
verify.completions(
{
marker: ["1", "2"],
includes: ["async", "await"].map(
name => ({ name, sortText: completion.SortText.GlobalsOrKeywords })
),
excludes: ["public", "private", "protected", "constructor", "readonly", "static", "abstract", "get", "set"],
},
{ marker: ["3", "4"], exact: completion.classElementKeywords, isNewIdentifierLocation: true },
);
| {
"end_byte": 676,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionInFunctionLikeBody.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentStatementForIn.ts_0_403 | /// <reference path='fourslash.ts'/>
////function Foo() {
//// for (var i in [])
//// {
//// /*insideStatement*/
//// }
//// /*afterStatement*/
//// for (var i in [])
//// /*insideStatement2*/
////}
goTo.marker('insideStatement');
verify.indentationIs(8);
goTo.marker('afterStatement');
verify.indentationIs(4);
goTo.marker('insideStatement2');
verify.indentationIs(8);
| {
"end_byte": 403,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentStatementForIn.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionIndexSignature.ts_0_558 | /// <reference path='fourslash.ts'/>
////interface I {
//// /*defI*/[x: string]: boolean;
////}
////interface J {
//// /*defJ*/[x: string]: number;
////}
////interface K {
//// /*defa*/[x: `a${string}`]: string;
//// /*defb*/[x: `${string}b`]: string;
////}
////declare const i: I;
////i.[|/*useI*/foo|];
////declare const ij: I | J;
////ij.[|/*useIJ*/foo|];
////declare const k: K;
////k.[|/*usea*/a|];
////k.[|/*useb*/b|];
////k.[|/*useab*/ab|];
verify.baselineGoToDefinition(
"useI",
"useIJ",
"usea",
"useb",
"useab",
);
| {
"end_byte": 558,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionIndexSignature.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction35.ts_0_368 | /// <reference path='fourslash.ts' />
/////*a*/()/*b*/ => {
//// return {} satisfies any
////}
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: "() => ({} satisfies any)",
});
| {
"end_byte": 368,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction35.ts"
} |
TypeScript/tests/cases/fourslash/renameModuleExportsProperties3.ts_3_280 | / <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: a.js
////[|class [|{| "contextRangeIndex": 0 |}A|] {}|]
////module.exports = { [|A|] }
const [r0Def, r0, r1] = test.ranges();
verify.baselineRename([r0, r1], { providePrefixAndSuffixTextForRename: true }); | {
"end_byte": 280,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameModuleExportsProperties3.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedCommaExpression01.ts_0_186 | /// <reference path='fourslash.ts' />
////// should NOT see a and b
////foo((a, b) => a,/*1*/
verify.completions({ marker: "1", excludes: ["a", "b"], isNewIdentifierLocation: true });
| {
"end_byte": 186,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedCommaExpression01.ts"
} |
TypeScript/tests/cases/fourslash/inlineVariableTemplateString5.ts_0_422 | /// <reference path="fourslash.ts" />
////const /*a*/pizza/*b*/ = "🍕";
////export const prompt = `Hello, would you like some ${pizza}`;
goTo.select("a", "b");
verify.refactorAvailable("Inline variable");
edit.applyRefactor({
refactorName: "Inline variable",
actionName: "Inline variable",
actionDescription: "Inline variable",
newContent: "export const prompt = `Hello, would you like some 🍕`;"
}); | {
"end_byte": 422,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableTemplateString5.ts"
} |
TypeScript/tests/cases/fourslash/formattingObjectLiteralOpenCurlyNewlineAssignment.ts_0_527 | /// <reference path='fourslash.ts' />
////
//// var obj = {};
//// obj =
//// {
//// prop: 3
//// };
////
//// var obj2 = obj ||
//// {
//// prop: 0
//// }
////
format.document();
verify.currentFileContentIs(
`
var obj = {};
obj =
{
prop: 3
};
var obj2 = obj ||
{
prop: 0
}
`
);
format.setOption("indentMultiLineObjectLiteralBeginningOnBlankLine", true);
format.document();
verify.currentFileContentIs(
`
var obj = {};
obj =
{
prop: 3
};
var obj2 = obj ||
{
prop: 0
}
`
); | {
"end_byte": 527,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingObjectLiteralOpenCurlyNewlineAssignment.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoFromContextualUnionType1.ts_0_427 | /// <reference path='fourslash.ts' />
// @strict: true
//// // based on https://github.com/microsoft/TypeScript/issues/55495
//// type X =
//// | {
//// name: string;
//// [key: string]: any;
//// }
//// | {
//// name: "john";
//// someProp: boolean;
//// };
////
//// const obj = { name: "john", /*1*/someProp: "foo" } satisfies X;
verify.quickInfoAt("1", "(property) someProp: string");
| {
"end_byte": 427,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoFromContextualUnionType1.ts"
} |
TypeScript/tests/cases/fourslash/formatWithTabs2.ts_0_303 | /// <reference path="fourslash.ts"/>
////const foo = [
//// 1
////];
const options = format.copyFormatOptions();
options.IndentSize = 2;
options.TabSize = 2;
options.ConvertTabsToSpaces = false;
format.setFormatOptions(options);
format.document();
verify.currentFileContentIs(
`const foo = [
1
];`); | {
"end_byte": 303,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatWithTabs2.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_reExportDefault.ts_0_844 | /// <reference path="fourslash.ts" />
// @Filename: /user.ts
////foo;
// @Filename: /user2.ts
////unnamed;
// @Filename: /user3.ts
////reExportUnnamed;
// @Filename: /reExportNamed.ts
////export { default } from "./named";
// @Filename: /reExportUnnamed.ts
////export { default } from "./unnamed";
// @Filename: /named.ts
////function foo() {}
////export default foo;
// @Filename: /unnamed.ts
////export default 0;
goTo.file("/user.ts");
verify.importFixAtPosition([
`import foo from "./named";
foo;`,
`import foo from "./reExportNamed";
foo;`,
]);
goTo.file("/user2.ts");
verify.importFixAtPosition([
`import unnamed from "./unnamed";
unnamed;`,
`import unnamed from "./reExportUnnamed";
unnamed;`,
]);
goTo.file("/user3.ts");
verify.importFixAtPosition([
`import reExportUnnamed from "./reExportUnnamed";
reExportUnnamed;`]);
| {
"end_byte": 844,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_reExportDefault.ts"
} |
TypeScript/tests/cases/fourslash/getOutliningForTupleType.ts_0_327 | /// <reference path="fourslash.ts"/>
////type A =[| [
//// number,
//// number,
//// number
////]|]
////
////type B =[| [
//// [|[
//// [|[
//// number,
//// number,
//// number
//// ]|]
//// ]|]
////]|]
verify.outliningSpansInCurrentFile(test.ranges(), "code");
| {
"end_byte": 327,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOutliningForTupleType.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_noSelfImports2.ts_0_390 | /// <reference path='fourslash.ts' />
//@Filename: /bar.ts
////import { y, z } from "./a";
// @Filename: /a.ts
////[|export const y = 1;|]
////export const z = 2;
verify.moveToFile({
newFileContents: {
"/a.ts": "export const z = 2;",
"/bar.ts":
`import { z } from "./a";
export const y = 1;
`,
},
interactiveRefactorArguments: { targetFile: "/bar.ts" }
});
| {
"end_byte": 390,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_noSelfImports2.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType84.ts_0_408 | /// <reference path='fourslash.ts' />
//// type A = { a: string /*1*/} | { b: string } | { c: string }/*2*/;
goTo.select("1", "2");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent:
`type /*RENAME*/NewType = {
a: string;
} | {
b: string;
} | {
c: string;
};
type A = NewType;`,
});
| {
"end_byte": 408,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType84.ts"
} |
TypeScript/tests/cases/fourslash/mapCodeToplevelReplace.ts_0_259 | ///<reference path="fourslash.ts"/>
// @Filename: /topLevelReplace.ts
//// function foo() {
//// return 1;
//// }[||]
//// function bar() {
//// return 2;
//// }
////
verify.baselineMapCode([test.ranges()], [
`
function foo() {
return 3;
}
`
]); | {
"end_byte": 259,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeToplevelReplace.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationLocal_03.ts_0_242 | /// <reference path='fourslash.ts'/>
// Should return the definition when invoked on variable assignment
//// let [|he/*local_var*/llo|] = {};
////
//// x.hello();
////
//// hello = {};
////
verify.baselineGoToImplementation("local_var");
| {
"end_byte": 242,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationLocal_03.ts"
} |
TypeScript/tests/cases/fourslash/tsxCompletion2.ts_0_378 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// class MyComp { props: { ONE: string; TWO: number } }
//// var x = <MyComp /**//>;
verify.completions({ marker: "", exact: ["ONE", "TWO"] });
| {
"end_byte": 378,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletion2.ts"
} |
TypeScript/tests/cases/fourslash/tsxQuickInfo6.ts_3_779 | / <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare function ComponentSpecific<U>(l: {prop: U}): JSX.Element;
//// declare function ComponentSpecific1<U>(l: {prop: U, "ignore-prop": number}): JSX.Element;
//// function Bar<T extends {prop: number}>(arg: T) {
//// let a1 = <Compone/*1*/ntSpecific {...arg} ignore-prop="hi" />; // U is number
//// let a2 = <ComponentSpecific1 {...arg} ignore-prop={10} />; // U is number
//// let a3 = <Component/*2*/Specific {...arg} prop="hello" />; // U is "hello"
//// }
verify.quickInfos({
1: "function ComponentSpecific<number>(l: {\n prop: number;\n}): JSX.Element",
2: "function ComponentSpecific<never>(l: {\n prop: never;\n}): JSX.Element"
});
| {
"end_byte": 779,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxQuickInfo6.ts"
} |
TypeScript/tests/cases/fourslash/completionsOverridingMethod3.ts_0_690 | /// <reference path="fourslash.ts" />
// @newline: LF
// @Filename: boo.d.ts
// Case: Declaration files
////interface Ghost {
//// boo(): string;
////}
////
////declare class Poltergeist implements Ghost {
//// /*b*/
////}
verify.completions({
marker: "b",
isNewIdentifierLocation: true,
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithClassMemberSnippets: true,
},
includes: [
{
name: "boo",
sortText: completion.SortText.LocationPriority,
insertText: "boo(): string;",
filterText: "boo",
}
],
}); | {
"end_byte": 690,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingMethod3.ts"
} |
TypeScript/tests/cases/fourslash/inlineVariableNoParensPropertyAccess.ts_0_734 | /// <reference path="fourslash.ts" />
////const /*a1*/foo/*b1*/ = "foo";
////console.log(foo.length);
////const /*a2*/notTrue/*b2*/ = false;
////notTrue.valueOf();
goTo.select("a1", "b1");
verify.refactorAvailable("Inline variable");
edit.applyRefactor({
refactorName: "Inline variable",
actionName: "Inline variable",
actionDescription: "Inline variable",
newContent: `console.log("foo".length);
const notTrue = false;
notTrue.valueOf();`
});
goTo.select("a2", "b2");
verify.refactorAvailable("Inline variable");
edit.applyRefactor({
refactorName: "Inline variable",
actionName: "Inline variable",
actionDescription: "Inline variable",
newContent: `console.log("foo".length);
false.valueOf();`
});
| {
"end_byte": 734,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableNoParensPropertyAccess.ts"
} |
TypeScript/tests/cases/fourslash/completionsMergedDeclarations1.ts_0_670 | /// <reference path='fourslash.ts'/>
////interface Point {
//// x: number;
//// y: number;
////}
////function point(x: number, y: number): Point {
//// return { x: x, y: y };
////}
////module point {
//// export var origin = point(0, 0);
//// export function equals(p1: Point, p2: Point) {
//// return p1.x == p2.x && p1.y == p2.y;
//// }
////}
////var p1 = /*1*/point(0, 0);
////var p2 = point./*2*/origin;
////var b = point./*3*/equals(p1, p2);
verify.completions(
{ marker: "1", includes: "point", isNewIdentifierLocation: true },
{ marker: ["2", "3"], exact: completion.functionMembersWithPrototypePlus(["equals", "origin"]) },
);
| {
"end_byte": 670,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsMergedDeclarations1.ts"
} |
TypeScript/tests/cases/fourslash/genericCallSignaturesInNonGenericTypes1.ts_0_348 | /// <reference path='fourslash.ts'/>
////interface WrappedObject<T> { }
////interface WrappedArray<T> { }
////interface Underscore {
//// <T>(list: T[]): WrappedArray<T>;
//// <T>(obj: T): WrappedObject<T>;
////}
////var _: Underscore;
////var a: number[];
////var /**/b = _(a);
verify.quickInfoAt("", "var b: WrappedArray<number>");
| {
"end_byte": 348,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericCallSignaturesInNonGenericTypes1.ts"
} |
TypeScript/tests/cases/fourslash/identifierErrorRecovery.ts_0_310 | /// <reference path="fourslash.ts"/>
//// var /*1*/export/*2*/;
//// var foo;
//// var /*3*/class/*4*/;
//// var bar;
verify.errorExistsBetweenMarkers("1", "2");
verify.errorExistsBetweenMarkers("3", "4");
verify.numberOfErrorsInCurrentFile(3);
goTo.eof();
verify.completions({ includes: ["foo", "bar"] });
| {
"end_byte": 310,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/identifierErrorRecovery.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceMemberNestedTypeAlias.ts_0_585 | /// <reference path='fourslash.ts' />
////type Either<T> = { val: T } | Error;
////interface I {
//// x: Either<Either<string>>;
//// foo(x: Either<Either<string>>): void;
////}
////class C implements I {}
verify.codeFix({
description: "Implement interface 'I'",
newFileContent:
`type Either<T> = { val: T } | Error;
interface I {
x: Either<Either<string>>;
foo(x: Either<Either<string>>): void;
}
class C implements I {
x: Either<Either<string>>;
foo(x: Either<Either<string>>): void {
throw new Error("Method not implemented.");
}
}`,
});
| {
"end_byte": 585,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceMemberNestedTypeAlias.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptQuickInfo2.ts_0_203 | /// <reference path='fourslash.ts'/>
// @allowNonTsExtensions: true
// @Filename: Foo.js
/////** @param {number} [a] */
////function /**/f(a) { }
verify.quickInfoAt("", "function f(a?: number): void"); | {
"end_byte": 203,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptQuickInfo2.ts"
} |
TypeScript/tests/cases/fourslash/deduplicateDuplicateMergedBindCheckErrors.ts_0_197 | /// <reference path="./fourslash.ts" />
//// class X {
//// foo() {
//// return 1;
//// }
//// get foo() {
//// return 1;
//// }
//// }
verify.numberOfErrorsInCurrentFile(2);
| {
"end_byte": 197,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/deduplicateDuplicateMergedBindCheckErrors.ts"
} |
TypeScript/tests/cases/fourslash/renameContextuallyTypedProperties2.ts_0_1477 | /// <reference path='fourslash.ts' />
////interface I {
//// prop1: () => void;
//// [|[|{| "contextRangeIndex": 0 |}prop2|](): void;|]
////}
////
////var o1: I = {
//// prop1() { },
//// [|[|{| "contextRangeIndex": 2 |}prop2|]() { }|]
////};
////
////var o2: I = {
//// prop1: () => { },
//// [|[|{| "contextRangeIndex": 4 |}prop2|]: () => { }|]
////};
////
////var o3: I = {
//// get prop1() { return () => { }; },
//// [|get [|{| "contextRangeIndex": 6 |}prop2|]() { return () => { }; }|]
////};
////
////var o4: I = {
//// set prop1(v) { },
//// [|set [|{| "contextRangeIndex": 8 |}prop2|](v) { }|]
////};
////
////var o5: I = {
//// "prop1"() { },
//// [|"[|{| "contextRangeIndex": 10 |}prop2|]"() { }|]
////};
////
////var o6: I = {
//// "prop1": function () { },
//// [|"[|{| "contextRangeIndex": 12 |}prop2|]": function () { }|]
////};
////
////var o7: I = {
//// ["prop1"]: function () { },
//// [|["[|{| "contextRangeIndex": 14 |}prop2|]"]: function () { }|]
////};
////
////var o8: I = {
//// ["prop1"]() { },
//// [|["[|{| "contextRangeIndex": 16 |}prop2|]"]() { }|]
////};
////
////var o9: I = {
//// get ["prop1"]() { return () => { }; },
//// [|get ["[|{| "contextRangeIndex": 18 |}prop2|]"]() { return () => { }; }|]
////};
////
////var o10: I = {
//// set ["prop1"](v) { },
//// [|set ["[|{| "contextRangeIndex": 20 |}prop2|]"](v) { }|]
////};
verify.baselineRenameAtRangesWithText("prop2");
| {
"end_byte": 1477,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameContextuallyTypedProperties2.ts"
} |
TypeScript/tests/cases/fourslash/completionsWithDeprecatedTag10.ts_0_553 | /// <reference path="fourslash.ts" />
// @Filename: /foo.ts
/////** @deprecated foo */
////export const foo = 0;
// @Filename: /index.ts
/////**/
verify.completions({
marker: "",
includes: [{
name: "foo",
source: "/foo",
sourceDisplay: "./foo",
hasAction: true,
kind: "const",
kindModifiers: "export,deprecated",
sortText: completion.SortText.Deprecated(completion.SortText.AutoImportSuggestions),
}],
preferences: {
includeCompletionsForModuleExports: true,
},
});
| {
"end_byte": 553,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsWithDeprecatedTag10.ts"
} |
TypeScript/tests/cases/fourslash/codefixUnreferenceableDecoratorMetadata2.ts_0_958 | /// <reference path="fourslash.ts" />
// @isolatedModules: true
// @module: es2015
// @experimentalDecorators: true
// @emitDecoratorMetadata: true
// @Filename: /mod.ts
//// export default interface I1 {}
//// export interface I2 {}
// @Filename: /index.ts
//// [|import I1, { I2 } from "./mod";|]
////
//// declare var EventListener: any;
//// class HelloWorld {
//// @EventListener("1")
//// p1!: I2;
//// p2!: I2;
//// }
const diag = ts.Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled;
goTo.file("/index.ts");
verify.codeFix({
description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
errorCode: diag.code,
applyChanges: false,
newFileContent: `import I1, * as mod from "./mod";
declare var EventListener: any;
class HelloWorld {
@EventListener("1")
p1!: mod.I2;
p2!: mod.I2;
}`,
});
| {
"end_byte": 958,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codefixUnreferenceableDecoratorMetadata2.ts"
} |
TypeScript/tests/cases/fourslash/parserCorruptionAfterMapInClass.ts_0_270 | /// <reference path="fourslash.ts" />
// @target: esnext
// @lib: es2015
// @strict: true
//// class C {
//// map = new Set<string, number>/*$*/
////
//// foo() {
////
//// }
//// }
goTo.marker('$');
edit.insert('()');
verify.getSyntacticDiagnostics([]);
| {
"end_byte": 270,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/parserCorruptionAfterMapInClass.ts"
} |
TypeScript/tests/cases/fourslash/completionsOverridingMethod15.ts_0_373 | /// <reference path="fourslash.ts" />
// @newline: LF
////declare class B {
//// get foo(): any;
//// set foo(value: any);
////}
////class A extends B {
//// /**/
////}
goTo.marker("");
verify.baselineCompletions({
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithClassMemberSnippets: true,
});
| {
"end_byte": 373,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingMethod15.ts"
} |
TypeScript/tests/cases/fourslash/findAllReferencesFromLinkTagReference2.ts_0_206 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////enum E {
//// /** {@link /**/Foo} */
//// Foo
////}
////interface Foo {
//// foo: E.Foo;
////}
verify.baselineFindAllReferences("");
| {
"end_byte": 206,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesFromLinkTagReference2.ts"
} |
TypeScript/tests/cases/fourslash/navigationItemsInConstructorsExactMatch.ts_0_848 | /// <reference path="fourslash.ts"/>
// @noLib: true
////class Test {
//// [|private search1: number;|]
//// constructor([|public search2: boolean|], [|readonly search3: string|], search4: string) {
//// }
////}
// Search for properties defined in the constructor, but not other constructor paramters
const [r0, r1, r2] = test.ranges();
verify.navigateTo({
pattern: "search",
expected: [
{ name: "search1", matchKind: "prefix", kind: "property", kindModifiers: "private", range: r0, containerName: "Test", containerKind: "class" },
{ name: "search2", matchKind: "prefix", kind: "property", kindModifiers: "public", range: r1, containerName: "Test", containerKind: "class" },
{ name: "search3", matchKind: "prefix", kind: "property", range: r2, containerName: "Test", containerKind: "class" },
],
});
| {
"end_byte": 848,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationItemsInConstructorsExactMatch.ts"
} |
TypeScript/tests/cases/fourslash/diagnosticsJsFileCompilationDuplicateFunctionImplementation.ts_0_938 | /// <reference path="fourslash.ts" />
// @declaration: true
// @newLine: lf
// @outFile: out.js
// @allowJs: true
// @Filename: b.js
// @emitThisFile: true
////function foo() { return 10; }/*1*/
// @Filename: a.ts
// @emitThisFile: true
////function [|foo|]() { return 30; }/*2*/
goTo.marker("1");
verify.getSemanticDiagnostics([]);
goTo.marker("2");
verify.getSemanticDiagnostics([{
message: "Duplicate function implementation.",
code: 2393
}]);
verify.verifyGetEmitOutputContentsForCurrentFile([
{ name: "out.js", text: "function foo() { return 10; }\nfunction foo() { return 30; }\n", writeByteOrderMark: false },
{ name: "out.d.ts", text: "declare function foo(): number;\ndeclare function foo(): number;\n", writeByteOrderMark: false }]);
goTo.marker("2");
verify.getSemanticDiagnostics([{
message: "Duplicate function implementation.",
code: 2393
}]);
goTo.marker("1");
verify.getSemanticDiagnostics([]);
| {
"end_byte": 938,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/diagnosticsJsFileCompilationDuplicateFunctionImplementation.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingMember12.ts_0_244 | /// <reference path='fourslash.ts' />
//// class C {}
//// const x: number = new C().x;
verify.codeFix({
description: "Declare property 'x'",
index: 0,
newFileContent:
`class C {
x: number;
}
const x: number = new C().x;`
});
| {
"end_byte": 244,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember12.ts"
} |
TypeScript/tests/cases/fourslash/completionsWithOptionalProperties.ts_0_425 | /// <reference path="fourslash.ts" />
// @strict: true
//// interface Options {
//// hello?: boolean;
//// world?: boolean;
//// }
//// declare function foo(options?: Options): void;
//// foo({
//// hello: true,
//// /**/
//// });
verify.completions({
marker: "",
exact: [
{ name: "world", kind: "property", kindModifiers: "optional", sortText: completion.SortText.OptionalMember }
]
});
| {
"end_byte": 425,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsWithOptionalProperties.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarItemsMissingName1.ts_0_1127 | ////export function
////class C {
//// foo() {}
////}
verify.navigationTree({
"text": "\"navigationBarItemsMissingName1\"",
"kind": "module",
"childItems": [
{
"text": "<function>",
"kind": "function",
"kindModifiers": "export"
},
{
"text": "C",
"kind": "class",
"childItems": [
{
"text": "foo",
"kind": "method"
}
]
}
]
});
verify.navigationBar([
{
"text": "\"navigationBarItemsMissingName1\"",
"kind": "module",
"childItems": [
{
"text": "<function>",
"kind": "function",
"kindModifiers": "export"
},
{
"text": "C",
"kind": "class"
}
]
},
{
"text": "C",
"kind": "class",
"childItems": [
{
"text": "foo",
"kind": "method"
}
],
"indent": 1
}
]);
| {
"end_byte": 1127,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsMissingName1.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsCommonJsRequire2.ts_0_231 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: /a.js
//// function f() { }
//// module.exports.f = f
// @Filename: /b.js
//// const { f } = require('./a')
//// /**/f
verify.baselineFindAllReferences("");
| {
"end_byte": 231,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsCommonJsRequire2.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionSameFile.ts_0_788 | /// <reference path='fourslash.ts' />
////var /*localVariableDefinition*/localVariable;
////function /*localFunctionDefinition*/localFunction() { }
////class /*localClassDefinition*/localClass { }
////interface /*localInterfaceDefinition*/localInterface{ }
////module /*localModuleDefinition*/localModule{ export var foo = 1;}
////
////
/////*localVariableReference*/localVariable = 1;
/////*localFunctionReference*/localFunction();
////var foo = new /*localClassReference*/localClass();
////class fooCls implements /*localInterfaceReference*/localInterface { }
////var fooVar = /*localModuleReference*/localModule.foo;
verify.baselineGetDefinitionAtPosition("localVariableReference", "localFunctionReference", "localClassReference", "localInterfaceReference", "localModuleReference");
| {
"end_byte": 788,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionSameFile.ts"
} |
TypeScript/tests/cases/fourslash/codeFixDeleteUnmatchedParameter_allJS.ts_0_789 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @filename: /a.js
/////**
//// * @param {number} a
//// * @param {number} b
//// */
////function f1() {}
////
/////**
//// * @param {number} a
//// * @param {string} b
//// */
////function f2(a) {
//// a;
////}
////
/////**
//// * @param {number} a
//// * @param {string} b
//// * @param {number} c
//// */
////function f3(a, c) {
//// a;
//// c;
////}
goTo.file("/a.js");
verify.codeFixAll({
fixId: "deleteUnmatchedParameter",
fixAllDescription: ts.Diagnostics.Delete_all_unused_param_tags.message,
newFileContent:
`/** */
function f1() {}
/**
* @param {number} a
*/
function f2(a) {
a;
}
/**
* @param {number} a
* @param {number} c
*/
function f3(a, c) {
a;
c;
}`,
});
| {
"end_byte": 789,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixDeleteUnmatchedParameter_allJS.ts"
} |
TypeScript/tests/cases/fourslash/indentationInAugmentations2.ts_0_154 | /// <reference path="fourslash.ts"/>
//// declare module "A" {
//// global {/*1*/
goTo.marker("1");
edit.insertLine("");
verify.indentationIs(8); | {
"end_byte": 154,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indentationInAugmentations2.ts"
} |
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class9.ts_0_357 | /// <reference path='fourslash.ts' />
// @allowNonTsExtensions: true
// @Filename: foo.js
////function Foo() {
//// this.a = 0;
////}
////Foo["b"] = function () {
////}
verify.codeFix({
description: "Convert function to an ES2015 class",
newFileContent:
`class Foo {
constructor() {
this.a = 0;
}
static b() {
}
}
`
});
| {
"end_byte": 357,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class9.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionSwitchCase1.ts_0_144 | /// <reference path="fourslash.ts" />
////switch (null ) {
//// [|/*start*/case|] null: break;
////}
verify.baselineGoToDefinition("start");
| {
"end_byte": 144,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionSwitchCase1.ts"
} |
TypeScript/tests/cases/fourslash/completionListInExtendsClauseAtEOF.ts_0_177 | /// <reference path='fourslash.ts' />
////declare module mod {
//// class Foo { }
////}
////class Bar extends mod./**/
verify.completions({ marker: "", includes: "Foo" });
| {
"end_byte": 177,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInExtendsClauseAtEOF.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_umdDefaultNoCrash2.ts_0_984 | /// <reference path="fourslash.ts" />
// @moduleResolution: node
// @allowJs: true
// @checkJs: true
// @Filename: /node_modules/dottie/package.json
//// {
//// "name": "dottie",
//// "main": "dottie.js"
//// }
// @Filename: /node_modules/dottie/dottie.js
//// (function (undefined) {
//// var root = this;
////
//// var Dottie = function () {};
////
//// Dottie["default"] = function (object, path, value) {};
////
//// if (typeof module !== "undefined" && module.exports) {
//// exports = module.exports = Dottie;
//// } else {
//// root["Dottie"] = Dottie;
//// root["Dot"] = Dottie;
////
//// if (typeof define === "function") {
//// define([], function () {
//// return Dottie;
//// });
//// }
//// }
//// })();
// @Filename: /src/index.js
//// import Dottie from 'dottie';
//// /**/
verify.completions({
marker: "",
includes: [{ name: "Dottie" }],
preferences: { includeCompletionsForModuleExports: true },
});
| {
"end_byte": 984,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_umdDefaultNoCrash2.ts"
} |
TypeScript/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts_0_252 | /// <reference path="fourslash.ts"/>
////class Foo {
//// public x: number;
////}
////
////class Bar extends Foo {
//// public /*1*/x/*2*/: string = 'hi';
////}
verify.errorExistsBetweenMarkers("1", "2");
verify.numberOfErrorsInCurrentFile(1);
| {
"end_byte": 252,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/squiggleIllegalSubclassOverride.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction25.ts_0_395 | /// <reference path='fourslash.ts' />
//// const a = (a: number) /*a*/=>/*b*/ { return a; /* trailing */};
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 a = (a: number) => a /* trailing */;`,
});
| {
"end_byte": 395,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction25.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationEnums.ts_0_614 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_enums.baseline
// @Filename: bpSpan_enums.ts
////enum e {
//// x,
//// y,
//// x
////}
////enum e2 {
//// x = 10,
//// y = 10,
//// z,
//// x2
////}
////enum e3 {
////}
////declare enum e4 {
//// x,
//// y,
//// z,
//// x2
////}
////enum e11
////{
//// x,
//// y,
//// x
////}
////enum e12
////{
//// x = 10,
//// y = 10,
//// z,
//// x2
////}
////enum e13
////{
////}
////declare enum e14
////{
//// x,
//// y,
//// z,
//// x2
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 614,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationEnums.ts"
} |
TypeScript/tests/cases/fourslash/goToTypeDefinitionAliases.ts_0_532 | /// <reference path='fourslash.ts' />
// @Filename: goToTypeDefinitioAliases_module1.ts
////interface /*definition*/I {
//// p;
////}
////export {I as I2};
// @Filename: goToTypeDefinitioAliases_module2.ts
////import {I2 as I3} from "./goToTypeDefinitioAliases_module1";
////var v1: I3;
////export {v1 as v2};
// @Filename: goToTypeDefinitioAliases_module3.ts
////import {/*reference1*/v2 as v3} from "./goToTypeDefinitioAliases_module2";
/////*reference2*/v3;
verify.baselineGoToType(
"reference1",
"reference2",
);
| {
"end_byte": 532,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToTypeDefinitionAliases.ts"
} |
TypeScript/tests/cases/fourslash/todoComments12.ts_0_120 | //// /*
//// [|TODO(jason) 1|]
//// [|HACK 2|]
//// */
verify.todoCommentsInCurrentFile(["HACK", "TODO(jason)"]); | {
"end_byte": 120,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/todoComments12.ts"
} |
TypeScript/tests/cases/fourslash/semanticClassification1.ts_0_821 | /// <reference path="fourslash.ts"/>
//// module /*0*/M {
//// export interface /*1*/I {
//// }
//// }
//// interface /*2*/X extends /*3*/M./*4*/I { }
const c = classification("original");
verify.semanticClassificationsAre("original",
c.moduleName("M", test.marker("0").position),
c.interfaceName("I", test.marker("1").position),
c.interfaceName("X", test.marker("2").position),
c.moduleName("M", test.marker("3").position),
c.interfaceName("I", test.marker("4").position));
var c2 = classification("2020")
verify.semanticClassificationsAre("2020",
c2.semanticToken("namespace.declaration", "M"),
c2.semanticToken("interface.declaration", "I"),
c2.semanticToken("interface.declaration", "X"),
c2.semanticToken("namespace", "M"),
c2.semanticToken("interface", "I"),
)
| {
"end_byte": 821,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semanticClassification1.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixDefaultExport5.ts_0_320 | /// <reference path="fourslash.ts" />
// @moduleResolution: node
// @Filename: /node_modules/hooks/useFoo.ts
////declare const _default: () => void;
////export default _default;
// @Filename: /test.ts
////[|useFoo|];
goTo.file("/test.ts");
verify.importFixAtPosition([`import useFoo from "hooks/useFoo";
useFoo`]);
| {
"end_byte": 320,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixDefaultExport5.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringAssignmentForOfObjectBindingPattern.ts_0_4057 | /// <reference path='fourslash.ts' />
////declare var console: {
//// log(msg: any): void;
////}
////interface Robot {
//// name: string;
//// skill: string;
////}
////interface MultiRobot {
//// name: string;
//// skills: {
//// primary: string;
//// secondary: string;
//// };
////}
////let robots: Robot[] = [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }];
////let multiRobots: MultiRobot[] = [{ name: "mower", skills: { primary: "mowing", secondary: "none" } },
//// { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }];
////function getRobots() {
//// return robots;
////}
////function getMultiRobots() {
//// return multiRobots;
////}
////let nameA: string, primaryA: string, secondaryA: string, i: number, skillA: string;
////let name: string, primary: string, secondary: string, skill: string;
////for ({name: nameA } of robots) {
//// console.log(nameA);
////}
////for ({name: nameA } of getRobots()) {
//// console.log(nameA);
////}
////for ({name: nameA } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) {
//// console.log(nameA);
////}
////for ({ skills: { primary: primaryA, secondary: secondaryA } } of multiRobots) {
//// console.log(primaryA);
////}
////for ({ skills: { primary: primaryA, secondary: secondaryA } } of getMultiRobots()) {
//// console.log(primaryA);
////}
////for ({ skills: { primary: primaryA, secondary: secondaryA } } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } },
//// { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) {
//// console.log(primaryA);
////}
////for ({name } of robots) {
//// console.log(nameA);
////}
////for ({name } of getRobots()) {
//// console.log(nameA);
////}
////for ({name } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) {
//// console.log(nameA);
////}
////for ({ skills: { primary, secondary } } of multiRobots) {
//// console.log(primaryA);
////}
////for ({ skills: { primary, secondary } } of getMultiRobots()) {
//// console.log(primaryA);
////}
////for ({ skills: { primary, secondary } } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } },
//// { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) {
//// console.log(primaryA);
////}
////for ({name: nameA, skill: skillA } of robots) {
//// console.log(nameA);
////}
////for ({name: nameA, skill: skillA } of getRobots()) {
//// console.log(nameA);
////}
////for ({name: nameA, skill: skillA } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) {
//// console.log(nameA);
////}
////for ({name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of multiRobots) {
//// console.log(nameA);
////}
////for ({name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of getMultiRobots()) {
//// console.log(nameA);
////}
////for ({name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } },
//// { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) {
//// console.log(nameA);
////}
////for ({name, skill } of robots) {
//// console.log(nameA);
////}
////for ({name, skill } of getRobots()) {
//// console.log(nameA);
////}
////for ({name, skill } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) {
//// console.log(nameA);
////}
////for ({name, skills: { primary, secondary } } of multiRobots) {
//// console.log(nameA);
////}
////for ({name, skills: { primary, secondary } } of getMultiRobots()) {
//// console.log(nameA);
////}
////for ({name, skills: { primary, secondary } } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } },
//// { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) {
//// console.log(nameA);
////}
verify.baselineCurrentFileBreakpointLocations();
| {
"end_byte": 4057,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringAssignmentForOfObjectBindingPattern.ts"
} |
TypeScript/tests/cases/fourslash/codeFixRenameUnmatchedParameterJS3.ts_0_1828 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @filename: /a.js
/////**
//// * @param {number} notDefined1
//// * @param {number} notDefined2
//// * @param {number} a
//// * @param {number} b
//// */
////function foo(a, b, typo1, typo2) {
//// a;
//// b;
//// typo1;
//// typo2;
////}
verify.codeFixAvailable([
{ description: "Delete unused '@param' tag 'notDefined1'" },
{ description: "Rename '@param' tag name 'notDefined1' to 'typo1'" },
{ description: "Disable checking for this file" },
{ description: "Delete unused '@param' tag 'notDefined2'" },
{ description: "Rename '@param' tag name 'notDefined2' to 'typo1'" },
{ description: "Disable checking for this file" },
{ description: "Infer parameter types from usage" },
{ description: "Infer parameter types from usage" },
]);
verify.codeFix({
description: [ts.Diagnostics.Rename_param_tag_name_0_to_1.message, "notDefined1", "typo1"],
index: 1,
newFileContent:
`/**
* @param {number} typo1
* @param {number} notDefined2
* @param {number} a
* @param {number} b
*/
function foo(a, b, typo1, typo2) {
a;
b;
typo1;
typo2;
}`,
applyChanges: true
});
verify.codeFixAvailable([
{ description: "Delete unused '@param' tag 'notDefined2'" },
{ description: "Rename '@param' tag name 'notDefined2' to 'typo2'" },
{ description: "Disable checking for this file" },
{ description: "Infer parameter types from usage" },
]);
verify.codeFix({
description: [ts.Diagnostics.Rename_param_tag_name_0_to_1.message, "notDefined2", "typo2"],
index: 1,
newFileContent:
`/**
* @param {number} typo1
* @param {number} typo2
* @param {number} a
* @param {number} b
*/
function foo(a, b, typo1, typo2) {
a;
b;
typo1;
typo2;
}`,
});
| {
"end_byte": 1828,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRenameUnmatchedParameterJS3.ts"
} |
TypeScript/tests/cases/fourslash/formatControlFlowConstructs.ts_0_152 | /// <reference path="fourslash.ts" />
////if (true)/**/
////{
////}
format.document();
goTo.marker();
verify.currentLineContentIs("if (true) {"); | {
"end_byte": 152,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatControlFlowConstructs.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptCompletions1.ts_0_254 | ///<reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: Foo.js
/////** @type {number} */
////var v;
////v./**/
verify.completions({ marker: "", includes: { name: "toExponential", kind: "method", kindModifiers: "declare" } });
| {
"end_byte": 254,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptCompletions1.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnElementAccessInWriteLocation1.ts_0_214 | /// <reference path='fourslash.ts'/>
// @strict: true
// @exactOptionalPropertyTypes: true
//// declare const xx: { prop?: number };
//// xx['prop'/*1*/] = 1;
verify.quickInfoAt('1', '(property) prop?: number');
| {
"end_byte": 214,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnElementAccessInWriteLocation1.ts"
} |
TypeScript/tests/cases/fourslash/extract-const-callback-function.ts_0_418 | /// <reference path='fourslash.ts' />
////const x = [1,2,3].map(/*a*/function (x) { return x + 1 }/*b*/);
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "constant_scope_0",
actionDescription: "Extract to constant in enclosing scope",
newContent:
`const newLocal = function(x: number): number { return x + 1; };
const x = [1,2,3].map(/*RENAME*/newLocal);`
});
| {
"end_byte": 418,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const-callback-function.ts"
} |
TypeScript/tests/cases/fourslash/codeFixConvertTypedefToType5.ts_0_246 | /// <reference path='fourslash.ts' />
////
//// /**
//// * @typedef {number} Foo
//// */
////
verify.codeFix({
description: ts.Diagnostics.Convert_typedef_to_TypeScript_type.message,
index: 0,
newFileContent: `
type Foo = number;
`,
}); | {
"end_byte": 246,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertTypedefToType5.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_singleLineStatements3.ts_0_262 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
////export class c1 {} class c2 {}
verify.codeFix({
description: "Remove unused declaration for: 'c2'",
index: 0,
newFileContent: "export class c1 {} "
});
| {
"end_byte": 262,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_singleLineStatements3.ts"
} |
TypeScript/tests/cases/fourslash/unusedFunctionInNamespace3.ts_0_229 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters:true
//// [| namespace Validation {
//// function function1() {
//// }
////} |]
verify.rangeAfterCodeFix(`namespace Validation {
}`);
| {
"end_byte": 229,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedFunctionInNamespace3.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType36.ts_0_373 | /// <reference path='fourslash.ts' />
//// type A = (v: /*a*/string | number/*b*/) => v is string;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent: `type /*RENAME*/NewType = string | number;
type A = (v: NewType) => v is string;`,
});
| {
"end_byte": 373,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType36.ts"
} |
TypeScript/tests/cases/fourslash/autoImportModuleNone2.ts_0_604 | /// <reference path="fourslash.ts" />
// @module: none
// @moduleResolution: node10
// @target: es2015
// @Filename: /node_modules/dep/index.d.ts
////export const x: number;
// @Filename: /index.ts
//// x/**/
verify.completions({
marker: "",
includes: [{
name: "x",
source: "dep",
sourceDisplay: "dep",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
}],
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: true,
},
});
edit.replaceLine(0, "import { x } from 'dep'; x;");
verify.getSemanticDiagnostics([]);
| {
"end_byte": 604,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportModuleNone2.ts"
} |
TypeScript/tests/cases/fourslash/referencesForGlobalsInExternalModule.ts_0_540 | /// <reference path='fourslash.ts'/>
// Global variable reference.
/////*1*/var /*2*/topLevelVar = 2;
////var topLevelVar2 = /*3*/topLevelVar;
////
/////*4*/class /*5*/topLevelClass { }
////var c = new /*6*/topLevelClass();
////
/////*7*/interface /*8*/topLevelInterface { }
////var i: /*9*/topLevelInterface;
////
/////*10*/module /*11*/topLevelModule {
//// export var x;
////}
////var x = /*12*/topLevelModule.x;
////
////export = x;
verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12');
| {
"end_byte": 540,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForGlobalsInExternalModule.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts_0_622 | /// <reference path='fourslash.ts' />
////interface I {
//// ["foo"](o: any): boolean;
//// ["x"]: boolean;
//// [1](): string;
//// [2]: boolean;
////}
////
////class C implements I {}
verify.codeFix({
description: "Implement interface 'I'",
newFileContent:
`interface I {
["foo"](o: any): boolean;
["x"]: boolean;
[1](): string;
[2]: boolean;
}
class C implements I {
["foo"](o: any): boolean {
throw new Error("Method not implemented.");
}
["x"]: boolean;
[1](): string {
throw new Error("Method not implemented.");
}
[2]: boolean;
}`,
});
| {
"end_byte": 622,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsIife.ts_0_207 | /// <reference path='fourslash.ts'/>
// @strictNullChecks: true
////var iife = (function foo/*1*/(x, y) { return x })(12);
verify.quickInfoAt('1', '(local function) foo(x: number, y?: undefined): number');
| {
"end_byte": 207,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsIife.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue20.ts_0_694 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface A {
//// bar: string
//// }
//// class Comp { props: { t: () => number } }
//// var x = <Comp t={() => {
//// { bar: '1' }
//// }} />;
verify.codeFixAvailable([
{ description: ts.Diagnostics.Add_a_return_statement.message },
{ description: ts.Diagnostics.Remove_braces_from_arrow_function_body.message },
{ description: `Infer type of 'props' from usage` },
{ description: ts.Diagnostics.Remove_unused_label.message },
]);
| {
"end_byte": 694,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue20.ts"
} |
TypeScript/tests/cases/fourslash/genericFunctionWithGenericParams1.ts_0_168 | /// <reference path='fourslash.ts'/>
////var obj = function f<T>(a: T) {
//// var x/**/x: T;
//// return a;
////};
verify.quickInfoAt("", "(local var) xx: T");
| {
"end_byte": 168,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericFunctionWithGenericParams1.ts"
} |
TypeScript/tests/cases/fourslash/getImportsOne.ts_0_276 | ///<reference path="fourslash.ts"/>
// @Filename: /first.ts
//// export function foo() {
//// return 1;
//// }
// @Filename: /index.ts
//// import { foo } from "./first";
//// function bar() {
//// return 2;
//// }
////
verify.getImports('/index.ts', ['/first.ts'])
| {
"end_byte": 276,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getImportsOne.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType67.ts_0_235 | /// <reference path='fourslash.ts' />
//// function foo(a: /*a*/{ a: number | string, b: string } & { b: string } & { d: boolean }/*b*/) { }
goTo.select("a", "b");
verify.not.refactorAvailable("Extract type", "Extract to interface")
| {
"end_byte": 235,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType67.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess15.ts_0_585 | /// <reference path='fourslash.ts' />
//// class A {
//// /*a*/public _a: number = 1;/*b*/
//// public a: string = "foo";
//// }
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 _a: number = 1;
public get /*RENAME*/a_1(): number {
return this._a;
}
public set a_1(value: number) {
this._a = value;
}
public a: string = "foo";
}`,
});
| {
"end_byte": 585,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess15.ts"
} |
TypeScript/tests/cases/fourslash/completionsJsdocParamTypeBeforeName.ts_0_319 | /// <reference path="fourslash.ts" />
//// /** @param /*name1*/ {/*type*/} /*name2*/ */
//// function toString(obj) {}
verify.completions({
marker: "type",
exact: completion.globalTypes
});
verify.completions({
marker: "name1",
exact: ["obj"]
});
verify.completions({
marker: "name2",
exact: ["obj"]
});
| {
"end_byte": 319,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsJsdocParamTypeBeforeName.ts"
} |
TypeScript/tests/cases/fourslash/refactorKind_rewriteString.ts_0_186 | /// <reference path='fourslash.ts' />
//// const foo = /*a*/"a" + bar/*b*/;
goTo.select("a", "b");
verify.refactorKindAvailable("refactor.rewrite",
[
"refactor.rewrite.string"
]);
| {
"end_byte": 186,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorKind_rewriteString.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_JSDocTags13.ts_0_288 | /// <reference path="fourslash.ts" />
////let a;
////let b: {
//// /** Comment */ /*1*/p0: number
//// /** Comment */ /*2*/p1: number
//// /** Comment */ /*3*/p2: number
////};
////let c;
// https://github.com/microsoft/TypeScript/issues/49807
verify.baselineSmartSelection();
| {
"end_byte": 288,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_JSDocTags13.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoTypeOnlyNamespaceAndClass.ts_0_318 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export namespace ns {
//// export class Box<T> {}
////}
// @Filename: /b.ts
////import type { ns } from './a';
////let x: /*1*/ns./*2*/Box<string>;
verify.quickInfoAt("1", "(alias) namespace ns\nimport ns");
verify.quickInfoAt("2", "class ns.Box<T>");
| {
"end_byte": 318,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoTypeOnlyNamespaceAndClass.ts"
} |
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction18.ts_0_393 | /// <reference path='fourslash.ts' />
// @target: es2015
////
////interface A {}
////export { A as PublicA };
////async function foo(): A {
//// return {}
////}
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Replace_0_with_Promise_1.message, "A", "A"],
newFileContent: `
interface A {}
export { A as PublicA };
async function foo(): Promise<A> {
return {}
}`
});
| {
"end_byte": 393,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction18.ts"
} |
TypeScript/tests/cases/fourslash/getEditsForFileRename_directory_down.ts_0_1768 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
/////// <reference path="./src/old/file.ts" />
////import old from "./src/old";
////import old2 from "./src/old/file";
////export default 0;
// @Filename: /src/b.ts
/////// <reference path="./old/file.ts" />
////import old from "./old";
////import old2 from "./old/file";
////export default 0;
// @Filename: /src/foo/c.ts
/////// <reference path="../old/file.ts" />
////import old from "../old";
////import old2 from "../old/file";
////export default 0;
// @Filename: /src/old/index.ts
////import a from "../../a";
////import a2 from "../b";
////import a3 from "../foo/c";
////import f from "./file";
////export default 0;
// @Filename: /src/old/file.ts
////export default 0;
// @Filename: /tsconfig.json
////{ "files": ["a.ts", "src/b.ts", "src/foo/c.ts", "src/old/index.ts", "src/old/file.ts"] }
verify.getEditsForFileRename({
oldPath: "/src/old",
newPath: "/src/newDir/new",
newFileContents: {
"/a.ts":
`/// <reference path="./src/newDir/new/file.ts" />
import old from "./src/newDir/new";
import old2 from "./src/newDir/new/file";
export default 0;`,
"/src/b.ts":
`/// <reference path="./newDir/new/file.ts" />
import old from "./newDir/new";
import old2 from "./newDir/new/file";
export default 0;`,
"/src/foo/c.ts":
`/// <reference path="../newDir/new/file.ts" />
import old from "../newDir/new";
import old2 from "../newDir/new/file";
export default 0;`,
"/src/old/index.ts":
`import a from "../../../a";
import a2 from "../../b";
import a3 from "../../foo/c";
import f from "./file";
export default 0;`,
"/tsconfig.json":
`{ "files": ["a.ts", "src/b.ts", "src/foo/c.ts", "src/newDir/new/index.ts", "src/newDir/new/file.ts"] }`,
},
});
| {
"end_byte": 1768,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_directory_down.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_typesVersions.ts_0_994 | /// <reference path="fourslash.ts" />
// @module: commonjs
// @checkJs: true
// @Filename: /node_modules/unified/package.json
//// {
//// "name": "unified",
//// "types": "types/ts3.444/index.d.ts",
//// "typesVersions": {
//// ">=4.0": {
//// "types/ts3.444/*": [
//// "types/ts4.0/*"
//// ]
//// }
//// }
//// }
// @Filename: /node_modules/unified/types/ts3.444/index.d.ts
//// export declare const x: number;
// @Filename: /node_modules/unified/types/ts4.0/index.d.ts
//// export declare const x: number;
// @Filename: /foo.js
//// import {} from "unified";
// @Filename: /index.js
//// x/**/
verify.importFixModuleSpecifiers("", [
"unified",
// This obviously doesn't look like a desired module specifier, but the package.json is misconfigured
// (taken from a real-world example). The fact that it resolves (according to TS) is good enough to
// generate it.
"unified/types/ts3.444/index.js",
], { importModuleSpecifierEnding: "js" });
| {
"end_byte": 994,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_typesVersions.ts"
} |
TypeScript/tests/cases/fourslash/codeFixRequireInTs2.ts_0_242 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////const { a, b, c } = [|require("a")|];
verify.codeFix({
description: ts.Diagnostics.Convert_require_to_import.message,
newFileContent: 'import { a, b, c } from "a";',
});
| {
"end_byte": 242,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRequireInTs2.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_method.ts_0_604 | /// <reference path='fourslash.ts' />
////class Foo {
//// /*a*/bar/*b*/(t: string, s: string): string {
//// return s + t;
//// }
////}
////var foo = new Foo();
////foo.bar("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 {
bar({ t, s }: { t: string; s: string; }): string {
return s + t;
}
}
var foo = new Foo();
foo.bar({ t: "a", s: "b" });`
}); | {
"end_byte": 604,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_method.ts"
} |
TypeScript/tests/cases/fourslash/getEditsForFileRename_keepFileExtensions.ts_0_460 | /// <reference path="fourslash.ts"/>
// @Filename: /tsconfig.json
////{
//// "compilerOptions": {
//// "module": "Node16",
//// "rootDirs": ["src"]
//// }
////}
// @Filename: /src/person.ts
////export const name = 0;
// @Filename: /src/index.ts
////import {name} from "./person.js";
verify.getEditsForFileRename({
oldPath: '/src/person.ts',
newPath: '/src/vip.ts',
newFileContents: {
'/src/index.ts': 'import {name} from "./vip.js";',
},
});
| {
"end_byte": 460,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_keepFileExtensions.ts"
} |
TypeScript/tests/cases/fourslash/completionListInstanceProtectedMembers.ts_0_1183 | /// <reference path='fourslash.ts'/>
////class Base {
//// private privateMethod() { }
//// private privateProperty;
////
//// protected protectedMethod() { }
//// protected protectedProperty;
////
//// public publicMethod() { }
//// public publicProperty;
////
//// protected protectedOverriddenMethod() { }
//// protected protectedOverriddenProperty;
////
//// test() {
//// this./*1*/;
////
//// var b: Base;
//// var c: C1;
////
//// b./*2*/;
//// c./*3*/;
//// }
////}
////
////class C1 extends Base {
//// protected protectedOverriddenMethod() { }
//// protected protectedOverriddenProperty;
////}
verify.completions(
{
marker: ["1", "2"],
unsorted: ["privateMethod", "privateProperty", "protectedMethod", "protectedProperty", "publicMethod", "publicProperty", "protectedOverriddenMethod", "protectedOverriddenProperty", "test"],
},
{
marker: "3",
// Can not access protected properties overridden in subclass
unsorted: ["privateMethod", "privateProperty", "protectedMethod", "protectedProperty", "publicMethod", "publicProperty", "test"],
},
);
| {
"end_byte": 1183,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInstanceProtectedMembers.ts"
} |
TypeScript/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts_0_299 | /// <reference path='fourslash.ts'/>
////interface I {
//// [|[|{| "contextRangeIndex": 0 |}property1|]: number;|]
//// property2: string;
////}
////
////var foo: I;
////[|var { [|{| "contextRangeIndex": 2 |}property1|]: prop1 } = foo;|]
verify.baselineRenameAtRangesWithText("property1");
| {
"end_byte": 299,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction11.ts_0_364 | /// <reference path='fourslash.ts' />
//// const foo = /*a*/a/*b*/ => { return 1, 2, 3; };
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 => (1, 2, 3);`,
});
| {
"end_byte": 364,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction11.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionApparentTypeProperties.ts_0_283 | /// <reference path='fourslash.ts' />
////interface Number {
//// /*definition*/myObjectMethod(): number;
////}
////
////var o = 0;
////o.[|/*reference1*/myObjectMethod|]();
////o[[|"/*reference2*/myObjectMethod"|]]();
verify.baselineGoToDefinition("reference1", "reference2");
| {
"end_byte": 283,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionApparentTypeProperties.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoTypedefTag.ts_0_714 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: a.js
//// /**
//// * The typedef tag should not appear in the quickinfo.
//// * @typedef {{ foo: 'foo' }} Foo
//// */
//// function f() { }
//// f/*1*/()
//// /**
//// * A removed comment
//// * @tag Usage shows that non-param tags in comments explain the typedef instead of using it
//// * @typedef {{ nope: any }} Nope not here
//// * @tag comment 2
//// */
//// function g() { }
//// g/*2*/()
//// /**
//// * The whole thing is kept
//// * @param {Local} keep
//// * @typedef {{ local: any }} Local kept too
//// * @returns {void} also kept
//// */
//// function h(keep) { }
//// h/*3*/({ nope: 1 })
verify.baselineQuickInfo()
| {
"end_byte": 714,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoTypedefTag.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionReturn4.ts_0_105 | /// <reference path="fourslash.ts" />
////[|/*start*/return|];
verify.baselineGoToDefinition("start");
| {
"end_byte": 105,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionReturn4.ts"
} |
TypeScript/tests/cases/fourslash/memberListOfModuleInAnotherModule.ts_0_1076 | /// <reference path='fourslash.ts'/>
////namespace mod1 {
//// var mX = 1;
//// function mFunc() { }
//// class mClass { }
//// namespace mMod { }
//// interface mInt {}
//// export var meX = 1;
//// export function meFunc() { }
//// export class meClass { }
//// export namespace meMod { export var iMex = 1; }
//// export interface meInt {}
////}
////
////namespace frmConfirm {
//// import Mod1 = mod1;
//// import iMod1 = mod1./*1*/meMod;
//// Mod1./*2*/meX = 1;
//// iMod1./*3*/iMex = 1;
////}
const values: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> = [
{ name: "meClass", text: "class mod1.meClass" },
{ name: "meFunc", text: "function mod1.meFunc(): void" },
{ name: "meMod", text: "namespace mod1.meMod" },
{ name: "meX", text: "var mod1.meX: number" },
];
verify.completions(
{ marker: "1", unsorted: [...values, { name: "meInt", text: "interface mod1.meInt" }] },
{ marker: "2", exact: values },
{ marker: "3", exact: { name: "iMex", text: "var mod1.meMod.iMex: number" } },
);
| {
"end_byte": 1076,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberListOfModuleInAnotherModule.ts"
} |
TypeScript/tests/cases/fourslash/completionListInIndexSignature01.ts_0_571 | /// <reference path='fourslash.ts' />
////interface I<T> {
//// [/*1*/]: T;
//// [/*2*/]: T;
////}
////
////class C {
//// [/*3*/]: string;
//// [str/*4*/: string]: number;
////}
////
////type T = {
//// [x/*5*/yz: number]: boolean;
//// [/*6*/
const exact = completion.globalsPlus(["C"]);
verify.completions(
{ marker: ["1", "2", "3", "6"], exact, isNewIdentifierLocation: true },
{ marker: "4", unsorted: ["str", ...exact], isNewIdentifierLocation: true },
{ marker: "5", unsorted: ["xyz", ...exact], isNewIdentifierLocation: true },
);
| {
"end_byte": 571,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInIndexSignature01.ts"
} |
TypeScript/tests/cases/fourslash/textChangesPreserveNewlines2.ts_0_404 | /// <reference path="fourslash.ts" />
//// /*1*/1 +
//// 2 +
////
//// 3 +
////
////
//// 4;/*2*/
goTo.select("1", "2");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_0",
actionDescription: "Extract to function in global scope",
newContent:
`/*RENAME*/newFunction();
function newFunction() {
1 +
2 +
3 +
4;
}
`
});
| {
"end_byte": 404,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/textChangesPreserveNewlines2.ts"
} |
TypeScript/tests/cases/fourslash/formatSelectionWithTrivia3.ts_0_279 | /// <reference path="fourslash.ts" />
// Tests comment indentation with range ending before next token (end block)
////if (true) {
/////*begin*/// test comment
/////*end*/}
format.selection('begin', 'end');
verify.currentFileContentIs("if (true) {\n // test comment\n}");
| {
"end_byte": 279,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatSelectionWithTrivia3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInvalidJsxCharacters1.ts_0_466 | /// <reference path='fourslash.ts' />
// @jsx: react
// @filename: main.tsx
//// let foo = <div>}</div>;
verify.codeFix({
description: ts.Diagnostics.Wrap_invalid_character_in_an_expression_container.message,
newFileContent: `let foo = <div>{"}"}</div>;`,
index: 0,
});
verify.codeFix({
description: ts.Diagnostics.Convert_invalid_character_to_its_html_entity_code.message,
newFileContent: `let foo = <div>}</div>;`,
index: 1,
});
| {
"end_byte": 466,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInvalidJsxCharacters1.ts"
} |
TypeScript/tests/cases/fourslash/interfaceExtendsPrimitive.ts_0_250 | /// <reference path="fourslash.ts"/>
// Ensure there is only one error here and that it is in the type ref of the base
//// interface x extends /*1*/string/*2*/ { }
verify.errorExistsBetweenMarkers('1', '2');
verify.numberOfErrorsInCurrentFile(1); | {
"end_byte": 250,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/interfaceExtendsPrimitive.ts"
} |
TypeScript/tests/cases/fourslash/incrementalResolveConstructorDeclaration.ts_0_325 | /// <reference path="fourslash.ts" />
////class c1 {
//// private b: number;
//// constructor(a: string) {
//// this.b = a;
//// }
////}
////var val = new c1("hello");
/////*1*/val;
// Do resolve without typeCheck
verify.quickInfoAt("1", "var val: c1");
// TypeCheck
verify.numberOfErrorsInCurrentFile(1);
| {
"end_byte": 325,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incrementalResolveConstructorDeclaration.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.