_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/getEditsForFileRename_resolveJsonModule.ts_0_333 | /// <reference path='fourslash.ts' />
// @resolveJsonModule: true
// @Filename: /a.ts
////import text from "./message.json";
// @Filename: /message.json
////{}
verify.getEditsForFileRename({
oldPath: "/a.ts",
newPath: "/src/a.ts",
newFileContents: {
"/a.ts": 'import text from "../message.json";',
},
});
| {
"end_byte": 333,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_resolveJsonModule.ts"
} |
TypeScript/tests/cases/fourslash/extract-const_jsxFragment3.ts_0_775 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: a.tsx
////declare var React: any;
////class Foo extends React.Component<{}, {}> {
//// render() {
//// return (
//// <div>
//// /*a*/<></>/*b*/
//// </div>
//// );
//// }
////}
goTo.file("a.tsx");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "constant_scope_1",
actionDescription: "Extract to readonly field in class 'Foo'",
newContent:
`declare var React: any;
class Foo extends React.Component<{}, {}> {
private readonly newProperty = <></>;
render() {
return (
<div>
{this./*RENAME*/newProperty}
</div>
);
}
}`
});
| {
"end_byte": 775,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const_jsxFragment3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAwaitInSyncFunction6.ts_0_270 | /// <reference path='fourslash.ts' />
////const f = (promise) => {
//// await promise;
////}
verify.codeFix({
index: 0,
description: "Add async modifier to containing function",
newFileContent:
`const f = async (promise) => {
await promise;
}`,
});
| {
"end_byte": 270,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAwaitInSyncFunction6.ts"
} |
TypeScript/tests/cases/fourslash/completionListInFunctionExpression.ts_0_491 | /// <reference path="fourslash.ts"/>
////() => {
//// var foo = 0;
//// /*requestCompletion*/
//// foo./*memberCompletion*/toString;
////}/*editDeclaration*/
function check() {
verify.completions(
{ marker: "requestCompletion", includes: "foo" },
{ marker: "memberCompletion", includes: "toExponential" },
);
}
check();
// Now change the decl by adding a semicolon
goTo.marker("editDeclaration");
edit.insert(";");
// foo should still be there
check();
| {
"end_byte": 491,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInFunctionExpression.ts"
} |
TypeScript/tests/cases/fourslash/genericFunctionReturnType.ts_0_473 | /// <reference path='fourslash.ts'/>
////function foo<T, U>(x: T, y: U): (a: U) => T {
//// var z = y;
//// return (z) => x;
////}
////var /*2*/r = foo(/*1*/1, "");
////var /*4*/r2 = r(/*3*/"");
verify.signatureHelp({ marker: "1", text: "foo(x: number, y: string): (a: string) => number" });
verify.quickInfoAt("2", "var r: (a: string) => number");
verify.signatureHelp({ marker: "3", text: "r(a: string): number" });
verify.quickInfoAt("4", "var r2: number");
| {
"end_byte": 473,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericFunctionReturnType.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpCommentsFunctionExpression.ts_0_1165 | /// <reference path='fourslash.ts' />
// test arrow doc comments
/////** lambdaFoo var comment*/
////var lambdaFoo = /** this is lambda comment*/ (/**param a*/a: number, /**param b*/b: number) => a + b;
////var lambddaNoVarComment = /** this is lambda multiplication*/ (/**param a*/a: number, /**param b*/b: number) => a * b;
////lambdaFoo(/*5*/10, /*6*/20);
// test nested arrow doc comments
////function anotherFunc(a: number) {
//// /** documentation
//// @param b {string} inner parameter */
//// var lambdaVar = /** inner docs */(b: string) => {
//// var localVar = "Hello ";
//// return localVar + b;
//// }
//// return lambdaVar("World") + a;
////}
// test function expression doc comments
/////**
//// * On variable
//// * @param s the first parameter!
//// * @returns the parameter's length
//// */
////var assigned = /**
//// * Summary on expression
//// * @param s param on expression
//// * @returns return on expression
//// */function(/** On parameter */s: string) {
//// return s.length;
////}
////assigned(/*18*/"hey");
verify.baselineSignatureHelp()
| {
"end_byte": 1165,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpCommentsFunctionExpression.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_overloads2.ts_0_462 | /// <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;
////}|]
verify.moveToNewFile({
newFileContents: {
"/a.ts": "",
"/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": 462,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_overloads2.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsInteractiveWithClosures.ts_0_397 | /// <reference path="fourslash.ts" />
//// function foo1(a: number) {
//// return (b: number) => {
//// return a + b
//// }
//// }
//// foo1(1)(2);
//// function foo2(a: (b: number) => number) {
//// return a(1) + 2
//// }
//// foo2((c: number) => c + 1);
verify.baselineInlayHints(undefined, {
includeInlayParameterNameHints: "all",
interactiveInlayHints: true
});
| {
"end_byte": 397,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveWithClosures.ts"
} |
TypeScript/tests/cases/fourslash/goToTypeDefinition3.ts_0_142 | /// <reference path='fourslash.ts' />
////type /*definition*/T = string;
////const x: /*reference*/T;
verify.baselineGoToType("reference");
| {
"end_byte": 142,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToTypeDefinition3.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsJsDocImportTag2.ts_0_685 | /// <reference path="fourslash.ts" />
// @checkJs: true
// @Filename: /component.js
//// export default class Component {
//// constructor() {
//// this.id_ = Math.random();
//// }
//// id() {
//// return this.id_;
//// }
//// }
// @Filename: /spatial-navigation.js
//// /** @import Component from './component.js' */
////
//// export class SpatialNavigation {
//// /**
//// * @param {Component} component
//// */
//// add(component) {}
//// }
// @Filename: /player.js
//// import Component from './component.js';
////
//// /**
//// * @extends Component/*1*/
//// */
//// export class Player extends Component {}
verify.baselineFindAllReferences("1");
| {
"end_byte": 685,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsJsDocImportTag2.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction16.ts_0_354 | /// <reference path='fourslash.ts' />
//// const foo = /*a*/a/*b*/ => { return {}; };
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Add or remove braces in an arrow function",
actionName: "Remove braces from arrow function",
actionDescription: "Remove braces from arrow function",
newContent: `const foo = a => ({});`,
});
| {
"end_byte": 354,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction16.ts"
} |
TypeScript/tests/cases/fourslash/referencesForImports.ts_0_297 | /// <reference path='fourslash.ts'/>
////declare module "jquery" {
//// function $(s: string): any;
//// export = $;
////}
/////*1*/import /*2*/$ = require("jquery");
/////*3*/$("a");
/////*4*/import /*5*/$ = require("jquery");
verify.baselineFindAllReferences('1', '2', '3', '4', '5');
| {
"end_byte": 297,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForImports.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType1.ts_0_769 | /// <reference path='fourslash.ts' />
// @Filename: a.ts
////export interface A {
//// x: number;
////}
// @Filename: b.ts
////import { A } from "./a";
////export interface B<T> {
//// payload: T;
////}
////export function create(fn: (args: B<A>) => void) {}
// @Filename: c.ts
////import { create } from "./b";
////class C {
//// bar() {
//// create(args => this.foo(args));
//// }
////}
goTo.file("c.ts");
verify.codeFix({
description: [ts.Diagnostics.Declare_method_0.message, "foo"],
index: 0,
newFileContent:
`import { A } from "./a";
import { B, create } from "./b";
class C {
bar() {
create(args => this.foo(args));
}
foo(args: B<A>): void {
throw new Error("Method not implemented.");
}
}`
});
| {
"end_byte": 769,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType1.ts"
} |
TypeScript/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts_0_417 | /// <reference path='fourslash.ts' />
// @Filename: justAComment.ts
//// // We want to check off-by-one errors in assessing the end of the comment, so we check twice,
//// // first with a trailing space and then without.
//// // /*0*/
//// // /*1*/
//// // We also want to check EOF handling at the end of a comment
//// // /*2*/
for (const marker of test.markers()) {
verify.noDocCommentTemplateAt(marker);
}
| {
"end_byte": 417,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_notInCommonjsProject.ts_0_271 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: /a.js
////exports.x = 0;
// No suggestion to convert to an ES6 module,
// since there are no es6 modules in this project and we don't have a high enough target.
verify.getSuggestionDiagnostics([]);
| {
"end_byte": 271,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_notInCommonjsProject.ts"
} |
TypeScript/tests/cases/fourslash/codeFixRequireInTs5.ts_0_165 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////const a = 1;
////const b = 2;
////const foo = require(`foo${a}${b}`);
verify.not.codeFixAvailable();
| {
"end_byte": 165,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRequireInTs5.ts"
} |
TypeScript/tests/cases/fourslash/unusedTypeParametersInMethod2.ts_0_265 | /// <reference path='fourslash.ts' />
// @noUnusedParameters: true
//// class C1 {
//// [|f1<T extends number, U>(a: U)|] {a;}
//// }
verify.codeFix({
index: 0,
description: "Remove unused declaration for: 'T'",
newRangeContent: "f1<U>(a: U)",
});
| {
"end_byte": 265,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedTypeParametersInMethod2.ts"
} |
TypeScript/tests/cases/fourslash/incrementalParsingDynamicImport1.ts_0_339 | /// <reference path="fourslash.ts"/>
// @lib: es6
// @Filename: ./foo.ts
//// export function bar() { return 1; }
//// var x1 = import("./foo");
//// x1.then(foo => {
//// var s: string = foo.bar();
//// })
//// /*1*/
verify.numberOfErrorsInCurrentFile(1);
goTo.marker("1");
edit.insert(" ");
verify.numberOfErrorsInCurrentFile(1); | {
"end_byte": 339,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incrementalParsingDynamicImport1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInvalidJsxCharacters6.ts_0_483 | /// <reference path='fourslash.ts' />
// @jsx: react
// @filename: main.tsx
//// let foo = <div>>{"foo"}</div>;
verify.codeFix({
description: ts.Diagnostics.Wrap_invalid_character_in_an_expression_container.message,
newFileContent: `let foo = <div>{">"}{"foo"}</div>;`,
index: 0,
});
verify.codeFix({
description: ts.Diagnostics.Convert_invalid_character_to_its_html_entity_code.message,
newFileContent: `let foo = <div>>{"foo"}</div>;`,
index: 1,
});
| {
"end_byte": 483,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInvalidJsxCharacters6.ts"
} |
TypeScript/tests/cases/fourslash/callHierarchyTaggedTemplate.ts_0_269 | /// <reference path="fourslash.ts" />
//// function foo() {
//// bar`a${1}b`;
//// }
////
//// function /**/bar(array: TemplateStringsArray, ...args: any[]) {
//// baz();
//// }
////
//// function baz() {
//// }
goTo.marker();
verify.baselineCallHierarchy();
| {
"end_byte": 269,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyTaggedTemplate.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_defaultExport.ts_0_266 | /// <reference path="fourslash.ts" />
// @module: esnext
// @allowJs: true
// @checkJs: true
// @Filename: /a.js
////class C {}
////export default C;
// @Filename: /b.js
////[|C;|]
goTo.file("/b.js");
verify.importFixAtPosition([
`import C from "./a";
C;`,
]);
| {
"end_byte": 266,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_defaultExport.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedFunction18.ts_3_362 | / <reference path="fourslash.ts" />
////interface MyType {
////}
////
////function foo(x: string, y: number, z: boolean) {
//// function bar(a: number, b: string = "hello", c: typeof x = "hello") {
//// var v = (p: MyType) => y + /*1*/
////}
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"] });
| {
"end_byte": 362,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedFunction18.ts"
} |
TypeScript/tests/cases/fourslash/navigateToImport.ts_0_555 | /// <reference path="fourslash.ts" />
// @Filename: library.ts
////[|export function foo() {}|]
////[|export function bar() {}|]
// @Filename: user.ts
////import {foo, [|bar as baz|]} from './library';
const [r0, r1, r2] = test.ranges();
verify.navigateTo(
{ pattern: "foo", expected: [{ name: "foo", kind: "function", kindModifiers: "export", range: r0 }] },
{ pattern: "bar", expected: [{ name: "bar", kind: "function", kindModifiers: "export", range: r1 }] },
{ pattern: "baz", expected: [{ name: "baz", kind: "alias", range: r2 }] },
);
| {
"end_byte": 555,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigateToImport.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionReturn3.ts_0_166 | /// <reference path="fourslash.ts" />
////class C {
//// /*end*/m() {
//// [|/*start*/return|] 1;
//// }
////}
verify.baselineGoToDefinition("start");
| {
"end_byte": 166,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionReturn3.ts"
} |
TypeScript/tests/cases/fourslash/textChangesPreserveNewlines5.ts_0_534 | /// <reference path="fourslash.ts" />
//// /*1*/f // call expression
//// (arg)(
//// /** @type {number} */
//// blah,
////
//// blah
////
//// );/*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() {
f // call expression
(arg)(
/** @type {number} */
blah,
blah
);
}
`
});
| {
"end_byte": 534,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/textChangesPreserveNewlines5.ts"
} |
TypeScript/tests/cases/fourslash/formatSelectionWithTrivia4.ts_0_314 | /// <reference path="fourslash.ts" />
// Tests comment indentation with range ending before next token (statement)
////if (true) {
/////*begin*/// test comment
/////*end*/console.log();
////}
format.selection('begin', 'end');
verify.currentFileContentIs("if (true) {\n // test comment\nconsole.log();\n}");
| {
"end_byte": 314,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatSelectionWithTrivia4.ts"
} |
TypeScript/tests/cases/fourslash/findAllReferencesNonExistentExportBinding.ts_0_262 | /// <reference path="fourslash.ts" />
// @Filename: /tsconfig.json
//// { "compilerOptions": { "module": "commonjs" } }
// @filename: /bar.ts
////import { Foo/**/ } from "./foo";
// @filename: /foo.ts
////export { Foo }
verify.baselineFindAllReferences('');
| {
"end_byte": 262,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesNonExistentExportBinding.ts"
} |
TypeScript/tests/cases/fourslash/codeFixImportNonExportedMember_all4.ts_0_578 | /// <reference path="fourslash.ts" />
// @module: esnext
// @filename: /a.ts
////const a = 1;
////export const foo = 1;
// @filename: /b.ts
////const b = 1;
////export const bar = 1;
// @filename: /c.ts
////import { a } from "./a";
////import { b } from "./b";
goTo.file("/c.ts");
verify.codeFixAll({
fixId: "fixImportNonExportedMember",
fixAllDescription: ts.Diagnostics.Export_all_referenced_locals.message,
newFileContent: {
"/a.ts":
`export const a = 1;
export const foo = 1;`,
"/b.ts":
`export const b = 1;
export const bar = 1;`
},
});
| {
"end_byte": 578,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImportNonExportedMember_all4.ts"
} |
TypeScript/tests/cases/fourslash/completionImportModuleSpecifierEndingDts.ts_0_439 | /// <reference path='fourslash.ts'/>
//@Filename:test.d.ts
//// export declare class Test {}
//@Filename:module.ts
////import { Test } from ".//**/"
verify.completions({ marker: "", includes:{name:"test.js"}, preferences: {importModuleSpecifierEnding: "js" }, isNewIdentifierLocation: true});
verify.completions({ marker: "", includes:{name:"test"}, preferences: {importModuleSpecifierEnding: "index" }, isNewIdentifierLocation: true});
| {
"end_byte": 439,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionImportModuleSpecifierEndingDts.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpNegativeTests.ts_0_292 | /// <reference path='fourslash.ts' />
// Negative tests
//////inside a comment foo(/*insideComment*/
////cl/*invalidContext*/ass InvalidSignatureHelpLocation { }
////InvalidSignatureHelpLocation(/*validContext*/);
verify.noSignatureHelp("insideComment", "invalidContext", "validContext");
| {
"end_byte": 292,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpNegativeTests.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationEnum_00.ts_0_271 | /// <reference path='fourslash.ts'/>
// Should handle calls made on members of an enum
//// enum Foo {
//// [|Foo1|] = function initializer() { return 5 } (),
//// Foo2 = 6
//// }
////
//// Foo.Fo/*reference*/o1;
verify.baselineGoToImplementation("reference"); | {
"end_byte": 271,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationEnum_00.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteralRelativeImport6.ts_0_974 | /// <reference path='fourslash.ts' />
// Should give correct completions for rootDirs regardless of the slash at the end
// @rootDirs: /repo/src1,/repo/src2/,/repo/generated1,/repo/generated2/
// @Filename: /repo/src1/test1.ts
//// import * as foo1 from "./dir//*import_as1*/
//// import foo2 = require("./dir//*import_equals1*/
//// var foo3 = require("./dir//*require1*/
// @Filename: /repo/src2/test2.ts
//// import * as foo1 from "./dir//*import_as2*/
//// import foo2 = require("./dir//*import_equals2*/
//// var foo3 = require("./dir//*require2*/
// @Filename: /repo/generated1/dir/f1.ts
//// /*f1*/
// @Filename: /repo/generated2/dir/f2.ts
//// /*f2*/
verify.completions(
{
marker: ["import_as1", "import_equals1", "require1"],
exact: ["f1", "f2"],
isNewIdentifierLocation: true,
},
{
marker: ["import_as2", "import_equals2", "require2"],
exact: ["f1", "f2"],
isNewIdentifierLocation: true,
}
);
| {
"end_byte": 974,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralRelativeImport6.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsTripleSlash8.ts_0_259 | /// <reference path="fourslash.ts"/>
//// /// <reference path="
const c = classification("original");
verify.syntacticClassificationsAre(
c.comment("/// "),
c.punctuation("<"),
c.jsxSelfClosingTagName("reference"),
c.comment(" path=\""));
| {
"end_byte": 259,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsTripleSlash8.ts"
} |
TypeScript/tests/cases/fourslash/renameNumericalIndex.ts_0_132 | /// <reference path="fourslash.ts" />
////const foo = { [|0|]: true };
////foo[[|0|]];
verify.baselineRenameAtRangesWithText("0"); | {
"end_byte": 132,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameNumericalIndex.ts"
} |
TypeScript/tests/cases/fourslash/augmentedTypesModule5.ts_0_413 | /// <reference path='fourslash.ts'/>
////declare class m3e { foo(): void }
////module m3e { export var y = 2; }
////var /*1*/r = new m3e();
////r./*2*/
////var /*4*/r2 = m3e./*3*/
verify.quickInfoAt("1", "var r: m3e");
verify.completions({ marker: "2", exact: "foo" });
edit.insert('foo();');
verify.completions({ marker: "3", includes: "y" });
edit.insert('y;');
verify.quickInfoAt("4", "var r2: number");
| {
"end_byte": 413,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/augmentedTypesModule5.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingMember21.ts_0_181 | /// <reference path='fourslash.ts' />
////declare let p: Promise<string>;
////async function f() {
//// p.toLowerCase();
////}
verify.not.codeFixAvailable("fixMissingMember");
| {
"end_byte": 181,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember21.ts"
} |
TypeScript/tests/cases/fourslash/todoComments2.ts_0_61 | //// // not TODO
verify.todoCommentsInCurrentFile(["TODO"]); | {
"end_byte": 61,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/todoComments2.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_barrelExport3.ts_0_1005 | /// <reference path="fourslash.ts" />
// @module: commonjs
// @Filename: /foo/a.ts
//// export const A = 0;
// @Filename: /foo/b.ts
//// export {};
//// A/*sibling*/
// @Filename: /foo/index.ts
//// export * from "./a";
//// export * from "./b";
// @Filename: /index.ts
//// export * from "./foo";
//// export * from "./src";
// @Filename: /src/a.ts
//// export {};
//// A/*parent*/
// @Filename: /src/index.ts
//// export * from "./a";
verify.importFixModuleSpecifiers("sibling", ["./a", "./index", "../index"], { importModuleSpecifierEnding: "index" });
// Here, "../foo/a" and "../foo/index" actually have the same sorting score,
// so the original program order is preserved, which seems coincidentally probably good?
// In other words, a re-export is preferable only if it saves on directory separators
// and isn't in an ancestor directory of the importing file.
verify.importFixModuleSpecifiers("parent", ["../foo/a", "../foo/index", "../index"], { importModuleSpecifierEnding: "index" });
| {
"end_byte": 1005,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_barrelExport3.ts"
} |
TypeScript/tests/cases/fourslash/completionListWithModulesFromModule.ts_0_6871 | /// <reference path='fourslash.ts'/>
// @noLib: true
////namespace mod1 {
//// var mod1var = 1;
//// function mod1fn() {
//// var bar = 1;
//// function foob() { }
//// }
//// class mod1cls {
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// interface mod1int {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// namespace mod1mod {
//// var m1X = 1;
//// function m1Func() {
//// var bar = 1;
//// function foob() { }
//// }
//// class m1Class {
//// private cVar = 1;
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// interface m1Int {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// export var m1eX = 1;
//// export function m1eFunc() {
//// }
//// export class m1eClass {
//// private cVar = 1;
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// export interface m1eInt {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// namespace m1Mod { }
//// export namespace m1eMod { }
//// }
//// export var mod1evar = 1;
//// export function mod1efn() {
//// var bar = 1;
//// function foob() { }
//// }
//// export class mod1ecls {
//// private cVar = 1;
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// export interface mod1eint {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// export namespace mod1emod {
//// var mX = 1;
//// function mFunc() {
//// var bar = 1;
//// function foob() { }
//// }
//// class mClass {
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// interface mInt {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// export var meX = 1;
//// export function meFunc() {
//// }
//// export class meClass {
//// private cVar = 1;
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// export interface meInt {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// namespace mMod { }
//// export namespace meMod { }
//// }
////}
////
////// EXTENDING NAMESPACE 1
////namespace mod1 {
//// export var mod1eexvar = 1;
//// var mod1exvar = 2;
////}
////
////namespace mod2 {
//// var mod2var = "shadow";
//// function mod2fn() {
//// var bar = 1;
//// function foob() { }
//// }
//// class mod2cls {
//// private cVar = 1;
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// namespace mod2mod { }
//// interface mod2int {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// export var mod2evar = 1;
//// export function mod2efn() {
//// }
//// export class mod2ecls {
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// export interface mod2eint {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// export namespace mod2emod { }
////}
////
////namespace mod2 {
//// export var mod2eexvar = 1;
////}
////
////namespace mod3 {
//// var shwvar = "shadow";
//// function shwfn(shadow: any) {
//// var bar = 1;
//// function foob() { }
//// }
//// class shwcls {
//// constructor(public shadow: any) { }
//// private cVar = 1;
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// interface shwint {
//// (bar: any): any;
//// new (bar: any): any;
//// sivar: string;
//// sifn(shadow: any): any;
//// }
//// /*shadowNamespaceWithNoExport*/
//// var tmp: /*shadowNamespaceWithNoExportType*/
////}
////
////namespace mod4 {
//// export var shwvar = "shadow";
//// export function shwfn(shadow: any) {
//// var bar = 1;
//// function foob(){ }
//// }
//// export class shwcls {
//// constructor(shadow: any) { }
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// export interface shwint {
//// (bar: any): any;
//// new (bar: any): any;
//// sivar: string;
//// sifn(shadow: any): any;
//// }
//// /*shadowNamespaceWithExport*/
//// var tmp: /*shadowNamespaceWithExportType*/
////}
////
////namespace mod5 {
//// import Mod1 = mod1;
//// import iMod1 = mod1.mod1emod;
//// /*namespaceWithImport*/
//// var tmp: /*namespaceWithImportType*/
////}
////
////function shwfn() {
//// var sfvar = 1;
//// function sffn() { }
////}
////
////class shwcls {
//// private scvar = 1;
//// private scfn() { }
//// public scpfn() { }
//// public scpvar = 1;
//// static scsvar = 1;
//// static scsfn() { }
////}
////
////interface shwint {
//// (bar: any): any;
//// new (bar: any): any;
//// sivar: any;
//// sifn(bar: any): any;
////}
////
////var shwvar = 1;
const commonValues: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> =
[1, 2, 3, 4, 5].map(n => ({ name: `mod${n}`, text: `namespace mod${n}` }));
const commonTypes: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> =
[1, 2, 4].map(n => ({ name: `mod${n}`, text: `namespace mod${n}` })); | {
"end_byte": 6871,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListWithModulesFromModule.ts"
} |
TypeScript/tests/cases/fourslash/completionListWithModulesFromModule.ts_6873_8355 | verify.completions(
{
marker: ["shadowNamespaceWithNoExport", "shadowNamespaceWithExport"],
unsorted: completion.globalsPlus([
...commonValues,
{ name: "shwfn", text: "function shwfn(shadow: any): void" },
{ name: "shwvar", text: "var shwvar: string" },
{ name: "shwcls", text: "class shwcls" },
"tmp",
], { noLib: true }),
}, {
marker: ["shadowNamespaceWithNoExportType", "shadowNamespaceWithExportType"],
unsorted: completion.typeKeywordsPlus([
completion.globalThisEntry,
{ name: "shwcls", text: "class shwcls" },
{ name: "shwint", text: "interface shwint" },
...commonTypes,
]),
},
{
marker: "namespaceWithImport",
unsorted: completion.globalsPlus([
"Mod1",
"iMod1",
"tmp",
{ name: "shwfn", text: "function shwfn(): void" },
...commonValues,
{ name: "shwcls", text: "class shwcls" },
{ name: "shwvar", text: "var shwvar: number" },
], { noLib: true }),
},
{
marker: "namespaceWithImportType",
unsorted: completion.typeKeywordsPlus([
completion.globalThisEntry,
"Mod1",
"iMod1",
...commonTypes,
{ name: "shwcls", text: "class shwcls" },
{ name: "shwint", text: "interface shwint" },
]),
}
); | {
"end_byte": 8355,
"start_byte": 6873,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListWithModulesFromModule.ts"
} |
TypeScript/tests/cases/fourslash/unusedTypeParametersWithTrivia3.ts_0_298 | /// <reference path="fourslash.ts" />
// @noUnusedParameters: true
////export type Foo</* comment */T1 extends any, T2 extends any/* comment */> = () => void;
verify.codeFix({
description: ts.Diagnostics.Remove_type_parameters.message,
newFileContent: "export type Foo = () => void;"
});
| {
"end_byte": 298,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedTypeParametersWithTrivia3.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoTypeAliasDefinedInDifferentFile.ts_0_262 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////export type X = { x: number };
////export function f(x: X): void {}
// @Filename: /b.ts
////import { f } from "./a";
/////**/f({ x: 1 });
verify.quickInfoAt("", "(alias) f(x: X): void\nimport f");
| {
"end_byte": 262,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoTypeAliasDefinedInDifferentFile.ts"
} |
TypeScript/tests/cases/fourslash/memberListOfExportedClass.ts_0_303 | /// <reference path='fourslash.ts' />
////module M {
//// export class C { public pub = 0; private priv = 1; }
//// export var V = 0;
////}
////
////
////var c = new M.C();
////
////c./**/ // test on c.
verify.completions({ marker: "", exact: { name: "pub", text: "(property) M.C.pub: number" } });
| {
"end_byte": 303,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberListOfExportedClass.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixDefaultExport2.ts_0_285 | /// <reference path="fourslash.ts" />
// @Filename: /lib.ts
////class Base { }
////export default Base;
// @Filename: /test.ts
////[|class Derived extends Base { }|]
goTo.file("/test.ts");
verify.importFixAtPosition([
`import Base from "./lib";
class Derived extends Base { }`,]);
| {
"end_byte": 285,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixDefaultExport2.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesSuper2.ts_0_1216 | /// <reference path='fourslash.ts' />
////class SuperType {
//// superMethod() {
//// }
////
//// static superStaticMethod() {
//// return 10;
//// }
////}
////
////class SubType extends SuperType {
//// public prop1 = super.superMethod;
//// private prop2 = super.superMethod;
////
//// constructor() {
//// super();
//// }
////
//// public method1() {
//// return super.superMethod();
//// }
////
//// private method2() {
//// return super.superMethod();
//// }
////
//// public method3() {
//// var x = () => super.superMethod();
////
//// // Bad but still gets highlighted
//// function f() {
//// super.superMethod();
//// }
//// }
////
//// // Bad but still gets highlighted.
//// public static statProp1 = [|super|].superStaticMethod;
////
//// public static staticMethod1() {
//// return [|super|].superStaticMethod();
//// }
////
//// private static staticMethod2() {
//// return [|supe/**/r|].superStaticMethod();
//// }
////
//// // Are not actually 'super' keywords.
//// super = 10;
//// static super = 20;
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 1216,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesSuper2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts_0_388 | /// <reference path='fourslash.ts' />
////abstract class A<T> {
//// abstract f(x: T): T;
////}
////
////class C<U> extends A<U> {}
verify.codeFix({
description: "Implement inherited abstract class",
newFileContent:
`abstract class A<T> {
abstract f(x: T): T;
}
class C<U> extends A<U> {
f(x: U): U {
throw new Error("Method not implemented.");
}
}`
});
| {
"end_byte": 388,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts"
} |
TypeScript/tests/cases/fourslash/todoComments15.ts_0_77 | //// "// HACK 1";
verify.todoCommentsInCurrentFile(["TODO(jason)", "HACK"]); | {
"end_byte": 77,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/todoComments15.ts"
} |
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType7.ts_0_315 | /// <reference path='fourslash.ts' />
////function /*a*/foo/*b*/() {
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Infer function return type",
actionName: "Infer function return type",
actionDescription: "Infer function return type",
newContent:
`function foo(): void {
}`
});
| {
"end_byte": 315,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType7.ts"
} |
TypeScript/tests/cases/fourslash/arbitraryModuleNamespaceIdentifiers_values.ts_0_630 | /// <reference path='fourslash.ts' />
// @Filename: /foo.ts
////const foo = "foo";
////export { foo as "[|__<alias>|]" };
////import { "[|__<alias>|]" as bar } from "./foo";
////if (bar !== "foo") throw bar;
// @Filename: /bar.ts
////import { "[|__<alias>|]" as first } from "./foo";
////export { "[|__<alias>|]" as "<other>" } from "./foo";
////import { "<other>" as second } from "./bar";
////if (first !== "foo") throw first;
////if (second !== "foo") throw second;
verify.noErrors();
verify.baselineRename(test.ranges());
verify.baselineGoToDefinition(...test.ranges());
verify.baselineFindAllReferences(...test.ranges());
| {
"end_byte": 630,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/arbitraryModuleNamespaceIdentifiers_values.ts"
} |
TypeScript/tests/cases/fourslash/docCommentTemplateInterfacesEnumsAndTypeAliases.ts_0_1009 | /// <reference path='fourslash.ts' />
/////*interfaceFoo*/
////interface Foo {
//// /*propertybar*/
//// bar: any;
////
//// /*methodbaz*/
//// baz(message: any): void;
////
//// /*methodUnit*/
//// unit(): void;
////}
////
/////*enumStatus*/
////const enum Status {
//// /*memberOpen*/
//// Open,
////
//// /*memberClosed*/
//// Closed
////}
////
/////*aliasBar*/
////type Bar = Foo & any;
verify.docCommentTemplateAt("interfaceFoo", /*expectedOffset*/ 3,
"/** */");
verify.docCommentTemplateAt("propertybar", /*expectedOffset*/ 3,
"/** */");
verify.docCommentTemplateAt("methodbaz", /*expectedOffset*/ 11,
`/**
*
* @param message
*/`);
verify.docCommentTemplateAt("methodUnit", /*expectedOffset*/ 3,
"/** */");
verify.docCommentTemplateAt("enumStatus", /*expectedOffset*/ 3,
"/** */");
verify.docCommentTemplateAt("memberOpen", /*expectedOffset*/ 3,
"/** */");
verify.docCommentTemplateAt("memberClosed", /*expectedOffset*/ 3,
"/** */");
| {
"end_byte": 1009,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateInterfacesEnumsAndTypeAliases.ts"
} |
TypeScript/tests/cases/fourslash/completionListInferKeyword.ts_0_266 | /// <reference path='fourslash.ts' />
//// type Bar<T> = T extends { a: (x: in/**/) => void }
//// ? U
//// : never;
verify.completions({
marker: "",
includes: [{ name: "infer", kind: "keyword", sortText: completion.SortText.GlobalsOrKeywords }]
});
| {
"end_byte": 266,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInferKeyword.ts"
} |
TypeScript/tests/cases/fourslash/importFixesGlobalTypingsCache.ts_0_907 | /// <reference path="fourslash.ts" />
// @Filename: /project/tsconfig.json
//// { "compilerOptions": { "allowJs": true, "checkJs": true } }
// @Filename: /home/src/Library/Caches/typescript/node_modules/@types/react-router-dom/package.json
//// { "name": "@types/react-router-dom", "version": "16.8.4", "types": "index.d.ts" }
// @Filename: /home/src/Library/Caches/typescript/node_modules/@types/react-router-dom/index.d.ts
////export class BrowserRouter {}
// @Filename: /project/node_modules/react-router-dom/package.json
//// { "name": "react-router-dom", "version": "16.8.4", "main": "index.js" }
// @Filename: /project/node_modules/react-router-dom/index.js
//// export const BrowserRouter = () => null;
// @Filename: /project/index.js
////BrowserRouter/**/
goTo.file("/project/index.js");
verify.importFixAtPosition([`const { BrowserRouter } = require("react-router-dom");
BrowserRouter`]);
| {
"end_byte": 907,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importFixesGlobalTypingsCache.ts"
} |
TypeScript/tests/cases/fourslash/completionsAfterJSDoc.ts_0_327 | /// <reference path="fourslash.ts" />
////export interface Foo {
//// /** JSDoc */
//// /**/foo(): void;
////}
// Should not crash, #35632
verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: [{
name: "readonly",
kind: "keyword",
sortText: completion.SortText.GlobalsOrKeywords
}]
});
| {
"end_byte": 327,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsAfterJSDoc.ts"
} |
TypeScript/tests/cases/fourslash/codeFixConvertTypedefToType2.ts_0_288 | /// <reference path='fourslash.ts' />
////
//// /**
//// * @typedef {(number|string|undefined)} Foo
//// */
////
verify.codeFix({
description: ts.Diagnostics.Convert_typedef_to_TypeScript_type.message,
index: 0,
newFileContent: `
type Foo = (number | string | undefined);
`,
}); | {
"end_byte": 288,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertTypedefToType2.ts"
} |
TypeScript/tests/cases/fourslash/formattingOnTypeLiteral.ts_0_846 | /// <reference path='fourslash.ts' />
////function _uniteVertices<p extends string, a>(
//// minority: Pinned<p, Vertex<a>>,
//// majorityCounter: number,
//// majority: Pinned<p, Vertex<a>>
////): {
//// /*start*/
//// majorityCounter: number;
//// vertecis: Pinned<p, {
//// oldVertexId: VertexId;
//// vertex: Vertex<a>;
//// }>;
//// /*end*/
//// } {
////}
format.document();
verify.currentFileContentIs(`function _uniteVertices<p extends string, a>(
minority: Pinned<p, Vertex<a>>,
majorityCounter: number,
majority: Pinned<p, Vertex<a>>
): {
majorityCounter: number;
vertecis: Pinned<p, {
oldVertexId: VertexId;
vertex: Vertex<a>;
}>;
} {
}`);
goTo.marker("start");
verify.indentationIs(4);
goTo.marker("end");
verify.indentationIs(4); | {
"end_byte": 846,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnTypeLiteral.ts"
} |
TypeScript/tests/cases/fourslash/unusedFunctionInNamespace4.ts_0_234 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters:true
//// [| namespace Validation {
//// var function1 = function() {
//// }
////} |]
verify.rangeAfterCodeFix(`namespace Validation {
}`);
| {
"end_byte": 234,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedFunctionInNamespace4.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType31.ts_0_172 | /// <reference path='fourslash.ts' />
//// type Item<T> = T extends /*a*/(infer P)[]/*b*/ ? P : never
goTo.select("a", "b");
verify.not.refactorAvailable('Extract type')
| {
"end_byte": 172,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType31.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue27.ts_0_137 | /// <reference path='fourslash.ts' />
//// const a: ((() => number) | (() => undefined)) = () => { "" }
verify.not.codeFixAvailable();
| {
"end_byte": 137,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue27.ts"
} |
TypeScript/tests/cases/fourslash/jsDocFunctionSignatures11.ts_0_264 | ///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: Foo.js
/////**
//// * @type {{ [name: string]: string; }} variables
//// */
////const vari/**/ables = {};
goTo.marker();
verify.quickInfoIs("const variables: {\n [name: string]: string;\n}");
| {
"end_byte": 264,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocFunctionSignatures11.ts"
} |
TypeScript/tests/cases/fourslash/completionListInObjectLiteralAssignmentPattern1.ts_1_155 | /// <reference path="fourslash.ts" />
////let x = { a: 1, b: 2 };
////let y = ({ /**/ } = x, 1);
verify.completions({ marker: "", exact: ["a", "b"] });
| {
"end_byte": 155,
"start_byte": 1,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectLiteralAssignmentPattern1.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_moveNamespaceImport.ts_0_311 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////import * as o from './other';
////[|export const x = o.foo();|]
////export const a = 0;
verify.moveToNewFile({
newFileContents: {
"/a.ts":
`export const a = 0;`,
"/x.ts":
`import * as o from './other';
export const x = o.foo();
`
},
});
| {
"end_byte": 311,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_moveNamespaceImport.ts"
} |
TypeScript/tests/cases/fourslash/referencesForInheritedProperties7.ts_3_502 | / <reference path='fourslash.ts'/>
//// class class1 extends class1 {
//// /*0*/doStuff() { }
//// /*1*/propName: string;
//// }
//// interface interface1 extends interface1 {
//// /*2*/doStuff(): void;
//// /*3*/propName: string;
//// }
//// class class2 extends class1 implements interface1 {
//// /*4*/doStuff() { }
//// /*5*/propName: string;
//// }
////
//// var v: class2;
//// v.doStuff();
//// v.propName;
verify.baselineFindAllReferences('0', '1', '2', '3', '4', '5')
| {
"end_byte": 502,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForInheritedProperties7.ts"
} |
TypeScript/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction2.ts_0_1374 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// interface ButtonProps extends ClickableProps {
//// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// interface LinkProps extends ClickableProps {
//// goTo: string;
//// }
//// declare function /*firstSource*/MainButton(buttonProps: ButtonProps): JSX.Element;
//// declare function /*secondSource*/MainButton(linkProps: LinkProps): JSX.Element;
//// declare function /*thirdSource*/MainButton(props: ButtonProps | LinkProps): JSX.Element;
//// let opt = <[|Main/*firstTarget*/Button|] />;
//// let opt = <[|Main/*secondTarget*/Button|] children="chidlren" />;
//// let opt = <[|Main/*thirdTarget*/Button|] onClick={()=>{}} />;
//// let opt = <[|Main/*fourthTarget*/Button|] onClick={()=>{}} ignore-prop />;
//// let opt = <[|Main/*fifthTarget*/Button|] goTo="goTo" />;
//// let opt = <[|Main/*sixthTarget*/Button|] wrong />;
verify.baselineGoToDefinition(
"firstTarget",
"secondTarget",
"thirdTarget",
"fourthTarget",
"fifthTarget",
"sixthTarget",
);
| {
"end_byte": 1374,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxGoToDefinitionStatelessFunction2.ts"
} |
TypeScript/tests/cases/fourslash/tsxCompletionOnClosingTagWithoutJSX1.ts_3_142 | / <reference path='fourslash.ts' />
//@Filename: file.tsx
//// var x1 = <div><//**/
verify.completions({ marker: "", exact: "div>" });
| {
"end_byte": 142,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletionOnClosingTagWithoutJSX1.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType60.ts_0_399 | /// <reference path='fourslash.ts' />
//// function foo(a: /*a*/{ a: number | string, b: string }/*b*/) { }
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to interface",
actionDescription: "Extract to interface",
newContent: `interface /*RENAME*/NewType {
a: number | string;
b: string;
}
function foo(a: NewType) { }`,
});
| {
"end_byte": 399,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType60.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess12.ts_0_593 | /// <reference path='fourslash.ts' />
//// class A {
//// /*a*/public get a/*b*/ () { return 1; }
//// /*c*/public set a/*d*/ (v) { }
//// /*e*/public ['b']/*f*/ () { }
//// /*g*/public ['c'] = 1;/*h*/
//// }
goTo.select("a", "b");
verify.not.refactorAvailable("Generate 'get' and 'set' accessors");
goTo.select("c", "d");
verify.not.refactorAvailable("Generate 'get' and 'set' accessors");
goTo.select("e", "f");
verify.not.refactorAvailable("Generate 'get' and 'set' accessors");
goTo.select("g", "h");
verify.not.refactorAvailable("Generate 'get' and 'set' accessors"); | {
"end_byte": 593,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess12.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarItemsItemsExternalModules3.ts_0_1365 | /// <reference path="fourslash.ts"/>
// @Filename: test/my fil e.ts
////export class Bar {
//// public s: string;
////}
////export var x: number;
verify.navigationTree({
"text": "\"my fil\\te\"",
"kind": "module",
"childItems": [
{
"text": "Bar",
"kind": "class",
"kindModifiers": "export",
"childItems": [
{
"text": "s",
"kind": "property",
"kindModifiers": "public"
}
]
},
{
"text": "x",
"kind": "var",
"kindModifiers": "export"
}
]
});
verify.navigationBar([
{
"text": "\"my fil\\te\"",
"kind": "module",
"childItems": [
{
"text": "Bar",
"kind": "class",
"kindModifiers": "export"
},
{
"text": "x",
"kind": "var",
"kindModifiers": "export"
}
]
},
{
"text": "Bar",
"kind": "class",
"kindModifiers": "export",
"childItems": [
{
"text": "s",
"kind": "property",
"kindModifiers": "public"
}
],
"indent": 1
}
]);
| {
"end_byte": 1365,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsItemsExternalModules3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingMember15.ts_0_293 | /// <reference path='fourslash.ts' />
////interface Foo {}
////class Foo {}
////Foo.test;
verify.codeFix({
description: ignoreInterpolations(ts.Diagnostics.Declare_static_property_0),
index: 0,
newFileContent:
`interface Foo {}
class Foo {
static test: any;
}
Foo.test;`
});
| {
"end_byte": 293,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember15.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertExport_ambientModule.ts_0_554 | /// <reference path='fourslash.ts' />
// @Filename: /foo.ts
////declare module "foo" {
//// /*a*/export default function foo(): void;/*b*/
////}
// @Filename: /b.ts
////import foo from "foo";
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert export",
actionName: "Convert default export to named export",
actionDescription: "Convert default export to named export",
newContent: {
"/foo.ts":
`declare module "foo" {
export function foo(): void;
}`,
"/b.ts":
`import { foo } from "foo";`,
},
});
| {
"end_byte": 554,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertExport_ambientModule.ts"
} |
TypeScript/tests/cases/fourslash/findAllReferencesFromLinkTagReference5.ts_0_138 | /// <reference path="fourslash.ts" />
////enum E {
//// /** {@link E./**/A} */
//// A
////}
verify.baselineFindAllReferences("");
| {
"end_byte": 138,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesFromLinkTagReference5.ts"
} |
TypeScript/tests/cases/fourslash/completionEntryForUnionProperty.ts_0_499 | ///<reference path="fourslash.ts" />
////interface One {
//// commonProperty: number;
//// commonFunction(): number;
////}
////
////interface Two {
//// commonProperty: string
//// commonFunction(): number;
////}
////
////var x : One | Two;
////
////x./**/
verify.completions({
marker: "",
exact: [
{ name: "commonFunction", text: "(method) commonFunction(): number" },
{ name: "commonProperty", text: "(property) commonProperty: string | number" },
],
});
| {
"end_byte": 499,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionEntryForUnionProperty.ts"
} |
TypeScript/tests/cases/fourslash/extract-method38.ts_0_360 | /// <reference path='fourslash.ts' />
////function bar(fn: () => void) {}
////
////class Foo {
//// x: number;
//// foo() {
//// /*start*/bar(() => { this.x });/*end*/
//// }
////}
goTo.select("start", "end");
verify.refactorAvailable("Extract Symbol", "function_scope_1");
verify.not.refactorAvailable("Extract Symbol", "function_scope_2");
| {
"end_byte": 360,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method38.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageRestParam3.ts_0_191 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
////function f(a: number, [|...rest |]){
//// a;
//// rest.push(22);
////}
verify.rangeAfterCodeFix("...rest: number[]"); | {
"end_byte": 191,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageRestParam3.ts"
} |
TypeScript/tests/cases/fourslash/extract-method_jsxFragment2.ts_0_594 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: a.tsx
////function Foo() {
//// return (
//// <div>
//// /*a*/<></>/*b*/
//// </div>
//// );
////}
goTo.file("a.tsx");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_0",
actionDescription: "Extract to inner function in function 'Foo'",
newContent:
`function Foo() {
return (
<div>
{newFunction()}
</div>
);
function /*RENAME*/newFunction() {
return <></>;
}
}`
});
| {
"end_byte": 594,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method_jsxFragment2.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionSwitchCase6.ts_0_168 | /// <reference path="fourslash.ts" />
////export default { [|/*a*/case|] };
////[|/*b*/default|];
////[|/*c*/case|] 42;
verify.baselineGoToDefinition("a", "b", "c");
| {
"end_byte": 168,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionSwitchCase6.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromExpressionStatement.ts_0_200 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
//// function inferVoid( [| app |] ) {
//// app.use('hi')
//// }
verify.rangeAfterCodeFix("app: { use: (arg0: string) => void; }");
| {
"end_byte": 200,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromExpressionStatement.ts"
} |
TypeScript/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts_0_416 | /// <reference path="fourslash.ts" />
//@Filename: jsxExpressionFollowedByIdentifier.tsx
////declare var React: any;
////const a = <div>{<div />[|x|]}</div>
////const b = <div x={<div />[|x|]} />
test.ranges().forEach(range => {
verify.errorExistsAtRange(range, ts.Diagnostics._0_expected.code, "'}' expected.");
// This is just to ensure getting quick info doesn’t crash
verify.not.quickInfoExists();
});
| {
"end_byte": 416,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageMember.ts_0_198 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
////class C {
//// [|p;|]
//// method() {
//// this.p.push(10);
//// }
////}
verify.rangeAfterCodeFix("p: number[];"); | {
"end_byte": 198,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageMember.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoExportAssignmentOfGenericInterface.ts_0_402 | /// <reference path='fourslash.ts' />
// @Filename: quickInfoExportAssignmentOfGenericInterface_0.ts
////interface Foo<T> {
//// a: string;
////}
////export = Foo;
// @Filename: quickInfoExportAssignmentOfGenericInterface_1.ts
////import a = require('./quickInfoExportAssignmentOfGenericInterface_0');
////export var /*1*/x: a<a<string>>;
////x.a;
verify.quickInfoAt("1", "var x: a<a<string>>");
| {
"end_byte": 402,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoExportAssignmentOfGenericInterface.ts"
} |
TypeScript/tests/cases/fourslash/memberListOfEnumInModule.ts_0_216 | /// <reference path='fourslash.ts'/>
////module Fixes {
//// enum Foo {
//// bar,
//// baz
//// }
//// var f: Foo = Foo./**/;
////}
verify.completions({ marker: "", exact: ["bar", "baz"] });
| {
"end_byte": 216,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberListOfEnumInModule.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction22.ts_0_1225 | /// <reference path='fourslash.ts' />
//// const /*a*/foo/*b*/ = /*c*/(/*d*//*e*/aa/*f*/aa, /*g*/b/*h*/) /*i*//*j*/ /*k*/=>/*l*/ /*m*/{/*n*/ /*o*/return/*p*/ 1; };
goTo.select("a", "b");
verify.not.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function")
goTo.select("c", "d");
verify.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function")
goTo.select("e", "f");
verify.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function")
goTo.select("g", "h");
verify.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function")
goTo.select("i", "j");
verify.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function")
goTo.select("k", "l");
verify.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function")
goTo.select("m", "n");
verify.not.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function")
goTo.select("o", "p");
verify.not.refactorAvailable("Add or remove braces in an arrow function", "Remove braces from arrow function")
| {
"end_byte": 1225,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction22.ts"
} |
TypeScript/tests/cases/fourslash/formattingSingleLineWithNewLineOptionSet.ts_0_562 | /// <reference path='fourslash.ts' />
/////*1*/module Default{}
/////*2*/function foo(){}
/////*3*/if (true){}
/////*4*/function boo() {
////}
format.setOption("PlaceOpenBraceOnNewLineForFunctions", true);
format.setOption("PlaceOpenBraceOnNewLineForControlBlocks", true);
format.document();
goTo.marker('1');
verify.currentLineContentIs('module Default { }');
goTo.marker('2');
verify.currentLineContentIs('function foo() { }');
goTo.marker('3');
verify.currentLineContentIs('if (true) { }');
goTo.marker('4');
verify.currentLineContentIs('function boo()'); | {
"end_byte": 562,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingSingleLineWithNewLineOptionSet.ts"
} |
TypeScript/tests/cases/fourslash/organizeImportsGroup_CommentInNewline.ts_0_359 | /// <reference path="fourslash.ts" />
////// polyfill
////import c from "C";
////// not polyfill
////import d from "D";
////import a from "A";
////import b from "B";
////
////console.log(a, b, c, d)
verify.organizeImports(
`// polyfill
import c from "C";
// not polyfill
import a from "A";
import b from "B";
import d from "D";
console.log(a, b, c, d)`
);
| {
"end_byte": 359,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsGroup_CommentInNewline.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_EmptySpanConditionalReturnStatement.ts_0_668 | /// <reference path='fourslash.ts' />
////let a = { b: { c: 0 } };
////function f(){
//// return a.b ? /*a*//*b*/a.b.c : "whenFalse";
////}
// verify that the refactor is offered for empty spans in return statements.
goTo.select("a", "b");
verify.not.refactorAvailableForTriggerReason("implicit", "Convert to optional chain expression");
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 } };
function f(){
return a.b?.c ?? "whenFalse";
}`,
triggerReason: "invoked"
}); | {
"end_byte": 668,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_EmptySpanConditionalReturnStatement.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageArray.ts_0_556 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
//// function foo([|p, a, b, c, d, e |]) {
//// var x: string = a.pop()
//// b.reverse()
//// var rr: boolean[] = c.reverse()
//// d.some(t => t > 1); // can't infer from callbacks right now
//// var y = e.concat(12); // can't infer from overloaded functions right now
//// return p.push(12)
//// }
verify.rangeAfterCodeFix("p: number[], a: string[], b: any[], c: boolean[], d: any[], e: any[]", /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, /*index*/0);
| {
"end_byte": 556,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageArray.ts"
} |
TypeScript/tests/cases/fourslash/completionsOverridingProperties2.ts_0_506 | /// <reference path="fourslash.ts" />
////interface I {
//// prop: string;
////}
////class C implements I {
//// public pr/**/: string = 'foo';
////}
verify.completions({
marker: "",
includes: [
{ name: "prop", isSnippet: undefined, insertText: undefined }
],
isNewIdentifierLocation: true,
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: true,
includeCompletionsWithClassMemberSnippets: true,
}
});
| {
"end_byte": 506,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingProperties2.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_importType9.ts_0_1290 | /// <reference path="fourslash.ts" />
// @module: es2015
// @esModuleInterop: true
// @jsx: react
// @Filename: /types.d.ts
//// declare module "react" { var React: any; export = React; export as namespace React; }
// @Filename: /component.tsx
//// export function Component() { return <div />; }
// @Filename: /a.tsx
//// import type React from "react";
//// import type { Component } from "./component";
//// (<Component/**/ />)
goTo.marker("");
// It would be preferable for these fixes to be provided simultaneously, like the add-new-import fixes are,
// but this is such a weird edge case that I don't know that it's worth it - the test mainly ensures that
// both fixes are eventually offered without crashing and that they do what they say they're going to do.
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Remove_type_from_import_declaration_from_0.message, "react"],
applyChanges: true,
newFileContent: `import React from "react";
import type { Component } from "./component";
(<Component />)`
});
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Remove_type_from_import_declaration_from_0.message, "./component"],
applyChanges: true,
newFileContent: `import React from "react";
import { Component } from "./component";
(<Component />)`
});
| {
"end_byte": 1290,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_importType9.ts"
} |
TypeScript/tests/cases/fourslash/tsxCompletionInFunctionExpressionOfChildrenCallback.ts_0_733 | /// <reference path='fourslash.ts' />
//@module: commonjs
//@jsx: preserve
// @Filename: 1.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface IUser {
//// Name: string;
//// }
//// interface IFetchUserProps {
//// children: (user: IUser) => any;
//// }
//// function FetchUser(props: IFetchUserProps) { return undefined; }
//// function UserName() {
//// return (
//// <FetchUser>
//// { user => (
//// <h1>{ user./**/ }</h1>
//// )}
//// </FetchUser>
//// );
//// }
verify.completions({ marker: "", exact: undefined });
| {
"end_byte": 733,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletionInFunctionExpressionOfChildrenCallback.ts"
} |
TypeScript/tests/cases/fourslash/tsxFindAllReferences11.ts_0_873 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// interface ButtonProps extends ClickableProps {
//// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// interface LinkProps extends ClickableProps {
//// goTo: string;
//// }
//// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
//// declare function MainButton(linkProps: LinkProps): JSX.Element;
//// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
//// let opt = <MainButton /*1*/wrong />;
verify.baselineFindAllReferences('1');
| {
"end_byte": 873,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxFindAllReferences11.ts"
} |
TypeScript/tests/cases/fourslash/trailingCommaSignatureHelp.ts_0_393 | /// <reference path="fourslash.ts" />
////function str(n: number): string;
/////**
//// * Stringifies a number with radix
//// * @param radix The radix
//// */
////function str(n: number, radix: number): string;
////function str(n: number, radix?: number): string { return ""; }
////
////str(1, /*a*/)
////
////declare function f<T>(a: T): T;
////f(2, /*b*/);
verify.baselineSignatureHelp()
| {
"end_byte": 393,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/trailingCommaSignatureHelp.ts"
} |
TypeScript/tests/cases/fourslash/formatRemoveSpaceBetweenDotDotDotAndTypeName.ts_0_246 | /// <reference path="fourslash.ts"/>
//// let a: [... any[]];
//// let b: [... number[]];
//// let c: [... string[]];
format.document();
verify.currentFileContentIs(
`let a: [...any[]];
let b: [...number[]];
let c: [...string[]];`
);
| {
"end_byte": 246,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatRemoveSpaceBetweenDotDotDotAndTypeName.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForOverloadOnConst1.ts_0_1137 | /// <reference path='fourslash.ts'/>
////interface I {
//// x/*1*/1(a: number, callback: (x: 'hi') => number);
////}
////class C {
//// x/*2*/1(a: number, call/*3*/back: (x: 'hi') => number);
//// x/*4*/1(a: number, call/*5*/back: (x: string) => number) {
//// call/*6*/back('hi');
//// callback('bye');
//// var hm = "hm";
//// callback(hm);
//// }
////}
////var c: C;
////c.x/*7*/1(1, (x/*8*/x: 'hi') => { return 1; } );
////c.x1(1, (x/*9*/x: 'bye') => { return 1; } );
////c.x1(1, (x/*10*/x) => { return 1; } );
verify.quickInfos({
1: "(method) I.x1(a: number, callback: (x: \"hi\") => number): any",
2: "(method) C.x1(a: number, callback: (x: \"hi\") => number): any",
3: "(parameter) callback: (x: \"hi\") => number",
4: "(method) C.x1(a: number, callback: (x: \"hi\") => number): any",
5: "(parameter) callback: (x: string) => number",
6: "(parameter) callback: (x: string) => number",
7: "(method) C.x1(a: number, callback: (x: \"hi\") => number): any",
8: "(parameter) xx: \"hi\"",
9: "(parameter) xx: \"bye\"",
10: "(parameter) xx: \"hi\""
});
| {
"end_byte": 1137,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForOverloadOnConst1.ts"
} |
TypeScript/tests/cases/fourslash/getEmitOutputWithSyntacticErrorsForMultipleFiles2.ts_0_527 | /// <reference path="fourslash.ts" />
// @BaselineFile: getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline
// @outFile: out.js
// @Filename: inputFile1.ts
// @emitThisFile: true
//// // File to emit, does not contain syntactic errors, but --out is passed
//// // expected to not generate outputs because of the syntactic errors in the other file.
//// var noErrors = true;
// @Filename: inputFile2.ts
//// // File not emitted, and contains syntactic errors
//// var syntactic Error;
verify.baselineGetEmitOutput();
| {
"end_byte": 527,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputWithSyntacticErrorsForMultipleFiles2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddOptionalParam17.ts_0_604 | /// <reference path="fourslash.ts" />
////function f(a: string, b: string): string
////function f(a: number, b: number): number
////function f(a: number | string, b: number | string): number | string {
//// return a + b;
////}
////f(1, 2, "")
verify.codeFix({
description: [ts.Diagnostics.Add_optional_parameter_to_0.message, "f"],
index: 1,
newFileContent:
`function f(a: string, b: string, p0?: string): string
function f(a: number, b: number, p0?: string): number
function f(a: number | string, b: number | string, p0?: string): number | string {
return a + b;
}
f(1, 2, "")`
});
| {
"end_byte": 604,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddOptionalParam17.ts"
} |
TypeScript/tests/cases/fourslash/autoImportsNodeNext1.ts_0_766 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @Filename: /node_modules/pack/package.json
//// {
//// "name": "pack",
//// "version": "1.0.0",
//// "exports": {
//// ".": "./main.mjs"
//// }
//// }
// @Filename: /node_modules/pack/main.d.mts
//// import {} from "./unreachable.mjs";
//// export const fromMain = 0;
// @Filename: /node_modules/pack/unreachable.d.mts
//// export const fromUnreachable = 0;
// @Filename: /index.mts
//// import { fromMain } from "pack";
//// fromUnreachable/**/
goTo.marker("");
verify.importFixAtPosition([]);
verify.completions({
marker: "",
excludes: ["fromUnreachable"],
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: false,
}
});
| {
"end_byte": 766,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportsNodeNext1.ts"
} |
TypeScript/tests/cases/fourslash/unclosedArrayErrorRecovery.ts_0_122 | /// <reference path="fourslash.ts" />
////var table: number[;
/////**/table.push(1)
verify.not.errorExistsAfterMarker(); | {
"end_byte": 122,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unclosedArrayErrorRecovery.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageStringIndexSignatureJS.ts_0_392 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noEmit: true
// @noImplicitAny: true
// @Filename: important.js
////function f([|a|]) {
//// return a['hi'];
////}
verify.codeFix({
index: 0,
description: "Infer parameter types from usage",
newFileContent:
`/**
* @param {{ [x: string]: any; }} a
*/
function f(a) {
return a['hi'];
}`,
});
| {
"end_byte": 392,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageStringIndexSignatureJS.ts"
} |
TypeScript/tests/cases/fourslash/formatNestedClassWithOpenBraceOnNewLines.ts_0_353 | /// <reference path="fourslash.ts" />
////module A
////{
//// class B {
//// /*1*/
////}
format.setOption("PlaceOpenBraceOnNewLineForControlBlocks", true);
format.setOption("PlaceOpenBraceOnNewLineForFunctions", true);
goTo.marker("1");
edit.insert("}");
verify.currentFileContentIs(
"module A\n\
{\n\
class B\n\
{\n\
}\n\
}"
); | {
"end_byte": 353,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatNestedClassWithOpenBraceOnNewLines.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnErrorTypes1.ts_0_164 | /// <reference path='fourslash.ts' />
////var /*A*/f: {
//// x: number;
//// <
////};
verify.quickInfoAt("A", "var f: {\n (): any;\n x: number;\n}");
| {
"end_byte": 164,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnErrorTypes1.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpNegativeTests2.ts_0_269 | /// <reference path='fourslash.ts'/>
////class clsOverload { constructor(); constructor(test: string); constructor(test?: string) { } }
////var x = new clsOverload/*beforeOpenParen*/()/*afterCloseParen*/;
verify.noSignatureHelp("beforeOpenParen", "afterCloseParen");
| {
"end_byte": 269,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpNegativeTests2.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.