_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/callHierarchyExportDefaultFunction.ts_0_310 | /// <reference path="fourslash.ts" />
// @filename: main.ts
//// import bar from "./other";
////
//// function foo() {
//// bar();
//// }
// @filename: other.ts
//// export /**/default function () {
//// baz();
//// }
////
//// function baz() {
//// }
goTo.marker();
verify.baselineCallHierarchy();
| {
"end_byte": 310,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyExportDefaultFunction.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarItemsItemsExternalModules2.ts_0_1349 | /// <reference path="fourslash.ts"/>
// @Filename: test/file.ts
////export class Bar {
//// public s: string;
////}
////export var x: number;
verify.navigationTree({
"text": "\"file\"",
"kind": "module",
"childItems": [
{
"text": "Bar",
"kind": "class",
"kindModifiers": "export",
"childItems": [
{
"text": "s",
"kind": "property",
"kindModifiers": "public"
}
]
},
{
"text": "x",
"kind": "var",
"kindModifiers": "export"
}
]
});
verify.navigationBar([
{
"text": "\"file\"",
"kind": "module",
"childItems": [
{
"text": "Bar",
"kind": "class",
"kindModifiers": "export"
},
{
"text": "x",
"kind": "var",
"kindModifiers": "export"
}
]
},
{
"text": "Bar",
"kind": "class",
"kindModifiers": "export",
"childItems": [
{
"text": "s",
"kind": "property",
"kindModifiers": "public"
}
],
"indent": 1
}
]);
| {
"end_byte": 1349,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsItemsExternalModules2.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpInference.ts_0_288 | /// <reference path='fourslash.ts' />
////declare function f<T extends string>(a: T, b: T, c: T): void;
////f("x", /**/);
verify.signatureHelp({
marker: "",
text: 'f(a: "x", b: "x", c: "x"): void',
parameterCount: 3,
parameterName: "b",
parameterSpan: 'b: "x"',
});
| {
"end_byte": 288,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpInference.ts"
} |
TypeScript/tests/cases/fourslash/jsdocImportTagCompletion1.ts_0_190 | ///<reference path="fourslash.ts" />
// @allowJS: true
// @checkJs: true
// @filename: /a.js
/////**
//// * @/**/
//// */
verify.completions(
{ marker: "", includes: ["import"] },
);
| {
"end_byte": 190,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocImportTagCompletion1.ts"
} |
TypeScript/tests/cases/fourslash/completionListAtBeginningOfFile01.ts_0_183 | /// <reference path='fourslash.ts' />
/////*1*/
////var x = 0, y = 1, z = 2;
////enum E {
//// A, B, C
////}
verify.completions({ marker: "1", includes: ["x", "y", "z", "E"] });
| {
"end_byte": 183,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtBeginningOfFile01.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoJsdocTypedefMissingType.ts_0_168 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: /a.js
/////**
//// * @typedef /**/A
//// */
////var x;
verify.quickInfoAt("", "type A = any");
| {
"end_byte": 168,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsdocTypedefMissingType.ts"
} |
TypeScript/tests/cases/fourslash/extract-method_jsxFragment3.ts_0_779 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: a.tsx
////declare var React: any;
////class Foo extends React.Component<{}, {}> {
//// render() {
//// return (
//// <div>
//// /*a*/<></>/*b*/
//// </div>
//// );
//// }
////}
goTo.file("a.tsx");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_1",
actionDescription: "Extract to method in class 'Foo'",
newContent:
`declare var React: any;
class Foo extends React.Component<{}, {}> {
render() {
return (
<div>
{this./*RENAME*/newMethod()}
</div>
);
}
private newMethod() {
return <></>;
}
}`
});
| {
"end_byte": 779,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method_jsxFragment3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageRestParam2.ts_0_271 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
////function f(a: number, [|...rest |]){
//// a; rest;
////}
////f(1);
////f(2, "s1");
////f(3, false, "s2");
////f(4, "s1", "s2", false, "s4");
verify.rangeAfterCodeFix("...rest: (string | boolean)[]");
| {
"end_byte": 271,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageRestParam2.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteralFromSignature2.ts_0_226 | /// <reference path='fourslash.ts'/>
////declare function f(a: "x"): void;
////declare function f(a: string, b: number): void;
////f("/**/", 0);
verify.completions({ marker: "", exact: [], isNewIdentifierLocation: false });
| {
"end_byte": 226,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralFromSignature2.ts"
} |
TypeScript/tests/cases/fourslash/classSymbolLookup.ts_0_465 | /// <reference path="fourslash.ts" />
// Issue #53247
//// class Foo<T extends Object, C extends {}> {
//// private constructor(value : T, context: C){ }
//// static readonly makeFoo = <C extends {}>(context : C) =>
//// <T extends Object>(value : T) =>
//// new Foo<T, C>(value, context);
//// }
//// const x = Foo.makeFoo<{}>;
//// x({});
verify.encodedSemanticClassificationsLength("2020", 75);
verify.getSemanticDiagnostics([]); | {
"end_byte": 465,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/classSymbolLookup.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageRestParam2JS.ts_0_580 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noImplicitAny: true
// @Filename: important.js
/////** @param {number} a */
////function f(a, [|...rest|]){
//// a; rest;
////}
////f(1);
////f(2, "s1");
////f(3, false, "s2");
////f(4, "s1", "s2", false, "s4");
verify.codeFix({
description: "Infer parameter types from usage",
index: 0,
newFileContent:
`/**
* @param {number} a
* @param {(string | boolean)[]} rest
*/
function f(a, ...rest){
a; rest;
}
f(1);
f(2, "s1");
f(3, false, "s2");
f(4, "s1", "s2", false, "s4");`,
});
| {
"end_byte": 580,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageRestParam2JS.ts"
} |
TypeScript/tests/cases/fourslash/renameDestructuringNestedBindingElement.ts_0_655 | /// <reference path='fourslash.ts' />
////interface MultiRobot {
//// name: string;
//// skills: {
//// [|[|{| "contextRangeIndex": 0|}primary|]: string;|]
//// secondary: string;
//// };
////}
////let multiRobots: MultiRobot[];
////for ([|let { skills: {[|{| "contextRangeIndex": 2|}primary|]: primaryA, secondary: secondaryA } } of multiRobots|]) {
//// console.log(primaryA);
////}
////for ([|let { skills: {[|{| "contextRangeIndex": 4|}primary|], secondary } } of multiRobots|]) {
//// console.log([|primary|]);
////}
const [r0Def, r0, r1Def, r1, r2Def, r2, r3] = test.ranges();
verify.baselineRename([r0, r1, r2, r3]);
| {
"end_byte": 655,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameDestructuringNestedBindingElement.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionSwitchCase7.ts_0_158 | /// <reference path="fourslash.ts" />
////switch (null) {
//// case null:
//// export [|/*start*/default|] 123;
verify.baselineGoToDefinition("start");
| {
"end_byte": 158,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionSwitchCase7.ts"
} |
TypeScript/tests/cases/fourslash/quickfixAddMissingConstraint.ts_0_381 | /// <reference path="fourslash.ts" />
// @Filename: file.ts
////function f<T>(x: T) {
//// const y: `${number}` = x/**/;
////}
goTo.marker("");
verify.codeFix({
index: 0,
description: "Add `extends` constraint.",
newFileContent: {
"/tests/cases/fourslash/file.ts":
`function f<T extends \`$\{number}\`>(x: T) {
const y: \`$\{number}\` = x;
}`
}
});
| {
"end_byte": 381,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickfixAddMissingConstraint.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionNewExpressionTargetNotClass.ts_0_330 | /// <reference path='fourslash.ts' />
////class C2 {
////}
////let /*I*/I: {
//// /*constructSignature*/new(): C2;
////};
////new [|/*invokeExpression1*/I|]();
////let /*symbolDeclaration*/I2: {
////};
////new [|/*invokeExpression2*/I2|]();
verify.baselineGoToDefinition(
"invokeExpression1",
"invokeExpression2",
);
| {
"end_byte": 330,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionNewExpressionTargetNotClass.ts"
} |
TypeScript/tests/cases/fourslash/completionsThisType.ts_0_1123 | /// <reference path="fourslash.ts" />
////class C {
//// "foo bar": number;
//// xyz() {
//// return (/**/)
//// }
////}
////
////function f(this: { x: number }) { /*f*/ }
const preferences: FourSlashInterface.UserPreferences = { includeInsertTextCompletions: true };
verify.completions(
{
marker: "",
includes: [
{ name: "xyz", text: "(method) C.xyz(): any", kind: "method", insertText: "this.xyz", sortText: completion.SortText.SuggestedClassMembers, source: completion.CompletionSource.ThisProperty },
{ name: "foo bar", text: '(property) C["foo bar"]: number', kind: "property", insertText: 'this["foo bar"]', sortText: completion.SortText.SuggestedClassMembers, source: completion.CompletionSource.ThisProperty },
],
isNewIdentifierLocation: true,
preferences,
},
{
marker: "f",
includes: { name: "x", text: "(property) x: number", kind: "property", insertText: "this.x", sortText: completion.SortText.SuggestedClassMembers, source: completion.CompletionSource.ThisProperty },
preferences,
},
);
| {
"end_byte": 1123,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsThisType.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertImportForTriggerReason1.ts_0_312 | /// <reference path='fourslash.ts' />
////import /*a*//*b*/d, * as n from "m";
// Only offer refactor for empty span if explicity requested
goTo.select("a", "b");
verify.not.refactorAvailableForTriggerReason("implicit", "Convert import");
verify.refactorAvailableForTriggerReason("invoked", "Convert import");
| {
"end_byte": 312,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertImportForTriggerReason1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax_all.ts_0_294 | /// <reference path='fourslash.ts' />
// @strict: true
////function f(a: ?number, b: string!) {}
verify.codeFixAll({
fixId: "fixJSDocTypes_plain",
fixAllDescription: "Change all jsdoc-style types to TypeScript",
newFileContent: "function f(a: number | null | undefined, b: string) {}",
})
| {
"end_byte": 294,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax_all.ts"
} |
TypeScript/tests/cases/fourslash/refactorKind_rewriteImport.ts_0_193 | /// <reference path='fourslash.ts' />
//// /*a*/import * as m from "m";/*b*/
goTo.select("a", "b");
verify.refactorKindAvailable("refactor.rewrite",
[
"refactor.rewrite.import.named"
]);
| {
"end_byte": 193,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorKind_rewriteImport.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_named_fromMergedDeclarations.ts_0_766 | /// <reference path="fourslash.ts" />
// @module: esnext
// @Filename: /a.ts
////declare module "m" {
//// export class M {}
////}
// @Filename: /b.ts
////declare module "m" {
//// export interface M {}
////}
// @Filename: /c.ts
/////**/
verify.completions({
marker: "",
includes: {
name: "M",
source: "m",
sourceDisplay: "m",
text: "class M\ninterface M",
kind: "class",
kindModifiers: "export,declare",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences: { includeCompletionsForModuleExports: true },
});
verify.applyCodeActionFromCompletion("", {
name: "M",
source: "m",
description: `Add import from "m"`,
newFileContent: `import { M } from "m";
`,
});
| {
"end_byte": 766,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_named_fromMergedDeclarations.ts"
} |
TypeScript/tests/cases/fourslash/findAllReferencesJSDocFunctionNew.ts_0_190 | ///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: Foo.js
/////** @type {function (/*1*/new: string, string): string} */
////var f;
verify.baselineFindAllReferences('1');
| {
"end_byte": 190,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesJSDocFunctionNew.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction23.ts_0_754 | /// <reference path='fourslash.ts' />
//// const /*a*/foo/*b*/ = /*c*/()/*d*/ /*e*//*f*/ /*g*/=>/*h*/ /*i*/1/*j*/;
goTo.select("a", "b");
verify.not.refactorAvailable("Add or remove braces in an arrow function", "Add braces to arrow function")
goTo.select("c", "d");
verify.refactorAvailable("Add or remove braces in an arrow function", "Add braces to arrow function")
goTo.select("e", "f");
verify.refactorAvailable("Add or remove braces in an arrow function", "Add braces to arrow function")
goTo.select("g", "h");
verify.refactorAvailable("Add or remove braces in an arrow function", "Add braces to arrow function")
goTo.select("i", "j");
verify.not.refactorAvailable("Add or remove braces in an arrow function", "Add braces to arrow function")
| {
"end_byte": 754,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction23.ts"
} |
TypeScript/tests/cases/fourslash/extract-const-callback-function-no-context1.ts_0_518 | /// <reference path='fourslash.ts' />
////declare function fnUnion(fn: ((a: number) => number) | ((a: string) => string)): void
////fnUnion(/*a*/(a: any) => a/*b*/);
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "constant_scope_0",
actionDescription: "Extract to constant in enclosing scope",
newContent:
`declare function fnUnion(fn: ((a: number) => number) | ((a: string) => string)): void
const newLocal = (a: any) => a;
fnUnion(/*RENAME*/newLocal);`
});
| {
"end_byte": 518,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const-callback-function-no-context1.ts"
} |
TypeScript/tests/cases/fourslash/exhaustiveCaseCompletions1.ts_0_2404 | /// <reference path="fourslash.ts" />
// Basic tests
// @newline: LF
//// enum E {
//// A = 0,
//// B = "B",
//// C = "C",
//// }
//// // Mixed union
//// declare const u: E.A | E.B | 1;
//// switch (u) {
//// case/*1*/
//// }
//// // Union enum
//// declare const e: E;
//// switch (e) {
//// case/*2*/
//// }
//// enum F {
//// D = 1 << 0,
//// E = 1 << 1,
//// F = 1 << 2,
//// }
////
//// declare const f: F;
//// switch (f) {
//// case/*3*/
//// }
verify.completions(
{
marker: "1",
isNewIdentifierLocation: false,
includes: [
{
name: "case E.A: ...",
source: completion.CompletionSource.SwitchCases,
sortText: completion.SortText.GlobalsOrKeywords,
insertText:
`case E.A:
case E.B:
case 1:`,
},
],
preferences: {
includeCompletionsWithInsertText: true,
},
},
{
marker: "2",
isNewIdentifierLocation: false,
includes: [
{
name: "case E.A: ...",
source: completion.CompletionSource.SwitchCases,
sortText: completion.SortText.GlobalsOrKeywords,
insertText:
`case E.A:
case E.B:
case E.C:`,
},
],
preferences: {
includeCompletionsWithInsertText: true,
},
},
{
marker: "3",
isNewIdentifierLocation: false,
includes: [
{
name: "case F.D: ...",
source: completion.CompletionSource.SwitchCases,
sortText: completion.SortText.GlobalsOrKeywords,
insertText:
`case F.D:
case F.E:
case F.F:`,
},
],
preferences: {
includeCompletionsWithInsertText: true,
},
},
{
marker: "3",
isNewIdentifierLocation: false,
includes: [
{
name: "case F.D: ...",
source: completion.CompletionSource.SwitchCases,
sortText: completion.SortText.GlobalsOrKeywords,
isSnippet: true,
insertText:
`case F.D:$1
case F.E:$2
case F.F:$3`,
},
],
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: true,
},
},
); | {
"end_byte": 2404,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/exhaustiveCaseCompletions1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_prefix.ts_0_373 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
/////**
//// * @param a
//// * @param b
//// */
////function f(a, b) {
//// const x = a;
////}
verify.codeFix({
description: "Prefix 'b' with an underscore",
index: 1,
newFileContent:
`/**
* @param a
* @param _b
*/
function f(a, _b) {
const x = a;
}`,
});
| {
"end_byte": 373,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_prefix.ts"
} |
TypeScript/tests/cases/fourslash/addMemberToInterface.ts_0_317 | /// <reference path="fourslash.ts" />
////
//// namespace /*check*/Mod{
//// }
////
//// interface MyInterface {
//// /*insert*/
//// }
edit.disableFormatting();
verify.quickInfoAt("check", "namespace Mod");
goTo.marker('insert');
edit.insert("x: number;\n");
verify.quickInfoAt("check", "namespace Mod");
| {
"end_byte": 317,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/addMemberToInterface.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesSwitchCaseDefault.ts_0_451 | /// <reference path='fourslash.ts' />
////[|switch|] (10) {
//// [|case|] 1:
//// [|case|] 2:
//// [|case|] 4:
//// [|case|] 8:
//// foo: switch (20) {
//// case 1:
//// case 2:
//// break;
//// default:
//// break foo;
//// }
//// [|case|] 0xBEEF:
//// [|default|]:
//// [|break|];
//// [|case|] 16:
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 451,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesSwitchCaseDefault.ts"
} |
TypeScript/tests/cases/fourslash/debuggerStatementIndent.ts_0_143 | /// <reference path='fourslash.ts' />
//// if (false) {
//// debugger;
//// /**/
goTo.marker();
edit.insert('}');
verify.indentationIs(0);
| {
"end_byte": 143,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/debuggerStatementIndent.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_importType8.ts_0_415 | /// <reference path="fourslash.ts" />
// @module: es2015
// @verbatimModuleSyntax: true
// @Filename: /exports.ts
//// export interface SomeInterface {}
//// export class SomePig {}
// @Filename: /a.ts
//// import type { SomeInterface, SomePig } from "./exports.js";
//// new SomePig/**/
goTo.marker("");
verify.importFixAtPosition([
`import { SomePig, type SomeInterface } from "./exports.js";
new SomePig`]);
| {
"end_byte": 415,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_importType8.ts"
} |
TypeScript/tests/cases/fourslash/qualifyModuleTypeNames.ts_0_193 | /// <reference path='fourslash.ts' />
////module m { export class c { } };
////function x(arg: m.c) { return arg; }
////x(/**/
verify.signatureHelp({ marker: "", text: "x(arg: m.c): m.c" });
| {
"end_byte": 193,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/qualifyModuleTypeNames.ts"
} |
TypeScript/tests/cases/fourslash/completionsImportDeclarationAttributesErrorModuleSpecifier1.ts_0_314 | /// <reference path='fourslash.ts' />
// @strict: true
// @filename: global.d.ts
//// interface ImportAttributes {
//// type: "json";
//// }
// @filename: index.ts
//// import * as ns from () with { type: "/**/" };
verify.completions({
marker: "",
exact: ["json"],
isNewIdentifierLocation: false,
});
| {
"end_byte": 314,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImportDeclarationAttributesErrorModuleSpecifier1.ts"
} |
TypeScript/tests/cases/fourslash/restArgType.ts_0_2150 | /// <reference path="fourslash.ts"/>
////class Test {
//// private _priv(.../*1*/restArgs) {
//// }
//// public pub(.../*2*/restArgs) {
//// var x = restArgs[2];
//// }
////}
////var x: (...y: string[]) => void = function (.../*3*/y) {
//// var t = y;
////};
////function foo(x: (...y: string[]) => void ) { }
////foo((.../*4*/y1) => {
//// var t = y;
////});
////foo((/*5*/y2) => {
//// var t = y;
////});
////var t1 :(a1: string, a2: string) => void = (.../*t1*/f1) => { } // f1 => any[];
////var t2: (a1: string, ...a2: string[]) => void = (.../*t2*/f1) => { } // f1 => any[];
////var t3: (a1: number, a2: boolean, ...c: string[]) => void = (/*t31*/f1, .../*t32*/f2) => { }; // f1 => number, f2 => any[]
////var t4: (...a1: string[]) => void = (.../*t4*/f1) => { }; // f1 => string[]
////var t5: (...a1: string[]) => void = (/*t5*/f1) => { }; // f1 => string
////var t6: (...a1: string[]) => void = (/*t61*/f1, .../*t62*/f2) => { }; // f1 => string, f2 => string[]
////var t7: (...a1: string[]) => void = (/*t71*/f1, /*t72*/f2, /*t73*/f3) => { }; // fa => string, f2 => string, f3 => string
////// Explicit type annotation
////var t8: (...a1: string[]) => void = (/*t8*/f1: number[]) => { };
////// Explicit initialization value
////var t9: (a1: string[], a2: string[]) => void = (/*t91*/f1 = 4, /*t92*/f2 = [false, true]) => { };
verify.quickInfos({
1: "(parameter) restArgs: any[]",
2: "(parameter) restArgs: any[]",
3: "(parameter) y: string[]",
4: "(parameter) y1: string[]",
5: "(parameter) y2: string",
t1: "(parameter) f1: [a1: string, a2: string]",
t2: "(parameter) f1: [a1: string, ...a2: string[]]",
t31: "(parameter) f1: number",
t32: "(parameter) f2: [a2: boolean, ...c: string[]]",
t4: "(parameter) f1: string[]",
t5: "(parameter) f1: string",
t61: "(parameter) f1: string",
t62: "(parameter) f2: string[]",
t71: "(parameter) f1: string",
t72: "(parameter) f2: string",
t73: "(parameter) f3: string",
t8: "(parameter) f1: number[]",
t91: "(parameter) f1: string[]",
t92: "(parameter) f2: string[]"
});
| {
"end_byte": 2150,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/restArgType.ts"
} |
TypeScript/tests/cases/fourslash/referencesForOverrides.ts_0_1640 | /// <reference path='fourslash.ts'/>
////module FindRef3 {
//// module SimpleClassTest {
//// export class Foo {
//// public /*foo*/foo(): void {
//// }
//// }
//// export class Bar extends Foo {
//// public foo(): void {
//// }
//// }
//// }
////
//// module SimpleInterfaceTest {
//// export interface IFoo {
//// /*ifoo*/ifoo(): void;
//// }
//// export interface IBar extends IFoo {
//// ifoo(): void;
//// }
//// }
////
//// module SimpleClassInterfaceTest {
//// export interface IFoo {
//// /*icfoo*/icfoo(): void;
//// }
//// export class Bar implements IFoo {
//// public icfoo(): void {
//// }
//// }
//// }
////
//// module Test {
//// export interface IBase {
//// /*field*/field: string;
//// /*method*/method(): void;
//// }
////
//// export interface IBlah extends IBase {
//// field: string;
//// }
////
//// export interface IBlah2 extends IBlah {
//// field: string;
//// }
////
//// export interface IDerived extends IBlah2 {
//// method(): void;
//// }
////
//// export class Bar implements IDerived {
//// public field: string;
//// public method(): void { }
//// }
////
//// export class BarBlah extends Bar {
//// public field: string;
//// }
//// }
////
//// function test() {
//// var x = new SimpleClassTest.Bar();
//// x.foo();
////
//// var y: SimpleInterfaceTest.IBar = null;
//// y.ifoo();
////
//// var w: SimpleClassInterfaceTest.Bar = null;
//// w.icfoo();
////
//// var z = new Test.BarBlah();
//// z.field = "";
//// z.method();
//// }
////}
verify.baselineFindAllReferences('foo', 'ifoo', 'icfoo', 'field', 'method')
| {
"end_byte": 1640,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForOverrides.ts"
} |
TypeScript/tests/cases/fourslash/completionListInClassStaticBlocks.ts_0_688 | /// <reference path="fourslash.ts" />
// @target: esnext
////class Foo {
//// static #a = 1;
//// static a() {
//// this./*1*/
//// }
//// static b() {
//// Foo./*2*/
//// }
//// static {
//// this./*3*/
//// }
//// static {
//// Foo./*4*/
//// }
////}
verify.completions({
marker: ["1", "2", "3", "4"],
exact: completion.functionMembersPlus([
{ name: "#a", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "a", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "b", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "prototype" }
])
});
| {
"end_byte": 688,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInClassStaticBlocks.ts"
} |
TypeScript/tests/cases/fourslash/completionsOverridingProperties3.ts_0_507 | /// <reference path="fourslash.ts" />
////interface I {
//// prop: string;
////}
////class C implements I {
//// public pr/**/: string | number;
////}
verify.completions({
marker: "",
includes: [
{ name: "prop", isSnippet: undefined, insertText: undefined }
],
isNewIdentifierLocation: true,
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: true,
includeCompletionsWithClassMemberSnippets: true,
}
});
| {
"end_byte": 507,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingProperties3.ts"
} |
TypeScript/tests/cases/fourslash/jsDocTypedefQuickInfo1.ts_3_703 | / <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: jsDocTypedef1.js
//// /**
//// * @typedef {Object} Opts
//// * @property {string} x
//// * @property {string=} y
//// * @property {string} [z]
//// * @property {string} [w="hi"]
//// *
//// * @param {Opts} opts
//// */
//// function foo(/*1*/opts) {
//// opts.x;
//// }
//// foo({x: 'abc'});
//// /**
//// * @typedef {object} Opts1
//// * @property {string} x
//// * @property {string=} y
//// * @property {string} [z]
//// * @property {string} [w="hi"]
//// *
//// * @param {Opts1} opts
//// */
//// function foo1(/*2*/opts1) {
//// opts1.x;
//// }
//// foo1({x: 'abc'});
verify.baselineQuickInfo();
| {
"end_byte": 703,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocTypedefQuickInfo1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageAddition.ts_0_239 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
//// function foo([|a, m |]) {
//// return a + m
//// }
verify.rangeAfterCodeFix("a: any, m: any", /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, /*index*/0);
| {
"end_byte": 239,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageAddition.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddOptionalParam16.ts_0_521 | /// <reference path="fourslash.ts" />
////function f(a: string): string;
////function f(a: string, b?: number): string;
////function f(a: string, b?: number): string {
//// return "";
////}
////f("", "", 1);
verify.codeFix({
description: [ts.Diagnostics.Add_optional_parameter_to_0.message, "f"],
index: 1,
newFileContent:
`function f(a: string): string;
function f(a: string, p0?: string, b?: number): string;
function f(a: string, p0?: string, b?: number): string {
return "";
}
f("", "", 1);`
});
| {
"end_byte": 521,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddOptionalParam16.ts"
} |
TypeScript/tests/cases/fourslash/tsxFindAllReferences10.ts_0_1105 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// interface ClickableProps {
//// children?: string;
//// className?: string;
//// }
//// interface ButtonProps extends ClickableProps {
//// /*1*/onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
//// }
//// interface LinkProps extends ClickableProps {
//// goTo: string;
//// }
//// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
//// declare function MainButton(linkProps: LinkProps): JSX.Element;
//// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
//// let opt = <MainButton />;
//// let opt = <MainButton children="chidlren" />;
//// let opt = <MainButton onClick={()=>{}} />;
//// let opt = <MainButton onClick={()=>{}} ignore-prop />;
//// let opt = <MainButton goTo="goTo" />;
//// let opt = <MainButton wrong />;
verify.baselineFindAllReferences('1')
| {
"end_byte": 1105,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxFindAllReferences10.ts"
} |
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction1.ts_0_279 | /// <reference path='fourslash.ts' />
// @target: es2015
////async function fn(): number {}
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Replace_0_with_Promise_1.message, "number", "number"],
newFileContent: `async function fn(): Promise<number> {}`
});
| {
"end_byte": 279,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction1.ts"
} |
TypeScript/tests/cases/fourslash/renameFromNodeModulesDep4.ts_0_1912 | /// <reference path="fourslash.ts" />
// @Filename: /index.ts
////import hljs from "highlight.js/lib/core"
////import { h } from "highlight.js/lib/core";
////import { /*notOk*/h as hh } from "highlight.js/lib/core";
/////*ok*/[|hljs|];
/////*okWithAlias*/[|h|];
/////*ok2*/[|hh|];
// @Filename: /node_modules/highlight.js/lib/core.d.ts
////declare const hljs: { registerLanguage(s: string): void };
////export default hljs;
////export const h: string;
// @Filename: /tsconfig.json
////{}
const [ hljs, h, hh ] = test.ranges();
goTo.marker("ok");
verify.renameInfoSucceeded(
undefined,
undefined,
undefined,
undefined,
undefined,
hljs,
{ providePrefixAndSuffixTextForRename: true });
verify.renameInfoSucceeded(
undefined,
undefined,
undefined,
undefined,
undefined,
hljs,
{ providePrefixAndSuffixTextForRename: false });
goTo.marker("ok2");
verify.renameInfoSucceeded(
undefined,
undefined,
undefined,
undefined,
undefined,
hh,
{ providePrefixAndSuffixTextForRename: true });
verify.renameInfoSucceeded(
undefined,
undefined,
undefined,
undefined,
undefined,
hh,
{ providePrefixAndSuffixTextForRename: false });
goTo.marker("notOk");
verify.renameInfoFailed(
"You cannot rename elements that are defined in a 'node_modules' folder.",
{ providePrefixAndSuffixTextForRename: true });
verify.renameInfoFailed(
"You cannot rename elements that are defined in a 'node_modules' folder.",
{ providePrefixAndSuffixTextForRename: false });
goTo.marker("okWithAlias");
verify.renameInfoSucceeded(
undefined,
undefined,
undefined,
undefined,
undefined,
h,
{ providePrefixAndSuffixTextForRename: true });
verify.renameInfoFailed(
"You cannot rename elements that are defined in a 'node_modules' folder.",
{ providePrefixAndSuffixTextForRename: false });
| {
"end_byte": 1912,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameFromNodeModulesDep4.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements8.ts_0_448 | /// <reference path="fourslash.ts" />
// @noUnusedLocals: true
// @noUnusedParameters: true
////function foo() {
//// return { a: 1 };
////}
////[|function bar() {
//// const { a } = foo(),
//// b = 1;
//// return b;
////}|]
verify.codeFix({
index: 0,
description: ts.Diagnostics.Remove_unused_destructuring_declaration.message,
newRangeContent:
`function bar() {
const b = 1;
foo();
return b;
}`,
});
| {
"end_byte": 448,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements8.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixInferEndingPreference.ts_0_356 | /// <reference path="fourslash.ts" />
// @module: esnext
// @moduleResolution: bundler
// @Filename: /a.mts
//// export {};
// @Filename: /b.ts
//// export {};
// @Filename: /c.ts
//// export const c = 0;
// @Filename: /main.ts
//// import {} from "./a.mjs";
//// import {} from "./b";
////
//// c/**/;
verify.importFixModuleSpecifiers("", ["./c"]);
| {
"end_byte": 356,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixInferEndingPreference.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts_0_1253 | /// <reference path='fourslash.ts' />
// Should give completions for modules referenced via baseUrl and paths compiler options with wildcards
// @Filename: tsconfig.json
//// {
//// "compilerOptions": {
//// "baseUrl": "./modules",
//// "paths": {
//// "*": [
//// "prefix/0*/suffix.ts",
//// "prefix-only/*",
//// "*/suffix-only.ts"
//// ]
//// }
//// }
//// }
// @Filename: tests/test0.ts
//// import * as foo1 from "f/*import_as0*/
//// import foo2 = require("f/*import_equals0*/
//// var foo3 = require("f/*require0*/
//// import * as foo1 from "f/*import_as1*/
//// import foo2 = require("f/*import_equals1*/
//// var foo3 = require("f/*require1*/
//// import * as foo1 from "f/*import_as2*/
//// import foo2 = require("f/*import_equals2*/
//// var foo3 = require("f/*require2*/
// @Filename: modules/prefix/00test/suffix.ts
//// export var x = 5;
// @Filename: modules/prefix-only/1test.ts
//// export var y = 5;
// @Filename: modules/2test/suffix-only.ts
//// export var z = 5;
verify.completions({
marker: test.markers(),
exact: ["2test", "prefix", "prefix-only", "0test", "1test"],
isNewIdentifierLocation: true,
});
| {
"end_byte": 1253,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts"
} |
TypeScript/tests/cases/fourslash/ambientShorthandGotoDefinition.ts_0_859 | /// <reference path='fourslash.ts' />
// @Filename: declarations.d.ts
////declare module /*module*/"jquery"
// @Filename: user.ts
///////<reference path="declarations.d.ts"/>
////import [|/*importFoo*/foo|], {bar} from "jquery";
////import * as [|/*importBaz*/baz|] from "jquery";
////import [|/*importBang*/bang|] = require("jquery");
////[|foo/*useFoo*/|]([|bar/*useBar*/|], [|baz/*useBaz*/|], [|bang/*useBang*/|]);
verify.quickInfoAt("useFoo", "(alias) module \"jquery\"\nimport foo");
verify.quickInfoAt("useBar", "(alias) module \"jquery\"\nimport bar");
verify.quickInfoAt("useBaz", "(alias) module \"jquery\"\nimport baz");
verify.quickInfoAt("useBang", "(alias) module \"jquery\"\nimport bang = require(\"jquery\")");
verify.baselineGoToDefinition(
"useFoo", "importFoo",
"useBar",
"useBaz", "importBaz",
"useBang", "importBang"
); | {
"end_byte": 859,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/ambientShorthandGotoDefinition.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts_0_2393 | /// <reference path='fourslash.ts' />
// @lib: es2017
////interface I<Species> {
//// [Symbol.hasInstance](o: any): boolean;
//// [Symbol.isConcatSpreadable]: boolean;
//// [Symbol.iterator](): any;
//// [Symbol.match]: boolean;
//// [Symbol.replace](...args);
//// [Symbol.search](str: string): number;
//// [Symbol.species](): Species;
//// [Symbol.split](str: string, limit?: number): string[];
//// [Symbol.toPrimitive](hint: "number"): number;
//// [Symbol.toPrimitive](hint: "default"): number;
//// [Symbol.toPrimitive](hint: "string"): string;
//// [Symbol.toStringTag]: string;
//// [Symbol.unscopables]: any;
////}
////class C implements I<number> {}
verify.codeFix({
index: 0,
description: "Implement interface 'I<number>'",
newFileContent:
`interface I<Species> {
[Symbol.hasInstance](o: any): boolean;
[Symbol.isConcatSpreadable]: boolean;
[Symbol.iterator](): any;
[Symbol.match]: boolean;
[Symbol.replace](...args);
[Symbol.search](str: string): number;
[Symbol.species](): Species;
[Symbol.split](str: string, limit?: number): string[];
[Symbol.toPrimitive](hint: "number"): number;
[Symbol.toPrimitive](hint: "default"): number;
[Symbol.toPrimitive](hint: "string"): string;
[Symbol.toStringTag]: string;
[Symbol.unscopables]: any;
}
class C implements I<number> {
[Symbol.hasInstance](o: any): boolean {
throw new Error("Method not implemented.");
}
[Symbol.isConcatSpreadable]: boolean;
[Symbol.iterator]() {
throw new Error("Method not implemented.");
}
[Symbol.match]: boolean;
[Symbol.replace](...args: any[]) {
throw new Error("Method not implemented.");
}
[Symbol.search](str: string): number {
throw new Error("Method not implemented.");
}
[Symbol.species](): number {
throw new Error("Method not implemented.");
}
[Symbol.split](str: string, limit?: number): string[] {
throw new Error("Method not implemented.");
}
[Symbol.toPrimitive](hint: "number"): number;
[Symbol.toPrimitive](hint: "default"): number;
[Symbol.toPrimitive](hint: "string"): string;
[Symbol.toPrimitive](hint: unknown): string | number {
throw new Error("Method not implemented.");
}
[Symbol.toStringTag]: string;
[Symbol.unscopables]: any;
}`,
});
| {
"end_byte": 2393,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts"
} |
TypeScript/tests/cases/fourslash/renameModuleToVar.ts_0_289 | /// <reference path="./fourslash.ts"/>
////interface IMod {
//// y: number;
////}
////declare module/**/ X: IMod;// {
////// export var y: numb;
////var y: number;
////module Y {
//// var z = y + 5;
////}
goTo.marker();
edit.backspace(6);
edit.insert("var");
verify.noErrors();
| {
"end_byte": 289,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameModuleToVar.ts"
} |
TypeScript/tests/cases/fourslash/completionListInExportClause01.ts_0_772 | /// <reference path='fourslash.ts'/>
// @Filename: m1.ts
////export var foo: number = 1;
////export function bar() { return 10; }
////export function baz() { return 10; }
// @Filename: m2.ts
////export {/*1*/, /*2*/ from "./m1"
////export {/*3*/} from "./m1"
////export {foo,/*4*/ from "./m1"
////export {bar as /*5*/, /*6*/ from "./m1"
////export {foo, bar, baz as b,/*7*/} from "./m1"
const type = { name: "type", sortText: completion.SortText.GlobalsOrKeywords };
verify.completions(
{ marker: ["1", "2", "3"], exact: ["bar", "baz", "foo", type] },
{ marker: "4", exact: ["bar", "baz", type] },
{ marker: "5", exact: undefined, isNewIdentifierLocation: true },
{ marker: "6", exact: ["baz", "foo", type] },
{ marker: "7", exact: undefined },
);
| {
"end_byte": 772,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInExportClause01.ts"
} |
TypeScript/tests/cases/fourslash/jsdocExtendsTagCompletion.ts_0_166 | ///<reference path="fourslash.ts" />
/////** @extends {/**/} */
////class A {}
verify.completions(
{ marker: "", exact: completion.globalTypesPlus(["A"]) },
);
| {
"end_byte": 166,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocExtendsTagCompletion.ts"
} |
TypeScript/tests/cases/fourslash/typeOfKeywordCompletion.ts_0_193 | /// <reference path="fourslash.ts" />
////export type A = typ/**/
verify.completions({
marker: "",
includes: [{ name: "typeof", sortText: completion.SortText.GlobalsOrKeywords }]
});
| {
"end_byte": 193,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/typeOfKeywordCompletion.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts_0_440 | /// <reference path='fourslash.ts' />
////interface I {
//// x: number[];
//// y: Array<number>;
//// z: [number, string, I];
////}
////
////class C implements I {[| |]}
verify.codeFix({
description: "Implement interface 'I'",
newFileContent:
`interface I {
x: number[];
y: Array<number>;
z: [number, string, I];
}
class C implements I {
x: number[];
y: number[];
z: [number, string, I];
}`,
});
| {
"end_byte": 440,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpelling4.ts_0_156 | /// <reference path='fourslash.ts' />
//// export declare const despite: { the: any };
////
//// [|dispite.the|]
verify.rangeAfterCodeFix(`despite.the`);
| {
"end_byte": 156,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpelling4.ts"
} |
TypeScript/tests/cases/fourslash/formatNoSpaceBetweenClosingParenAndTemplateString.ts_0_193 | /// <reference path="fourslash.ts"/>
//// foo() `abc`;
//// bar()`def`;
//// baz()`a${x}b`;
format.document();
verify.currentFileContentIs(
`foo()\`abc\`;
bar()\`def\`;
baz()\`a\${x}b\`;`
);
| {
"end_byte": 193,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatNoSpaceBetweenClosingParenAndTemplateString.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceMappedTypeIndirectKeys.ts_0_589 | /// <reference path='fourslash.ts' />
////type Base = { ax: number; ay: string };
////type BaseKeys = keyof Base;
////type MappedIndirect = { [K in BaseKeys]: boolean };
////class MappedImpl implements MappedIndirect { }
// https://github.com/microsoft/TypeScript/issues/49811
verify.codeFix({
description: "Implement interface 'MappedIndirect'",
newFileContent:
`type Base = { ax: number; ay: string };
type BaseKeys = keyof Base;
type MappedIndirect = { [K in BaseKeys]: boolean };
class MappedImpl implements MappedIndirect {
ax: boolean;
ay: boolean;
}`,
});
| {
"end_byte": 589,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceMappedTypeIndirectKeys.ts"
} |
TypeScript/tests/cases/fourslash/callHierarchyFile.ts_0_132 | /// <reference path="fourslash.ts" />
//// foo();
//// function /**/foo() {
//// }
goTo.marker();
verify.baselineCallHierarchy();
| {
"end_byte": 132,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/callHierarchyFile.ts"
} |
TypeScript/tests/cases/fourslash/codeFixRenameUnmatchedParameter4.ts_0_376 | /// <reference path='fourslash.ts' />
// @filename: /a.ts
/////**
//// * @param {string} y
//// * @returns
//// */
////export const foo = (x: string) => x;
verify.codeFix({
description: [ts.Diagnostics.Rename_param_tag_name_0_to_1.message, "y", "x"],
index: 1,
newFileContent:
`/**
* @param {string} x
* @returns
*/
export const foo = (x: string) => x;`,
});
| {
"end_byte": 376,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRenameUnmatchedParameter4.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterface_typeInOtherFile.ts_0_481 | /// <reference path='fourslash.ts' />
// @Filename: /I.ts
////export interface J {}
////export interface I {
//// x: J;
//// m(): J;
////}
// @Filename: /C.ts
////import { I } from "./I";
////export class C implements I {}
goTo.file("/C.ts");
verify.codeFix({
description: "Implement interface 'I'",
newFileContent:
`import { I, J } from "./I";
export class C implements I {
x: J;
m(): J {
throw new Error("Method not implemented.");
}
}`,
});
| {
"end_byte": 481,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterface_typeInOtherFile.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_expandSelectionRange15.ts_0_416 | /// <reference path='fourslash.ts' />
//@Filename: /bar.ts
////const a = 1;
// @Filename: /a.ts
////let [|message: string, count: number = 10, functional|]: boolean = true;
verify.moveToFile({
newFileContents: {
"/a.ts":
``,
"/bar.ts":
`const a = 1;
let message: string, count: number = 10, functional: boolean = true;
`,
},
interactiveRefactorArguments: { targetFile: "/bar.ts" }
}); | {
"end_byte": 416,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_expandSelectionRange15.ts"
} |
TypeScript/tests/cases/fourslash/outliningSpansForArguments.ts_0_317 | /// <reference path="fourslash.ts"/>
//// console.log(123, 456)l;
//// console.log(
//// );
//// console.log[|(
//// 123, 456
//// )|];
//// console.log[|(
//// 123,
//// 456
//// )|];
//// () =>[| console.log[|(
//// 123,
//// 456
//// )|]|];
verify.outliningSpansInCurrentFile(test.ranges());
| {
"end_byte": 317,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/outliningSpansForArguments.ts"
} |
TypeScript/tests/cases/fourslash/completionsAtIncompleteObjectLiteralProperty.ts_0_345 | /// <reference path='fourslash.ts' />
// @noLib: true
////f({
//// a/**/
//// xyz: ``,
////});
////declare function f(options: { abc?: number, xyz?: string }): void;
verify.completions({
marker: "",
exact: [{ name: 'abc', kind: 'property', kindModifiers: 'declare,optional', sortText: completion.SortText.OptionalMember }],
});
| {
"end_byte": 345,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsAtIncompleteObjectLiteralProperty.ts"
} |
TypeScript/tests/cases/fourslash/semicolonFormattingInsideAComment.ts_0_191 | /// <reference path='fourslash.ts' />
//// ///**/
goTo.marker();
edit.insert(';');
// Semicolon Formating should not be triggered inside comments
verify.currentLineContentIs(' //;');
| {
"end_byte": 191,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semicolonFormattingInsideAComment.ts"
} |
TypeScript/tests/cases/fourslash/completionListForStringUnion.ts_0_616 | /// <reference path='fourslash.ts' />
//// type A = 'foo' | 'bar' | 'baz';
//// type B<T extends A> = {};
//// type C = B<'foo' | '[|/**/|]'>
const replacementSpan = test.ranges()[0]
verify.completions({ marker: "", exact: [
{ name: "bar", replacementSpan },
{ name: "baz", replacementSpan }
] });
edit.insert("b");
replacementSpan.end++
verify.completions({ exact: [
{ name: "bar", replacementSpan },
{ name: "baz", replacementSpan }
] });
edit.insert("ar");
replacementSpan.end += 2
verify.completions({ exact: [
{ name: "bar", replacementSpan },
{ name: "baz", replacementSpan }
] });
| {
"end_byte": 616,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListForStringUnion.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_typeImport1.ts_0_344 | /// <reference path="fourslash.ts" />
// @filename: /a.ts
////export interface A {
//// x: number;
////}
// @Filename: /b.ts
////import type { A } from "./a";
////[|function f(a: A) {}|]
verify.moveToNewFile({
newFileContents: {
"/b.ts": "",
"/f.ts":
`import type { A } from "./a";
function f(a: A) { }
`,
},
});
| {
"end_byte": 344,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_typeImport1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUndeclaredAcrossFiles3.ts_0_474 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @Filename: f3.ts
//// import { C } from "./f1";
//// import { D } from "./f2";
//// const c = new C();
//// c.m0(new D());
// @Filename: f2.ts
//// export class D { }
// @Filename: f1.ts
//// export class C {[|
//// |]x: number;
//// }
verify.getAndApplyCodeFix(/*errorCode*/ undefined, 0);
verify.rangeIs(`
m0(arg0: D) {
throw new Error("Method not implemented.");
}
`); | {
"end_byte": 474,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUndeclaredAcrossFiles3.ts"
} |
TypeScript/tests/cases/fourslash/completionListBuilderLocations_Modules.ts_0_284 | /// <reference path='fourslash.ts' />
////module A/*moduleName1*/
////module A./*moduleName2*/
verify.completions(
{ marker: "moduleName1", exact: completion.globals, isNewIdentifierLocation: true },
{ marker: "moduleName2", exact: [], isNewIdentifierLocation: true },
);
| {
"end_byte": 284,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListBuilderLocations_Modules.ts"
} |
TypeScript/tests/cases/fourslash/autoImportNoPackageJson_nodenext.ts_0_270 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @Filename: /node_modules/lit/index.d.cts
//// export declare function customElement(name: string): any;
// @Filename: /a.ts
//// customElement/**/
verify.importFixModuleSpecifiers("", ["lit/index.cjs"]);
| {
"end_byte": 270,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportNoPackageJson_nodenext.ts"
} |
TypeScript/tests/cases/fourslash/renameStringPropertyNames.ts_0_295 | /// <reference path='fourslash.ts' />
////var o = {
//// [|[|{| "contextRangeIndex": 0 |}prop|]: 0|]
////};
////
////o = {
//// [|"[|{| "contextRangeIndex": 2 |}prop|]": 1|]
////};
////
////o["[|prop|]"];
////o['[|prop|]'];
////o.[|prop|];
verify.baselineRenameAtRangesWithText("prop");
| {
"end_byte": 295,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameStringPropertyNames.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpJSMissingPropertyAccess.ts_0_151 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @Filename: test.js
////foo.filter(/**/)
verify.baselineSignatureHelp()
| {
"end_byte": 151,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpJSMissingPropertyAccess.ts"
} |
TypeScript/tests/cases/fourslash/completionListInObjectBindingPattern01.ts_0_233 | /// <reference path='fourslash.ts'/>
////interface I {
//// property1: number;
//// property2: string;
////}
////
////var foo: I;
////var { /**/ } = foo;
verify.completions({ marker: "", exact: ["property1", "property2"] });
| {
"end_byte": 233,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectBindingPattern01.ts"
} |
TypeScript/tests/cases/fourslash/codeFixOverrideModifier14.ts_0_330 | /// <reference path='fourslash.ts' />
// @noImplicitOverride: true
////class A {
//// protected async foo() {}
////}
////
////class B extends A {
//// [|protected async foo() {}|]
////}
verify.codeFix({
description: "Add 'override' modifier",
newRangeContent: "protected override async foo() {}",
index: 0
})
| {
"end_byte": 330,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixOverrideModifier14.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType2.ts_0_863 | /// <reference path="fourslash.ts" />
////type ListenerTemplate<T, S extends string, I extends string = "${1}"> = {
//// [K in keyof T as K extends string
//// ? S extends `${infer F}${I}${infer R}` ? `${F}${K}${R}` : K : K]
//// : (listener: (payload: T[K]) => void) => void;
////};
////type ListenActionable<E> = ListenerTemplate<E, "add*Listener" | "remove*Listener", "*">;
////type ClickEventSupport = ListenActionable<{ Click: 'some-click-event-payload' }>;
////
////[|class C implements ClickEventSupport { }|]
verify.codeFix({
description: "Implement interface 'ClickEventSupport'",
newRangeContent:
`class C implements ClickEventSupport {
addClickListener: (listener: (payload: "some-click-event-payload") => void) => void;
removeClickListener: (listener: (payload: "some-click-event-payload") => void) => void;
}`,
});
| {
"end_byte": 863,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType2.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringAssignmentForOfArrayBindingPatternDefaultValues.ts_0_3499 | /// <reference path='fourslash.ts' />
////declare var console: {
//// log(msg: any): void;
////}
////type Robot = [number, string, string];
////type MultiSkilledRobot = [string, [string, string]];
////let robotA: Robot = [1, "mower", "mowing"];
////let robotB: Robot = [2, "trimmer", "trimming"];
////let robots = [robotA, robotB];
////function getRobots() {
//// return robots;
////}
////let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]];
////let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]];
////let multiRobots = [multiRobotA, multiRobotB];
////function getMultiRobots() {
//// return multiRobots;
////}
////let nameA: string, primarySkillA: string, secondarySkillA: string;
////let numberB: number, nameB: string;
////let numberA2: number, nameA2: string, skillA2: string, nameMA: string;
////let numberA3: number, robotAInfo: (number | string)[], multiRobotAInfo: (string | [string, string])[];
////for ([, nameA = "noName"] of robots) {
//// console.log(nameA);
////}
////for ([, nameA = "noName"] of getRobots()) {
//// console.log(nameA);
////}
////for ([, nameA = "noName"] of [robotA, robotB]) {
//// console.log(nameA);
////}
////for ([, [
//// primarySkillA = "primary",
//// secondarySkillA = "secondary"
////] = ["skill1", "skill2"]] of multiRobots) {
//// console.log(primarySkillA);
////}
////for ([, [
//// primarySkillA = "primary",
//// secondarySkillA = "secondary"
////] = ["skill1", "skill2"]] of getMultiRobots()) {
//// console.log(primarySkillA);
////}
////for ([, [
//// primarySkillA = "primary",
//// secondarySkillA = "secondary"
////] = ["skill1", "skill2"]] of [multiRobotA, multiRobotB]) {
//// console.log(primarySkillA);
////}
////for ([numberB = -1] of robots) {
//// console.log(numberB);
////}
////for ([numberB = -1] of getRobots()) {
//// console.log(numberB);
////}
////for ([numberB = -1] of [robotA, robotB]) {
//// console.log(numberB);
////}
////for ([nameB = "noName"] of multiRobots) {
//// console.log(nameB);
////}
////for ([nameB = "noName"] of getMultiRobots()) {
//// console.log(nameB);
////}
////for ([nameB = "noName"] of [multiRobotA, multiRobotB]) {
//// console.log(nameB);
////}
////for ([numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of robots) {
//// console.log(nameA2);
////}
////for ([numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of getRobots()) {
//// console.log(nameA2);
////}
////for ([numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of [robotA, robotB]) {
//// console.log(nameA2);
////}
////for ([nameMA = "noName", [
//// primarySkillA = "primary",
//// secondarySkillA = "secondary"
////] = ["skill1", "skill2"]] of multiRobots) {
//// console.log(nameMA);
////}
////for ([nameMA = "noName", [
//// primarySkillA = "primary",
//// secondarySkillA = "secondary"
////] = ["skill1", "skill2"]] of getMultiRobots()) {
//// console.log(nameMA);
////}
////for ([nameMA = "noName", [
//// primarySkillA = "primary",
//// secondarySkillA = "secondary"
////] = ["skill1", "skill2"]] of [multiRobotA, multiRobotB]) {
//// console.log(nameMA);
////}
////for ([numberA3 = -1, ...robotAInfo] of robots) {
//// console.log(numberA3);
////}
////for ([numberA3 = -1, ...robotAInfo] of getRobots()) {
//// console.log(numberA3);
////}
////for ([numberA3 = -1, ...robotAInfo] of [robotA, robotB]) {
//// console.log(numberA3);
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 3499,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringAssignmentForOfArrayBindingPatternDefaultValues.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingConstInForInLoop2.ts_0_271 | /// <reference path='fourslash.ts' />
////for (x in []) {}
////for (y in []) {}
verify.codeFixAll({
fixId: "addMissingConst",
fixAllDescription: "Add 'const' to all unresolved variables",
newFileContent:
`for (const x in []) {}
for (const y in []) {}`
});
| {
"end_byte": 271,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingConstInForInLoop2.ts"
} |
TypeScript/tests/cases/fourslash/formatRemoveSemicolons2.ts_0_549 | /// <reference path="fourslash.ts" />
////namespace ts {
//// let x = 0;
//// //
//// interface I {
//// a: string;
//// /** @internal */
//// b: string;
//// }
//// let y = 0; //
////}
////let z = 0; //
format.setFormatOptions({ ...format.copyFormatOptions(), semicolons: ts.SemicolonPreference.Remove });
format.document();
verify.currentFileContentIs(`namespace ts {
let x = 0
//
interface I {
a: string
/** @internal */
b: string
}
let y = 0 //
}
let z = 0 //`);
| {
"end_byte": 549,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatRemoveSemicolons2.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_function3.ts_0_121 | /// <reference path="fourslash.ts" />
////const f3 = function () {
//// /**/
////}
verify.baselineSmartSelection();
| {
"end_byte": 121,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_function3.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoJsDocTags1.ts_0_468 | /// <reference path='fourslash.ts'/>
// @Filename: quickInfoJsDocTags1.ts
/////**
//// * Doc
//// * @author Me <me@domain.tld>
//// * @augments {C<T>} Augments it
//// * @template T A template
//// * @type {number | string} A type
//// * @typedef {number | string} NumOrStr
//// * @property {number} x The prop
//// * @param {number} x The param
//// * @returns The result
//// * @see x (the parameter)
//// */
////function /**/foo(x) {}
verify.baselineQuickInfo();
| {
"end_byte": 468,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTags1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixImportNonExportedMember9.ts_0_427 | /// <reference path="fourslash.ts" />
// @module: esnext
// @filename: /a.ts
/////**
//// * foo
//// */
////function foo() {}
////export {};
// @filename: /b.ts
////import { foo } from "./a";
goTo.file("/b.ts");
verify.codeFix({
description: [ts.Diagnostics.Export_0_from_module_1.message, "foo", "./a"],
index: 0,
newFileContent: {
"/a.ts":
`/**
* foo
*/
function foo() {}
export { foo };`,
}
});
| {
"end_byte": 427,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImportNonExportedMember9.ts"
} |
TypeScript/tests/cases/fourslash/importTypeCompletions9.ts_0_634 | /// <reference path="fourslash.ts" />
// @target: esnext
// @filename: /foo.ts
////export interface Foo {}
// @filename: /bar.ts
////[|import { type /**/ }|]
goTo.file("/bar.ts")
verify.completions({
marker: "",
exact: [{
name: "Foo",
sourceDisplay: "./foo",
source: "./foo",
insertText: "import { type Foo } from \"./foo\";",
replacementSpan: test.ranges()[0]
}],
isNewIdentifierLocation: true,
preferences: {
includeCompletionsForModuleExports: true,
includeCompletionsForImportStatements: true,
includeCompletionsWithInsertText: true
}
});
| {
"end_byte": 634,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importTypeCompletions9.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageMember2JS.ts_0_272 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noImplicitAny: true
// @Filename: important.js
/////** @typedef {{ [|p |]}} I */
/////** @type {I} */
////var i;
////i.p = 0;
verify.rangeAfterCodeFix("p: number", undefined, undefined, 0);
| {
"end_byte": 272,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageMember2JS.ts"
} |
TypeScript/tests/cases/fourslash/codeFixTopLevelForAwait_target_blankCompilerOptionsInTsConfig.ts_0_516 | /// <reference path="fourslash.ts" />
// @filename: /dir/a.ts
////declare const p: number[];
////for await (const _ of p);
////export {};
// @filename: /dir/tsconfig.json
////{
//// "compilerOptions": {
//// }
////}
verify.codeFix({
description: [ts.Diagnostics.Set_the_target_option_in_your_configuration_file_to_0.message, "es2017"],
index: 0,
newFileContent: {
"/dir/tsconfig.json":
`{
"compilerOptions": {
"target": "es2017",
"module": "commonjs"
}
}`
}
});
| {
"end_byte": 516,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelForAwait_target_blankCompilerOptionsInTsConfig.ts"
} |
TypeScript/tests/cases/fourslash/navigationItemsExportDefaultExpression.ts_0_2701 | /// <reference path="fourslash.ts"/>
//// export default function () {}
//// export default function () {
//// return class Foo {
//// }
//// }
////
//// export default () => ""
//// export default () => {
//// return class Foo {
//// }
//// }
////
//// export default function f1() {}
//// export default function f2() {
//// return class Foo {
//// }
//// }
////
//// const abc = 12;
//// export default abc;
//// export default class AB {}
//// export default {
//// a: 1,
//// b: 1,
//// c: {
//// d: 1
//// }
//// }
////
//// function foo(props: { x: number; y: number }) {}
//// export default foo({ x: 1, y: 1 });
verify.navigationTree({
"text": '"navigationItemsExportDefaultExpression"',
"kind": "module",
"childItems": [
{
"text": "default",
"kind": "function",
"kindModifiers": "export"
},
{
"text": "default",
"kind": "function",
"kindModifiers": "export",
"childItems": [
{
"text": "Foo",
"kind": "class"
}
]
},
{
"text": "default",
"kind": "function",
"kindModifiers": "export"
},
{
"text": "default",
"kind": "function",
"kindModifiers": "export",
"childItems": [
{
"text": "Foo",
"kind": "class"
}
]
},
{
"text": "default",
"kind": "const",
"kindModifiers": "export",
"childItems": [
{
"text": "a",
"kind": "property"
},
{
"text": "b",
"kind": "property"
},
{
"text": "c",
"kind": "property",
"childItems": [
{
"text": "d",
"kind": "property"
}
]
}
]
},
{
"text": "default",
"kind": "const",
"kindModifiers": "export",
"childItems": [
{
"text": "x",
"kind": "property"
},
{
"text": "y",
"kind": "property"
}
]
},
{
"text": "AB",
"kind": "class",
"kindModifiers": "export"
},
{
"text": "abc",
"kind": "const"
},
{
"text": "default",
"kind": "const",
"kindModifiers": "export"
},
{
"text": "f1",
"kind": "function",
"kindModifiers": "export"
},
{
"text": "f2",
"kind": "function",
"kindModifiers": "export",
"childItems": [
{
"text": "Foo",
"kind": "class"
}
]
},
{
"text": "foo",
"kind": "function"
}
]
});
| {
"end_byte": 2701,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationItemsExportDefaultExpression.ts"
} |
TypeScript/tests/cases/fourslash/formatVariableDeclarationList.ts_0_1556 | /// <reference path='fourslash.ts' />
/////*1*/var fun1 = function ( ) {
/////*2*/ var x = 'foo' ,
/////*3*/ z = 'bar' ;
/////*4*/ return x ;
/////*5*/},
////
/////*6*/fun2 = ( function ( f ) {
/////*7*/ var fun = function ( ) {
/////*8*/ console . log ( f ( ) ) ;
/////*9*/ },
/////*10*/ x = 'Foo' ;
/////*11*/ return fun ;
/////*12*/} ( fun1 ) ) ;
format.document();
goTo.marker("1");
verify.currentLineContentIs("var fun1 = function() {");
goTo.marker("2");
verify.currentLineContentIs(" var x = 'foo',");
goTo.marker("3");
verify.currentLineContentIs(" z = 'bar';");
goTo.marker("4");
verify.currentLineContentIs(" return x;");
goTo.marker("5");
verify.currentLineContentIs("},");
goTo.marker("6");
verify.currentLineContentIs(" fun2 = (function(f) {");
goTo.marker("7");
verify.currentLineContentIs(" var fun = function() {");
goTo.marker("8");
verify.currentLineContentIs(" console.log(f());");
goTo.marker("9");
verify.currentLineContentIs(" },");
goTo.marker("10");
verify.currentLineContentIs(" x = 'Foo';");
goTo.marker("11");
verify.currentLineContentIs(" return fun;");
goTo.marker("12");
verify.currentLineContentIs(" }(fun1));"); | {
"end_byte": 1556,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatVariableDeclarationList.ts"
} |
TypeScript/tests/cases/fourslash/completionListInTypedObjectLiterals3.ts_0_181 | /// <reference path="fourslash.ts" />
////interface Foo {
//// x: { a: number };
////}
////var aaa: Foo;
////aaa.x = { /*10*/
verify.completions({ marker: "10", exact: "a" });
| {
"end_byte": 181,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInTypedObjectLiterals3.ts"
} |
TypeScript/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_parameters.ts_0_1051 | /// <reference path='fourslash.ts' />
////var aa = 1;
////function testFunction(/*parameterName1*/
////function testFunction(a/*parameterName2*/
////function testFunction(a, /*parameterName3*/
////function testFunction(a, b/*parameterName4*/
////class bar5{ constructor(public /*constructorParameter1*/
////class bar6{ constructor(public a/*constructorParameter2*/
////class bar7{ constructor(protected a/*constructorParameter3*/
////class bar8{ constructor(private a/*constructorParameter4*/
////class bar9{ constructor(.../*constructorParameter5*/
////class bar10{ constructor(...a/*constructorParameter6*/
verify.completions(
{
marker: [1,2,3,4].map(i => `parameterName${i}`),
exact: undefined,
},
{
marker: [1,2,3,4].map(i => `constructorParameter${i}`),
exact: completion.constructorParameterKeywords,
isNewIdentifierLocation: true,
},
{
marker: [5, 6].map(i => `constructorParameter${i}`),
exact: undefined,
isNewIdentifierLocation: true,
},
);
| {
"end_byte": 1051,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_parameters.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsInteractiveTemplateLiteralTypes.ts_0_610 | /// <reference path="fourslash.ts" />
//// declare function getTemplateLiteral1(): `${string},${string}`;
//// const lit1 = getTemplateLiteral1();
//// declare function getTemplateLiteral2(): `\${${string},${string}`;
//// const lit2 = getTemplateLiteral2();
//// declare function getTemplateLiteral3(): `start${string}\${,$${string}end`;
//// const lit3 = getTemplateLiteral3();
//// declare function getTemplateLiteral4(): `${string}\`,${string}`;
//// const lit4 = getTemplateLiteral4();
verify.baselineInlayHints(undefined, {
includeInlayVariableTypeHints: true,
interactiveInlayHints: true
});
| {
"end_byte": 610,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveTemplateLiteralTypes.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts_0_656 | /// <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_o1: string): number",
argumentCount: 2,
parameterCount: 2,
parameterName: "templateStrings",
parameterSpan: "templateStrings: string[]",
});
| {
"end_byte": 656,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_typeOnly.ts_0_512 | /// <reference path="fourslash.ts" />
// @target: esnext
// @Filename: /a.ts
//// export class A {}
//// export class B {}
// @Filename: /b.ts
//// import type { A } from './a';
//// const b: B/**/
goTo.file('/b.ts');
verify.applyCodeActionFromCompletion('', {
name: 'B',
source: '/a',
description: `Update import from "./a"`,
preferences: {
includeCompletionsForModuleExports: true,
includeInsertTextCompletions: true
},
newFileContent: `import type { A, B } from './a';
const b: B`
});
| {
"end_byte": 512,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_typeOnly.ts"
} |
TypeScript/tests/cases/fourslash/formatTypeAnnotation2.ts_0_311 | /// <reference path='fourslash.ts' />
////function foo(x : number, y ?: string) : number {}
////interface Foo {
//// x : number;
//// y ?: number;
////}
format.document();
verify.currentFileContentIs(
`function foo(x: number, y?: string): number { }
interface Foo {
x: number;
y?: number;
}`
);
| {
"end_byte": 311,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatTypeAnnotation2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassExtendAbstractMethodWithLongName.ts_0_2163 | /// <reference path='fourslash.ts' />
////namespace some.really.long.generated.type.goes.here.you.know.this_.should.be.pretty.simple {
//// export interface Yah {}
////}
////namespace another.really.long.generated.type.goes.here.too.because.who.cares.about.space.do_.you.feel.me {
//// export interface Yah {}
////}
////interface this_will_be_collapsed {}
////interface this_is_fine {}
////abstract class AbstractCstVisitor {
//// abstract Node(
//// arg1: [
//// some.really.long.generated.type.goes.here.you.know.this_.should.be.pretty.simple.Yah[],
//// another.really.long.generated.type.goes.here.too.because.who.cares.about.space.do_.you.feel.me.Yah[]
//// ],
//// arg2: [this_will_be_collapsed],
//// arg3: Set<this_will_be_collapsed>,
//// arg4: this_is_fine
//// ): Set<this_will_be_collapsed>;
////}
////class CstVisitorImplementation extends AbstractCstVisitor {}
verify.codeFix({
description: "Implement inherited abstract class",
newFileContent: `namespace some.really.long.generated.type.goes.here.you.know.this_.should.be.pretty.simple {
export interface Yah {}
}
namespace another.really.long.generated.type.goes.here.too.because.who.cares.about.space.do_.you.feel.me {
export interface Yah {}
}
interface this_will_be_collapsed {}
interface this_is_fine {}
abstract class AbstractCstVisitor {
abstract Node(
arg1: [
some.really.long.generated.type.goes.here.you.know.this_.should.be.pretty.simple.Yah[],
another.really.long.generated.type.goes.here.too.because.who.cares.about.space.do_.you.feel.me.Yah[]
],
arg2: [this_will_be_collapsed],
arg3: Set<this_will_be_collapsed>,
arg4: this_is_fine
): Set<this_will_be_collapsed>;
}
class CstVisitorImplementation extends AbstractCstVisitor {
Node(arg1: [
some.really.long.generated.type.goes.here.you.know.this_.should.be.pretty.simple.Yah[],
another.really.long.generated.type.goes.here.too.because.who.cares.about.space.do_.you.feel.me.Yah[]
], arg2: [this_will_be_collapsed], arg3: Set<this_will_be_collapsed>, arg4: this_is_fine) {
throw new Error("Method not implemented.");
}
}`
});
| {
"end_byte": 2163,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassExtendAbstractMethodWithLongName.ts"
} |
TypeScript/tests/cases/fourslash/javaScriptModules18.ts_0_255 | ///<reference path="fourslash.ts" />
// CommonJS modules should not pollute the global namespace
// @allowJs: true
// @Filename: myMod.js
//// var x = require('fs');
// @Filename: other.js
//// /**/;
verify.completions({ marker: "", excludes: "x" });
| {
"end_byte": 255,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javaScriptModules18.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports10.ts_0_423 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
////function foo() {
//// return { x: 1, y: 1 };
////}
////export default foo();
verify.codeFix({
description: "Extract default export to variable",
index: 0,
newFileContent:
`function foo() {
return { x: 1, y: 1 };
}
const _default_1: {
x: number;
y: number;
} = foo();
export default _default_1;`,
});
| {
"end_byte": 423,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports10.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationNamespace_00.ts_0_392 | /// <reference path='fourslash.ts'/>
// Should handle namespace and module implementations
//// namespace /*implementation0*/Foo {
//// export function hello() {}
//// }
////
//// module /*implementation1*/Bar {
//// export function sure() {}
//// }
////
//// let x = Fo/*reference0*/o;
//// let y = Ba/*reference1*/r;
verify.baselineGoToImplementation("reference0", "reference1"); | {
"end_byte": 392,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationNamespace_00.ts"
} |
TypeScript/tests/cases/fourslash/codeFixOverrideModifier20.ts_0_333 | /// <reference path='fourslash.ts' />
// @noImplicitOverride: true
////class Foo {
//// static readonly p = '';
////}
////
////export class Bar extends Foo {
//// [|static readonly p = ''|];
////}
verify.codeFix({
description: "Add 'override' modifier",
newRangeContent: "static override readonly p = ''",
index: 0
})
| {
"end_byte": 333,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixOverrideModifier20.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsRestParameters1.ts_0_424 | /// <reference path="fourslash.ts" />
//// function foo1(a: number, ...b: number[]) {}
//// foo1(1, 1, 1, 1);
//// type Args2 = [a: number, b: number]
//// declare function foo2(c: number, ...args: Args2);
//// foo2(1, 2, 3)
//// type Args3 = [number, number]
//// declare function foo3(c: number, ...args: Args3);
//// foo3(1, 2, 3)
verify.baselineInlayHints(undefined, { includeInlayParameterNameHints: "literals" });
| {
"end_byte": 424,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsRestParameters1.ts"
} |
TypeScript/tests/cases/fourslash/deduplicateErrors.ts_0_180 | /// <reference path="./fourslash.ts" />
////let lololol = 123;
////
////lololo/**/
verify.encodedSemanticClassificationsLength("2020", 3);
verify.numberOfErrorsInCurrentFile(1);
| {
"end_byte": 180,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/deduplicateErrors.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_default_symbolName.ts_0_1134 | /// <reference path="fourslash.ts" />
// @module: commonjs
// @Filename: /node_modules/@types/range-parser/index.d.ts
////declare function RangeParser(): string;
////declare namespace RangeParser {
//// interface Options {
//// combine?: boolean;
//// }
////}
////export = RangeParser;
// @Filename: /b.ts
////R/*0*/
verify.completions(
{
marker: "0",
includes: {
name: "RangeParser",
kind: "function",
kindModifiers: "declare",
source: "/node_modules/@types/range-parser/index",
sourceDisplay: "range-parser",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
text: `namespace RangeParser
function RangeParser(): string`
},
preferences: {
includeCompletionsForModuleExports: true
}
},
);
verify.applyCodeActionFromCompletion("0", {
name: "RangeParser",
source: "/node_modules/@types/range-parser/index",
description: `Add import from "range-parser"`,
newFileContent: `import RangeParser = require("range-parser");
R`,
});
| {
"end_byte": 1134,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_default_symbolName.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_parameterInGetAccessor.ts_0_289 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
////let foo = {
//// get x(/**/param) {}
////}
verify.codeFix({
description: "Remove unused declaration for: 'param'",
index: 0,
newFileContent:
`let foo = {
get x() {}
}`
})
| {
"end_byte": 289,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_parameterInGetAccessor.ts"
} |
TypeScript/tests/cases/fourslash/autoImportVerbatimTypeOnly1.ts_0_942 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @verbatimModuleSyntax: true
// @Filename: /mod.ts
//// export const value = 0;
//// export class C { constructor(v: any) {} }
//// export interface I {}
// @Filename: /a.mts
//// const x: /**/
verify.applyCodeActionFromCompletion("", {
name: "I",
source: "./mod",
description: `Add import from "./mod.js"`,
data: {
exportName: "I",
fileName: "/mod.ts",
moduleSpecifier: "./mod.js",
},
newFileContent: `import type { I } from "./mod.js";
const x: `,
});
edit.insert("I = new C");
verify.applyCodeActionFromCompletion(/*markerName*/ undefined, {
name: "C",
source: "./mod",
description: `Update import from "./mod.js"`,
data: {
exportName: "C",
fileName: "/mod.ts",
moduleSpecifier: "./mod.js",
},
newFileContent: `import { C, type I } from "./mod.js";
const x: I = new C`,
});
| {
"end_byte": 942,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportVerbatimTypeOnly1.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateCommentAfterOperator.ts_0_516 | /// <reference path='fourslash.ts' />
//// const foo = /* C0 */ /*x*/"/*y*/foo" + /* C1 */ " is" + /* C2 */ 42 + /* C3 */ " and bar" + /* C4 */ " is" + /* C5 */ 52/* C6 */
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 = /* C0 */ `foo is\${ /* C1 */ /* C2 */42 /* C3 */} and bar is\${ /* C4 */ /* C5 */52 /* C6 */}`",
});
| {
"end_byte": 516,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateCommentAfterOperator.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties31.ts_0_348 | /// <reference path="fourslash.ts" />
////interface A {
//// a: number;
//// b: string;
////}
////interface B {
//// c: A[];
////}
////[|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": 348,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties31.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.