_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsClassProperty.ts_0_768 | /// <reference path='fourslash.ts'/>
////class c {
//// public /*1*/publicProperty: string;
//// private /*2*/privateProperty: string;
//// protected /*21*/protectedProperty: string;
//// static /*3*/staticProperty: string;
//// private static /*4*/privateStaticProperty: string;
//// protected static /*41*/protectedStaticProperty: string;
//// method() {
//// this./*5*/publicProperty;
//// this./*6*/privateProperty;
//// this./*61*/protectedProperty;
//// c./*7*/staticProperty;
//// c./*8*/privateStaticProperty;
//// c./*81*/protectedStaticProperty;
//// }
////}
////var cInstance = new c();
/////*9*/cInstance./*10*/publicProperty;
/////*11*/c./*12*/staticProperty;
verify.baselineQuickInfo(); | {
"end_byte": 768,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsClassProperty.ts"
} |
TypeScript/tests/cases/fourslash/insertMethodCallAboveOthers.ts_0_155 | /// <reference path="fourslash.ts" />
//// /**/
//// paired.reduce();
//// paired.map(() => undefined);
goTo.marker();
edit.insert("paired.reduce();");
| {
"end_byte": 155,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/insertMethodCallAboveOthers.ts"
} |
TypeScript/tests/cases/fourslash/extract-const-callback.ts_0_382 | /// <reference path='fourslash.ts' />
////const x = [1,2,3].map(/*a*/x => x + 1/*b*/);
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "constant_scope_0",
actionDescription: "Extract to constant in enclosing scope",
newContent:
`const newLocal = (x: number): number => x + 1;
const x = [1,2,3].map(/*RENAME*/newLocal);`
});
| {
"end_byte": 382,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const-callback.ts"
} |
TypeScript/tests/cases/fourslash/renameStringLiteralTypes3.ts_0_349 | /// <reference path='fourslash.ts' />
////type Foo = "[|a|]" | "b";
////
////class C {
//// p: Foo = "[|a|]";
//// m() {
//// switch (this.p) {
//// case "[|a|]":
//// return 1;
//// case "b":
//// return 2;
//// }
//// }
////}
verify.baselineRenameAtRangesWithText("a");
| {
"end_byte": 349,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameStringLiteralTypes3.ts"
} |
TypeScript/tests/cases/fourslash/completionsRecursiveNamespace.ts_0_285 | /// <reference path='fourslash.ts'/>
////declare namespace N {
//// export import M = N;
////}
////type T = N./**/
// Previously this would crash in `symbolCanBeReferencedAtTypeLocation` due to the namespace exporting itself.
verify.completions({ marker: "", exact: undefined });
| {
"end_byte": 285,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsRecursiveNamespace.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess5.ts_0_501 | /// <reference path='fourslash.ts' />
//// class A {
//// /*a*/_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 _a: string;
public get /*RENAME*/a(): string {
return this._a;
}
public set a(value: string) {
this._a = value;
}
}`,
});
| {
"end_byte": 501,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess5.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingMember_typeParameter.ts_0_572 | ////interface I {}
////
////function f<T>(t: T): number {
//// return t.foo;
////}
////
////function g<T extends I>(t: T): number {
//// return t.bar;
////}
// No code fix for "foo"
verify.codeFixAvailable([
{ description: "Declare property 'bar'" }, { description: "Add index signature for property 'bar'" },
])
verify.codeFix({
description: "Declare property 'bar'",
index: 0,
newFileContent:
`interface I {
bar: number;
}
function f<T>(t: T): number {
return t.foo;
}
function g<T extends I>(t: T): number {
return t.bar;
}`,
});
| {
"end_byte": 572,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember_typeParameter.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete8.ts_0_441 | /// <reference path='fourslash.ts' />
//// function f(templateStrings, x, y, z) { return 10; }
//// function g(templateStrings, x, y, z) { return ""; }
////
//// f `/*1*/\/*2*/`/*3*/ /*4*/
verify.signatureHelp({
marker: test.markers(),
text: "f(templateStrings: any, x: any, y: any, z: any): number",
argumentCount: 1,
parameterCount: 4,
parameterName: "templateStrings",
parameterSpan: "templateStrings: any",
});
| {
"end_byte": 441,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete8.ts"
} |
TypeScript/tests/cases/fourslash/javaScriptModulesError1.ts_0_278 | ///<reference path="fourslash.ts" />
// Error: Having more function parameters than entries in the dependency array
// @allowNonTsExtensions: true
// @Filename: Foo.js
//// define('mod1', ['a'], /**/function(a, b) {
////
//// });
// TODO: what should happen?
goTo.marker(); | {
"end_byte": 278,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javaScriptModulesError1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingCallParentheses14.ts_0_614 | /// <reference path='fourslash.ts'/>
// @strictNullChecks: true
////function foo() {
//// const x = {
//// foo: {
//// bar() { return true; }
//// }
//// }
//// x.foo.bar/**/ && 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:
`function foo() {
const x = {
foo: {
bar() { return true; }
}
}
x.foo.bar() && console.log('test');
}`,
});
| {
"end_byte": 614,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingCallParentheses14.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoMappedType.ts_0_488 | /// <reference path="./fourslash.ts"/>
////interface I {
//// /** m documentation */ m(): void;
////}
////declare const o: { [K in keyof I]: number };
////o.m/*0*/;
////
////declare const p: { [K in keyof I]: I[K] };
////p.m/*1*/;
////
////declare const q: Pick<I, "m">;
////q.m/*2*/;
verify.quickInfoAt("0", "(property) m: number", "m documentation");
verify.quickInfoAt("1", "(method) m(): void", "m documentation");
verify.quickInfoAt("2", "(method) m(): void", "m documentation");
| {
"end_byte": 488,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoMappedType.ts"
} |
TypeScript/tests/cases/fourslash/unusedLocalsInMethodFS2.ts_0_305 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
////class greeter {
//// public function1() {
//// [| var x, y; |]
//// use(y);
//// }
////}
verify.rangeAfterCodeFix("var y;", /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, 0);
| {
"end_byte": 305,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedLocalsInMethodFS2.ts"
} |
TypeScript/tests/cases/fourslash/completionsWithDeprecatedTag2.ts_0_422 | /// <reference path="fourslash.ts" />
/////** @deprecated foo */
////declare function foo<T>();
/////** @deprecated foo<T> */
////declare function foo<T>(x);
////
////foo/**/
verify.completions({
marker: "",
includes: [{
name: "foo",
kind: "function",
kindModifiers: "deprecated,declare",
sortText: completion.SortText.Deprecated(completion.SortText.LocationPriority),
}]
});
| {
"end_byte": 422,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsWithDeprecatedTag2.ts"
} |
TypeScript/tests/cases/fourslash/completionListForUnicodeEscapeName.ts_3_337 | / <reference path='fourslash.ts' />
////function \u0042 () { /*0*/ }
////export default function \u0043 () {}
////class \u0041 { /*2*/ }
/////*3*/
verify.completions(
{ marker: "0", includes: ["B"] },
{ marker: "2", excludes: ["C", "A"], isNewIdentifierLocation: true },
{ marker: "3", includes: ["B", "A", "C"] },
);
| {
"end_byte": 337,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListForUnicodeEscapeName.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_AsyncModifiers.ts_0_358 | /// <reference path='fourslash.ts' />
//// const /*x*/a/*y*/ = async () => { return 42; };
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to named function",
actionDescription: "Convert to named function",
newContent: `async function a() { return 42; }`,
});
| {
"end_byte": 358,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_AsyncModifiers.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringVariableStatementNestedObjectBindingPattern.ts_0_921 | /// <reference path='fourslash.ts' />
////declare var console: {
//// log(msg: string): void;
////}
////interface Robot {
//// name: string;
//// skills: {
//// primary: string;
//// secondary: string;
//// };
////}
////var robotA: Robot = { name: "mower", skills: { primary: "mowing", secondary: "none" } };
////var robotB: Robot = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } };
////
////var { skills: { primary: primaryA, secondary: secondaryA } } = robotA;
////var { name: nameB, skills: { primary: primaryB, secondary: secondaryB } } = robotB;
////var { name: nameC, skills: { primary: primaryB, secondary: secondaryB } } = { name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } };
////
////if (nameB == nameB) {
//// console.log(nameC);
////}
////else {
//// console.log(nameC);
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 921,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringVariableStatementNestedObjectBindingPattern.ts"
} |
TypeScript/tests/cases/fourslash/uncommentSelection2.ts_0_641 | // Common uncomment jsx cases
//@Filename: file.tsx
//// const a = <MyContainer>
//// {/*<MyF[|irstComponent />*/}
//// {/*<MySec|]ondComponent />*/}
//// </MyContainer>;
////
//// const b = <div>
//// {/*[|<div>*/}
//// SomeText
//// {/*</div>|]*/}
//// </div>;
////
//// const c = <MyContainer>
//// [||]{/*<MyFirstComponent />*/}
//// </MyContainer>;
verify.uncommentSelection(
`const a = <MyContainer>
<MyFirstComponent />
<MySecondComponent />
</MyContainer>;
const b = <div>
<div>
SomeText
</div>
</div>;
const c = <MyContainer>
<MyFirstComponent />
</MyContainer>;`); | {
"end_byte": 641,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/uncommentSelection2.ts"
} |
TypeScript/tests/cases/fourslash/getEditsForFileRename.ts_0_1056 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
/////// <reference path="./src/old.ts" />
////import old from "./src/old";
// @Filename: /src/a.ts
/////// <reference path="./old.ts" />
////import old from "./old";
// @Filename: /src/foo/a.ts
/////// <reference path="../old.ts" />
////import old from "../old";
// @Filename: /unrelated.ts
// Don't update an unrelated import
////import { x } from "././src/./foo/./a";
// @Filename: /src/old.ts
////export default 0;
// @Filename: /tsconfig.json
////{ "files": ["a.ts", "src/a.ts", "src/foo/a.ts", "src/old.ts"] }
verify.getEditsForFileRename({
oldPath: "/src/old.ts",
newPath: "/src/new.ts",
newFileContents: {
"/a.ts": '/// <reference path="./src/new.ts" />\nimport old from "./src/new";',
"/src/a.ts": '/// <reference path="./new.ts" />\nimport old from "./new";',
"/src/foo/a.ts": '/// <reference path="../new.ts" />\nimport old from "../new";',
"/tsconfig.json": '{ "files": ["a.ts", "src/a.ts", "src/foo/a.ts", "src/new.ts"] }',
},
});
| {
"end_byte": 1056,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpellingCaseSensitive2.ts_0_153 | /// <reference path='fourslash.ts' />
////export let console = 1;
////export let Console = 1;
////[|conole|] = 1;
verify.rangeAfterCodeFix('console');
| {
"end_byte": 153,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingCaseSensitive2.ts"
} |
TypeScript/tests/cases/fourslash/completionsObjectLiteralExpressions9.ts_0_3082 | /// <reference path="fourslash.ts" />
// @Filename: a.ts
////interface T {
//// aaa: number;
//// bbb?: number;
//// ccc?: number;
//// }
//// const obj: T = {
//// aaa: 1 * (2 + 3)
//// c/*a*/
//// }
// @Filename: b.ts
////interface T {
//// aaa?: string;
//// foo(): void;
//// }
//// const obj: T = {
//// foo() {
//
//// }
//// aa/*b*/
//// }
// @Filename: c.ts
//// interface ColorPalette {
//// primary?: string;
//// secondary?: string;
//// }
//// interface I {
//// color: ColorPalette;
//// }
//// const a: I = {
//// color: {primary: "red" sec/**/}
//// }
verify.completions({
marker: "a",
includes: [{
name: "bbb",
sortText: completion.SortText.OptionalMember,
hasAction: true,
source: completion.CompletionSource.ObjectLiteralMemberWithComma,
}],
preferences: {
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
},
});
verify.applyCodeActionFromCompletion("a", {
name: "bbb",
description: `Add missing comma for object member completion 'bbb'.`,
source: completion.CompletionSource.ObjectLiteralMemberWithComma,
newFileContent:
`interface T {
aaa: number;
bbb?: number;
ccc?: number;
}
const obj: T = {
aaa: 1 * (2 + 3),
c
}`,
preferences: {
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
},
});
verify.completions({
marker: "b",
includes: [{
name: "aaa",
sortText: completion.SortText.OptionalMember,
hasAction: true,
source: completion.CompletionSource.ObjectLiteralMemberWithComma,
}],
preferences: {
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
},
});
verify.applyCodeActionFromCompletion("b", {
name: "aaa",
description: `Add missing comma for object member completion 'aaa'.`,
source: completion.CompletionSource.ObjectLiteralMemberWithComma,
newFileContent:
`interface T {
aaa?: string;
foo(): void;
}
const obj: T = {
foo() {
},
aa
}`,
preferences: {
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
},
});
verify.completions({
marker: "",
includes: [{
name: "secondary",
sortText: completion.SortText.OptionalMember,
hasAction: true,
source: completion.CompletionSource.ObjectLiteralMemberWithComma,
}],
preferences: {
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
}
});
verify.applyCodeActionFromCompletion("", {
name: "secondary",
description: `Add missing comma for object member completion 'secondary'.`,
source: completion.CompletionSource.ObjectLiteralMemberWithComma,
newFileContent:
`interface ColorPalette {
primary?: string;
secondary?: string;
}
interface I {
color: ColorPalette;
}
const a: I = {
color: {primary: "red", sec}
}`,
preferences: {
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
},
});
| {
"end_byte": 3082,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsObjectLiteralExpressions9.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_notOnWhitespace.ts_0_139 | /// <reference path='fourslash.ts' />
////class A {
/////*a*/ /*b*/p = 0;
////}
goTo.select("a", "b");
verify.refactorsAvailable([]);
| {
"end_byte": 139,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_notOnWhitespace.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics1.ts_0_134 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: a.js
////import a = b;
verify.baselineSyntacticDiagnostics();
| {
"end_byte": 134,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics1.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationTypeAlias.ts_0_370 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_typealias.baseline
// @Filename: bpSpan_typealias.ts
////module m2 {
//// module m {
//// export class c {
//// }
//// }
//// type a = m.c;
//// export type b = m.c;
//// var x: a = new m.c();
//// var y: b = new m.c();
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 370,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationTypeAlias.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsPrivateNameMethods.ts_3_422 | / <reference path='fourslash.ts'/>
////class C {
//// /*1*/#foo(){ }
//// constructor() {
//// this./*2*/#foo();
//// }
////}
////class D extends C {
//// constructor() {
//// super()
//// this.#foo = 20;
//// }
////}
////class E {
//// /*3*/#foo(){ }
//// constructor() {
//// this./*4*/#foo();
//// }
////}
verify.baselineFindAllReferences('1', '2', '3', '4');
| {
"end_byte": 422,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsPrivateNameMethods.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports28-long-types.ts_0_2560 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
// fileName: code.ts
////export const sessionLoader = {
//// async loadSession() {
//// if (Math.random() > 0.5) {
//// return {
//// PROP_1: {
//// name: false,
//// },
//// PROPERTY_2: {
//// name: 1,
//// },
//// PROPERTY_3: {
//// name: 1
//// },
//// PROPERTY_4: {
//// name: 315,
//// },
//// };
//// }
////
//// return {
//// PROP_1: {
//// name: false,
//// },
//// PROPERTY_2: {
//// name: undefined,
//// },
//// PROPERTY_3: {
//// },
//// PROPERTY_4: {
//// name: 576,
//// },
//// };
//// },
////};
const description = "Add return type 'Promise<{\n PROP_1: {\n name: boolean;\n };\n PROPERTY_2: {\n name: number;\n };\n PROPERTY_3: {\n name: number;\n };\n PROPE...'";
verify.codeFixAvailable([
{ description }
]);
verify.codeFix({
description,
index: 0,
newFileContent:
`export const sessionLoader = {
async loadSession(): Promise<{
PROP_1: {
name: boolean;
};
PROPERTY_2: {
name: number;
};
PROPERTY_3: {
name: number;
};
PROPERTY_4: {
name: number;
};
} | {
PROP_1: {
name: boolean;
};
PROPERTY_2: {
name: any;
};
PROPERTY_3: {
name?: undefined;
};
PROPERTY_4: {
name: number;
};
}> {
if (Math.random() > 0.5) {
return {
PROP_1: {
name: false,
},
PROPERTY_2: {
name: 1,
},
PROPERTY_3: {
name: 1
},
PROPERTY_4: {
name: 315,
},
};
}
return {
PROP_1: {
name: false,
},
PROPERTY_2: {
name: undefined,
},
PROPERTY_3: {
},
PROPERTY_4: {
name: 576,
},
};
},
};`
});
| {
"end_byte": 2560,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports28-long-types.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts_0_2003 | /// <reference path='fourslash.ts' />
////class C {
//// [|{| "count": 3 |}export|] foo;
//// [|{| "count": 3 |}declare|] bar;
//// [|{| "count": 3 |}export|] [|{| "count": 3 |}declare|] foobar;
//// [|{| "count": 3 |}declare|] [|{| "count": 3 |}export|] barfoo;
////
//// constructor([|{| "count": 9 |}export|] conFoo,
//// [|{| "count": 9 |}declare|] conBar,
//// [|{| "count": 9 |}export|] [|{| "count": 9 |}declare|] conFooBar,
//// [|{| "count": 9 |}declare|] [|{| "count": 9 |}export|] conBarFoo,
//// [|{| "count": 4 |}static|] sue,
//// [|{| "count": 4 |}static|] [|{| "count": 9 |}export|] [|{| "count": 9 |}declare|] sueFooBar,
//// [|{| "count": 4 |}static|] [|{| "count": 9 |}declare|] [|{| "count": 9 |}export|] sueBarFoo,
//// [|{| "count": 9 |}declare|] [|{| "count": 4 |}static|] [|{| "count": 9 |}export|] barSueFoo) {
//// }
////}
////
////module m {
//// [|{| "count": 0 |}static|] a;
//// [|{| "count": 0 |}public|] b;
//// [|{| "count": 0 |}private|] c;
//// [|{| "count": 0 |}protected|] d;
//// [|{| "count": 0 |}static|] [|{| "count": 0 |}public|] [|{| "count": 0 |}private|] [|{| "count": 0 |}protected|] e;
//// [|{| "count": 0 |}public|] [|{| "count": 0 |}static|] [|{| "count": 0 |}protected|] [|{| "count": 0 |}private|] f;
//// [|{| "count": 0 |}protected|] [|{| "count": 0 |}static|] [|{| "count": 0 |}public|] g;
////}
////[|{| "count": 0 |}static|] a;
////[|{| "count": 0 |}public|] b;
////[|{| "count": 0 |}private|] c;
////[|{| "count": 0 |}protected|] d;
////[|{| "count": 0 |}static|] [|{| "count": 0 |}public|] [|{| "count": 0 |}private|] [|{| "count": 0 |}protected|] e;
////[|{| "count": 0 |}public|] [|{| "count": 0 |}static|] [|{| "count": 0 |}protected|] [|{| "count": 0 |}private|] f;
////[|{| "count": 0 |}protected|] [|{| "count": 0 |}static|] [|{| "count": 0 |}public|] g;
verify.baselineDocumentHighlights();
| {
"end_byte": 2003,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts"
} |
TypeScript/tests/cases/fourslash/indirectClassInstantiation.ts_0_1120 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: something.js
//// function TestObj(){
//// this.property = "value";
//// }
//// var constructor = TestObj;
//// var instance = new constructor();
//// instance./*a*/
//// var class2 = function() { };
//// class2.prototype.blah = function() { };
//// var inst2 = new class2();
//// inst2.blah/*b*/;
goTo.marker('a');
verify.completions({
exact: [
"property",
{ name: "blah", sortText: completion.SortText.JavascriptIdentifiers },
{ name: "class2", sortText: completion.SortText.JavascriptIdentifiers },
{ name: "constructor", sortText: completion.SortText.JavascriptIdentifiers },
{ name: "inst2", sortText: completion.SortText.JavascriptIdentifiers },
{ name: "instance", sortText: completion.SortText.JavascriptIdentifiers },
{ name: "prototype", sortText: completion.SortText.JavascriptIdentifiers },
{ name: "TestObj", sortText: completion.SortText.JavascriptIdentifiers },
]
});
edit.backspace();
goTo.marker('b');
verify.quickInfoIs('(method) class2.blah(): void');
| {
"end_byte": 1120,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indirectClassInstantiation.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_augmentation.ts_0_826 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export const foo = 0;
// @Filename: /bar.ts
////export {};
////declare module "./a" {
//// export const bar = 0;
////}
// @Filename: /user.ts
/////**/
verify.completions({
marker: "",
includes: [
{
name: "foo",
text: "const foo: 0",
source: "/a",
sourceDisplay: "./a",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
{
name: "bar",
text: "const bar: 0",
source: "/a",
sourceDisplay: "./a",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
],
preferences: {
includeCompletionsForModuleExports: true,
},
});
| {
"end_byte": 826,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_augmentation.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsExportNotAtTopLevel.ts_0_155 | /// <reference path="fourslash.ts" />
////{
//// /*1*/export const /*2*/x = 0;
//// /*3*/x;
////}
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 155,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsExportNotAtTopLevel.ts"
} |
TypeScript/tests/cases/fourslash/formatClassExpression.ts_0_530 | /// <reference path="fourslash.ts"/>
////class Thing extends (
//// class/*classOpenBrace*/
//// {
/////*classIndent*/
//// protected doThing() {/*methodAutoformat*/
/////*methodIndent*/
//// }
//// }
////) {
////}
format.document();
goTo.marker("classOpenBrace");
verify.currentLineContentIs(" class {");
goTo.marker("classIndent");
verify.indentationIs(8);
goTo.marker("methodAutoformat");
verify.currentLineContentIs(" protected doThing() {");
goTo.marker("methodIndent");
verify.indentationIs(12); | {
"end_byte": 530,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatClassExpression.ts"
} |
TypeScript/tests/cases/fourslash/declareFunction.ts_0_156 | /// <reference path="fourslash.ts" />
// @filename: index.ts
////declare function
verify.navigateTo({ pattern: "", fileName: "index.ts", expected: [] });
| {
"end_byte": 156,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/declareFunction.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsReExportsUseInImportType.ts_0_1774 | /// <reference path="fourslash.ts" />
// @Filename: /foo/types/types.ts
////[|export type /*full0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Full|] = { prop: string; };|]
// @Filename: /foo/types/index.ts
////[|import * as /*foo0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}foo|] from './types';|]
////[|export { /*foo1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}foo|] };|]
// @Filename: /app.ts
////[|import { /*foo2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}foo|] } from './foo/types';|]
////export type fullType = /*foo3*/[|foo|]./*full1*/[|Full|];
////type namespaceImport = typeof import('./foo/types');
////type fullType2 = import('./foo/types')./*foo4*/[|foo|]./*full2*/[|Full|];
verify.noErrors();
const [full0Def, full0, foo0Def, foo0, foo1Def, foo1, foo2Def, foo2, foo3, full1, foo4, full2] = test.ranges();
const fullRanges = [full0, full1, full2];
const full = {
definition: "type Full = {\n prop: string;\n}",
ranges: fullRanges
};
const fooTypesRanges = [foo0, foo1];
const fooTypes = {
definition: "import foo",
ranges: fooTypesRanges
};
const fooAppRanges = [foo2, foo3];
const fooApp = {
definition: "import foo",
ranges: fooAppRanges
};
const exportFooRanges = [foo4];
const fooExport = {
definition: "export foo",
ranges: exportFooRanges
};
verify.baselineFindAllReferences('full0', 'full1', 'full2', 'foo0', 'foo1', 'foo2', 'foo3', 'foo4');
verify.baselineRename(fullRanges);
verify.baselineRename(foo0);
verify.baselineRename([foo1, foo4]);
verify.baselineRename(fooAppRanges);
verify.baselineRename([foo2, foo3, foo4, foo0, foo1], { providePrefixAndSuffixTextForRename: false }); | {
"end_byte": 1774,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsReExportsUseInImportType.ts"
} |
TypeScript/tests/cases/fourslash/jsDocForTypeAlias.ts_0_139 | ///<reference path="fourslash.ts" />
/////** DOC */
////type /**/T = number
goTo.marker();
verify.quickInfoIs("type T = number", "DOC");
| {
"end_byte": 139,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocForTypeAlias.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete_import.ts_0_2602 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
////import d from "foo";
////import d2, { used1 } from "foo";
////import { x } from "foo";
////import { x2, used2 } from "foo";
////used1; used2;
////
////function f(a, b) {
//// const x = 0;
////}
////function g(a, b, c) { return a; }
////f; g;
////
////interface I {
//// m(x: number): void;
////}
////
////class C implements I {
//// m(x: number): void {} // Does not remove 'x', which is inherited
//// n(x: number): void {}
//// private ["o"](): void {}
////}
////C;
////
////declare function takesCb(cb: (x: number, y: string) => void): void;
////takesCb((x, y) => {});
////takesCb((x, y) => { x; });
////takesCb((x, y) => { y; });
////
////function fn1(x: number, y: string): void {}
////takesCb(fn1);
////
////function fn2(x: number, y: string): void { x; }
////takesCb(fn2);
////
////function fn3(x: number, y: string): void { y; }
////takesCb(fn3);
////
////x => {
//// const y = 0;
////};
////
////{
//// let a, b;
////}
////for (let i = 0, j = 0; ;) {}
////for (const x of []) {}
////for (const y in {}) {}
////
////export type First<T, U> = T;
////export interface ISecond<T, U> { u: U; }
////export const cls = class<T, U> { u: U; };
////export class Ctu<T, U> {}
////export type Length<T> = T extends ArrayLike<infer U> ? number : never; // Not affected, can't delete
verify.codeFixAll({
fixId: "unusedIdentifier_deleteImports",
fixAllDescription: ts.Diagnostics.Delete_all_unused_imports.message,
newFileContent:
`import { used1 } from "foo";
import { used2 } from "foo";
used1; used2;
function f(a, b) {
const x = 0;
}
function g(a, b, c) { return a; }
f; g;
interface I {
m(x: number): void;
}
class C implements I {
m(x: number): void {} // Does not remove 'x', which is inherited
n(x: number): void {}
private ["o"](): void {}
}
C;
declare function takesCb(cb: (x: number, y: string) => void): void;
takesCb((x, y) => {});
takesCb((x, y) => { x; });
takesCb((x, y) => { y; });
function fn1(x: number, y: string): void {}
takesCb(fn1);
function fn2(x: number, y: string): void { x; }
takesCb(fn2);
function fn3(x: number, y: string): void { y; }
takesCb(fn3);
x => {
const y = 0;
};
{
let a, b;
}
for (let i = 0, j = 0; ;) {}
for (const x of []) {}
for (const y in {}) {}
export type First<T, U> = T;
export interface ISecond<T, U> { u: U; }
export const cls = class<T, U> { u: U; };
export class Ctu<T, U> {}
export type Length<T> = T extends ArrayLike<infer U> ? number : never; // Not affected, can't delete`,
});
| {
"end_byte": 2602,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete_import.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction8.ts_0_225 | /// <reference path='fourslash.ts' />
//// const foo = /*a*/a/*b*/ => {
//// const b = 1;
//// return a + b;
//// };
goTo.select("a", "b");
verify.not.refactorAvailable("Add or remove braces in an arrow function");
| {
"end_byte": 225,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction8.ts"
} |
TypeScript/tests/cases/fourslash/completionsIsPossiblyTypeArgumentPosition.ts_0_1020 | /// <reference path="fourslash.ts" />
////const x = 0;
////type T = number;
////function f(x: number) {}
////function g<T>(x: T) {}
////class C<T> {}
////x + {| "valueOnly": true |}
////x < {| "valueOnly": true |}
////f < {| "valueOnly": true |}
////g < /*g*/
////const something: C</*something*/;
////const something2: C<C</*something2*/;
////new C</*C*/;
////new C<C</*CC*/;
////
////declare const callAndConstruct: { new<T>(): callAndConstruct<T>; <T>(): string; };
////interface callAndConstruct<T> {}
////new callAndConstruct<callAndConstruct</*callAndConstruct*/
for (const marker of test.markers()) {
if (marker.data && marker.data.valueOnly) {
verify.completions({ marker, includes: "x", excludes: "T" });
}
else {
verify.completions({ marker, includes: "T", excludes: "x" });
}
}
verify.signatureHelp({
marker: "callAndConstruct",
text: "callAndConstruct<T>(): string",
parameterName: "T",
parameterSpan: "T",
parameterCount: 1,
argumentCount: 1,
});
| {
"end_byte": 1020,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsIsPossiblyTypeArgumentPosition.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarItemsTypeAlias.ts_0_535 | /// <reference path="fourslash.ts"/>
////type T = number | string;
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "T",
"kind": "type"
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "T",
"kind": "type"
}
]
},
{
"text": "T",
"kind": "type",
"indent": 1
}
]);
| {
"end_byte": 535,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsTypeAlias.ts"
} |
TypeScript/tests/cases/fourslash/automaticConstructorToggling.ts_0_1404 | /// <reference path='fourslash.ts'/>
////class A<T> { }
////class B<T> {/*B*/ }
////class C<T> { /*C*/constructor(val: T) { } }
////class D<T> { constructor(/*D*/val: T) { } }
////
////new /*Asig*/A<string>();
////new /*Bsig*/B("");
////new /*Csig*/C("");
////new /*Dsig*/D<string>();
var A = 'A';
var B = 'B';
var C = 'C';
var D = 'D'
goTo.marker(B);
edit.insert('constructor(val: T) { }');
verify.quickInfos({
Asig: "constructor A<string>(): A<string>",
Bsig: "constructor B<string>(val: string): B<string>",
Csig: "constructor C<string>(val: string): C<string>",
Dsig: "constructor D<string>(val: string): D<string>" // Cannot resolve signature. Still fill in generics based on explicit type arguments.
});
goTo.marker(C);
edit.deleteAtCaret('constructor(val: T) { }'.length);
verify.quickInfos({
Asig: "constructor A<string>(): A<string>",
Bsig: "constructor B<string>(val: string): B<string>",
Csig: "constructor C<unknown>(): C<unknown>", // Cannot resolve signature
Dsig: "constructor D<string>(val: string): D<string>" // Cannot resolve signature
});
goTo.marker(D);
edit.deleteAtCaret("val: T".length);
verify.quickInfos({
Asig: "constructor A<string>(): A<string>",
Bsig: "constructor B<string>(val: string): B<string>",
Csig: "constructor C<unknown>(): C<unknown>", // Cannot resolve signature
Dsig: "constructor D<string>(): D<string>"
});
| {
"end_byte": 1404,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/automaticConstructorToggling.ts"
} |
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction9.ts_0_343 | /// <reference path='fourslash.ts' />
// @target: es2015
////interface Foo<T> {}
////async function fn(): Foo<number> {}
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Replace_0_with_Promise_1.message, "Foo<number>", "Foo<number>"],
newFileContent:
`interface Foo<T> {}
async function fn(): Promise<Foo<number>> {}`
});
| {
"end_byte": 343,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction9.ts"
} |
TypeScript/tests/cases/fourslash/completionsExternalModuleReferenceResolutionOrderInImportDeclaration.ts_0_732 | /// <reference path='fourslash.ts'/>
// @Filename: externalModuleRefernceResolutionOrderInImportDeclaration_file1.ts
////export function foo() { };
// @Filename: externalModuleRefernceResolutionOrderInImportDeclaration_file2.ts
////declare module "externalModuleRefernceResolutionOrderInImportDeclaration_file1" {
//// export function bar();
////}
// @Filename: externalModuleRefernceResolutionOrderInImportDeclaration_file3.ts
///////<reference path='externalModuleRefernceResolutionOrderInImportDeclaration_file2.ts'/>
////import file1 = require('externalModuleRefernceResolutionOrderInImportDeclaration_file1');
/////*1*/
goTo.marker('1');
edit.insert("file1.");
verify.completions({ includes: "bar", excludes: "foo" });
| {
"end_byte": 732,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsExternalModuleReferenceResolutionOrderInImportDeclaration.ts"
} |
TypeScript/tests/cases/fourslash/proto.ts_0_551 | /// <reference path='fourslash.ts' />
////module M {
//// export interface /*1*/__proto__ {}
////}
////var /*2*/__proto__: M.__proto__;
/////*3*/
////var /*4*/fun: (__proto__: any) => boolean;
verify.quickInfos({
1: "interface M.__proto__",
2: "var __proto__: M.__proto__"
});
verify.completions({ marker: "3", includes: { name: "__proto__", text: "var __proto__: M.__proto__" } });
edit.insert("__proto__");
verify.baselineGetDefinitionAtPosition(edit.caretPosition());
verify.quickInfoAt("4", "var fun: (__proto__: any) => boolean");
| {
"end_byte": 551,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/proto.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddVoidToPromise.5.ts_0_191 | /// <reference path='fourslash.ts' />
// @target: esnext
// @lib: es2015
// @strict: true
////const p4: Promise<number> = new Promise(resolve => resolve());
verify.not.codeFixAvailable();
| {
"end_byte": 191,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddVoidToPromise.5.ts"
} |
TypeScript/tests/cases/fourslash/codeFixDeleteUnmatchedParameterJS4.ts_0_456 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @filename: /a.js
/////**
//// * @param {number} a
//// */
////function foo() {}
verify.codeFixAvailable([
{ description: "Delete unused '@param' tag 'a'" },
{ description: "Disable checking for this file" },
]);
verify.codeFix({
description: [ts.Diagnostics.Delete_unused_param_tag_0.message, "a"],
index: 0,
newFileContent:
`/** */
function foo() {}`
});
| {
"end_byte": 456,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixDeleteUnmatchedParameterJS4.ts"
} |
TypeScript/tests/cases/fourslash/renameImportOfExportEquals2.ts_0_963 | /// <reference path='fourslash.ts' />
////[|declare namespace /*N*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}N|] {
//// export var x: number;
////}|]
////declare module "mod" {
//// [|export = [|{| "contextRangeIndex": 2 |}N|];|]
////}
////declare module "a" {
//// [|import * as /*O*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}O|] from "mod";|]
//// [|export { [|{| "contextRangeIndex": 6 |}O|] as /*P*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}P|] };|] // Renaming N here would rename
////}
////declare module "b" {
//// [|import { [|{| "contextRangeIndex": 9 |}P|] as /*Q*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 9 |}Q|] } from "a";|]
//// export const y: typeof [|Q|].x;
////}
verify.noErrors();
verify.baselineFindAllReferences("N", "O", "P", "Q");
verify.baselineRenameAtRangesWithText(["N", "O", "P", "Q"]); | {
"end_byte": 963,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameImportOfExportEquals2.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_functionParams1.ts_0_130 | /// <reference path="fourslash.ts" />
////function f(/*1*/p, /*2*/q?, /*3*/...r: any[] = []) {}
verify.baselineSmartSelection(); | {
"end_byte": 130,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_functionParams1.ts"
} |
TypeScript/tests/cases/fourslash/jsDocFunctionTypeCompletionsNoCrash.ts_0_237 | ///<reference path="fourslash.ts" />
//// /**
//// * @returns {function/**/(): string}
//// */
//// function updateCalendarEvent() {
//// return "";
//// }
verify.completions({
marker: "",
exact: completion.globalTypes
});
| {
"end_byte": 237,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocFunctionTypeCompletionsNoCrash.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesSetAndGet3.ts_0_470 | /// <reference path="fourslash.ts" />
////class Foo {
//// set bar(b: any) {
//// }
////
//// public get bar(): any {
//// return undefined;
//// }
////
//// public set set(s: any) {
//// }
////
//// public get set(): any {
//// return undefined;
//// }
////
//// public [|set|] get(g: any) {
//// }
////
//// public [|get|] get(): any {
//// return undefined;
//// }
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 470,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesSetAndGet3.ts"
} |
TypeScript/tests/cases/fourslash/organizeImportsUnicode4.ts_0_695 | /// <reference path="fourslash.ts" />
//// import {
//// Ab,
//// _aB,
//// aB,
//// _Ab,
//// } from './foo';
////
//// console.log(_aB, _Ab, aB, Ab);
verify.organizeImports(
`import {
_Ab,
_aB,
Ab,
aB,
} from './foo';
console.log(_aB, _Ab, aB, Ab);`, /*mode*/ undefined, {
organizeImportsIgnoreCase: false,
organizeImportsCollation: "unicode",
organizeImportsCaseFirst: "upper",
});
verify.organizeImports(
`import {
_aB,
_Ab,
aB,
Ab,
} from './foo';
console.log(_aB, _Ab, aB, Ab);`, /*mode*/ undefined, {
organizeImportsIgnoreCase: false,
organizeImportsCollation: "unicode",
organizeImportsCaseFirst: "lower",
});
| {
"end_byte": 695,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsUnicode4.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports33-methods.ts_0_387 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
// @Filename: /code.ts
////export class Foo {
//// m() {
//// }
////}
verify.codeFixAvailable([
{
"description": "Add return type 'void'"
},
])
verify.codeFix({
description: "Add return type 'void'",
index: 0,
newFileContent:
`export class Foo {
m(): void {
}
}`
});
| {
"end_byte": 387,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports33-methods.ts"
} |
TypeScript/tests/cases/fourslash/navigateToSymbolIterator.ts_0_282 | /// <reference path="fourslash.ts" />
////class C {
//// [|[Symbol.iterator]() {}|]
////}
verify.navigateTo({
pattern: "iterator",
expected: [
{ name: "iterator", kind: "method", range: test.ranges()[0], containerName: "C", containerKind: "class" },
],
});
| {
"end_byte": 282,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigateToSymbolIterator.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesSetAndGet.ts_0_470 | /// <reference path="fourslash.ts" />
////class Foo {
//// [|set|] bar(b: any) {
//// }
////
//// public [|get|] bar(): any {
//// return undefined;
//// }
////
//// public set set(s: any) {
//// }
////
//// public get set(): any {
//// return undefined;
//// }
////
//// public set get(g: any) {
//// }
////
//// public get get(): any {
//// return undefined;
//// }
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 470,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesSetAndGet.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoJsDocTags13.ts_0_476 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @filename: ./a.js
/////**
//// * First overload
//// * @overload
//// * @param {number} a
//// * @returns {void}
//// */
////
/////**
//// * Second overload
//// * @overload
//// * @param {string} a
//// * @returns {void}
//// */
////
/////**
//// * @param {string | number} a
//// * @returns {void}
//// */
////function f(a) {}
////
////f(/*a*/1);
////f(/*b*/"");
verify.baselineSignatureHelp();
| {
"end_byte": 476,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTags13.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteral14.ts_0_394 | /// <reference path='fourslash.ts'/>
////interface Foo {
//// a: string;
//// b: boolean;
//// c: number;
////}
////type Bar = Record<keyof Foo, any>["[|/**/|]"];
const replacementSpan = test.ranges()[0]
verify.completions({
marker: "",
exact: [
{ name: "a", replacementSpan },
{ name: "b", replacementSpan },
{ name: "c", replacementSpan }
]
});
| {
"end_byte": 394,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral14.ts"
} |
TypeScript/tests/cases/fourslash/addMemberInDeclarationFile.ts_0_415 | /// <reference path="fourslash.ts" />
// @Filename: ./declarations.d.ts
//// interface Response {}
// @Filename: foo.ts
//// import './declarations.d.ts'
//// declare const resp: Response
//// resp.test()
goTo.file('foo.ts')
verify.codeFixAvailable([
{ description: "Declare method 'test'" },
{ description: "Declare property 'test'" },
{ description: "Add index signature for property 'test'" }
])
| {
"end_byte": 415,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/addMemberInDeclarationFile.ts"
} |
TypeScript/tests/cases/fourslash/exhaustiveCaseCompletions9.ts_0_217 | /// <reference path="fourslash.ts" />
// @newline: LF
////switch (Math.random() ? 123 : 456) {
//// case "foo!":
//// case/**/
////}
verify.baselineCompletions({
includeCompletionsWithInsertText: true,
})
| {
"end_byte": 217,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/exhaustiveCaseCompletions9.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue3.ts_0_218 | /// <reference path='fourslash.ts' />
//// interface A {
//// foo: number
//// }
//// function Foo (): A | number {
//// 1
//// }
verify.codeFixAvailable([
{ description: 'Add a return statement' },
]);
| {
"end_byte": 218,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue3.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoJsDocNonDiscriminatedUnionSharedProp.ts_0_911 | /// <reference path='fourslash.ts'/>
//// interface Entries {
//// /**
//// * Plugins info...
//// */
//// plugins?: Record<string, Record<string, unknown>>;
//// /**
//// * Output info...
//// */
//// output?: string;
//// /**
//// * Format info...
//// */
//// format?: string;
//// }
////
//// interface Input extends Entries {
//// /**
//// * Input info...
//// */
//// input: string;
//// }
////
//// interface Types extends Entries {
//// /**
//// * Types info...
//// */
//// types: string;
//// }
////
//// type EntriesOptions = Input | Types;
////
//// const options: EntriesOptions[] = [
//// {
//// input: "./src/index.ts",
//// /*1*/output: "./dist/index.mjs",
//// },
//// {
//// types: "./src/types.ts",
//// format: "esm",
//// },
//// ];
verify.quickInfoAt("1", "(property) Entries.output?: string", "Output info...");
| {
"end_byte": 911,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocNonDiscriminatedUnionSharedProp.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageNumberIndexSignatureJS.ts_0_363 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noImplicitAny: true
// @Filename: important.js
////function f([|a|]) {
//// return a[0] + 1;
////}
verify.codeFix({
description: "Infer parameter types from usage",
index: 0,
newFileContent:
`/**
* @param {number[]} a
*/
function f(a) {
return a[0] + 1;
}`,
});
| {
"end_byte": 363,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageNumberIndexSignatureJS.ts"
} |
TypeScript/tests/cases/fourslash/renameInheritedProperties7.ts_3_281 | / <reference path='fourslash.ts'/>
//// class C extends D {
//// [|[|{| "contextRangeIndex": 0 |}prop1|]: string;|]
//// }
////
//// class D extends C {
//// prop1: string;
//// }
////
//// var c: C;
//// c.[|prop1|];
verify.baselineRenameAtRangesWithText("prop1");
| {
"end_byte": 281,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameInheritedProperties7.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsUnresolvedSymbols2.ts_0_388 | /// <reference path='fourslash.ts'/>
////import { /*a0*/Bar } from "does-not-exist";
////
////let a: /*a1*/Bar;
////let b: /*a2*/Bar<string>;
////let c: /*a3*/Bar<string, number>;
////let d: /*a4*/Bar./*b0*/X;
////let e: /*a5*/Bar./*b1*/X<string>;
////let f: /*a6*/Bar./*c0*/X./*d0*/Y;
verify.baselineFindAllReferences('a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'b0', 'b1', 'c0', 'd0');
| {
"end_byte": 388,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsUnresolvedSymbols2.ts"
} |
TypeScript/tests/cases/fourslash/mapCodeNoChanges.ts_0_266 | ///<reference path="fourslash.ts"/>
// @Filename: /index.ts
//// function foo() {
//// return 1;
//// }
//// [||]
//// function bar() {
//// return 2;
//// }
//// function baz() {
//// return 3;
//// }
////
verify.baselineMapCode([test.ranges()], []);
| {
"end_byte": 266,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeNoChanges.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_js_4.ts_0_504 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: a.js
//// class A {
//// /*a*/"a"/*b*/ = 1;
//// }
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 {
/*RENAME*/"_a" = 1;
get "a"() {
return this["_a"];
}
set "a"(value) {
this["_a"] = value;
}
}`,
});
| {
"end_byte": 504,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_js_4.ts"
} |
TypeScript/tests/cases/fourslash/completionsImportPathsConflict.ts_0_1265 | /// <reference path="fourslash.ts" />
// @Filename: /tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "esnext",
//// "paths": {
//// "@reduxjs/toolkit": ["src/index.ts"],
//// "@internal/*": ["src/*"]
//// }
//// }
//// }
// @Filename: /src/index.ts
//// export { configureStore } from "./configureStore";
// @Filename: /src/configureStore.ts
//// export function configureStore() {}
// @Filename: /src/tests/createAsyncThunk.typetest.ts
//// import {} from "@reduxjs/toolkit";
//// /**/
verify.completions({
marker: "",
includes: [{
name: "configureStore",
source: "@reduxjs/toolkit",
sourceDisplay: "@reduxjs/toolkit",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
}],
preferences: {
allowIncompleteCompletions: true,
includeCompletionsForModuleExports: true,
},
});
verify.applyCodeActionFromCompletion("", {
name: "configureStore",
source: "@reduxjs/toolkit",
data: {
exportName: "configureStore",
fileName: "/src/configureStore.ts",
moduleSpecifier: "@reduxjs/toolkit",
},
description: `Update import from "@reduxjs/toolkit"`,
newFileContent: `import { configureStore } from "@reduxjs/toolkit";\n`,
});
| {
"end_byte": 1265,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImportPathsConflict.ts"
} |
TypeScript/tests/cases/fourslash/jsdocSatisfiesTagRename.ts_0_286 | ///<reference path="fourslash.ts" />
// @noEmit: true
// @allowJS: true
// @checkJs: true
// @filename: /a.js
/////**
//// * @typedef {Object} T
//// * @property {number} a
//// */
////
/////** @satisfies {/**/T} comment */
////const foo = { a: 1 };
verify.baselineRename("", { });
| {
"end_byte": 286,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocSatisfiesTagRename.ts"
} |
TypeScript/tests/cases/fourslash/autoImportPackageJsonImportsCaseSensitivity.ts_0_465 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @allowImportingTsExtensions: true
// @Filename: /package.json
//// {
//// "type": "module",
//// "imports": {
//// "#src/*": "./SRC/*"
//// }
//// }
// @Filename: /src/add.ts
//// export function add(a: number, b: number) {}
// @Filename: /src/index.ts
//// add/*imports*/;
verify.importFixModuleSpecifiers("imports", ["#src/add.ts"], { importModuleSpecifierPreference: "non-relative" }); | {
"end_byte": 465,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPackageJsonImportsCaseSensitivity.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_symlink.ts_0_465 | /// <reference path="fourslash.ts" />
// @moduleResolution: node
// @noLib: true
// @Filename: /node_modules/real/index.d.ts
// @Symlink: /node_modules/link/index.d.ts
////export const foo: number;
// @Filename: /a.ts
////import { foo } from "link";
// @Filename: /b.ts
////[|foo;|]
// Uses "link" instead of "real" because `a` did.
goTo.file("/b.ts");
verify.importFixAtPosition([
`import { foo } from "link";
foo;`,
`import { foo } from "real";
foo;`,
]);
| {
"end_byte": 465,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_symlink.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportDefault0.ts_0_193 | /// <reference path="fourslash.ts" />
//// [|f1/*0*/();|]
// @Filename: module.ts
//// export default function f1() { };
verify.importFixAtPosition([
`import f1 from "./module";
f1();`
]);
| {
"end_byte": 193,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportDefault0.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsEnum2.ts_0_578 | /// <reference path='fourslash.ts'/>
////enum /*1*/E {
//// /*2*/"e1",
//// /*3*/'e2' = 10,
//// /*4*/"e3"
////}
////var /*5*/eInstance: /*6*/E;
/////*7*/eInstance = /*8*/E./*9*/e1;
/////*10*/eInstance = /*11*/E./*12*/e2;
/////*13*/eInstance = /*14*/E./*15*/e3;
////const enum /*16*/constE {
//// /*17*/"e1",
//// /*18*/'e2' = 10,
//// /*19*/"e3"
////}
////var /*20*/eInstance1: /*21*/constE;
/////*22*/eInstance1 = /*23*/constE./*24*/e1;
/////*25*/eInstance1 = /*26*/constE./*27*/e2;
/////*28*/eInstance1 = /*29*/constE./*30*/e3;
verify.baselineQuickInfo(); | {
"end_byte": 578,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsEnum2.ts"
} |
TypeScript/tests/cases/fourslash/arbitraryModuleNamespaceIdentifiers_types.ts_0_648 | /// <reference path='fourslash.ts' />
// @Filename: /foo.ts
////type foo = "foo";
////export { type foo as "[|__<alias>|]" };
////import { type "[|__<alias>|]" as bar } from "./foo";
////const testBar: bar = "foo";
// @Filename: /bar.ts
////import { type "[|__<alias>|]" as first } from "./foo";
////export { type "[|__<alias>|]" as "<other>" } from "./foo";
////import { type "<other>" as second } from "./bar";
////const testFirst: first = "foo";
////const testSecond: second = "foo";
verify.noErrors();
verify.baselineRename(test.ranges());
verify.baselineGoToDefinition(...test.ranges());
verify.baselineFindAllReferences(...test.ranges());
| {
"end_byte": 648,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/arbitraryModuleNamespaceIdentifiers_types.ts"
} |
TypeScript/tests/cases/fourslash/javascriptModules24.ts_0_552 | /// <reference path='fourslash.ts'/>
// @Filename: mod.ts
//// function foo() { return 42; }
//// namespace foo {
//// export function bar (a: string) { return a; }
//// }
//// export = foo;
// @Filename: app.ts
//// import * as foo from "./mod"
//// foo/*1*/();
//// foo.bar(/*2*/"test");
goTo.marker('1');
/**** BUG: Should be an error to invoke a call signature on a namespace import ****/
//verify.errorExistsBeforeMarker('1');
verify.quickInfoIs("(alias) foo(): number\nimport foo");
verify.signatureHelp({ marker: "2", argumentCount: 1 });
| {
"end_byte": 552,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javascriptModules24.ts"
} |
TypeScript/tests/cases/fourslash/renameStringPropertyNames2.ts_0_234 | /// <reference path="fourslash.ts" />
////type Props = {
//// foo: boolean;
////}
////
////let { foo }: Props = null as any;
////foo;
////
////let asd: Props = { "foo"/**/: true }; // rename foo here
verify.baselineRename("", {});
| {
"end_byte": 234,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameStringPropertyNames2.ts"
} |
TypeScript/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName2.ts_0_1356 | /// <reference path="fourslash.ts"/>
////module /*0*/M {
//// export interface /*1*/I {
//// }
////}
////
////module /*2*/M {
//// var x = 10;
////}
////
////var /*3*/M = {
//// foo: 10,
//// bar: 20
////}
////
////var v: /*4*/M./*5*/I;
////
////var x = /*6*/M;
const c = classification("original");
verify.semanticClassificationsAre("original",
c.moduleName("M", test.marker("0").position),
c.interfaceName("I", test.marker("1").position),
c.moduleName("M", test.marker("2").position),
c.moduleName("M", test.marker("4").position),
c.interfaceName("I", test.marker("5").position),
c.moduleName("M", test.marker("6").position));
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("namespace.declaration", "M"),
c2.semanticToken("interface.declaration", "I"),
c2.semanticToken("namespace.declaration", "M"),
c2.semanticToken("variable.declaration.local", "x"),
c2.semanticToken("variable.declaration", "M"),
c2.semanticToken("property.declaration", "foo"),
c2.semanticToken("property.declaration", "bar"),
c2.semanticToken("variable.declaration", "v"),
c2.semanticToken("namespace", "M"),
c2.semanticToken("interface", "I"),
c2.semanticToken("variable.declaration", "x"),
c2.semanticToken("namespace", "M"),
);
| {
"end_byte": 1356,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semanticClassificationInstantiatedModuleWithVariableOfSameName2.ts"
} |
TypeScript/tests/cases/fourslash/functionOverloadCount.ts_0_353 | /// <reference path="fourslash.ts"/>
////class C1 {
//// public attr(): string;
//// public attr(i: number): string;
//// public attr(i: number, x: boolean): string;
//// public attr(i?: any, x?: any) {
//// return "hi";
//// }
////}
////var i = new C1;
////i.attr(/*1*/
verify.signatureHelp({ marker: "1", overloadsCount: 3 });
| {
"end_byte": 353,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/functionOverloadCount.ts"
} |
TypeScript/tests/cases/fourslash/addAllMissingImportsNoCrash2.ts_0_160 | /// <reference path="fourslash.ts" />
// @Filename: file1.ts
//// export { /**/default };
goTo.marker();
verify.not.codeFixAllAvailable("fixMissingImport");
| {
"end_byte": 160,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/addAllMissingImportsNoCrash2.ts"
} |
TypeScript/tests/cases/fourslash/completionListInObjectBindingPattern09.ts_0_332 | /// <reference path='fourslash.ts'/>
////interface I {
//// propertyOfI_1: number;
//// propertyOfI_2: string;
////}
////interface J {
//// property1: I;
//// property2: string;
////}
////
////var foo: J;
////var { property1: { propertyOfI_1, }, /**/ } = foo;
verify.completions({ marker: "", exact: ["property2"] });
| {
"end_byte": 332,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectBindingPattern09.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsInteractiveRestParameters3.ts_0_294 | /// <reference path="fourslash.ts" />
////function fn(x: number, y: number, a: number, b: number) {
//// return x + y + a + b;
////}
////const foo: [x: number, y: number] = [1, 2];
////fn(...foo, 3, 4);
verify.baselineInlayHints(undefined, {
includeInlayParameterNameHints: "all",
});
| {
"end_byte": 294,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveRestParameters3.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAsFnArgument.ts_0_380 | /// <reference path='fourslash.ts' />
//// console.log("/*x*/f/*y*/oobar is " + 32 + " years old")
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
newContent:
`console.log(\`foobar is \${32} years old\`)`,
});
| {
"end_byte": 380,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAsFnArgument.ts"
} |
TypeScript/tests/cases/fourslash/codeFixConvertToMappedObjectType5.ts_0_153 | /// <reference path='fourslash.ts' />
//// type K = "foo" | "bar";
//// class SomeType {
//// [prop: K]: any;
//// }
verify.not.codeFixAvailable()
| {
"end_byte": 153,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToMappedObjectType5.ts"
} |
TypeScript/tests/cases/fourslash/unusedImports9FS.ts_0_339 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @Filename: file2.ts
//// [|import c = require('./file1')|]
// @Filename: file1.ts
//// export class Calculator {
//// handleChar() { }
//// }
////
//// export function test() {
////
//// }
////
//// export function test2() {
////
//// }
verify.rangeAfterCodeFix(""); | {
"end_byte": 339,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedImports9FS.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts_0_446 | /// <reference path='fourslash.ts' />
// @lib: es2017
////enum E { a,b,c }
////interface I {
//// x: E;
//// y: E.a
//// z: symbol;
//// w: object;
////}
////class C implements I {}
verify.codeFix({
description: "Implement interface 'I'",
newFileContent:
`enum E { a,b,c }
interface I {
x: E;
y: E.a
z: symbol;
w: object;
}
class C implements I {
x: E;
y: E.a;
z: symbol;
w: object;
}`,
});
| {
"end_byte": 446,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts"
} |
TypeScript/tests/cases/fourslash/completionsElementAccessNumeric.ts_0_747 | /// <reference path="fourslash.ts" />
// @target: esnext
////type Tup = [
//// /**
//// * The first label
//// */
//// lbl1: number,
//// /**
//// * The second label
//// */
//// lbl2: number
////];
////declare var x: Tup;
////x[|./**/|]
const replacementSpan = test.ranges()[0];
verify.completions(
{
marker: "",
includes: [
{name: "0", insertText: "[0]", replacementSpan, documentation: "The first label", text: "(property) 0: number (lbl1)" },
{name: "1", insertText: "[1]", replacementSpan, documentation: "The second label", text: "(property) 1: number (lbl2)" },
],
preferences: {
includeInsertTextCompletions: true,
},
},
);
| {
"end_byte": 747,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsElementAccessNumeric.ts"
} |
TypeScript/tests/cases/fourslash/jsDocPropertyDescription6.ts_0_663 | // /<reference path="fourslash.ts" />
//// interface Literal1Example {
//// [key: `prefix${string}`]: number | string;
//// /** Something else */
//// [key: `prefix${number}`]: number;
//// }
//// function literal1Example(e: Literal1Example) {
//// console.log(e./*literal1*/prefixMember);
//// console.log(e./*literal2*/anything);
//// console.log(e./*literal3*/prefix0);
//// }
verify.quickInfoAt("literal1", "(index) Literal1Example[`prefix${string}`]: string | number");
verify.quickInfoAt("literal2", "any");
verify.quickInfoAt("literal3", "(index) Literal1Example[`prefix${string}` | `prefix${number}`]: number", "Something else"); | {
"end_byte": 663,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocPropertyDescription6.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoPrivateIdentifierInTypeReferenceNoCrash1.ts_0_214 | /// <reference path="fourslash.ts" />
// @target: esnext
//// class Foo {
//// #prop: string = "";
////
//// method() {
//// const test: Foo.#prop/*1*/ = "";
//// }
//// }
verify.quickInfoAt("1", "");
| {
"end_byte": 214,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoPrivateIdentifierInTypeReferenceNoCrash1.ts"
} |
TypeScript/tests/cases/fourslash/whiteSpaceTrimming.ts_0_194 | /// <reference path="fourslash.ts" />
////if (true) {
//// //
//// /*err*/}
goTo.marker('err');
edit.insert("\n");
verify.currentFileContentIs("if (true) { \n // \n\n}");
| {
"end_byte": 194,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/whiteSpaceTrimming.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExportsTypePredicate1.ts_0_422 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
// @filename: index.ts
//// export function isString(value: unknown) {
//// return typeof value === "string";
//// }
verify.codeFix({
description: `Add return type 'value is string'`,
index: 0,
newFileContent: `export function isString(value: unknown): value is string {
return typeof value === "string";
}`,
});
| {
"end_byte": 422,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExportsTypePredicate1.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixDefaultExport.ts_0_221 | /// <reference path="fourslash.ts" />
// @Filename: /foo-bar.ts
////export default 0;
// @Filename: /b.ts
////[|foo/**/Bar|]
goTo.file("/b.ts");
verify.importFixAtPosition([`import fooBar from "./foo-bar";
fooBar`]);
| {
"end_byte": 221,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixDefaultExport.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl0.ts_0_294 | /// <reference path="fourslash.ts" />
//// [|f1/*0*/();|]
// @Filename: tsconfig.json
//// {
//// "compilerOptions": {
//// "baseUrl": "./a"
//// }
//// }
// @Filename: a/b.ts
//// export function f1() { };
verify.importFixAtPosition([
`import { f1 } from "b";
f1();`,
]);
| {
"end_byte": 294,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl0.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateBinaryExpr1.ts_0_388 | /// <reference path='fourslash.ts' />
//// const foo = "/*x*/f/*y*/oobar is " + (42 + 6) + " years old"
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
newContent:
`const foo = \`foobar is \${42 + 6} years old\``,
});
| {
"end_byte": 388,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateBinaryExpr1.ts"
} |
TypeScript/tests/cases/fourslash/completionListWithModulesOutsideModuleScope2.ts_0_7052 | /// <reference path="fourslash.ts"/>
////module mod1 {
//// var mod1var = 1;
//// function mod1fn() {
//// var bar = 1;
//// function foob() { }
//// }
//// class mod1cls {
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// interface mod1int {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// module mod1mod {
//// var m1X = 1;
//// function m1Func() {
//// var bar = 1;
//// function foob() { }
//// }
//// class m1Class {
//// private cVar = 1;
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// interface m1Int {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// export var m1eX = 1;
//// export function m1eFunc() {
//// }
//// export class m1eClass {
//// private cVar = 1;
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// export interface m1eInt {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// module m1Mod { }
//// export module m1eMod { }
//// }
//// export var mod1evar = 1;
//// export function mod1efn() {
//// var bar = 1;
//// function foob() { }
//// }
//// export class mod1ecls {
//// private cVar = 1;
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// export interface mod1eint {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// export module mod1emod {
//// var mX = 1;
//// function mFunc() {
//// var bar = 1;
//// function foob() { }
//// }
//// class mClass {
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// interface mInt {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// export var meX = 1;
//// export function meFunc() {
//// }
//// export class meClass {
//// private cVar = 1;
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// export interface meInt {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// module mMod { }
//// export module meMod { }
//// }
////}
////
////// EXTENDING MODULE 1
////module mod1 {
//// export var mod1eexvar = 1;
//// var mod1exvar = 2;
////}
////
////module mod2 {
//// var mod2var = "shadow";
//// function mod2fn() {
//// var bar = 1;
//// function foob() { }
//// }
//// class mod2cls {
//// private cVar = 1;
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// module mod2mod { }
//// interface mod2int {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// export var mod2evar = 1;
//// export function mod2efn() {
//// }
//// export class mod2ecls {
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// export interface mod2eint {
//// (bar: any): any;
//// new (bar: any): any;
//// bar: any;
//// foob(bar: any): any;
//// }
//// export module mod2emod { }
////}
////
////module mod2 {
//// export var mod2eexvar = 1;
////}
////
////module mod3 {
//// var shwvar = "shadow";
//// function shwfn() {
//// var bar = 1;
//// function foob() { }
//// }
//// class shwcls {
//// constructor(public shadow: any) { }
//// private cVar = 1;
//// public cFunc() { }
//// public ceFunc() { }
//// public ceVar = 1;
//// static csVar = 1;
//// static csFunc() { }
//// }
//// interface shwint {
//// (bar: any): any;
//// new (bar: any): any;
//// sivar: string;
//// sifn(shadow: any): any;
//// }
////}
////
////function shwfn() {
//// var sfvar = 1;
//// function sffn() { }
////}
////
////class shwcls {
//// private scvar = 1;
//// private scfn() { }
//// public scpfn() { }
//// public scpvar = 1;
//// static scsvar = 1;
//// static scsfn() { }
////}
////
////interface shwint {
//// (bar: any): any;
//// new (bar: any): any;
//// sivar: any;
//// sifn(bar: any): any;
////}
////
////var shwvar = 1;
////
////class extCls extends shwcls {
//// /*extendedClass*/
////}
////
////function shwFnTest() {
//// function shwFnTest {
////
//// }
//// var shwvar = "1";
//// /*localVar*/
////}
////
////var obj = {
//// x: /*objectLiteral*/
////}
verify.completions(
{
marker: "extendedClass",
unsorted: ["scpfn", "scpvar", ...completion.classElementKeywords],
isNewIdentifierLocation: true,
},
{
marker: "objectLiteral",
includes: [
"mod1",
"mod2",
"mod3",
{ name: "shwvar", text: "var shwvar: number" },
{ name: "shwfn", text: "function shwfn(): void" },
{ name: "shwcls", text: "class shwcls" },
],
excludes: [
"shwint",
"mod2var",
"mod2fn",
"mod2cls",
"mod2int",
"mod2mod",
"mod2evar",
"mod2efn",
"mod2ecls",
"mod2eint",
"mod2emod",
"sfvar",
"sffn",
"scvar",
"scfn",
"scpfn",
"scpvar",
"scsvar",
"scsfn",
"sivar",
"sifn",
"mod1exvar",
"mod2eexvar",
]
},
{
marker: "localVar",
includes: { name: "shwvar", text: "(local var) shwvar: string" },
},
);
| {
"end_byte": 7052,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListWithModulesOutsideModuleScope2.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteral_quotePreference2.ts_0_342 | /// <reference path='fourslash.ts'/>
////const a = {
//// '#': 'a'
////};
////a[|./**/|]
verify.completions({
marker: "",
includes: [
{ name: "#", insertText: "['#']", replacementSpan: test.ranges()[0] },
],
preferences: {
includeInsertTextCompletions: true,
quotePreference: "single",
},
});
| {
"end_byte": 342,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral_quotePreference2.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_typeLiteral.ts_0_598 | /// <reference path='fourslash.ts' />
////type Foo = {
//// method(x: string, y: string): void;
////}
////const x: Foo = {
//// method(/*a*/x: string, y: string/*b*/): void {},
////};
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `type Foo = {
method({ x, y }: { x: string; y: string; }): void;
}
const x: Foo = {
method({ x, y }: { x: string; y: string; }): void {},
};`
});
| {
"end_byte": 598,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_typeLiteral.ts"
} |
TypeScript/tests/cases/fourslash/moduleNodeNextAutoImport1.ts_0_437 | /// <reference path="fourslash.ts" />
// @Filename: /tsconfig.json
//// { "compilerOptions": { "module": "nodenext" } }
// @Filename: /package.json
//// { "type": "module" }
// @Filename: /mobx.d.ts
//// export declare function autorun(): void;
// @Filename: /index.ts
//// autorun/**/
// @Filename: /utils.ts
//// import "./mobx.js";
goTo.marker("");
verify.importFixAtPosition([`import { autorun } from "./mobx.js";
autorun`]);
| {
"end_byte": 437,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moduleNodeNextAutoImport1.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpEmptyList.ts_0_466 | /// <reference path='fourslash.ts' />
////function Foo(arg1: string, arg2: string) {
////}
////
////Foo(/*1*/);
////function Bar<T>(arg1: string, arg2: string) { }
////Bar</*2*/>();
verify.signatureHelp(
{
marker: "1",
text: "Foo(arg1: string, arg2: string): void",
parameterCount: 2,
parameterName: "arg1",
parameterSpan: "arg1: string",
},
{ marker: "2", text: "Bar<T>(arg1: string, arg2: string): void" },
);
| {
"end_byte": 466,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpEmptyList.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingEnumMember8.ts_0_264 | /// <reference path='fourslash.ts' />
////enum E {
//// a,
//// b = 1,
//// c = "123"
////}
////E.d
verify.codeFix({
description: "Add missing enum member 'd'",
newFileContent: `enum E {
a,
b = 1,
c = "123",
d = "d"
}
E.d`
});
| {
"end_byte": 264,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingEnumMember8.ts"
} |
TypeScript/tests/cases/fourslash/formattingTemplates.ts_0_290 | ///<reference path="fourslash.ts"/>
////String.call `${123}`/*1*/
////String.call `${123} ${456}`/*2*/
goTo.marker("1");
edit.insert(";");
verify.currentLineContentIs("String.call`${123}`;");
goTo.marker("2");
edit.insert(";");
verify.currentLineContentIs("String.call`${123} ${456}`;"); | {
"end_byte": 290,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingTemplates.ts"
} |
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc13.ts_0_289 | /// <reference path='fourslash.ts' />
////class C {
//// /** @return {number} */
//// get c() { return 12 }
////}
verify.codeFix({
description: "Annotate with type from JSDoc",
newFileContent:
`class C {
/** @return {number} */
get c(): number { return 12 }
}`,
});
| {
"end_byte": 289,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc13.ts"
} |
TypeScript/tests/cases/fourslash/completionsObjectLiteralModuleExports.ts_0_281 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @Filename: index.js
//// const almanac = 0;
//// module.exports = {
//// a/**/
//// };
verify.completions({
marker: "",
isNewIdentifierLocation: true,
includes: "almanac",
excludes: "a",
});
| {
"end_byte": 281,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsObjectLiteralModuleExports.ts"
} |
TypeScript/tests/cases/fourslash/toggleLineComment6.ts_0_244 | // Selection is at the start of jsx its still js.
//@Filename: file.tsx
//// let a = (
//// [|<div>
//// some text|]
//// </div>
//// );
verify.toggleLineComment(
`let a = (
//<div>
// some text
</div>
);`); | {
"end_byte": 244,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/toggleLineComment6.ts"
} |
TypeScript/tests/cases/fourslash/arityErrorAfterStringCompletions.ts_0_390 | ///<reference path="fourslash.ts"/>
// @strict: true
////
//// interface Events {
//// click: any;
//// drag: any;
//// }
////
//// declare function addListener<K extends keyof Events>(type: K, listener: (ev: Events[K]) => any): void;
////
//// /*1*/addListener/*2*/("/*3*/")
verify.completions({ marker: ["3"], exact: ["click", "drag"] });
verify.errorExistsBetweenMarkers("1", "2");
| {
"end_byte": 390,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/arityErrorAfterStringCompletions.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags9.ts_0_670 | /// <reference path='fourslash.ts' />
//// function f(templateStrings: string[], p1_o1: string): number;
//// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string;
//// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean;
//// function f(...foo[]: any) { return ""; }
////
//// f `${/*1*/ /*2*/ /*3*/} ${
verify.signatureHelp({
marker: test.markers(),
overloadsCount: 3,
text: "f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string",
argumentCount: 3,
parameterCount: 4,
parameterName: "p1_o2",
parameterSpan: "p1_o2: number",
});
| {
"end_byte": 670,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags9.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.