_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction9.ts_0_360
/// <reference path='fourslash.ts' /> //// const foo = /*a*/a/*b*/ => (1, 2, 3); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Add or remove braces in an arrow function", actionName: "Add braces to arrow function", actionDescription: "Add braces to arrow function", newContent: `const foo = a => { return (1, 2, 3); };`, });
{ "end_byte": 360, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction9.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceCallback.ts_0_1484
/// <reference path='fourslash.ts' /> // #35508 ////interface IFoo1 { //// parse(reviver: () => any): void; ////} //// ////class Foo1 implements IFoo1 { ////} //// ////interface IFoo2 { //// parse(reviver: { (): any }): void; ////} //// ////class Foo2 implements IFoo2 { ////} //// ////interface IFoo3 { //// parse(reviver: new () => any): void; ////} //// ////class Foo3 implements IFoo3 { ////} //// ////interface IFoo4 { //// parse(reviver: { new (): any }): void; ////} //// ////class Foo4 implements IFoo4 { ////} verify.codeFixAll({ fixAllDescription: ts.Diagnostics.Implement_all_unimplemented_interfaces.message, fixId: "fixClassIncorrectlyImplementsInterface", newFileContent: `interface IFoo1 { parse(reviver: () => any): void; } class Foo1 implements IFoo1 { parse(reviver: () => any): void { throw new Error("Method not implemented."); } } interface IFoo2 { parse(reviver: { (): any }): void; } class Foo2 implements IFoo2 { parse(reviver: { (): any; }): void { throw new Error("Method not implemented."); } } interface IFoo3 { parse(reviver: new () => any): void; } class Foo3 implements IFoo3 { parse(reviver: new () => any): void { throw new Error("Method not implemented."); } } interface IFoo4 { parse(reviver: { new (): any }): void; } class Foo4 implements IFoo4 { parse(reviver: { new(): any; }): void { throw new Error("Method not implemented."); } }`});
{ "end_byte": 1484, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceCallback.ts" }
TypeScript/tests/cases/fourslash/completionListInObjectLiteral.ts_0_291
/// <reference path="fourslash.ts" /> ////interface point { //// x: number; //// y: number; ////} ////interface thing { //// name: string; //// pos: point; ////} ////var t: thing; ////t.pos = { x: 4, y: 3 + t./**/ }; verify.completions({ marker: "", exact: ["name", "pos"] });
{ "end_byte": 291, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectLiteral.ts" }
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_Typed.ts_0_428
/// <reference path='fourslash.ts' /> //// const concat = /*x*/f/*y*/unction(a: string, b: string): string { //// return a + b; //// }; goTo.select("x", "y"); edit.applyRefactor({ refactorName: "Convert arrow function or function expression", actionName: "Convert to arrow function", actionDescription: "Convert to arrow function", newContent: `const concat = (a: string, b: string): string => a + b;`, });
{ "end_byte": 428, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_Typed.ts" }
TypeScript/tests/cases/fourslash/findAllRefsReExport_broken.ts_0_132
/// <reference path='fourslash.ts' /> // @Filename: /a.ts /////*1*/export { /*2*/x }; verify.baselineFindAllReferences('1', '2');
{ "end_byte": 132, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsReExport_broken.ts" }
TypeScript/tests/cases/fourslash/completionListForShorthandPropertyAssignment.ts_0_152
/// <reference path="fourslash.ts" /> //// var person: {name:string; id: number} = { n/**/ verify.completions({ marker: "", exact: ["id", "name"] });
{ "end_byte": 152, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListForShorthandPropertyAssignment.ts" }
TypeScript/tests/cases/fourslash/codeFixAddVoidToPromise.4.ts_0_405
/// <reference path='fourslash.ts' /> // @target: esnext // @lib: es2015 // @strict: true ////const p4 = new Promise<{ x: number } & { y: string }>(resolve => resolve()); verify.codeFix({ errorCode: 2794, description: "Add 'void' to Promise resolved without a value", index: 0, newFileContent: `const p4 = new Promise<({ x: number } & { y: string }) | void>(resolve => resolve());` });
{ "end_byte": 405, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddVoidToPromise.4.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_NotForOptionalChain.ts_0_196
/// <reference path='fourslash.ts' /> ////let a = { b: { c: 0 } }; /////*a*/a && a.b && a?.b?.c;/*b*/ goTo.select("a", "b"); verify.not.refactorAvailable("Convert to optional chain expression");
{ "end_byte": 196, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_NotForOptionalChain.ts" }
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction8.ts_0_279
/// <reference path='fourslash.ts' /> // @target: es2015 ////async function fn(): symbol {} verify.codeFix({ index: 0, description: [ts.Diagnostics.Replace_0_with_Promise_1.message, "symbol", "symbol"], newFileContent: `async function fn(): Promise<symbol> {}` });
{ "end_byte": 279, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction8.ts" }
TypeScript/tests/cases/fourslash/quickInfoInOptionalChain.ts_0_907
/// <reference path='fourslash.ts'/> // // @strict: true // //// interface A { //// arr: string[]; //// } //// //// function test(a?: A): string { //// return a?.ar/*1*/r.length ? "A" : "B"; //// } //// //// interface Foo { bar: { baz: string } }; //// declare const foo: Foo | undefined; //// //// if (foo?.b/*2*/ar.b/*3*/az) {} //// //// interface Foo2 { bar?: { baz: { qwe: string } } }; //// declare const foo2: Foo2; //// //// if (foo2.b/*4*/ar?.b/*5*/az.q/*6*/we) {} verify.quickInfoAt("1", "(property) A.arr: string[]"); verify.quickInfoAt("2", "(property) Foo.bar: {\n baz: string;\n}"); verify.quickInfoAt("3", "(property) baz: string | undefined"); verify.quickInfoAt("4", "(property) Foo2.bar?: {\n baz: {\n qwe: string;\n };\n} | undefined"); verify.quickInfoAt("5", "(property) baz: {\n qwe: string;\n}"); verify.quickInfoAt("6", "(property) qwe: string | undefined");
{ "end_byte": 907, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoInOptionalChain.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements1.ts_0_335
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @noUnusedParameters: true ////export function f({ x, y }, a) { //// a; ////} verify.codeFix({ description: [ts.Diagnostics.Remove_unused_declarations_for_Colon_0.message, "x, y"], index: 0, newFileContent: `export function f({ }, a) { a; }`, });
{ "end_byte": 335, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements1.ts" }
TypeScript/tests/cases/fourslash/completionAfterNewline.ts_0_420
/// <reference path="fourslash.ts" /> // issue: https://github.com/microsoft/TypeScript/issues/54729 // Tests that `isCompletionListBlocker` returns true at position 1, and returns false after a newline. ////let foo /*1*/ /////*2*/ /////*3*/ verify.completions( { marker: "1", exact: undefined }, { marker: ["2", "3"], exact: completion.globalsPlus([ { name: "foo", }, ]), } );
{ "end_byte": 420, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionAfterNewline.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts_0_1922
/// <reference path='fourslash.ts' /> // Should give completions for node modules and files within those modules with ts file extensions // @Filename: tests/test0.ts //// import * as foo1 from "f/*import_as0*/ //// import * as foo2 from "fake-module//*import_as1*/ //// import * as foo3 from "[|fake-module/*import_as2*/|] //// import foo4 = require("f/*import_equals0*/ //// import foo5 = require("fake-module//*import_equals1*/ //// import foo6 = require("[|fake-module/*import_equals2*/|] //// var foo7 = require("f/*require0*/ //// var foo8 = require("fake-module//*require1*/ //// var foo9 = require("[|fake-module/*require2*/|] // @Filename: package.json //// { "dependencies": { "fake-module": "latest" }, "devDependencies": { "fake-module-dev": "latest" } } // @Filename: node_modules/fake-module/index.js //// /*fake-module*/ // @Filename: node_modules/fake-module/index.d.ts //// /*fakemodule-d-ts*/ // @Filename: node_modules/fake-module/ts.ts //// /*ts*/ // @Filename: node_modules/fake-module/dts.d.ts //// /*dts*/ // @Filename: node_modules/fake-module/tsx.tsx //// /*tsx*/ // @Filename: node_modules/fake-module/js.js //// /*js*/ // @Filename: node_modules/fake-module/jsx.jsx //// /*jsx*/ // @Filename: node_modules/fake-module-dev/index.js //// /*fakemodule-dev*/ // @Filename: node_modules/fake-module-dev/index.d.ts //// /*fakemodule-dev-d-ts*/ // @Filename: node_modules/unlisted-module/index.ts //// /*unlisted-module*/ ["import_as", "import_equals", "require"].forEach((kind, i) => { verify.completions( { marker: `${kind}0`, exact: ["fake-module", "fake-module-dev"], isNewIdentifierLocation: true }, { marker: `${kind}1`, exact: ["dts", "index", "ts", "tsx"], isNewIdentifierLocation: true }, { marker: `${kind}2`, exact: ["fake-module", "fake-module-dev"].map(name => ({ name, replacementSpan: test.ranges()[i] })), isNewIdentifierLocation: true }, ); });
{ "end_byte": 1922, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts" }
TypeScript/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts_0_288
/// <reference path="fourslash.ts" /> ////interface I1 { //// a(): void; //// b(): void; ////} //// ////var imp1: I1 = { //// a() {}, //// /*0*/ ////} //// ////var imp2: I1 = { //// a: () => {}, //// /*1*/ ////} verify.completions({ marker: ["0", "1"], exact: "b" });
{ "end_byte": 288, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.ts_0_791
/// <reference path='fourslash.ts' /> ////declare var console: { //// log(msg: string): void; ////} ////type MultiSkilledRobot = [string, string[]]; ////var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ////var multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; ////let [, skillA = ["noSkill", "noSkill"]] = multiRobotA; ////let [nameMB = "noName" ] = multiRobotB; ////let [nameMA = "noName", [primarySkillA = "noSkill", secondarySkillA = "noSkill"] = ["noSkill", "noSkill"]] = multiRobotA; ////let [nameMC = "noName" ] = ["roomba", ["vacuum", "mopping"]]; ////let [nameMC2 = "noName", [primarySkillC = "noSkill", secondarySkillC = "noSkill"] = ["noSkill", "noSkill"]] = ["roomba", ["vacuum", "mopping"]]; verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 791, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesSetAndGet2.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/getOccurrencesSetAndGet2.ts" }
TypeScript/tests/cases/fourslash/formatNoSpaceAfterTemplateHeadAndMiddle.ts_0_896
/// <reference path='fourslash.ts' /> ////const a1 = `${ 1 }${ 1 }`; ////const a2 = ` //// ${ 1 }${ 1 } ////`; ////const a3 = ` //// //// //// ${ 1 }${ 1 } ////`; ////const a4 = ` //// //// ${ 1 }${ 1 } //// ////`; ////const a5 = `text ${ 1 } text ${ 1 } text`; ////const a6 = ` //// text ${ 1 } //// text ${ 1 } //// text ////`; format.setOption("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces", false); format.document(); verify.currentFileContentIs( "const a1 = `${1}${1}`;\n" + "const a2 = `\n" + " ${1}${1}\n" + "`;\n" + "const a3 = `\n" + "\n" + "\n" + " ${1}${1}\n" + "`;\n" + "const a4 = `\n" + "\n" + " ${1}${1}\n" + "\n" + "`;\n" + "const a5 = `text ${1} text ${1} text`;\n" + "const a6 = `\n" + " text ${1}\n" + " text ${1}\n" + " text\n" + "`;" );
{ "end_byte": 896, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatNoSpaceAfterTemplateHeadAndMiddle.ts" }
TypeScript/tests/cases/fourslash/pathCompletionsTypesVersionsWildcard1.ts_0_835
/// <reference path="fourslash.ts" /> // @module: commonjs // @Filename: /node_modules/foo/package.json //// { //// "types": "index.d.ts", //// "typesVersions": { //// "*": { //// "*": ["dist/*"] //// } //// } //// } // @Filename: /node_modules/foo/nope.d.ts //// export const nope = 0; // @Filename: /node_modules/foo/dist/index.d.ts //// export const index = 0; // @Filename: /node_modules/foo/dist/blah.d.ts //// export const blah = 0; // @Filename: /node_modules/foo/dist/subfolder/one.d.ts //// export const one = 0; // @Filename: /a.ts //// import { } from "foo//**/"; verify.completions({ marker: "", isNewIdentifierLocation: true, exact: ["blah", "index", "subfolder"], }); edit.insert("subfolder/"); verify.completions({ marker: "", isNewIdentifierLocation: true, exact: ["one"], });
{ "end_byte": 835, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsTypesVersionsWildcard1.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationClasses.ts_0_1189
/// <reference path='fourslash.ts' /> // @BaselineFile: bpSpan_classes.baseline // @Filename: bpSpan_classes.ts ////module Foo.Bar { //// "use strict"; //// //// class Greeter { //// constructor(public greeting: string) { //// } //// //// greet() { //// return "<h1>" + this.greeting + "</h1>"; //// } //// } //// //// //// function foo(greeting: string): Greeter { //// return new Greeter(greeting); //// } //// //// var greeter = new Greeter("Hello, world!"); //// var str = greeter.greet(); //// //// function foo2(greeting: string, ...restGreetings /* more greeting */: string[]) { //// var greeters: Greeter[] = []; /* inline block comment */ //// greeters[0] = new Greeter(greeting); //// for (var i = 0; i < restGreetings.length; i++) { //// greeters.push(new Greeter(restGreetings[i])); //// } //// //// return greeters; //// } //// //// var b = foo2("Hello", "World", "!"); //// // This is simple signle line comment //// for (var j = 0; j < b.length; j++) { //// b[j].greet(); //// } ////} verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 1189, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationClasses.ts" }
TypeScript/tests/cases/fourslash/formatInsertSpaceAfterCloseBraceBeforeCloseBracket.ts_0_188
///<reference path="fourslash.ts"/> ////[{}] format.setOption("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets", true); format.document(); verify.currentFileContentIs("[ {} ]");
{ "end_byte": 188, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatInsertSpaceAfterCloseBraceBeforeCloseBracket.ts" }
TypeScript/tests/cases/fourslash/renameInheritedProperties6.ts_3_279
/ <reference path='fourslash.ts'/> //// interface C extends D { //// propD: number; //// } //// interface D extends C { //// [|[|{| "contextRangeIndex": 0 |}propC|]: number;|] //// } //// var d: D; //// d.[|propC|]; verify.baselineRenameAtRangesWithText("propC");
{ "end_byte": 279, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameInheritedProperties6.ts" }
TypeScript/tests/cases/fourslash/autoImportPackageRootPathExtension.ts_0_489
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: /node_modules/pkg/package.json //// { //// "name": "pkg", //// "version": "1.0.0", //// "main": "lib" //// } // @Filename: /node_modules/pkg/lib/index.d.mts //// export declare function foo(): any; // @Filename: /package.json //// { //// "dependencies": { //// "pkg": "*" //// } //// } // @Filename: /index.ts //// foo/**/ verify.importFixModuleSpecifiers("", ["pkg/lib/index.mjs"]);
{ "end_byte": 489, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPackageRootPathExtension.ts" }
TypeScript/tests/cases/fourslash/exhaustiveCaseCompletions8.ts_0_623
/// <reference path="fourslash.ts" /> // @newline: LF ////export function foo(position: -1n | 0n) { //// switch (position) { //// /**/ //// } ////} verify.completions( { marker: "", isNewIdentifierLocation: false, includes: [ { name: "case 0n: ...", source: completion.CompletionSource.SwitchCases, sortText: completion.SortText.GlobalsOrKeywords, insertText: `case 0n: case -1n:`, }, ], preferences: { includeCompletionsWithInsertText: true, }, }, );
{ "end_byte": 623, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/exhaustiveCaseCompletions8.ts" }
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue2.ts_0_220
/// <reference path='fourslash.ts' /> //// interface A { //// foo: number //// } //// function Foo (): A { //// ({ foo: 1 }) //// } verify.codeFixAvailable([ { description: 'Add a return statement' }, ]);
{ "end_byte": 220, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue2.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDocTags12.ts_0_358
/// <reference path="fourslash.ts" /> /////** //// * @param {Object} options the args object //// * @param {number} options.a first number //// * @param {number} options.b second number //// * @param {Function} callback the callback function //// * @returns {number} //// */ ////function /**/f(options, callback = null) { ////} verify.baselineQuickInfo();
{ "end_byte": 358, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTags12.ts" }
TypeScript/tests/cases/fourslash/quickInfoOnJsxIntrinsicDeclaredUsingCatchCallIndexSignature.ts_0_297
/// <reference path="fourslash.ts" /> // https://github.com/microsoft/TypeScript/issues/5984 // @jsx: react // @filename: /a.tsx //// declare namespace JSX { //// interface IntrinsicElements { [elemName: string]: any; } //// } //// </**/div class="democlass" />; verify.baselineQuickInfo();
{ "end_byte": 297, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnJsxIntrinsicDeclaredUsingCatchCallIndexSignature.ts" }
TypeScript/tests/cases/fourslash/renameForAliasingExport01.ts_0_197
/// <reference path='fourslash.ts'/> // @Filename: foo.ts ////let x = 1; //// ////export { /**/[|x|] as y }; goTo.marker(); verify.renameInfoSucceeded(/*displayName*/"x", /*fullDisplayName*/"x");
{ "end_byte": 197, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameForAliasingExport01.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteral15.ts_0_223
/// <reference path='fourslash.ts'/> ////let x: { [_ in "foo"]: string } = { //// "[|/**/|]" ////} verify.completions({ marker: "", exact: [ { name: "foo", replacementSpan: test.ranges()[0] } ] });
{ "end_byte": 223, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral15.ts" }
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc26.ts_0_547
/// <reference path="fourslash.ts" /> // @strict: true ////class C { //// /** //// * @private //// * @param {Object} [foo] //// * @param {Object} foo.a //// * @param {String} [foo.a.b] //// */ //// m(foo) { } ////} verify.codeFix({ description: ts.Diagnostics.Annotate_with_type_from_JSDoc.message, index: 1, newFileContent: `class C { /** * @private * @param {Object} [foo] * @param {Object} foo.a * @param {String} [foo.a.b] */ m(foo: { a: { b?: string; }; }) { } }`, });
{ "end_byte": 547, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc26.ts" }
TypeScript/tests/cases/fourslash/inlineVariableDestructuredVariableDeclaration4.ts_0_470
/// <reference path="fourslash.ts" /> ////function f() { //// const a = { prop: 123 }; //// const { prop } = /*a*/a/*b*/; ////} goTo.select("a", "b"); verify.refactorAvailableForTriggerReason("invoked", "Inline variable"); edit.applyRefactor({ refactorName: "Inline variable", actionName: "Inline variable", actionDescription: "Inline variable", newContent: `function f() { const { prop } = { prop: 123 }; }`, triggerReason: "invoked" });
{ "end_byte": 470, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableDestructuredVariableDeclaration4.ts" }
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateBackTick.ts_0_188
/// <reference path='fourslash.ts' /> //// const foo = "/*x*/w/*y*/ith back`tick" goTo.select("x", "y"); verify.not.refactorAvailable(ts.Diagnostics.Convert_to_template_string.message);
{ "end_byte": 188, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateBackTick.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_importType1.ts_0_795
/// <reference path="fourslash.ts" /> // @verbatimModuleSyntax: true // @module: es2015 // @Filename: /exports.ts //// export default someValue = 0; //// export function Component() {} //// export interface ComponentProps {} // @Filename: /a.ts //// import { Component } from "./exports.js"; //// interface MoreProps extends /*a*/ComponentProps {} // @Filename: /b.ts //// import someValue from "./exports.js"; //// interface MoreProps extends /*b*/ComponentProps {} goTo.marker("a"); verify.importFixAtPosition([ `import { Component, type ComponentProps } from "./exports.js"; interface MoreProps extends ComponentProps {}`]); goTo.marker("b"); verify.importFixAtPosition([ `import someValue, { type ComponentProps } from "./exports.js"; interface MoreProps extends ComponentProps {}`]);
{ "end_byte": 795, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_importType1.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_js_5.ts_0_539
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: a.js //// class A { //// _a = 2; //// /*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 { _a = 2; /*RENAME*/"_a_1" = 1; get "a"() { return this["_a_1"]; } set "a"(value) { this["_a_1"] = value; } }`, });
{ "end_byte": 539, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess_js_5.ts" }
TypeScript/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts_0_373
/// <reference path='fourslash.ts' /> // @noImplicitOverride: true ////abstract class A { //// public abstract x: number; ////} //// ////class C extends A {[| |]} verify.codeFix({ description: "Implement inherited abstract class", newFileContent: `abstract class A { public abstract x: number; } class C extends A { public override x: number; }`, });
{ "end_byte": 373, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts" }
TypeScript/tests/cases/fourslash/completionsPaths_kinds.ts_0_601
/// <reference path="fourslash.ts" /> // @Filename: /src/b.ts ////not read // @Filename: /src/dir/x.ts ////not read // @Filename: /src/a.ts ////import {} from "./[|/*0*/|]"; ////import {} from "./[|/*1*/|]"; // @Filename: /tsconfig.json ////{ //// "compilerOptions": { //// "baseUrl": ".", //// "paths": { //// "foo/*": ["src/*"] //// } //// } ////} verify.completions({ marker: ["0", "1"], exact: [ { name: "b", kind: "script", kindModifiers: ".ts" }, { name: "dir", kind: "directory" }, ], isNewIdentifierLocation: true });
{ "end_byte": 601, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsPaths_kinds.ts" }
TypeScript/tests/cases/fourslash/findAllRefsUnresolvedSymbols3.ts_0_389
/// <reference path='fourslash.ts'/> ////import * as /*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": 389, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsUnresolvedSymbols3.ts" }
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsClassDefaultAnonymous.ts_0_120
/// <reference path='fourslash.ts'/> /////*1*/export /*2*/default /*3*/class /*4*/ { ////} verify.baselineQuickInfo();
{ "end_byte": 120, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsClassDefaultAnonymous.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts_0_299
/// <reference path='fourslash.ts' /> ////interface I<X> { //// x: keyof X; ////} ////class C<Y> implements I<Y> {[| |]} verify.codeFix({ description: "Implement interface 'I<Y>'", newFileContent: `interface I<X> { x: keyof X; } class C<Y> implements I<Y> { x: keyof Y; }`, });
{ "end_byte": 299, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDocTagsTypedef.ts_0_451
/// <reference path='fourslash.ts'/> // @noEmit: true // @allowJs: true // @Filename: quickInfoJsDocTagsTypedef.js /////** //// * Bar comment //// * @typedef {Object} /*1*/Bar //// * @property {string} baz - baz comment //// * @property {string} qux - qux comment //// */ //// /////** //// * foo comment //// * @param {/*2*/Bar} x - x comment //// * @returns {Bar} //// */ ////function foo(x) { //// return x; ////} verify.baselineQuickInfo();
{ "end_byte": 451, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTagsTypedef.ts" }
TypeScript/tests/cases/fourslash/inlayHintsInteractiveRestParameters2.ts_0_582
/// <reference path="fourslash.ts" /> ////function foo(a: unknown, b: unknown, c: unknown) { } ////function foo1(...x: [number, number | undefined]) { //// foo(...x, 3); ////} ////function foo2(...x: []) { //// foo(...x, 1, 2, 3); ////} ////function foo3(...x: [number, number?]) { //// foo(1, ...x); ////} ////function foo4(...x: [number, number?]) { //// foo(...x, 3); ////} ////function foo5(...x: [number, number]) { //// foo(...x, 3); ////} verify.baselineInlayHints(undefined, { includeInlayParameterNameHints: "all", interactiveInlayHints: true, });
{ "end_byte": 582, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveRestParameters2.ts" }
TypeScript/tests/cases/fourslash/malformedObjectLiteral.ts_0_257
///<reference path="fourslash.ts"/> ////var tt = { aa };/**/ ////var y = /*1*/"unclosed string literal /////*2*/var x = "closed string literal" verify.errorExistsBeforeMarker(); verify.errorExistsAfterMarker("1"); verify.not.errorExistsAfterMarker("2");
{ "end_byte": 257, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/malformedObjectLiteral.ts" }
TypeScript/tests/cases/fourslash/completionListInObjectBindingPattern08.ts_0_333
/// <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: "propertyOfI_2" });
{ "end_byte": 333, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectBindingPattern08.ts" }
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsEnum3.ts_0_596
/// <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": 596, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsEnum3.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_moveNamedImport2.ts_0_393
/// <reference path='fourslash.ts' /> // @Filename: /other.ts //// export function foo() { return 1 }; // @Filename: /a.ts ////import { foo as oFoo } from './other'; ////[|export const x = oFoo();|] ////export const a = 0; verify.moveToNewFile({ newFileContents: { "/a.ts": `export const a = 0;`, "/x.ts": `import { foo as oFoo } from './other'; export const x = oFoo(); ` }, });
{ "end_byte": 393, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_moveNamedImport2.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageConstructorFunctionJS.ts_0_551
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @noImplicitAny: true // @Filename: test.js ////function TokenType([|label, token |]) { //// this.label = label; //// this.token = token || "N/A"; ////}; ////new TokenType("HI") verify.codeFix({ description: "Infer parameter types from usage", index: 0, newFileContent: `/** * @param {string} label * @param {string} [token] */ function TokenType(label, token ) { this.label = label; this.token = token || "N/A"; }; new TokenType("HI")`, });
{ "end_byte": 551, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageConstructorFunctionJS.ts" }
TypeScript/tests/cases/fourslash/javascriptModules25.ts_0_270
/// <reference path='fourslash.ts'/> // @allowJs: true // @Filename: mod.js //// function foo() { return {a: true}; } //// module.exports.a = foo; // @Filename: app.js //// import * as mod from "./mod" //// mod./**/ verify.completions({ marker: "", includes: "a" });
{ "end_byte": 270, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javascriptModules25.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_endingPreference.ts_0_686
/// <reference path="fourslash.ts" /> // @moduleResolution: node // @Filename: /foo/index.ts ////export const foo = 0; // @Filename: /a.ts ////foo; // @Filename: /b.ts ////foo; // @Filename: /c.ts ////foo; const tests: ReadonlyArray<[string, FourSlashInterface.UserPreferences["importModuleSpecifierEnding"], string]> = [ ["/a.ts", "js", "./foo/index.js"], ["/b.ts", "index", "./foo/index"], ["/c.ts", "minimal", "./foo"], ]; for (const [fileName, importModuleSpecifierEnding, specifier] of tests) { goTo.file(fileName); verify.importFixAtPosition([`import { foo } from "${specifier}";\n\nfoo;`,], /*errorCode*/ undefined, { importModuleSpecifierEnding }); }
{ "end_byte": 686, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_endingPreference.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_barrelExport.ts_0_663
/// <reference path="fourslash.ts" /> // @module: commonjs // @Filename: /foo/a.ts //// export const A = 0; // @Filename: /foo/b.ts //// export {}; //// A/*sibling*/ // @Filename: /foo/index.ts //// export * from "./a"; //// export * from "./b"; // @Filename: /index.ts //// export * from "./foo"; //// export * from "./src"; // @Filename: /src/a.ts //// export {}; //// A/*parent*/ // @Filename: /src/index.ts //// export * from "./a"; // Module specifiers made up of only "." and ".." components are deprioritized verify.importFixModuleSpecifiers("sibling", ["./a", ".", ".."]); verify.importFixModuleSpecifiers("parent", ["../foo", "../foo/a", ".."]);
{ "end_byte": 663, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_barrelExport.ts" }
TypeScript/tests/cases/fourslash/formatAsyncKeyword.ts_0_419
/// <reference path="fourslash.ts" /> /////*1*/let x = async () => 1; /////*2*/let y = async() => 1; /////*3*/let z = async function () { return 1; }; format.document(); goTo.marker("1"); verify.currentLineContentIs("let x = async () => 1;"); goTo.marker("2"); verify.currentLineContentIs("let y = async () => 1;"); goTo.marker("3"); verify.currentLineContentIs("let z = async function() { return 1; };")
{ "end_byte": 419, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatAsyncKeyword.ts" }
TypeScript/tests/cases/fourslash/toggleDuplicateFunctionDeclaration.ts_0_193
/// <reference path="fourslash.ts" /> //// class D { } //// D(); var funcDecl = 'declare function D();'; goTo.bof(); edit.insert(funcDecl); goTo.bof(); edit.deleteAtCaret(funcDecl.length);
{ "end_byte": 193, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/toggleDuplicateFunctionDeclaration.ts" }
TypeScript/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess.ts_0_348
/// <reference path='fourslash.ts' /> ////class Base{ ////} ////class C extends Base{ //// private a:number; //// constructor() {[| //// this.a = 12; //// super(); //// |]} //// m() { this.a; } // avoid unused 'a' ////} verify.rangeAfterCodeFix(` super(); this.a = 12; `, /*includeWhiteSpace*/ true);
{ "end_byte": 348, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingConstToStandaloneIdentifier1.ts_0_162
/// <reference path='fourslash.ts' /> ////x = 0; verify.codeFix({ description: "Add 'const' to unresolved variable", newFileContent: "const x = 0;" });
{ "end_byte": 162, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingConstToStandaloneIdentifier1.ts" }
TypeScript/tests/cases/fourslash/codeFixConvertToMappedObjectType4.ts_0_297
/// <reference path='fourslash.ts' /> //// type K = "foo" | "bar"; //// interface SomeType { //// [prop: K]: any; //// } verify.codeFix({ description: `Convert 'SomeType' to mapped object type`, newFileContent: `type K = "foo" | "bar"; type SomeType = { [prop in K]: any; };` })
{ "end_byte": 297, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToMappedObjectType4.ts" }
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_initializerInference.ts_0_534
/// <reference path='fourslash.ts' /> ////function f(/*a*/a: number, b = { x: 1, z: { s: true } }/*b*/) { //// return b; ////} ////f(2); 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: `function f({ a, b = { x: 1, z: { s: true } } }: { a: number; b?: { x: number; z: { s: boolean; }; }; }) { return b; } f({ a: 2 });` });
{ "end_byte": 534, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_initializerInference.ts" }
TypeScript/tests/cases/fourslash/jsdocOnInheritedMembers1.ts_0_356
///<reference path="fourslash.ts" /> // @allowJs: true // @checkJs: true // @filename: /a.js /////** @template T */ ////class A { //// /** Method documentation. */ //// method() {} ////} //// /////** @extends {A<number>} */ ////class B extends A { //// method() {} ////} //// ////const b = new B(); ////b.method/**/; verify.baselineQuickInfo();
{ "end_byte": 356, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocOnInheritedMembers1.ts" }
TypeScript/tests/cases/fourslash/findAllRefsForComputedProperties.ts_0_283
/// <reference path='fourslash.ts'/> ////interface I { //// ["/*0*/prop1"]: () => void; ////} //// ////class C implements I { //// ["/*1*/prop1"]: any; ////} //// ////var x: I = { //// ["/*2*/prop1"]: function () { }, ////} verify.baselineFindAllReferences('0', '1', '2')
{ "end_byte": 283, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForComputedProperties.ts" }
TypeScript/tests/cases/fourslash/signatureHelpSimpleFunctionCall.ts_0_584
/// <reference path='fourslash.ts' /> ////// Simple function test ////function functionCall(str: string, num: number) { ////} ////functionCall(/*functionCall1*/); ////functionCall("", /*functionCall2*/1); verify.signatureHelp( { marker: "functionCall1", text: "functionCall(str: string, num: number): void", parameterName: "str", parameterSpan: "str: string", }, { marker: "functionCall2", text: "functionCall(str: string, num: number): void", parameterName: "num", parameterSpan: "num: number", }, );
{ "end_byte": 584, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpSimpleFunctionCall.ts" }
TypeScript/tests/cases/fourslash/jsdocThrowsTag_findAllReferences.ts_0_166
/// <reference path="fourslash.ts" /> ////class /**/E extends Error {} /////** //// * @throws {E} //// */ ////function f() {} verify.baselineFindAllReferences("");
{ "end_byte": 166, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocThrowsTag_findAllReferences.ts" }
TypeScript/tests/cases/fourslash/commentsExternalModulesFourslash.ts_0_3701
/// <reference path='fourslash.ts' /> // @Filename: commentsExternalModules_file0.ts /////** Namespace comment*/ ////export namespace m/*1*/1 { //// /** b's comment*/ //// export var b: number; //// /** foo's comment*/ //// function foo() { //// return /*2*/b; //// } //// /** m2 comments*/ //// export namespace m2 { //// /** class comment;*/ //// export class c { //// }; //// /** i*/ //// export var i = new c(); //// } //// /** exported function*/ //// export function fooExport() { //// return f/*3q*/oo(/*3*/); //// } ////} /////*4*/m1./*5*/fooEx/*6q*/port(/*6*/); ////var my/*7*/var = new m1.m2./*8*/c(); // @Filename: commentsExternalModules_file1.ts /////**This is on import declaration*/ ////import ex/*9*/tMod = require("./commentsExternalModules_file0"); /////*10*/extMod./*11*/m1./*12*/fooExp/*13q*/ort(/*13*/); ////var new/*14*/Var = new extMod.m1.m2./*15*/c(); goTo.file("commentsExternalModules_file0.ts"); verify.quickInfoAt("1", "namespace m1", "Namespace comment"); verify.completions({ marker: "2", includes: [ { name: "b", text: "var b: number", documentation: "b's comment" }, { name: "foo", text: "function foo(): number", documentation: "foo's comment" }, ] }); verify.signatureHelp({ marker: "3", docComment: "foo's comment" }); verify.quickInfoAt("3q", "function foo(): number", "foo's comment"); verify.completions({ marker: "4", includes: { name: "m1", text: "namespace m1", documentation: "Namespace comment" }, }); verify.completions({ marker: "5", includes: [ { name: "b", text: "var m1.b: number", documentation: "b's comment" }, { name: "fooExport", text: "function m1.fooExport(): number", documentation: "exported function" }, { name: "m2", text: "namespace m1.m2", documentation: "m2 comments" }, ], }); verify.signatureHelp({ marker: "6", docComment: "exported function" }); verify.quickInfoAt("6q", "function m1.fooExport(): number", "exported function"); verify.quickInfoAt("7", "var myvar: m1.m2.c"); verify.completions({ marker: "8", includes: [ { name: "c", text: "constructor m1.m2.c(): m1.m2.c", documentation: "class comment;" }, { name: "i", text: "var m1.m2.i: m1.m2.c", documentation: "i" }, ], }); goTo.file("commentsExternalModules_file1.ts"); verify.quickInfoAt("9", 'import extMod = require("./commentsExternalModules_file0")', "This is on import declaration"); verify.completions( { marker: "10", includes: { name: "extMod", text: 'import extMod = require("./commentsExternalModules_file0")', documentation: "This is on import declaration" }, }, { marker: "11", includes: { name: "m1", text: "namespace extMod.m1", documentation: "Namespace comment" }, }, { marker: "12", includes: [ { name: "b", text: "var extMod.m1.b: number", documentation: "b's comment" }, { name: "fooExport", text: "function extMod.m1.fooExport(): number", documentation: "exported function" }, { name: "m2", text: "namespace extMod.m1.m2", documentation: "m2 comments" }, ], }, ); verify.signatureHelp({ marker: "13", docComment: "exported function" }); verify.quickInfoAt("13q", "function extMod.m1.fooExport(): number", "exported function"); verify.quickInfoAt("14", "var newVar: extMod.m1.m2.c"); verify.completions({ marker: "15", exact: [ { name: "c", text: "constructor extMod.m1.m2.c(): extMod.m1.m2.c", documentation: "class comment;" }, { name: "i", text: "var extMod.m1.m2.i: extMod.m1.m2.c", documentation: "i" }, ], });
{ "end_byte": 3701, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/commentsExternalModulesFourslash.ts" }
TypeScript/tests/cases/fourslash/autoImportsWithRootDirsAndRootedPath01.ts_0_485
/// <reference path="./fourslash.ts" /> // @Filename: /dir/foo.ts //// export function foo() {} // @Filename: /dir/bar.ts //// /*$*/ // @Filename: /dir/tsconfig.json ////{ //// "compilerOptions": { //// "module": "amd", //// "moduleResolution": "classic", //// "rootDirs": ["D:/"] //// } ////} goTo.marker("$"); verify.completions({ preferences: { includeCompletionsForModuleExports: true, allowIncompleteCompletions: true, } });
{ "end_byte": 485, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportsWithRootDirsAndRootedPath01.ts" }
TypeScript/tests/cases/fourslash/jsDocPropertyDescription7.ts_0_337
///<reference path="fourslash.ts" /> //// class StringClass { //// /** Something generic */ //// static [p: string]: any; //// } //// function stringClass(e: typeof StringClass) { //// console.log(e./*stringClass*/anything); //// } verify.quickInfoAt("stringClass", "(index) StringClass[string]: any", "Something generic");
{ "end_byte": 337, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocPropertyDescription7.ts" }
TypeScript/tests/cases/fourslash/commentBraceCompletionPosition.ts_3_948
/ <reference path="fourslash.ts" /> //// /** //// * inside jsdoc /*1*/ //// */ //// function f() { //// // inside regular comment /*2*/ //// var c = ""; //// //// /*3*//* inside /*4*/multi- //// line comment /*5*/ //// */ //// var y =12; //// } goTo.marker('1'); verify.isValidBraceCompletionAtPosition('('); verify.not.isValidBraceCompletionAtPosition('"'); verify.not.isValidBraceCompletionAtPosition(`'`); verify.not.isValidBraceCompletionAtPosition('`'); goTo.marker('2'); verify.isValidBraceCompletionAtPosition('('); verify.not.isValidBraceCompletionAtPosition('"'); goTo.marker('3'); verify.isValidBraceCompletionAtPosition('('); verify.isValidBraceCompletionAtPosition('"'); goTo.marker('4'); verify.isValidBraceCompletionAtPosition('('); verify.not.isValidBraceCompletionAtPosition('"'); goTo.marker('5'); verify.isValidBraceCompletionAtPosition('('); verify.not.isValidBraceCompletionAtPosition('"');
{ "end_byte": 948, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/commentBraceCompletionPosition.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingEnumMember9.ts_0_322
/// <reference path='fourslash.ts' /> ////enum E { //// a, //// b = 1, //// c = "123" ////} ////enum A { //// a = E.a ////} ////A.b verify.codeFix({ description: "Add missing enum member 'b'", newFileContent: `enum E { a, b = 1, c = "123" } enum A { a = E.a, b } A.b` });
{ "end_byte": 322, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingEnumMember9.ts" }
TypeScript/tests/cases/fourslash/completionListStringParenthesizedExpression.ts_0_876
/// <reference path='fourslash.ts'/> ////const foo = { //// a: 1, //// b: 1, //// c: 1 ////} ////const a = foo["[|/*1*/|]"]; ////const b = foo[("[|/*2*/|]")]; ////const c = foo[(("[|/*3*/|]"))]; const [r1, r2, r3] = test.ranges(); verify.completions( { marker: "1", exact: [ { name: "a", replacementSpan: r1 }, { name: "b", replacementSpan: r1 }, { name: "c", replacementSpan: r1 } ] }, { marker: "2", exact: [ { name: "a", replacementSpan: r2 }, { name: "b", replacementSpan: r2 }, { name: "c", replacementSpan: r2 } ] }, { marker: "3", exact: [ { name: "a", replacementSpan: r3 }, { name: "b", replacementSpan: r3 }, { name: "c", replacementSpan: r3 } ] } );
{ "end_byte": 876, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListStringParenthesizedExpression.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl1.ts_0_540
/// <reference path="fourslash.ts" /> // @Filename: /tsconfig.json ////{ //// "compilerOptions": { //// "baseUrl": "./a" //// } ////} // @Filename: /a/b/x.ts ////export function f1() { }; // @Filename: /a/b/y.ts ////[|f1/*0*/();|] goTo.file("/a/b/y.ts"); // Use the local import because it's simpler. verify.importFixAtPosition([ `import { f1 } from "./x"; f1();`, ]); verify.importFixAtPosition([ `import { f1 } from "b/x"; f1();`, ], /*errorCode*/ undefined, { importModuleSpecifierPreference: "non-relative", });
{ "end_byte": 540, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl1.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteral_quotePreference3.ts_0_341
/// <reference path='fourslash.ts'/> ////const a = { //// "#": "a" ////}; ////a[|./**/|] verify.completions({ marker: "", includes: [ { name: "#", insertText: '["#"]', replacementSpan: test.ranges()[0] }, ], preferences: { includeInsertTextCompletions: true, quotePreference: "double" }, });
{ "end_byte": 341, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral_quotePreference3.ts" }
TypeScript/tests/cases/fourslash/tsxFindAllReferencesUnionElementType1.ts_3_575
/ <reference path='fourslash.ts' /> //@Filename: file.tsx // @jsx: preserve // @noLib: true //// declare module JSX { //// interface Element { } //// interface IntrinsicElements { //// } //// interface ElementAttributesProperty { props; } //// } //// function SFC1(prop: { x: number }) { //// return <div>hello </div>; //// }; //// function SFC2(prop: { x: boolean }) { //// return <h1>World </h1>; //// } //// /*1*/var /*2*/SFCComp = SFC1 || SFC2; //// /*3*/</*4*/SFCComp x={ "hi" } /> verify.baselineFindAllReferences('1', '2', '3', '4');
{ "end_byte": 575, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxFindAllReferencesUnionElementType1.ts" }
TypeScript/tests/cases/fourslash/codeFixSpellingJs2.ts_0_303
/// <reference path='fourslash.ts' /> // @allowjs: true // @noEmit: true // @filename: a.js //// export var inModule = 1 //// [|inmodule|].toFixed() verify.codeFix({ description: "Change spelling to 'inModule'", index: 0, newFileContent: `export var inModule = 1 inModule.toFixed()`, });
{ "end_byte": 303, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingJs2.ts" }
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts_0_714
/// <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 `${ undefined } ${ undefined } ${/*1*/ 10/*2*/./*3*/01 /*4*/} ` verify.signatureHelp({ marker: test.markers(), overloadsCount: 3, text: "f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string", argumentCount: 4, parameterCount: 4, parameterName: "p3_o2", parameterSpan: "p3_o2: number", });
{ "end_byte": 714, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts" }
TypeScript/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_02.ts_0_480
/// <reference path='fourslash.ts'/> // Should go to implementation of properties that are assigned to implementations of an interface using shorthand notation //// interface Foo { //// hello(): void; //// } //// //// function createFoo(): Foo { //// return { //// hello //// }; //// //// function [|hello|]() {} //// } //// //// function whatever(x: Foo) { //// x.h/*function_call*/ello(); //// } verify.baselineGoToImplementation("function_call");
{ "end_byte": 480, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_02.ts" }
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc12.ts_0_361
/// <reference path='fourslash.ts' /> ////class C { //// /** //// * @return {...*} //// */ //// m(x) { //// return [x]; //// } ////} verify.codeFix({ description: "Annotate with type from JSDoc", index: 0, newFileContent: `class C { /** * @return {...*} */ m(x): any[] { return [x]; } }`, });
{ "end_byte": 361, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc12.ts" }
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classExpressionGoodUsages.ts_0_640
/// <reference path='fourslash.ts' /> ////const c = class C { //// static a: number = 2; //// /*a*/constructor/*b*/(a: number, b: number) { } ////} ////const a = new c(0, 1); ////const b = c.a; ////c["a"] = 3; 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: `const c = class C { static a: number = 2; constructor({ a, b }: { a: number; b: number; }) { } } const a = new c({ a: 0, b: 1 }); const b = c.a; c["a"] = 3;` });
{ "end_byte": 640, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classExpressionGoodUsages.ts" }
TypeScript/tests/cases/fourslash/completionsClassMemberImportTypeNodeParameter4.ts_0_749
/// <reference path="fourslash.ts" /> // @module: nodenext // @FileName: /other/cls.d.ts //// export declare class Cls { //// method( //// param: import("./doesntexist.js").Foo, //// ): import("./doesntexist.js").Foo; //// } // @FileName: /index.d.ts //// import { Cls } from "./other/cls.js"; //// //// export declare class Derived extends Cls { //// /*1*/ //// } verify.completions({ marker: "1", includes: [ { name: "method", insertText: `method(param: import("./doesntexist.js").Foo);`, filterText: "method", hasAction: undefined, }, ], preferences: { includeCompletionsWithClassMemberSnippets: true, includeCompletionsWithInsertText: true, }, isNewIdentifierLocation: true, });
{ "end_byte": 749, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsClassMemberImportTypeNodeParameter4.ts" }
TypeScript/tests/cases/fourslash/toggleLineComment7.ts_0_735
// Common comment line cases. //@Filename: file.tsx //// const a = <MyContainer> //// [|<MyFirstComponent /> //// <MySecondComponent />|] //// </MyContainer>; //// const b = <MyContainer> //// {/*<MyF[|irstComponent />*/} //// {/*<MySec|]ondComponent />*/} //// </MyContainer>; //// const c = <MyContainer>[| //// <MyFirstComponent /> //// <MySecondCompo|]nent /> //// </MyContainer>; verify.toggleLineComment( `const a = <MyContainer> {/*<MyFirstComponent />*/} {/*<MySecondComponent />*/} </MyContainer>; const b = <MyContainer> <MyFirstComponent /> <MySecondComponent /> </MyContainer>; //const c = <MyContainer> // <MyFirstComponent /> // <MySecondComponent /> </MyContainer>;`);
{ "end_byte": 735, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/toggleLineComment7.ts" }
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodOverrides.ts_0_1102
/// <reference path='fourslash.ts' /> ////class A { //// /*a*/foo/*b*/(a: number, b: number) { } ////} ////class B extends A { //// /*c*/foo/*d*/(c: number, d: number) { } ////} ////var a = new A(); ////a.foo(3, 4); ////var b = new B(); ////b.foo(5, 6); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert parameters to destructured object", actionName: "Convert parameters to destructured object", actionDescription: "Convert parameters to destructured object", newContent: `class A { foo(a: number, b: number) { } } class B extends A { foo(c: number, d: number) { } } var a = new A(); a.foo(3, 4); var b = new B(); b.foo(5, 6);` }); goTo.select("c", "d"); edit.applyRefactor({ refactorName: "Convert parameters to destructured object", actionName: "Convert parameters to destructured object", actionDescription: "Convert parameters to destructured object", newContent: `class A { foo(a: number, b: number) { } } class B extends A { foo(c: number, d: number) { } } var a = new A(); a.foo(3, 4); var b = new B(); b.foo(5, 6);` });
{ "end_byte": 1102, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodOverrides.ts" }
TypeScript/tests/cases/fourslash/findAllRefsRenameImportWithSameName.ts_0_531
/// <reference path="fourslash.ts" /> // @Filename: /a.ts ////[|export const /*0*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|] //@Filename: /b.ts ////[|import { /*1*/[|{| "contextRangeIndex": 2 |}x|] as /*2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|] } from "./a";|] /////*3*/[|x|]; verify.noErrors(); const [r0Def, r0, r1Def, r1, r2, r3] = test.ranges(); verify.baselineFindAllReferences('0', '1', '2', '3'); verify.baselineRename([r0, r1, r2, r3]);
{ "end_byte": 531, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsRenameImportWithSameName.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportRootDirs1.ts_0_359
/// <reference path="fourslash.ts" /> // @Filename: a/f1.ts //// [|foo/*0*/();|] // @Filename: a/b/index.ts //// export function foo() {}; // @Filename: tsconfig.json //// { //// "compilerOptions": { //// "rootDirs": [ //// "a" //// ] //// } //// } verify.importFixAtPosition([ `import { foo } from "./b"; foo();` ]);
{ "end_byte": 359, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportRootDirs1.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesReadonly2.ts_0_131
/// <reference path="fourslash.ts" /> ////type T = { //// [|readonly|] prop: string; ////} verify.baselineDocumentHighlights();
{ "end_byte": 131, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesReadonly2.ts" }
TypeScript/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames7.ts_0_150
/// <reference path='fourslash.ts' /> /////*1*/function /*2*/__foo() { //// /*3*/__foo(); ////} verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 150, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames7.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringAssignmentForObjectBindingPatternDefaultValues.ts_0_5645
/// <reference path='fourslash.ts' /> ////declare var console: { //// log(msg: any): void; ////} ////interface Robot { //// name: string; //// skill: string; ////} ////interface MultiRobot { //// name: string; //// skills: { //// primary?: string; //// secondary?: string; //// }; ////} ////let robot: Robot = { name: "mower", skill: "mowing" }; ////let multiRobot: MultiRobot = { name: "mower", skills: { primary: "mowing", secondary: "none" } }; ////function getRobot() { //// return robot; ////} ////function getMultiRobot() { //// return multiRobot; ////} ////let nameA: string, primaryA: string, secondaryA: string, i: number, skillA: string; ////let name: string, primary: string, secondary: string, skill: string; ////for ({name: nameA = "noName" } = robot, i = 0; i < 1; i++) { //// console.log(nameA); ////} ////for ({name: nameA = "noName" } = getRobot(), i = 0; i < 1; i++) { //// console.log(nameA); ////} ////for ({name: nameA = "noName" } = <Robot>{ name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) { //// console.log(nameA); ////} ////for ({ //// skills: { //// primary: primaryA = "primary", //// secondary: secondaryA = "secondary" //// } = { primary: "none", secondary: "none" } ////} = multiRobot, i = 0; i < 1; i++) { //// console.log(primaryA); ////} ////for ({ //// skills: { //// primary: primaryA = "primary", //// secondary: secondaryA = "secondary" //// } = { primary: "none", secondary: "none" } ////} = getMultiRobot(), i = 0; i < 1; i++) { //// console.log(primaryA); ////} ////for ({ //// skills: { //// primary: primaryA = "primary", //// secondary: secondaryA = "secondary" //// } = { primary: "none", secondary: "none" } ////} = <MultiRobot>{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, //// i = 0; i < 1; i++) { //// console.log(primaryA); ////} ////for ({ name = "noName" } = robot, i = 0; i < 1; i++) { //// console.log(nameA); ////} ////for ({ name = "noName" } = getRobot(), i = 0; i < 1; i++) { //// console.log(nameA); ////} ////for ({ name = "noName" } = <Robot>{ name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) { //// console.log(nameA); ////} ////for ({ //// skills: { //// primary = "primary", //// secondary = "secondary" //// } = { primary: "none", secondary: "none" } ////} = multiRobot, i = 0; i < 1; i++) { //// console.log(primaryA); ////} ////for ({ //// skills: { //// primary = "primary", //// secondary = "secondary" //// } = { primary: "none", secondary: "none" } ////} = getMultiRobot(), i = 0; i < 1; i++) { //// console.log(primaryA); ////} ////for ({ //// skills: { //// primary = "primary", //// secondary = "secondary" //// } = { primary: "none", secondary: "none" } ////} = <MultiRobot>{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, //// i = 0; i < 1; i++) { //// console.log(primaryA); ////} ////for ({name: nameA = "noName", skill: skillA = "skill" } = robot, i = 0; i < 1; i++) { //// console.log(nameA); ////} ////for ({name: nameA = "noName", skill: skillA = "skill" } = getRobot(), i = 0; i < 1; i++) { //// console.log(nameA); ////} ////for ({name: nameA = "noName", skill: skillA = "skill" } = <Robot>{ name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) { //// console.log(nameA); ////} ////for ({ //// name: nameA = "noName", //// skills: { //// primary: primaryA = "primary", //// secondary: secondaryA = "secondary" //// } = { primary: "none", secondary: "none" } ////} = multiRobot, i = 0; i < 1; i++) { //// console.log(primaryA); ////} ////for ({ //// name: nameA = "noName", //// skills: { //// primary: primaryA = "primary", //// secondary: secondaryA = "secondary" //// } = { primary: "none", secondary: "none" } ////} = getMultiRobot(), i = 0; i < 1; i++) { //// console.log(primaryA); ////} ////for ({ //// name: nameA = "noName", //// skills: { //// primary: primaryA = "primary", //// secondary: secondaryA = "secondary" //// } = { primary: "none", secondary: "none" } ////} = <MultiRobot>{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, //// i = 0; i < 1; i++) { //// console.log(primaryA); ////} ////for ({ name = "noName", skill = "skill" } = robot, i = 0; i < 1; i++) { //// console.log(nameA); ////} ////for ({ name = "noName", skill = "skill" } = getRobot(), i = 0; i < 1; i++) { //// console.log(nameA); ////} ////for ({ name = "noName", skill = "skill" } = <Robot>{ name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) { //// console.log(nameA); ////} ////for ({ //// name = "noName", //// skills: { //// primary = "primary", //// secondary = "secondary" //// } = { primary: "none", secondary: "none" } ////} = multiRobot, i = 0; i < 1; i++) { //// console.log(primaryA); ////} ////for ({ //// name = "noName", //// skills: { //// primary = "primary", //// secondary = "secondary" //// } = { primary: "none", secondary: "none" } ////} = getMultiRobot(), i = 0; i < 1; i++) { //// console.log(primaryA); ////} ////for ({ //// name = "noName", //// skills: { //// primary = "primary", //// secondary = "secondary" //// } = { primary: "none", secondary: "none" } ////} = <MultiRobot>{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, //// i = 0; i < 1; i++) { //// console.log(primaryA); ////} verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 5645, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringAssignmentForObjectBindingPatternDefaultValues.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_typeOnly3.ts_0_888
/// <reference path="fourslash.ts" /> // @module: esnext // @verbatimModuleSyntax: true // @Filename: Presenter.ts //// export type DisplayStyle = "normal" | "compact"; //// //// export default class Presenter { //// present(displayStyle: DisplayStyle): Element { //// return document.createElement("placeholder"); //// } //// } // @Filename: index.ts //// import type Presenter from "./Presenter"; //// //// function present( //// presenter: Presenter, //// displayStyle: DisplayStyle, //// ) {} goTo.file("index.ts"); verify.codeFix({ errorCode: ts.Diagnostics.Cannot_find_name_0.code, description: ignoreInterpolations(ts.Diagnostics.Add_import_from_0), newFileContent: `import type { DisplayStyle } from "./Presenter"; import type Presenter from "./Presenter"; function present( presenter: Presenter, displayStyle: DisplayStyle, ) {}` });
{ "end_byte": 888, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_typeOnly3.ts" }
TypeScript/tests/cases/fourslash/inlayHintsParameterNamesInSpan1.ts_0_826
/// <reference path="fourslash.ts" /> //// function foo1 (a: number, b: number) {} //// function foo2 (c: number, d: number) {} //// function foo3 (e: number, f: number) {} //// function foo4 (g: number, h: number) {} //// function foo5 (i: number, j: number) {} //// function foo6 (k: number, i: number) {} //// function c1 () { foo1(/*a*/1, /*b*/2); } //// function c2 () { foo2(/*c*/1, /*d*/2); } //// function c3 () { foo3(/*e*/1, /*f*/2); } //// function c4 () { foo4(/*g*/1, /*h*/2); } //// function c5 () { foo5(/*i*/1, /*j*/2); } //// function c6 () { foo6(/*k*/1, /*l*/2); } const start = test.markerByName('c'); const end = test.markerByName('h'); const span = { start: start.position, length: end.position - start.position }; verify.baselineInlayHints(span, { includeInlayParameterNameHints: "literals", })
{ "end_byte": 826, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsParameterNamesInSpan1.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageJS.ts_0_308
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @noImplicitAny: true // @Filename: test.js ////[|var foo;|] ////function f() { //// foo += 2; ////} verify.rangeAfterCodeFix("/**\n * @type {number}\n*/\nvar foo;",/*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, 0);
{ "end_byte": 308, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageJS.ts" }
TypeScript/tests/cases/fourslash/smartIndentActualIndentation.ts_0_278
/// <reference path='fourslash.ts'/> //// class A { //// /*1*/ //// } ////module M { //// class C { //// /*2*/ //// } ////} goTo.marker("1"); verify.indentationIs(12); goTo.marker("2"); verify.indentationIs(16);
{ "end_byte": 278, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentActualIndentation.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDocTags8.ts_0_319
/// <reference path="fourslash.ts" /> // @noEmit: true // @allowJs: true // @Filename: quickInfoJsDocTags8.js /////** //// * @typedef {{ [x: string]: any, y: number }} Foo //// */ //// /////** //// * @type {(t: T) => number} //// * @template {Foo} T //// */ ////const /**/foo = t => t.y; verify.baselineQuickInfo();
{ "end_byte": 319, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTags8.ts" }
TypeScript/tests/cases/fourslash/codeFixExpectedComma03.ts_0_150
/// <reference path='fourslash.ts' /> ////class C { //// const example = [|{ one: 1 one }|] ////} verify.not.codeFixAvailable("fixExpectedComma")
{ "end_byte": 150, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixExpectedComma03.ts" }
TypeScript/tests/cases/fourslash/ambientShorthandFindAllRefs.ts_0_357
/// <reference path='fourslash.ts' /> // @Filename: declarations.d.ts ////declare module "jquery"; // @Filename: user.ts ////import {/*1*/x} from "jquery"; // @Filename: user2.ts ////import {/*2*/x} from "jquery"; // TODO: Want these to be in the same group, but that would require creating a symbol for `x`. verify.baselineFindAllReferences('1', '2');
{ "end_byte": 357, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/ambientShorthandFindAllRefs.ts" }
TypeScript/tests/cases/fourslash/unusedMethodInClass6.ts_0_234
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true ////class C { //// private "string" (){} ////} verify.codeFix({ description: `Remove unused declaration for: '"string"'`, newFileContent: "class C {\n}", });
{ "end_byte": 234, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedMethodInClass6.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports3.ts_0_500
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true ////const a = 42; ////const b = 42; ////export class C { //// //making sure comments are not changed //// property =a+b; // comment should stay here ////} verify.codeFix({ description: "Add annotation of type 'number'", index: 0, newFileContent: `const a = 42; const b = 42; export class C { //making sure comments are not changed property: number =a+b; // comment should stay here }`, });
{ "end_byte": 500, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports3.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceAuto1.ts_0_712
/// <reference path='fourslash.ts' /> // @filename: a.ts ////export interface I { //// a(): void; //// b(x: "x", y: "a" | "b"): "b"; //// //// c: "c"; //// d: { e: "e"; }; ////} // @filename: b.ts ////import { I } from "./a"; ////class Foo implements I {} goTo.file("b.ts") verify.codeFix({ description: [ts.Diagnostics.Implement_interface_0.message, "I"], index: 0, newFileContent: `import { I } from "./a"; class Foo implements I { a(): void { throw new Error("Method not implemented."); } b(x: "x", y: "a" | "b"): "b" { throw new Error("Method not implemented."); } c: "c"; d: { e: "e"; }; }`, preferences: { quotePreference: "auto" } });
{ "end_byte": 712, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceAuto1.ts" }
TypeScript/tests/cases/fourslash/jsxAttributeCompletionStyleAuto.ts_0_2431
/// <reference path="fourslash.ts" /> // @Filename: foo.tsx //// declare namespace JSX { //// interface Element { } //// interface IntrinsicElements { //// foo: { //// prop_a: boolean; //// prop_b: string; //// prop_c: any; //// prop_d: { p1: string; } //// prop_e: string | undefined; //// prop_f: boolean | undefined | { p1: string; }; //// prop_g: { p1: string; } | undefined; //// prop_h?: string; //// prop_i?: boolean; //// prop_j?: { p1: string; }; //// prop_string_literal_union?: 'input' | 'password' | (string & {}) //// } //// } //// } //// //// <foo [|prop_/**/|] /> verify.completions({ marker: "", exact: [ { name: "prop_a", isSnippet: undefined, }, { name: "prop_b", insertText: "prop_b=\"$1\"", isSnippet: true, }, { name: "prop_c", insertText: "prop_c={$1}", isSnippet: true, }, { name: "prop_d", insertText: "prop_d={$1}", isSnippet: true, }, { name: "prop_e", insertText: "prop_e=\"$1\"", isSnippet: true, }, { name: "prop_f", isSnippet: undefined, }, { name: "prop_g", insertText: "prop_g={$1}", isSnippet: true, }, { name: "prop_h", insertText: "prop_h=\"$1\"", isSnippet: true, sortText: completion.SortText.OptionalMember, }, { name: "prop_i", isSnippet: undefined, sortText: completion.SortText.OptionalMember, }, { name: "prop_j", insertText: "prop_j={$1}", isSnippet: true, sortText: completion.SortText.OptionalMember, }, { name: "prop_string_literal_union", insertText: "prop_string_literal_union=\"$1\"", isSnippet: true, sortText: completion.SortText.OptionalMember, } ], preferences: { jsxAttributeCompletionStyle: "auto", includeCompletionsWithSnippetText: true, includeCompletionsWithInsertText: true, } });
{ "end_byte": 2431, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsxAttributeCompletionStyleAuto.ts" }
TypeScript/tests/cases/fourslash/autoImportTypeImport5.ts_0_3485
/// <reference path="fourslash.ts" /> // @verbatimModuleSyntax: true // @target: esnext // @Filename: /exports1.ts //// export const a = 0; //// export const A = 1; //// export const b = 2; //// export const B = 3; //// export const c = 4; //// export const C = 5; //// export type x = 6; //// export const X = 7; //// export type y = 8 //// export const Y = 9; //// export const Z = 10; // @Filename: /exports2.ts //// export const d = 0; //// export const D = 1; //// export const e = 2; //// export const E = 3; // @Filename: /index0.ts //// import { type X, type Y, type Z } from "./exports1"; //// const foo: x/*0*/; //// const bar: y; // @Filename: /index1.ts //// import { A, B, type X, type Y, type Z } from "./exports1"; //// const foo: x/*1*/; //// const bar: y; // addition of correctly sorted regular imports should not affect correctly sorted type imports goTo.marker("0"); verify.importFixAtPosition([ `import { type x, type X, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, `import { type X, type y, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, ], /*errorCode*/ undefined, { organizeImportsTypeOrder : "last" }); verify.importFixAtPosition([ `import { type x, type X, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, `import { type X, type y, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, ], /*errorCode*/ undefined, { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "last" }); verify.importFixAtPosition([ `import { type x, type X, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, `import { type X, type y, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, ], /*errorCode*/ undefined, { organizeImportsTypeOrder : "inline" }); verify.importFixAtPosition([ `import { type x, type X, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, `import { type X, type y, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, ], /*errorCode*/ undefined, { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "inline" }); verify.importFixAtPosition([ `import { type x, type X, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, `import { type X, type y, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, ], /*errorCode*/ undefined, { organizeImportsTypeOrder : "first" }); verify.importFixAtPosition([ `import { type x, type X, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, `import { type X, type y, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, ], /*errorCode*/ undefined, { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "first" }); goTo.marker("1"); verify.importFixAtPosition([ `import { A, B, type x, type X, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, `import { A, B, type X, type y, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, ], /*errorCode*/ undefined, { organizeImportsTypeOrder : "last" }); verify.importFixAtPosition([ `import { A, B, type x, type X, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, `import { A, B, type X, type y, type Y, type Z } from "./exports1";\nconst foo: x;\nconst bar: y;`, ], /*errorCode*/ undefined, { organizeImportsIgnoreCase: true, organizeImportsTypeOrder : "last" });
{ "end_byte": 3485, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportTypeImport5.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports48.ts_0_1284
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true // @moduleResolution: node // @target: es2018 // @jsx: react-jsx // @filename: node_modules/react/package.json ////{ //// "name": "react", //// "types": "index.d.ts", ////} // @filename: node_modules/react/index.d.ts ////export = React; ////declare namespace JSX { //// interface Element extends GlobalJSXElement { } //// interface IntrinsicElements extends GlobalJSXIntrinsicElements { } ////} ////declare namespace React { } ////declare global { //// namespace JSX { //// interface Element { } //// interface IntrinsicElements { [x: string]: any; } //// } ////} ////interface GlobalJSXElement extends JSX.Element {} ////interface GlobalJSXIntrinsicElements extends JSX.IntrinsicElements {} // @filename: node_modules/react/jsx-runtime.d.ts ////import './'; // @filename: node_modules/react/jsx-dev-runtime.d.ts ////import './'; // @filename: /a.tsx ////export const x = <div aria-label="label text" />; goTo.file("/a.tsx"); verify.codeFix({ description: `Add satisfies and an inline type assertion with 'JSX.Element'`, index: 1, newFileContent: 'export const x = (<div aria-label="label text" />) satisfies JSX.Element as JSX.Element;', });
{ "end_byte": 1284, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports48.ts" }
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives3.ts_0_200
/// <reference path='fourslash.ts' /> //// function foo(strs, ...rest) { //// } //// //// /*1*/fo/*2*/o /*3*/`abcd${0 + 1}abcd{1 + 1}abcd`/*4*/ /*5*/ verify.noSignatureHelp(...test.markerNames());
{ "end_byte": 200, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives3.ts" }
TypeScript/tests/cases/fourslash/typeOperatorNodeBuilding.ts_0_635
/// <reference path='fourslash.ts'/> // @Filename: keyof.ts //// function doSomethingWithKeys<T>(...keys: (keyof T)[]) { } //// //// const /*1*/utilityFunctions = { //// doSomethingWithKeys //// }; // @Filename: typeof.ts //// class Foo { static a: number; } //// function doSomethingWithTypes(...statics: (typeof Foo)[]) {} //// //// const /*2*/utilityFunctions = { //// doSomethingWithTypes //// }; verify.quickInfos({ 1: "const utilityFunctions: {\n doSomethingWithKeys: <T>(...keys: (keyof T)[]) => void;\n}", 2: "const utilityFunctions: {\n doSomethingWithTypes: (...statics: (typeof Foo)[]) => void;\n}" });
{ "end_byte": 635, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/typeOperatorNodeBuilding.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingConstInForOfLoop1.ts_0_182
/// <reference path='fourslash.ts' /> ////for (x of []) {} verify.codeFix({ description: "Add 'const' to unresolved variable", newFileContent: "for (const x of []) {}" });
{ "end_byte": 182, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingConstInForOfLoop1.ts" }
TypeScript/tests/cases/fourslash/completionListInTypeLiteralInTypeParameter6.ts_0_309
/// <reference path="fourslash.ts" /> ////interface Foo { //// one: string; //// two: number; ////} //// ////interface Bar<T extends Foo> { //// foo: T; ////} //// ////var foobar: Bar<{ one: string } | {/**/ verify.completions({ marker: "", exact: ["one", "two"], isNewIdentifierLocation: true });
{ "end_byte": 309, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInTypeLiteralInTypeParameter6.ts" }
TypeScript/tests/cases/fourslash/completionListAtDeclarationOfParameterType.ts_0_254
/// <reference path='fourslash.ts'/> ////module Bar { //// export class Bleah { //// } //// export class Foo extends Bleah { //// } ////} //// ////function Blah(x: /**/Bar.Bleah) { ////} verify.completions({ marker: "", includes: "Bar" });
{ "end_byte": 254, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtDeclarationOfParameterType.ts" }
TypeScript/tests/cases/fourslash/quickInfoSignatureRestParameterFromUnion2.ts_0_398
/// <reference path='fourslash.ts'/> // https://github.com/microsoft/TypeScript/issues/55574 //// declare const rest: //// | ((a?: { a: true }, ...rest: string[]) => unknown) //// | ((b?: { b: true }) => unknown); //// //// /**/rest({ a: true, b: true }, "foo", "bar"); verify.quickInfoAt( "", `const rest: (arg0?: { a: true; } & { b: true; }, ...rest: string[]) => unknown`, );
{ "end_byte": 398, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoSignatureRestParameterFromUnion2.ts" }
TypeScript/tests/cases/fourslash/findAllReferencesJSDocFunctionThis.ts_0_314
///<reference path="fourslash.ts" /> // @allowJs: true // @Filename: Foo.js /////** @type {function (this: string, string): string} */ ////var f = function (s) { return /*0*/this + s; } // NOTE: '0' should refer to both `this` and `s`, // but currently only refers to `this` verify.baselineFindAllReferences('0')
{ "end_byte": 314, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesJSDocFunctionThis.ts" }