_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/findAllReferencesFromLinkTagReference3.ts_0_225 | /// <reference path="fourslash.ts" />
// @filename: a.ts
////interface Foo {
//// foo: E.Foo;
////}
// @Filename: b.ts
////enum E {
//// /** {@link /**/Foo} */
//// Foo
////}
verify.baselineFindAllReferences("");
| {
"end_byte": 225,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesFromLinkTagReference3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCannotFindModule_suggestion_js.ts_0_814 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @Filename: /node_modules/abs/index.js
////export default function abs() {}
// @Filename: /a.js
////import abs from [|"abs"|];
////abs;
test.setTypesRegistry({ "abs": undefined });
verify.noErrors();
goTo.file("/a.js");
verify.getSuggestionDiagnostics([{
message: "Could not find a declaration file for module 'abs'. '/node_modules/abs/index.js' implicitly has an 'any' type.",
code: 7016,
}]);
verify.codeFixAvailable([
{
description: "Install '@types/abs'",
commands: [{
type: "install package",
file: "/a.js",
packageName: "@types/abs",
}],
},
{ description: "Ignore this error message" },
{ description: "Disable checking for this file" },
]);
| {
"end_byte": 814,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCannotFindModule_suggestion_js.ts"
} |
TypeScript/tests/cases/fourslash/formatOnEnterInComment.ts_0_168 | /// <reference path="fourslash.ts"/>
//// /**
//// * /*1*/
//// */
goTo.marker("1");
edit.insertLine("");
verify.currentFileContentIs(
` /**
*
*/`
); | {
"end_byte": 168,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatOnEnterInComment.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarItemsExports.ts_0_1035 | /// <reference path="fourslash.ts"/>
////export { a } from "a";
////
////export { b as B } from "a"
////
////export import e = require("a");
////
////export * from "a"; // no bindings here
verify.navigationTree({
"text": "\"navigationBarItemsExports\"",
"kind": "module",
"childItems": [
{
"text": "a",
"kind": "alias"
},
{
"text": "B",
"kind": "alias"
},
{
"text": "e",
"kind": "alias",
"kindModifiers": "export"
}
]
});
verify.navigationBar([
{
"text": "\"navigationBarItemsExports\"",
"kind": "module",
"childItems": [
{
"text": "a",
"kind": "alias"
},
{
"text": "B",
"kind": "alias"
},
{
"text": "e",
"kind": "alias",
"kindModifiers": "export"
}
]
}
]);
| {
"end_byte": 1035,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsExports.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsCommonJsRequire3.ts_0_233 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: /a.js
//// function f() { }
//// module.exports = { f }
// @Filename: /b.js
//// const { f } = require('./a')
//// /**/f
verify.baselineFindAllReferences("");
| {
"end_byte": 233,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsCommonJsRequire3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete.ts_0_2595 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
////import d from "foo";
////import d2, { used1 } from "foo";
////import { x } from "foo";
////import { x2, used2 } from "foo";
////used1; used2;
////
////function f(a, b) {
//// const x = 0;
////}
////function g(a) { return a; }
////function h(c) { return c; }
////f(); g(); h();
////
////interface I {
//// m(x: number): void;
////}
////
////class C implements I {
//// m(x: number): void {} // Does not remove 'x', which is inherited
//// n(x: number): void {}
//// private ["o"](): void {}
////}
////C;
////
////declare function takesCb(cb: (x: number, y: string) => void): void;
////takesCb((x, y) => {});
////takesCb((x, y) => { x; });
////takesCb((x, y) => { y; });
////
////function fn1(x: number, y: string): void {}
////takesCb(fn1);
////
////function fn2(x: number, y: string): void { x; }
////takesCb(fn2);
////
////function fn3(x: number, y: string): void { y; }
////takesCb(fn3);
////
////x => {
//// const y = 0;
////};
////
////{
//// let a, b;
////}
////for (let i = 0, j = 0; ;) {}
////for (const x of []) {}
////for (const y in {}) {}
////
////export type First<T, U> = T;
////export interface ISecond<T, U> { u: U; }
////export const cls = class<T, U> { u: U; };
////export class Ctu<T, U> {}
////export type Length<T> = T extends ArrayLike<infer U> ? number : never; // Not affected, can't delete
verify.codeFixAll({
fixId: "unusedIdentifier_delete",
fixAllDescription: ts.Diagnostics.Delete_all_unused_declarations.message,
newFileContent:
`import d from "foo";
import d2, { used1 } from "foo";
import { x } from "foo";
import { x2, used2 } from "foo";
used1; used2;
function f() {
}
function g(a) { return a; }
function h(c) { return c; }
f(); g(); h();
interface I {
m(x: number): void;
}
class C implements I {
m(x: number): void {} // Does not remove 'x', which is inherited
n(): void {}
}
C;
declare function takesCb(cb: (x: number, y: string) => void): void;
takesCb(() => {});
takesCb((x) => { x; });
takesCb((x, y) => { y; });
function fn1(x: number, y: string): void {}
takesCb(fn1);
function fn2(x: number, y: string): void { x; }
takesCb(fn2);
function fn3(x: number, y: string): void { y; }
takesCb(fn3);
() => {
};
{
}
for (; ;) {}
for (const {} of []) {}
for (const {} in {}) {}
export type First<T> = T;
export interface ISecond<U> { u: U; }
export const cls = class<U> { u: U; };
export class Ctu {}
export type Length<T> = T extends ArrayLike<infer U> ? number : never; // Not affected, can't delete`,
});
| {
"end_byte": 2595,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete.ts"
} |
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class8.ts_0_360 | /// <reference path='fourslash.ts' />
// @allowNonTsExtensions: true
// @Filename: foo.js
////function Foo() {
//// this.a = 0;
////}
////Foo.prototype[`b`] = function () {
////}
verify.codeFix({
description: "Convert function to an ES2015 class",
newFileContent:
`class Foo {
constructor() {
this.a = 0;
}
b() {
}
}
`
});
| {
"end_byte": 360,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class8.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction24.ts_0_392 | /// <reference path='fourslash.ts' />
//// const a = (a: number) /*a*/=>/*b*/ {/* comment */ return a;};
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) => /* comment */ a;`,
});
| {
"end_byte": 392,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction24.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_noSemicolons.ts_0_366 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export function foo() {}
// @Filename: /b.ts
////const x = 0
////const y = 1
////const z = fo/**/
verify.applyCodeActionFromCompletion("", {
name: "foo",
source: "/a",
description: `Add import from "./a"`,
newFileContent: `import { foo } from "./a"
const x = 0
const y = 1
const z = fo`,
});
| {
"end_byte": 366,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_noSemicolons.ts"
} |
TypeScript/tests/cases/fourslash/completionsLiteralMatchingGenericSignature.ts_0_228 | /// <reference path="fourslash.ts" />
// @Filename: /a.tsx
//// declare function bar1<P extends "" | "bar" | "baz">(p: P): void;
////
//// bar1("/*ts*/")
////
verify.completions({ marker: ["ts"], exact: ["", "bar", "baz"] });
| {
"end_byte": 228,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsLiteralMatchingGenericSignature.ts"
} |
TypeScript/tests/cases/fourslash/codeFixRenameUnmatchedParameterJS2.ts_0_769 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @filename: /a.js
/////**
//// * @param {number} d
//// * @param {number} a
//// * @param {number} b
//// */
////function foo(a, b, c) {
//// a;
//// b;
//// c;
////}
verify.codeFixAvailable([
{ description: "Delete unused '@param' tag 'd'" },
{ description: "Rename '@param' tag name 'd' to 'c'" },
{ 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, "d", "c"],
index: 1,
newFileContent:
`/**
* @param {number} c
* @param {number} a
* @param {number} b
*/
function foo(a, b, c) {
a;
b;
c;
}`
});
| {
"end_byte": 769,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRenameUnmatchedParameterJS2.ts"
} |
TypeScript/tests/cases/fourslash/autoImportPnpm.ts_0_745 | /// <reference path="fourslash.ts" />
// @Filename: /tsconfig.json
//// { "compilerOptions": { "module": "commonjs" } }
// @Filename: /node_modules/.pnpm/mobx@6.0.4/node_modules/mobx/package.json
//// { "types": "dist/mobx.d.ts" }
// @Filename: /node_modules/.pnpm/mobx@6.0.4/node_modules/mobx/dist/mobx.d.ts
//// export declare function autorun(): void;
// @Filename: /index.ts
//// autorun/**/
// @Filename: /utils.ts
//// import "mobx";
// @link: /node_modules/.pnpm/mobx@6.0.4/node_modules/mobx -> /node_modules/mobx
// @link: /node_modules/.pnpm/mobx@6.0.4/node_modules/mobx -> /node_modules/.pnpm/cool-mobx-dependent@1.2.3/node_modules/mobx
goTo.marker("");
verify.importFixAtPosition([`import { autorun } from "mobx";
autorun`]);
| {
"end_byte": 745,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPnpm.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefs_importType_exportEquals.ts_0_1132 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////[|type /*0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|] = number;|]
////[|namespace /*1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}T|] {
//// export type U = string;
////}|]
////[|/*export*/[|{| "contextRangeIndex": 4 |}export|] = /*2*/[|{| "contextRangeIndex": 4 |}T|];|]
// @Filename: /b.ts
////[|const x: import("/*3*/[|{| "contextRangeIndex": 7 |}./[|a|]|]") = 0;|]
////[|const y: import("/*4*/[|{| "contextRangeIndex": 10 |}./[|a|]|]").U = "";|]
verify.noErrors();
const [r0Def, r0, r1Def, r1, r2Def, rExport, r2, r3Def, r3, r3b, r4Def, r4, r4b] = test.ranges();
verify.baselineFindAllReferences('0', '1', '2', '3', '4', 'export');
verify.baselineRename([r0, r1, r2]);
for (const range of [r3b, r4b]) {
goTo.rangeStart(range);
verify.renameInfoSucceeded(/*displayName*/ "/a.ts", /*fullDisplayName*/ "./a", /*kind*/ "module", /*kindModifiers*/ "", /*fileToRename*/ "/a.ts", range);
verify.renameInfoFailed("You cannot rename this element.", { allowRenameOfImportPath: false });
}
| {
"end_byte": 1132,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefs_importType_exportEquals.ts"
} |
TypeScript/tests/cases/fourslash/importFixes_quotePreferenceDouble_importHelpers.ts_0_301 | /// <reference path='fourslash.ts'/>
// @importHelpers: true
// @filename: /a.ts
////export default () => {};
// @filename: /b.ts
////export default () => {};
// @filename: /test.ts
////import a from "./a";
////[|b|];
goTo.file("/test.ts");
verify.importFixAtPosition([`import b from "./b";
b`]);
| {
"end_byte": 301,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importFixes_quotePreferenceDouble_importHelpers.ts"
} |
TypeScript/tests/cases/fourslash/genericObjectBaseType.ts_0_268 | /// <reference path='fourslash.ts' />
//// class C<T> {
//// constructor(){}
//// foo(a: T) {
//// return a.toString();
//// }
//// }
//// var x = new C<string>();
//// var y: string = x.foo("hi");
//// /*1*/
goTo.marker('1');
verify.noErrors();
| {
"end_byte": 268,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericObjectBaseType.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarItemsFunctionsBroken.ts_0_856 | /// <reference path="fourslash.ts"/>
////function f() {
//// function;
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "f",
"kind": "function",
"childItems": [
{
"text": "<function>",
"kind": "function"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "f",
"kind": "function"
}
]
},
{
"text": "f",
"kind": "function",
"childItems": [
{
"text": "<function>",
"kind": "function"
}
],
"indent": 1
}
]);
| {
"end_byte": 856,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsFunctionsBroken.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixDefaultExport4.ts_0_231 | /// <reference path="fourslash.ts" />
// @Filename: /foo.ts
////const a = () => {};
////export default a;
// @Filename: /test.ts
////[|foo|];
goTo.file("/test.ts");
verify.importFixAtPosition([`import foo from "./foo";
foo`]);
| {
"end_byte": 231,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixDefaultExport4.ts"
} |
TypeScript/tests/cases/fourslash/todoComments13.ts_0_55 | //// TODO
verify.todoCommentsInCurrentFile(["TODO"]); | {
"end_byte": 55,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/todoComments13.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_import_multipleUniqueIdentifiers.ts_0_418 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @target: esnext
// @Filename: /a.js
////const x = require("x");
////const [a, b] = require("x");
////const {c, ...d} = require("x");
////x; a; b; c; d;
verify.codeFix({
description: "Convert to ES module",
newFileContent:
`import x from "x";
import _x from "x";
const [a, b] = _x;
import __x from "x";
const { c, ...d } = __x;
x; a; b; c; d;`,
});
| {
"end_byte": 418,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_import_multipleUniqueIdentifiers.ts"
} |
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType1.ts_0_394 | /// <reference path='fourslash.ts' />
////function /*a*/foo/*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:
`function foo(): { x: number; y: number; } {
return { x: 1, y: 1 };
}`
});
| {
"end_byte": 394,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType1.ts"
} |
TypeScript/tests/cases/fourslash/quickinfoForNamespaceMergeWithClassConstrainedToSelf.ts_0_590 | /// <reference path="fourslash.ts" />
//// declare namespace AMap {
//// namespace MassMarks {
//// interface Data {
//// style?: number;
//// }
//// }
//// class MassMarks<D extends MassMarks.Data = MassMarks.Data> {
//// constructor(data: D[] | string);
//// clear(): void;
//// }
//// }
////
//// interface MassMarksCustomData extends AMap.MassMarks./*1*/Data {
//// name: string;
//// id: string;
//// }
verify.quickInfoAt("1", "interface AMap.MassMarks<D extends AMap.MassMarks.Data = AMap.MassMarks.Data>.Data");
| {
"end_byte": 590,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickinfoForNamespaceMergeWithClassConstrainedToSelf.ts"
} |
TypeScript/tests/cases/fourslash/getEditsForFileRename_unresolvableImport.ts_0_689 | /// <reference path="fourslash.ts" />
// @Filename: /tsconfig.json
//// {
//// "compilerOptions": {
//// "allowJs": true,
//// "paths": {
//// "*": ["./next/src/*"],
//// "@app": ["./modules/@app/*"],
//// "@app/*": ["./modules/@app/*"],
//// "@local": ["./modules/@local/*"],
//// "@local/*": ["./modules/@local/*"]
//// }
//// }
//// }
// @Filename: /modules/@app/something/index.js
//// import "@local/some-other-import";
// @Filename: /modules/@local/index.js
//// import "@local/some-other-import";
verify.getEditsForFileRename({
oldPath: "/modules/@app/something",
newPath: "/modules/@app/something-2",
newFileContents: {}
});
| {
"end_byte": 689,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_unresolvableImport.ts"
} |
TypeScript/tests/cases/fourslash/unusedFunctionInNamespace2.ts_0_282 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| namespace greeter {
//// export function function2() {
//// }
//// function function1() {
//// }
////} |]
verify.rangeAfterCodeFix(`namespace greeter {
export function function2() {
}
}`);
| {
"end_byte": 282,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedFunctionInNamespace2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_singleLineStatements2.ts_0_277 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
////export function f1() {} function f2() {}
verify.codeFix({
description: "Remove unused declaration for: 'f2'",
index: 0,
newFileContent: "export function f1() {} "
});
| {
"end_byte": 277,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_singleLineStatements2.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsReExportStarAs.ts_0_454 | /// <reference path="fourslash.ts" />
// @Filename: /leafModule.ts
////export const /*helloDef*/hello = () => 'Hello';
// @Filename: /exporting.ts
////export * as /*leafDef*/Leaf from './leafModule';
// @Filename: /importing.ts
//// import { /*leafImportDef*/Leaf } from './exporting';
//// /*leafUse*/[|Leaf|]./*helloUse*/[|hello|]()
verify.noErrors();
verify.baselineFindAllReferences('helloDef', 'helloUse', 'leafDef', 'leafImportDef', 'leafUse')
| {
"end_byte": 454,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsReExportStarAs.ts"
} |
TypeScript/tests/cases/fourslash/codeFixConvertTypedefToType4.ts_0_642 | /// <reference path='fourslash.ts' />
////
//// /**
//// * @typedef {object} Person
//// * @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: `
interface Person {
data: {
name: string;
age: number;
contact: {
address: string;
phone?: string;
};
};
}
`,
});
| {
"end_byte": 642,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertTypedefToType4.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType37.ts_0_372 | /// <reference path='fourslash.ts' />
//// type A = (v: string | number) => v is /*a*/string/*b*/;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent: `type /*RENAME*/NewType = string;
type A = (v: string | number) => v is NewType;`,
});
| {
"end_byte": 372,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType37.ts"
} |
TypeScript/tests/cases/fourslash/formatTSXWithInlineComment.ts_0_195 | /// <reference path="fourslash.ts"/>
// @Filename: foo.tsx
////const a = <div>
//// // <a />
////</div>
format.document();
verify.currentFileContentIs(`const a = <div>
// <a />
</div>`);
| {
"end_byte": 195,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatTSXWithInlineComment.ts"
} |
TypeScript/tests/cases/fourslash/getCompletionEntryDetails2.ts_0_491 | /// <reference path="fourslash.ts" />
////class Foo {
////}
////module Foo {
//// export var x: number;
////}
////Foo./**/
const exact: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> = completion.functionMembersPlus([
"prototype",
{ name: "x", text: "var Foo.x: number" },
]);
verify.completions({ marker: "", exact });
// Make an edit
edit.insert("a");
edit.backspace();
// Checking for completion details after edit should work too
verify.completions({ exact });
| {
"end_byte": 491,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getCompletionEntryDetails2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue21.ts_0_327 | /// <reference path='fourslash.ts' />
//// interface A {
//// a: () => number
//// }
////
//// let b: A = {
//// a: () => { 1 }
//// }
verify.codeFixAvailable([
{ description: ts.Diagnostics.Add_a_return_statement.message },
{ description: ts.Diagnostics.Remove_braces_from_arrow_function_body.message }
]);
| {
"end_byte": 327,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue21.ts"
} |
TypeScript/tests/cases/fourslash/referencesForClassMembersExtendingGenericClass.ts_0_386 | /// <reference path='fourslash.ts'/>
////class Base<T> {
//// /*a1*/a: this;
//// /*method1*/method<U>(a?:T, b?:U): this { }
////}
////class MyClass extends Base<number> {
//// /*a2*/a;
//// /*method2*/method() { }
////}
////
////var c: MyClass;
////c./*a3*/a;
////c./*method3*/method();
verify.baselineFindAllReferences('a1', 'a2', 'a3', 'method1', 'method2', 'method3')
| {
"end_byte": 386,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForClassMembersExtendingGenericClass.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_previousTokenIsSemicolon.ts_0_529 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export function foo() {}
// @Filename: /b.ts
////import * as a from 'a';
/////**/
verify.completions({
marker: "",
includes: {
name: "foo",
source: "/a",
sourceDisplay: "./a",
text: "function foo(): void",
kind: "function",
kindModifiers: "export",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences: { includeCompletionsForModuleExports: true },
});
| {
"end_byte": 529,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_previousTokenIsSemicolon.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoClassKeyword.ts_0_211 | /// <reference path='fourslash.ts'/>
////[1].forEach(cla/*1*/ss {});
////[1].forEach(cla/*2*/ss OK{});
verify.quickInfoAt("1", "(local class) (Anonymous class)");
verify.quickInfoAt("2", "(local class) OK");
| {
"end_byte": 211,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoClassKeyword.ts"
} |
TypeScript/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_catch.ts_0_199 | /// <reference path='fourslash.ts' />
////var aa = 1;
//// try {} catch(/*catchVariable1*/
//// try {} catch(a/*catchVariable2*/
verify.completions({ marker: test.markers(), exact: undefined });
| {
"end_byte": 199,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_catch.ts"
} |
TypeScript/tests/cases/fourslash/contextuallyTypedObjectLiteralMethodDeclarationParam01.ts_0_597 | /// <reference path="fourslash.ts" />
// @noImplicitAny: true
////interface A {
//// numProp: number;
////}
////
////interface B {
//// strProp: string;
////}
////
////interface Foo {
//// method1(arg: A): void;
//// method2(arg: B): void;
////}
////
////function getFoo1(): Foo {
//// return {
//// method1(/*param1*/arg) {
//// arg.numProp = 10;
//// },
//// method2(/*param2*/arg) {
//// arg.strProp = "hello";
//// }
//// }
////}
verify.quickInfos({
param1: "(parameter) arg: A",
param2: "(parameter) arg: B"
});
| {
"end_byte": 597,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/contextuallyTypedObjectLiteralMethodDeclarationParam01.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_JSDocTags12.ts_0_283 | /// <reference path="fourslash.ts" />
////type B = {};
////type A = {
//// a(/** Comment */ /*1*/p0: number, /** Comment */ /*2*/p1: number, /** Comment */ /*3*/p2: number): string;
////};
// https://github.com/microsoft/TypeScript/issues/49807
verify.baselineSmartSelection();
| {
"end_byte": 283,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_JSDocTags12.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess14.ts_0_476 | /// <reference path='fourslash.ts' />
//// class A {
//// /*a*/public readonly a: string = "foo";/*b*/
//// }
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Generate 'get' and 'set' accessors",
actionName: "Generate 'get' and 'set' accessors",
actionDescription: "Generate 'get' and 'set' accessors",
newContent: `class A {
private readonly /*RENAME*/_a: string = "foo";
public get a(): string {
return this._a;
}
}`,
});
| {
"end_byte": 476,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess14.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType66.ts_0_388 | /// <reference path='fourslash.ts' />
//// function foo<U>(a: /*a*/{ a: string } & { b: U }/*b*/) { }
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to interface",
actionDescription: "Extract to interface",
newContent: `interface /*RENAME*/NewType<U> {
a: string;
b: U;
}
function foo<U>(a: NewType<U>) { }`,
});
| {
"end_byte": 388,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType66.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction10.ts_0_366 | /// <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": 366,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction10.ts"
} |
TypeScript/tests/cases/fourslash/basicClassMembers.ts_0_261 | /// <reference path='fourslash.ts' />
////class n {
//// constructor (public x: number, public y: number, private z: string) { }
////}
////var t = new n(0, 1, '');
goTo.eof();
edit.insert('t.');
verify.completions({ includes: ["x", "y"], excludes: "z" });
| {
"end_byte": 261,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/basicClassMembers.ts"
} |
TypeScript/tests/cases/fourslash/completionsWithStringReplacementMode1.ts_0_2457 | /// <reference path="fourslash.ts" />
//// interface TFunction {
//// (_: 'login.title', __?: {}): string;
//// (_: 'login.description', __?: {}): string;
//// (_: 'login.sendEmailAgree', __?: {}): string;
//// (_: 'login.termsOfUse', __?: {}): string;
//// (_: 'login.privacyPolicy', __?: {}): string;
//// (_: 'login.sendEmailButton', __?: {}): string;
//// (_: 'login.emailInputPlaceholder', __?: {}): string;
//// (_: 'login.errorWrongEmailTitle', __?: {}): string;
//// (_: 'login.errorWrongEmailDescription', __?: {}): string;
//// (_: 'login.errorGeneralEmailTitle', __?: {}): string;
//// (_: 'login.errorGeneralEmailDescription', __?: {}): string;
//// (_: 'login.loginErrorTitle', __?: {}): string;
//// (_: 'login.loginErrorDescription', __?: {}): string;
//// (_: 'login.openEmailAppErrorTitle', __?: {}): string;
//// (_: 'login.openEmailAppErrorDescription', __?: {}): string;
//// (_: 'login.openEmailAppErrorConfirm', __?: {}): string;
//// }
//// const f: TFunction = (() => {}) as any;
//// f('[|login./**/|]')
verify.completions({
marker: "",
exact: [
{ name: "login.title", replacementSpan: test.ranges()[0] },
{ name: "login.description", replacementSpan: test.ranges()[0] },
{ name: "login.sendEmailAgree", replacementSpan: test.ranges()[0] },
{ name: "login.termsOfUse", replacementSpan: test.ranges()[0] },
{ name: "login.privacyPolicy", replacementSpan: test.ranges()[0] },
{ name: "login.sendEmailButton", replacementSpan: test.ranges()[0] },
{ name: "login.emailInputPlaceholder", replacementSpan: test.ranges()[0] },
{ name: "login.errorWrongEmailTitle", replacementSpan: test.ranges()[0] },
{ name: "login.errorWrongEmailDescription", replacementSpan: test.ranges()[0] },
{ name: "login.errorGeneralEmailTitle", replacementSpan: test.ranges()[0] },
{ name: "login.errorGeneralEmailDescription", replacementSpan: test.ranges()[0] },
{ name: "login.loginErrorTitle", replacementSpan: test.ranges()[0] },
{ name: "login.loginErrorDescription", replacementSpan: test.ranges()[0] },
{ name: "login.openEmailAppErrorTitle", replacementSpan: test.ranges()[0] },
{ name: "login.openEmailAppErrorDescription", replacementSpan: test.ranges()[0] },
{ name: "login.openEmailAppErrorConfirm", replacementSpan: test.ranges()[0] },
]
}); | {
"end_byte": 2457,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsWithStringReplacementMode1.ts"
} |
TypeScript/tests/cases/fourslash/tripleSlashRefPathCompletionExtensionsAllowJSFalse.ts_0_567 | /// <reference path='fourslash.ts' />
// Should give completions for relative references to ts files only when allowJs is false.
// @Filename: test0.ts
//// /// <reference path="/*0*/
//// /// <reference path=".//*1*/
//// /// <reference path="./f/*2*/
// @Filename: f1.ts
////
// @Filename: f1.js
////
// @Filename: f1.d.ts
////
// @Filename: f1.tsx
////
// @Filename: f1.js
////
// @Filename: f1.jsx
////
// @Filename: f1.cs
////
verify.completions({
marker: test.markers(),
exact: ["f1.d.ts", "f1.ts", "f1.tsx"],
isNewIdentifierLocation: true,
});
| {
"end_byte": 567,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tripleSlashRefPathCompletionExtensionsAllowJSFalse.ts"
} |
TypeScript/tests/cases/fourslash/mapCodeToplevelInsertNoClass.ts_0_236 | ///<reference path="fourslash.ts"/>
// @Filename: /index.ts
//// function foo() {
//// return 1;
//// }[||]
//// function bar() {
//// return 2;
//// }
verify.baselineMapCode([test.ranges()], [
`
baz() {
return 3;
}
`
]);
| {
"end_byte": 236,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeToplevelInsertNoClass.ts"
} |
TypeScript/tests/cases/fourslash/codeFixRequireInTs3.ts_0_137 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////const { a, b: { c } } = [|require("a")|];
verify.not.codeFixAvailable();
| {
"end_byte": 137,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRequireInTs3.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsNoImportClause.ts_0_234 | /// <reference path="fourslash.ts" />
// https://github.com/Microsoft/TypeScript/issues/15452
// @Filename: /a.ts
/////*1*/export const /*2*/x = 0;
// @Filename: /b.ts
////import "./a";
verify.baselineFindAllReferences('1', '2');
| {
"end_byte": 234,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsNoImportClause.ts"
} |
TypeScript/tests/cases/fourslash/completionsAsyncMethodDeclaration.ts_0_406 | /// <reference path="fourslash.ts" />
//// const obj = {
//// a() {},
//// async b/*1*/
//// };
//// const obj2 = {
//// async /*2*/
//// };
//// class Foo {
//// async b/*3*/
//// }
//// class Foo2 {
//// async /*4*/
//// }
//// class Bar {
//// static async b/*5*/
//// }
test.markerNames().forEach(marker => {
verify.completions({
marker,
isNewIdentifierLocation: true
});
});
| {
"end_byte": 406,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsAsyncMethodDeclaration.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoElementAccessDeclaration.ts_0_291 | /// <reference path="fourslash.ts" />
// @checkJs: true
// @allowJs: true
// @Filename: a.js
////const mod = {};
////mod["@@thing1"] = {};
////mod["/**/@@thing1"]["@@thing2"] = 0;
goTo.marker();
verify.quickInfoIs(`module mod["@@thing1"]
(property) mod["@@thing1"]: typeof mod.@@thing1`);
| {
"end_byte": 291,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoElementAccessDeclaration.ts"
} |
TypeScript/tests/cases/fourslash/referencesForAmbients.ts_0_498 | /// <reference path='fourslash.ts'/>
/////*1*/declare module "/*2*/foo" {
//// /*3*/var /*4*/f: number;
////}
////
/////*5*/declare module "/*6*/bar" {
//// /*7*/export import /*8*/foo = require("/*9*/foo");
//// var f2: typeof /*10*/foo./*11*/f;
////}
////
////declare module "baz" {
//// /*12*/import bar = require("/*13*/bar");
//// var f2: typeof bar./*14*/foo;
////}
verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14');
| {
"end_byte": 498,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForAmbients.ts"
} |
TypeScript/tests/cases/fourslash/formatSelectionWithTrivia2.ts_0_172 | /// <reference path="fourslash.ts" />
/////*begin*/;
////
/////*end*/
////
format.selection('begin', 'end');
verify.currentFileContentIs(";\n\n\n ");
| {
"end_byte": 172,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatSelectionWithTrivia2.ts"
} |
TypeScript/tests/cases/fourslash/getOutliningForTypeLiteral.ts_0_429 | /// <reference path="fourslash.ts"/>
////type A =[| {
//// a: number;
////}|]
////
////type B =[| {
//// a:[| {
//// a1:[| {
//// a2:[| {
//// x: number;
//// y: number;
//// }|]
//// }|]
//// }|],
//// b:[| {
//// x: number;
//// }|],
//// c:[| {
//// x: number;
//// }|]
////}|]
verify.outliningSpansInCurrentFile(test.ranges(), "code");
| {
"end_byte": 429,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOutliningForTypeLiteral.ts"
} |
TypeScript/tests/cases/fourslash/textChangesPreserveNewlines3.ts_0_514 | /// <reference path="fourslash.ts" />
//// /*1*/app
//// .use(foo)
////
//// .use(bar)
////
////
//// .use(
//// baz,
////
//// blob);/*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() {
app
.use(foo)
.use(bar)
.use(
baz,
blob);
}
`
});
| {
"end_byte": 514,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/textChangesPreserveNewlines3.ts"
} |
TypeScript/tests/cases/fourslash/completionsImportDefaultExportCrash2.ts_0_1044 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @allowJs: true
// @Filename: /node_modules/dom7/index.d.ts
//// export interface Dom7Array {
//// length: number;
//// prop(propName: string): any;
//// }
////
//// export interface Dom7 {
//// (): Dom7Array;
//// fn: any;
//// }
////
//// declare const Dom7: Dom7;
////
//// export {
//// Dom7 as $,
//// };
// @Filename: /dom7.js
//// import * as methods from 'dom7';
//// Object.keys(methods).forEach((methodName) => {
//// if (methodName === '$') return;
//// methods.$.fn[methodName] = methods[methodName];
//// });
////
//// export default methods.$;
// @Filename: /swipe-back.js
//// /*1*/
verify.completions({
marker: "1",
includes: [{
name: "$",
hasAction: true,
source: 'dom7',
sortText: completion.SortText.AutoImportSuggestions,
}, {
name: "Dom7",
hasAction: true,
source: './dom7',
sortText: completion.SortText.AutoImportSuggestions,
}],
preferences: {
includeCompletionsForModuleExports: true,
}
});
| {
"end_byte": 1044,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImportDefaultExportCrash2.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionReturn5.ts_0_181 | /// <reference path="fourslash.ts" />
////function foo() {
//// class Foo {
//// static { [|/*start*/return|]; }
//// }
////}
verify.baselineGoToDefinition("start");
| {
"end_byte": 181,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionReturn5.ts"
} |
TypeScript/tests/cases/fourslash/codeFixImportNonExportedMember_all2.ts_0_577 | /// <reference path="fourslash.ts" />
// @module: esnext
// @filename: /a.ts
////declare function foo(): any;
////declare function bar(): any;
////declare function baz(): any;
////export { baz };
// @filename: /b.ts
////import { foo, bar } from "./a";
goTo.file("/b.ts");
verify.codeFixAll({
fixId: "fixImportNonExportedMember",
fixAllDescription: ts.Diagnostics.Export_all_referenced_locals.message,
newFileContent: {
"/a.ts":
`declare function foo(): any;
declare function bar(): any;
declare function baz(): any;
export { baz, foo, bar };`
},
});
| {
"end_byte": 577,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImportNonExportedMember_all2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixTopLevelForAwait_module_blankCompilerOptionsInTsConfig.ts_0_337 | /// <reference path="fourslash.ts" />
// @filename: /dir/a.ts
////declare const p: number[];
////for await (const _ of p);
////export {};
// @filename: /dir/tsconfig.json
////{
//// "compilerOptions": {
//// }
////}
// Cannot fix module when default module option is `commonjs`...
verify.not.codeFixAvailable("fixModuleOption");
| {
"end_byte": 337,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelForAwait_module_blankCompilerOptionsInTsConfig.ts"
} |
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class_exportModifier2.ts_0_371 | /// <reference path='fourslash.ts' />
// @allowNonTsExtensions: true
// @Filename: test123.js
////export const foo = function() {
////};
////foo.prototype.instanceMethod = function() {
////};
verify.codeFix({
description: "Convert function to an ES2015 class",
newFileContent:
`export class foo {
constructor() {
}
instanceMethod() {
}
}
`,
});
| {
"end_byte": 371,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class_exportModifier2.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedVoidExpression01.ts_0_140 | /// <reference path='fourslash.ts' />
////var x;
////var y = (p) => void /*1*/
verify.completions({ marker: "1", includes: ["p", "x"] });
| {
"end_byte": 140,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedVoidExpression01.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringAssignmentForOfObjectBindingPatternDefaultValues.ts_0_5728 | /// <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 = "noName" } of robots) {
//// console.log(nameA);
////}
////for ({name: nameA = "noName" } of getRobots()) {
//// console.log(nameA);
////}
////for ({name: nameA = "noName" } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) {
//// console.log(nameA);
////}
////for ({ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } =
//// { primary: "nosKill", secondary: "noSkill" } } of multiRobots) {
//// console.log(primaryA);
////}
////for ({ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } =
//// { primary: "nosKill", secondary: "noSkill" } } of getMultiRobots()) {
//// console.log(primaryA);
////}
////for ({ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } =
//// { primary: "nosKill", secondary: "noSkill" } } of
//// <MultiRobot[]>[{ name: "mower", skills: { primary: "mowing", secondary: "none" } },
//// { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) {
//// console.log(primaryA);
////}
////for ({ name = "noName" } of robots) {
//// console.log(nameA);
////}
////for ({ name = "noName" } of getRobots()) {
//// console.log(nameA);
////}
////for ({ name = "noName" } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) {
//// console.log(nameA);
////}
////for ({
//// skills: {
//// primary = "primary",
//// secondary = "secondary"
//// } = { primary: "noSkill", secondary: "noSkill" }
////} of multiRobots) {
//// console.log(primaryA);
////}
////for ({
//// skills: {
//// primary = "primary",
//// secondary = "secondary"
//// } = { primary: "noSkill", secondary: "noSkill" }
////} of getMultiRobots()) {
//// console.log(primaryA);
////}
////for ({
//// skills: {
//// primary = "primary",
//// secondary = "secondary"
//// } = { primary: "noSkill", secondary: "noSkill" }
////} of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } },
//// { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) {
//// console.log(primaryA);
////}
////for ({name: nameA = "noName", skill: skillA = "noSkill" } of robots) {
//// console.log(nameA);
////}
////for ({name: nameA = "noName", skill: skillA = "noSkill" } of getRobots()) {
//// console.log(nameA);
////}
////for ({name: nameA = "noName", skill: skillA = "noSkill" } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) {
//// console.log(nameA);
////}
////for ({
//// name: nameA = "noName",
//// skills: {
//// primary: primaryA = "primary",
//// secondary: secondaryA = "secondary"
//// } = { primary: "noSkill", secondary: "noSkill" }
////} of multiRobots) {
//// console.log(nameA);
////}
////for ({
//// name: nameA = "noName",
//// skills: {
//// primary: primaryA = "primary",
//// secondary: secondaryA = "secondary"
//// } = { primary: "noSkill", secondary: "noSkill" }
////} of getMultiRobots()) {
//// console.log(nameA);
////}
////for ({
//// name: nameA = "noName",
//// skills: {
//// primary: primaryA = "primary",
//// secondary: secondaryA = "secondary"
//// } = { primary: "noSkill", secondary: "noSkill" }
////} of <MultiRobot[]>[{ name: "mower", skills: { primary: "mowing", secondary: "none" } },
//// { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) {
//// console.log(nameA);
////}
////for ({ name = "noName", skill = "noSkill" } of robots) {
//// console.log(nameA);
////}
////for ({ name = "noName", skill = "noSkill" } of getRobots()) {
//// console.log(nameA);
////}
////for ({ name = "noName", skill = "noSkill" } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) {
//// console.log(nameA);
////}
////for ({
//// name = "noName",
//// skills: {
//// primary = "primary",
//// secondary = "secondary"
//// } = { primary: "noSkill", secondary: "noSkill" }
////} of multiRobots) {
//// console.log(nameA);
////}
////for ({
//// name = "noName",
//// skills: {
//// primary = "primary",
//// secondary = "secondary"
//// } = { primary: "noSkill", secondary: "noSkill" }
////} of getMultiRobots()) {
//// console.log(nameA);
////}
////for ({
//// name = "noName",
//// skills: {
//// primary = "primary",
//// secondary = "secondary"
//// } = { primary: "noSkill", secondary: "noSkill" }
////} of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } },
//// { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) {
//// console.log(nameA);
////}
verify.baselineCurrentFileBreakpointLocations();
| {
"end_byte": 5728,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringAssignmentForOfObjectBindingPatternDefaultValues.ts"
} |
TypeScript/tests/cases/fourslash/completionEntryForPropertyConstrainedToString.ts_0_284 | /// <reference path="fourslash.ts" />
//// declare function test<P extends "a" | "b">(p: { type: P }): void;
////
//// test({ type: /*ts*/ })
verify.completions({ marker: ["ts"], includes: ['"a"', '"b"'], isNewIdentifierLocation: false, defaultCommitCharacters: [".", ",", ";"] });
| {
"end_byte": 284,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionEntryForPropertyConstrainedToString.ts"
} |
TypeScript/tests/cases/fourslash/todoComments4.ts_0_64 | //// // TODOnomatch
verify.todoCommentsInCurrentFile(["TODO"]); | {
"end_byte": 64,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/todoComments4.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingMember27.ts_0_321 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
////interface IFoo {}
////const foo: IFoo = {}
////foo.bar()
verify.codeFix({
description: [ts.Diagnostics.Declare_method_0.message, "bar"],
index: 0,
newFileContent:
`interface IFoo {
bar(): unknown;
}
const foo: IFoo = {}
foo.bar()`,
});
| {
"end_byte": 321,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember27.ts"
} |
TypeScript/tests/cases/fourslash/augmentedTypesModule3.ts_0_430 | /// <reference path='fourslash.ts'/>
////function m2g() { };
////module m2g { export class C { foo(x: number) { } } }
////var x: m2g./*1*/;
////var /*2*/r = m2g/*3*/;
verify.completions({ marker: "1", exact: "C" });
edit.insert('C.');
verify.completions({ exact: undefined });
edit.backspace(1);
verify.quickInfoAt("2", "var r: typeof m2g");
goTo.marker('3');
edit.insert('(');
verify.signatureHelp({ text: "m2g(): void" });
| {
"end_byte": 430,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/augmentedTypesModule3.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_barrelExport5.ts_0_707 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @Filename: /package.json
//// { "type": "module" }
// @Filename: /foo/a.ts
//// export const A = 0;
// @Filename: /foo/b.ts
//// export {};
//// A/*sibling*/
// @Filename: /foo/index.ts
//// export * from "./a.js";
//// export * from "./b.js";
// @Filename: /index.ts
//// export * from "./foo/index.js";
//// export * from "./src/index.js";
// @Filename: /src/a.ts
//// export {};
//// A/*parent*/
// @Filename: /src/index.ts
//// export * from "./a.js";
verify.importFixModuleSpecifiers("sibling", ["./a.js", "./index.js", "../index.js"]);
verify.importFixModuleSpecifiers("parent", ["../foo/a.js", "../foo/index.js", "../index.js"]); | {
"end_byte": 707,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_barrelExport5.ts"
} |
TypeScript/tests/cases/fourslash/completionListForTransitivelyExportedMembers03.ts_3_739 | /<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: "", includes: ["I1", "I2", "I1_OR_I2", "C1"] });
| {
"end_byte": 739,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListForTransitivelyExportedMembers03.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteralImport1.ts_0_920 | /// <reference path='fourslash.ts' />
// Should define spans for replacement that appear after the last directory seperator in import statements
// @typeRoots: my_typings
// @Filename: test.ts
//// import * as foo0 from "./some/*0*/
//// import * as foo1 from "./sub/some/*1*/
//// import * as foo2 from "[|some-|]/*2*/"
//// import * as foo3 from "..//*3*/";
// @Filename: someFile1.ts
//// /*someFile1*/
// @Filename: sub/someFile2.ts
//// /*someFile2*/
// @Filename: my_typings/some-module/index.d.ts
//// export var x = 9;
verify.completions(
{ marker: "0", exact: ["someFile1", "my_typings", "sub"], isNewIdentifierLocation: true },
{ marker: "1", exact: "someFile2", isNewIdentifierLocation: true },
{ marker: "2", exact: { name: "some-module", replacementSpan: test.ranges()[0] }, isNewIdentifierLocation: true },
{ marker: "3", exact: "fourslash", isNewIdentifierLocation: true },
);
| {
"end_byte": 920,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralImport1.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringAssignmentForObjectBindingPattern.ts_0_4043 | /// <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 robot: Robot = { name: "mower", skill: "mowing" };
////let multiRobot: MultiRobot = { name: "mower", skills: { primary: "mowing", secondary: "none" } };
////function getRobot() {
//// return robot;
////}
////function getMultiRobot() {
//// return multiRobot;
////}
////let nameA: string, primaryA: string, secondaryA: string, i: number, skillA: string;
////let name: string, primary: string, secondary: string, skill: string;
////for ({ name: nameA } = robot, i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for ({ name: nameA } = getRobot(), i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for ({ name: nameA } = <Robot>{ name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for ({ skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for ({ skills: { primary: primaryA, secondary: secondaryA } } = getMultiRobot(), i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for ({ skills: { primary: primaryA, secondary: secondaryA } } =
//// <MultiRobot>{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } },
//// i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for ({ name } = robot, i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for ({ name } = getRobot(), i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for ({ name } = <Robot>{ name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for ({ skills: { primary, secondary } } = getMultiRobot(), i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for ({ skills: { primary, secondary } } =
//// <MultiRobot>{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } },
//// i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for ({ name: nameA, skill: skillA } = robot, i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for ({ name: nameA, skill: skillA } = getRobot(), i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for ({ name: nameA, skill: skillA } = <Robot>{ name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for ({ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for ({ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = getMultiRobot(), i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for ({ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } =
//// <MultiRobot>{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } },
//// i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for ({ name, skill } = robot, i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for ({ name, skill } = getRobot(), i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for ({ name, skill } = <Robot>{ name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for ({ name, skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for ({ name, skills: { primary, secondary } } = getMultiRobot(), i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for ({ name, skills: { primary, secondary } } =
//// <MultiRobot>{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } },
//// i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 4043,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringAssignmentForObjectBindingPattern.ts"
} |
TypeScript/tests/cases/fourslash/completionsExportImport.ts_0_469 | /// <reference path="fourslash.ts" />
////declare global {
//// namespace N {
//// const foo: number;
//// }
////}
////export import foo = N.foo;
/////**/
verify.completions({
marker: "",
exact: completion.globalsPlus([
{ name: "foo", kind: "alias", kindModifiers: "export,declare", text: "(alias) const foo: number\nimport foo = N.foo" },
{ name: "N", kind: "module", kindModifiers: "declare", text: "namespace N" },
]),
});
| {
"end_byte": 469,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsExportImport.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_InFunctionCall.ts_0_442 | /// <reference path='fourslash.ts' />
////let foo = { bar: { baz: 0 } };
////f(/*a*/foo && foo.bar && foo.bar.baz/*b*/);
// allow for call arguments
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to optional chain expression",
actionName: "Convert to optional chain expression",
actionDescription: "Convert to optional chain expression",
newContent:
`let foo = { bar: { baz: 0 } };
f(foo?.bar?.baz);`
}); | {
"end_byte": 442,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_InFunctionCall.ts"
} |
TypeScript/tests/cases/fourslash/renameRest.ts_0_281 | /// <reference path='fourslash.ts'/>
////interface Gen {
//// x: number;
//// [|[|{| "contextRangeIndex": 0 |}parent|]: Gen;|]
//// millenial: string;
////}
////let t: Gen;
////var { x, ...rest } = t;
////rest.[|parent|];
verify.baselineRenameAtRangesWithText("parent");
| {
"end_byte": 281,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameRest.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_inCommonJsFile.ts_0_533 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @target: esnext
// @Filename: /a.cjs
////module.exports = 0;
// @Filename: /b.cts
////module.exports = 0;
// @Filename: /c.ts
////module.exports = 0;
// @Filename: /d.js
////module.exports = 0;
goTo.file("/a.cjs");
verify.codeFixAvailable([]);
goTo.file("/b.cts");
verify.codeFixAvailable([]);
goTo.file("/c.ts");
verify.codeFixAvailable([]);
goTo.file("/d.js");
verify.codeFix({
description: "Convert to ES module",
newFileContent: 'export default 0;',
}); | {
"end_byte": 533,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_inCommonJsFile.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess20.ts_0_560 | /// <reference path='fourslash.ts' />
//// class A {
//// public a_1: number;
//// /*a*/public a: string;/*b*/
//// }
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Generate 'get' and 'set' accessors",
actionName: "Generate 'get' and 'set' accessors",
actionDescription: "Generate 'get' and 'set' accessors",
newContent: `class A {
public a_1: number;
private /*RENAME*/_a: string;
public get a(): string {
return this._a;
}
public set a(value: string) {
this._a = value;
}
}`,
});
| {
"end_byte": 560,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess20.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType52.ts_0_184 | /// <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": 184,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType52.ts"
} |
TypeScript/tests/cases/fourslash/extract-method2.ts_0_784 | /// <reference path='fourslash.ts' />
//// namespace NS {
//// class Q {
//// foo() {
//// console.log('100');
//// const m = 10, j = "hello", k = {x: "what"};
//// const q = /*start*/m + j + k/*end*/;
//// }
//// }
//// }
goTo.select('start', 'end')
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_3",
actionDescription: "Extract to function in global scope",
newContent:
`namespace NS {
class Q {
foo() {
console.log('100');
const m = 10, j = "hello", k = {x: "what"};
const q = /*RENAME*/newFunction(m, j, k);
}
}
}
function newFunction(m: number, j: string, k: { x: string; }) {
return m + j + k;
}
`
});
| {
"end_byte": 784,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue15.ts_0_333 | /// <reference path='fourslash.ts' />
//// interface A {
//// bar: string
//// }
////
//// function Foo (a: () => A) { a() }
//// Foo(() => { bar: '1' })
verify.codeFixAvailable([
{ description: 'Wrap the following body with parentheses which should be an object literal' },
{ description: 'Remove unused label' },
]);
| {
"end_byte": 333,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue15.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportFile5.ts_0_258 | /// <reference path="fourslash.ts" />
//// [|bar/*0*/();|]
// @Filename: foo.ts
//// interface MyStatic {
//// bar(): void;
//// }
//// declare var x: MyStatic;
//// export = x;
-verify.importFixAtPosition([
`import { bar } from "./foo";
bar();`
]);
| {
"end_byte": 258,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportFile5.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingAttributes1.ts_0_396 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: foo.tsx
////interface P {
//// a: number;
//// b: string;
////}
////
////const A = ({ a, b }: P) =>
//// <div>{a}{b}</div>;
////
////const Bar = () =>
//// [|<A></A>|]
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_attributes.message,
newRangeContent: `<A a={0} b={""}></A>`
});
| {
"end_byte": 396,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAttributes1.ts"
} |
TypeScript/tests/cases/fourslash/addFunctionInDuplicatedConstructorClassBody.ts_0_228 | /// <reference path="fourslash.ts" />
//// class Foo {
//// constructor() { }
//// constructor() { }
//// /**/
//// }
goTo.marker();
var func = 'fn() { }';
edit.insert(func);
verify.numberOfErrorsInCurrentFile(2);
| {
"end_byte": 228,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/addFunctionInDuplicatedConstructorClassBody.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization6.ts_0_234 | /// <reference path='fourslash.ts' />
// @strict: true
//// class T {
//// a: "1";
//// }
verify.codeFix({
description: `Add initializer to property 'a'`,
newFileContent: `class T {
a: "1" = "1";
}`,
index: 2
}) | {
"end_byte": 234,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization6.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_BinaryExpression.ts_0_378 | /// <reference path='fourslash.ts' />
////let a = { b: { c: 0 } };
/////*a*/a && a.b && a.b.c;/*b*/
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to optional chain expression",
actionName: "Convert to optional chain expression",
actionDescription: "Convert to optional chain expression",
newContent:
`let a = { b: { c: 0 } };
a?.b?.c;`
}); | {
"end_byte": 378,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_BinaryExpression.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_alias2.ts_1_696 | /// <reference path='fourslash.ts' />
// @filename: /producer.ts
//// export function doit() {};
//// export const x = 1;
// @filename: /test.ts
//// import { doit as doit2 } from "./producer";
////
//// class Another {}
////
//// [|class Consumer {
//// constructor() {
//// doit2();
//// }
//// }|]
// @filename: /consumer.ts
//// import { x } from "./producer";
//// x;
verify.moveToFile({
newFileContents: {
"/test.ts":
`
class Another {}
`,
"/consumer.ts":
`import { doit as doit2, x } from "./producer";
x;
class Consumer {
constructor() {
doit2();
}
}
`
},
interactiveRefactorArguments: { targetFile: "/consumer.ts" },
});
| {
"end_byte": 696,
"start_byte": 1,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_alias2.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsReturnType.ts_0_426 | /// <reference path="fourslash.ts" />
//// function foo1 () {
//// return 1
//// }
//// function foo2 (): number {
//// return 1
//// }
//// class C {
//// foo() {
//// return 1
//// }
//// }
//// const a = () => 1
//// const b = function () { return 1 }
//// const c = (b) => 1
//// const d = b => 1
verify.baselineInlayHints(undefined, {
includeInlayFunctionLikeReturnTypeHints: true,
});
| {
"end_byte": 426,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsReturnType.ts"
} |
TypeScript/tests/cases/fourslash/completionListIsGlobalCompletion.ts_0_2997 | /// <reference path='fourslash.ts'/>
// @Filename: file.ts
////export var x = 10;
////export var y = 10;
////export default class C {
////}
// @Filename: a.ts
////import { /*1*/ } from "./file.ts"; // no globals in imports - export not found
//@Filename: file.tsx
/////// <reference path="/*2*/..\services\services.ts" /> // no globals in reference paths
////import { /*3*/ } from "./file1.ts"; // no globals in imports - export not found
////var test = "/*4*/"; // no globals in strings
/////*5*/class A { // insert globals
//// foo(): string { return ''; }
////}
////
////class /*6*/B extends A { // no globals after class keyword
//// bar(): string {
//// /*7*/ // insert globals
//// return '';
//// }
////}
////
////class C</*8*/ U extends A, T extends A> { // no globals at beginning of generics
//// x: U;
//// y = this./*9*/x; // no globals inserted for member completions
//// /*10*/ // insert globals
////}
/////*11*/ // insert globals
////const y = <div /*12*/ />; // no globals in jsx attribute found
////const z = <div =/*13*/ />; // no globals in jsx attribute with syntax error
////const x = `/*14*/ ${/*15*/}`; // globals only in template expression
////var user = </*16*/User name=/*17*/{ /*18*/window.isLoggedIn ? window.name : '/*19*/'} />; // globals only in JSX expression (but not in JSX expression strings)
const x = ["test", "A", "B", "C", "y", "z", "x", "user"];
const globals = completion.sorted([...x, ...completion.globals])
verify.completions(
{ marker: ["1"], exact: ["x", "y", { name: "type", sortText: completion.SortText.GlobalsOrKeywords }], isGlobalCompletion: false },
{ marker: ["3"], exact: [{ name: "type", sortText: completion.SortText.GlobalsOrKeywords }], isNewIdentifierLocation: true, isGlobalCompletion: false },
{ marker: ["6", "8", "12", "14"], exact: undefined, isGlobalCompletion: false },
{ marker: "2", exact: ["a.ts", "file.ts"], isGlobalCompletion: false, isNewIdentifierLocation: true },
{ marker: ["4", "19"], exact: [], isGlobalCompletion: false },
{ marker: ["5", "11"], exact: globals, isGlobalCompletion: true },
{ marker: ["18"], exact: globals.filter(name => name !== 'user'), isGlobalCompletion: true },
{ marker: "7", exact: completion.globalsInsideFunction(x), isGlobalCompletion: true },
{ marker: "9", exact: ["x", "y"], isGlobalCompletion: false },
{ marker: "10", exact: completion.classElementKeywords, isGlobalCompletion: false, isNewIdentifierLocation: true },
{ marker: "13", exact: completion.globalTypesPlus(["A", "B", "C"]), isGlobalCompletion: false },
{ marker: "15", exact: globals.filter(name => name !== 'x'), isGlobalCompletion: true, isNewIdentifierLocation: true },
{ marker: "16", unsorted: [...x, completion.globalThisEntry, ...completion.globalsVars, completion.undefinedVarEntry].filter(name => name !== 'user'), isGlobalCompletion: false },
{ marker: "17", exact: completion.globalKeywords, isGlobalCompletion: false },
);
| {
"end_byte": 2997,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListIsGlobalCompletion.ts"
} |
TypeScript/tests/cases/fourslash/documentHighlightAtInheritedProperties6.ts_3_321 | / <reference path='fourslash.ts'/>
// @Filename: file1.ts
//// class C extends D {
//// [|prop0|]: string;
//// [|prop1|]: string;
//// }
////
//// class D extends C {
//// [|prop0|]: string;
//// [|prop1|]: string;
//// }
////
//// var d: D;
//// d.[|prop1|];
verify.baselineDocumentHighlights();
| {
"end_byte": 321,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlightAtInheritedProperties6.ts"
} |
TypeScript/tests/cases/fourslash/completionListAtInvalidLocations.ts_0_692 | /// <reference path='fourslash.ts' />
//// var v1 = '';
//// " /*openString1*/
//// var v2 = '';
//// "/*openString2*/
//// var v3 = '';
//// " bar./*openString3*/
//// var v4 = '';
//// // bar./*inComment1*/
//// var v6 = '';
//// // /*inComment2*/
//// var v7 = '';
//// /* /*inComment3*/
//// var v11 = '';
//// // /*inComment4*/
//// var v12 = '';
//// type htm/*inTypeAlias*/
////
//// // /*inComment5*/
//// foo;
//// var v10 = /reg/*inRegExp1*/ex/;
verify.completions(
{ marker: ["openString1", "openString2", "openString3"], exact: [] },
{ marker: ["inComment1", "inComment2", "inComment3", "inComment4", "inTypeAlias", "inComment5", "inRegExp1"], exact: undefined },
);
| {
"end_byte": 692,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtInvalidLocations.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_overloads4.ts_0_507 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////function add(x: number, y: number): number;
////[|function add(x: string, y: string): string;
////function add(x: any, y: any) {
//// return x + y;
////}|]
////function remove() {}
verify.moveToNewFile({
newFileContents: {
"/a.ts": "function remove() {}",
"/add.ts":
`function add(x: number, y: number): number;
function add(x: string, y: string): string;
function add(x: any, y: any) {
return x + y;
}
`
},
});
| {
"end_byte": 507,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_overloads4.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsJsDocImportTag4.ts_0_675 | /// <reference path="fourslash.ts" />
// @checkJs: true
// @Filename: /component.js
//// export class Component {
//// constructor() {
//// this.id_ = Math.random();
//// }
//// id() {
//// return this.id_;
//// }
//// }
// @Filename: /spatial-navigation.js
//// /** @import * as C from './component.js' */
////
//// export class SpatialNavigation {
//// /**
//// * @param {C.Component} component
//// */
//// add(component) {}
//// }
// @Filename: /player.js
//// import * as C from './component.js';
////
//// /**
//// * @extends C/*1*/.Component
//// */
//// export class Player extends Component {}
verify.baselineFindAllReferences("1");
| {
"end_byte": 675,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsJsDocImportTag4.ts"
} |
TypeScript/tests/cases/fourslash/goToTypeDefinition5.ts_0_192 | /// <reference path='fourslash.ts' />
// @Filename: foo.ts
////let Foo: /*definition*/unresolved;
////type Foo = { x: string };
/////*reference*/Foo;
verify.baselineGoToType("reference");
| {
"end_byte": 192,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToTypeDefinition5.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesProtected2.ts_0_1486 | /// <reference path='fourslash.ts' />
////module m {
//// export class C1 {
//// public pub1;
//// public pub2;
//// private priv1;
//// private priv2;
//// protected prot1;
//// protected prot2;
////
//// public public;
//// private private;
//// protected protected;
////
//// public constructor(public a, private b, protected c, public d, private e, protected f) {
//// this.public = 10;
//// this.private = 10;
//// this.protected = 10;
//// }
////
//// public get x() { return 10; }
//// public set x(value) { }
////
//// public static statPub;
//// private static statPriv;
//// protected static statProt;
//// }
////
//// export interface I1 {
//// }
////
//// export declare module ma.m1.m2.m3 {
//// interface I2 {
//// }
//// }
////
//// export module mb.m1.m2.m3 {
//// declare var foo;
////
//// export class C2 {
//// public pub1;
//// private priv1;
//// [|protected|] prot1;
////
//// [|protected|] constructor(public public, [|protected|] protected, private private) {
//// public = private = protected;
//// }
//// }
//// }
////
//// declare var ambientThing: number;
//// export var exportedThing = 10;
//// declare function foo(): string;
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 1486,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesProtected2.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentListItem.ts_0_228 | /// <reference path='fourslash.ts'/>
////[1,
//// 2
//// + 3, 4,
//// /*1*/
////[1,
//// 2
//// + 3, 4
//// /*2*/
goTo.marker("1");
verify.indentationIs(4)
goTo.marker("2");
verify.indentationIs(4) | {
"end_byte": 228,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentListItem.ts"
} |
TypeScript/tests/cases/fourslash/semanticClassificationsCancellation1.ts_0_552 | /// <reference path="fourslash.ts" />
////module M {
////}
////module N {
////}
const c = classification("original");
cancellation.setCancelled(1);
verifyOperationIsCancelled(() => verify.semanticClassificationsAre("original", ));
cancellation.resetCancelled();
verify.semanticClassificationsAre("original",
c.moduleName("M"),
c.moduleName("N"));
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("namespace.declaration", "M"),
c2.semanticToken("namespace.declaration", "N"),
);
| {
"end_byte": 552,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semanticClassificationsCancellation1.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_export_moduleDotExportsEqualsRequire.ts_0_1060 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @target: esnext
// @Filename: /a.d.ts
////export const x: number;
// @Filename: /b.d.ts
////export default function f() {}
// @Filename: /c.d.ts
////export default function f(): void;
////export function g(): void;
// @Filename: /d.ts
////declare const x: number;
////export = x;
// @Filename: /z.js
// Normally -- just `export *`
////module.exports = require("./a");
// If just a default is exported, just `export { default }`
////module.exports = require("./b");
// May need both
////module.exports = require("./c");
// For `export =` re-export the "default" since that's what it will be converted to.
////module.exports = require("./d");
// In untyped case just go with `export *`
////module.exports = require("./unknown");
goTo.file("/z.js");
verify.codeFix({
description: "Convert to ES module",
newFileContent:
`export * from "./a";
export { default } from "./b";
export * from "./c";
export { default } from "./c";
export { default } from "./d";
export * from "./unknown";`,
});
| {
"end_byte": 1060,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_export_moduleDotExportsEqualsRequire.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationInterface.ts_0_738 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_interface.baseline
// @Filename: bpSpan_interface.ts
////interface I {
//// property: string;
//// method(): number;
//// (a: string): string;
//// new (a: string): I;
//// [a: number]: number;
////}
////module m {
//// interface I1 {
//// property: string;
//// method(): number;
//// (a: string): string;
//// new (a: string): I;
//// [a: number]: number;
//// }
//// export interface I2 {
//// property: string;
//// method(): number;
//// (a: string): string;
//// new (a: string): I;
//// [a: number]: number;
//// }
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 738,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationInterface.ts"
} |
TypeScript/tests/cases/fourslash/brokenClassErrorRecovery.ts_0_177 | /// <reference path="fourslash.ts" />
////class Foo {
//// constructor() { var x = [1, 2, 3 }
////}
/////**/
////var bar = new Foo();
verify.not.errorExistsAfterMarker();
| {
"end_byte": 177,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/brokenClassErrorRecovery.ts"
} |
TypeScript/tests/cases/fourslash/textChangesIndentStyle.ts_0_543 | /// <reference path="fourslash.ts" />
// This fourslash file is indented with tabs.
// @Filename: /a.ts
//// [|export class Foo {
//// constructor(
//// public readonly a: number,
////
//// /**
//// * Docs!
//// */
//// public readonly b: number,
//// ) { }
//// }|]
format.setOption("convertTabsToSpaces", false);
verify.moveToNewFile({
newFileContents: {
"/a.ts": "",
"/Foo.ts":
`export class Foo {
constructor(
public readonly a: number,
/**
* Docs!
*/
public readonly b: number
) { }
}
`
}
});
| {
"end_byte": 543,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/textChangesIndentStyle.ts"
} |
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax4.ts_0_188 | /// <reference path='fourslash.ts' />
//// var x: [|Array.<number>|] = 12;
verify.codeFix({
description: "Change 'Array.<number>' to 'number[]'",
newRangeContent: "number[]",
});
| {
"end_byte": 188,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax4.ts"
} |
TypeScript/tests/cases/fourslash/unusedVariableInForLoop6FS.ts_0_290 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// function f1 () {
//// for ([|const elem of|] ["a", "b", "c"]) {
////
//// }
//// }
verify.codeFix({
description: "Remove unused declaration for: 'elem'",
index: 0,
newRangeContent: "const {} of",
});
| {
"end_byte": 290,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedVariableInForLoop6FS.ts"
} |
TypeScript/tests/cases/fourslash/completionInJSDocFunctionThis.ts_0_295 | ///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: Foo.js
/////** @type {function (this: string, string): string} */
////var f = function (s) { return this/**/; }
verify.completions({ marker: "", includes: { name: "this", sortText: completion.SortText.GlobalsOrKeywords } });
| {
"end_byte": 295,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionInJSDocFunctionThis.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddParameterNames2.ts_0_152 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
////type Rest = ([|...number|]) => void;
verify.rangeAfterCodeFix("...arg0: number[]");
| {
"end_byte": 152,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddParameterNames2.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoMappedTypeMethods.ts_0_223 | /// <reference path="fourslash.ts" />
// https://github.com/microsoft/TypeScript/issues/32983
////type M = { [K in 'one']: any };
////const x: M = {
//// /**/one() {}
////}
verify.quickInfoAt("", "(property) one: any");
| {
"end_byte": 223,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoMappedTypeMethods.ts"
} |
TypeScript/tests/cases/fourslash/doubleUnderscoreCompletions.ts_0_503 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: a.js
//// function MyObject(){
//// this.__property = 1;
//// }
//// var instance = new MyObject();
//// instance./*1*/
verify.completions({
marker: "1",
exact: [
{ name: "__property", text: "(property) MyObject.__property: number" },
{ name: "instance", sortText: completion.SortText.JavascriptIdentifiers },
{ name: "MyObject", sortText: completion.SortText.JavascriptIdentifiers },
],
});
| {
"end_byte": 503,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/doubleUnderscoreCompletions.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.