_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/smartSelection_JSDocTags10.ts_0_168 | /// <reference path="fourslash.ts" />
/////**
//// * @template T
//// * @extends {/**/Set<T>}
//// */
////class A extends B {
////}
verify.baselineSmartSelection();
| {
"end_byte": 168,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_JSDocTags10.ts"
} |
TypeScript/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enums.ts_0_206 | /// <reference path='fourslash.ts' />
////var aa = 1;
////enum /*enumName1*/
////enum a/*enumName2*/
////var x = 0; enum /*enumName4*/
verify.completions({ marker: test.markers(), exact: undefined });
| {
"end_byte": 206,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_enums.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_duplicatePackages_typesAndNotTypes.ts_0_1417 | /// <reference path="fourslash.ts" />
// @module: commonjs
// @esModuleInterop: true
// @Filename: /node_modules/@types/react-dom/package.json
//// { "name": "react-dom", "version": "1.0.0", "types": "./index.d.ts" }
// @Filename: /node_modules/@types/react-dom/index.d.ts
//// import * as React from "react";
//// export function render(): void;
// @Filename: /node_modules/@types/react/package.json
//// { "name": "react", "version": "1.0.0", "types": "./index.d.ts" }
// @Filename: /node_modules/@types/react/index.d.ts
//// import "./other";
//// export declare function useState(): void;
// @Filename: /node_modules/@types/react/other.d.ts
//// export declare function useRef(): void;
// @Filename: /packages/a/node_modules/react/package.json
//// { "name": "react", "version": "1.0.1", "types": "./index.d.ts" }
// @Filename: /packages/a/node_modules/react/index.d.ts
//// export declare function useState(): void;
// @Filename: /packages/a/index.ts
//// import "react-dom";
//// import "react";
// @Filename: /packages/a/foo.ts
//// useState/**/
goTo.marker("");
verify.completions({
marker: "",
exact: completion.globalsPlus([{
name: "useState",
source: "react",
sourceDisplay: "react",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
}]),
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: true,
},
});
| {
"end_byte": 1417,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_duplicatePackages_typesAndNotTypes.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsForOfKeyword2.ts_0_531 | /// <reference path="fourslash.ts"/>
//// for (var of in of) { }
const c = classification("original");
verify.syntacticClassificationsAre(
c.keyword("for"),
c.punctuation("("),
c.keyword("var"),
c.identifier("of"),
c.keyword("in"),
c.identifier("of"),
c.punctuation(")"),
c.punctuation("{"),
c.punctuation("}")
);
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("variable.declaration", "of"),
c2.semanticToken("variable", "of"),
);
| {
"end_byte": 531,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsForOfKeyword2.ts"
} |
TypeScript/tests/cases/fourslash/fixExactOptionalUnassignableProperties19.ts_0_728 | /// <reference path='fourslash.ts'/>
// @strictNullChecks: true
// @exactOptionalPropertyTypes: true
//// interface FPA {
//// a?: number
//// }
//// interface J {
//// a?: number | undefined
//// }
//// declare var j: J
//// declare function fpa(fpa: { fpa: FPA }): void
//// fpa({ fpa: j }/**/)
verify.codeFixAvailable([
{ description: ts.Diagnostics.Add_undefined_to_optional_property_type.message }
]);
verify.codeFix({
description: ts.Diagnostics.Add_undefined_to_optional_property_type.message,
index: 0,
newFileContent:
`interface FPA {
a?: number | undefined
}
interface J {
a?: number | undefined
}
declare var j: J
declare function fpa(fpa: { fpa: FPA }): void
fpa({ fpa: j })`,
});
| {
"end_byte": 728,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixExactOptionalUnassignableProperties19.ts"
} |
TypeScript/tests/cases/fourslash/todoComments11.ts_0_120 | //// /*
//// [|TODO(jason) 1|]
//// [|HACK 2|]
//// */
verify.todoCommentsInCurrentFile(["TODO(jason)", "HACK"]); | {
"end_byte": 120,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/todoComments11.ts"
} |
TypeScript/tests/cases/fourslash/semanticClassification2.ts_0_660 | /// <reference path="fourslash.ts"/>
//// interface /*0*/Thing {
//// toExponential(): number;
//// }
////
//// var Thing = 0;
//// Thing.toExponential();
const c = classification("original");
verify.semanticClassificationsAre("original", c.interfaceName("Thing", test.marker("0").position));
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("interface.declaration", "Thing"),
c2.semanticToken("member.declaration", "toExponential"),
c2.semanticToken("variable.declaration", "Thing"),
c2.semanticToken("variable", "Thing"),
c2.semanticToken("member.defaultLibrary", "toExponential")
);
| {
"end_byte": 660,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semanticClassification2.ts"
} |
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType3.ts_0_410 | /// <reference path='fourslash.ts' />
////const foo = /*a*/function/*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 = function(): { x: number; y: number; } {
return { x: 1, y: 1 };
}`
});
| {
"end_byte": 410,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType3.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOfStringPropertyNames1.ts_0_510 | /// <reference path='fourslash.ts'/>
////interface foo {
//// "foo bar": string;
////}
////var f: foo;
////var /*1*/r = f['foo bar'];
////class bar {
//// 'hello world': number;
//// '1': string;
//// constructor() {
//// bar['hello world'] = 3;
//// }
////}
////var b: bar;
////var /*2*/r2 = b["hello world"];
////var /*3*/r4 = b['1'];
////var /*4*/r5 = b[1];
verify.quickInfos({
1: "var r: string",
2: "var r2: number",
3: "var r4: string",
4: "var r5: string"
});
| {
"end_byte": 510,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOfStringPropertyNames1.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixDefaultExport6.ts_0_355 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
//// export default Math.foo;
// @Filename: /index.ts
//// a/**/
verify.applyCodeActionFromCompletion("", {
name: "a",
source: "/a",
description: `Add import from "./a"`,
newFileContent: `import a from "./a";\n\na`,
preferences: {
includeCompletionsForModuleExports: true
}
});
| {
"end_byte": 355,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixDefaultExport6.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingResolutionModeImportAttribute.ts_0_1976 | /// <reference path='fourslash.ts' />
// @module: nodenext
// @Filename: /package.json
//// { "type": "module" }
// @Filename: /module.ts
//// export {};
// @Filename: /common1.cts
//// [|import type { } from "./module.ts"/*1*/;|]
// @Filename: /common2.cts
//// [|import type { } from "./module.ts"/*2*/ with { "type": "typescript" };|]
// @Filename: /common3.cts
//// [|import type { } from "./module"/*3*/;|]
// @Filename: /common4.cts
//// [|type _1 = typeof import("./module.ts"/*4*/);|]
goTo.marker("1");
verify.codeFix({
index: 0,
errorCode: ts.Diagnostics.Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute.code,
applyChanges: false,
description: "Add 'resolution-mode' import attribute",
newRangeContent: `import type { } from "./module.ts" with { "resolution-mode": "import" };`,
});
goTo.marker("2");
verify.codeFix({
index: 0,
errorCode: ts.Diagnostics.Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute.code,
applyChanges: false,
description: "Add 'resolution-mode' import attribute",
newRangeContent: `import type { } from "./module.ts" with { "type": "typescript", "resolution-mode": "import" };`,
});
goTo.marker("3");
verify.codeFix({
index: 0,
errorCode: ts.Diagnostics.Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute.code,
applyChanges: false,
description: "Add 'resolution-mode' import attribute",
newRangeContent: `import type { } from "./module" with { "resolution-mode": "require" };`,
});
goTo.marker("4");
verify.codeFix({
index: 0,
errorCode: ts.Diagnostics.Type_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute.code,
applyChanges: false,
description: "Add 'resolution-mode' import attribute",
newRangeContent: `type _1 = typeof import("./module.ts", { with: { "resolution-mode": "import" } });`,
}); | {
"end_byte": 1976,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingResolutionModeImportAttribute.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUndeclaredMethod.ts_0_1783 | /// <reference path='fourslash.ts' />
//// class A {
//// constructor() {
//// this.foo1(1,2,3);
//// // 7 type args
//// this.foo2<1,2,3,4,5,6,7>();
//// // 8 type args
//// this.foo3<1,2,3,4,5,6,7,8>();
//// }
//// }
verify.codeFix({
description: "Declare method 'foo1'",
index: 0,
newFileContent:
`class A {
constructor() {
this.foo1(1,2,3);
// 7 type args
this.foo2<1,2,3,4,5,6,7>();
// 8 type args
this.foo3<1,2,3,4,5,6,7,8>();
}
foo1(arg0: number, arg1: number, arg2: number) {
throw new Error("Method not implemented.");
}
}`,
applyChanges: true,
});
verify.codeFix({
description: "Declare method 'foo2'",
index: 0,
newFileContent:
`class A {
constructor() {
this.foo1(1,2,3);
// 7 type args
this.foo2<1,2,3,4,5,6,7>();
// 8 type args
this.foo3<1,2,3,4,5,6,7,8>();
}
foo2<T, U, V, W, X, Y, Z>() {
throw new Error("Method not implemented.");
}
foo1(arg0: number, arg1: number, arg2: number) {
throw new Error("Method not implemented.");
}
}`,
applyChanges: true,
});
verify.codeFix({
description: "Declare method 'foo3'",
index: 0,
newFileContent:
`class A {
constructor() {
this.foo1(1,2,3);
// 7 type args
this.foo2<1,2,3,4,5,6,7>();
// 8 type args
this.foo3<1,2,3,4,5,6,7,8>();
}
foo3<T, U, V, W, X, Y, Z, T7>() {
throw new Error("Method not implemented.");
}
foo2<T, U, V, W, X, Y, Z>() {
throw new Error("Method not implemented.");
}
foo1(arg0: number, arg1: number, arg2: number) {
throw new Error("Method not implemented.");
}
}`
});
| {
"end_byte": 1783,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUndeclaredMethod.ts"
} |
TypeScript/tests/cases/fourslash/completionListCladule.ts_0_821 | /// <reference path="fourslash.ts"/>
////class Foo {
//// doStuff(): number { return 0; }
//// static staticMethod() {}
////}
////module Foo {
//// export var x: number;
////}
////Foo/*c1*/; // should get "x", "prototype"
////var s: Foo/*c2*/; // no types, in Foo, so shouldnt have anything
////var f = new Foo();
////f/*c3*/;
goTo.marker("c1");
edit.insert(".");
verify.completions({
includes: [
{ name: "x", sortText: completion.SortText.LocationPriority },
{ name: "prototype", sortText: completion.SortText.LocationPriority },
{ name: "staticMethod", sortText: completion.SortText.LocalDeclarationPriority }
]
});
goTo.marker("c2");
edit.insert(".");
verify.completions({ exact: undefined });
goTo.marker("c3");
edit.insert(".");
verify.completions({ exact: "doStuff" });
| {
"end_byte": 821,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListCladule.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptCompletions2.ts_0_257 | ///<reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: Foo.js
/////** @type {(number|string)} */
////var v;
////v./**/
verify.completions({ marker: "", includes: { name: "valueOf", kind: "method", kindModifiers: "declare" } });
| {
"end_byte": 257,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptCompletions2.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnElementAccessInWriteLocation2.ts_0_215 | /// <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": 215,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnElementAccessInWriteLocation2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixConvertTypedefToType6.ts_0_4223 | /// <reference path='fourslash.ts' />
////
//// /**
//// * @typedef {number} FooNum
//// */
////
//// /**
//// * Some text above the typedef
//// *
//// * @typedef {(number|string|undefined)} FooSome
//// */
////
//// /**
//// * @typedef {string} FooString
//// *
//// * @typedef FooPerson
//// * type {object}
//// * @property {string} id - person's ID
//// * @property name {string} // person's name
//// * @property {number|undefined} age - person's age
//// *
//// * @typedef {object} AnotherFooPerson
//// * @property {object} data
//// * @property {string} data.name
//// * @property {number} data.age
//// * @property {object} data.contact
//// * @property {string} data.contact.address
//// * @property {string} [data.contact.phone]
//// */
////
verify.codeFix({
description: ts.Diagnostics.Convert_typedef_to_TypeScript_type.message,
index: 0,
newFileContent: `
type FooNum = number;
/**
* Some text above the typedef
*
* @typedef {(number|string|undefined)} FooSome
*/
/**
* @typedef {string} FooString
*
* @typedef FooPerson
* type {object}
* @property {string} id - person's ID
* @property name {string} // person's name
* @property {number|undefined} age - person's age
*
* @typedef {object} AnotherFooPerson
* @property {object} data
* @property {string} data.name
* @property {number} data.age
* @property {object} data.contact
* @property {string} data.contact.address
* @property {string} [data.contact.phone]
*/
`,
});
verify.codeFix({
description: ts.Diagnostics.Convert_typedef_to_TypeScript_type.message,
index: 1,
newFileContent: `
/**
* @typedef {number} FooNum
*/
/**
* Some text above the typedef
*/
type FooSome = (number | string | undefined);
/**
* @typedef {string} FooString
*
* @typedef FooPerson
* type {object}
* @property {string} id - person's ID
* @property name {string} // person's name
* @property {number|undefined} age - person's age
*
* @typedef {object} AnotherFooPerson
* @property {object} data
* @property {string} data.name
* @property {number} data.age
* @property {object} data.contact
* @property {string} data.contact.address
* @property {string} [data.contact.phone]
*/
`,
});
verify.codeFix({
description: ts.Diagnostics.Convert_typedef_to_TypeScript_type.message,
index: 2,
newFileContent: `
/**
* @typedef {number} FooNum
*/
/**
* Some text above the typedef
*
* @typedef {(number|string|undefined)} FooSome
*/
type FooString = string;
/**
* @typedef FooPerson
* type {object}
* @property {string} id - person's ID
* @property name {string} // person's name
* @property {number|undefined} age - person's age
*
* @typedef {object} AnotherFooPerson
* @property {object} data
* @property {string} data.name
* @property {number} data.age
* @property {object} data.contact
* @property {string} data.contact.address
* @property {string} [data.contact.phone]
*/
`,
});
verify.codeFix({
description: ts.Diagnostics.Convert_typedef_to_TypeScript_type.message,
index: 3,
newFileContent: `
/**
* @typedef {number} FooNum
*/
/**
* Some text above the typedef
*
* @typedef {(number|string|undefined)} FooSome
*/
/**
* @typedef {string} FooString
*/
interface FooPerson {
id: string;
name: string;
age: number | undefined;
}
/**
* @typedef {object} AnotherFooPerson
* @property {object} data
* @property {string} data.name
* @property {number} data.age
* @property {object} data.contact
* @property {string} data.contact.address
* @property {string} [data.contact.phone]
*/
`,
});
verify.codeFix({
description: ts.Diagnostics.Convert_typedef_to_TypeScript_type.message,
index: 4,
newFileContent: `
/**
* @typedef {number} FooNum
*/
/**
* Some text above the typedef
*
* @typedef {(number|string|undefined)} FooSome
*/
/**
* @typedef {string} FooString
*
* @typedef FooPerson
* type {object}
* @property {string} id - person's ID
* @property name {string} // person's name
* @property {number|undefined} age - person's age
*/
interface AnotherFooPerson {
data: {
name: string;
age: number;
contact: {
address: string;
phone?: string;
};
};
}
`,
});
| {
"end_byte": 4223,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertTypedefToType6.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType35.ts_0_344 | /// <reference path='fourslash.ts' />
//// type Union<T, U> = /*a*/U | T/*b*/;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent: `type /*RENAME*/NewType<U, T> = U | T;
type Union<T, U> = NewType<U, T>;`,
});
| {
"end_byte": 344,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType35.ts"
} |
TypeScript/tests/cases/fourslash/completionListInNamespaceImportName01.ts_0_228 | /// <reference path='fourslash.ts'/>
// @Filename: m1.ts
////export var foo: number = 1;
// @Filename: m2.ts
////import * as /**/ from "m1"
verify.completions({ marker: "", exact: undefined, isNewIdentifierLocation: true });
| {
"end_byte": 228,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInNamespaceImportName01.ts"
} |
TypeScript/tests/cases/fourslash/autoImportModuleNone1.ts_0_716 | /// <reference path="fourslash.ts" />
// @module: none
// @moduleResolution: node10
// @target: es5
// @Filename: /node_modules/dep/index.d.ts
////export const x: number;
// @Filename: /index.ts
//// x/**/
verify.completions({
marker: "",
excludes: ["x"],
preferences: {
includeCompletionsForModuleExports: true,
},
});
edit.replaceLine(0, "import { x } from 'dep'; x;");
verify.getSemanticDiagnostics([{
range: { fileName: "/index.ts", pos: 0, end: "import { x } from 'dep';".length },
code: ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none.code,
message: ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none.message
}]);
| {
"end_byte": 716,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportModuleNone1.ts"
} |
TypeScript/tests/cases/fourslash/callHierarchyCallExpressionByConstNamedFunctionExpression.ts_0_244 | /// <reference path="fourslash.ts" />
//// function foo() {
//// bar();
//// }
////
//// const bar = function () {
//// baz();
//// }
////
//// function baz() {
//// }
////
//// /**/bar()
goTo.marker();
verify.baselineCallHierarchy();
| {
"end_byte": 244,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyCallExpressionByConstNamedFunctionExpression.ts"
} |
TypeScript/tests/cases/fourslash/tripleSlashRefPathCompletionNarrowing.ts_0_1262 | /// <reference path='fourslash.ts' />
// Exercises how changes in the basename change the completions offered.
// They should have no effect, as filtering completions is the responsibility of the editor.
// @Filename: f1.ts
//// /*f1*/
// @Filename: f2.ts
//// /*f2*/
// @Filename: d/g.ts
//// /*g*/
// @Filename: test.ts
//// /// <reference path="f/*0*/
//// /// <reference path="./f/*1*/
//// /// <reference path="./d/*2*/
//// /// <reference path="f1/*3*/
//// /// <reference path="[|f1./*4*/|]
//// /// <reference path="[|f1.t/*5*/|]
//// /// <reference path="[|f1.ts/*6*/|]
//// /// <reference path="./f1/*7*/
//// /// <reference path="./[|f1./*8*/|]
//// /// <reference path="./[|f1.t/*9*/|]
//// /// <reference path="./[|f1.ts/*10*/|]
const names = ["f1.ts", "f2.ts", "d"];
const markersWithReplacementSpan = [4, 5, 6, 8, 9, 10];
const ranges = test.ranges();
verify.completions(
{
marker: ["0", "1", "2", "3", "7"],
exact: names,
isNewIdentifierLocation: true,
},
...markersWithReplacementSpan.map((marker, i): FourSlashInterface.CompletionsOptions => ({
marker: String(marker),
exact: names.map(name => ({ name, replacementSpan: ranges[i] })),
isNewIdentifierLocation: true,
})),
);
| {
"end_byte": 1262,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tripleSlashRefPathCompletionNarrowing.ts"
} |
TypeScript/tests/cases/fourslash/completionsWrappedClass.ts_0_446 | /// <reference path="fourslash.ts" />
////class Client {
//// private close() { }
//// public open() { }
////}
////type Wrap<T> = T &
////{
//// [K in Extract<keyof T, string> as `${K}Wrapped`]: T[K];
////};
////class Service {
//// method() {
//// let service = undefined as unknown as Wrap<Client>;
//// const { /*a*/ } = service;
//// }
////}
verify.completions({ marker: "a", exact: ["open", "openWrapped"] });
| {
"end_byte": 446,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsWrappedClass.ts"
} |
TypeScript/tests/cases/fourslash/codeFixForgottenThisPropertyAccess_static.ts_0_451 | /// <reference path='fourslash.ts' />
////class C {
//// static m() { m(); }
//// n() { m(); }
////}
verify.codeFix({
description: "Add 'C.' to unresolved variable",
index: 0,
newFileContent:
`class C {
static m() { C.m(); }
n() { m(); }
}`,
applyChanges: true,
});
verify.codeFix({
description: "Add 'C.' to unresolved variable",
newFileContent:
`class C {
static m() { C.m(); }
n() { C.m(); }
}`
});
| {
"end_byte": 451,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixForgottenThisPropertyAccess_static.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionSwitchCase2.ts_0_141 | /// <reference path="fourslash.ts" />
////switch (null) {
//// [|/*start*/default|]: break;
////}
verify.baselineGoToDefinition("start");
| {
"end_byte": 141,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionSwitchCase2.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_umdDefaultNoCrash1.ts_0_1097 | /// <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
//// /**/
verify.completions({
marker: "",
includes: [
{
name: "Dottie",
hasAction: true,
source: "/node_modules/dottie/dottie",
sortText: completion.SortText.AutoImportSuggestions,
},
],
preferences: { includeCompletionsForModuleExports: true },
});
| {
"end_byte": 1097,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_umdDefaultNoCrash1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpellingVsMissingMember.ts_0_381 | /// <reference path='fourslash.ts' />
// Tests that the spelling fix is returned first.
////class C {
//// foof: number;
//// method() {
//// this.foo = 10;
//// }
////}
verify.codeFixAvailable([
{ description: "Change spelling to 'foof'" },
{ description: "Declare property \'foo\'" },
{ description: "Add index signature for property 'foo'" },
]);
| {
"end_byte": 381,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingVsMissingMember.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction26.ts_0_422 | /// <reference path='fourslash.ts' />
//// const a = (a: number) /*a*/=>/*b*/ {/* leading */ 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) => /* leading */ a /* trailing */;`,
});
| {
"end_byte": 422,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction26.ts"
} |
TypeScript/tests/cases/fourslash/letQuickInfoAndCompletionList.ts_0_677 | /// <reference path='fourslash.ts' />
////let /*1*/a = 10;
/////*2*/a = 30;
////function foo() {
//// let /*3*/b = 20;
//// /*4*/b = /*5*/a;
////}
const a = "let a: number";
const b = "let b: number";
const completionA: FourSlashInterface.ExpectedCompletionEntry = { name: "a", text: a };
const completionB: FourSlashInterface.ExpectedCompletionEntry = { name: "b", text: b };
verify.completions(
{ marker: "2", includes: completionA },
{ marker: "4", includes: [completionA, completionB] },
{ marker: "5", includes: [completionA, completionB], isNewIdentifierLocation: true },
);
verify.quickInfos({
1: a,
2: a,
3: b,
4: b,
5: a,
});
| {
"end_byte": 677,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/letQuickInfoAndCompletionList.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodCallUnion.ts_0_690 | /// <reference path='fourslash.ts' />
////class A {
//// /*a*/foo/*b*/(a: number, b: number) { return a + b; }
////}
////class B {
//// foo(c: number, d: number) { return c + d; }
////}
////declare var ab: A | B;
////ab.foo(1, 2);
goTo.select("a", "b");
// Refactor should not make changes
edit.applyRefactor({
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `class A {
foo(a: number, b: number) { return a + b; }
}
class B {
foo(c: number, d: number) { return c + d; }
}
declare var ab: A | B;
ab.foo(1, 2);`
}); | {
"end_byte": 690,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodCallUnion.ts"
} |
TypeScript/tests/cases/fourslash/semanticModernClassificationInfinityAndNaN.ts_0_923 | /// <reference path="fourslash.ts"/>
//// Infinity;
//// NaN;
////
////// Regular properties
////
////const obj1 = {
//// Infinity: 100,
//// NaN: 200,
//// "-Infinity": 300
////};
////
////obj1.Infinity;
////obj1.NaN;
////obj1["-Infinity"];
////
////// Shorthand properties
////
////const obj2 = {
//// Infinity,
//// NaN,
////}
////
////obj2.Infinity;
////obj2.NaN;
// Basically only the obj1 and obj2 should be showing up in this list
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("variable.declaration.readonly", "obj1"),
c2.semanticToken("variable.readonly", "obj1"),
c2.semanticToken("variable.readonly", "obj1"),
c2.semanticToken("variable.readonly", "obj1"),
c2.semanticToken("variable.declaration.readonly", "obj2"),
c2.semanticToken("variable.readonly", "obj2"),
c2.semanticToken("variable.readonly", "obj2"),
); | {
"end_byte": 923,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semanticModernClassificationInfinityAndNaN.ts"
} |
TypeScript/tests/cases/fourslash/findAllReferencesFromLinkTagReference1.ts_0_136 | /// <reference path="fourslash.ts" />
////enum E {
//// /** {@link /**/A} */
//// A
////}
verify.baselineFindAllReferences("");
| {
"end_byte": 136,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesFromLinkTagReference1.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringVariableStatementDefaultValues.ts_0_732 | /// <reference path='fourslash.ts' />
////interface Robot {
//// name: string;
//// skill: string;
////}
////declare var console: {
//// log(msg: string): void;
////}
////var hello = "hello";
////var robotA: Robot = { name: "mower", skill: "mowing" };
////var robotB: Robot = { name: "trimmer", skill: "trimming" };
////var { name: nameA = "<NoName>" } = robotA;
////var { name: nameB = "<NoName>", skill: skillB = "<skillUnspecified>" } = robotB;
////var { name: nameC = "<NoName>", skill: skillC = "<skillUnspecified>" } = { name: "Edger", skill: "cutting edges" };
////if (nameA == nameB) {
//// console.log(skillB);
////}
////else {
//// console.log(nameC);
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 732,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringVariableStatementDefaultValues.ts"
} |
TypeScript/tests/cases/fourslash/jsFileImportNoTypes.ts_0_1019 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @filename: /declarations.ts
//// export class TestClass {}
//// export const testValue = {};
//// export enum TestEnum {}
//// export function testFunction() {}
//// export interface testInterface {}
//// export namespace TestNamespaceEmpty {}
//// export namespace TestNamespaceWithType {
//// export type testTypeInner = boolean;
//// }
//// export namespace TestNamespaceWithValue {
//// export const testValueInner = true;
//// }
//// export type testType = {};
////
//// export interface TestInterfaceMerged {}
//// export interface TestInterfaceMerged {}
////
//// export interface TestClassInterfaceMerged {}
//// export class TestClassInterfaceMerged {}
////
//// export declare const declaredVariable: number;
//// export declare class DeclaredClass {}
//// export declare interface DeclaredInterface {}
//// export declare type DeclaredType = {};
// @filename: /a.js
////import { /**/ } from './declarations.ts'
verify.baselineCompletions();
| {
"end_byte": 1019,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsFileImportNoTypes.ts"
} |
TypeScript/tests/cases/fourslash/transitiveExportImports3.ts_0_839 | /// <reference path='fourslash.ts'/>
// @Filename: a.ts
////[|export function /*f*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|]() {}|]
// @Filename: b.ts
////[|export { [|{| "contextRangeIndex": 2 |}f|] as /*g0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}g|] } from "./a";|]
////[|import { /*f2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}f|] } from "./a";|]
////[|import { /*g1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 7 |}g|] } from "./b";|]
verify.noErrors();
const [f0Def, f0, f1Def, f1, g0, f2Def, f2, g1Def, g1] = test.ranges();
verify.baselineFindAllReferences('f', 'g0', 'g1', 'f2');
verify.baselineRename([f0, f1]);
verify.baselineRename(f2);
verify.baselineRename(g0);
verify.baselineRename(g1);
| {
"end_byte": 839,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/transitiveExportImports3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingMember11.ts_0_418 | /// <reference path='fourslash.ts' />
//// class C {}
//// function f(v: number): void { }
//// f(new C().add(1, 2))
verify.codeFix({
index: 0,
description: ignoreInterpolations(ts.Diagnostics.Declare_method_0),
newFileContent:
`class C {
add(arg0: number, arg1: number): number {
throw new Error("Method not implemented.");
}
}
function f(v: number): void { }
f(new C().add(1, 2))`,
});
| {
"end_byte": 418,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember11.ts"
} |
TypeScript/tests/cases/fourslash/completionListInExtendsClause.ts_0_701 | /// <reference path='fourslash.ts' />
////interface IFoo {
//// method();
////}
////
////class Foo {
//// property: number;
//// method() { }
//// static staticMethod() { }
////}
////class test1 extends Foo./*1*/ {}
////class test2 implements IFoo./*2*/ {}
////interface test3 extends IFoo./*3*/ {}
////interface test4 implements Foo./*4*/ {}
verify.completions(
{
marker: "1",
exact: completion.functionMembersPlus([
{ name: "staticMethod", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "prototype", sortText: completion.SortText.LocationPriority },
])
},
{ marker: ["2", "3", "4"], exact: undefined },
);
| {
"end_byte": 701,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInExtendsClause.ts"
} |
TypeScript/tests/cases/fourslash/unusedImports13FS.ts_0_269 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @Filename: file2.ts
//// [| import A, { x } from './a'; |]
//// console.log(A);
// @Filename: file1.ts
//// export default 10;
//// export var x = 10;
verify.rangeAfterCodeFix("import A from './a';"); | {
"end_byte": 269,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedImports13FS.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarItemsMissingName2.ts_0_908 | /////**
//// * This is a class.
//// */
////class /* But it has no name! */ {
//// foo() {}
////}
// Anonymous classes are still included.
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "<class>",
"kind": "class",
"childItems": [
{
"text": "foo",
"kind": "method"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "<class>",
"kind": "class"
}
]
},
{
"text": "<class>",
"kind": "class",
"childItems": [
{
"text": "foo",
"kind": "method"
}
],
"indent": 1
}
]);
| {
"end_byte": 908,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsMissingName2.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_unexported_uninitialized_var.ts_0_541 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @target: esnext
// @Filename: /a.js
////var privateUnrelated;
////[|exports.f|] = function() {};
////privateUnrelated = 1;
////console.log(privateUnrelated);
verify.getSuggestionDiagnostics([{
message: "File is a CommonJS module; it may be converted to an ES module.",
code: 80001,
}]);
verify.codeFix({
description: "Convert to ES module",
newFileContent:
`var privateUnrelated;
export function f() {}
privateUnrelated = 1;
console.log(privateUnrelated);`,
});
| {
"end_byte": 541,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_unexported_uninitialized_var.ts"
} |
TypeScript/tests/cases/fourslash/refactorOverloadListToSingleSignature8.ts_0_589 | /// <reference path='fourslash.ts' />
////interface A {
//// /*a*/foo(): void;
//// foo(a: string): void;
//// foo(a: number, b: number): void;
//// foo(...rest: symbol[]): void;/*b*/
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert overload list to single signature",
actionName: "Convert overload list to single signature",
actionDescription: ts.Diagnostics.Convert_overload_list_to_single_signature.message,
newContent: `interface A {
foo(...args: [] | [a: string] | [a: number, b: number] | [...rest: symbol[]]): void;
}`,
});
| {
"end_byte": 589,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorOverloadListToSingleSignature8.ts"
} |
TypeScript/tests/cases/fourslash/codeFixTopLevelAwait_module_existingCompilerOptionsInTsConfig.ts_0_507 | /// <reference path="fourslash.ts" />
// @filename: /dir/a.ts
////declare const p: Promise<number>;
////await p;
////export {};
// @filename: /dir/tsconfig.json
////{
//// "compilerOptions": {
//// "module": "es2015"
//// }
////}
verify.codeFix({
description: [ts.Diagnostics.Set_the_module_option_in_your_configuration_file_to_0.message, "esnext"],
index: 0,
newFileContent: {
"/dir/tsconfig.json":
`{
"compilerOptions": {
"module": "esnext"
}
}`
}
});
| {
"end_byte": 507,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelAwait_module_existingCompilerOptionsInTsConfig.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts_0_279 | /// <reference path='fourslash.ts' />
//// class C1 {
//// f1() {}
//// }
////
//// class C2 extends C1 {
////
//// }
////
//// class C3 implements C2 {[|
//// |]f2(){}
//// }
verify.rangeAfterCodeFix(`f1(): void{
throw new Error("Method not implemented.");
}
`);
| {
"end_byte": 279,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts"
} |
TypeScript/tests/cases/fourslash/indentationInAugmentations1.ts_0_164 | /// <reference path="fourslash.ts"/>
// @module: amd
//// export {}
//// declare global {/*1*/
goTo.marker("1");
edit.insertLine("");
verify.indentationIs(4); | {
"end_byte": 164,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indentationInAugmentations1.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsForDefaultExport_reExport.ts_0_325 | /// <reference path='fourslash.ts' />
// @Filename: /export.ts
////const /*0*/foo = 1;
////export default /*1*/foo;
// @Filename: /re-export.ts
////export { /*2*/default } from "./export";
// @Filename: /re-export-dep.ts
////import /*3*/fooDefault from "./re-export";
verify.baselineFindAllReferences('0', '1', '2', '3')
| {
"end_byte": 325,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForDefaultExport_reExport.ts"
} |
TypeScript/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts_0_191 | /// <reference path='fourslash.ts'/>
////var x = [|function [|{| "contextRangeIndex": 0 |}f|](g: any, h: any) {
//// [|f|]([|f|], g);
////}|]
verify.baselineRenameAtRangesWithText("f");
| {
"end_byte": 191,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromFunctionThisUsageJsDocExistingDocsClass.ts_0_742 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noImplicitThis: true
// @Filename: /consumesType.js
/////**
//// * @returns {string}
//// */
////function [|returnThisMember|]() {
//// return this.member;
////}
////
////class Container {
//// member = "sample";
//// returnThisMember = returnThisMember;
////};
////
////container.returnThisMember();
verify.codeFix({
description: "Infer 'this' type of 'returnThisMember' from usage",
index: 0,
newFileContent: `/**
* @returns {string}
* @this {Container}
*/
function returnThisMember() {
return this.member;
}
class Container {
member = "sample";
returnThisMember = returnThisMember;
};
container.returnThisMember();`
});
| {
"end_byte": 742,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromFunctionThisUsageJsDocExistingDocsClass.ts"
} |
TypeScript/tests/cases/fourslash/goToTypeDefinition_promiseType.ts_0_296 | /// <reference path='fourslash.ts' />
//// type User = { name: string };
//// async function /*reference*/getUser() { return { name: "Bob" } satisfies User as User }
////
//// const /*reference2*/promisedBob = getUser()
////
//// export {}
verify.baselineGoToType("reference", "reference2");
| {
"end_byte": 296,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToTypeDefinition_promiseType.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesPropertyInAliasedInterface.ts_0_297 | ////module m {
//// export interface Foo {
//// [|abc|]
//// }
////}
////
////import Bar = m.Foo;
////
////export interface I extends Bar {
//// [|abc|]
////}
////
////class C implements Bar {
//// [|abc|]
////}
////
////(new C()).[|abc|];
verify.baselineDocumentHighlights();
| {
"end_byte": 297,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesPropertyInAliasedInterface.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsForComputedProperties2.ts_0_265 | /// <reference path='fourslash.ts'/>
////interface I {
//// [/*1*/42](): void;
////}
////
////class C implements I {
//// [/*2*/42]: any;
////}
////
////var x: I = {
//// ["/*3*/42"]: function () { }
////}
verify.baselineFindAllReferences('1', '2', '3')
| {
"end_byte": 265,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForComputedProperties2.ts"
} |
TypeScript/tests/cases/fourslash/completionListInNamedFunctionExpression1.ts_3_219 | /<reference path="fourslash.ts" />
//// var x = function foo() {
//// /*1*/
//// }
verify.completions({ marker: "1", includes: { name: "foo", text: "(local function) foo(): void", kind: "local function" } });
| {
"end_byte": 219,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInNamedFunctionExpression1.ts"
} |
TypeScript/tests/cases/fourslash/formatAsyncClassMethod1.ts_0_174 | ///<reference path="fourslash.ts"/>
////class Foo {
//// async foo() {}
////}
format.document();
verify.currentFileContentIs(
`class Foo {
async foo() { }
}`
);
| {
"end_byte": 174,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatAsyncClassMethod1.ts"
} |
TypeScript/tests/cases/fourslash/documentHighlightMultilineTemplateStrings.ts_3_165 | / <reference path='fourslash.ts'/>
////const foo = `
//// a
//// [|b|]
//// c
////`
const [r] = test.ranges();
verify.baselineDocumentHighlights(r);
| {
"end_byte": 165,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlightMultilineTemplateStrings.ts"
} |
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax19.ts_0_173 | /// <reference path='fourslash.ts' />
//// var index: { new (ix: number): [|?|] };
verify.codeFix({
description: "Change '?' to 'any'",
newRangeContent: "any",
});
| {
"end_byte": 173,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax19.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAwaitInSyncFunction2.ts_0_272 | /// <reference path='fourslash.ts' />
////const f = function() {
//// await Promise.resolve();
////}
verify.codeFix({
description: "Add async modifier to containing function",
newFileContent:
`const f = async function() {
await Promise.resolve();
}`,
});
| {
"end_byte": 272,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAwaitInSyncFunction2.ts"
} |
TypeScript/tests/cases/fourslash/documentHighlightAtInheritedProperties4.ts_3_268 | / <reference path='fourslash.ts'/>
// @Filename: file1.ts
//// class class1 extends class1 {
//// [|doStuff|]() { }
//// [|propName|]: string;
//// }
////
//// var c: class1;
//// c.[|doStuff|]();
//// c.[|propName|];
verify.baselineDocumentHighlights();
| {
"end_byte": 268,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlightAtInheritedProperties4.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType50.ts_0_181 | /// <reference path='fourslash.ts' />
//// interface I { f: (this: O, b: number) => /*a*/typeof this.a/*b*/ };
goTo.select("a", "b");
verify.not.refactorAvailable("Extract type")
| {
"end_byte": 181,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType50.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess22.ts_0_593 | /// <reference path='fourslash.ts' />
//// class A {
//// public a_1: number;
//// constructor(public /*a*/a/*b*/: string) { }
//// }
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Generate 'get' and 'set' accessors",
actionName: "Generate 'get' and 'set' accessors",
actionDescription: "Generate 'get' and 'set' accessors",
newContent: `class A {
public get a(): string {
return this._a;
}
public set a(value: string) {
this._a = value;
}
public a_1: number;
constructor(private /*RENAME*/_a: string) { }
}`,
});
| {
"end_byte": 593,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess22.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpExpandedRestTuples.ts_0_1139 | /// <reference path='fourslash.ts' />
////export function complex(item: string, another: string, ...rest: [] | [settings: object, errorHandler: (err: Error) => void] | [errorHandler: (err: Error) => void, ...mixins: object[]]) {
////
////}
////
////complex(/*1*/);
////complex("ok", "ok", /*2*/);
////complex("ok", "ok", e => void e, {}, /*3*/);
verify.signatureHelp(
{
marker: "1",
text: "complex(item: string, another: string): void",
overloadsCount: 3,
parameterCount: 2,
parameterName: "item",
parameterSpan: "item: string",
isVariadic: false,
},
{
marker: "2",
text: "complex(item: string, another: string, settings: object, errorHandler: (err: Error) => void): void",
overloadsCount: 3,
parameterCount: 4,
parameterName: "settings",
parameterSpan: "settings: object",
isVariadic: false,
},
{
marker: "3",
text: "complex(item: string, another: string, errorHandler: (err: Error) => void, ...mixins: object[]): void",
overloadsCount: 3,
isVariadic: true,
},
);
| {
"end_byte": 1139,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpExpandedRestTuples.ts"
} |
TypeScript/tests/cases/fourslash/codeFixOverrideModifier_js1.ts_0_463 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noEmit: true
// @noImplicitOverride: true
// @filename: a.js
//// class B {
//// foo (v) {}
//// }
//// class D extends B {
//// /** @public */
//// foo (v) {}
//// }
verify.codeFix({
description: "Add 'override' modifier",
index: 0,
newFileContent:
`class B {
foo (v) {}
}
class D extends B {
/**
*
* @override
*/
foo (v) {}
}`,
}) | {
"end_byte": 463,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixOverrideModifier_js1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingAttributes3.ts_0_495 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: foo.tsx
////interface P {
//// a: number;
//// b: string;
//// c: number[];
//// d: any;
////}
////
////const A = ({ a, b, c, d }: P) =>
//// <div>{a}{b}{c}{d}</div>;
////
////const Bar = () =>
//// [|<A {...{ a: 1, b: "" }}></A>|]
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_attributes.message,
newRangeContent: `<A c={[]} d={undefined} {...{ a: 1, b: "" }}></A>`
});
| {
"end_byte": 495,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAttributes3.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_reExport.ts_0_316 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export default function foo(): void {}
// @Filename: /b.ts
////export { default } from "./a";
// @Filename: /user.ts
////[|foo;|]
goTo.file("/user.ts");
verify.importFixAtPosition([
`import foo from "./a";
foo;`,
`import foo from "./b";
foo;`,
]);
| {
"end_byte": 316,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_reExport.ts"
} |
TypeScript/tests/cases/fourslash/completionsBeforeRestArg1.ts_0_238 | /// <reference path="fourslash.ts" />
// @target: esnext
// @lib: esnext
//// const layers = Object.assign({}, /*1*/...[]);
verify.completions({
marker: "1",
includes: completion.globals,
isNewIdentifierLocation: true,
});
| {
"end_byte": 238,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsBeforeRestArg1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue17.ts_0_267 | /// <reference path='fourslash.ts' />
//// interface A {
//// bar: string
//// }
////
//// function Foo (): A {
//// bar: '123'
//// }
verify.codeFixAvailable([
{ description: 'Add a return statement' },
{ description: 'Remove unused label' },
]);
| {
"end_byte": 267,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue17.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_parameter_callback2.ts_0_356 | /// <reference path='fourslash.ts' />
// @noUnusedParameters: true
////declare function foo(cb: (x: number, y: string) => void): void;
////function fn(x: number, y: number): any {
//// return y;
////}
////foo(fn);
// No codefix to remove a non-last parameter in a callback
verify.codeFixAvailable([{ description: "Prefix 'x' with an underscore" }]);
| {
"end_byte": 356,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_parameter_callback2.ts"
} |
TypeScript/tests/cases/fourslash/completionsTuple.ts_0_426 | /// <reference path="fourslash.ts" />
////declare const x: [number, number];
////x[|./**/|];
const replacementSpan = test.ranges()[0];
verify.completions({
marker: "",
includes: [
{ name: "0", insertText: '[0]', replacementSpan },
{ name: "1", insertText: '[1]', replacementSpan },
"length",
],
excludes: "2",
preferences: {
includeInsertTextCompletions: true,
},
});
| {
"end_byte": 426,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsTuple.ts"
} |
TypeScript/tests/cases/fourslash/completionListInNamedClassExpressionWithShadowing.ts_0_654 | ///<reference path="fourslash.ts" />
//// class myClass { /*0*/ }
//// /*1*/
//// var x = class myClass {
//// getClassName (){
//// m/*2*/
//// }
//// /*3*/
//// }
//// var y = class {
//// getSomeName() {
//// /*4*/
//// }
//// /*5*/
//// }
verify.completions(
{ marker: "0", excludes: "myClass", isNewIdentifierLocation: true },
{ marker: ["1", "4"], includes: { name: "myClass", text: "class myClass", kind: "class" } },
{ marker: "2", includes: { name: "myClass", text: "(local class) myClass", kind: "local class" } },
{ marker: ["3", "5"], excludes: "myClass", isNewIdentifierLocation: true },
);
| {
"end_byte": 654,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInNamedClassExpressionWithShadowing.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsForOfKeyword.ts_0_531 | /// <reference path="fourslash.ts"/>
//// for (var of of of) { }
const c = classification("original");
verify.syntacticClassificationsAre(
c.keyword("for"),
c.punctuation("("),
c.keyword("var"),
c.identifier("of"),
c.keyword("of"),
c.identifier("of"),
c.punctuation(")"),
c.punctuation("{"),
c.punctuation("}")
);
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("variable.declaration", "of"),
c2.semanticToken("variable", "of"),
);
| {
"end_byte": 531,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsForOfKeyword.ts"
} |
TypeScript/tests/cases/fourslash/formattingOnEmptyInterfaceLiteral.ts_0_767 | /// <reference path='fourslash.ts' />
/////*1*/ function foo ( x : { } ) { }
////
/////*2*/foo ( { } ) ;
////
////
////
/////*3*/ interface bar {
/////*4*/ x : { } ;
/////*5*/ y : ( ) => { } ;
/////*6*/ }
format.document();
goTo.marker("1");
verify.currentLineContentIs("function foo(x: {}) { }");
goTo.marker("2");
verify.currentLineContentIs("foo({});");
goTo.marker("3");
verify.currentLineContentIs("interface bar {");
goTo.marker("4");
verify.currentLineContentIs(" x: {};");
goTo.marker("5");
verify.currentLineContentIs(" y: () => {};");
goTo.marker("6");
verify.currentLineContentIs("}"); | {
"end_byte": 767,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnEmptyInterfaceLiteral.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName04.ts_0_278 | /// <reference path='fourslash.ts'/>
////interface Recursive {
//// next?: Recursive;
//// value: any;
////}
////
////function f ({ /*1*/next: { /*2*/next: x} }) {
////}
verify.quickInfos({
1: `(property) next: {
next: any;
}`,
2: "(property) next: any"
});
| {
"end_byte": 278,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForObjectBindingElementPropertyName04.ts"
} |
TypeScript/tests/cases/fourslash/editTemplateConstraint.ts_0_152 | /// <reference path='fourslash.ts' />
/////**
//// * @template {/**/
//// */
////function f() {}
goTo.marker("");
edit.insert("n");
edit.insert("u");
| {
"end_byte": 152,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/editTemplateConstraint.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_exportEquals.ts_0_1335 | /// <reference path="fourslash.ts" />
// @module: commonjs
// @Filename: /a.d.ts
////declare function a(): void;
////declare namespace a {
//// export interface b {}
////}
////export = a;
// @Filename: /b.ts
////a/*0*/;
////let x: b/*1*/;
const preferences: FourSlashInterface.UserPreferences = { includeCompletionsForModuleExports: true };
verify.completions(
{
marker: "0",
includes: {
name: "a",
source: "/a",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences,
},
{
marker: "1",
includes: {
name: "b",
source: "/a",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences,
}
);
// Import { b } first, or it will just add a qualified name from 'a' (which isn't what we're trying to test)
verify.applyCodeActionFromCompletion("1", {
name: "b",
source: "/a",
description: `Add import from "./a"`,
newFileContent:
`import { b } from "./a";
a;
let x: b;`,
});
verify.applyCodeActionFromCompletion("0", {
name: "a",
source: "/a",
description: `Add import from "./a"`,
newFileContent:
`import { b } from "./a";
import a = require("./a");
a;
let x: b;`,
});
| {
"end_byte": 1335,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_exportEquals.ts"
} |
TypeScript/tests/cases/fourslash/completionsRecommended_nonAccessibleSymbol.ts_0_185 | /// <reference path="fourslash.ts" />
////function f() {
//// class C {}
//// return (c: C) => void;
////}
////f()(new /**/);
verify.completions({ marker: "", excludes: "C" });
| {
"end_byte": 185,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsRecommended_nonAccessibleSymbol.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpWithUnknown.ts_0_86 | /// <reference path='fourslash.ts'/>
////eval(\/*1*/
verify.baselineSignatureHelp()
| {
"end_byte": 86,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpWithUnknown.ts"
} |
TypeScript/tests/cases/fourslash/genericInterfacePropertyInference2.ts_0_2573 | /// <reference path='fourslash.ts'/>
////interface I {
//// x: number;
////}
////
////var anInterface: I;
////interface IG<T> {
//// x: T;
////}
////var aGenericInterface: IG<number>;
////
////class C<T> implements IG<T> {
//// x: T;
////}
////
////interface Foo<T> {
//// ofFooT: Foo<T>;
//// ofFooFooNum: Foo<Foo<number>>; // should be error?
//// ofIG: IG<T>;
//// ofIG5: { x: Foo<T>; }; // same as ofIG3
//// ofC1: C<T>;
////}
////
////var f: Foo<any>;
////var f2: Foo<number>;
////var f3: Foo<I>;
////var f4: Foo<{ x: number }>;
////var f5: Foo<Foo<number>>;
////
////// T is any
////var f_/*a1*/r4 = f.ofFooT;
////var f_/*a2*/r7 = f.ofFooFooNum;
////var f_/*a3*/r9 = f.ofIG;
////var f_/*a5*/r13 = f.ofIG5;
////var f_/*a7*/r17 = f.ofC1;
////
////// T is number
////var f2_/*b1*/r4 = f2.ofFooT;
////var f2_/*b2*/r7 = f2.ofFooFooNum;
////var f2_/*b3*/r9 = f2.ofIG;
////var f2_/*b5*/r13 = f2.ofIG5;
////var f2_/*b7*/r17 = f2.ofC1;
////
////// T is I}
////var f3_/*c1*/r4 = f3.ofFooT;
////var f3_/*c2*/r7 = f3.ofFooFooNum;
////var f3_/*c3*/r9 = f3.ofIG;
////var f3_/*c5*/r13 = f3.ofIG5;
////var f3_/*c7*/r17 = f3.ofC1;
////
////// T is {x: number}
////var f4_/*d1*/r4 = f4.ofFooT;
////var f4_/*d2*/r7 = f4.ofFooFooNum;
////var f4_/*d3*/r9 = f4.ofIG;
////var f4_/*d5*/r13 = f4.ofIG5;
////var f4_/*d7*/r17 = f4.ofC1;
////
////// T is Foo<number>
////var f5_/*e1*/r4 = f5.ofFooT;
////var f5_/*e2*/r7 = f5.ofFooFooNum;
////var f5_/*e3*/r9 = f5.ofIG;
////var f5_/*e5*/r13 = f5.ofIG5;
////var f5_/*e7*/r17 = f5.ofC1;
verify.noErrors();
verify.quickInfos({
a1: "var f_r4: Foo<any>",
a2: "var f_r7: Foo<Foo<number>>",
a3: "var f_r9: IG<any>",
a5: "var f_r13: {\n x: Foo<any>;\n}",
a7: "var f_r17: C<any>",
b1: "var f2_r4: Foo<number>",
b2: "var f2_r7: Foo<Foo<number>>",
b3: "var f2_r9: IG<number>",
b5: "var f2_r13: {\n x: Foo<number>;\n}",
b7: "var f2_r17: C<number>",
c1: "var f3_r4: Foo<I>",
c2: "var f3_r7: Foo<Foo<number>>",
c3: "var f3_r9: IG<I>",
c5: "var f3_r13: {\n x: Foo<I>;\n}",
c7: "var f3_r17: C<I>",
d1: "var f4_r4: Foo<{\n x: number;\n}>",
d2: "var f4_r7: Foo<Foo<number>>",
d3: "var f4_r9: IG<{\n x: number;\n}>",
d5: "var f4_r13: {\n x: Foo<{\n x: number;\n }>;\n}",
d7: "var f4_r17: C<{\n x: number;\n}>",
e1: "var f5_r4: Foo<Foo<number>>",
e2: "var f5_r7: Foo<Foo<number>>",
e3: "var f5_r9: IG<Foo<number>>",
e5: "var f5_r13: {\n x: Foo<Foo<number>>;\n}",
e7: "var f5_r17: C<Foo<number>>",
});
| {
"end_byte": 2573,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericInterfacePropertyInference2.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteralImport3.ts_0_180 | /// <reference path="fourslash.ts" />
// @filename: /globals.d.ts
////declare module "*.css";
// @filename: /a.ts
////import * as foo from "/**/";
verify.baselineCompletions();
| {
"end_byte": 180,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralImport3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingMember25.ts_0_310 | /// <reference path='fourslash.ts' />
////[|type Foo = {
//// y: number;
////};|]
////function f(foo: Foo) {
//// foo.x = 1;
////}
verify.codeFix({
description: [ts.Diagnostics.Declare_property_0.message, "x"],
index: 0,
newRangeContent:
`type Foo = {
x: number;
y: number;
};`
});
| {
"end_byte": 310,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember25.ts"
} |
TypeScript/tests/cases/fourslash/augmentedTypesModule1.ts_0_279 | /// <reference path='fourslash.ts'/>
////module m1c {
//// export interface I { foo(): void; }
////}
////var m1c = 1; // Should be allowed
////var x: m1c./*1*/;
////var /*2*/r = m1c;
verify.completions({ marker: "1", exact: "I" });
verify.quickInfoAt("2", "var r: number");
| {
"end_byte": 279,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/augmentedTypesModule1.ts"
} |
TypeScript/tests/cases/fourslash/todoComments6.ts_0_100 | //// /*
//// * [|TODO 1|]
//// * [|TODO 2|]
//// */
verify.todoCommentsInCurrentFile(["TODO"]); | {
"end_byte": 100,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/todoComments6.ts"
} |
TypeScript/tests/cases/fourslash/completionListForTransitivelyExportedMembers01.ts_3_737 | /<reference path="fourslash.ts" />
// @Filename: A.ts
////export interface I1 { one: number }
////export interface I2 { two: string }
////export type I1_OR_I2 = I1 | I2;
////
////export class C1 {
//// one: string;
////}
////
////export module Inner {
//// export interface I3 {
//// three: boolean
//// }
////
//// export var varVar = 100;
//// export let letVar = 200;
//// export const constVar = 300;
////}
// @Filename: B.ts
////export var bVar = "bee!";
// @Filename: C.ts
////export var cVar = "see!";
////export * from "./A";
////export * from "./B"
// @Filename: D.ts
////import * as c from "./C";
////var x = c./**/
verify.completions({ marker: "", exact: ["bVar", "C1", "cVar", "Inner"] });
| {
"end_byte": 737,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListForTransitivelyExportedMembers01.ts"
} |
TypeScript/tests/cases/fourslash/codeFixRequireInTs1.ts_0_348 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////const a = [|require("a")|];
verify.getSuggestionDiagnostics([{
message: "'require' call may be converted to an import.",
code: 80005,
}]);
verify.codeFix({
description: ts.Diagnostics.Convert_require_to_import.message,
newFileContent: 'import a = require("a");',
});
| {
"end_byte": 348,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRequireInTs1.ts"
} |
TypeScript/tests/cases/fourslash/renamePrivateMethod.ts_0_258 | /// <reference path='fourslash.ts' />
////class Foo {
//// [|[|{| "contextRangeIndex": 0 |}#foo|]() { }|]
//// callFoo() {
//// return this.[|#foo|]();
//// }
////}
const ranges = test.rangesByText().get("#foo");
verify.baselineRename(ranges);
| {
"end_byte": 258,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renamePrivateMethod.ts"
} |
TypeScript/tests/cases/fourslash/findReferencesJSXTagName3.ts_0_956 | /// <reference path='fourslash.ts'/>
// @jsx: preserve
// @Filename: /a.tsx
////namespace JSX {
//// export interface Element { }
//// export interface IntrinsicElements {
//// [|[|/*1*/div|]: any;|]
//// }
////}
////
////[|const [|/*6*/Comp|] = () =>
//// [|<[|/*2*/div|]>
//// Some content
//// [|<[|/*3*/div|]>More content</[|/*4*/div|]>|]
//// </[|/*5*/div|]>|];|]
////
////const x = [|<[|/*7*/Comp|]>
//// Content
////</[|/*8*/Comp|]>|];
const [d0Def, d0, c0Def, c0, d1Def, d1, d2Def, d2, d3, d4, c1Def, c1, c2] = test.ranges();
const allD = [d0, d1, d2, d3, d4];
const allC = [c0, c1, c2];
verify.baselineFindAllReferences(
// div occurrences
'1', '2', '3', '4', '5',
// Comp occurrences
'6', '7', '8'
);
// For document highlights, we will just do tag matching if on a tag. Otherwise we find-all-references.
verify.baselineDocumentHighlights(allD);
verify.baselineDocumentHighlights(allC); | {
"end_byte": 956,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findReferencesJSXTagName3.ts"
} |
TypeScript/tests/cases/fourslash/formattingNestedScopes.ts_0_868 | /// <reference path='fourslash.ts'/>
/////*1*/ module My.App {
/////*2*/export var appModule = angular.module("app", [
/////*3*/ ]).config([() => {
/////*4*/ configureStates
/////*5*/($stateProvider);
/////*6*/}]).run(My.App.setup);
/////*7*/ }
format.document()
goTo.marker("1");
verify.currentLineContentIs("module My.App {");
goTo.marker("2");
verify.currentLineContentIs(" export var appModule = angular.module(\"app\", [");
goTo.marker("3");
verify.currentLineContentIs(" ]).config([() => {");
goTo.marker("4");
verify.currentLineContentIs(" configureStates");
goTo.marker("5");
verify.currentLineContentIs(" ($stateProvider);");
goTo.marker("6");
verify.currentLineContentIs(" }]).run(My.App.setup);");
goTo.marker("7");
verify.currentLineContentIs("}"); | {
"end_byte": 868,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingNestedScopes.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction12.ts_0_358 | /// <reference path='fourslash.ts' />
//// const foo = /*a*/a/*b*/ => { return "foo"; };
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 => "foo";`,
});
| {
"end_byte": 358,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction12.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarFunctionPrototype3.ts_0_1008 | /// <reference path="fourslash.ts"/>
// @Filename: foo.js
////var A;
////A.prototype.a = function() { };
////A.b = function() { };
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "A",
"kind": "class",
"childItems": [
{
"text": "constructor",
"kind": "constructor"
},
{
"text": "a",
"kind": "function"
},
{
"text": "b",
"kind": "function"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "A",
"kind": "class"
}
]
},
{
"text": "A",
"kind": "class",
"childItems": [
{
"text": "constructor",
"kind": "constructor"
},
{
"text": "a",
"kind": "function"
},
{
"text": "b",
"kind": "function"
}
],
"indent": 1
}
]);
| {
"end_byte": 1008,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarFunctionPrototype3.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionReturn7.ts_0_264 | /// <reference path="fourslash.ts" />
////function foo(a: string, b: string): string;
////function foo(a: number, b: number): number;
////function /*end*/foo(a: any, b: any): any {
//// [|/*start*/return|] a + b;
////}
verify.baselineGoToDefinition("start");
| {
"end_byte": 264,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionReturn7.ts"
} |
TypeScript/tests/cases/fourslash/textChangesPreserveNewlines1.ts_0_433 | /// <reference path="fourslash.ts" />
//// /*1*/console.log(1);
////
//// console.log(2);
////
//// console.log(3);/*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() {
console.log(1);
console.log(2);
console.log(3);
}
`
});
| {
"end_byte": 433,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/textChangesPreserveNewlines1.ts"
} |
TypeScript/tests/cases/fourslash/completionListInIndexSignature02.ts_0_457 | /// <reference path='fourslash.ts' />
////interface I<T> {
//// [x: /*1*/]: T;
//// [: /*2*/]: T
////}
////
////class C {
//// [a: /*3*/]: string;
//// [str: string/*4*/]: number;
////}
////
////type T = {
//// [xyz: /*5*/
const exact = completion.globalTypesPlus(["I", "C"]);
verify.completions(
{ marker: ["1", "2"], unsorted: ["T", ...exact] },
{ marker: ["3", "4", "5"], exact: completion.globalTypesPlus(["C", "I", "T"]) },
);
| {
"end_byte": 457,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInIndexSignature02.ts"
} |
TypeScript/tests/cases/fourslash/semicolonFormattingNewline.ts_0_207 | /// <reference path='fourslash.ts' />
////declare var f: {
//// (): any;
//// (x: number): string;
//// foo: number;/**/
////};
goTo.marker();
edit.insert('\n');
verify.indentationIs(4);
| {
"end_byte": 207,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semicolonFormattingNewline.ts"
} |
TypeScript/tests/cases/fourslash/tripleSlashRefPathCompletionRootdirs.ts_0_790 | /// <reference path='fourslash.ts' />
// Should NOT give completions for directories that are merged via the rootDirs compiler option
// @rootDirs: sub/src1,src2
// @Filename: src2/test0.ts
//// /// <reference path="./mo/*0*/
// @Filename: src2/module0.ts
//// export var w = 0;
// @Filename: sub/src1/module1.ts
//// export var x = 0;
// @Filename: sub/src1/module2.ts
//// export var y = 0;
// @Filename: sub/src1/more/module3.ts
//// export var z = 0;
// @Filename: f1.ts
//// /*f1*/
// @Filename: f2.tsx
//// /*f2*/
// @Filename: folder/f1.ts
//// /*subf1*/
// @Filename: f3.js
//// /*f3*/
// @Filename: f4.jsx
//// /*f4*/
// @Filename: e1.ts
//// /*e1*/
// @Filename: e2.js
//// /*e2*/
verify.completions({ marker: "0", exact: "module0.ts", isNewIdentifierLocation: true });
| {
"end_byte": 790,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tripleSlashRefPathCompletionRootdirs.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInvalidJsxCharacters2.ts_0_462 | /// <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": 462,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInvalidJsxCharacters2.ts"
} |
TypeScript/tests/cases/fourslash/runtimeBehaviorTests.ts_0_4808 | /// <reference path='fourslash.ts'/>
////interface RT_JQueryElement {
//// id: string;
////}
////
////interface RT_JQuery {
//// [n: number]: RT_JQueryElement;
////}
////
////module RT_StaticModule {
//// export class C {
//// x: number;
//// g: any;
//// constructor(public c1: number, public c2: number, c3: number) {
//// this.x = C.y + this.c1 + this.c2 + c3;
//// this.g = (v: number) => C.f(this.x + C.y + v + this.c1 + this.c2 + C.pub);
//// }
////
//// static priv = 2;
//// static pub = 3;
//// static y = C.priv;
//// static f(n: number) {
//// return "wow: " + (n + C.y + C.pub + C.priv);
////
//// }
//// }
//// var c = C.y;
//// export function f() {
//// var result = "";
//// result += (c);
//// result += (new C(0, 1, 2).x);
//// result += (C.f(10));
//// result += (new C(5, 10, 20).g(C.y));
//// return result;
//// }
////}
////
////module RT_SuperCalls {
//// class Base {
//// constructor() {
//// var x: any;
//// }
//// public foo() {
//// return "base";
//// }
////
//// public bar() {
//// return "basebar";
//// }
//// }
////
//// class Sub1 extends Base {
//// public foo() {
//// return "sub1" + super.foo() + super.bar();
//// }
//// }
////
//// class SubSub1 extends Sub1 {
//// public foo() {
//// return "subsub1" + super.foo();
//// }
//// }
////
//// var s = new Sub1();
//// var ss = new SubSub1();
//// export var result = s.foo() + ss.foo();
////}
////
////module RT_SuperCalls2 {
//// // Case 5
//// class Base5 {
//// public x() {
//// return "BaseX";
//// }
////
//// public y() {
//// return "BaseY";
//// }
//// }
////
//// class Sub5 extends Base5 {
//// public x() {
//// return "SubX";
//// }
//// }
////
//// class SubSub5 extends Sub5 {
//// public x() {
//// return super.x();
//// }
//// public y() {
//// return super.y();
//// }
//// }
////
//// // Case 6
//// class Base6 {
//// public x() {
//// return "BaseX";
//// }
//// }
////
//// class Sub6 extends Base6 {
//// public y() {
//// return "SubY";
//// }
//// }
////
//// class SubSub6 extends Sub6 {
//// public y() {
//// return super.y();
//// }
//// }
////
//// var results1 = new SubSub5();
//// var results2 = new SubSub6();
//// export var result = results1.x() + results1.y() + results2.y();
////}
////
////module RT_VarArgs {
//// module M {
//// export class C {
//// public f(x: string, ...rest: number[]) {
//// var sum = 0;
//// for (var i = 0; i < rest.length; i++) {
//// sum += rest[i];
//// }
//// result += (x + ": " + sum);
//// return result;
//// }
////
//// public fnope(x: string, ...rest: number[]) {
////
//// }
////
//// public fonly(...rest: string[]) {
//// var builder = "";
//// for (var i = 0; i < rest.length; i++) {
//// builder += rest[i];
//// }
//// return builder;
//// }
//// }
//// }
////
//// var x = new M.C();
//// export var result = "";
//// result += x.f("hello", 3, 3, 3, 3, 3); // ok
//// result += x.f("hello"); // ok varargs length 0
//// result += x.fonly("a"); // ok
//// result += x.fonly("a", "b", "c", "d"); //ok
////}
////
////
////var jq: RT_JQuery = { 0: { id: "a" }, 1: { id: "b" } };
////var r1 = jq[0].id
////
////var r2 = RT_StaticModule.f();
////
////var a = {
//// "foo": function () { },
//// "bar": 5
////};
////var r3 = a.bar.toString();
////
////var r4 = RT_SuperCalls.result;
////var r5 = RT_SuperCalls2.result;
////var r6 = false;
////var r7 = RT_VarArgs.result;
// Indexes propertly
verify.eval('r1', 'a');
// Calls static methods properly
verify.eval('r2', '25wow: 17wow: 66');
// Generates string indicies propertly
verify.eval('r3', '5');
// Calls super methods correctly (#1)
verify.eval('r4', 'sub1basebasebarsubsub1sub1basebasebar');
// Calls super methods correctly (#2)
verify.eval('r5', 'SubXBaseYSubY');
// Calls methods on primitives correctly
verify.eval('true.toString()', 'true');
verify.eval('r6.toString()', 'false');
verify.eval('1..toString()', '1');
// Copies vararg arrays correctly
verify.eval('r7', 'hello: 15hello: 15hello: 0aabcd');
| {
"end_byte": 4808,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/runtimeBehaviorTests.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingEnumMember5.ts_0_230 | /// <reference path='fourslash.ts' />
////enum E {
//// a = "a" + "-",
////}
////E.b
verify.codeFix({
description: "Add missing enum member 'b'",
newFileContent: `enum E {
a = "a" + "-",
b = "b",
}
E.b`
});
| {
"end_byte": 230,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingEnumMember5.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsQuotePreference1.ts_0_290 | /// <reference path="fourslash.ts" />
////const a1: '"' = '"';
////const b1: '\\' = '\\';
////export function fn(a = a1, b = b1) {}
verify.baselineInlayHints(undefined, {
includeInlayFunctionParameterTypeHints: true,
interactiveInlayHints: true,
quotePreference: "double"
});
| {
"end_byte": 290,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsQuotePreference1.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_Single_While.ts_0_388 | /// <reference path='fourslash.ts' />
//// const foo = /*x*/f/*y*/unction() {
//// while (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 = () => {
while (true) { }
};`,
});
| {
"end_byte": 388,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_Single_While.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_typeParameter3.ts_0_380 | /// <reference path="fourslash.ts" />
// @noUnusedLocals: true
// @noUnusedParameters: true
////function f<
//// T1, T2, /** comment related to T3 */
//// T3,
////>(a: T1, b: T3) {}
verify.codeFix({
index: 0,
description: "Remove unused declaration for: 'T2'",
newFileContent:
`function f<
T1, /** comment related to T3 */
T3,
>(a: T1, b: T3) {}`
});
| {
"end_byte": 380,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_typeParameter3.ts"
} |
TypeScript/tests/cases/fourslash/importStatementCompletions_js2.ts_0_1012 | /// <reference path="fourslash.ts" />
// These options resemble the defaults for inferred projects with JS,
// except notably lacking --allowSyntheticDefaultImports. Probably nobody
// ever wants a configuration like this, but we maintain that this is
// correct and consistent behavior for these settings.
// @allowJs: true
// @target: es2020
// @checkJs: true
// @module: commonjs
// @noEmit: true
// @Filename: /node_modules/react/index.d.ts
//// declare namespace React {
//// export class Component {}
//// }
//// export = React;
// @Filename: /test.js
//// [|import R/**/|]
verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: [{
name: "React",
source: "react",
insertText: `import * as React from "react";`,
isSnippet: true,
replacementSpan: test.ranges()[0],
sourceDisplay: "react",
}],
preferences: {
includeCompletionsForImportStatements: true,
includeInsertTextCompletions: true,
includeCompletionsWithSnippetText: true,
}
});
| {
"end_byte": 1012,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importStatementCompletions_js2.ts"
} |
TypeScript/tests/cases/fourslash/completionsSalsaMethodsOnAssignedFunctionExpressions.ts_0_319 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: something.js
////var C = function () { }
/////**
//// * The prototype method.
//// * @param {string} a Parameter definition.
//// */
////function f(a) {}
////C.prototype.m = f;
////
////var x = new C();
////x./*2*/m();
verify.baselineCompletions()
| {
"end_byte": 319,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsSalsaMethodsOnAssignedFunctionExpressions.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts_0_656 | /// <reference path='fourslash.ts' />
//// function f(templateStrings: string[], p1_o1: string): number;
//// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string;
//// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean;
//// function f(...foo[]: any) { return ""; }
////
//// f `${/*1*/ 123.456/*2*/ /*3*/ } ${
verify.signatureHelp({
marker: test.markers(),
overloadsCount: 3,
text: "f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string",
parameterCount: 4,
parameterName: "p1_o2",
parameterSpan: "p1_o2: number",
});
| {
"end_byte": 656,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedNamespaceInNamespace.ts_0_236 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////namespace A {
//// namespace B {
//// }
////}
verify.codeFix({
description: "Remove unused declaration for: 'B'",
newFileContent: `namespace A {
}`,
});
| {
"end_byte": 236,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedNamespaceInNamespace.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.