_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/renameJsPropertyAssignment4.ts_0_208 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: /a.js
////function f() {
//// var /*1*/foo = this;
//// /*2*/foo.x = 1;
////}
goTo.file("/a.js")
verify.baselineRename(["1", "2"]);
| {
"end_byte": 208,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameJsPropertyAssignment4.ts"
} |
TypeScript/tests/cases/fourslash/callHierarchyFunctionAmbiguity.1.ts_0_338 | /// <reference path="fourslash.ts" />
// @filename: a.d.ts
//// declare function foo(x?: number): void;
// @filename: b.d.ts
//// declare function foo(x?: string): void;
//// declare function foo(x?: boolean): void;
// @filename: main.ts
//// function bar() {
//// /**/foo();
//// }
goTo.marker();
verify.baselineCallHierarchy();
| {
"end_byte": 338,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyFunctionAmbiguity.1.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpImportStarFromExportEquals.ts_0_333 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: /node_modules/@types/abs/index.d.ts
////declare function abs(str: string): string;
////export = abs;
// @Filename: /a.js
////import * as abs from "abs";
////abs/**/;
goTo.marker();
edit.insert('(');
verify.signatureHelp({ text: "abs(str: string): string" });
| {
"end_byte": 333,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpImportStarFromExportEquals.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsLet.ts_0_535 | /// <reference path='fourslash.ts'/>
////let /*1*/a = 10;
////function foo() {
//// let /*2*/b = /*3*/a;
//// if (b) {
//// let /*4*/b1 = 10;
//// }
////}
////module m {
//// let /*5*/c = 10;
//// export let /*6*/d = 10;
//// if (c) {
//// let /*7*/e = 10;
//// }
////}
////let /*8*/f: () => number;
////let /*9*/g = /*10*/f;
/////*11*/f();
////let /*12*/h: { (a: string): number; (a: number): string; };
////let /*13*/i = /*14*/h;
/////*15*/h(10);
/////*16*/h("hello");
verify.baselineQuickInfo(); | {
"end_byte": 535,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsLet.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports19.ts_0_369 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
// @lib: es2019
////export const a = {
//// z: Symbol()
////} as const;
verify.codeFix({
description: `Add annotation of type '{ readonly z: symbol; }'`,
index: 0,
newFileContent:
`export const a: {
readonly z: symbol;
} = {
z: Symbol()
} as const;`
});
| {
"end_byte": 369,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports19.ts"
} |
TypeScript/tests/cases/fourslash/extract-method_jsxSelfClosingElement1.ts_0_577 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: a.tsx
////function Foo() {
//// return (
//// <div>
//// /*a*/<br />/*b*/
//// </div>
//// );
////}
goTo.file("a.tsx");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_1",
actionDescription: "Extract to function in global scope",
newContent:
`function Foo() {
return (
<div>
{newFunction()}
</div>
);
}
function /*RENAME*/newFunction() {
return <br />;
}
`
});
| {
"end_byte": 577,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method_jsxSelfClosingElement1.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionOverriddenMember2.ts_0_215 | /// <reference path="./fourslash.ts"/>
// @noImplicitOverride: true
////class Foo {
//// /*2*/m() {}
////}
////
////class Bar extends Foo {
//// [|/*1*/override|] m() {}
////}
verify.baselineGoToDefinition("1");
| {
"end_byte": 215,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionOverriddenMember2.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_default_anonymous.ts_0_1144 | /// <reference path="fourslash.ts" />
// Use `/src` to test that directory names are not included in conversion from module path to identifier.
// @module: esnext
// @noLib: true
// @Filename: /src/foo-bar.ts
////export default 0;
// @Filename: /src/b.ts
////def/*0*/
////fooB/*1*/
goTo.marker("0");
const preferences: FourSlashInterface.UserPreferences = { includeCompletionsForModuleExports: true };
verify.completions(
{
marker: "0",
exact: completion.globalsPlus([], { noLib: true }),
preferences
},
{
marker: "1",
includes: {
name: "fooBar",
source: "/src/foo-bar",
sourceDisplay: "./foo-bar",
text: "(property) default: 0",
kind: "property",
kindModifiers: "export",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences,
},
);
verify.applyCodeActionFromCompletion("1", {
name: "fooBar",
source: "/src/foo-bar",
description: `Add import from "./foo-bar"`,
newFileContent: `import fooBar from "./foo-bar"
def
fooB`,
});
| {
"end_byte": 1144,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_default_anonymous.ts"
} |
TypeScript/tests/cases/fourslash/pathCompletionsAllowModuleAugmentationExtensions.ts_0_345 | /// <reference path="fourslash.ts" />
// @Filename: /project/foo.css
//// export const foo = 0;
// @Filename: declarations.d.ts
//// declare module "*.css" {}
// @Filename: /project/main.ts
//// import {} from ".//**/"
// Extensionless by default
verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: ["foo.css"],
});
| {
"end_byte": 345,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsAllowModuleAugmentationExtensions.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingConstToArrayDestructuring1.ts_0_170 | /// <reference path='fourslash.ts' />
////[x] = [0];
verify.codeFix({
description: "Add 'const' to unresolved variable",
newFileContent: "const [x] = [0];"
});
| {
"end_byte": 170,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingConstToArrayDestructuring1.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentAfterNewExpression.ts_3_365 | / <reference path="fourslash.ts"/>
////
////new Array
////{| "indent": 0 |}
////new Array;
////{| "indent": 0 |}
////new Array(0);
////{| "indent": 0 |}
////new Array(;
////{| "indent": 0 |}
////new Array(
////{| "indent": 4 |}
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
});
| {
"end_byte": 365,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentAfterNewExpression.ts"
} |
TypeScript/tests/cases/fourslash/memberCompletionFromFunctionCall.ts_0_243 | /// <reference path="fourslash.ts" />
////declare interface ifoo {
//// text: (value: any) => ifoo;
////}
////declare var foo: ifoo;
////foo.text(function() { })/**/
goTo.marker();
edit.insert(".");
verify.completions({ exact: "text" });
| {
"end_byte": 243,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberCompletionFromFunctionCall.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts_0_382 | /// <reference path='fourslash.ts' />
// @noImplicitOverride: true
////abstract class A {
//// protected abstract x: number;
////}
////
////class C extends A {[| |]}
verify.codeFix({
description: "Implement inherited abstract class",
newFileContent:
`abstract class A {
protected abstract x: number;
}
class C extends A {
protected override x: number;
}`,
});
| {
"end_byte": 382,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpRestArgs1.ts_0_284 | /// <reference path="fourslash.ts" />
////function fn(a: number, b: number, c: number) {}
////const a = [1, 2] as const;
////const b = [1] as const;
////
////fn(...a, /*1*/);
////fn(/*2*/, ...a);
////
////fn(...b, /*3*/);
////fn(/*4*/, ...b, /*5*/);
verify.baselineSignatureHelp();
| {
"end_byte": 284,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpRestArgs1.ts"
} |
TypeScript/tests/cases/fourslash/unusedVariableInClass3.ts_0_233 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////class greeter {[|
//// private X = function() {};
////|]}
verify.codeFix({
description: "Remove unused declaration for: 'X'",
newRangeContent: "\n",
});
| {
"end_byte": 233,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedVariableInClass3.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionClassConstructors.ts_0_1078 | /// <reference path='fourslash.ts'/>
// @filename: definitions.ts
//// export class Base {
//// constructor(protected readonly cArg: string) {}
//// }
////
//// export class Derived extends Base {
//// readonly email = this.cArg.getByLabel('Email')
//// readonly password = this.cArg.getByLabel('Password')
//// }
// @filename: main.ts
//// import { Derived } from './definitions'
//// const derived = new [|/*Derived*/Derived|](cArg)
// @filename: defInSameFile.ts
//// import { Base } from './definitions'
//// class SameFile extends Base {
//// readonly name: string = 'SameFile'
//// }
//// const SameFile = new [|/*SameFile*/SameFile|](cArg)
//// const wrapper = new [|/*Base*/Base|](cArg)
// @filename: hasConstructor.ts
//// import { Base } from './definitions'
//// class HasConstructor extends Base {
//// constructor() {}
//// readonly name: string = '';
//// }
//// const hasConstructor = new [|/*HasConstructor*/HasConstructor|](cArg)
verify.baselineGoToDefinition(
"Derived",
"SameFile",
"HasConstructor",
"Base",
);
| {
"end_byte": 1078,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionClassConstructors.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarGetterAndSetter.ts_0_1554 | /// <reference path="fourslash.ts" />
////class X {
//// get x() {}
//// set x(value) {
//// // Inner declaration should make the setter top-level.
//// function f() {}
//// }
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "X",
"kind": "class",
"childItems": [
{
"text": "x",
"kind": "getter"
},
{
"text": "x",
"kind": "setter",
"childItems": [
{
"text": "f",
"kind": "function"
}
]
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "X",
"kind": "class"
}
]
},
{
"text": "X",
"kind": "class",
"childItems": [
{
"text": "x",
"kind": "getter"
},
{
"text": "x",
"kind": "setter"
}
],
"indent": 1
},
{
"text": "x",
"kind": "setter",
"childItems": [
{
"text": "f",
"kind": "function"
}
],
"indent": 2
}
]);
| {
"end_byte": 1554,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarGetterAndSetter.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpOnOverloadOnConst.ts_0_499 | /// <reference path='fourslash.ts'/>
////function x1(x: 'hi');
////function x1(y: 'bye');
////function x1(z: string);
////function x1(a: any) {
////}
////
////x1(''/*1*/);
////x1('hi'/*2*/);
////x1('bye'/*3*/);
verify.signatureHelp(
{ marker: "1", overloadsCount: 3, parameterName: "z", parameterSpan: "z: string" },
{ marker: "2", overloadsCount: 3, parameterName: "x", parameterSpan: 'x: "hi"' },
{ marker: "3", overloadsCount: 3, parameterName: "y", parameterSpan: 'y: "bye"' },
);
| {
"end_byte": 499,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpOnOverloadOnConst.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization8.ts_0_262 | /// <reference path='fourslash.ts' />
// @strict: true
//// class T {
//// a: string | boolean;
//// }
verify.codeFix({
description: `Add initializer to property 'a'`,
newFileContent: `class T {
a: string | boolean = false;
}`,
index: 2
}) | {
"end_byte": 262,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization8.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts_0_754 | /// <reference path='fourslash.ts' />
////function f<A,B,C>/*1*/(/*2*/a: A, /*3*/b:/*4*/B, c/*5*/, d: C/*6*/
function verifyIndentationAfterNewLine(marker: string, indentation: number, positionWorkaround: number, expectedText: string): void {
goTo.marker(marker);
edit.insert("\n");
// The next two lines are to workaround #13433
goTo.position(positionWorkaround);
verify.textAtCaretIs(expectedText);
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 4, 24, '(');
verifyIndentationAfterNewLine("2", 8, 34, 'a');
verifyIndentationAfterNewLine("3", 8, 48, 'b');
verifyIndentationAfterNewLine("4", 12, 63, 'B');
verifyIndentationAfterNewLine("5", 8, 76, ',');
verifyIndentationAfterNewLine("6", 8, 83, '');
| {
"end_byte": 754,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts"
} |
TypeScript/tests/cases/fourslash/jsFileImportNoTypes2.ts_0_1681 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: /default.ts
//// export default class TestDefaultClass {}
// @Filename: /defaultType.ts
//// export default interface TestDefaultInterface {}
// @Filename: /reExport/toReExport.ts
//// export class TestClassReExport {}
//// export interface TestInterfaceReExport {}
// @Filename: /reExport/index.ts
//// export { TestClassReExport, TestInterfaceReExport } from './toReExport';
// @Filename: /exportList.ts
//// class TestClassExportList {};
//// interface TestInterfaceExportList {};
//// export { TestClassExportList, TestInterfaceExportList };
// @Filename: /baseline.ts
//// export class TestClassBaseline {}
//// export interface TestInterfaceBaseline {}
// @Filename: /a.js
//// import /**/
verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: [
{
name: "TestClassBaseline",
insertText: "import { TestClassBaseline } from \"./baseline\";",
source: "./baseline",
},
{
name: "TestClassExportList",
insertText: "import { TestClassExportList } from \"./exportList\";",
source: "./exportList",
},
{
name: "TestClassReExport",
insertText: "import { TestClassReExport } from \"./reExport\";",
source: "./reExport",
},
{
name: "TestDefaultClass",
insertText: "import TestDefaultClass from \"./default\";",
source: "./default",
},
],
preferences: {
includeCompletionsForImportStatements: true,
includeCompletionsWithInsertText: true,
}
});
| {
"end_byte": 1681,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsFileImportNoTypes2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax15.ts_0_461 | /// <reference path='fourslash.ts' />
//// var f = <[|function(number?): number|]>(x => x);
verify.codeFix({
description: "Change 'number?' to 'number'",
errorCode: 17019,
index: 0,
newRangeContent: "function(number): number",
applyChanges: true
});
verify.codeFix({
description: "Change 'function(number): number' to '(arg0: number) => number'",
errorCode: 8020,
index: 0,
newRangeContent: "(arg0: number) => number",
});
| {
"end_byte": 461,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax15.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsLocalFunction.ts_0_942 | /// <reference path='fourslash.ts'/>
////function /*1*/outerFoo() {
//// function /*2*/foo(param: string, optionalParam?: string, paramWithInitializer = "hello", ...restParam: string[]) {
//// }
//// function /*3*/foowithoverload(a: string): string;
//// function /*4*/foowithoverload(a: number): number;
//// function /*5*/foowithoverload(a: any): any {
//// return a;
//// }
//// function /*6*/foowith3overload(a: string): string;
//// function /*7*/foowith3overload(a: number): number;
//// function /*8*/foowith3overload(a: boolean): boolean;
//// function /*9*/foowith3overload(a: any): any {
//// return a;
//// }
//// /*10*/foo("hello");
//// /*11*/foowithoverload("hello");
//// /*12*/foowithoverload(10);
//// /*13*/foowith3overload("hello");
//// /*14*/foowith3overload(10);
//// /*15*/foowith3overload(true);
////}
/////*16*/outerFoo();
verify.baselineQuickInfo(); | {
"end_byte": 942,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsLocalFunction.ts"
} |
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType12.ts_0_459 | /// <reference path='fourslash.ts' />
////function f(x: number) {
//// return 1;
////}
////function /*a*/f/*b*/(x: number) {
//// return "1";
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Infer function return type",
actionName: "Infer function return type",
actionDescription: "Infer function return type",
newContent:
`function f(x: number) {
return 1;
}
function f(x: number): string {
return "1";
}`
});
| {
"end_byte": 459,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType12.ts"
} |
TypeScript/tests/cases/fourslash/jsdocSatisfiesTagFindAllReferences.ts_0_292 | ///<reference path="fourslash.ts" />
// @noEmit: true
// @allowJS: true
// @checkJs: true
// @filename: /a.js
/////**
//// * @typedef {Object} T
//// * @property {number} a
//// */
////
/////** @satisfies {/**/T} comment */
////const foo = { a: 1 };
verify.baselineFindAllReferences("");
| {
"end_byte": 292,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocSatisfiesTagFindAllReferences.ts"
} |
TypeScript/tests/cases/fourslash/completionNoAutoInsertQuestionDotWithUserPreferencesOff.ts_0_422 | /// <reference path="fourslash.ts" />
// @strict: true
//// interface User {
//// address?: {
//// city: string;
//// "postal code": string;
//// }
//// };
//// declare const user: User;
//// user.address[|./**/|]
verify.completions({
marker: "",
exact: [],
preferences: {
includeInsertTextCompletions: true,
includeAutomaticOptionalChainCompletions: false
},
});
| {
"end_byte": 422,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionNoAutoInsertQuestionDotWithUserPreferencesOff.ts"
} |
TypeScript/tests/cases/fourslash/completionListOnParam.ts_0_226 | /// <reference path='fourslash.ts' />
////module Bar {
//// export class Blah { }
////}
////
////class Point {
//// public Foo(x: Bar./**/Blah, y: Bar.Blah) { }
////}
verify.completions({ marker: "", exact: "Blah" });
| {
"end_byte": 226,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListOnParam.ts"
} |
TypeScript/tests/cases/fourslash/codeFixTopLevelAwait_module_compatibleCompilerOptionsInTsConfig.ts_0_325 | /// <reference path="fourslash.ts" />
// @filename: /dir/a.ts
////declare const p: Promise<number>;
////await p;
////export {};
// @filename: /dir/tsconfig.json
////{
//// "compilerOptions": {
//// "target": "es2017",
//// "module": "esnext"
//// }
////}
verify.not.codeFixAvailable("fixModuleOption");
| {
"end_byte": 325,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelAwait_module_compatibleCompilerOptionsInTsConfig.ts"
} |
TypeScript/tests/cases/fourslash/extract-jsdoc.ts_0_191 | /// <reference path='fourslash.ts' />
/////**
//// * /*a*//*b*/
//// * {@link Foo}
//// */
goTo.select("a", "b");
verify.not.refactorAvailableForTriggerReason("invoked", "Extract Symbol");
| {
"end_byte": 191,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-jsdoc.ts"
} |
TypeScript/tests/cases/fourslash/completionListOnAliases.ts_0_295 | /// <reference path='fourslash.ts' />
////module M {
//// export var value;
////
//// import x = M;
//// /*1*/
//// x./*2*/
////}
verify.completions(
{ marker: "1", includes: [{ name: "x", text: "(alias) namespace x\nimport x = M" }] },
{ marker: "2", exact: "value" },
);
| {
"end_byte": 295,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListOnAliases.ts"
} |
TypeScript/tests/cases/fourslash/formatWithBaseIndent.ts_0_6695 | /// <reference path='fourslash.ts'/>
////
/////*1*/ module classes {
/////*2*/ class Bar {
////
/////*3*/ constructor() {
/////*4*/ }
////
/////*5*/private foo: string = "";
////
/////*6*/ private f() {
/////*7*/ var a: any[] = [[1, 2], [3, 4], 5];
/////*8*/ return ((1 + 1));
/////*9*/ }
////
/////*10*/ private f2() {
/////*11*/ if (true) { } { };
/////*12*/ }
/////*13*/ }
/////*14*/ }
////
////
/////*15*/ module interfaces {
/////*16*/ interface Foo {
////
/////*17*/ x: number;
////
/////*18*/ foo(): number;
/////*19*/ }
/////*20*/ }
////
////
/////*21*/ module nestedModules {
/////*22*/ module Foo2 {
/////*23*/ function f() {
/////*24*/ }
/////*25*/ var x: number;
/////*26*/}
/////*27*/ }
////
////
/////*28*/ module Enums {
/////*29*/ enum Foo3 {
/////*30*/ val1 ,
/////*31*/ val2,
/////*32*/ }
/////*33*/ }
////
////
/////*34*/ function controlStatements() {
/////*35*/ for (var i = 0; i < 10; i++) {
/////*36*/ }
////
/////*37*/ for (var e in foo.bar) {
/////*38*/ }
////
/////*39*/with (foo.bar) {
/////*40*/ }
////
/////*41*/ while (false) {
/////*42*/ }
////
/////*43*/ do {
/////*44*/ } while (false);
////
/////*45*/ switch (foo.bar) {
/////*46*/ }
////
/////*47*/ switch (foo.bar) {
/////*48*/ case 1:
/////*49*/ break;
/////*50*/ default:
/////*51*/ break;
/////*52*/ }
/////*53*/ }
////
////
/////*54*/ function tryCatch() {
/////*55*/try {
/////*56*/}
/////*57*/catch (err) {
/////*58*/ }
/////*59*/ }
////
////
/////*60*/ function tryFinally() {
/////*61*/ try {
/////*62*/ }
/////*63*/ finally {
/////*64*/ }
/////*65*/ }
////
////
/////*66*/ function tryCatchFinally() {
/////*67*/ try {
/////*68*/ }
/////*69*/ catch (err) {
/////*70*/ }
/////*71*/ finally {
/////*72*/ }
/////*73*/ }
////
////
/////*74*/ class indentBeforeCurly
/////*75*/ {
/////*76*/ }
////
////
/////*77*/ function argumentsListIndentation(bar,
/////*78*/ blah,
/////*79*/ );
////
////
/////*80*/ function blockIndentAfterIndentedParameter1(bar,
/////*81*/ blah) {
/////*82*/ }
////
////
/////*83*/ function blockIndentAfterIndentedParameter2(bar,
/////*84*/ blah) {
/////*85*/ if (foo) {
/////*86*/ }
/////*87*/}
////
/////*88*/ var templateLiterals = `abcdefghi
/////*89*/jklmnop
/////*90*/qrstuvwxyz`;
var originalOptions = format.copyFormatOptions();
var copy = format.copyFormatOptions();
copy.BaseIndentSize = 10;
copy.IndentSize = 4;
format.setFormatOptions(copy);
format.document();
verify.currentFileContentIs(`
module classes {
class Bar {
constructor() {
}
private foo: string = "";
private f() {
var a: any[] = [[1, 2], [3, 4], 5];
return ((1 + 1));
}
private f2() {
if (true) { } { };
}
}
}
module interfaces {
interface Foo {
x: number;
foo(): number;
}
}
module nestedModules {
module Foo2 {
function f() {
}
var x: number;
}
}
module Enums {
enum Foo3 {
val1,
val2,
}
}
function controlStatements() {
for (var i = 0; i < 10; i++) {
}
for (var e in foo.bar) {
}
with (foo.bar) {
}
while (false) {
}
do {
} while (false);
switch (foo.bar) {
}
switch (foo.bar) {
case 1:
break;
default:
break;
}
}
function tryCatch() {
try {
}
catch (err) {
}
}
function tryFinally() {
try {
}
finally {
}
}
function tryCatchFinally() {
try {
}
catch (err) {
}
finally {
}
}
class indentBeforeCurly {
}
function argumentsListIndentation(bar,
blah,
);
function blockIndentAfterIndentedParameter1(bar,
blah) {
}
function blockIndentAfterIndentedParameter2(bar,
blah) {
if (foo) {
}
}
var templateLiterals = \`abcdefghi
jklmnop
qrstuvwxyz\`;`);
format.setFormatOptions(originalOptions); | {
"end_byte": 6695,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatWithBaseIndent.ts"
} |
TypeScript/tests/cases/fourslash/addInterfaceMemberAboveClass.ts_0_361 | /// <reference path="fourslash.ts" />
////
//// interface Intersection {
//// /*insertHere*/
//// }
//// interface Scene { }
//// class /*className*/Sphere {
//// constructor() {
//// }
//// }
verify.quickInfoAt("className", "class Sphere");
goTo.marker('insertHere');
edit.insert("ray: Ray;");
verify.quickInfoAt("className", "class Sphere");
| {
"end_byte": 361,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/addInterfaceMemberAboveClass.ts"
} |
TypeScript/tests/cases/fourslash/organizeImports13.ts_0_1395 | /// <reference path="fourslash.ts" />
////import {
//// Type1,
//// Type2,
//// func4,
//// Type3,
//// Type4,
//// Type5,
//// Type7,
//// Type8,
//// Type9,
//// func1,
//// func2,
//// Type6,
//// func3,
//// func5,
//// func6,
//// func7,
//// func8,
//// func9,
////} from "foo";
////interface Use extends Type1, Type2, Type3, Type4, Type5, Type6, Type7, Type8, Type9 {}
////console.log(func1, func2, func3, func4, func5, func6, func7, func8, func9);
verify.organizeImports(
`import {
Type1,
Type2,
Type3,
Type4,
Type5,
Type6,
Type7,
Type8,
Type9,
func1,
func2,
func3,
func4,
func5,
func6,
func7,
func8,
func9,
} from "foo";
interface Use extends Type1, Type2, Type3, Type4, Type5, Type6, Type7, Type8, Type9 {}
console.log(func1, func2, func3, func4, func5, func6, func7, func8, func9);`
);
verify.organizeImports(
`import {
func1,
func2,
func3,
func4,
func5,
func6,
func7,
func8,
func9,
Type1,
Type2,
Type3,
Type4,
Type5,
Type6,
Type7,
Type8,
Type9,
} from "foo";
interface Use extends Type1, Type2, Type3, Type4, Type5, Type6, Type7, Type8, Type9 {}
console.log(func1, func2, func3, func4, func5, func6, func7, func8, func9);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: true });
| {
"end_byte": 1395,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImports13.ts"
} |
TypeScript/tests/cases/fourslash/getImportsDynamic.ts_0_275 | ///<reference path="fourslash.ts"/>
// @Filename: /first.ts
//// export function foo() {
//// return 1;
//// }
// @Filename: /index.ts
//// let bar: typeof import('./first').foo = function bar() {
//// return 2;
//// }
verify.getImports('/index.ts', ['/first.ts'])
| {
"end_byte": 275,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getImportsDynamic.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_filteredByPackageJson_direct.ts_0_933 | /// <reference path="fourslash.ts" />
//@noEmit: true
//@Filename: /package.json
////{
//// "dependencies": {
//// "react": "*"
//// }
////}
//@Filename: /node_modules/react/index.d.ts
////export declare var React: any;
//@Filename: /node_modules/react/package.json
////{
//// "name": "react",
//// "types": "./index.d.ts"
////}
//@Filename: /node_modules/fake-react/index.d.ts
////export declare var ReactFake: any;
//@Filename: /node_modules/fake-react/package.json
////{
//// "name": "fake-react",
//// "types": "./index.d.ts"
////}
//@Filename: /src/index.ts
////const x = Re/**/
verify.completions({
marker: test.marker(""),
isNewIdentifierLocation: true,
includes: {
name: "React",
hasAction: true,
source: "/node_modules/react/index",
sortText: completion.SortText.AutoImportSuggestions
},
excludes: "ReactFake",
preferences: {
includeCompletionsForModuleExports: true
}
});
| {
"end_byte": 933,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_filteredByPackageJson_direct.ts"
} |
TypeScript/tests/cases/fourslash/referencesForFunctionParameter.ts_0_206 | /// <reference path='fourslash.ts'/>
////var x;
////var n;
////
////function n(x: number, /*1*/n: number) {
//// /*2*/n = 32;
//// x = /*3*/n;
////}
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 206,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForFunctionParameter.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_reExports5.ts_0_565 | /// <reference path='fourslash.ts' />
// @module: esnext
//@Filename: /a.ts
////export function a() { }
//@Filename: /b.ts
////export function foo() { }
////[|export function bar() {}|]
// @Filename: /c.ts
////export function baz() { }
////export * from "./a";
////export {
//// bar,
////} from "./b";
verify.moveToFile({
newFileContents: {
"/b.ts":
`export function foo() { }
`,
"/c.ts":
`export function baz() { }
export function bar() { }
export * from "./a";
`,
},
interactiveRefactorArguments: { targetFile: "/c.ts" },
});
| {
"end_byte": 565,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_reExports5.ts"
} |
TypeScript/tests/cases/fourslash/completionsCommentsCommentParsing.ts_0_5782 | /// <reference path='fourslash.ts' />
/////// This is simple /// comments
////function simple() {
////}
////
////simple( );
////
/////// multiLine /// Comments
/////// This is example of multiline /// comments
/////// Another multiLine
////function multiLine() {
////}
////multiLine( );
////
/////** this is eg of single line jsdoc style comment */
////function jsDocSingleLine() {
////}
////jsDocSingleLine();
////
////
/////** this is multiple line jsdoc stule comment
////*New line1
////*New Line2*/
////function jsDocMultiLine() {
////}
////jsDocMultiLine();
////
/////** multiple line jsdoc comments no longer merge
////*New line1
////*New Line2*/
/////** Shoul mege this line as well
////* and this too*/ /** Another this one too*/
////function jsDocMultiLineMerge() {
////}
////jsDocMultiLineMerge();
////
////
/////// Triple slash comment
/////** jsdoc comment */
////function jsDocMixedComments1() {
////}
////jsDocMixedComments1();
////
/////// Triple slash comment
/////** jsdoc comment */ /** another jsDocComment*/
////function jsDocMixedComments2() {
////}
////jsDocMixedComments2();
////
/////** jsdoc comment */ /*** triplestar jsDocComment*/
/////// Triple slash comment
////function jsDocMixedComments3() {
////}
////jsDocMixedComments3();
////
/////** jsdoc comment */ /** another jsDocComment*/
/////// Triple slash comment
/////// Triple slash comment 2
////function jsDocMixedComments4() {
////}
////jsDocMixedComments4();
////
/////// Triple slash comment 1
/////** jsdoc comment */ /** another jsDocComment*/
/////// Triple slash comment
/////// Triple slash comment 2
////function jsDocMixedComments5() {
////}
////jsDocMixedComments5();
////
/////** another jsDocComment*/
/////// Triple slash comment 1
/////// Triple slash comment
/////// Triple slash comment 2
/////** jsdoc comment */
////function jsDocMixedComments6() {
////}
////jsDocMixedComments6();
////
////// This shoulnot be help comment
////function noHelpComment1() {
////}
////noHelpComment1();
////
/////* This shoulnot be help comment */
////function noHelpComment2() {
////}
////noHelpComment2();
////
////function noHelpComment3() {
////}
////noHelpComment3();
/////** Adds two integers and returns the result
//// * @param {number} a first number
//// * @param b second number
//// */
////function sum(a: number, b: number) {
//// return /*18*/a + b;
////}
/////*15*/sum(10, 20);
/////** This is multiplication function
//// * @param
//// * @param a first number
//// * @param b
//// * @param c {
//// @param d @anotherTag
//// * @param e LastParam @anotherTag*/
////function multiply(a: number, b: number, c?: number, d?, e?) {
////}
////multiply(10, 20, 30, 40, 50);
/////** fn f1 with number
////* @param { string} b about b
////*/
////function f1(a: number);
////function f1(b: string);
/////**@param opt optional parameter*/
////function f1(aOrb, opt?) {
//// return /*24*/aOrb;
////}
////f1(10);
////f1("hello");
/////*27*/
/////** This is subtract function
////@param { a
////*@param { number | } b this is about b
////@param { { () => string; } } c this is optional param c
////@param { { () => string; } d this is optional param d
////@param { { () => string; } } e this is optional param e
////@param { { { () => string; } } f this is optional param f
////*/
////function subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string) {
////}
////subtract(10, 20, null, null, null, null);
/////** this is square function
////@paramTag { number } a this is input number of paramTag
////@param { number } a this is input number
////@returnType { number } it is return type
////*/
////function square(a: number) {
//// return a * a;
////}
////square(10);
/////** this is divide function
////@param { number} a this is a
////@paramTag { number } g this is optional param g
////@param { number} b this is b
////*/
////function divide(a: number, b: number) {
////}
////divide(10, 20);
/////**
////Function returns string concat of foo and bar
////@param {string} foo is string
////@param {string} bar is second string
////*/
////function fooBar(foo: string, bar: string) {
//// return foo + bar;
////}
////fooBar("foo","bar");
/////** This is a comment */
////var x;
/////**
//// * This is a comment
//// */
////var y;
/////** this is jsdoc style function with param tag as well as inline parameter help
////*@param a it is first parameter
////*@param c it is third parameter
////*/
////function jsDocParamTest(/** this is inline comment for a */a: number, /** this is inline comment for b*/ b: number, c: number, d: number) {
//// return /*39*/a + b + c + d;
////}
/////*44*/jsDocParamTest(30, 40, 50, 60);
/////** This is function comment
//// * And properly aligned comment
//// */
////function jsDocCommentAlignmentTest1() {
////}
////jsDocCommentAlignmentTest1();
/////** This is function comment
//// * And aligned with 4 space char margin
//// */
////function jsDocCommentAlignmentTest2() {
////}
////jsDocCommentAlignmentTest2();
/////** This is function comment
//// * And aligned with 4 space char margin
//// * @param {string} a this is info about a
//// * spanning on two lines and aligned perfectly
//// * @param b this is info about b
//// * spanning on two lines and aligned perfectly
//// * spanning one more line alined perfectly
//// * spanning another line with more margin
//// * @param c this is info about b
//// * not aligned text about parameter will eat only one space
//// */
////function jsDocCommentAlignmentTest3(a: string, b, c) {
////}
////jsDocCommentAlignmentTest3("hello",1, 2);
/////**/
////class NoQuickInfoClass {
////}
verify.baselineCompletions()
| {
"end_byte": 5782,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsCommentsCommentParsing.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCalledES2015Import10.ts_0_426 | /// <reference path='fourslash.ts' />
// @esModuleInterop: true
// @Filename: foo.d.ts
////declare function foo(): void;
////declare namespace foo {}
////export = foo;
// @Filename: index.ts
////import * as foo from "./foo";
////[|foo()|];
goTo.file(1);
verify.codeFix({
description: `Replace import with 'import foo = require("./foo");'.`,
newFileContent: `import foo = require("./foo");
foo();`,
index: 1,
});
| {
"end_byte": 426,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCalledES2015Import10.ts"
} |
TypeScript/tests/cases/fourslash/completionsCommitCharactersExportImportClause.ts_0_331 | /// <reference path='fourslash.ts' />
// @filename: a.ts
//// const xx: string = "aa";
//// function ff(): void {}
//// export { /*1*/ };
// @filename: exports.ts
//// export const ff: string = "";
//// export const aa = () => {};
// @filename: imports.ts
//// import { /*2*/ } from "./exports";
verify.baselineCompletions(); | {
"end_byte": 331,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsCommitCharactersExportImportClause.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationWithErrors.ts_3_512 | / <reference path='fourslash.ts'/>
////class A {
//// a:
////}
////c =
const c = classification("original")
verify.syntacticClassificationsAre(
c.keyword("class"), c.className("A"), c.punctuation("{"),
c.identifier("a"), c.punctuation(":"),
c.punctuation("}"),
c.identifier("c"), c.operator("=")
);
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("class.declaration", "A"),
c2.semanticToken("property.declaration", "a"),
);
| {
"end_byte": 512,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationWithErrors.ts"
} |
TypeScript/tests/cases/fourslash/completionListProtectedMembers.ts_0_732 | /// <reference path="fourslash.ts"/>
////class Base {
//// protected y;
//// constructor(protected x) {}
//// method() { this./*1*/; }
////}
////class D1 extends Base {
//// protected z;
//// method1() { this./*2*/; }
////}
////class D2 extends Base {
//// method2() { this./*3*/; }
////}
////class D3 extends D1 {
//// method2() { this./*4*/; }
////}
////var b: Base;
////f./*5*/
verify.completions(
{ marker: "1", unsorted: ["y", "x", "method"] },
{ marker: "2", unsorted: ["z", "method1", "y", "x", "method"] },
{ marker: "3", unsorted: ["method2", "y", "x", "method"] },
{ marker: "4", unsorted: ["method2", "z", "method1", "y", "x", "method"] },
{ marker: "5", exact: undefined },
);
| {
"end_byte": 732,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListProtectedMembers.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_NotForOtherOperators.ts_0_1133 | /// <reference path='fourslash.ts' />
////let a = { b: { c: { d: 0 } } };
/////*1a*/a || a.b && a.b.c && a.b.c.d;/*1b*/
/////*2a*/a && a.b || a.b.c && a.b.c.d;/*2b*/
/////*3a*/a && a.b && a.b.c || a.b.c.d;/*3b*/
/////*4a*/a ?? a.b && a.b.c && a.b.c.d;/*4b*/
/////*5a*/a && a.b ?? a.b.c || a.b.c.d;/*5b*/
/////*6a*/a && a.b && a.b.c ?? a.b.c.d;/*6b*/
// Only offer refactor for && chains.
goTo.select("1a", "1b");
verify.not.refactorAvailableForTriggerReason("implicit", "Convert to optional chain expression");
goTo.select("2a", "2b");
verify.not.refactorAvailableForTriggerReason("implicit", "Convert to optional chain expression");
goTo.select("3a", "3b");
verify.not.refactorAvailableForTriggerReason("implicit", "Convert to optional chain expression");
goTo.select("4a", "4b");
verify.not.refactorAvailableForTriggerReason("implicit", "Convert to optional chain expression");
goTo.select("5a", "5b");
verify.not.refactorAvailableForTriggerReason("implicit", "Convert to optional chain expression");
goTo.select("6a", "6b");
verify.not.refactorAvailableForTriggerReason("implicit", "Convert to optional chain expression");
| {
"end_byte": 1133,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_NotForOtherOperators.ts"
} |
TypeScript/tests/cases/fourslash/renameDeclarationKeywords.ts_0_3554 | /// <reference path='fourslash.ts'/>
////[|{| "id": "baseDecl" |}class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "baseDecl" |}Base|] {}|]
////[|{| "id": "implemented1Decl" |}interface [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "implemented1Decl" |}Implemented1|] {}|]
////[|{| "id": "classDecl1" |}[|class|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "classDecl1" |}C1|] [|extends|] [|Base|] [|implements|] [|Implemented1|] {
//// [|{| "id": "getDecl" |}[|get|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "getDecl" |}e|]() { return 1; }|]
//// [|{| "id": "setDecl" |}[|set|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "setDecl" |}e|](v) {}|]
////}|]
////[|{| "id": "interfaceDecl1" |}[|interface|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "interfaceDecl1" |}I1|] [|extends|] [|Base|] { }|]
////[|{| "id": "typeDecl" |}[|type|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "typeDecl" |}T|] = { }|]
////[|{| "id": "enumDecl" |}[|enum|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "enumDecl" |}E|] { }|]
////[|{| "id": "namespaceDecl" |}[|namespace|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "namespaceDecl" |}N|] { }|]
////[|{| "id": "moduleDecl" |}[|module|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "moduleDecl" |}M|] { }|]
////[|{| "id": "functionDecl" |}[|function|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "functionDecl" |}fn|]() {}|]
////[|{| "id": "varDecl" |}[|var|] [|{| "isWriteAccess": false, "isDefinition": true, "contextRangeId": "varDecl" |}x|];|]
////[|{| "id": "letDecl" |}[|let|] [|{| "isWriteAccess": false, "isDefinition": true, "contextRangeId": "letDecl" |}y|];|]
////[|{| "id": "constDecl" |}[|const|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "constDecl" |}z|] = 1;|]
const [
baseDecl,
baseDecl_name,
implemented1Decl,
implemented1Decl_name,
classDecl1,
classDecl1_classKeyword,
classDecl1_name,
classDecl1_extendsKeyword,
classDecl1_extendsName,
classDecl1_implementsKeyword,
classDecl1_implementsName,
getDecl,
getDecl_getKeyword,
getDecl_name,
setDecl,
setDecl_setKeyword,
setDecl_name,
interfaceDecl1,
interfaceDecl1_interfaceKeyword,
interfaceDecl1_name,
interfaceDecl1_extendsKeyword,
interfaceDecl1_extendsName,
typeDecl,
typeDecl_typeKeyword,
typeDecl_name,
enumDecl,
enumDecl_enumKeyword,
enumDecl_name,
namespaceDecl,
namespaceDecl_namespaceKeyword,
namespaceDecl_name,
moduleDecl,
moduleDecl_moduleKeyword,
moduleDecl_name,
functionDecl,
functionDecl_functionKeyword,
functionDecl_name,
varDecl,
varDecl_varKeyword,
varDecl_name,
letDecl,
letDecl_letKeyword,
letDecl_name,
constDecl,
constDecl_constKeyword,
constDecl_name,
] = test.ranges();
verify.baselineRename([
classDecl1_classKeyword,
classDecl1_extendsKeyword,
classDecl1_implementsKeyword,
getDecl_getKeyword, setDecl_setKeyword,
interfaceDecl1_interfaceKeyword,
interfaceDecl1_extendsKeyword,
typeDecl_typeKeyword,
enumDecl_enumKeyword,
namespaceDecl_namespaceKeyword,
moduleDecl_moduleKeyword,
functionDecl_functionKeyword,
varDecl_varKeyword,
letDecl_letKeyword,
constDecl_constKeyword,
]); | {
"end_byte": 3554,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameDeclarationKeywords.ts"
} |
TypeScript/tests/cases/fourslash/completionListOutsideOfForLoop02.ts_0_131 | /// <reference path='fourslash.ts' />
////for (let i = 0; i < 10; i++);/*1*/
verify.completions({ marker: "1", excludes: "i" });
| {
"end_byte": 131,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListOutsideOfForLoop02.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentCloseBrace.ts_0_296 | /// <reference path='fourslash.ts'/>
////class A {
//// {| "indentation": 0|} }
////class B {
//// var x = 1;
//// {| "indentation": 0|} }
test.markers().forEach((marker) => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation);
});
| {
"end_byte": 296,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentCloseBrace.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsInteractiveJsDocParameterNames.ts_0_427 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @Filename: /a.js
//// var x
//// x.foo(1, 2);
//// /**
//// * @type {{foo: (a: number, b: number) => void}}
//// */
//// var y
//// y.foo(1, 2)
//// /**
//// * @type {string}
//// */
//// var z = ""
goTo.file('/a.js')
verify.baselineInlayHints(undefined, {
includeInlayParameterNameHints: "literals",
interactiveInlayHints: true
});
| {
"end_byte": 427,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveJsDocParameterNames.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsInteractiveParameterNamesWithComments.ts_0_847 | /// <reference path="fourslash.ts" />
//// const fn = (x: any) => { }
//// fn(/* nobody knows exactly what this param is */ 42);
//// function foo (aParameter: number, bParameter: number, cParameter: number) { }
//// foo(
//// /** aParameter */
//// 1,
//// // bParameter
//// 2,
//// /* cParameter */
//// 3
//// )
//// foo(
//// /** multiple comments */
//// /** aParameter */
//// 1,
//// /** bParameter */
//// /** multiple comments */
//// 2,
//// // cParameter
//// /** multiple comments */
//// 3
//// )
//// foo(
//// /** wrong name */
//// 1,
//// 2,
//// /** multiple */
//// /** wrong */
//// /** name */
//// 3
//// )
verify.baselineInlayHints(undefined, {
includeInlayParameterNameHints: "literals",
interactiveInlayHints: true
});
| {
"end_byte": 847,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveParameterNamesWithComments.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingConstInForLoopWithObjectDestructuring1.ts_0_208 | /// <reference path='fourslash.ts' />
////for ({ x } of [{ x: 0 }]) { }
verify.codeFix({
description: "Add 'const' to unresolved variable",
newFileContent: "for (const { x } of [{ x: 0 }]) { }"
});
| {
"end_byte": 208,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingConstInForLoopWithObjectDestructuring1.ts"
} |
TypeScript/tests/cases/fourslash/jsdocWithBarInTypeLiteral.ts_0_289 | /// <reference path="fourslash.ts" />
// @filename: index.js
//// class I18n {
//// /**
//// * @param {{dot|fulltext}} [stringMode] - which mode our translation keys use
//// */
//// constructor(options = {}) {}
//// }
verify.encodedSyntacticClassificationsLength(69);
| {
"end_byte": 289,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocWithBarInTypeLiteral.ts"
} |
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc3.ts_0_1603 | /// <reference path='fourslash.ts' />
/////**
//// * @param {number} x - the first parameter
//// * @param {{ a: string, b: Date }} y - the most complex parameter
//// * @param z - the best parameter
//// * @param alpha - the other best parameter
//// * @param {*} beta - I have no idea how this got here
//// */
////function [|f|]([|x|], [|y|], z: string, [|alpha|], [|beta|]) {
//// x; y; z; alpha; beta;
////}
const [r0, r1, r2, r3, r4] = test.ranges();
verify.getSuggestionDiagnostics([
{message: "JSDoc types may be moved to TypeScript types.", code: 80004, range: r0},
{message: "Parameter 'x' implicitly has an 'any' type, but a better type may be inferred from usage.", code: 7044, range: r1 },
{message: "Parameter 'y' implicitly has an 'any' type, but a better type may be inferred from usage.", code: 7044, range: r2 },
{message: "Parameter 'alpha' implicitly has an 'any' type, but a better type may be inferred from usage.", code: 7044, range: r3 },
{message: "Parameter 'beta' implicitly has an 'any' type, but a better type may be inferred from usage.", code: 7044, range: r4 }]);
verify.codeFix({
description: "Annotate with type from JSDoc",
index: 0,
newFileContent:
// TODO: GH#22358
`/**
* @param {number} x - the first parameter
* @param {{ a: string, b: Date }} y - the most complex parameter
* @param z - the best parameter
* @param alpha - the other best parameter
* @param {*} beta - I have no idea how this got here
*/
function f(x: number, y: { a: string; b: Date; }, z: string, alpha, beta: any) {
x; y; z; alpha; beta;
}`,
});
| {
"end_byte": 1603,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc3.ts"
} |
TypeScript/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts_0_899 | /// <reference path='fourslash.ts' />
const singleLineOffset = 3;
const multiLineOffset = 11;
////class C {
/////*0*/ /*1*/
//// foo();
//// /*2*/foo(a);
//// /*3*/foo(a, b);
//// /*4*/foo(a, {x: string}, [c]);
//// /*5*/foo(a?, b?, ...args) {
//// }
////}
verify.docCommentTemplateAt("0", singleLineOffset,
"/** */");
verify.docCommentTemplateAt("1", singleLineOffset,
"/** */");
verify.docCommentTemplateAt("2", multiLineOffset,
`/**
*
* @param a
*/
`);
verify.docCommentTemplateAt("3", multiLineOffset,
`/**
*
* @param a
* @param b
*/
`);
verify.docCommentTemplateAt("4", multiLineOffset,
`/**
*
* @param a
* @param param1
* @param param2
*/
`);
verify.docCommentTemplateAt("5", multiLineOffset,
`/**
*
* @param a
* @param b
* @param args
*/
`);
| {
"end_byte": 899,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts"
} |
TypeScript/tests/cases/fourslash/callHierarchyClassPropertyArrowFunction.ts_0_213 | /// <reference path="fourslash.ts" />
////class C {
//// caller = () => {
//// this.callee();
//// }
////
//// /**/callee = () => {
//// }
////}
goTo.marker();
verify.baselineCallHierarchy();
| {
"end_byte": 213,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyClassPropertyArrowFunction.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsOverloadCall2.ts_0_438 | /// <reference path="fourslash.ts" />
////type HasID = {
//// id: number;
////}
////
////type Numbers = {
//// n: number[];
////}
////
////declare function func(bad1: number, bad2: HasID): void;
////declare function func(ok_1: Numbers, ok_2: HasID): void;
////
////func(
//// { n: [1, 2, 3] },
//// {
//// id: 1,
//// },
////);
verify.baselineInlayHints(undefined, {
includeInlayParameterNameHints: "all",
});
| {
"end_byte": 438,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsOverloadCall2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingMember29.ts_0_375 | /// <reference path='fourslash.ts' />
////class C {
//// constructor() {
//// this.#foo();
//// }
////}
verify.codeFix({
description: [ts.Diagnostics.Declare_method_0.message, "#foo"],
index: 0,
newFileContent:
`class C {
constructor() {
this.#foo();
}
#foo() {
throw new Error("Method not implemented.");
}
}`,
});
| {
"end_byte": 375,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember29.ts"
} |
TypeScript/tests/cases/fourslash/formattingInDestructuring1.ts_0_567 | /// <reference path='fourslash.ts'/>
////interface let { }
/////*1*/var x: let [];
////
////function foo() {
//// 'use strict'
/////*2*/ let [x] = [];
/////*3*/ const [x] = [];
/////*4*/ for (let[x] = [];x < 1;) {
//// }
////}
format.document();
goTo.marker("1");
verify.currentLineContentIs("var x: let[];");
goTo.marker("2");
verify.currentLineContentIs(" let [x] = [];");
goTo.marker("3");
verify.currentLineContentIs(" const [x] = [];");
goTo.marker("4");
verify.currentLineContentIs(" for (let [x] = []; x < 1;) {"); | {
"end_byte": 567,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingInDestructuring1.ts"
} |
TypeScript/tests/cases/fourslash/renameJsPrototypeProperty01.ts_0_282 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: a.js
////function bar() {
////}
////[|bar.prototype.[|{| "contextRangeIndex": 0 |}x|] = 10;|]
////var t = new bar();
////[|t.[|{| "contextRangeIndex": 2 |}x|] = 11;|]
verify.baselineRenameAtRangesWithText("x");
| {
"end_byte": 282,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameJsPrototypeProperty01.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixShebang.ts_0_277 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export const foo = 0;
// @Filename: /b.ts
////[|#!/usr/bin/env node
////foo/**/|]
goTo.file("/a.ts");
goTo.file("/b.ts");
verify.importFixAtPosition([
`#!/usr/bin/env node
import { foo } from "./a";
foo`,
]);
| {
"end_byte": 277,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixShebang.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration2.ts_0_363 | /// <reference path='fourslash.ts' />
////foo();
////foo();
////foo();
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "foo"],
applyChanges: true,
newFileContent:
`foo();
foo();
foo();
function foo() {
throw new Error("Function not implemented.");
}
`
});
verify.not.codeFixAvailable();
| {
"end_byte": 363,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageSetter.ts_0_217 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
////class C {
//// set [|x(v)|] {
//// v;
//// }
////}
////(new C).x = 1;
verify.rangeAfterCodeFix("x(v: number)", undefined, undefined, 0); | {
"end_byte": 217,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageSetter.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedFunction10.ts_3_295 | / <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: /*1*/
verify.completions({ marker: "1", includes: "MyType" });
| {
"end_byte": 295,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedFunction10.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpAtEOF.ts_0_289 | /// <reference path='fourslash.ts' />
////function Foo(arg1: string, arg2: string) {
////}
////
////Foo(/**/
verify.signatureHelp({
marker: "",
text: "Foo(arg1: string, arg2: string): void",
parameterCount: 2,
parameterName: "arg1",
parameterSpan: "arg1: string",
})
| {
"end_byte": 289,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpAtEOF.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingNew3.ts_0_254 | /// <reference path='fourslash.ts' />
////class C {
////}
////let x = [C];
////let a = x[0]();
verify.codeFix({
description: "Add missing 'new' operator to call",
index: 0,
newFileContent:
`class C {
}
let x = [C];
let a = new x[0]();`
});
| {
"end_byte": 254,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingNew3.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsBadImport.ts_0_137 | /// <reference path='fourslash.ts'/>
////import { /*0*/ab as /*1*/cd } from "doesNotExist";
verify.baselineFindAllReferences('0', '1')
| {
"end_byte": 137,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsBadImport.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts_0_259 | /// <reference path='fourslash.ts' />
////interface I<T> { x: T; }
////class C<T> implements I<T> {}
verify.codeFix({
description: "Implement interface 'I<T>'",
newFileContent:
`interface I<T> { x: T; }
class C<T> implements I<T> {
x: T;
}`
});
| {
"end_byte": 259,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_all_infer.ts_0_518 | /// <reference path='fourslash.ts' />
////type Length<T> = T extends ArrayLike<infer U> ? number : never;
////type Indexer<T> = T extends ArrayLike<infer U> ? number : never;
////function f(p) {} // Ignored
verify.codeFixAll({
fixId: "unusedIdentifier_infer",
fixAllDescription: "Replace all unused 'infer' with 'unknown'",
newFileContent:
`type Length<T> = T extends ArrayLike<unknown> ? number : never;
type Indexer<T> = T extends ArrayLike<unknown> ? number : never;
function f(p) {} // Ignored`,
});
| {
"end_byte": 518,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_all_infer.ts"
} |
TypeScript/tests/cases/fourslash/renamePrivateFields.ts_0_201 | /// <reference path='fourslash.ts' />
////class Foo {
//// [|/**/#foo|] = 1;
////
//// getFoo() {
//// return this.#foo;
//// }
////}
goTo.marker("");
verify.renameInfoSucceeded("#foo");
| {
"end_byte": 201,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renamePrivateFields.ts"
} |
TypeScript/tests/cases/fourslash/overloadQuickInfo.ts_0_993 | /// <reference path='fourslash.ts' />
////function Foo(a: string, b: number, c: boolean);
////function Foo(a: any, name: string, age: number);
////function Foo(fred: any[], name: string, age: number);
////function Foo(fred: any[ ] , name: string[], age: number);
////function Foo(fred: any[], name: string[], age: number[]);
////function Foo(fred: any, name: string[], age: number[]); // Extraneous spaces should get removed
////function Foo(fred: any, name: boolean, age: number[]);
////function Foo(dave: boolean, name: string);
////function Foo(fred: any, mandy: {(): number}, age: number[]); // Embedded interface will get converted to shorthand notation, () =>
////function Foo(fred: any, name: string, age: { });
////function Foo(fred: any, name: string, age: number[]);
////function Foo(test: string, name, age: number);
////function Foo();
////function Foo(x?: any, y?: any, z?: any) {
////}
////Fo/**/o();
verify.quickInfoAt("", "function Foo(): any (+12 overloads)");
| {
"end_byte": 993,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/overloadQuickInfo.ts"
} |
TypeScript/tests/cases/fourslash/autoImportAllowTsExtensions1.ts_0_504 | /// <reference path="fourslash.ts" />
// @moduleResolution: bundler
// @allowImportingTsExtensions: true
// @noEmit: true
// @Filename: /node_modules/@types/foo/index.d.ts
//// export const fromAtTypesFoo: number;
// @Filename: /node_modules/bar/index.d.ts
//// export const fromBar: number;
// @Filename: /local.ts
//// export const fromLocal: number;
// @Filename: /Component.tsx
//// export function Component() { return null; }
// @Filename: /main.ts
//// /**/
verify.baselineAutoImports("");
| {
"end_byte": 504,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportAllowTsExtensions1.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType68.ts_0_234 | /// <reference path='fourslash.ts' />
//// function foo(a: /*a*/{ a: number | string, b: string } & { b: number } & { d: boolean }/*b*/) { }
goTo.select("a", "b");
verify.not.refactorAvailable("Extract type", "Extract to interface") | {
"end_byte": 234,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType68.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageContextualImport1.ts_0_537 | /// <reference path="fourslash.ts" />
// @strict: true
// @noImplicitAny: true
// @noLib: true
// @Filename: /a.ts
////export interface User {}
////export declare function getEmail(user: User): string;
// @Filename: /b.ts
////import { getEmail } from "./a";
////
////export function f([|user|]) {
//// getEmail(user);
////}
goTo.file("/b.ts");
verify.codeFix({
description: "Infer parameter types from usage",
newFileContent:
`import { getEmail, User } from "./a";
export function f(user: User) {
getEmail(user);
}`
});
| {
"end_byte": 537,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageContextualImport1.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToNamed_MultiDecl.ts_0_379 | /// <reference path='fourslash.ts' />
//// let foo, bar = /*x*/(/*y*/) => 1 + 1, magicNo;
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to named function",
actionDescription: "Convert to named function",
newContent: `let foo, magicNo;
function bar() {
return 1 + 1;
}
`,
});
| {
"end_byte": 379,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToNamed_MultiDecl.ts"
} |
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction17.ts_0_287 | /// <reference path='fourslash.ts' />
// @target: es2015
////const foo = async (): number => {}
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Replace_0_with_Promise_1.message, "number", "number"],
newFileContent: `const foo = async (): Promise<number> => {}`
});
| {
"end_byte": 287,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction17.ts"
} |
TypeScript/tests/cases/fourslash/fixExactOptionalUnassignableProperties15.ts_0_717 | /// <reference path='fourslash.ts'/>
// @strictNullChecks: true
// @exactOptionalPropertyTypes: true
//// interface More {
//// a?: number
//// b?: number
//// }
//// interface J {
//// a?: number | undefined
//// }
//// declare var j: J
//// declare var more: More
//// more/**/ = j
verify.codeFixAvailable([
{ description: ts.Diagnostics.Add_undefined_to_optional_property_type.message }
]);
verify.codeFix({
description: ts.Diagnostics.Add_undefined_to_optional_property_type.message,
index: 0,
newFileContent:
`interface More {
a?: number | undefined
b?: number | undefined
}
interface J {
a?: number | undefined
}
declare var j: J
declare var more: More
more = j`,
});
| {
"end_byte": 717,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixExactOptionalUnassignableProperties15.ts"
} |
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax21.ts_0_173 | /// <reference path='fourslash.ts' />
//// var index = { set p(x: [|*|]) { x; } };
verify.codeFix({
description: "Change '*' to 'any'",
newRangeContent: "any",
});
| {
"end_byte": 173,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax21.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUndeclaredPropertyFunctionEmptyClass.ts_0_463 | /// <reference path='fourslash.ts' />
//// [|class A {
//// constructor() {
//// this.x = function(x: number, y?: A){
//// return x > 0 ? x : y;
//// }
//// }
//// }|]
verify.rangeAfterCodeFix(`
class A {
x: (x: number, y?: A) => A;
constructor() {
this.x = function(x: number, y?: A){
return x > 0 ? x : y;
}
}
}
`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
| {
"end_byte": 463,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUndeclaredPropertyFunctionEmptyClass.ts"
} |
TypeScript/tests/cases/fourslash/extendsKeywordCompletion2.ts_0_237 | /// <reference path="fourslash.ts" />
////function f1<T /*1*/>() {}
////function f2<T ext/*2*/>() {}
verify.completions({
marker: ["1", "2"],
includes: [{ name: "extends", sortText: completion.SortText.GlobalsOrKeywords }]
});
| {
"end_byte": 237,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extendsKeywordCompletion2.ts"
} |
TypeScript/tests/cases/fourslash/unusedImportDeclaration_withEmptyPath1.ts_0_433 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////// leading trivia
////import * as foo from "";
////import { b } from "./b";
////import { c } from "./c";
// @Filename: /b.ts
////export const b = null;
// @Filename: /c.ts
////export const c = null;
verify.codeFix({
index: 0,
description: "Remove import from ''",
newFileContent:
`// leading trivia
import { b } from "./b";
import { c } from "./c";`,
});
| {
"end_byte": 433,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedImportDeclaration_withEmptyPath1.ts"
} |
TypeScript/tests/cases/fourslash/completionsObjectLiteralMethod1.ts_0_6167 | /// <reference path="fourslash.ts" />
// @newline: LF
// @Filename: a.ts
////interface IFoo {
//// bar(x: number): void;
////}
////
////const obj: IFoo = {
//// /*a*/
////}
////type Foo = {
//// bar(x: number): void;
//// foo: (x: string) => string;
////}
////
////const f: Foo = {
//// /*b*/
////}
////
////interface Overload {
//// buzz(a: number): number;
//// buzz(a: string): string;
////}
////const o: Overload = {
//// /*c*/
////}
////interface Prop {
//// "space bar"(): string;
////}
////const p: Prop = {
//// /*d*/
////}
verify.completions({
marker: "a",
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithObjectLiteralMethodSnippets: true,
useLabelDetailsInCompletionEntries: true,
},
includes: [
{
name: "bar",
sortText: completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "bar"),
insertText: undefined,
},
{
name: "bar",
sortText: completion.SortText.SortBelow(
completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "bar")),
source: completion.CompletionSource.ObjectLiteralMethodSnippet,
insertText: "bar(x) {\n},",
labelDetails: {
detail: "(x)",
},
},
],
});
verify.completions({
marker: "b",
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithObjectLiteralMethodSnippets: true,
useLabelDetailsInCompletionEntries: true,
},
includes: [
{
name: "bar",
sortText: completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "bar"),
insertText: undefined,
},
{
name: "bar",
sortText: completion.SortText.SortBelow(
completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "bar")),
source: completion.CompletionSource.ObjectLiteralMethodSnippet,
insertText: "bar(x) {\n},",
labelDetails: {
detail: "(x)",
},
},
{
name: "foo",
sortText: completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "foo"),
insertText: undefined,
},
{
name: "foo",
sortText: completion.SortText.SortBelow(
completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "foo")),
source: completion.CompletionSource.ObjectLiteralMethodSnippet,
insertText: "foo(x) {\n},",
labelDetails: {
detail: "(x)",
},
},
],
});
verify.completions({
marker: "c",
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithObjectLiteralMethodSnippets: true,
},
exact: [
{
name: "buzz",
sortText: completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "buzz"),
// no declaration insert text, because this property has overloads
insertText: undefined,
},
],
});
verify.completions({
marker: "d",
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithObjectLiteralMethodSnippets: true,
useLabelDetailsInCompletionEntries: true,
},
includes: [
{
name: "\"space bar\"",
sortText: completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "\"space bar\""),
insertText: undefined,
},
{
name: "\"space bar\"",
sortText: completion.SortText.SortBelow(
completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "\"space bar\"")),
source: completion.CompletionSource.ObjectLiteralMethodSnippet,
insertText: "\"space bar\"() {\n},",
labelDetails: {
detail: "()",
},
},
],
});
verify.completions({
marker: "a",
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: true,
includeCompletionsWithObjectLiteralMethodSnippets: true,
useLabelDetailsInCompletionEntries: true,
},
includes: [
{
name: "bar",
sortText: completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "bar"),
insertText: undefined,
},
{
name: "bar",
sortText: completion.SortText.SortBelow(
completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "bar")),
source: completion.CompletionSource.ObjectLiteralMethodSnippet,
isSnippet: true,
insertText: "bar(x) {\n $0\n},",
labelDetails: {
detail: "(x)",
},
},
],
});
verify.completions({
marker: "a",
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: true,
includeCompletionsWithObjectLiteralMethodSnippets: true,
useLabelDetailsInCompletionEntries: false,
},
includes: [
{
name: "bar",
sortText: completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "bar"),
insertText: undefined,
},
{
name: "bar(x)",
sortText: completion.SortText.SortBelow(
completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "bar")),
source: completion.CompletionSource.ObjectLiteralMethodSnippet,
isSnippet: true,
insertText: "bar(x) {\n $0\n},",
},
],
});
| {
"end_byte": 6167,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsObjectLiteralMethod1.ts"
} |
TypeScript/tests/cases/fourslash/mapCodeNestedLabeledReplace.ts_0_461 | ///<reference path="fourslash.ts"/>
// @Filename: /index.ts
//// function foo() {
//// const x: number = 1;
//// const y: number = 2;
//// myLabel: if (x === y) [||]{
//// console.log("hello");
//// console.log("you");
//// break myLabel;
//// }
//// return 1;
//// }
////
verify.baselineMapCode([test.ranges()], [
`
myLabel: if (y === x) {
console.log("goodbye");
console.log("world");
break myLabel;
}
`
]); | {
"end_byte": 461,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeNestedLabeledReplace.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccessRemoveGrammarErrors1.ts_0_467 | /// <reference path='fourslash.ts' />
//// const foo = {
//// /*a*/async a: 1/*b*/
//// }
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Generate 'get' and 'set' accessors",
actionName: "Generate 'get' and 'set' accessors",
actionDescription: "Generate 'get' and 'set' accessors",
newContent: `const foo = {
/*RENAME*/_a: 1,
get a() {
return this._a;
},
set a(value) {
this._a = value;
},
}`,
});
| {
"end_byte": 467,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccessRemoveGrammarErrors1.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType39.ts_0_372 | /// <reference path='fourslash.ts' />
//// type A = /*a*/(v: string | number) => v is string/*b*/;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent: `type /*RENAME*/NewType = (v: string | number) => v is string;
type A = NewType;`,
});
| {
"end_byte": 372,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType39.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_parameterInOverride.ts_0_321 | /// <reference path='fourslash.ts' />
// @noUnusedParameters: true
////interface I {
//// m(x: number): void;
////}
////
////class C implements I {
//// m(x: number): void {}
////}
// No codefix to remove the parameter, it's inherited
verify.codeFixAvailable([{ description: "Prefix 'x' with an underscore" }]);
| {
"end_byte": 321,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_parameterInOverride.ts"
} |
TypeScript/tests/cases/fourslash/navto_excludeLib1.ts_0_915 | /// <reference path="fourslash.ts"/>
// @filename: /index.ts
//// import { weirdName as otherName } from "bar";
//// const [|weirdName: number = 1|];
// @filename: /tsconfig.json
//// {}
// @filename: /node_modules/bar/index.d.ts
//// export const [|weirdName: number|];
// @filename: /node_modules/bar/package.json
//// {}
const [weird, otherWeird] = test.ranges();
verify.navigateTo({
pattern: "weirdName",
expected: [{
name: "weirdName",
kind: "const",
kindModifiers: "export,declare",
range: otherWeird,
matchKind: "exact",
},
{
name: "weirdName",
kind: "const",
range: weird,
matchKind: "exact",
}],
});
verify.navigateTo({
pattern: "weirdName",
excludeLibFiles: true,
expected: [{
name: "weirdName",
kind: "const",
range: weird,
matchKind: "exact",
}],
}); | {
"end_byte": 915,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navto_excludeLib1.ts"
} |
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class6.ts_0_358 | /// <reference path='fourslash.ts' />
// @allowNonTsExtensions: true
// @Filename: foo.js
////function Foo() {
//// this.a = 0;
////}
////Foo.prototype[1] = function () {
////}
verify.codeFix({
description: "Convert function to an ES2015 class",
newFileContent:
`class Foo {
constructor() {
this.a = 0;
}
1() {
}
}
`
});
| {
"end_byte": 358,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class6.ts"
} |
TypeScript/tests/cases/fourslash/renameUMDModuleAlias2.ts_3_321 | / <reference path='fourslash.ts' />
// @Filename: 0.d.ts
//// export function doThing(): string;
//// export function doTheOtherThing(): void;
//// export as namespace /**/[|myLib|];
// @Filename: 1.ts
//// /// <reference path="0.d.ts" />
//// myLib.doThing();
goTo.marker();
verify.renameInfoSucceeded("myLib"); | {
"end_byte": 321,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameUMDModuleAlias2.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport2.ts_0_1099 | /// <reference path="fourslash.ts" />
//@noEmit: true
//@Filename: /package.json
////{
//// "dependencies": {
//// "b_": "*",
//// "_c": "*"
//// }
////}
//@Filename: /node_modules/a/index.d.ts
////export const foo = 0;
//@Filename: /node_modules/a/package.json
////{
//// "name": "a",
//// "types": "./index.d.ts"
////}
//@Filename: /node_modules/b_/index.d.ts
////export { foo } from "a";
//@Filename: /node_modules/b_/package.json
////{
//// "name": "b_",
//// "types": "./index.d.ts"
////}
//@Filename: /node_modules/_c/index.d.ts
////export { foo } from "b_";
//@Filename: /node_modules/_c/package.json
////{
//// "name": "_c",
//// "types": "./index.d.ts"
////}
//@Filename: /src/index.ts
////fo/**/
verify.completions({
marker: test.marker(""),
includes: [
completion.undefinedVarEntry,
{
name: "foo",
source: "/node_modules/b_/index",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
...completion.statementKeywordsWithTypes
],
preferences: {
includeCompletionsForModuleExports: true
}
});
| {
"end_byte": 1099,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport2.ts"
} |
TypeScript/tests/cases/fourslash/completionsJsdocTypeTagCast.ts_0_281 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: /a.js
////const x = /** @type {{ s: string }} */ ({ /**/ });
verify.completions({
marker: "",
exact: [
"s",
{ name: "x", sortText: completion.SortText.JavascriptIdentifiers }
]
});
| {
"end_byte": 281,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsJsdocTypeTagCast.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsForStaticInstancePropertyInheritance.ts_0_444 | /// <reference path='fourslash.ts'/>
////class X{
//// /*0*/foo:any
////}
////
////class Y extends X{
//// static /*1*/foo:any
////}
////
////class Z extends Y{
//// static /*2*/foo:any
//// /*3*/foo:any
////}
////
////const x = new X();
////const y = new Y();
////const z = new Z();
////x./*4*/foo;
////y./*5*/foo;
////z./*6*/foo;
////Y./*7*/foo;
////Z./*8*/foo;
verify.baselineFindAllReferences('0', '1', '2', '3', '4', '5', '6', '7', '8')
| {
"end_byte": 444,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForStaticInstancePropertyInheritance.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType_js_TypeLiteral_CommentAfterProperty.ts_0_457 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: a.js
////type Foo = /*a*/[|{
//// oops: string;
//// /**
//// *
//// */
////}|]/*b*/;
goTo.file('a.js')
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to typedef",
actionDescription: "Extract to typedef",
newContent:
`/**
* @typedef {{
oops: string;
}} /*RENAME*/NewType
*/
type Foo = NewType;`,
});
| {
"end_byte": 457,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType_js_TypeLiteral_CommentAfterProperty.ts"
} |
TypeScript/tests/cases/fourslash/formattingAfterChainedFatArrow.ts_0_200 | /// <reference path="fourslash.ts" />
////var x = n => p => {
//// while (true) {
//// void 0;
//// }/**/
////};
goTo.marker();
format.document();
verify.currentLineContentIs(' }');
| {
"end_byte": 200,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingAfterChainedFatArrow.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceTypeLiterals.ts_0_866 | /// <reference path='fourslash.ts' />
////type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
////
////export type DeepPartial<T> = T extends Builtin ? T :
//// T extends Array<infer U> ? Array<DeepPartial<U>> :
//// T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> :
//// T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> } : Partial<T>;
////
////export interface Nested {
//// field: string;
////}
////
////interface Foo {
//// request(): DeepPartial<{ nested1: Nested; test2: Nested }>;
////}
////[|export class C implements Foo {}|]
verify.codeFix({
description: "Implement interface 'Foo'",
newRangeContent:
`export class C implements Foo {
request(): DeepPartial<{ nested1: Nested; test2: Nested; }> {
throw new Error("Method not implemented.");
}
}`,
});
| {
"end_byte": 866,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceTypeLiterals.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_NoRepeatCalls.ts_0_840 | /// <reference path='fourslash.ts' />
////let a = { b: ()=> {
//// return {
//// c: ()=> {
//// return {
//// d: 0
//// }
//// }
//// }
////}};
/////*1a*//*2a*/a && a.b && a.b().c/*1b*/ && a.b().c().d;/*2b*/
// We should stop at the first call for b since it may not be a pure function.
goTo.select("2a", "2b");
verify.not.refactorAvailable("Convert to optional chain expression");
goTo.select("1a", "1b");
edit.applyRefactor({
refactorName: "Convert to optional chain expression",
actionName: "Convert to optional chain expression",
actionDescription: "Convert to optional chain expression",
newContent:
`let a = { b: ()=> {
return {
c: ()=> {
return {
d: 0
}
}
}
}};
a?.b?.().c && a.b().c().d;`
}); | {
"end_byte": 840,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_NoRepeatCalls.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddConvertToUnknownForNonOverlappingTypes2.ts_0_225 | /// <reference path='fourslash.ts' />
////0 * (4 + 3) / 100 as string
verify.codeFix({
description: "Add 'unknown' conversion for non-overlapping types",
newFileContent: `0 * (4 + 3) / 100 as unknown as string`
});
| {
"end_byte": 225,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddConvertToUnknownForNonOverlappingTypes2.ts"
} |
TypeScript/tests/cases/fourslash/convertFunctionToEs6ClassJsDoc.ts_0_801 | /// <reference path='fourslash.ts' />
// @allowNonTsExtensions: true
// @Filename: test123.js
////function fn() {
//// /** neat! */
//// this.x = 100;
////}
////
/////** awesome
//// * stuff
//// */
////fn.prototype.arr = () => { return ""; }
/////** great */
////fn.prototype.arr2 = () => [];
////
/////**
//// * This is a cool function!
////*/
////fn.prototype.bar = function (y) {
//// this.x = y;
////};
verify.codeFix({
description: "Convert function to an ES2015 class",
newFileContent:
`class fn {
constructor() {
/** neat! */
this.x = 100;
}
/** awesome
* stuff
*/
arr() { return ""; }
/** great */
arr2() { return []; }
/**
* This is a cool function!
*/
bar(y) {
this.x = y;
}
}
`,
});
| {
"end_byte": 801,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6ClassJsDoc.ts"
} |
TypeScript/tests/cases/fourslash/extract-method30.ts_0_480 | /// <reference path='fourslash.ts' />
/////*a*/console.log(0) //
////console.log(0)/*b*/
format.setFormatOptions({ ...format.copyFormatOptions(), semicolons: ts.SemicolonPreference.Ignore });
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_0",
actionDescription: "Extract to function in global scope",
newContent:
`/*RENAME*/newFunction()
function newFunction() {
console.log(0) //
console.log(0)
}
`
});
| {
"end_byte": 480,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method30.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesIsDefinitionOfExport.ts_0_202 | /// <reference path='fourslash.ts' />
// @Filename: m.ts
////export var /*1*/x = 12;
// @Filename: main.ts
////import { /*2*/x } from "./m";
////const y = x;
verify.baselineFindAllReferences('1', '2')
| {
"end_byte": 202,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesIsDefinitionOfExport.ts"
} |
TypeScript/tests/cases/fourslash/formatDotAfterNumber.ts_0_584 | /// <reference path='fourslash.ts' />
////1+ 2 .toString() +3/*1*/
////1+ 2. .toString() +3/*2*/
////1+ 2.0 .toString() +3/*3*/
////1+ (2) .toString() +3/*4*/
////1+ 2_000 .toString() +3/*5*/
format.document();
goTo.marker("1");
verify.currentLineContentIs("1 + 2 .toString() + 3");
goTo.marker("2");
verify.currentLineContentIs("1 + 2..toString() + 3");
goTo.marker("3");
verify.currentLineContentIs("1 + 2.0.toString() + 3");
goTo.marker("4");
verify.currentLineContentIs("1 + (2).toString() + 3");
goTo.marker("5");
verify.currentLineContentIs("1 + 2_000 .toString() + 3");
| {
"end_byte": 584,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatDotAfterNumber.ts"
} |
TypeScript/tests/cases/fourslash/completionAfterQuestionDot.ts_0_1031 | /// <reference path="fourslash.ts" />
// @strict: true
//// class User {
//// #foo: User;
//// bar: User;
//// address?: {
//// city: string;
//// "postal code": string;
//// };
//// constructor() {
//// this.address[|?./*1*/|];
//// this[|?./*2*/|];
//// this?.bar[|?./*3*/|];
//// }
//// };
verify.completions({
marker: "1",
exact: [
{ name: "city", text: "(property) city: string" },
{ name: "postal code", text: "(property) \"postal code\": string", insertText: "?.[\"postal code\"]", replacementSpan: test.ranges()[0] }
],
preferences: { includeInsertTextCompletions: true },
});
verify.completions({
marker: "2",
exact: [
{ name: "address" },
{ name: "bar" },
],
preferences: { includeInsertTextCompletions: true },
});
verify.completions({
marker: "3",
exact: [
{ name: "address" },
{ name: "bar" },
],
preferences: { includeInsertTextCompletions: true },
});
| {
"end_byte": 1031,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionAfterQuestionDot.ts"
} |
TypeScript/tests/cases/fourslash/refactorOverloadListToSingleSignature4.ts_0_668 | /// <reference path='fourslash.ts' />
////class A {
//// /*a*/foo(): void;
//// foo(a: string): void;
//// foo(a: number, b: number): void;
//// foo(...rest: symbol[]): void;/*b*/
//// foo(...args: any[]): void {
//// // body
//// }
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert overload list to single signature",
actionName: "Convert overload list to single signature",
actionDescription: ts.Diagnostics.Convert_overload_list_to_single_signature.message,
newContent: `class A {
foo(...args: [] | [a: string] | [a: number, b: number] | [...rest: symbol[]]): void {
// body
}
}`,
});
| {
"end_byte": 668,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorOverloadListToSingleSignature4.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.