_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/breakpointValidationImport.ts_0_297 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_import.baseline
// @Filename: bpSpan_import.ts
////module m {
//// class c {
//// }
////}
////import a = m.c;
////export import b = m.c;
////var x = new a();
////var y = new b();
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 297,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationImport.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefs_jsEnum.ts_0_265 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: /a.js
/////** @enum {string} */
/////*1*/const /*2*/E = { A: "" };
/////*3*/E["A"];
/////** @type {/*4*/E} */
////const e = /*5*/E.A;
verify.baselineFindAllReferences('1', '2', '3', '4', '5'); | {
"end_byte": 265,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefs_jsEnum.ts"
} |
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc9.5.ts_0_333 | /// <reference path='fourslash.ts' />
/////**
//// * @template T
//// * @param {T} x
//// * @returns {T}
//// */
////var f = /*a*/x/*b*/ => x
verify.codeFix({
index: 0,
description: "Annotate with type from JSDoc",
newFileContent:
`/**
* @template T
* @param {T} x
* @returns {T}
*/
var f = <T>(x: T): T => x`,
});
| {
"end_byte": 333,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc9.5.ts"
} |
TypeScript/tests/cases/fourslash/constructorFindAllReferences1.ts_0_191 | /// <reference path="fourslash.ts" />
////export class C {
//// /**/public constructor() { }
//// public foo() { }
////}
////
////new C().foo();
verify.baselineFindAllReferences("");
| {
"end_byte": 191,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/constructorFindAllReferences1.ts"
} |
TypeScript/tests/cases/fourslash/exhaustiveCaseCompletions7.ts_0_630 | /// <reference path="fourslash.ts" />
// @newline: LF
////export function foo(position: -1 | 0 | 1) {
//// switch (position) {
//// /**/
//// }
////}
verify.completions(
{
marker: "",
isNewIdentifierLocation: false,
includes: [
{
name: "case 0: ...",
source: completion.CompletionSource.SwitchCases,
sortText: completion.SortText.GlobalsOrKeywords,
insertText:
`case 0:
case 1:
case -1:`,
},
],
preferences: {
includeCompletionsWithInsertText: true,
},
},
);
| {
"end_byte": 630,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/exhaustiveCaseCompletions7.ts"
} |
TypeScript/tests/cases/fourslash/referencesForNumericLiteralPropertyNames.ts_0_200 | /// <reference path='fourslash.ts'/>
////class Foo {
//// public /*1*/12: any;
////}
////
////var x: Foo;
////x[12];
////x = { "12": 0 };
////x = { 12: 0 };
verify.baselineFindAllReferences('1')
| {
"end_byte": 200,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForNumericLiteralPropertyNames.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsInteractiveOverloadCall.ts_0_764 | /// <reference path="fourslash.ts" />
//// interface Call {
//// (a: number): void
//// (b: number, c: number): void
//// new (d: number): Call
//// }
//// declare const call: Call;
//// call(1);
//// call(1, 2);
//// new call(1);
//// declare function foo(w: number): void
//// declare function foo(a: number, b: number): void;
//// declare function foo(a: number | undefined, b: number | undefined): void;
//// foo(1)
//// foo(1, 2)
//// class Class {
//// constructor(a: number);
//// constructor(b: number, c: number);
//// constructor(b: number, c?: number) { }
//// }
//// new Class(1)
//// new Class(1, 2)
verify.baselineInlayHints(undefined, {
includeInlayParameterNameHints: "literals",
interactiveInlayHints: true
});
| {
"end_byte": 764,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveOverloadCall.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsIsDefinition.ts_0_813 | // from #42889
/// <reference path="fourslash.ts" />
//// declare function foo(a: number): number;
//// declare function foo(a: string): string;
//// declare function foo/*1*/(a: string | number): string | number;
////
//// function foon(a: number): number;
//// function foon(a: string): string;
//// function foon/*2*/(a: string | number): string | number {
//// return a
//// }
////
//// foo; foon;
////
//// export const bar/*3*/ = 123;
//// console.log({ bar });
////
//// interface IFoo {
//// foo/*4*/(): void;
//// }
//// class Foo implements IFoo {
//// constructor(n: number)
//// constructor()
//// /*5*/constructor(n: number?) { }
//// foo/*6*/(): void { }
//// static init() { return new this() }
//// }
verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6')
| {
"end_byte": 813,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsIsDefinition.ts"
} |
TypeScript/tests/cases/fourslash/getEditsForFileRename_casing.ts_0_438 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////import { foo } from "./dir/fOo";
// @Filename: /dir/fOo.ts
////export const foo = 0;
// On a case-insensitive file system (like fourslash uses), there was a bug where we used the canonicalized path suffix.
verify.getEditsForFileRename({
oldPath: "/dir",
newPath: "/newDir",
newFileContents: {
"/a.ts":
`import { foo } from "./newDir/fOo";`,
},
});
| {
"end_byte": 438,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_casing.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefs_importType_js.ts_0_348 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @Filename: /a.js
/////**/module.exports = class C {};
////module.exports.D = class D {};
// @Filename: /b.js
/////** @type {import("./a")} */
////const x = 0;
/////** @type {import("./a").D} */
////const y = 0;
verify.noErrors();
verify.baselineFindAllReferences(""); | {
"end_byte": 348,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefs_importType_js.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_emptyRanges.ts_0_216 | /// <reference path="fourslash.ts" />
////class HomePage {
//// componentDidMount(/*1*/) {
//// if (this.props.username/*2*/) {
//// return '/*3*/';
//// }
//// }
////}
verify.baselineSmartSelection(); | {
"end_byte": 216,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_emptyRanges.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddOptionalParam10.ts_0_310 | /// <reference path="fourslash.ts" />
////[|function f() {}|]
////
////const a = 1;
////const b = "";
////f(a, b, true);
verify.codeFix({
description: [ts.Diagnostics.Add_optional_parameters_to_0.message, "f"],
index: 1,
newRangeContent: "function f(a?: number, b?: string, p0?: boolean) {}"
});
| {
"end_byte": 310,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddOptionalParam10.ts"
} |
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction7.ts_0_267 | /// <reference path='fourslash.ts' />
// @target: es2015
////async function fn(): any {}
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Replace_0_with_Promise_1.message, "any", "any"],
newFileContent: `async function fn(): Promise<any> {}`
});
| {
"end_byte": 267,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction7.ts"
} |
TypeScript/tests/cases/fourslash/renameFromNodeModulesDep2.ts_0_1382 | /// <reference path="fourslash.ts" />
// @Filename: /node_modules/first/index.d.ts
////import { /*okWithAlias*/[|Foo|] } from "foo";
////declare type FooBar = Foo[/*notOk*/"bar"];
// @Filename: /node_modules/first/node_modules/foo/package.json
//// { "types": "index.d.ts" }
// @Filename: /node_modules/first/node_modules/foo/index.d.ts
////export interface Foo {
//// /*ok2*/[|bar|]: string;
////}
// @Filename: /node_modules/first/node_modules/foo/bar.d.ts
////import { Foo } from "./index";
////declare type FooBar = Foo[/*ok3*/"[|bar|]"];
const [ okWithAliasRange, ok2Range, ok3Range ] = test.ranges();
goTo.marker("okWithAlias");
verify.renameInfoSucceeded(
undefined,
undefined,
undefined,
undefined,
undefined,
okWithAliasRange,
{ providePrefixAndSuffixTextForRename: true });
verify.renameInfoFailed(
"You cannot rename elements that are defined in another 'node_modules' folder.",
{ providePrefixAndSuffixTextForRename: false });
goTo.marker("notOk");
verify.renameInfoFailed("You cannot rename elements that are defined in another 'node_modules' folder.");
goTo.marker("ok2");
verify.renameInfoSucceeded(
undefined,
undefined,
undefined,
undefined,
undefined,
ok2Range);
goTo.marker("ok3");
verify.renameInfoSucceeded(undefined,
undefined,
undefined,
undefined,
undefined,
ok3Range);
| {
"end_byte": 1382,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameFromNodeModulesDep2.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedIndexSignature01.ts_0_158 | /// <reference path='fourslash.ts' />
////class C {
//// [foo: string]: typeof /*1*/
////}
verify.completions({ marker: "1", includes: ["foo", "C"] });
| {
"end_byte": 158,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedIndexSignature01.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_asKeyword.ts_0_212 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export function as() {}
// @Filename: /b.ts
////1 a/*1*/
////a/*2*/
verify.baselineCompletions({
includeCompletionsForModuleExports: true,
});
| {
"end_byte": 212,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_asKeyword.ts"
} |
TypeScript/tests/cases/fourslash/isDefinitionInterfaceImplementation.ts_0_233 | /// <reference path='fourslash.ts'/>
////interface I {
//// /*1*/M(): void;
////}
////
////class C implements I {
//// /*2*/M() { }
////}
////
////({} as I).M();
////({} as C).M();
verify.baselineFindAllReferences('1', '2');
| {
"end_byte": 233,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/isDefinitionInterfaceImplementation.ts"
} |
TypeScript/tests/cases/fourslash/callHierarchyClass.ts_0_219 | /// <reference path="fourslash.ts" />
//// function foo() {
//// bar();
//// }
////
//// function /**/bar() {
//// new Baz();
//// }
////
//// class Baz {
//// }
goTo.marker();
verify.baselineCallHierarchy();
| {
"end_byte": 219,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyClass.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingDeclareProperty2.ts_0_490 | /// <reference path='fourslash.ts' />
// @useDefineForClassFields: true
////class B {
//// p = 1
////}
////class C extends B {
//// p: number
////}
////class D extends B {
//// p: 1 | 2 | 3
////}
verify.codeFixAll({
fixId: "addMissingDeclareProperty",
fixAllDescription: "Prefix all incorrect property declarations with 'declare'",
newFileContent: `class B {
p = 1
}
class C extends B {
declare p: number
}
class D extends B {
declare p: 1 | 2 | 3
}`
});
| {
"end_byte": 490,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingDeclareProperty2.ts"
} |
TypeScript/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts_0_522 | /// <reference path='fourslash.ts' />
// @Filename: a.ts
////[|export var /*1*/[|{| "isDefinition": true, "contextRangeIndex": 0 |}a|];|]
// @Filename: b.ts
////[|import { /*2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}a|] } from './a';|]
////[|export { /*3*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}a|] };|]
const [r0Def, r0, r1Def, r1, r2Def, r2] = test.ranges();
verify.baselineFindAllReferences('1', '2', '3');
verify.baselineRename([r0, r1, r2]); | {
"end_byte": 522,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts"
} |
TypeScript/tests/cases/fourslash/duplicateFunctionImplementation.ts_0_239 | /// <reference path="fourslash.ts" />
//// interface IFoo<T> {
//// foo<T>(): T;
//// }
//// function foo<string>(/**/): string { return null; }
//// function foo<T>(x: T): T { return null; }
goTo.marker();
edit.insert("x: string");
| {
"end_byte": 239,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/duplicateFunctionImplementation.ts"
} |
TypeScript/tests/cases/fourslash/unusedTypeParametersInFunction2.ts_0_245 | /// <reference path='fourslash.ts' />
// @noUnusedParameters: true
//// [|function f1<X, Y>(a: X) {a}|]
verify.codeFix({
description: "Remove unused declaration for: 'Y'",
index: 0,
newRangeContent: "function f1<X>(a: X) {a}",
});
| {
"end_byte": 245,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedTypeParametersInFunction2.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodCalls.ts_0_662 | /// <reference path='fourslash.ts' />
////class Foo {
//// /*a*/bar/*b*/(t: string, s: string): string {
//// return s + t;
//// }
////}
////var foo = new Foo();
////foo['bar']("a", "b");
////foo.bar("a", "b");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `class Foo {
bar({ t, s }: { t: string; s: string; }): string {
return s + t;
}
}
var foo = new Foo();
foo['bar']({ t: "a", s: "b" });
foo.bar({ t: "a", s: "b" });`
}); | {
"end_byte": 662,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodCalls.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationInterface_03.ts_0_294 | /// <reference path='fourslash.ts'/>
// Should go to object literals within cast expressions when invoked on interface
//// interface Fo/*interface_definition*/o { hello: () => void }
////
//// var x = <Foo> [|{ hello: () => {} }|];
verify.baselineGoToImplementation("interface_definition"); | {
"end_byte": 294,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationInterface_03.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_decorators.ts_0_900 | /// <reference path='fourslash.ts' />
// @experimentalDecorators: true
// @Filename: /a.ts
////const decorator1: any = () => {};
////const decorator2: any = () => {};
////[|class Foo {
//// constructor(@decorator1 private readonly x: number,
//// @decorator1 @decorator2 private readonly y: number) { }
////
//// method1(@decorator1 x: number) { }
//// method2(@decorator1 @decorator2 x: number) { }
////}|]
verify.noErrors();
verify.moveToNewFile({
newFileContents: {
"/a.ts":
`export const decorator1: any = () => {};
export const decorator2: any = () => {};
`,
"/Foo.ts":
`import { decorator1, decorator2 } from "./a";
class Foo {
constructor(@decorator1 private readonly x: number,
@decorator1 @decorator2 private readonly y: number) { }
method1(@decorator1 x: number) { }
method2(@decorator1 @decorator2 x: number) { }
}
`
}
});
| {
"end_byte": 900,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_decorators.ts"
} |
TypeScript/tests/cases/fourslash/importStatementCompletions_esModuleInterop1.ts_0_690 | /// <reference path="fourslash.ts" />
// @esModuleInterop: false
// @Filename: /mod.ts
//// const foo = 0;
//// export = foo;
// @Filename: /importExportEquals.ts
//// [|import f/**/|]
verify.completions({
isNewIdentifierLocation: true,
marker: "",
exact: [{
name: "foo",
source: "./mod",
insertText: `import foo$1 = require("./mod");`,
isSnippet: true,
replacementSpan: test.ranges()[0],
sourceDisplay: "./mod",
}, {
name: "type",
sortText: completion.SortText.GlobalsOrKeywords,
}],
preferences: {
includeCompletionsForImportStatements: true,
includeInsertTextCompletions: true,
includeCompletionsWithSnippetText: true,
}
});
| {
"end_byte": 690,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importStatementCompletions_esModuleInterop1.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixExistingImport5.ts_0_251 | /// <reference path="fourslash.ts" />
//// [|import "./module";
//// f1/*0*/();|]
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
verify.importFixAtPosition([`import "./module";
import { f1 } from "./module";
f1();`]);
| {
"end_byte": 251,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixExistingImport5.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports22-formatting.ts_0_386 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
// @lib: es2019
/////**
//// * Test
//// */
////export function foo(){}
verify.codeFixAvailable([
{ description: "Add return type 'void'" }
]);
verify.codeFix({
description: "Add return type 'void'",
index: 0,
newFileContent:
`/**
* Test
*/
export function foo(): void{}`
}); | {
"end_byte": 386,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports22-formatting.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_jsx2.ts_0_736 | /// <reference path="fourslash.ts" />
// @jsx: react
// @module: esnext
// @esModuleInterop: true
// @moduleResolution: node
// @Filename: /node_modules/react/index.d.ts
////export = React;
////export as namespace React;
////declare namespace React {
//// class Component {}
////}
// @Filename: /node_modules/react-native/index.d.ts
////import * as React from "react";
////export class Text extends React.Component {};
// @Filename: /a.tsx
////import React from "react";
////<[|Text|]></Text>;
goTo.file("/a.tsx");
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Add_import_from_0.message, "react-native"],
newFileContent:
`import React from "react";
import { Text } from "react-native";
<Text></Text>;`
});
| {
"end_byte": 736,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_jsx2.ts"
} |
TypeScript/tests/cases/fourslash/inlineVariableShorthandPropertyAssignment.ts_0_329 | /// <reference path="fourslash.ts" />
////const foo = 1;
////const bar = { /*a*/foo/*b*/ };
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Inline variable",
actionName: "Inline variable",
actionDescription: "Inline variable",
newContent: "const bar = { foo: 1 };",
triggerReason: "invoked",
});
| {
"end_byte": 329,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableShorthandPropertyAssignment.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentIfStatement.ts_0_511 | /// <reference path='fourslash.ts'/>
//// if /*1*/(true) { }
////
//// if (true) /*2*/ { /*3*/
//// } /*4*/
////
//// if (1 === /*5*/ 2) { }
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
goTo.marker(marker);
edit.insert("\n");
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 4);
verifyIndentationAfterNewLine("2", 0);
verifyIndentationAfterNewLine("3", 4);
verifyIndentationAfterNewLine("4", 0);
verifyIndentationAfterNewLine("5", 4); | {
"end_byte": 511,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentIfStatement.ts"
} |
TypeScript/tests/cases/fourslash/incompleteFunctionCallCodefix.ts_0_219 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
////function f(/*1*/x) {
//// x;
////}
////f(
goTo.marker('1');
verify.codeFixAvailable([
{ "description": "Infer parameter types from usage" }
]);
| {
"end_byte": 219,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incompleteFunctionCallCodefix.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnon_FnArgument.ts_0_424 | /// <reference path='fourslash.ts' />
//// function doSomething(a){}
//// doSomething(/*x*/(/*y*/) => 1 + 1);
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to anonymous function",
actionDescription: "Convert to anonymous function",
newContent: `function doSomething(a){}
doSomething(function() {
return 1 + 1;
});`,
});
| {
"end_byte": 424,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnon_FnArgument.ts"
} |
TypeScript/tests/cases/fourslash/renameExportSpecifier2.ts_0_263 | /// <reference path="fourslash.ts" />
// @Filename: a.ts
////const name = {};
////export { name/**/ };
// @Filename: b.ts
////import { name } from './a';
////const x = name.toString();
verify.baselineRename("", { providePrefixAndSuffixTextForRename: false });
| {
"end_byte": 263,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameExportSpecifier2.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsTripleSlash10.ts_0_368 | /// <reference path="fourslash.ts"/>
//// /// <reference path="./module.ts"
const c = classification("original");
verify.syntacticClassificationsAre(
c.comment("/// "),
c.punctuation("<"),
c.jsxSelfClosingTagName("reference"),
c.comment(" "),
c.jsxAttribute("path"),
c.operator("="),
c.jsxAttributeStringLiteralValue("\"./module.ts\""));
| {
"end_byte": 368,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsTripleSlash10.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration12.ts_0_540 | /// <reference path='fourslash.ts' />
// @filename: /test.ts
////export const x = 1;
// @filename: /foo.ts
////import * as test from "./test";
////test.foo();
////test.foo();
////test.foo();
goTo.file("/foo.ts");
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "foo"],
applyChanges: true,
newFileContent: {
"/test.ts":
`export const x = 1;
export function foo() {
throw new Error("Function not implemented.");
}
`
}
});
verify.not.codeFixAvailable();
| {
"end_byte": 540,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration12.ts"
} |
TypeScript/tests/cases/fourslash/extractSymbolForTriggerReason2.ts_0_338 | /// <reference path='fourslash.ts' />
////const foo = ba/*a*/r + b/*b*/az;
// Expand selection to fit nodes if refactors are explicitly requested
goTo.select("a", "b");
verify.not.refactorAvailableForTriggerReason("implicit", "Extract Symbol");
verify.refactorAvailableForTriggerReason("invoked", "Extract Symbol", "constant_scope_0");
| {
"end_byte": 338,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extractSymbolForTriggerReason2.ts"
} |
TypeScript/tests/cases/fourslash/referencesForExpressionKeywords.ts_0_464 | /// <reference path='fourslash.ts'/>
////class C {
//// static x = 1;
////}
/////*new*/new C();
/////*void*/void C;
/////*typeof*/typeof C;
/////*delete*/delete C.x;
/////*async*/async function* f() {
//// /*yield*/yield C;
//// /*await*/await C;
////}
////"x" /*in*/in C;
////undefined /*instanceof*/instanceof C;
////undefined /*as*/as C;
verify.baselineFindAllReferences('new', 'void', 'typeof', 'yield', 'await', 'in', 'instanceof', 'as', 'delete')
| {
"end_byte": 464,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForExpressionKeywords.ts"
} |
TypeScript/tests/cases/fourslash/completionOfAwaitPromise6.ts_0_317 | /// <reference path='fourslash.ts'/>
//// async function foo(x: Promise<string>) {
//// [|x./**/|]
//// }
const replacementSpan = test.ranges()[0]
verify.completions({
marker: "",
exact: [
"catch",
"then",
],
preferences: {
includeInsertTextCompletions: false,
},
});
| {
"end_byte": 317,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionOfAwaitPromise6.ts"
} |
TypeScript/tests/cases/fourslash/formattingQMark.ts_0_271 | /// <reference path='fourslash.ts'/>
////interface A {
/////*1*/ foo? ();
/////*2*/ foo? <T>();
////}
format.document();
goTo.marker("1");
verify.currentLineContentIs(" foo?();");
goTo.marker("2");
verify.currentLineContentIs(" foo?<T>();"); | {
"end_byte": 271,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingQMark.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_NotForOutOfOrderSequence.ts_0_298 | /// <reference path='fourslash.ts' />
////let a = { b: 0 };
////let x = { b: 0 };
/////*a*/a && x && a.b && x.y;/*b*/
// We don't currently offer a refactor for this case but should add it in the future.
goTo.select("a", "b");
verify.not.refactorAvailable("Convert to optional chain expression"); | {
"end_byte": 298,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_NotForOutOfOrderSequence.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsClassWithStaticThisAccess.ts_0_474 | /// <reference path="fourslash.ts" />
////[|class /*0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}C|] {
//// static s() {
//// /*1*/[|this|];
//// }
//// static get f() {
//// return /*2*/[|this|];
////
//// function inner() { this; }
//// class Inner { x = this; }
//// }
////}|]
const [r0Def, r0, r1, r2] = test.ranges();
verify.baselineFindAllReferences('0', '1', '2');
verify.baselineRename(r0)
| {
"end_byte": 474,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsClassWithStaticThisAccess.ts"
} |
TypeScript/tests/cases/fourslash/linkedEditingJsxTag9.ts_0_2068 | /// <reference path='fourslash.ts' />
// the content of whitespace.tsx
//const whitespaceOpening = (
// < div >
// </div>
//);
//const whitespaceClosing = (
// </div>
// </ div >
//);
//const triviaOpening = (
// /* this is comment */</* more comment */ div /* comments */>Hello
// </ /* even more comment */ div /* bye */>
//);
// @Filename: /whitespace.tsx
////const whitespaceOpening = (
//// </*0*/ /*1*/div/*2*/ /*3*/> /*4*/
//// <//*5*/di/*6*/v>
////);
////const whitespaceClosing = (
//// </*7*/di/*8*/v>
//// <//*9*/ /*10*/div/*11*/ /*12*/> /*13*/
////);
////const triviaOpening = (
//// /* this is/*14*/ comment *//*15*/</*16*//* /*17*/more/*18*/ comment *//*19*/ di/*20*/v /* comments */>/*21*/Hello/*22*/
//// <//*23*/ /*24*///*25*/* even/*26*/ more comment *//*27*/ d/*28*/iv /* b/*29*/ye */>
////);
const wordPattern = "[a-zA-Z0-9:\\-\\._$]*";
const markers = test.markers();
const linkedCursors1 = {
ranges: [{ start: markers[1].position, length: 3 }, { start: markers[5].position, length: 3 }],
wordPattern,
};
const linkedCursors2 = {
ranges: [{ start: markers[7].position, length: 3 }, { start: markers[10].position, length: 3 }],
wordPattern,
};
const linkedCursors3 = {
ranges: [{ start: markers[20].position - 2, length: 3 }, { start: markers[28].position - 1, length: 3 }],
wordPattern,
};
verify.linkedEditing( {
"0": undefined,
"1": linkedCursors1,
"2": linkedCursors1,
"3": undefined,
"4": undefined,
"5": linkedCursors1,
"6": linkedCursors1,
"7": linkedCursors2,
"8": linkedCursors2,
"9": undefined,
"10": linkedCursors2,
"11": linkedCursors2,
"12": undefined,
"13": undefined,
"14": undefined,
"15": undefined,
"16": undefined,
"17": undefined,
"18": undefined,
"19": undefined,
"20": linkedCursors3,
"21": undefined,
"22": undefined,
"23": undefined,
"24": undefined,
"25": undefined,
"26": undefined,
"27": undefined,
"28": linkedCursors3,
"29": undefined
});
| {
"end_byte": 2068,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/linkedEditingJsxTag9.ts"
} |
TypeScript/tests/cases/fourslash/formattingIllegalImportClause.ts_0_620 | /// <reference path='fourslash.ts' />
//// var expect = require('expect.js');
//// import React from 'react'/*1*/;
//// import { mount } from 'enzyme';
//// require('../setup');
//// var Amount = require('../../src/js/components/amount');
//// describe('<Failed />', () => {
//// var history
//// beforeEach(() => {
//// history = createMemoryHistory();
//// sinon.spy(history, 'pushState');
//// });
//// afterEach(() => {
//// })
//// it('redirects to order summary', () => {
//// });
//// });
format.document();
goTo.marker("1");
verify.currentLineContentIs("import React from 'react';") | {
"end_byte": 620,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingIllegalImportClause.ts"
} |
TypeScript/tests/cases/fourslash/semanticModernClassificationCallableVariables.ts_0_1345 | //// class A { onEvent: () => void; }
//// const x = new A().onEvent;
//// const match = (s: any) => x();
//// const other = match;
//// match({ other });
//// interface B = { (): string; }; var b: B
//// var s: String;
//// var t: { (): string; foo: string};
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("class.declaration", "A"),
c2.semanticToken("member.declaration", "onEvent"),
c2.semanticToken("function.declaration.readonly", "x"),
c2.semanticToken("class", "A"),
c2.semanticToken("member", "onEvent"),
c2.semanticToken("function.declaration.readonly", "match"),
c2.semanticToken("parameter.declaration", "s"),
c2.semanticToken("function.readonly", "x"),
c2.semanticToken("function.declaration.readonly", "other"),
c2.semanticToken("function.readonly", "match"),
c2.semanticToken("function.readonly", "match"),
c2.semanticToken("member.declaration", "other"),
c2.semanticToken("interface.declaration", "B"),
c2.semanticToken("variable.declaration", "b"),
c2.semanticToken("interface", "B"),
c2.semanticToken("variable.declaration", "s"),
c2.semanticToken("interface.defaultLibrary", "String"),
c2.semanticToken("variable.declaration", "t"),
c2.semanticToken("property.declaration", "foo"),
);; | {
"end_byte": 1345,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semanticModernClassificationCallableVariables.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoInheritDoc3.ts_0_471 | /// <reference path="fourslash.ts" />
// @noEmit: true
// @allowJs: true
// @Filename: quickInfoInheritDoc3.ts
////function getBaseClass() {
//// return class Base {
//// /**
//// * Base.prop
//// */
//// prop: string | undefined;
//// }
////}
////class SubClass extends getBaseClass() {
//// /**
//// * @inheritdoc
//// * SubClass.prop
//// */
//// /*1*/prop: string | undefined;
////}
verify.baselineQuickInfo(); | {
"end_byte": 471,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoInheritDoc3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixConstToLet1.ts_0_192 | /// <reference path='fourslash.ts' />
////const x = 42;
////x = 75;
verify.codeFix({
description: "Convert 'const' to 'let'",
index: 0,
newFileContent:
`let x = 42;
x = 75;`
});
| {
"end_byte": 192,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConstToLet1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties23.ts_0_292 | /// <reference path="fourslash.ts" />
////enum E {
//// A
////}
////let obj: Record<E, any> = {}
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newFileContent:
`enum E {
A
}
let obj: Record<E, any> = {
[E.A]: undefined
}`,
});
| {
"end_byte": 292,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties23.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertImport_namedToNamespace.ts_0_646 | /// <reference path='fourslash.ts' />
/////*a*/import { x, y as z, T } from "m";/*b*/
////const m = 0;
////const o = { x };
////export { x }; // Need a named import for this
////z;
////const n: T = 0;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert import",
actionName: "Convert named imports to namespace import",
actionDescription: "Convert named imports to namespace import",
newContent:
// TODO: GH#23781 (m_1.y shouldn't be indented)
`import * as m_1 from "m";
import { x } from "m";
const m = 0;
const o = { x: m_1.x };
export { x }; // Need a named import for this
m_1.y;
const n: m_1.T = 0;`,
});
| {
"end_byte": 646,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertImport_namedToNamespace.ts"
} |
TypeScript/tests/cases/fourslash/returnTypeOfGenericFunction1.ts_0_254 | /// <reference path='fourslash.ts'/>
////interface WrappedArray<T> {
//// map<U>(iterator: (value: T) => U, context?: any): U[];
////}
////var x: WrappedArray<string>;
////var /**/y = x.map(s => s.length);
verify.quickInfoAt("", "var y: number[]");
| {
"end_byte": 254,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/returnTypeOfGenericFunction1.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_decorators1.ts_0_610 | /// <reference path='fourslash.ts' />
// @experimentalDecorators: true
// @Filename: /a.ts
////const decorator1: any = () => {};
////const decorator2: any = () => {};
////[|class Foo {
//// @decorator1 method1() { }
//// @decorator1 @decorator2 method2() { }
////}|]
verify.noErrors();
verify.moveToNewFile({
newFileContents: {
"/a.ts":
`export const decorator1: any = () => {};
export const decorator2: any = () => {};
`,
"/Foo.ts":
`import { decorator1, decorator2 } from "./a";
class Foo {
@decorator1 method1() { }
@decorator1 @decorator2 method2() { }
}
`
}
});
| {
"end_byte": 610,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_decorators1.ts"
} |
TypeScript/tests/cases/fourslash/nonExistingImport.ts_0_201 | /// <reference path='fourslash.ts' />
////module m {
//// import foo = module(_foo);
//// var n: num/*1*/
////}
verify.completions({ marker: "1", exact: completion.globalTypesPlus(["foo"]) });
| {
"end_byte": 201,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/nonExistingImport.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsInsideWithBlock.ts_0_301 | /// <reference path='fourslash.ts'/>
/////*1*/var /*2*/x = 0;
////
////with ({}) {
//// var y = x; // Reference of x here should not be picked
//// y++; // also reference for y should be ignored
////}
////
/////*3*/x = /*4*/x + 1;
verify.baselineFindAllReferences('1', '2', '3', '4');
| {
"end_byte": 301,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsInsideWithBlock.ts"
} |
TypeScript/tests/cases/fourslash/jsdocDeprecated_suggestion7.ts_0_258 | ///<reference path="fourslash.ts" />
//// enum Direction {
//// Left = -1,
//// Right = 1,
//// }
//// type T = Direction.Left
//// /** @deprecated */
//// const x = 1
//// type x = string
//// var y: x = 'hi'
verify.getSuggestionDiagnostics([]);
| {
"end_byte": 258,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocDeprecated_suggestion7.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports30-inline-import.ts_0_642 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
// @Filename: /person-code.ts
////export type Person = { x: string; }
////export function getPerson() : Person {
//// return null!
////}
// @Filename: /code.ts
////import { getPerson } from "./person-code";
////export const exp = {
//// person: getPerson()
////};
goTo.file("/code.ts");
verify.codeFix({
description: "Add satisfies and an inline type assertion with 'Person'",
index: 1,
newFileContent:
`import { getPerson, Person } from "./person-code";
export const exp = {
person: getPerson() satisfies Person as Person
};`
});
| {
"end_byte": 642,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports30-inline-import.ts"
} |
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class-removeConstructor2.ts_0_389 | // @allowNonTsExtensions: true
// @Filename: test123.js
/// <reference path="./fourslash.ts" />
//// // Comment
//// function /*1*/fn() {
//// this.baz = 10;
//// }
//// fn.prototype.constructor = fn
verify.codeFix({
description: "Convert function to an ES2015 class",
newFileContent:
`// Comment
class fn {
constructor() {
this.baz = 10;
}
}
`,
});
| {
"end_byte": 389,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class-removeConstructor2.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportAllowSyntheticDefaultImports3.ts_0_370 | /// <reference path="fourslash.ts" />
// @AllowSyntheticDefaultImports: false
// @Module: commonjs
// @Filename: a/f1.ts
//// [|export var x = 0;
//// bar/*0*/();|]
// @Filename: a/foo.d.ts
//// declare function bar(): number;
//// export = bar;
//// export as namespace bar;
verify.importFixAtPosition([
`import bar = require("./foo");
export var x = 0;
bar();`
]); | {
"end_byte": 370,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportAllowSyntheticDefaultImports3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixConvertToTypeOnlyImport6.ts_0_639 | /// <reference path="fourslash.ts" />
// @module: esnext
// @verbatimModuleSyntax: true
// @filename: /b.ts
////export interface I {}
////export const foo = {};
// @filename: /a.ts
//// import { I, type foo } from "./b";
//// export declare const x: typeof foo;
goTo.file("/a.ts");
verify.codeFix({
index: 0,
description: ts.Diagnostics.Use_import_type.message,
newFileContent: `import type { I, foo } from "./b";
export declare const x: typeof foo;`,
});
verify.codeFix({
index: 1,
description: `Use 'type I'`,
newFileContent: `import { type I, type foo } from "./b";
export declare const x: typeof foo;`,
});
| {
"end_byte": 639,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToTypeOnlyImport6.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsInteractiveImportType2.ts_0_470 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @Filename: /a.js
//// module.exports.a = 1
// @Filename: /b.js
//// function foo () { return require('./a'); }
//// function bar () { return require('./a').a; }
//// const c = foo()
//// const d = bar()
goTo.file('/b.js')
verify.baselineInlayHints(undefined, {
includeInlayVariableTypeHints: true,
includeInlayFunctionLikeReturnTypeHints: true,
interactiveInlayHints: true
});
| {
"end_byte": 470,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveImportType2.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_EmptySpanVariableStatementBinary.ts_0_602 | /// <reference path='fourslash.ts' />
////let a = { b: { c: 0 } };
////let x = a && a.b && /*a*//*b*/a.b.c;
// verify that the refactor is offered for empty spans in variable 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 } };
let x = a?.b?.c;`,
triggerReason: "invoked"
}); | {
"end_byte": 602,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_EmptySpanVariableStatementBinary.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_simple1.ts_0_219 | /// <reference path="fourslash.ts" />
////class Foo {
//// bar(a, b) {
//// if (/*1*/a === b) {
//// return tr/*2*/ue;
//// }
//// return false;
//// }
////}
verify.baselineSmartSelection();
| {
"end_byte": 219,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_simple1.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportFileDetachedComments.ts_0_448 | /// <reference path="fourslash.ts" />
//// [|/**
//// * This is a comment intended to be attached to this interface
//// */
//// export interface SomeInterface {
//// }
//// f1/*0*/();|]
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
verify.importFixAtPosition([
`import { f1 } from "./module";
/**
* This is a comment intended to be attached to this interface
*/
export interface SomeInterface {
}
f1();`
]);
| {
"end_byte": 448,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportFileDetachedComments.ts"
} |
TypeScript/tests/cases/fourslash/formatSpaceAfterImplementsExtends.ts_0_400 | ///<reference path="fourslash.ts"/>
////class C1 implements Array<string>{
////}
////
////class C2 implements Number{
////}
////
////class C3 extends Array<string>{
////}
////
////class C4 extends Number{
////}
format.document();
verify.currentFileContentIs(
`class C1 implements Array<string> {
}
class C2 implements Number {
}
class C3 extends Array<string> {
}
class C4 extends Number {
}`);
| {
"end_byte": 400,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatSpaceAfterImplementsExtends.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingParam14.ts_0_516 | /// <reference path="fourslash.ts" />
////function f(a: string): string;
////function f(a: string, b: number): string;
////function f(a: string, b?: number): string {
//// return "";
////}
////f("", "", 1);
verify.codeFix({
description: [ts.Diagnostics.Add_missing_parameter_to_0.message, "f"],
index: 0,
newFileContent:
`function f(a: string): string;
function f(a: string, p0: string, b: number): string;
function f(a: string, p0: string, b?: number): string {
return "";
}
f("", "", 1);`
});
| {
"end_byte": 516,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingParam14.ts"
} |
TypeScript/tests/cases/fourslash/toggleMultilineComment8.ts_0_217 | // If the range only contains comments, uncomment all.
//// /*let var[|1 = 1;*/
//// /*let var2 = 2;*/
////
//// /*let var3 |]= 3;*/
verify.toggleMultilineComment(
`let var1 = 1;
let var2 = 2;
let var3 = 3;`); | {
"end_byte": 217,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/toggleMultilineComment8.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnon_MultiParam.ts_0_377 | /// <reference path='fourslash.ts' />
//// const foo = /*x*/(/*y*/a,b,c) => a + 1;
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to anonymous function",
actionDescription: "Convert to anonymous function",
newContent: `const foo = function(a, b, c) {
return a + 1;
};`,
});
| {
"end_byte": 377,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnon_MultiParam.ts"
} |
TypeScript/tests/cases/fourslash/javaScriptModulesWithBackticks.ts_0_216 | ///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: a.js
//// exports.x = 0;
// @Filename: consumer.js
//// var a = require(`./a`);
//// a./**/;
verify.completions({ marker: "", includes: "x" });
| {
"end_byte": 216,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javaScriptModulesWithBackticks.ts"
} |
TypeScript/tests/cases/fourslash/incrementalEditInvocationExpressionAboveInterfaceDeclaration.ts_0_344 | /// <reference path="fourslash.ts" />
////declare function alert(message?: any): void;
/////*1*/
////interface Foo {
//// setISO8601(dString): Date;
////}
// Do resolve without typeCheck
goTo.marker('1');
edit.insert("alert(");
verify.signatureHelp({ text: "alert(message?: any): void" });
// TypeCheck
verify.errorExistsAfterMarker('1'); | {
"end_byte": 344,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incrementalEditInvocationExpressionAboveInterfaceDeclaration.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsInteractiveParameterNamesInSpan1.ts_0_858 | /// <reference path="fourslash.ts" />
//// function foo1 (a: number, b: number) {}
//// function foo2 (c: number, d: number) {}
//// function foo3 (e: number, f: number) {}
//// function foo4 (g: number, h: number) {}
//// function foo5 (i: number, j: number) {}
//// function foo6 (k: number, i: number) {}
//// function c1 () { foo1(/*a*/1, /*b*/2); }
//// function c2 () { foo2(/*c*/1, /*d*/2); }
//// function c3 () { foo3(/*e*/1, /*f*/2); }
//// function c4 () { foo4(/*g*/1, /*h*/2); }
//// function c5 () { foo5(/*i*/1, /*j*/2); }
//// function c6 () { foo6(/*k*/1, /*l*/2); }
const start = test.markerByName('c');
const end = test.markerByName('h');
const span = { start: start.position, length: end.position - start.position };
verify.baselineInlayHints(span, {
includeInlayParameterNameHints: "literals",
interactiveInlayHints: true
})
| {
"end_byte": 858,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveParameterNamesInSpan1.ts"
} |
TypeScript/tests/cases/fourslash/organizeImportsType7.ts_0_1138 | /// <reference path="fourslash.ts" />
//// import { a, type A, b } from "foo";
//// interface Use extends A {}
//// console.log(a, b);
verify.organizeImports(
`import { a, type A, b } from "foo";
interface Use extends A {}
console.log(a, b);`,
/*mode*/ undefined,
{ organizeImportsTypeOrder: "inline" });
edit.replaceLine(0, 'import { a, type A, b } from "foo1";');
verify.organizeImports(
`import { a, type A, b } from "foo1";
interface Use extends A {}
console.log(a, b);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "inline" });
edit.replaceLine(0, 'import { a, type A, b } from "foo2";');
verify.organizeImports(
`import { a, type A, b } from "foo2";
interface Use extends A {}
console.log(a, b);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: true, organizeImportsTypeOrder: "inline"});
edit.replaceLine(0, 'import { a, type A, b } from "foo3";');
verify.organizeImports(
`import { type A, a, b } from "foo3";
interface Use extends A {}
console.log(a, b);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: false, organizeImportsTypeOrder: "inline" }); | {
"end_byte": 1138,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsType7.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_promoteTypeOnly7.ts_0_855 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @allowImportingTsExtensions: true
// @Filename: /exports.ts
//// export interface SomeInterface {}
//// export class SomePig {}
// @Filename: /a.ts
//// import type { SomePig } from "./exports.ts";
//// new SomePig/**/
verify.completions({
marker: "",
includes: [{
name: "SomePig",
source: completion.CompletionSource.TypeOnlyAlias,
hasAction: true,
}]
});
verify.applyCodeActionFromCompletion("", {
name: "SomePig",
source: completion.CompletionSource.TypeOnlyAlias,
description: `Remove 'type' from import declaration from "./exports.ts"`,
newFileContent:
`import { SomePig } from "./exports.ts";
new SomePig`,
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
},
});
| {
"end_byte": 855,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_promoteTypeOnly7.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoJsDocGetterSetter.ts_0_1029 | /// <reference path='fourslash.ts' />
//// class A {
//// /**
//// * getter A
//// * @returns return A
//// */
//// get /*1*/x(): string {
//// return "";
//// }
//// /**
//// * setter A
//// * @param value foo A
//// * @todo empty jsdoc
//// */
//// set /*2*/x(value) { }
//// }
//// // override both getter and setter
//// class B extends A {
//// /**
//// * getter B
//// * @returns return B
//// */
//// get /*3*/x(): string {
//// return "";
//// }
//// /**
//// * setter B
//// * @param value foo B
//// */
//// set /*4*/x(vale) { }
//// }
//// // not override
//// class C extends A { }
//// // only override setter
//// class D extends A {
//// /**
//// * setter D
//// * @param value foo D
//// */
//// set /*5*/x(val: string) { }
//// }
//// new A()./*6*/x = "1";
//// new B()./*7*/x = "1";
//// new C()./*8*/x = "1";
//// new D()./*9*/x = "1";
verify.baselineQuickInfo();
| {
"end_byte": 1029,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocGetterSetter.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoJsDocTextFormatting1.ts_0_1095 | /// <reference path='fourslash.ts'/>
// Regression test for #33386
//// /**
//// * @param {number} var1 **Highlighted text**
//// * @param {string} var2 Another **Highlighted text**
//// */
//// function f1(var1, var2) { }
////
//// /**
//// * @param {number} var1 *Regular text with an asterisk
//// * @param {string} var2 Another *Regular text with an asterisk
//// */
//// function f2(var1, var2) { }
////
//// /**
//// * @param {number} var1
//// * *Regular text with an asterisk
//// * @param {string} var2
//// * Another *Regular text with an asterisk
//// */
//// function f3(var1, var2) { }
////
//// /**
//// * @param {number} var1
//// * **Highlighted text**
//// * @param {string} var2
//// * Another **Highlighted text**
//// */
//// function f4(var1, var2) { }
////
//// /**
//// * @param {number} var1
//// **Highlighted text**
//// * @param {string} var2
//// Another **Highlighted text**
//// */
//// function f5(var1, var2) { }
////
//// f1(/*1*/);
//// f2(/*2*/);
//// f3(/*3*/);
//// f4(/*4*/);
//// f5(/*5*/);
verify.baselineSignatureHelp()
| {
"end_byte": 1095,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTextFormatting1.ts"
} |
TypeScript/tests/cases/fourslash/renameJsThisProperty06.ts_0_329 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: a.js
////var C = class {
//// constructor(y) {
//// this.x = y;
//// }
////}
////[|C.prototype.[|{| "contextRangeIndex": 0 |}z|] = 1;|]
////var t = new C(12);
////[|t.[|{| "contextRangeIndex": 2 |}z|] = 11;|]
verify.baselineRenameAtRangesWithText("z");
| {
"end_byte": 329,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameJsThisProperty06.ts"
} |
TypeScript/tests/cases/fourslash/completionsDotDotDotInObjectLiteral1.ts_0_316 | /// <reference path="fourslash.ts" />
//// // https://github.com/microsoft/TypeScript/issues/57540
////
//// const foo = { b: 100 };
////
//// const bar: {
//// a: number;
//// b: number;
//// } = {
//// a: 42,
//// .../*1*/
//// };
verify.completions({ marker: "1", includes: ["foo"], excludes: ["b"] });
| {
"end_byte": 316,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsDotDotDotInObjectLiteral1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration26.ts_0_477 | /// <reference path="fourslash.ts" />
// @strict: true
////interface Foo {
//// a: ((e: any) => void) | null;
////}
////
////const foo: Foo = {
//// a: fn
////}
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "fn"],
newFileContent:
`interface Foo {
a: ((e: any) => void) | null;
}
const foo: Foo = {
a: fn
}
function fn(e: any): void {
throw new Error("Function not implemented.");
}
`
});
| {
"end_byte": 477,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration26.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration_jsx_all.ts_0_1101 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: /foo.tsx
////interface P {
//// onClick: (a: number, b: string) => void;
////}
////
////const A = ({ onClick }: P) =>
//// <div onClick={onClick}></div>;
////
////const B = () =>
//// <A onClick={handleClick}></A>
////
////const C = () => {
//// return (
//// <A onClick={handleClick}></A>
//// );
////}
goTo.file("/foo.tsx");
verify.codeFixAll({
fixId: "fixMissingFunctionDeclaration",
fixAllDescription: ts.Diagnostics.Add_all_missing_function_declarations.message,
newFileContent: {
"/foo.tsx":
`interface P {
onClick: (a: number, b: string) => void;
}
const A = ({ onClick }: P) =>
<div onClick={onClick}></div>;
const B = () =>
<A onClick={handleClick}></A>
const C = () => {
function handleClick(a: number, b: string): void {
throw new Error("Function not implemented.");
}
return (
<A onClick={handleClick}></A>
);
}
function handleClick(a: number, b: string): void {
throw new Error("Function not implemented.");
}
`
}
});
| {
"end_byte": 1101,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration_jsx_all.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_parameter1.ts_0_203 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
////function g(a, b) { b; }
////g(1, 2);
verify.not.codeFixAvailable("Remove unused declaration for: 'a'");
| {
"end_byte": 203,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_parameter1.ts"
} |
TypeScript/tests/cases/fourslash/getPreProcessedFile.ts_0_1037 | /// <reference path="fourslash.ts" />
// @ModuleResolution: classic
// @Filename: refFile1.ts
//// class D { }
// @Filename: refFile2.ts
//// export class E {}
// @Filename: main.ts
// @ResolveReference: true
//// ///<reference path="refFile1.ts" />
//// ///<reference path = "/*1*/NotExistRef.ts/*2*/" />
//// /*3*////<reference path "invalidRefFile1.ts" />/*4*/
//// import ref2 = require("refFile2");
//// import noExistref2 = require(/*5*/"NotExistRefFile2"/*6*/);
//// import invalidRef1 /*7*/require/*8*/("refFile2");
//// import invalidRef2 = /*9*/requi/*10*/(/*10A*/"refFile2");
//// var obj: /*11*/C/*12*/;
//// var obj1: D;
//// var obj2: ref2.E;
goTo.file("main.ts");
verify.numberOfErrorsInCurrentFile(7);
verify.errorExistsBetweenMarkers("1", "2");
verify.errorExistsBetweenMarkers("3", "4");
verify.errorExistsBetweenMarkers("5", "6");
verify.errorExistsBetweenMarkers("7", "8");
verify.errorExistsBetweenMarkers("9", "10");
verify.errorExistsBetweenMarkers("10", "10A");
verify.errorExistsBetweenMarkers("11", "12");
| {
"end_byte": 1037,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getPreProcessedFile.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsTemplates2.ts_0_696 | /// <reference path="fourslash.ts"/>
////var tiredOfCanonicalExamples =
////`goodbye "${ `hello world` }"
////and ${ `good${ " " }riddance` }`;
const c = classification("original");
verify.syntacticClassificationsAre(
c.keyword("var"), c.identifier("tiredOfCanonicalExamples"), c.operator("="),
c.stringLiteral("`goodbye \"${"), c.stringLiteral("`hello world`"),
c.stringLiteral("}\" \nand ${"), c.stringLiteral("`good${"), c.stringLiteral("\" \""), c.stringLiteral("}riddance`"), c.stringLiteral("}`"), c.punctuation(";"));
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("variable.declaration", "tiredOfCanonicalExamples"),
);
| {
"end_byte": 696,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsTemplates2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnreachableCode.ts_0_952 | /// <reference path='fourslash.ts' />
////function f() {
//// return f();
//// [|return 1;|]
//// function f(a?: EE) { return a; }
//// [|return 2;|]
//// type T = number;
//// interface I {}
//// const enum E {}
//// [|enum EE {}|]
//// namespace N { export type T = number; }
//// [|namespace N { export const x: T = 0; }|]
//// var x: I;
//// [|var y: T = 0;
//// E; N; x; y;|]
////}
verify.getSuggestionDiagnostics(test.ranges().map((range): FourSlashInterface.Diagnostic => ({
message: "Unreachable code detected.",
code: 7027,
reportsUnnecessary: true,
range,
})));
verify.codeFixAll({
fixId: "fixUnreachableCode",
fixAllDescription: "Remove all unreachable code",
newFileContent:
`function f() {
return f();
function f(a?: EE) { return a; }
type T = number;
interface I {}
const enum E {}
namespace N { export type T = number; }
var x: I;
}`,
});
| {
"end_byte": 952,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnreachableCode.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpCommentsClass.ts_0_1273 | /// <reference path='fourslash.ts' />
/////** This is class c2 without constructor*/
////class c2 {
////}
////var i2 = new c2(/*3*/);
////var i2_c = c2;
////class c3 {
//// /** Constructor comment*/
//// constructor() {
//// }
////}
////var i3 = new c3(/*8*/);
////var i3_c = c3;
/////** Class comment*/
////class c4 {
//// /** Constructor comment*/
//// constructor() {
//// }
////}
////var i4 = new c4(/*13*/);
////var i4_c = c4;
/////** Class with statics*/
////class c5 {
//// static s1: number;
////}
////var i5 = new c5(/*18*/);
////var i5_c = c5;
/////** class with statics and constructor*/
////class c6 {
//// /** s1 comment*/
//// static s1: number;
//// /** constructor comment*/
//// constructor() {
//// }
////}
////var i6 = new c6(/*23*/);
////var i6_c = c6;
////
////class a {
//// /**
//// constructor for a
//// @param a this is my a
//// */
//// constructor(a: string) {
//// }
////}
////new a(/*27*/"Hello");
////module m {
//// export module m2 {
//// /** class comment */
//// export class c1 {
//// /** constructor comment*/
//// constructor() {
//// }
//// }
//// }
////}
////var myVar = new m.m2.c1();
verify.baselineSignatureHelp()
| {
"end_byte": 1273,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpCommentsClass.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_imports.ts_0_166 | /// <reference path="fourslash.ts" />
////import { /**/x as y, z } from './z';
////import { b } from './';
////
////console.log(1);
verify.baselineSmartSelection(); | {
"end_byte": 166,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_imports.ts"
} |
TypeScript/tests/cases/fourslash/getImportsOneJs.ts_0_299 | ///<reference path="fourslash.ts"/>
// @checkJs: true
// @Filename: /first.ts
//// export function foo() {
//// return 1;
//// }
// @Filename: /index.js
//// const { foo } = require("./first");
//// function bar() {
//// return 2;
//// }
////
verify.getImports('/index.js', ['/first.ts'])
| {
"end_byte": 299,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getImportsOneJs.ts"
} |
TypeScript/tests/cases/fourslash/completionListInClassExpressionWithTypeParameter.ts_0_408 | ///<reference path="fourslash.ts" />
//// var x = class myClass <TypeParam> {
//// getClassName (){
//// /*0*/
//// var tmp: /*0Type*/;
//// }
//// prop: Ty/*1*/
//// }
verify.completions(
{ marker: "0", excludes: "TypeParam" },
{ marker: ["0Type", "1"], includes: { name: "TypeParam", text: "(type parameter) TypeParam in myClass<TypeParam>", kind: "type parameter" } },
);
| {
"end_byte": 408,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInClassExpressionWithTypeParameter.ts"
} |
TypeScript/tests/cases/fourslash/tsxCompletionOnClosingTag1.ts_3_304 | / <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// div: { ONE: string; TWO: number; }
//// }
//// }
//// var x1 = <div><//**/
verify.completions({ marker: "", exact: "div>" });
| {
"end_byte": 304,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletionOnClosingTag1.ts"
} |
TypeScript/tests/cases/fourslash/autoImportPackageRootPathTypeModule.ts_0_493 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: /node_modules/pkg/package.json
//// {
//// "name": "pkg",
//// "version": "1.0.0",
//// "main": "lib",
//// "type": "module"
//// }
// @Filename: /node_modules/pkg/lib/index.js
//// export function foo() {};
// @Filename: /package.json
//// {
//// "dependencies": {
//// "pkg": "*"
//// }
//// }
// @Filename: /index.ts
//// foo/**/
verify.importFixModuleSpecifiers("", ["pkg/lib"]);
| {
"end_byte": 493,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPackageRootPathTypeModule.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction2.ts_0_362 | /// <reference path='fourslash.ts' />
//// const foo = /*a*/a/*b*/ => ({ a: 1 });
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Add or remove braces in an arrow function",
actionName: "Add braces to arrow function",
actionDescription: "Add braces to arrow function",
newContent: `const foo = a => {
return ({ a: 1 });
};`,
});
| {
"end_byte": 362,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction2.ts"
} |
TypeScript/tests/cases/fourslash/tsxRename4.ts_0_582 | /// <reference path='fourslash.ts' />
// @jsx: preserve
//@Filename: file.tsx
////declare module JSX {
//// interface Element {}
//// interface IntrinsicElements {
//// div: {};
//// }
////}
////[|class [|{| "contextRangeIndex": 0 |}MyClass|] {}|]
////
////[|<[|{| "contextRangeIndex": 2 |}MyClass|]></[|{| "contextRangeIndex": 2 |}MyClass|]>|];
////[|<[|{| "contextRangeIndex": 5 |}MyClass|]/>|];
////
////[|<[|{| "contextRangeIndex": 7 |}div|]> </[|{| "contextRangeIndex": 7 |}div|]>|]
verify.noErrors();
verify.baselineRenameAtRangesWithText("MyClass", "div"); | {
"end_byte": 582,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxRename4.ts"
} |
TypeScript/tests/cases/fourslash/completionsEnum.ts_0_687 | /// <reference path="fourslash.ts" />
////enum E {
//// v
////}
////const enum ES {
//// v = "str",
//// x = "str2"
////}
////const e: E = /*a*/;
////const es: ES = /*b*/;
verify.completions({
marker: "a",
isNewIdentifierLocation: true,
excludes: ["0"],
includes: [
{
name: "E",
isRecommended: true,
sortText: completion.SortText.LocationPriority,
}
],
}, {
marker: "b",
isNewIdentifierLocation: true,
excludes: [`"str"`, `"str2"`],
includes: [
{
name: "ES",
isRecommended: true,
sortText: completion.SortText.LocationPriority,
}
],
});
| {
"end_byte": 687,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsEnum.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarFunctionIndirectlyInVariableDeclaration.ts_0_2075 | /// <reference path="fourslash.ts"/>
////var a = {
//// propA: function() {
//// var c;
//// }
////};
////var b;
////b = {
//// propB: function() {
//// // function must not have an empty body to appear top level
//// var d;
//// }
////};
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "var",
"childItems": [
{
"text": "propA",
"kind": "method",
"childItems": [
{
"text": "c",
"kind": "var"
}
]
}
]
},
{
"text": "b",
"kind": "var"
},
{
"text": "propB",
"kind": "method",
"childItems": [
{
"text": "d",
"kind": "var"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "var"
},
{
"text": "b",
"kind": "var"
},
{
"text": "propB",
"kind": "method"
}
]
},
{
"text": "a",
"kind": "var",
"childItems": [
{
"text": "propA",
"kind": "method"
}
],
"indent": 1
},
{
"text": "propA",
"kind": "method",
"childItems": [
{
"text": "c",
"kind": "var"
}
],
"indent": 2
},
{
"text": "propB",
"kind": "method",
"childItems": [
{
"text": "d",
"kind": "var"
}
],
"indent": 1
}
]);
| {
"end_byte": 2075,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarFunctionIndirectlyInVariableDeclaration.ts"
} |
TypeScript/tests/cases/fourslash/formatNamedExportImport.ts_0_2482 | /// <reference path="fourslash.ts"/>
/////*selectionStart*/
////export { x, y as yy, z } from "foo"/*export1*/
////export{x, y as yy, z}from"bar"/*export2*/
////
////export
/////*exportOpenBrace*/{x,/*exportSpecifier1*/
////y as yy, z/*exportSpecifier2*/ }/*exportCloseBrace*/
//// from/*fromKeywordAutoformat*/
/////*fromKeywordIndent*/
////"foo"/*exportDir*/
////
////import {x, y as yy, z}from "baz"/*import1*/
////
////import/*importOpenBrace*/{x,/*importSpecifier1*/
////y
////as yy,/*importSpecifier2*/
////z}/*importCloseBrace*/
////from "wow"/*importDir*/
/////*selectionEnd*/
////
////export/*formatOnEnter*/{/*formatOnEnterOpenBrace*/
/////*differentLineIndent*/x/*differentLineAutoformat*/
////} from "abc"
////
////export {
/////*incompleteExportDeclIndent*/
/////*incompleteExportDeclIndent2*/
format.selection("selectionStart", "selectionEnd");
goTo.marker("export1");
verify.currentLineContentIs('export { x, y as yy, z } from "foo"');
goTo.marker("export2");
verify.currentLineContentIs('export { x, y as yy, z } from "bar"');
goTo.marker("exportOpenBrace");
verify.currentLineContentIs("export {");
goTo.marker("exportSpecifier1");
verify.currentLineContentIs(" x,");
goTo.marker("exportSpecifier2");
verify.currentLineContentIs(" y as yy, z");
goTo.marker("exportCloseBrace");
verify.currentLineContentIs("}");
goTo.marker("fromKeywordAutoformat");
verify.currentLineContentIs(" from");
goTo.marker("fromKeywordIndent");
verify.indentationIs(4);
goTo.marker("exportDir");
verify.currentLineContentIs(' "foo"');
goTo.marker("import1");
verify.currentLineContentIs('import { x, y as yy, z } from "baz"');
goTo.marker("importOpenBrace");
verify.currentLineContentIs("import {");
goTo.marker("importSpecifier1");
verify.currentLineContentIs(" x,");
goTo.marker("importSpecifier2");
verify.currentLineContentIs(" as yy,");
goTo.marker("importCloseBrace");
verify.currentLineContentIs("}");
goTo.marker("importDir");
verify.currentLineContentIs(' from "wow"');
goTo.marker("formatOnEnter");
edit.insertLine('');
goTo.marker("formatOnEnterOpenBrace");
verify.currentLineContentIs("{");
goTo.marker("differentLineIndent");
verify.indentationIs(4);
edit.insertLine('');
goTo.marker("differentLineAutoformat");
verify.currentLineContentIs(" x");
goTo.marker("incompleteExportDeclIndent")
verify.indentationIs(4);
edit.insert("} from");
goTo.marker("incompleteExportDeclIndent2");
verify.indentationIs(4); | {
"end_byte": 2482,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatNamedExportImport.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceEmptyMultilineBody.ts_0_341 | /// <reference path='fourslash.ts' />
// @lib: es2017
////interface I {
//// x: number;
//// y: number;
////}
////class C implements I {
////}
verify.codeFix({
description: "Implement interface 'I'",
newFileContent:
`interface I {
x: number;
y: number;
}
class C implements I {
x: number;
y: number;
}`,
});
| {
"end_byte": 341,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceEmptyMultilineBody.ts"
} |
TypeScript/tests/cases/fourslash/refactorKind_generateGetAndSetAccessor.ts_0_236 | /// <reference path='fourslash.ts' />
//// class A {
//// /*a*/public a: string;/*b*/
//// }
goTo.select("a", "b");
verify.refactorKindAvailable("refactor.rewrite.property",
[
"refactor.rewrite.property.generateAccessors"
]);
| {
"end_byte": 236,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorKind_generateGetAndSetAccessor.ts"
} |
TypeScript/tests/cases/fourslash/completionImportModuleSpecifierEndingTs.ts_0_448 | /// <reference path='fourslash.ts'/>
//@Filename:test.ts
////export function f(){
//// return 1
////}
//@Filename:module.ts
////import { f } 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": 448,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionImportModuleSpecifierEndingTs.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionExternalModuleName4.ts_0_134 | /// <reference path='fourslash.ts'/>
// @Filename: b.ts
////import n = require('unknown/*1*/');
verify.baselineGoToDefinition("1");
| {
"end_byte": 134,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionExternalModuleName4.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationInterfaceMethod_06.ts_0_1242 | /// <reference path='fourslash.ts'/>
// Should not return references to parent interfaces even if the method is declared there
//// interface SuperFoo {
//// hello (): void;
//// }
////
//// interface Foo extends SuperFoo {
//// someOtherFunction(): void;
//// }
////
//// class Bar implements Foo {
//// [|hello|]() {}
//// someOtherFunction() {}
//// }
////
//// function createFoo(): Foo {
//// return {
//// [|hello|]() {},
//// someOtherFunction() {}
//// };
//// }
////
//// var y: Foo = {
//// [|hello|]() {},
//// someOtherFunction() {}
//// };
////
//// class FooLike implements SuperFoo {
//// hello() {}
//// someOtherFunction() {}
//// }
////
//// class NotRelatedToFoo {
//// hello() {} // This case is equivalent to the last case, but is not returned because it does not share a common ancestor with Foo
//// someOtherFunction() {}
//// }
////
//// class NotFoo implements SuperFoo {
//// hello() {} // We only want implementations of Foo, even though the function is declared in SuperFoo
//// }
////
//// function (x: Foo) {
//// x.he/*function_call*/llo()
//// }
verify.baselineGoToImplementation("function_call"); | {
"end_byte": 1242,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationInterfaceMethod_06.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentObjectBindingPattern01.ts_3_452 | / <reference path="fourslash.ts"/>
////var /*1*/{/*2*/a,/*3*/b:/*4*/k,/*5*/
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
goTo.marker(marker);
edit.insert("\n");
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 4);
verifyIndentationAfterNewLine("2", 8);
verifyIndentationAfterNewLine("3", 8);
verifyIndentationAfterNewLine("4", 8);
verifyIndentationAfterNewLine("5", 8);
| {
"end_byte": 452,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentObjectBindingPattern01.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpIteratorNext.ts_0_639 | /// <reference path='fourslash.ts' />
// @lib: esnext
//// declare const iterator: Iterator<string, void, number>;
////
//// iterator.next(/*1*/);
//// iterator.next(/*2*/ 0);
////
//// declare const generator: Generator<string, void, number>;
////
//// generator.next(/*3*/);
//// generator.next(/*4*/ 0);
////
//// declare const asyncIterator: AsyncIterator<string, void, number>;
////
//// asyncIterator.next(/*5*/);
//// asyncIterator.next(/*6*/ 0);
////
//// declare const asyncGenerator: AsyncGenerator<string, void, number>;
////
//// asyncGenerator.next(/*7*/);
//// asyncGenerator.next(/*8*/ 0);
verify.baselineSignatureHelp();
| {
"end_byte": 639,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpIteratorNext.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_prologueDirectives3.ts_0_108 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////[|"use strict";|]
verify.noMoveToNewFile();
| {
"end_byte": 108,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_prologueDirectives3.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.