_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/codeFixAddMissingMember18_declarePrivateMethod.ts_0_687 | /// <reference path='fourslash.ts' />
////class A {
//// constructor() {
//// this._foo();
//// }
////}
verify.codeFixAvailable([
{ description: "Declare private method '_foo'" },
{ description: "Declare method '_foo'" },
{ description: "Declare private property '_foo'" },
{ description: "Declare property '_foo'" },
{ description: "Add index signature for property '_foo'" }
])
verify.codeFix({
description: [ts.Diagnostics.Declare_private_method_0.message, "_foo"],
index: 0,
newFileContent:
`class A {
constructor() {
this._foo();
}
private _foo() {
throw new Error("Method not implemented.");
}
}`
});
| {
"end_byte": 687,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember18_declarePrivateMethod.ts"
} |
TypeScript/tests/cases/fourslash/underscoreTypings01.ts_0_1279 | /// <reference path='fourslash.ts'/>
////interface Iterator_<T, U> {
//// (value: T, index: any, list: any): U;
////}
////
////interface WrappedArray<T> {
//// map<U>(iterator: Iterator_<T, U>, context?: any): U[];
////}
////
////interface Underscore {
//// <T>(list: T[]): WrappedArray<T>;
//// map<T, U>(list: T[], iterator: Iterator_<T, U>, context?: any): U[];
////}
////
////declare var _: Underscore;
////
////var a: string[];
////var /*1*/b = _.map(a, /*2*/x => x.length); // Was typed any[], should be number[]
////var /*3*/c = _(a).map(/*4*/x => x.length);
////var /*5*/d = a.map(/*6*/x => x.length);
////
////var aa: any[];
////var /*7*/bb = _.map(aa, /*8*/x => x.length);
////var /*9*/cc = _(aa).map(/*10*/x => x.length);
////var /*11*/dd = aa.map(/*12*/x => x.length);
////
////var e = a.map(x => x./*13*/
verify.quickInfos({
1: "var b: number[]",
2: "(parameter) x: string",
3: "var c: number[]",
4: "(parameter) x: string",
5: "var d: number[]",
6: "(parameter) x: string",
7: "var bb: any[]",
8: "(parameter) x: any",
9: "var cc: any[]",
10: "(parameter) x: any",
11: "var dd: any[]",
12: "(parameter) x: any"
});
verify.completions({ marker: "13", includes: "length", excludes: "toFixed" });
| {
"end_byte": 1279,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/underscoreTypings01.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_OnModuleSpecifier.ts_0_183 | /// <reference path='fourslash.ts' />
////import { x } from /*x*/"foo"/*y*/;
goTo.select("x", "y");
verify.not.refactorAvailable(ts.Diagnostics.Convert_to_template_string.message);
| {
"end_byte": 183,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_OnModuleSpecifier.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentStartLineInLists.ts_0_159 | /// <reference path='fourslash.ts'/>
////foo(function () {
////}).then(function () {/*1*/
////})
goTo.marker("1");
edit.insert("\n");
verify.indentationIs(4); | {
"end_byte": 159,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentStartLineInLists.ts"
} |
TypeScript/tests/cases/fourslash/completionListInFunctionDeclaration.ts_0_536 | /// <reference path='fourslash.ts' />
////var a = 0;
////function foo(/**/
verify.completions({ marker: "", exact: undefined });
edit.insert("a"); // foo(a|
verify.completions({ exact: undefined });
edit.insert(" , "); // foo(a ,|
verify.completions({ exact: undefined });
edit.insert("b"); // foo(a ,b|
verify.completions({ exact: undefined });
edit.insert(":"); // foo(a ,b:| <- type ref
verify.completions({ exact: completion.globalTypes });
edit.insert("number, "); // foo(a ,b:number,|
verify.completions({ exact: undefined });
| {
"end_byte": 536,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInFunctionDeclaration.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinition_mappedType.ts_0_180 | ///<reference path="fourslash.ts"/>
////interface I { /*def*/m(): void; };
////declare const i: { [K in "m"]: I[K] };
////i.[|/*ref*/m|]();
verify.baselineGoToDefinition("ref");
| {
"end_byte": 180,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinition_mappedType.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts_0_1728 | /// <reference path='fourslash.ts' />
// @noImplicitOverride: true
////abstract class A {
//// abstract get a(): number | string;
//// abstract get b(): this;
//// abstract get c(): A;
////
//// abstract set d(arg: number | string);
//// abstract set e(arg: this);
//// abstract set f(arg: A);
////
//// abstract get g(): string;
//// abstract set g(newName: string);
////}
////
////// Don't need to add anything in this case.
////abstract class B extends A {}
////
////class C extends A {}
verify.codeFix({
description: "Implement inherited abstract class",
newFileContent:
`abstract class A {
abstract get a(): number | string;
abstract get b(): this;
abstract get c(): A;
abstract set d(arg: number | string);
abstract set e(arg: this);
abstract set f(arg: A);
abstract get g(): string;
abstract set g(newName: string);
}
// Don't need to add anything in this case.
abstract class B extends A {}
class C extends A {
override get a(): string | number {
throw new Error("Method not implemented.");
}
override get b(): this {
throw new Error("Method not implemented.");
}
override get c(): A {
throw new Error("Method not implemented.");
}
override set d(arg: string | number) {
throw new Error("Method not implemented.");
}
override set e(arg: this) {
throw new Error("Method not implemented.");
}
override set f(arg: A) {
throw new Error("Method not implemented.");
}
override get g(): string {
throw new Error("Method not implemented.");
}
override set g(newName: string) {
throw new Error("Method not implemented.");
}
}`
});
| {
"end_byte": 1728,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_import_es6DefaultImport.ts_0_321 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @target: esnext
// @Filename: /a.js
////const x = require('x');
////x.default();
////const y = require('y').default;
////y();
verify.codeFix({
description: "Convert to ES module",
newFileContent:
`import x from 'x';
x();
import y from 'y';
y();`,
});
| {
"end_byte": 321,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_import_es6DefaultImport.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixOptionalImport0.ts_0_382 | /// <reference path="fourslash.ts" />
// @Filename: a/f1.ts
//// [|import * as ns from "./foo";
//// foo/*0*/();|]
// @Filename: a/foo/bar.ts
//// export function foo() {};
// @Filename: a/foo.ts
//// export { foo } from "./foo/bar";
verify.importFixAtPosition([
`import * as ns from "./foo";
ns.foo();`,
`import * as ns from "./foo";
import { foo } from "./foo";
foo();`,
]);
| {
"end_byte": 382,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixOptionalImport0.ts"
} |
TypeScript/tests/cases/fourslash/genericTypeWithMultipleBases1MultiFile.ts_0_814 | /// <reference path='fourslash.ts'/>
// @Filename: genericTypeWithMultipleBases_0.ts
////interface iBaseScope {
//// watch: () => void;
////}
// @Filename: genericTypeWithMultipleBases_1.ts
////interface iMover {
//// moveUp: () => void;
////}
// @Filename: genericTypeWithMultipleBases_2.ts
////interface iScope<TModel> extends iBaseScope, iMover {
//// family: TModel;
////}
// @Filename: genericTypeWithMultipleBases_3.ts
////var x: iScope<number>;
// @Filename: genericTypeWithMultipleBases_4.ts
////x./**/
verify.completions({
marker: "",
includes: [
{ name: "watch", text: "(property) iBaseScope.watch: () => void" },
{ name: "moveUp", text: "(property) iMover.moveUp: () => void" },
{ name: "family", text: "(property) iScope<number>.family: number" },
],
});
| {
"end_byte": 814,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericTypeWithMultipleBases1MultiFile.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoLink5.ts_0_168 | /// <reference path="fourslash.ts" />
////const A = 123;
/////**
//// * See {@link A| constant A} instead
//// */
////const /**/B = 456;
verify.baselineQuickInfo();
| {
"end_byte": 168,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoLink5.ts"
} |
TypeScript/tests/cases/fourslash/semanticModernClassificationVariables.ts_0_657 | //// var x = 9, y1 = [x];
//// try {
//// for (const s of y1) { x = s }
//// } catch (e) {
//// throw y1;
//// }
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("variable.declaration", "x"),
c2.semanticToken("variable.declaration", "y1"),
c2.semanticToken("variable", "x"),
c2.semanticToken("variable.declaration.readonly.local", "s"),
c2.semanticToken("variable", "y1"),
c2.semanticToken("variable", "x"),
c2.semanticToken("variable.readonly.local", "s"),
c2.semanticToken("variable.declaration.local", "e"),
c2.semanticToken("variable", "y1"),
);; | {
"end_byte": 657,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semanticModernClassificationVariables.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOfGenericTypeAssertions1.ts_0_351 | /// <reference path='fourslash.ts'/>
////function f<T>(x: T): T { return null; }
////var /*1*/r = <T>(x: T) => x;
////var /*2*/r2 = < <T>(x: T) => T>f;
////var a;
////var /*3*/r3 = < <T>(x: <A>(y: A) => A) => T>a;
verify.quickInfos({
1: "var r: <T>(x: T) => T",
2: "var r2: <T>(x: T) => T",
3: "var r3: <T>(x: <A>(y: A) => A) => T"
});
| {
"end_byte": 351,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOfGenericTypeAssertions1.ts"
} |
TypeScript/tests/cases/fourslash/completionListInImportClause06.ts_0_372 | /// <reference path='fourslash.ts' />
// @typeRoots: T1,T2
// @Filename: app.ts
////import * as A from "/*1*/";
// @Filename: T1/a__b/index.d.ts
////export declare let x: number;
// @Filename: T2/a__b/index.d.ts
////export declare let x: number;
// Confirm that entries are de-dup'd.
verify.completions({ marker: "1", exact: "@a/b", isNewIdentifierLocation: true });
| {
"end_byte": 372,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInImportClause06.ts"
} |
TypeScript/tests/cases/fourslash/outliningHintSpansForFunction.ts_0_337 | /// <reference path="fourslash.ts"/>
////[|namespace NS {
//// [|function f(x: number, y: number) {
//// return x + y;
//// }|]
////
//// [|function g(
//// x: number,
//// y: number,
//// ): number {
//// return x + y;
//// }|]
////}|]
verify.outliningHintSpansInCurrentFile(test.ranges());
| {
"end_byte": 337,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/outliningHintSpansForFunction.ts"
} |
TypeScript/tests/cases/fourslash/completionInAugmentedClassModule.ts_0_208 | /// <reference path='fourslash.ts'/>
////declare class m3f { foo(x: number): void }
////module m3f { export interface I { foo(): void } }
////var x: m3f./**/
verify.completions({ marker: "", exact: "I" });
| {
"end_byte": 208,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionInAugmentedClassModule.ts"
} |
TypeScript/tests/cases/fourslash/tsxCompletion8.ts_0_338 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// div: { ONE: string; TWO: number; }
//// }
//// }
//// var x = <div /*1*/ autoComplete /*2*/ />;
verify.completions({ marker: ["1", "2"], exact: ["ONE", "TWO"] });
| {
"end_byte": 338,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletion8.ts"
} |
TypeScript/tests/cases/fourslash/jsDocTypeTagQuickInfo1.ts_3_724 | / <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: jsDocTypeTag1.js
//// /** @type {String} */
//// var /*1*/S;
//// /** @type {Number} */
//// var /*2*/N;
//// /** @type {Boolean} */
//// var /*3*/B;
//// /** @type {Void} */
//// var /*4*/V;
//// /** @type {Undefined} */
//// var /*5*/U;
//// /** @type {Null} */
//// var /*6*/Nl;
//// /** @type {Array} */
//// var /*7*/A;
//// /** @type {Promise} */
//// var /*8*/P;
//// /** @type {Object} */
//// var /*9*/Obj;
//// /** @type {Function} */
//// var /*10*/Func;
//// /** @type {*} */
//// var /*11*/AnyType;
//// /** @type {?} */
//// var /*12*/QType;
//// /** @type {String|Number} */
//// var /*13*/SOrN;
verify.baselineQuickInfo(); | {
"end_byte": 724,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocTypeTagQuickInfo1.ts"
} |
TypeScript/tests/cases/fourslash/squiggleIllegalInterfaceExtension.ts_0_224 | /// <reference path="fourslash.ts"/>
////var n = '';/**/
////interface x extends /*1*/string/*2*/ {}
verify.not.errorExistsBeforeMarker();
verify.errorExistsBetweenMarkers("1", "2");
verify.numberOfErrorsInCurrentFile(1);
| {
"end_byte": 224,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/squiggleIllegalInterfaceExtension.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCalledES2015Import5.ts_0_408 | /// <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 from "./foo";'.`,
newRangeContent: `import foo from "./foo";`,
index: 0,
});
| {
"end_byte": 408,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCalledES2015Import5.ts"
} |
TypeScript/tests/cases/fourslash/completionsOverridingMethod9.ts_0_839 | /// <reference path="fourslash.ts" />
// @Filename: a.ts
// @newline: LF
////interface IFoo {
//// a?: number;
//// b?(x: number): void;
////}
////class Foo implements IFoo {
//// /**/
////}
verify.completions({
marker: "",
isNewIdentifierLocation: true,
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithClassMemberSnippets: true,
},
includes: [
{
name: "a",
sortText: completion.SortText.LocationPriority,
insertText: "a?: number;",
filterText: "a",
},
{
name: "b",
sortText: completion.SortText.LocationPriority,
insertText: "b(x: number): void {\n}",
filterText: "b",
},
],
});
| {
"end_byte": 839,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingMethod9.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptQuickInfo8.ts_0_639 | /// <reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: file.js
//// let x = {
//// /** @type {number} */
//// get m() {
//// return undefined;
//// }
//// }
//// x.m/*1*/;
////
//// class Foo {
//// /** @type {string} */
//// get b() {
//// return undefined;
//// }
//// }
//// var y = new Foo();
//// y.b/*2*/;
goTo.marker('1');
edit.insert('.');
verify.completions({ includes: { name: "toFixed", kind: "method", kindModifiers: "declare" } });
edit.backspace();
goTo.marker('2');
edit.insert('.');
verify.completions({ includes: { name: "substring", kind: "method", kindModifiers: "declare" } });
| {
"end_byte": 639,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptQuickInfo8.ts"
} |
TypeScript/tests/cases/fourslash/extract-method25.ts_0_504 | /// <reference path='fourslash.ts' />
// Preserve newlines correctly when semicolons aren't present
//// function fn() {
//// var q = /*a*/[0]/*b*/
//// q[0]++
//// }
goTo.select('a', 'b')
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_0",
actionDescription: "Extract to inner function in function 'fn'",
newContent:
`function fn() {
var q = /*RENAME*/newFunction()
q[0]++
function newFunction() {
return [0]
}
}`
});
| {
"end_byte": 504,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method25.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationTryCatchFinally.ts_0_590 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_tryCatchFinally.baseline
// @Filename: bpSpan_tryCatchFinally.ts
////var x = 10;
////try {
//// x = x + 1;
////} catch (e) {
//// x = x - 1;
////} finally {
//// x = x * 10;
////}
////try
////{
//// x = x + 1;
//// throw new Error();
////}
////catch (e)
////{
//// x = x - 1;
////}
////finally
////{
//// x = x * 10;
////}
////try {
//// throw (function foo() {
//// new Error(x.toString());
//// })();
////}
////finally {
//// x++;
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 590,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationTryCatchFinally.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassifications1.ts_0_1789 | /// <reference path="fourslash.ts"/>
//// // comment
//// module M {
//// var v = 0 + 1;
//// var s = "string";
////
//// class C<T> {
//// }
////
//// enum E {
//// }
////
//// interface I {
//// }
////
//// module M1.M2 {
//// }
//// }
const c = classification("original");
verify.syntacticClassificationsAre(
c.comment("// comment"),
c.keyword("module"), c.moduleName("M"), c.punctuation("{"),
c.keyword("var"), c.identifier("v"), c.operator("="), c.numericLiteral("0"), c.operator("+"), c.numericLiteral("1"), c.punctuation(";"),
c.keyword("var"), c.identifier("s"), c.operator("="), c.stringLiteral('"string"'), c.punctuation(";"),
c.keyword("class"), c.className("C"), c.punctuation("<"), c.typeParameterName("T"), c.punctuation(">"), c.punctuation("{"),
c.punctuation("}"),
c.keyword("enum"), c.enumName("E"), c.punctuation("{"),
c.punctuation("}"),
c.keyword("interface"), c.interfaceName("I"), c.punctuation("{"),
c.punctuation("}"),
c.keyword("module"), c.moduleName("M1"), c.punctuation("."), c.moduleName("M2"), c.punctuation("{"),
c.punctuation("}"),
c.punctuation("}"));
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("namespace.declaration", "M"),
c2.semanticToken("variable.declaration.local", "v"),
c2.semanticToken("variable.declaration.local", "s"),
c2.semanticToken("class.declaration", "C"),
c2.semanticToken("typeParameter.declaration", "T"),
c2.semanticToken("enum.declaration", "E"),
c2.semanticToken("interface.declaration", "I"),
c2.semanticToken("namespace.declaration", "M1"),
c2.semanticToken("namespace.declaration", "M2"),
);
| {
"end_byte": 1789,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassifications1.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_moveJsxImport1.ts_0_393 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @noLib: true
// @libFiles: react.d.ts,lib.d.ts
// @Filename: file.tsx
//// import React = require('react');
//// [|<div/>;|]
//// 1;
verify.moveToNewFile({
newFileContents: {
"/tests/cases/fourslash/file.tsx":
`1;`,
"/tests/cases/fourslash/newFile.tsx":
`import React = require('react');
<div />;
`,
}
});
| {
"end_byte": 393,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_moveJsxImport1.ts"
} |
TypeScript/tests/cases/fourslash/referencesForGlobals4.ts_0_296 | /// <reference path='fourslash.ts'/>
// Global module reference.
// @Filename: referencesForGlobals_1.ts
/////*1*/module /*2*/globalModule {
//// export f() { };
////}
// @Filename: referencesForGlobals_2.ts
////var m = /*3*/globalModule;
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 296,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForGlobals4.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_set.ts_0_438 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
////class C {
//// set x(value: number) {}
////}
// No codefix to remove parameter, since setter must have a parameter
verify.codeFixAvailable([{ description: "Prefix 'value' with an underscore" }]);
verify.codeFix({
description: "Prefix 'value' with an underscore",
newFileContent:
`class C {
set x(_value: number) {}
}`,
});
| {
"end_byte": 438,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_set.ts"
} |
TypeScript/tests/cases/fourslash/renameForDefaultExport07.ts_0_445 | /// <reference path='fourslash.ts'/>
// @Filename: foo.ts
////export default function /**/[|DefaultExportedFunction|]() {
//// return DefaultExportedFunction
////}
/////**
//// * Commenting DefaultExportedFunction
//// */
////
////var x: typeof DefaultExportedFunction;
////
////var y = DefaultExportedFunction();
goTo.marker();
verify.renameInfoSucceeded("DefaultExportedFunction", '"/tests/cases/fourslash/foo".DefaultExportedFunction'); | {
"end_byte": 445,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameForDefaultExport07.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingAwait_signatures2.ts_0_1253 | /// <reference path="fourslash.ts" />
////async function fn(a: Promise<() => void>, b: Promise<() => void> | (() => void), C: Promise<{ new(): any }>) {
//// a()
//// b()
//// new C()
////}
verify.codeFix({
description: ts.Diagnostics.Add_await.message,
index: 0,
newFileContent:
`async function fn(a: Promise<() => void>, b: Promise<() => void> | (() => void), C: Promise<{ new(): any }>) {
(await a)()
b()
new C()
}`
});
verify.codeFix({
description: ts.Diagnostics.Add_await.message,
index: 1,
newFileContent:
`async function fn(a: Promise<() => void>, b: Promise<() => void> | (() => void), C: Promise<{ new(): any }>) {
a()
;(await b)()
new C()
}`
});
verify.codeFix({
description: ts.Diagnostics.Add_await.message,
index: 2,
newFileContent:
`async function fn(a: Promise<() => void>, b: Promise<() => void> | (() => void), C: Promise<{ new(): any }>) {
a()
b()
new (await C)()
}`
});
verify.codeFixAll({
fixAllDescription: ts.Diagnostics.Fix_all_expressions_possibly_missing_await.message,
fixId: "addMissingAwait",
newFileContent:
`async function fn(a: Promise<() => void>, b: Promise<() => void> | (() => void), C: Promise<{ new(): any }>) {
(await a)()
;(await b)()
new (await C)()
}`
});
| {
"end_byte": 1253,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAwait_signatures2.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_refactorAvailable2.ts_0_381 | /// <reference path='fourslash.ts' />
/////*a*/
////namespace ns {
//// export function fn() {
//// }
//// fn();
////}
/////*b*/
goTo.select("a", "b");
verify.refactorAvailable("Move to a new file",
/*actionName*/ undefined,
/*actionDescription*/ undefined,
/*kind*/ undefined,
{
allowTextChangesInNewFiles: true
},
/*includeInteractiveActions*/ true);
| {
"end_byte": 381,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_refactorAvailable2.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsJsDocTemplateTag_class.ts_0_134 | /// <reference path='fourslash.ts'/>
/////** @template /*1*/T */
////class C</*2*/T> {}
verify.baselineFindAllReferences('1', '2');
| {
"end_byte": 134,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsJsDocTemplateTag_class.ts"
} |
TypeScript/tests/cases/fourslash/renameImportOfReExport.ts_0_812 | /// <reference path='fourslash.ts' />
// @noLib: true
////declare module "a" {
//// [|export class /*1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}C|] {}|]
////}
////declare module "b" {
//// [|export { /*2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}C|] } from "a";|]
////}
////declare module "c" {
//// [|import { /*3*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}C|] } from "b";|]
//// export function f(c: [|C|]): void;
////}
verify.noErrors();
const ranges = test.ranges();
const [r0Def, r0, r1Def, r1, r2Def, r2, r3] = ranges;
const importRanges = [r2, r3];
verify.baselineFindAllReferences('1', '2', '3');
verify.baselineRename(r0);
verify.baselineRename(r1);
verify.baselineRename(importRanges); | {
"end_byte": 812,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameImportOfReExport.ts"
} |
TypeScript/tests/cases/fourslash/jsdocDeprecated_suggestion10.ts_0_713 | ///<reference path="fourslash.ts" />
// @filename: foo.ts
////export namespace foo {
//// /** @deprecated */
//// export const bar = 1;
//// [|bar|];
////}
////foo.[|bar|];
////foo[[|"bar"|]];
goTo.file('foo.ts');
const ranges = test.ranges();
verify.getSuggestionDiagnostics([
{
"code": 6385,
"message": "'bar' is deprecated.",
"reportsDeprecated": true,
"range": ranges[0]
},
{
"code": 6385,
"message": "'bar' is deprecated.",
"reportsDeprecated": true,
"range": ranges[1]
},
{
"code": 6385,
"message": "'bar' is deprecated.",
"reportsDeprecated": true,
"range": ranges[2]
},
]);
| {
"end_byte": 713,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocDeprecated_suggestion10.ts"
} |
TypeScript/tests/cases/fourslash/unusedParameterInFunction2.ts_0_248 | /// <reference path='fourslash.ts' />
// @noUnusedParameters: true
////function [|greeter(x,y)|] {
//// use(x);
////}
verify.codeFix({
description: "Remove unused declaration for: 'y'",
index: 0,
newRangeContent: "greeter(x)",
});
| {
"end_byte": 248,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedParameterInFunction2.ts"
} |
TypeScript/tests/cases/fourslash/completionsGenericIndexedAccess1.ts_0_322 | /// <reference path="fourslash.ts" />
// #34825
////interface Sample {
//// addBook: { name: string, year: number }
////}
////
////export declare function testIt<T>(method: T[keyof T]): any
////testIt<Sample>({ /**/ });
verify.completions({
marker: '',
exact: [
{ name: 'name' },
{ name: 'year' },
]
});
| {
"end_byte": 322,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsGenericIndexedAccess1.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsModuleAugmentation.ts_0_307 | /// <reference path='fourslash.ts' />
// @Filename: /node_modules/foo/index.d.ts
/////*1*/export type /*2*/T = number;
// @Filename: /a.ts
////import * as foo from "foo";
////declare module "foo" {
//// export const x: /*3*/T;
////}
verify.noErrors();
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 307,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsModuleAugmentation.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_JSDocTags1.ts_0_169 | /// <reference path="fourslash.ts" />
/////**
//// * @returns {Array<{ value: /**/string }>}
//// */
////function foo() { return [] }
verify.baselineSmartSelection();
| {
"end_byte": 169,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_JSDocTags1.ts"
} |
TypeScript/tests/cases/fourslash/completionsAugmentedTypesClass2.ts_0_336 | /// <reference path='fourslash.ts'/>
////class c5b { public foo(){ } }
////module c5b { var y = 2; } // should be ok
////c5b./*1*/
////var r = new c5b();
////r./*2*/
verify.completions({ marker: "1", excludes: ["y"] });
edit.backspace(4);
verify.completions({ marker: "2", exact: { name: "foo", text: "(method) c5b.foo(): void" } });
| {
"end_byte": 336,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsAugmentedTypesClass2.ts"
} |
TypeScript/tests/cases/fourslash/formattingIfInElseBlock.ts_0_190 | /// <reference path='fourslash.ts' />
////if (true) {
////}
////else {
//// if (true) {
//// /*1*/
////}
goTo.marker("1");
edit.insert("}")
verify.currentLineContentIs(" }");
| {
"end_byte": 190,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingIfInElseBlock.ts"
} |
TypeScript/tests/cases/fourslash/codeFixConvertToTypeOnlyExport3.ts_0_1059 | /// <reference path="fourslash.ts" />
// @isolatedModules: true
// @Filename: /a.ts
////export type T1 = {};
////export const V1 = {};
////export type T2 = {};
// @Filename: /b.ts
////export type T3 = {};
////export const V2 = {};
////export type T4 = {};
////export type T5 = {};
// @Filename: /c.ts
////export type T6 = {};
////export type T7 = {};
// @Filename: /d.ts
/////* Test comment */
////export { T1, V1, T2 } from './a';
////export { T3, V2, T4, T5 } from './b';
////// TODO: fix messy formatting
////export {
//// T6 // need to export this
//// , T7, /* and this */ } from "./c";
goTo.file("/d.ts");
verify.codeFixAll({
fixAllDescription: ts.Diagnostics.Convert_all_re_exported_types_to_type_only_exports.message,
fixId: "convertToTypeOnlyExport",
newFileContent:
`/* Test comment */
export { V1 } from './a';
export type { T1, T2 } from './a';
export { V2 } from './b';
export type { T3, T4, T5 } from './b';
// TODO: fix messy formatting
export type {
T6 // need to export this
, T7, /* and this */ } from "./c";`
});
| {
"end_byte": 1059,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToTypeOnlyExport3.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString7.ts_0_445 | /// <reference path='fourslash.ts' />
////const foo = 1;
////const bar = /*start*/"a " + `${foo}` + " b " + " c"/*end*/;
goTo.select("start", "end");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
newContent: [
"const foo = 1;",
"const bar = `a ${foo} b c`;"
].join("\n")
});
| {
"end_byte": 445,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString7.ts"
} |
TypeScript/tests/cases/fourslash/formatSelectionWithTrivia.ts_0_274 | /// <reference path="fourslash.ts" />
////if (true) {
//// //
//// /*begin*/
//// //
//// ;
////
//// }/*end*/
format.selection('begin', 'end');
verify.currentFileContentIs("if (true) { \n // \n\n // \n ;\n\n}");
| {
"end_byte": 274,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatSelectionWithTrivia.ts"
} |
TypeScript/tests/cases/fourslash/extractFunctionContainingThis3.ts_0_732 | /// <reference path='fourslash.ts' />
////const foo = {
//// bar: "1",
//// baz() {
//// /*start*/console.log(this);
//// console.log(this.bar);/*end*/
//// }
////}
goTo.select("start", "end");
verify.refactorAvailable("Extract Symbol", "function_scope_0");
verify.refactorAvailable("Extract Symbol", "function_scope_1");
goTo.select("start", "end");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_1",
actionDescription: "Extract to function in global scope",
newContent:
`const foo = {
bar: "1",
baz() {
/*RENAME*/newFunction.call(this);
}
}
function newFunction(this: any) {
console.log(this);
console.log(this.bar);
}
`
}); | {
"end_byte": 732,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extractFunctionContainingThis3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddOptionalParam1.ts_0_256 | /// <reference path="fourslash.ts" />
////[|function f() {}|]
////
////const a = 1;
////f(a);
verify.codeFix({
description: [ts.Diagnostics.Add_optional_parameter_to_0.message, "f"],
index: 1,
newRangeContent: "function f(a?: number) {}"
});
| {
"end_byte": 256,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddOptionalParam1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInvalidJsxCharacters10.ts_0_332 | /// <reference path='fourslash.ts' />
// @jsx: react
// @filename: main.tsx
//// let foo = <div>></div>;
verify.codeFix({
index: 0,
description: ts.Diagnostics.Wrap_invalid_character_in_an_expression_container.message,
newFileContent: `let foo = <div>{">"}</div>;`,
preferences: { quotePreference: "double" }
});
| {
"end_byte": 332,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInvalidJsxCharacters10.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionDynamicImport3.ts_3_221 | / <reference path='fourslash.ts' />
// @Filename: foo.ts
//// export function /*Destination*/bar() { return "bar"; }
//// import('./foo').then(({ [|ba/*1*/r|] }) => undefined);
verify.baselineGoToDefinition("1");
| {
"end_byte": 221,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionDynamicImport3.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefs_importType_js.3.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.3.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpCallExpression.ts_0_430 | /// <reference path='fourslash.ts'/>
////function fnTest(str: string, num: number) { }
////fnTest(/*1*/'', /*2*/5);
verify.signatureHelp(
{
marker: "1",
text: 'fnTest(str: string, num: number): void',
parameterCount: 2,
parameterName: "str",
parameterSpan: "str: string",
},
{
marker: "2",
parameterName: "num",
parameterSpan: "num: number",
},
);
| {
"end_byte": 430,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpCallExpression.ts"
} |
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax_all_nullable.ts_0_339 | /// <reference path='fourslash.ts' />
// @strict: true
////function f(a: ?number, b: string!) {}
verify.codeFixAll({
fixId: "fixJSDocTypes_nullable",
fixAllDescription: "Change all jsdoc-style types to TypeScript (and add '| undefined' to nullable types)",
newFileContent: "function f(a: number | null | undefined, b: string) {}",
})
| {
"end_byte": 339,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax_all_nullable.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnJsxIntrinsicDeclaredUsingTemplateLiteralTypeSignatures.ts_0_364 | /// <reference path="fourslash.ts" />
// https://github.com/microsoft/TypeScript/issues/55240
// @jsx: react
// @filename: /a.tsx
//// declare namespace JSX {
//// interface IntrinsicElements {
//// [k: `foo${string}`]: any;
//// [k: `foobar${string}`]: any;
//// }
//// }
//// </*1*/foobaz />;
//// </*2*/foobarbaz />;
verify.baselineQuickInfo();
| {
"end_byte": 364,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnJsxIntrinsicDeclaredUsingTemplateLiteralTypeSignatures.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs.ts_0_905 | /// <reference path='fourslash.ts' />
//// class A {
//// constructor() {
//// this.foo1(() => 1, () => "2", () => false);
//// this.foo2((a: number) => a, (b: string) => b, (c: boolean) => c);
//// }[|
//// |]
//// }
verify.codeFix({
description: "Declare method 'foo1'",
index: 0,
newRangeContent: `
foo1(arg0: () => number, arg1: () => string, arg2: () => boolean) {
throw new Error("Method not implemented.");
}
`,
applyChanges: true,
});
verify.codeFix({
description: "Declare method 'foo2'",
index: 0,
newRangeContent: `
foo2(arg0: (a: number) => number, arg1: (b: string) => string, arg2: (c: boolean) => boolean) {
throw new Error("Method not implemented.");
}
foo1(arg0: () => number, arg1: () => string, arg2: () => boolean) {
throw new Error("Method not implemented.");
}
`,
});
| {
"end_byte": 905,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs.ts"
} |
TypeScript/tests/cases/fourslash/renameDestructuringAssignmentNestedInArrayLiteral.ts_0_507 | /// <reference path='fourslash.ts' />
////interface I {
//// [|[|{| "contextRangeIndex": 0 |}property1|]: number;|]
//// property2: string;
////}
////var elems: I[], p1: number, [|[|{| "contextRangeIndex": 2 |}property1|]: number|];
////[|[{ [|{| "contextRangeIndex": 4 |}property1|]: p1 }] = elems;|]
////[|[{ [|{| "contextRangeIndex": 6 |}property1|] }] = elems;|]
const ranges = test.ranges();
const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3] = ranges;
verify.baselineRename([r0, r2, r1, r3]);
| {
"end_byte": 507,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameDestructuringAssignmentNestedInArrayLiteral.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_named_addToNamedImports.ts_0_739 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export function foo() {}
////export const x = 0;
// @Filename: /b.ts
////import { x } from "./a";
////f/**/;
verify.completions({
marker: "",
includes: {
name: "foo",
source: "/a",
sourceDisplay: "./a",
text: "function foo(): void",
kind: "function",
kindModifiers: "export",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences: { includeCompletionsForModuleExports: true },
});
verify.applyCodeActionFromCompletion("", {
name: "foo",
source: "/a",
description: `Update import from "./a"`,
newFileContent: `import { foo, x } from "./a";
f;`,
});
| {
"end_byte": 739,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_named_addToNamedImports.ts"
} |
TypeScript/tests/cases/fourslash/completionsWithDeprecatedTag6.ts_0_374 | /// <reference path="fourslash.ts"/>
////module Foo {
//// /** @deprecated foo */
//// export var foo: number;
////}
////Foo./**/
verify.completions({
marker: "",
exact: [{
name: "foo",
kind: "var",
kindModifiers: "export,deprecated",
sortText: completion.SortText.Deprecated(completion.SortText.LocationPriority),
}]
});
| {
"end_byte": 374,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsWithDeprecatedTag6.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionVariableAssignment.ts_0_279 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @filename: foo.js
////const Bar;
////const Foo = /*def*/Bar = function () {}
////Foo.prototype.bar = function() {}
////new [|Foo/*ref*/|]();
goTo.file("foo.js");
verify.baselineGoToDefinition("ref");
| {
"end_byte": 279,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionVariableAssignment.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnon_SingleLine.ts_0_365 | /// <reference path='fourslash.ts' />
//// const foo = /*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: `const foo = function() {
return 1 + 1;
};`,
});
| {
"end_byte": 365,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnon_SingleLine.ts"
} |
TypeScript/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard8.ts_0_562 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @Filename: /node_modules/foo/package.json
//// {
//// "name": "foo",
//// "exports": {
//// "./*": "./dist/*.js"
//// }
//// }
// @Filename: /node_modules/foo/dist/blah.js
//// export const blah = 0;
// @Filename: /node_modules/foo/dist/blah.d.ts
//// export declare const blah: 0;
// @Filename: /index.mts
//// import { } from "foo//**/";
verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: [
{ name: "blah", kind: "script", kindModifiers: "" },
]
});
| {
"end_byte": 562,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard8.ts"
} |
TypeScript/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_properties.ts_0_521 | /// <reference path='fourslash.ts' />
////var aa = 1;
////class A1 {
//// /*property1*/
////}
////class A2 {
//// p/*property2*/
////}
////class A3 {
//// public s/*property3*/
////}
////class A4 {
//// a/*property4*/
////}
////class A5 {
//// public a/*property5*/
////}
////class A6 {
//// protected a/*property6*/
////}
////class A7 {
//// private a/*property7*/
////}
verify.completions({ marker: test.markers(), exact: completion.classElementKeywords, isNewIdentifierLocation: true });
| {
"end_byte": 521,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_properties.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingCallParentheses10.ts_0_584 | /// <reference path='fourslash.ts'/>
// @strictNullChecks: true
////class Foo {
//// #test = () => true;
//// run() {
//// if (this.#test/**/) {
//// console.log('test')
//// }
//// }
////}
verify.codeFixAvailable([
{ description: ts.Diagnostics.Add_missing_call_parentheses.message }
]);
verify.codeFix({
description: ts.Diagnostics.Add_missing_call_parentheses.message,
index: 0,
newFileContent:
`class Foo {
#test = () => true;
run() {
if (this.#test()) {
console.log('test')
}
}
}`,
});
| {
"end_byte": 584,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingCallParentheses10.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics5.ts_0_145 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: a.js
////class C implements D { }
verify.baselineSyntacticDiagnostics();
| {
"end_byte": 145,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics5.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsNoSubstitutionTemplateLiteralNoCrash1.ts_0_106 | /// <reference path='fourslash.ts' />
//// type Test = `T/*1*/`;
verify.baselineFindAllReferences('1');
| {
"end_byte": 106,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsNoSubstitutionTemplateLiteralNoCrash1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageArrow.ts_0_387 | /// <reference path='fourslash.ts' />
////const a = (x) => x;
////const b = x => x;
////const c = x => x + 1;
////const d = x => x;
////d(1);
verify.codeFixAll({
fixId: "inferFromUsage",
fixAllDescription: "Infer all types from usage",
newFileContent: `const a = (x: any) => x;
const b = (x: any) => x;
const c = (x: number) => x + 1;
const d = (x: number) => x;
d(1);`,
});
| {
"end_byte": 387,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageArrow.ts"
} |
TypeScript/tests/cases/fourslash/mapCodeMixedClassDeclaration.ts_0_334 | ///<reference path="fourslash.ts"/>
// @Filename: /index.ts
//// class MyClass {[||]
//// x = 1;
//// foo() {
//// return 1;
//// }
//// bar() {
//// return 2;
//// }
//// }
////
verify.baselineMapCode([test.ranges()], [
`
x = 3;
bar() {
return 'hello';
}
baz() {
return 3;
}
y = 2;
`
]); | {
"end_byte": 334,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeMixedClassDeclaration.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties19.ts_0_743 | /// <reference path='fourslash.ts' />
////export interface Foo<T> {
//// z(...args: T extends unknown[] ? T : [T]);
////}
////export interface Bar {
//// a(foo: Foo<[number]>): void;
//// b(foo: Foo<[]>): void;
//// c(foo: Foo<number>): void;
////}
////[|const bar: Bar = {};|]
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newRangeContent:
`const bar: Bar = {
a: function(foo: Foo<[number]>): void {
throw new Error("Function not implemented.");
},
b: function(foo: Foo<[]>): void {
throw new Error("Function not implemented.");
},
c: function(foo: Foo<number>): void {
throw new Error("Function not implemented.");
}
};`,
});
| {
"end_byte": 743,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties19.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassExprExtendsAbstractExpressionWithTypeArgs.ts_0_497 | /// <reference path='fourslash.ts' />
////function foo<T>(a: T) {
//// a;
//// abstract class C<U> {
//// abstract a: T | U;
//// }
//// return C;
////}
////
////let B = class extends foo("s")<number> {}
verify.codeFix({
description: "Implement inherited abstract class",
newFileContent:
`function foo<T>(a: T) {
a;
abstract class C<U> {
abstract a: T | U;
}
return C;
}
let B = class extends foo("s")<number> {
a: string | number;
}`
});
| {
"end_byte": 497,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassExprExtendsAbstractExpressionWithTypeArgs.ts"
} |
TypeScript/tests/cases/fourslash/codeFixImportNonExportedMember13.ts_0_450 | /// <reference path="fourslash.ts" />
// @module: esnext
// @isolatedModules: true
// @filename: /a.ts
////type T1 = {};
////type T2 = {};
////export type { T1 };
// @filename: /b.ts
////import { T2 } from "./a";
goTo.file("/b.ts");
verify.codeFix({
description: [ts.Diagnostics.Export_0_from_module_1.message, "T2", "./a"],
index: 0,
newFileContent: {
"/a.ts":
`type T1 = {};
type T2 = {};
export type { T1, T2 };`,
}
});
| {
"end_byte": 450,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImportNonExportedMember13.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts_0_177 | /// <reference path='fourslash.ts'/>
////type Options = "/*1*/option 1" | "option 2";
////let myOption: Options = "/*2*/option 1";
verify.baselineFindAllReferences('1', '2');
| {
"end_byte": 177,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationInterfaceMethod_08.ts_0_421 | /// <reference path='fourslash.ts'/>
// Should handle calls made on this
//// interface Foo {
//// hello (): void;
//// }
////
//// class SuperBar implements Foo {
//// [|hello|]() {}
//// }
////
//// class Bar extends SuperBar {
//// whatever() { this.he/*function_call*/llo(); }
//// }
////
//// class SubBar extends Bar {
//// [|hello|]() {}
//// }
verify.baselineGoToImplementation("function_call");
| {
"end_byte": 421,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationInterfaceMethod_08.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsDocComment3.ts_0_591 | /// <reference path="fourslash.ts"/>
//// /** @param foo { number /* } */
//// var v;
const c = classification("original");
verify.syntacticClassificationsAre(
c.comment("/** "),
c.punctuation("@"),
c.docCommentTagName("param"),
c.comment(" "),
c.parameterName("foo"),
c.comment(" "),
c.punctuation("{"),
c.keyword("number"),
c.comment(" /* } */"),
c.keyword("var"),
c.identifier("v"),
c.punctuation(";"));
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("variable.declaration", "v"),
);
| {
"end_byte": 591,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsDocComment3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization20.ts_0_251 | /// <reference path='fourslash.ts' />
// @strict: true
//// class T {
//// a: 2; // comment
//// }
verify.codeFix({
description: `Add initializer to property 'a'`,
newFileContent: `class T {
a: 2 = 2; // comment
}`,
index: 2
})
| {
"end_byte": 251,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization20.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_packageJsonImportsPreference.ts_0_1278 | /// <reference path="fourslash.ts" />
// @module: preserve
// @allowImportingTsExtensions: true
// @Filename: /project/package.json
//// {
//// "name": "project",
//// "version": "1.0.0",
//// "imports": {
//// "#internal/*": "./src/internal/*.ts"
//// }
//// }
// @Filename: /project/src/internal/foo.ts
//// export const internalFoo = 0;
// @Filename: /project/src/other.ts
//// export * from "./internal/foo.ts";
// @Filename: /project/src/main.ts
//// internalFoo/**/
goTo.marker("");
verify.completions({
includes: [
{
name: "internalFoo",
source: "#internal/foo",
sourceDisplay: "#internal/foo",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
},
],
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: true,
importModuleSpecifierPreference: "non-relative"
},
});
verify.completions({
includes: [
{
name: "internalFoo",
source: "./other",
sourceDisplay: "./other",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
},
],
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: true,
importModuleSpecifierPreference: "relative"
},
});
| {
"end_byte": 1278,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_packageJsonImportsPreference.ts"
} |
TypeScript/tests/cases/fourslash/codeFixEnableJsxFlag_blankCompilerOptionsTsConfig.ts_0_429 | /// <reference path='fourslash.ts' />
// @Filename: /dir/a.tsx
////export const Component = () => <></>;
// @Filename: /dir/tsconfig.json
////{
//// "compilerOptions": {
//// }
////}
goTo.file("/dir/a.tsx");
verify.codeFix({
description: "Enable the '--jsx' flag in your configuration file",
newFileContent: {
"/dir/tsconfig.json":
`{
"compilerOptions": {
"jsx": "react"
}
}`,
},
});
| {
"end_byte": 429,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixEnableJsxFlag_blankCompilerOptionsTsConfig.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsNoHintWhenArgumentMatchesName.ts_0_364 | /// <reference path="fourslash.ts" />
//// function foo (a: number, b: number) {}
//// declare const a: 1;
//// foo(a, 2);
//// declare const v: any;
//// foo(v.a, v.a);
//// foo(v.b, v.b);
//// foo(v.c, v.c);
verify.baselineInlayHints(undefined, {
includeInlayParameterNameHints: "all",
includeInlayParameterNameHintsWhenArgumentMatchesName: false,
});
| {
"end_byte": 364,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsNoHintWhenArgumentMatchesName.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties48.ts_0_382 | /// <reference path='fourslash.ts' />
// @strict: true
//// interface A {
//// a: number;
//// b: string;
//// }
//// interface B {
//// c: (A | undefined)[];
//// }
//// [|const b: B[] = [{ c: [{}] }];|]
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newRangeContent:
`const b: B[] = [{ c: [{
a: 0,
b: ""
}] }];`,
});
| {
"end_byte": 382,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties48.ts"
} |
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class_commentOnVariableDeclaration.ts_0_291 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: /a.js
/////** Doc */
////const C = function() { this.x = 0; }
verify.codeFix({
description: "Convert function to an ES2015 class",
newFileContent:
`/** Doc */
class C {
constructor() { this.x = 0; }
}`,
});
| {
"end_byte": 291,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class_commentOnVariableDeclaration.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess1.ts_0_507 | /// <reference path='fourslash.ts' />
//// class A {
//// /*a*/public a: string;/*b*/
//// }
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Generate 'get' and 'set' accessors",
actionName: "Generate 'get' and 'set' accessors",
actionDescription: "Generate 'get' and 'set' accessors",
newContent: `class A {
private /*RENAME*/_a: string;
public get a(): string {
return this._a;
}
public set a(value: string) {
this._a = value;
}
}`,
});
| {
"end_byte": 507,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess1.ts"
} |
TypeScript/tests/cases/fourslash/fourslash.ts_0_4261 | // Welcome to the FourSlash syntax guide!
// A line in the source text is indicated by four slashes (////)
// Tip: Hit Ctrl-K Ctrl-C Ctrl-K Ctrl-C to prefix-slash any selected block of text in Visual Studio
//// This is a line in the source text!
// Files are terminated by any entirely blank line (e.g.
// interspersed //-initiated comments are allowed)
// You can indicate a 'marker' with /**/
//// function./**/
// ... goTo.marker();
// Optionally, markers may have names:
//// function.go(/*1*/x, /*2*/y);
// goTo.marker('1');
// Marker names may consist of any alphanumeric characters
// File metadata must occur directly before the first line of source text
// and is indicated by an @ symbol:
// @Filename: lib.d.ts
//// this is the first line of my file
// Global options may appear anywhere
// @Module: Node
// @Target: ES5
// In the imperative section, you can write any valid TypeScript code.
//---------------------------------------
// For API editors:
// When editting this file, and only while editing this file, enable the reference comments
// and comment out the declarations in this section to get proper type information.
// Undo these changes before compiling/committing/editing any other fourslash tests.
// The test suite will likely crash if you try 'jake runtests' with reference comments enabled.
//
// Explanation:
// We want type-completion while we edit this file, but at compile time/while editting fourslash tests,
// we don't want to include the following reference because we are compiling this file in "--out" mode and don't want to rope
// in the entire codebase into the compilation each fourslash test. Additionally, we don't want to expose the
// src/harness/fourslash.ts API's (or the rest of the compiler) because they are unstable and complicate the
// fourslash testing DSL. Finally, in this case, runtime reflection is (much) faster.
//
// TODO: figure out a better solution to the API exposure problem.
declare module ts {
export const Diagnostics: typeof import("../../../src/compiler/diagnosticInformationMap.generated").Diagnostics;
export type MapKey = string | number;
export interface Map<T> {
forEach(action: (value: T, key: string) => void): void;
get(key: MapKey): T;
has(key: MapKey): boolean;
set(key: MapKey, value: T): this;
delete(key: MapKey): boolean;
clear(): void;
}
interface SymbolDisplayPart {
text: string;
kind: string;
}
enum IndentStyle {
None = 0,
Block = 1,
Smart = 2,
}
const enum InlayHintKind {
Type = "Type",
Parameter = "Parameter",
Enum = "Enum",
}
enum SemicolonPreference {
Ignore = "ignore",
Insert = "insert",
Remove = "remove",
}
interface OutputFile {
name: string;
writeByteOrderMark: boolean;
text: string;
}
enum DiagnosticCategory {
Warning,
Error,
Suggestion,
Message
}
enum OrganizeImportsMode {
All = "All",
SortAndCombine = "SortAndCombine",
RemoveUnused = "RemoveUnused",
}
interface DiagnosticMessage {
key: string;
category: DiagnosticCategory;
code: number;
message: string;
reportsUnnecessary?: {};
}
interface LineAndCharacter {
line: number;
character: number;
}
interface CompletionEntryData {
fileName?: string;
ambientModuleName?: string;
isPackageJsonImport?: true;
moduleSpecifier?: string;
exportName: string;
}
interface CompilerOptions {
module?: string;
target?: string;
jsx?: string;
allowJs?: boolean;
maxNodeModulesJsDepth?: number;
strictNullChecks?: boolean;
sourceMap?: boolean;
allowSyntheticDefaultImports?: boolean;
allowNonTsExtensions?: boolean;
resolveJsonModule?: boolean;
[key: string]: string | number | boolean | undefined;
}
function flatMap<T, U>(array: ReadonlyArray<T>, mapfn: (x: T, i: number) => U | ReadonlyArray<U> | undefined): U[];
interface TextRange {
pos: number;
end: number;
}
} | {
"end_byte": 4261,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fourslash.ts"
} |
TypeScript/tests/cases/fourslash/fourslash.ts_4263_11512 | declare namespace FourSlashInterface {
interface Marker {
fileName: string;
position: number;
data?: any;
}
enum IndentStyle {
None = 0,
Block = 1,
Smart = 2,
}
interface EditorOptions {
BaseIndentSize?: number,
IndentSize: number;
TabSize: number;
NewLineCharacter: string;
ConvertTabsToSpaces: boolean;
}
interface EditorSettings {
baseIndentSize?: number;
indentSize?: number;
tabSize?: number;
newLineCharacter?: string;
convertTabsToSpaces?: boolean;
indentStyle?: IndentStyle;
trimTrailingWhitespace?: boolean;
}
interface FormatCodeOptions extends EditorOptions {
InsertSpaceAfterCommaDelimiter: boolean;
InsertSpaceAfterSemicolonInForStatements: boolean;
InsertSpaceBeforeAndAfterBinaryOperators: boolean;
InsertSpaceAfterKeywordsInControlFlowStatements: boolean;
InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean;
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: boolean;
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
InsertSpaceAfterTypeAssertion: boolean;
PlaceOpenBraceOnNewLineForFunctions: boolean;
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
insertSpaceBeforeTypeAnnotation: boolean;
[s: string]: boolean | number | string | undefined;
}
interface FormatCodeSettings extends EditorSettings {
readonly insertSpaceAfterCommaDelimiter?: boolean;
readonly insertSpaceAfterSemicolonInForStatements?: boolean;
readonly insertSpaceBeforeAndAfterBinaryOperators?: boolean;
readonly insertSpaceAfterConstructor?: boolean;
readonly insertSpaceAfterKeywordsInControlFlowStatements?: boolean;
readonly insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean;
readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean;
readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean;
readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean;
readonly insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean;
readonly insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
readonly insertSpaceAfterTypeAssertion?: boolean;
readonly insertSpaceBeforeFunctionParenthesis?: boolean;
readonly placeOpenBraceOnNewLineForFunctions?: boolean;
readonly placeOpenBraceOnNewLineForControlBlocks?: boolean;
readonly insertSpaceBeforeTypeAnnotation?: boolean;
readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean;
readonly semicolons?: ts.SemicolonPreference;
readonly indentSwitchCase?: boolean;
}
interface InteractiveRefactorArguments {
targetFile: string;
}
interface Range {
fileName: string;
pos: number;
end: number;
marker?: Marker;
}
type MarkerOrNameOrRange = string | Marker | Range;
interface TextSpan {
start: number;
end: number;
}
interface TextRange {
pos: number;
end: number;
}
class test_ {
markers(): Marker[];
markerNames(): string[];
markerName(m: Marker): string;
marker(name?: string): Marker;
ranges(): Range[];
rangesInFile(fileName?: string): Range[];
spans(): Array<{ start: number, length: number }>;
rangesByText(): ts.Map<Range[]>;
markerByName(s: string): Marker;
symbolsInScope(range: Range): any[];
setTypesRegistry(map: { [key: string]: void }): void;
getSemanticDiagnostics(): Diagnostic[];
}
class config {
configurePlugin(pluginName: string, configuration: any): void;
setCompilerOptionsForInferredProjects(options: ts.CompilerOptions)
}
class goTo {
marker(name?: string | Marker): void;
eachMarker(markers: ReadonlyArray<string>, action: (marker: Marker, index: number) => void): void;
eachMarker(action: (marker: Marker, index: number) => void): void;
rangeStart(range: Range): void;
eachRange(action: (range: Range) => void): void;
bof(): void;
eof(): void;
position(position: number, fileIndex?: number): any;
position(position: number, fileName?: string): any;
position(lineAndCharacter: ts.LineAndCharacter, fileName?: string): void;
file(index: number, content?: string, scriptKindName?: string): any;
file(name: string, content?: string, scriptKindName?: string): any;
select(startMarker: string, endMarker: string): void;
selectRange(range: Range): void;
/**
* Selects a line at a given index, not including any newline characters.
* @param index 0-based
*/
selectLine(index: number): void;
}
class verifyNegatable {
private negative;
not: verifyNegatable;
allowedClassElementKeywords: string[];
allowedConstructorParameterKeywords: string[];
constructor(negative?: boolean);
errorExistsBetweenMarkers(startMarker: string, endMarker: string): void;
errorExistsAfterMarker(markerName?: string): void;
errorExistsBeforeMarker(markerName?: string): void;
quickInfoExists(): void;
isValidBraceCompletionAtPosition(openingBrace?: string): void;
jsxClosingTag(map: { [markerName: string]: { readonly newText: string } | undefined }): void;
linkedEditing(map: { [markerName: string]: LinkedEditingInfo | undefined }): void;
baselineLinkedEditing(): void;
isInCommentAtPosition(onlyMultiLineDiverges?: boolean): void;
codeFix(options: {
description: string | [string, ...(string | number)[]] | DiagnosticIgnoredInterpolations,
newFileContent?: NewFileContent,
newRangeContent?: string,
errorCode?: number,
index?: number,
preferences?: UserPreferences,
applyChanges?: boolean,
commands?: {}[],
});
codeFixAvailable(options?: ReadonlyArray<VerifyCodeFixAvailableOptions> | string): void;
codeFixAllAvailable(fixName: string): void;
applicableRefactorAvailableAtMarker(markerName: string): void;
codeFixDiagnosticsAvailableAtMarkers(markerNames: string[], diagnosticCode?: number): void;
applicableRefactorAvailableForRange(): void;
refactorAvailable(name: string, actionName?: string, actionDescription?: string, kind?: string, preferences?: {}, includeInteractiveActions?: boolean): void;
refactorAvailableForTriggerReason(triggerReason: RefactorTriggerReason, name: string, action?: string, actionDescription?: string, kind?: string, preferences?: {}, includeInteractiveActions?: boolean): void;
refactorKindAvailable(refactorKind: string, expected: string[], preferences?: {}): void;
} | {
"end_byte": 11512,
"start_byte": 4263,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fourslash.ts"
} |
TypeScript/tests/cases/fourslash/fourslash.ts_11517_20683 | class verify extends verifyNegatable {
assertHasRanges(ranges: Range[]): void;
caretAtMarker(markerName?: string): void;
completions(...options: CompletionsOptions[]): { andApplyCodeAction(options: {
name: string,
source: string,
description: string,
newFileContent?: string,
newRangeContent?: string,
}): void };
applyCodeActionFromCompletion(markerName: string | undefined, options: {
name: string,
source?: string,
data?: ts.CompletionEntryData,
description: string,
newFileContent?: string,
newRangeContent?: string,
preferences?: UserPreferences,
});
indentationIs(numberOfSpaces: number): void;
indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle?: ts.IndentStyle, baseIndentSize?: number): void;
textAtCaretIs(text: string): void;
/**
* Compiles the current file and evaluates 'expr' in a context containing
* the emitted output, then compares (using ===) the result of that expression
* to 'value'. Do not use this function with external modules as it is not supported.
*/
eval(expr: string, value: any): void;
currentLineContentIs(text: string): void;
currentFileContentIs(text: string): void;
formatDocumentChangesNothing(): void;
verifyGetEmitOutputForCurrentFile(expected: string): void;
verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void;
baselineFindAllReferences(...markerOrRange: MarkerOrNameOrRange[]): void;
baselineFindAllReferencesAtRangesWithText(...rangeText: string[]): void;
baselineGetFileReferences(...fileName: string[]): void;
baselineGoToDefinition(...markerOrRange: MarkerOrNameOrRange[]): void;
baselineGoToDefinitionAtRangesWithText(...rangeText: string[]): void;
baselineGetDefinitionAtPosition(...markerOrRange: MarkerOrNameOrRange[]): void;
baselineGetDefinitionAtRangesWithText(...rangeText: string[]): void;
baselineGoToSourceDefinition(...markerOrRange: MarkerOrNameOrRange[]): void;
baselineGoToSourceDefinitionAtRangesWithText(...rangeText: string[]): void;
baselineGoToType(...markerOrRange: MarkerOrNameOrRange[]): void;
baselineGoToTypeAtRangesWithText(...rangeText: string[]): void;
baselineGoToImplementation(...markerOrRange: MarkerOrNameOrRange[]): void;
baselineGoToImplementationAtRangesWithText(...rangeText: string[]): void;
baselineDocumentHighlights(markerOrRange?: ArrayOrSingle<MarkerOrNameOrRange>, options?: VerifyDocumentHighlightsOptions): void;
baselineDocumentHighlightsAtRangesWithText(rangeText?: ArrayOrSingle<string>, options?: VerifyDocumentHighlightsOptions): void;
symbolAtLocation(startRange: Range, ...declarationRanges: Range[]): void;
typeOfSymbolAtLocation(range: Range, symbol: any, expected: string): void;
typeAtLocation(range: Range, expected: string): void;
noSignatureHelp(...markers: (string | Marker)[]): void;
noSignatureHelpForTriggerReason(triggerReason: SignatureHelpTriggerReason, ...markers: (string | Marker)[]): void
signatureHelpPresentForTriggerReason(triggerReason: SignatureHelpTriggerReason, ...markers: (string | Marker)[]): void
signatureHelp(...options: VerifySignatureHelpOptions[], ): void;
// Checks that there are no compile errors.
noErrors(): void;
errorExistsAtRange(range: Range, code: number, message?: string): void;
numberOfErrorsInCurrentFile(expected: number): void;
baselineCurrentFileBreakpointLocations(): void;
baselineCurrentFileNameOrDottedNameSpans(): void;
baselineGetEmitOutput(insertResultsIntoVfs?: boolean): void;
baselineSyntacticDiagnostics(): void;
baselineSyntacticAndSemanticDiagnostics(): void;
getEmitOutput(expectedOutputFiles: ReadonlyArray<string>): void;
baselineCompletions(preferences?: UserPreferences): void;
baselineQuickInfo(): void;
baselineSmartSelection(): void;
baselineSignatureHelp(): void;
nameOrDottedNameSpanTextIs(text: string): void;
outliningSpansInCurrentFile(spans: Range[], kind?: "comment" | "region" | "code" | "imports"): void;
outliningHintSpansInCurrentFile(spans: Range[]): void;
todoCommentsInCurrentFile(descriptors: string[]): void;
matchingBracePositionInCurrentFile(bracePosition: number, expectedMatchPosition: number): void;
noMatchingBracePositionInCurrentFile(bracePosition: number): void;
docCommentTemplateAt(markerName: string | FourSlashInterface.Marker, expectedOffset: number, expectedText: string, options?: VerifyDocCommentTemplateOptions): void;
noDocCommentTemplateAt(markerName: string | FourSlashInterface.Marker): void;
rangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number, index?: number): void;
codeFixAll(options: { fixId: string, fixAllDescription: string, newFileContent: NewFileContent, commands?: {}[], preferences?: UserPreferences }): void;
fileAfterApplyingRefactorAtMarker(markerName: string, expectedContent: string, refactorNameToApply: string, actionName: string, formattingOptions?: FormatCodeOptions): void;
rangeIs(expectedText: string, includeWhiteSpace?: boolean): void;
fileAfterApplyingRefactorAtMarker(markerName: string, expectedContent: string, refactorNameToApply: string, formattingOptions?: FormatCodeOptions): void;
getAndApplyCodeFix(errorCode?: number, index?: number): void;
importFixAtPosition(expectedTextArray: string[], errorCode?: number, options?: UserPreferences): void;
importFixModuleSpecifiers(marker: string, moduleSpecifiers: string[], options?: UserPreferences): void;
baselineAutoImports(marker: string, fullNamesForCodeFix?: string[], options?: UserPreferences): void;
navigationBar(json: any, options?: { checkSpans?: boolean }): void;
navigationTree(json: any, options?: { checkSpans?: boolean }): void;
navigateTo(...options: VerifyNavigateToOptions[]);
/** Prefer {@link syntacticClassificationsAre} for more descriptive tests */
encodedSyntacticClassificationsLength(expected: number): void;
/** Prefer {@link semanticClassificationsAre} for more descriptive tests */
encodedSemanticClassificationsLength(format: "original" | "2020", length: number): void;
/**
* This method *requires* a contiguous, complete, and ordered stream of classifications for a file.
*/
syntacticClassificationsAre(...classifications: {
classificationType: string;
text?: string;
}[]): void;
/**
* This method *requires* an ordered stream of classifications for a file, and spans are highly recommended.
*/
semanticClassificationsAre(format: "original" | "2020", ...classifications: {
classificationType: string | number;
text?: string;
textSpan?: TextSpan;
}[]): void;
/** Edits the current testfile and replaces with the semantic classifications */
replaceWithSemanticClassifications(format: "2020")
renameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string, fileToRename?: string, range?: Range, preferences?: UserPreferences): void;
renameInfoFailed(message?: string, preferences?: UserPreferences): void;
baselineRename(markerOrRange?: ArrayOrSingle<MarkerOrNameOrRange>, options?: RenameOptions): void;
baselineRenameAtRangesWithText(rangeText?: ArrayOrSingle<string>, options?: RenameOptions): void;
/** Verify the quick info available at the current marker. */
quickInfoIs(expectedText: string, expectedDocumentation?: string, expectedTags?: { name: string; text: string; }[]): void;
/** Goto a marker and call `quickInfoIs`. */
quickInfoAt(markerName: string | Range, expectedText?: string, expectedDocumentation?: string, expectedTags?: { name: string; text: string; }[]): void;
/**
* Call `quickInfoAt` for each pair in the object.
* (If the value is an array, it is [expectedText, expectedDocumentation].)
*/
quickInfos(namesAndTexts: { [name: string]: string | [string, string] }): void;
verifyQuickInfoDisplayParts(kind: string, kindModifiers: string, textSpan: {
start: number;
length: number;
}, displayParts: ts.SymbolDisplayPart[], documentation: ts.SymbolDisplayPart[], tags: { name: string, text?: string }[] | undefined): void;
baselineInlayHints(span?: { start: number; length: number; }, preferences?: InlayHintsOptions): void;
getSyntacticDiagnostics(expected: ReadonlyArray<Diagnostic>): void;
getSemanticDiagnostics(expected: ReadonlyArray<Diagnostic>): void; | {
"end_byte": 20683,
"start_byte": 11517,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fourslash.ts"
} |
TypeScript/tests/cases/fourslash/fourslash.ts_20692_29834 | getRegionSemanticDiagnostics(
ranges: ts.TextRange[],
expectedDiagnostics: ReadonlyArray<Diagnostic> | undefined,
expectedRanges?: ReadonlyArray<TextRange>): void;
getSuggestionDiagnostics(expected: ReadonlyArray<Diagnostic>): void;
ProjectInfo(expected: string[]): void;
getEditsForFileRename(options: {
readonly oldPath: string;
readonly newPath: string;
readonly newFileContents: { readonly [fileName: string]: string };
readonly preferences?: UserPreferences;
}): void;
baselineCallHierarchy(): void;
moveToNewFile(options: {
readonly newFileContents: { readonly [fileName: string]: string };
readonly preferences?: UserPreferences;
}): void;
noMoveToNewFile(): void;
moveToFile(options: {
readonly newFileContents: { readonly [fileName: string]: string };
readonly interactiveRefactorArguments: InteractiveRefactorArguments;
readonly preferences?: UserPreferences;
}): void;
generateTypes(...options: GenerateTypesOptions[]): void;
organizeImports(newContent: string, mode?: ts.OrganizeImportsMode, preferences?: UserPreferences): void;
toggleLineComment(newFileContent: string): void;
toggleMultilineComment(newFileContent: string): void;
commentSelection(newFileContent: string): void;
uncommentSelection(newFileContent: string): void;
preparePasteEdits(options: {
copiedFromFile: string,
copiedTextRange: { pos: number, end: number }[],
providePasteEdits: boolean
}): void;
pasteEdits(options: {
newFileContents: { readonly [fileName: string]: string };
args: {
pastedText: string[];
pasteLocations: { pos: number, end: number }[];
copiedFrom?: { file: string, range: { pos: number, end: number }[] };
}
}): void;
baselineMapCode(ranges: Range[][], changes: string[]): void;
getImports(fileName: string, imports: string[]): void;
}
class edit {
caretPosition(): Marker;
backspace(count?: number): void;
deleteAtCaret(times?: number): void;
replace(start: number, length: number, text: string): void;
paste(text: string): void;
insert(text: string): void;
insertLine(text: string): void;
insertLines(...lines: string[]): void;
/** @param index 0-based */
deleteLine(index: number): void;
/**
* @param startIndex 0-based
* @param endIndexInclusive 0-based
*/
deleteLineRange(startIndex: number, endIndexInclusive: number): void;
/** @param index 0-based */
replaceLine(index: number, text: string): void;
moveRight(count?: number): void;
moveLeft(count?: number): void;
enableFormatting(): void;
disableFormatting(): void;
applyRefactor(options: { refactorName: string, actionName: string, actionDescription: string, newContent: NewFileContent, triggerReason?: RefactorTriggerReason }): void;
}
class debug {
printCurrentParameterHelp(): void;
printCurrentFileState(): void;
printCurrentFileStateWithWhitespace(): void;
printCurrentFileStateWithoutCaret(): void;
printCurrentQuickInfo(): void;
printCurrentSignatureHelp(): void;
printCompletionListMembers(options?: { includeExternalModuleExports: boolean }): void;
printAvailableCodeFixes(): void;
printBreakpointLocation(pos: number): void;
printBreakpointAtCurrentLocation(): void;
printNameOrDottedNameSpans(pos: number): void;
printErrorList(): void;
printNavigationBar(): void;
printNavigationItems(searchValue?: string): void;
printScriptLexicalStructureItems(): void;
printOutliningSpans(): void;
printReferences(): void;
printContext(): void;
}
class format {
document(): void;
copyFormatOptions(): FormatCodeOptions;
setFormatOptions(options: FormatCodeOptions | FormatCodeSettings): any;
selection(startMarker: string, endMarker: string): void;
onType(posMarker: string, key: string): void;
setOption(name: keyof FormatCodeOptions, value: number | string | boolean): void;
}
class cancellation {
resetCancelled(): void;
setCancelled(numberOfCalls?: number): void;
}
interface ModernClassificationFactory {
semanticToken(identifier: string, name: string)
}
interface ClassificationFactory {
comment(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
identifier(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
keyword(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
numericLiteral(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
operator(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
stringLiteral(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
whiteSpace(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
text(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
punctuation(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
docCommentTagName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
className(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
enumName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
interfaceName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
moduleName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
typeParameterName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
parameterName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
typeAliasName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
jsxOpenTagName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
jsxCloseTagName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
jsxSelfClosingTagName(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
jsxAttribute(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
jsxText(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
jsxAttributeStringLiteralValue(text: string, position?: number): {
classificationType: string;
text: string;
textSpan?: TextSpan;
};
}
interface ReferenceGroup {
readonly definition: ReferencesDefinition;
readonly ranges: ReadonlyArray<Range>;
}
type ReferencesDefinition = string | {
text: string;
range: Range;
}
interface Diagnostic {
message: string;
/** @default `test.ranges()[0]` */
range?: Range;
code: number;
reportsUnnecessary?: true;
reportsDeprecated?: true;
}
interface VerifyDocumentHighlightsOptions {
filesToSearch: ReadonlyArray<string>;
} | {
"end_byte": 29834,
"start_byte": 20692,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fourslash.ts"
} |
TypeScript/tests/cases/fourslash/fourslash.ts_29839_39687 | interface UserPreferences {
readonly quotePreference?: "auto" | "double" | "single";
readonly includeCompletionsForModuleExports?: boolean;
readonly includeCompletionsForImportStatements?: boolean;
readonly includeCompletionsWithSnippetText?: boolean;
readonly includeCompletionsWithInsertText?: boolean;
readonly includeCompletionsWithClassMemberSnippets?: boolean;
readonly includeCompletionsWithObjectLiteralMethodSnippets?: boolean;
readonly useLabelDetailsInCompletionEntries?: boolean;
readonly allowIncompleteCompletions?: boolean;
/** @deprecated use `includeCompletionsWithInsertText` */
readonly includeInsertTextCompletions?: boolean;
readonly includeAutomaticOptionalChainCompletions?: boolean;
readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative";
readonly importModuleSpecifierEnding?: "minimal" | "index" | "js";
readonly jsxAttributeCompletionStyle?: "auto" | "braces" | "none";
readonly providePrefixAndSuffixTextForRename?: boolean;
readonly allowRenameOfImportPath?: boolean;
readonly autoImportFileExcludePatterns?: readonly string[];
readonly autoImportSpecifierExcludeRegexes?: readonly string[];
readonly preferTypeOnlyAutoImports?: boolean;
readonly organizeImportsIgnoreCase?: "auto" | boolean;
readonly organizeImportsCollation?: "unicode" | "ordinal";
readonly organizeImportsLocale?: string;
readonly organizeImportsNumericCollation?: boolean;
readonly organizeImportsAccentCollation?: boolean;
readonly organizeImportsCaseFirst?: "upper" | "lower" | false;
readonly organizeImportsTypeOrder?: "first" | "last" | "inline";
}
interface InlayHintsOptions extends UserPreferences {
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
readonly includeInlayFunctionParameterTypeHints?: boolean;
readonly includeInlayVariableTypeHints?: boolean;
readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean;
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
readonly includeInlayEnumMemberValueHints?: boolean;
readonly interactiveInlayHints?: boolean;
}
interface CompletionsOptions {
readonly marker?: ArrayOrSingle<string | Marker>;
readonly isNewIdentifierLocation?: boolean;
readonly isGlobalCompletion?: boolean;
readonly optionalReplacementSpan?: Range;
/** Must provide all completion entries in order. */
readonly exact?: ArrayOrSingle<ExpectedCompletionEntry>;
/** Must provide all completion entries, but order doesn't matter. */
readonly unsorted?: readonly ExpectedCompletionEntry[];
readonly includes?: ArrayOrSingle<ExpectedCompletionEntry>;
readonly excludes?: ArrayOrSingle<string>;
readonly preferences?: UserPreferences;
readonly triggerCharacter?: string;
readonly defaultCommitCharacters?: string[];
}
type ExpectedCompletionEntry = string | ExpectedCompletionEntryObject;
interface ExpectedCompletionEntryObject {
readonly name: string;
readonly source?: string;
readonly insertText?: string;
readonly filterText?: string;
readonly replacementSpan?: Range;
readonly hasAction?: boolean;
readonly isRecommended?: boolean;
readonly isFromUncheckedFile?: boolean;
readonly kind?: string;
readonly kindModifiers?: string;
readonly sortText?: completion.SortText;
readonly isPackageJsonImport?: boolean;
readonly isSnippet?: boolean;
readonly commitCharacters?: string[];
// details
readonly text?: string;
readonly documentation?: string;
readonly tags?: ReadonlyArray<JSDocTagInfo>;
readonly sourceDisplay?: string;
readonly labelDetails?: ExpectedCompletionEntryLabelDetails;
}
export interface ExpectedCompletionEntryLabelDetails {
detail?: string;
description?: string;
}
interface VerifySignatureHelpOptions {
marker?: ArrayOrSingle<string | Marker>;
/** @default 1 */
overloadsCount?: number;
docComment?: string;
text?: string;
parameterName?: string;
parameterSpan?: string;
parameterDocComment?: string;
parameterCount?: number;
argumentCount?: number;
isVariadic?: boolean;
tags?: ReadonlyArray<JSDocTagInfo>;
triggerReason?: SignatureHelpTriggerReason;
overrideSelectedItemIndex?: number;
}
interface VerifyDocCommentTemplateOptions {
generateReturnInDocTemplate?: boolean;
}
type LinkedEditingInfo = {
readonly ranges: { start: number, length: number }[];
wordPattern?: string;
}
export type SignatureHelpTriggerReason =
| SignatureHelpInvokedReason
| SignatureHelpCharacterTypedReason
| SignatureHelpRetriggeredReason;
/**
* Signals that the user manually requested signature help.
* The language service will unconditionally attempt to provide a result.
*/
export interface SignatureHelpInvokedReason {
kind: "invoked",
triggerCharacter?: undefined,
}
/**
* Signals that the signature help request came from a user typing a character.
* Depending on the character and the syntactic context, the request may or may not be served a result.
*/
export interface SignatureHelpCharacterTypedReason {
kind: "characterTyped",
/**
* Character that was responsible for triggering signature help.
*/
triggerCharacter: string,
}
/**
* Signals that this signature help request came from typing a character or moving the cursor.
* This should only occur if a signature help session was already active and the editor needs to see if it should adjust.
* The language service will unconditionally attempt to provide a result.
* `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move.
*/
export interface SignatureHelpRetriggeredReason {
kind: "retrigger",
/**
* Character that was responsible for triggering signature help.
*/
triggerCharacter?: string,
}
export type RefactorTriggerReason = "implicit" | "invoked";
export interface VerifyCodeFixAvailableOptions {
readonly description: string;
readonly actions?: ReadonlyArray<{ readonly type: string, readonly data: {} }>;
readonly commands?: ReadonlyArray<{}>;
}
export interface VerifyInlayHintsOptions {
text: string;
position: number;
kind?: ts.InlayHintKind;
whitespaceBefore?: boolean;
whitespaceAfter?: boolean;
}
interface VerifyNavigateToOptions {
readonly pattern: string;
readonly fileName?: string;
readonly expected: ReadonlyArray<ExpectedNavigateToItem>;
readonly excludeLibFiles?: boolean;
}
interface ExpectedNavigateToItem {
readonly name: string;
readonly kind: string;
readonly kindModifiers?: string; // default: ""
readonly matchKind?: string; // default: "exact"
readonly isCaseSensitive?: boolean; // default: "true"
readonly range: Range;
readonly containerName?: string; // default: ""
readonly containerKind?: string; // default: ScriptElementKind.unknown
}
interface JSDocTagInfo {
readonly name: string;
readonly text: string | ts.SymbolDisplayPart[] | undefined;
}
interface GenerateTypesOptions {
readonly name?: string;
readonly value: unknown;
readonly global?: boolean;
readonly output?: string | undefined;
readonly outputBaseline?: string;
}
type ArrayOrSingle<T> = T | ReadonlyArray<T>;
type NewFileContent = string | { readonly [fileName: string]: string };
type RenameLocationsOptions = ReadonlyArray<RenameLocationOptions> | {
readonly findInStrings?: boolean;
readonly findInComments?: boolean;
readonly ranges: ReadonlyArray<RenameLocationOptions>;
readonly providePrefixAndSuffixTextForRename?: boolean;
};
type RenameOptions = { readonly findInStrings?: boolean, readonly findInComments?: boolean, readonly providePrefixAndSuffixTextForRename?: boolean, readonly quotePreference?: "auto" | "double" | "single" };
type RenameLocationOptions = Range | { readonly range: Range, readonly prefixText?: string, readonly suffixText?: string };
type DiagnosticIgnoredInterpolations = { template: string }
}
/** Wraps a diagnostic message to be compared ignoring interpolated strings */
declare function ignoreInterpolations(diagnostic: string | ts.DiagnosticMessage): FourSlashInterface.DiagnosticIgnoredInterpolations;
declare function verifyOperationIsCancelled(f: any): void;
declare var test: FourSlashInterface.test_;
declare var config: FourSlashInterface.config;
declare var goTo: FourSlashInterface.goTo;
declare var verify: FourSlashInterface.verify;
declare var edit: FourSlashInterface.edit;
declare var debug: FourSlashInterface.debug;
declare var format: FourSlashInterface.format;
declare var cancellation: FourSlashInterface.cancellation;
declare function classification(format: "original"): FourSlashInterface.ClassificationFactory;
declare function classification(format: "2020"): FourSlashInterface.ModernClassificationFactory; | {
"end_byte": 39687,
"start_byte": 29839,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fourslash.ts"
} |
TypeScript/tests/cases/fourslash/fourslash.ts_39688_43703 | declare namespace completion {
type Entry = FourSlashInterface.ExpectedCompletionEntryObject;
interface GlobalsPlusOptions {
noLib?: boolean;
}
export type SortText = string & { __sortText: any };
export const SortText: {
LocalDeclarationPriority: SortText,
LocationPriority: SortText,
OptionalMember: SortText,
MemberDeclaredBySpreadAssignment: SortText,
SuggestedClassMembers: SortText,
GlobalsOrKeywords: SortText,
AutoImportSuggestions: SortText,
ClassMemberSnippets: SortText,
JavascriptIdentifiers: SortText,
Deprecated(sortText: SortText): SortText,
ObjectLiteralProperty(presetSortText: SortText, symbolDisplayName: string): SortText,
SortBelow(sortText: SortText): SortText,
};
export const enum CompletionSource {
ThisProperty = "ThisProperty/",
ClassMemberSnippet = "ClassMemberSnippet/",
TypeOnlyAlias = "TypeOnlyAlias/",
ObjectLiteralMethodSnippet = "ObjectLiteralMethodSnippet/",
SwitchCases = "SwitchCases/",
ObjectLiteralMemberWithComma = "ObjectLiteralMemberWithComma/",
}
export const globalThisEntry: Entry;
export const undefinedVarEntry: Entry;
export const globals: ReadonlyArray<Entry>;
export const globalsInJs: ReadonlyArray<Entry>;
export const globalKeywords: ReadonlyArray<Entry>;
export const globalInJsKeywords: ReadonlyArray<Entry>;
export const insideMethodKeywords: ReadonlyArray<Entry>;
export const insideMethodInJsKeywords: ReadonlyArray<Entry>;
export const globalsVars: ReadonlyArray<Entry>;
export function sorted(entries: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>;
export function globalsInsideFunction(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>, options?: GlobalsPlusOptions): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>;
export function globalsInJsInsideFunction(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>, options?: GlobalsPlusOptions): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>;
export function globalsPlus(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>, options?: GlobalsPlusOptions): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>;
export function globalsInJsPlus(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>, options?: GlobalsPlusOptions): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>;
export const keywordsWithUndefined: ReadonlyArray<Entry>;
export const keywords: ReadonlyArray<Entry>;
export const typeKeywords: ReadonlyArray<Entry>;
export function typeKeywordsPlus(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>): ReadonlyArray<Entry>;
export const globalTypes: ReadonlyArray<Entry>;
export function globalTypesPlus(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>): ReadonlyArray<Entry>;
export const typeAssertionKeywords: ReadonlyArray<Entry>;
export const classElementKeywords: ReadonlyArray<Entry>;
export const classElementInJsKeywords: ReadonlyArray<Entry>;
export const constructorParameterKeywords: ReadonlyArray<Entry>;
export const functionMembers: ReadonlyArray<Entry>;
export function functionMembersPlus(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>;
export const functionMembersWithPrototype: ReadonlyArray<Entry>;
export function functionMembersWithPrototypePlus(plus: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry>;
export const stringMembers: ReadonlyArray<Entry>;
export const statementKeywordsWithTypes: ReadonlyArray<Entry>;
export const statementKeywords: ReadonlyArray<Entry>;
export const statementInJsKeywords: ReadonlyArray<Entry>;
} | {
"end_byte": 43703,
"start_byte": 39688,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fourslash.ts"
} |
TypeScript/tests/cases/fourslash/unusedImportsFS_entireImportDeclaration.ts_0_285 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @Filename: /a.ts
////// leading trivia
////import a, { b } from "mod"; // trailing trivia
verify.codeFix({
description: "Remove import from 'mod'",
newFileContent:
`// leading trivia
// trailing trivia`,
});
| {
"end_byte": 285,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedImportsFS_entireImportDeclaration.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_stringLiteral.ts_0_117 | /// <reference path="fourslash.ts" />
//// const a = 'a';
//// const b = /**/'b';
verify.baselineSmartSelection();
| {
"end_byte": 117,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_stringLiteral.ts"
} |
TypeScript/tests/cases/fourslash/docCommentTemplateJsSpecialPropertyAssignment.ts_0_322 | /// <reference path='fourslash.ts' />
// @Filename: /a.js
/////*0*/module.exports = function(a) {};
////const myNamespace = {};
/////*1*/myNamespace.myExport = function(x) {};
verify.docCommentTemplateAt("0", 7,
`/**
*
* @param {any} a
*/
`);
verify.docCommentTemplateAt("1", 7,
`/**
*
* @param {any} x
*/
`);
| {
"end_byte": 322,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateJsSpecialPropertyAssignment.ts"
} |
TypeScript/tests/cases/fourslash/renameDefaultLibDontWork.ts_0_367 | /// <reference path='fourslash.ts' />
// Tests that tokens found on the default library are not renamed.
// "test" is a comment on the default library.
// @Filename: file1.ts
//// [|var [|{| "contextRangeIndex": 0 |}test|] = "foo";|]
//// console.log([|test|]);
const [r0Def, ...ranges] = test.ranges();
verify.baselineRename(ranges[0], { findInComments: true, }); | {
"end_byte": 367,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameDefaultLibDontWork.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsInteractiveMultifile1.ts_0_535 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
//// export interface Foo { a: string }
// @Filename: /b.ts
//// async function foo () {
//// return {} as any as import('./a').Foo
//// }
//// function bar () { return import('./a') }
//// async function main () {
//// const a = await foo()
//// const b = await bar()
//// }
goTo.file('/b.ts')
verify.baselineInlayHints(undefined, {
includeInlayVariableTypeHints: true,
includeInlayFunctionLikeReturnTypeHints: true,
interactiveInlayHints: true
});
| {
"end_byte": 535,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveMultifile1.ts"
} |
TypeScript/tests/cases/fourslash/indentationInObject.ts_0_666 | /// <reference path="fourslash.ts"/>
//// function foo() {
//// {/*8_0*/x:1;y:2;z:3};
//// {x:1/*12_0*/;y:2;z:3};
//// {x:1;/*8_1*/y:2;z:3};
//// {
//// x:1;/*8_2*/y:2;z:3};
//// {x:1;y:2;z:3/*4_0*/};
//// {
//// x:1;y:2;z:3/*4_1*/};
//// {x:1;y:2;z:3}/*4_2*/;
//// {
//// x:1;y:2;z:3}/*4_3*/;
//// }
for (let i = 0; i < 4; ++i) {
goTo.marker(`4_${i}`);
edit.insertLine("");
verify.indentationIs(4);
}
for (let i = 0; i < 3; ++i) {
goTo.marker(`8_${i}`);
edit.insertLine("");
verify.indentationIs(8);
}
goTo.marker(`12_0`);
edit.insertLine("");
verify.indentationIs(12);
| {
"end_byte": 666,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indentationInObject.ts"
} |
TypeScript/tests/cases/fourslash/referencesForStringLiteralPropertyNames.ts_0_214 | /// <reference path='fourslash.ts'/>
////class Foo {
//// public "/*1*/ss": any;
////}
////
////var x: Foo;
////x.ss;
////x["ss"];
////x = { "ss": 0 };
////x = { ss: 0 };
verify.baselineFindAllReferences('1')
| {
"end_byte": 214,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForStringLiteralPropertyNames.ts"
} |
TypeScript/tests/cases/fourslash/alignmentAfterFormattingOnMultilineExpressionAndParametersList.ts_0_563 | /// <reference path='fourslash.ts' />
////class TestClass {
//// private testMethod1(param1: boolean,
//// param2/*1*/: boolean) {
//// }
////
//// public testMethod2(a: number, b: number, c: number) {
//// if (a === b) {
//// }
//// else if (a != c &&
//// a/*2*/ > b &&
//// b/*3*/ < c) {
//// }
////
//// }
////}
format.document();
goTo.marker("1");
verify.indentationIs(8);
goTo.marker("2");
verify.indentationIs(12);
goTo.marker("3");
verify.indentationIs(12);
| {
"end_byte": 563,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/alignmentAfterFormattingOnMultilineExpressionAndParametersList.ts"
} |
TypeScript/tests/cases/fourslash/extract-const_jsxAttribute3.ts_0_809 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: a.tsx
////declare var React: any;
////class Foo extends React.Component<{}, {}> {
//// render() {
//// return (
//// <div>
//// <a href=/*a*/"string"/*b*/></a>;
//// </div>
//// );
//// }
////}
goTo.file("a.tsx");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "constant_scope_1",
actionDescription: "Extract to readonly field in class 'Foo'",
newContent:
`declare var React: any;
class Foo extends React.Component<{}, {}> {
private readonly newProperty = "string";
render() {
return (
<div>
<a href={this./*RENAME*/newProperty}></a>;
</div>
);
}
}`
});
| {
"end_byte": 809,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const_jsxAttribute3.ts"
} |
TypeScript/tests/cases/fourslash/organizeImportsType9.ts_0_1562 | /// <reference path="fourslash.ts" />
//// import { type a, type A, b, B } from "foo";
//// console.log(a, b, A, B);
verify.organizeImports(
`import { type a, type A, b, B } from "foo";
console.log(a, b, A, B);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "inline" });
edit.replaceLine(0, 'import { type a, type A, b, B } from "foo1";');
verify.organizeImports(
`import { type a, type A, b, B } from "foo1";
console.log(a, b, A, B);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "first"}
);
edit.replaceLine(0, 'import { type a, type A, b, B } from "foo2";');
verify.organizeImports(
`import { b, B, type a, type A } from "foo2";
console.log(a, b, A, B);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "last" }
);
edit.replaceLine(0, 'import { type a, type A, b, B } from "foo3";');
verify.organizeImports(
`import { type a, type A, b, B } from "foo3";
console.log(a, b, A, B);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: "auto" }
);
edit.replaceLine(0, 'import { type a, type A, b, B } from "foo4";');
verify.organizeImports(
`import { type a, type A, b, B } from "foo4";
console.log(a, b, A, B);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: true });
edit.replaceLine(0, 'import { type a, type A, b, B } from "foo5";');
verify.organizeImports(
`import { type A, B, type a, b } from "foo5";
console.log(a, b, A, B);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: false }); | {
"end_byte": 1562,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsType9.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesReturn.ts_0_480 | /// <reference path='fourslash.ts' />
////function f(a: number) {
//// if (a > 0) {
//// [|ret/**/urn|] (function () {
//// return;
//// return;
//// return;
////
//// if (false) {
//// return true;
//// }
//// })() || true;
//// }
////
//// var unusued = [1, 2, 3, 4].map(x => { return 4 })
////
//// [|return|];
//// [|return|] true;
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 480,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesReturn.ts"
} |
TypeScript/tests/cases/fourslash/formatAfterMultilineComment.ts_0_132 | /// <reference path="fourslash.ts"/>
/////*foo
////*/"123123";
format.document();
verify.currentFileContentIs(`/*foo
*/"123123";`)
| {
"end_byte": 132,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatAfterMultilineComment.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpTypeParametersNotVariadic.ts_0_188 | /// <reference path="fourslash.ts" />
//// declare function f(a: any, ...b: any[]): any;
//// f</*1*/>(1, 2);
verify.signatureHelp({ marker: "1", argumentCount: 0, isVariadic: false });
| {
"end_byte": 188,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTypeParametersNotVariadic.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingMember4.ts_0_444 | /// <reference path='fourslash.ts' />
// @checkJs: true
// @allowJs: true
// @Filename: a.js
////class C {
//// constructor() {
//// }
//// method() {
//// this.foo === 10;
//// }
////}
verify.codeFix({
description: "Initialize property 'foo' in the constructor",
index: 0,
newFileContent: `class C {
constructor() {
this.foo = undefined;
}
method() {
this.foo === 10;
}
}`
});
| {
"end_byte": 444,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember4.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefs_importType_meaningAtLocation.ts_0_297 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
/////*1*/export type /*2*/T = 0;
/////*3*/export const /*4*/T = 0;
// @Filename: /b.ts
////const x: import("./a")./*5*/T = 0;
////const x: typeof import("./a")./*6*/T = 0;
verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6');
| {
"end_byte": 297,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefs_importType_meaningAtLocation.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingDeclareProperty.ts_0_307 | /// <reference path='fourslash.ts' />
// @useDefineForClassFields: true
////class B {
//// p = 1
////}
////class C extends B {
//// p: number
////}
verify.codeFix({
description: "Prefix with 'declare'",
newFileContent: `class B {
p = 1
}
class C extends B {
declare p: number
}`
});
| {
"end_byte": 307,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingDeclareProperty.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarMerging_grandchildren.ts_0_1523 | /// <reference path="fourslash.ts"/>
////// Should not merge grandchildren with property assignments
////const o = {
//// a: {
//// m() {},
//// },
//// b: {
//// m() {},
//// },
////}
verify.navigationTree({
text: "<global>",
kind: "script",
childItems: [
{
text: "o",
kind: "const",
childItems: [
{
text: "a",
kind: "property",
childItems: [
{ text: "m", kind: "method" }
]
},
{
text: "b",
kind: "property",
childItems: [
{ text: "m", kind: "method" }
]
},
],
},
]
});
verify.navigationBar([
{
text: "<global>",
kind: "script",
childItems: [
{ text: "o", kind: "const" },
],
},
{
text: "o",
kind: "const",
childItems: [
{ text: "a", kind: "property" },
{ text: "b", kind: "property" },
],
indent: 1,
},
{
text: "a",
kind: "property",
childItems: [
{ text: "m", kind: "method" },
],
indent: 2,
},
{
text: "b",
kind: "property",
childItems: [
{ text: "m", kind: "method" },
],
indent: 2,
},
]);
| {
"end_byte": 1523,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarMerging_grandchildren.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.