_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/renameLabel3.ts_0_231
/// <reference path="fourslash.ts" /> /////**/loop: ////for (let i = 0; i <= 10; i++) { //// if (i === 0) continue loop; //// if (i === 1) continue loop; //// if (i === 10) break loop; ////} verify.baselineRename("", {});
{ "end_byte": 231, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameLabel3.ts" }
TypeScript/tests/cases/fourslash/completionsImport_default_reExport.ts_0_876
/// <reference path="fourslash.ts" /> // @module: commonjs // @allowJs: true // @Filename: /file1.js //// const a = 1; //// export { //// a as b //// }; //// export default a; // @Filename: /file2.js //// import * as foo from './file1'; //// /**/ //// export default foo.b; goTo.marker(""); verify.completions({ marker: "", exact: completion.globalsInJsPlus([ "foo", { name: "a", source: "./file1", sourceDisplay: "./file1", hasAction: true, sortText: completion.SortText.AutoImportSuggestions }, { name: "b", source: "./file1", sourceDisplay: "./file1", hasAction: true, sortText: completion.SortText.AutoImportSuggestions } ]), preferences: { includeCompletionsForModuleExports: true, allowIncompleteCompletions: true, }, });
{ "end_byte": 876, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_default_reExport.ts" }
TypeScript/tests/cases/fourslash/findAllReferencesImportMeta.ts_0_140
/// <reference path="fourslash.ts" /> ////// Haha that's so meta! //// ////let x = import.meta/**/; verify.baselineFindAllReferences("");
{ "end_byte": 140, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesImportMeta.ts" }
TypeScript/tests/cases/fourslash/renameImportOfExportEquals.ts_0_1248
/// <reference path='fourslash.ts' /> ////[|declare namespace /*N*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}N|] { //// [|export var /*x*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|]: number;|] ////}|] ////declare module "mod" { //// [|export = [|{| "contextRangeIndex": 4 |}N|];|] ////} ////declare module "a" { //// [|import * as /*a*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}N|] from "mod";|] //// [|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 8 |}N|] };|] // Renaming N here would rename ////} ////declare module "b" { //// [|import { /*b*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 10 |}N|] } from "a";|] //// export const y: typeof [|N|].[|x|]; ////} const [N0Def, N0, x0Def, x0, N1Def, N1, a0Def, a0, a1Def, a1, b0Def, b0, b1, x1] = test.ranges(); const nRanges = [N0, N1]; const aRanges = [a0, a1]; const bRanges = [b0, b1]; const xRanges = [x0, x1]; verify.baselineFindAllReferences('N', 'a', 'b', 'x'); verify.baselineRename(nRanges); verify.baselineRename(a0); verify.baselineRename(a1); verify.baselineRename(bRanges); verify.baselineRename(xRanges);
{ "end_byte": 1248, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameImportOfExportEquals.ts" }
TypeScript/tests/cases/fourslash/referencesForStringLiteralPropertyNames2.ts_0_189
/// <reference path='fourslash.ts'/> ////class Foo { //// /*1*/"/*2*/blah"() { return 0; } ////} //// ////var x: Foo; ////x./*3*/blah; verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 189, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForStringLiteralPropertyNames2.ts" }
TypeScript/tests/cases/fourslash/extract-const_jsxElement1.ts_0_563
/// <reference path='fourslash.ts' /> // @jsx: preserve // @filename: a.tsx ////function Foo() { //// return ( //// <div> //// /*a*/<span></span>/*b*/ //// </div> //// ); ////} goTo.file("a.tsx"); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "constant_scope_1", actionDescription: "Extract to constant in global scope", newContent: `const /*RENAME*/newLocal = <span></span>; function Foo() { return ( <div> {newLocal} </div> ); }` });
{ "end_byte": 563, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const_jsxElement1.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType75.ts_0_272
/// <reference path='fourslash.ts' /> // @Filename: a.ts //// interface Foo<T extends { prop: T }> {} //// interface Foo<T extends { prop: /*a*/T/*b*/ }> {} goTo.file("a.ts"); goTo.select("a", "b"); verify.not.refactorAvailable("Extract type", "Extract to type alias");
{ "end_byte": 272, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType75.ts" }
TypeScript/tests/cases/fourslash/completionListOfUnion.ts_0_774
/// <reference path='fourslash.ts' /> // @strictNullChecks: true // Primitives should be skipped, so `| number | null | undefined` should have no effect on completions. ////const x: { a: number, b: number } | { a: string, c: string } | { b: boolean } | number | null | undefined = { /*x*/ }; ////interface I { a: number; } ////function f(...args: Array<I | I[]>) {} ////f({ /*f*/ }); verify.completions( { marker: "x", exact: [ { name: "a", text: "(property) a: string | number" }, { name: "b", text: "(property) b: number | boolean" }, { name: "c", text: "(property) c: string"} , ], }, { marker: "f", includes: [{ name: "a", text: "(property) I.a: number" }] }, // Also contains array members );
{ "end_byte": 774, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListOfUnion.ts" }
TypeScript/tests/cases/fourslash/unclosedStringLiteralErrorRecovery2.ts_0_206
/// <reference path="fourslash.ts" /> ////function alpha() { //// //// var x = "x\ //// var y = 1; //// function beta() { } //// beta(; //// /**/ ////} verify.not.errorExistsAfterMarker();
{ "end_byte": 206, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unclosedStringLiteralErrorRecovery2.ts" }
TypeScript/tests/cases/fourslash/completionsImport_exportEquals_global.ts_0_720
/// <reference path="fourslash.ts" /> // @module: es6 // @Filename: /console.d.ts //// interface Console {} //// declare var console: Console; //// declare module "console" { //// export = console; //// } // @Filename: /react-native.d.ts //// import 'console'; //// declare global { //// interface Console {} //// var console: Console; //// } // @Filename: /a.ts ////conso/**/ verify.completions({ marker: "", exact: completion.globalsPlus([{ hasAction: undefined, // asserts that it does *not* have an action name: "console", sortText: completion.SortText.GlobalsOrKeywords, }]), preferences: { includeCompletionsForModuleExports: true, includeInsertTextCompletions: true } });
{ "end_byte": 720, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_exportEquals_global.ts" }
TypeScript/tests/cases/fourslash/completionListStaticMembers.ts_0_448
/// <reference path='fourslash.ts'/> ////class Foo { //// static a() {} //// static b() {} ////} ////Foo./**/ verify.completions({ marker: "", exact: completion.functionMembersPlus([ { name: "a", sortText: completion.SortText.LocalDeclarationPriority }, { name: "b", sortText: completion.SortText.LocalDeclarationPriority }, { name: "prototype", sortText: completion.SortText.LocationPriority }, ]), });
{ "end_byte": 448, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListStaticMembers.ts" }
TypeScript/tests/cases/fourslash/jsdocDeprecated_suggestion18.ts_0_515
///<reference path="fourslash.ts" /> // @jsx: preserve // @filename: foo.tsx ////interface Props { //// /** @deprecated */ //// x: number; //// y: number; ////} ////function A(props: Props) { //// return <div>{props.y}</div> ////} ////function B() { //// return <A [|x|]={1} [|y|]={1} /> ////} const [range] = test.ranges(); verify.getSuggestionDiagnostics([ { "code": 6385, "message": "'x' is deprecated.", "reportsDeprecated": true, "range": range }, ]);
{ "end_byte": 515, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocDeprecated_suggestion18.ts" }
TypeScript/tests/cases/fourslash/completionsImport_duplicatePackages_scoped.ts_0_1627
/// <reference path="fourslash.ts" /> // @module: commonjs // @esModuleInterop: true // @Filename: /node_modules/@scope/react-dom/package.json //// { "name": "react-dom", "version": "1.0.0", "types": "./index.d.ts" } // @Filename: /node_modules/@scope/react-dom/index.d.ts //// import * as React from "react"; //// export function render(): void; // @Filename: /node_modules/@scope/react/package.json //// { "name": "react", "version": "1.0.0", "types": "./index.d.ts" } // @Filename: /node_modules/@scope/react/index.d.ts //// import "./other"; //// export declare function useState(): void; // @Filename: /node_modules/@scope/react/other.d.ts //// export declare function useRef(): void; // @Filename: /packages/a/node_modules/@scope/react/package.json //// { "name": "react", "version": "1.0.1", "types": "./index.d.ts" } // @Filename: /packages/a/node_modules/@scope/react/index.d.ts //// export declare function useState(): void; // @Filename: /packages/a/index.ts //// import "@scope/react-dom"; //// import "@scope/react"; // @Filename: /packages/a/foo.ts //// /**/ goTo.marker(""); verify.completions({ marker: "", exact: completion.globalsPlus([{ name: "render", source: "@scope/react-dom", sourceDisplay: "@scope/react-dom", hasAction: true, sortText: completion.SortText.AutoImportSuggestions, }, { name: "useState", source: "@scope/react", sourceDisplay: "@scope/react", hasAction: true, sortText: completion.SortText.AutoImportSuggestions, }]), preferences: { includeCompletionsForModuleExports: true, allowIncompleteCompletions: true, }, });
{ "end_byte": 1627, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_duplicatePackages_scoped.ts" }
TypeScript/tests/cases/fourslash/autoImportRootDirs.ts_0_389
/// <reference path="fourslash.ts" /> // @Filename: /tsconfig.json //// { //// "compilerOptions": { //// "module": "commonjs", //// "rootDirs": [".", "./some/other/root"] //// } //// } // @Filename: /some/other/root/types.ts //// export type Something = {}; // @Filename: /index.ts //// const s: Something/**/ verify.importFixModuleSpecifiers("", ["./types"]);
{ "end_byte": 389, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportRootDirs.ts" }
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue22.ts_0_368
/// <reference path='fourslash.ts' /> //// interface A { //// a: () => number //// } //// //// function Foo (): A { //// return { //// a: () => { 1 } //// } //// } verify.codeFixAvailable([ { description: ts.Diagnostics.Add_a_return_statement.message }, { description: ts.Diagnostics.Remove_braces_from_arrow_function_body.message } ]);
{ "end_byte": 368, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue22.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts_0_1032
/// <reference path='fourslash.ts' /> ////var x = class C { //// public x; //// public y; //// public z; //// public staticX; //// constructor() { //// this; //// this.x; //// this.y; //// this.z; //// } //// foo() { //// this; //// () => this; //// () => { //// if (this) { //// this; //// } //// } //// function inside() { //// this; //// (function (_) { //// this; //// })(this); //// } //// return this.x; //// } //// //// static bar() { //// [|this|]; //// [|this|].staticX; //// () => [|this|]; //// () => { //// if ([|this|]) { //// [|this|]; //// } //// } //// function inside() { //// this; //// (function (_) { //// this; //// })(this); //// } //// } ////} verify.baselineDocumentHighlights();
{ "end_byte": 1032, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts" }
TypeScript/tests/cases/fourslash/completionsCommentsClass.ts_0_1243
/// <reference path='fourslash.ts' /> /////** This is class c2 without constructor*/ ////class c2 { ////} ////var i2 = new c2(); ////var i2_c = c2; ////class c3 { //// /** Constructor comment*/ //// constructor() { //// } ////} ////var i3 = new c3(); ////var i3_c = c3; /////** Class comment*/ ////class c4 { //// /** Constructor comment*/ //// constructor() { //// } ////} ////var i4 = new c4(); ////var i4_c = c4; /////** Class with statics*/ ////class c5 { //// static s1: number; ////} ////var i5 = new c5(); ////var i5_c = c5; /////** class with statics and constructor*/ ////class c6 { //// /** s1 comment*/ //// static s1: number; //// /** constructor comment*/ //// constructor() { //// } ////} ////var i6 = new c6(); ////var i6_c = c6; /////*26*/ ////class a { //// /** //// constructor for a //// @param a this is my a //// */ //// constructor(a: string) { //// } ////} ////new a("Hello"); ////module m { //// export module m2 { //// /** class comment */ //// export class c1 { //// /** constructor comment*/ //// constructor() { //// } //// } //// } ////} ////var myVar = new m.m2.c1(); verify.baselineCompletions()
{ "end_byte": 1243, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsCommentsClass.ts" }
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsModules.ts_0_479
/// <reference path='fourslash.ts'/> ////namespace /*1*/m { //// var /*2*/namespaceElemWithoutExport = 10; //// export var /*3*/namespaceElemWithExport = 10; ////} ////var /*4*/a = /*5*/m; ////var /*6*/b: typeof /*7*/m; ////namespace /*8*/m1./*9*/m2 { //// var /*10*/namespaceElemWithoutExport = 10; //// export var /*11*/namespaceElemWithExport = 10; ////} ////var /*12*/x = /*13*/m1./*14*/m2; ////var /*15*/y: typeof /*16*/m1./*17*/m2; verify.baselineQuickInfo();
{ "end_byte": 479, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsModules.ts" }
TypeScript/tests/cases/fourslash/fixExactOptionalUnassignableProperties18.ts_0_753
/// <reference path='fourslash.ts'/> // @strictNullChecks: true // @exactOptionalPropertyTypes: true //// interface ShorthandPropertyAssignment { //// a?: number //// } //// interface J { //// a?: number | undefined //// } //// declare var j: J //// var ospa/**/: { j: ShorthandPropertyAssignment } = { j } verify.codeFixAvailable([ { description: ts.Diagnostics.Add_undefined_to_optional_property_type.message } ]); verify.codeFix({ description: ts.Diagnostics.Add_undefined_to_optional_property_type.message, index: 0, newFileContent: `interface ShorthandPropertyAssignment { a?: number | undefined } interface J { a?: number | undefined } declare var j: J var ospa: { j: ShorthandPropertyAssignment } = { j }`, });
{ "end_byte": 753, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixExactOptionalUnassignableProperties18.ts" }
TypeScript/tests/cases/fourslash/goToTypeDefinitionPrimitives.ts_0_369
/// <reference path='fourslash.ts' /> // @Filename: module1.ts ////var w: {a: number}; ////var x = "string"; ////var y: number | string; ////var z; // any // @Filename: module2.ts ////w./*reference1*/a; /////*reference2*/x; /////*reference3*/y; /////*reference4*/y; verify.baselineGoToType( "reference1", "reference2", "reference3", "reference4", );
{ "end_byte": 369, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToTypeDefinitionPrimitives.ts" }
TypeScript/tests/cases/fourslash/syntacticClassificationsForOfKeyword3.ts_0_625
/// <reference path="fourslash.ts"/> //// for (var of; of; of) { } const c = classification("original"); verify.syntacticClassificationsAre( c.keyword("for"), c.punctuation("("), c.keyword("var"), c.identifier("of"), c.punctuation(";"), c.identifier("of"), c.punctuation(";"), c.identifier("of"), c.punctuation(")"), c.punctuation("{"), c.punctuation("}") ); const c2 = classification("2020"); verify.semanticClassificationsAre("2020", c2.semanticToken("variable.declaration", "of"), c2.semanticToken("variable", "of"), c2.semanticToken("variable", "of"), );
{ "end_byte": 625, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsForOfKeyword3.ts" }
TypeScript/tests/cases/fourslash/signatureHelpNoArguments.ts_0_238
/// <reference path='fourslash.ts' /> ////function foo(n: number): string { ////} //// ////foo(/**/ verify.signatureHelp({ marker: "", text: "foo(n: number): string", parameterName: "n", parameterSpan: "n: number", });
{ "end_byte": 238, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpNoArguments.ts" }
TypeScript/tests/cases/fourslash/smartSelection_JSDocTags11.ts_0_232
/// <reference path="fourslash.ts" /> ////const x = 1; ////type Foo = { //// /** comment */ //// /*2*/readonly /*1*/status: number; ////}; // https://github.com/microsoft/TypeScript/issues/39618 verify.baselineSmartSelection();
{ "end_byte": 232, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_JSDocTags11.ts" }
TypeScript/tests/cases/fourslash/referencesForInheritedProperties2.ts_0_486
/// <reference path='fourslash.ts'/> // extends statement in a diffrent declaration ////interface interface1 { //// /*1*/doStuff(): void; ////} //// ////interface interface2 { //// doStuff(): void; ////} //// ////interface interface2 extends interface1 { ////} //// ////class class1 implements interface2 { //// doStuff() { //// //// } ////} //// ////class class2 extends class1 { //// ////} //// ////var v: class2; ////v.doStuff(); verify.baselineFindAllReferences('1')
{ "end_byte": 486, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForInheritedProperties2.ts" }
TypeScript/tests/cases/fourslash/codeFixImplicitThis_ts_functionExpression_noName.ts_0_410
/// <reference path='fourslash.ts' /> // @noImplicitThis: true ////class C { //// m() { //// const f = function() { //// this; //// }; //// } ////} verify.codeFix({ description: "Convert function expression 'anonymous function' to arrow function", index: 0, newFileContent: `class C { m() { const f = () => { this; }; } }`, });
{ "end_byte": 410, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImplicitThis_ts_functionExpression_noName.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringVariableStatementArrayBindingPattern2.ts_0_690
/// <reference path='fourslash.ts' /> ////declare var console: { //// log(msg: string): void; ////} ////type MultiSkilledRobot = [string, [string, string]]; ////var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; ////var multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; //// ////let [, skillA] = multiRobotA; ////let [nameMB] = multiRobotB; ////let [nameMA, [primarySkillA, secondarySkillA]] = multiRobotA; //// ////let [nameMC] = ["roomba", ["vacuum", "mopping"]]; ////let [nameMC2, [primarySkillC, secondarySkillC]] = ["roomba", ["vacuum", "mopping"]]; //// ////let [...multiRobotAInfo] = multiRobotA; verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 690, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringVariableStatementArrayBindingPattern2.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess17.ts_0_548
/// <reference path='fourslash.ts' /> //// class A { //// constructor(protected /*a*/a/*b*/: string) { } //// } 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 { protected get a(): string { return this._a; } protected set a(value: string) { this._a = value; } constructor(private /*RENAME*/_a: string) { } }`, });
{ "end_byte": 548, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess17.ts" }
TypeScript/tests/cases/fourslash/formattingReplaceTabsWithSpaces.ts_0_748
/// <reference path="fourslash.ts"/> ////module Foo { /////*1*/ class Test { } /////*2*/ class Test { } /////*3*/class Test { } /////*4*/ class Test { } /////*5*/ class Test { } /////*6*/ class Test { } /////*7*/ class Test { } ////} format.document(); goTo.marker("1"); verify.currentLineContentIs(" class Test { }") goTo.marker("2"); verify.currentLineContentIs(" class Test { }") goTo.marker("3"); verify.currentLineContentIs(" class Test { }") goTo.marker("4"); verify.currentLineContentIs(" class Test { }") goTo.marker("5"); verify.currentLineContentIs(" class Test { }") goTo.marker("6"); verify.currentLineContentIs(" class Test { }") goTo.marker("7"); verify.currentLineContentIs(" class Test { }")
{ "end_byte": 748, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingReplaceTabsWithSpaces.ts" }
TypeScript/tests/cases/fourslash/signatureHelpJSMissingIdentifier.ts_0_141
/// <reference path="fourslash.ts" /> // @allowJs: true // @checkJs: true // @Filename: test.js ////log(/**/) verify.noSignatureHelp("");
{ "end_byte": 141, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpJSMissingIdentifier.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesIsDefinitionOfArrowFunction.ts_0_138
/// <reference path='fourslash.ts' /> /////*1*/var /*2*/f = x => x + 1; /////*3*/f(12); verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 138, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesIsDefinitionOfArrowFunction.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType65.ts_0_198
/// <reference path='fourslash.ts' /> //// type T = { c: string } //// function foo(a: /*a*/T/*b*/) { } goTo.select("a", "b"); verify.not.refactorAvailable("Extract type", "Extract to interface")
{ "end_byte": 198, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType65.ts" }
TypeScript/tests/cases/fourslash/renameModifiers.ts_0_1668
/// <reference path='fourslash.ts'/> ////[|[|declare|] [|abstract|] class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeDelta": -3 |}C1|] { //// [|[|static|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeDelta": -2 |}a|];|] //// [|[|readonly|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeDelta": -2 |}b|];|] //// [|[|public|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeDelta": -2 |}c|];|] //// [|[|protected|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeDelta": -2 |}d|];|] //// [|[|private|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeDelta": -2 |}e|];|] ////}|] ////[|[|const|] enum [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeDelta": -2 |}E|] { ////}|] ////[|[|async|] function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeDelta": -2 |}fn|]() {}|] ////[|[|export|] [|default|] class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeDelta": -3 |}C2|] {}|] const [ class1Def, declareKeyword, abstractKeyword, class1Name, aDef, staticKeyword, aName, bDef, readonlyKeyword, bName, cDef, publicKeyword, cName, dDef, protectedKeyword, dName, eDef, privateKeyword, eName, enumDef, constKeyword, enumName, functionDef, asyncKeyword, functionName, class2Def, exportKeyword, defaultKeyword, class2Name, ] = test.ranges(); verify.baselineRename([ declareKeyword, abstractKeyword, staticKeyword, readonlyKeyword, publicKeyword, protectedKeyword, privateKeyword, constKeyword, asyncKeyword, exportKeyword, defaultKeyword, ]);
{ "end_byte": 1668, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameModifiers.ts" }
TypeScript/tests/cases/fourslash/findAllRefsNonModule.ts_0_450
/// <reference path="fourslash.ts" /> // @checkJs: true // @Filename: /script.ts //// console.log("I'm a script!"); // @Filename: /import.ts //// import "./script/*1*/"; // @Filename: /require.js //// require("./script/*2*/"); //// console.log("./script/*3*/"); // @Filename: /tripleSlash.ts //// /// <reference path="script.ts" /> // @Filename: /stringLiteral.ts //// console.log("./script"); verify.baselineFindAllReferences("1", "2", "3");
{ "end_byte": 450, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsNonModule.ts" }
TypeScript/tests/cases/fourslash/codeFixRenameUnmatchedParameterJS1.ts_0_699
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @filename: /a.js /////** //// * @param {number} a //// * @param {number} c //// */ ////function foo(a, b) { //// a; //// b; ////} verify.codeFixAvailable([ { description: "Delete unused '@param' tag 'c'" }, { description: "Rename '@param' tag name 'c' to 'b'" }, { description: "Disable checking for this file" }, { description: "Infer parameter types from usage" }, ]); verify.codeFix({ description: [ts.Diagnostics.Rename_param_tag_name_0_to_1.message, "c", "b"], index: 1, newFileContent: `/** * @param {number} a * @param {number} b */ function foo(a, b) { a; b; }` });
{ "end_byte": 699, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRenameUnmatchedParameterJS1.ts" }
TypeScript/tests/cases/fourslash/organizeImportsAttributes4.ts_0_855
/// <reference path="fourslash.ts" /> ////import { A } from "./a" assert { foo: "foo", bar: "bar" }; ////import { B } from "./a" assert { bar: "bar", foo: "foo" }; ////import { D } from "./a" assert { bar: "foo", foo: "bar" }; ////import { E } from "./a" assert { foo: 'bar', bar: "foo" }; ////import { C } from "./a" assert { foo: "bar", bar: "foo" }; ////import { F } from "./a" assert { foo: "42" }; ////import { Y } from "./a" assert { foo: 42 }; ////import { Z } from "./a" assert { foo: "42" }; //// ////export type G = A | B | C | D | E | F | Y | Z; verify.organizeImports( `import { A, B } from "./a" assert { foo: "foo", bar: "bar" }; import { C, D, E } from "./a" assert { bar: "foo", foo: "bar" }; import { F, Z } from "./a" assert { foo: "42" }; import { Y } from "./a" assert { foo: 42 }; export type G = A | B | C | D | E | F | Y | Z;`);
{ "end_byte": 855, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsAttributes4.ts" }
TypeScript/tests/cases/fourslash/genericCallsWithOptionalParams1.ts_0_434
/// <reference path='fourslash.ts'/> ////class Collection<T> { //// public add(x: T) { } ////} ////interface Utils { //// fold<T, S>(c: Collection<T>, folder: (s: S, t: T) => T, init?: S): T; ////} ////var c = new Collection<string>(); ////var utils: Utils; ////var /*1*/r = utils.fold(c, (s, t) => t, ""); ////var /*2*/r2 = utils.fold(c, (s, t) => t); verify.quickInfos({ 1: "var r: string", 2: "var r2: string" });
{ "end_byte": 434, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericCallsWithOptionalParams1.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixDefaultExport7.ts_0_237
/// <reference path="fourslash.ts" /> // @lib: dom // @Filename: foo.ts //// export default globalThis.localStorage; // @Filename: index.ts //// foo/**/ goTo.marker(""); verify.importFixAtPosition([`import foo from "./foo"; foo`]);
{ "end_byte": 237, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixDefaultExport7.ts" }
TypeScript/tests/cases/fourslash/todoComments10.ts_0_106
//// /* //// [|todo 1|] //// [|hack 2|] //// */ verify.todoCommentsInCurrentFile(["TODO", "HACK"]);
{ "end_byte": 106, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/todoComments10.ts" }
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType2.ts_0_442
/// <reference path='fourslash.ts' /> ////class Foo { //// /*a*/method/*b*/() { //// return { x: 1, y: 1 }; //// } ////} goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Infer function return type", actionName: "Infer function return type", actionDescription: "Infer function return type", newContent: `class Foo { method(): { x: number; y: number; } { return { x: 1, y: 1 }; } }` });
{ "end_byte": 442, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType2.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports53-nested-generic-types.ts_0_604
/// <reference path='fourslash.ts'/> // Our current heursitic to avoid overly verbose generic types // doesn't handle generic types nested inside other types. // @isolatedDeclarations: true // @declaration: true ////export interface Foo<T, U = T[]> {} ////export function foo(x: Map<number, Foo<string>>) { //// return x; ////} verify.codeFix({ description: "Add return type 'Map<number, Foo<string, string[]>>'", index: 0, newFileContent: `export interface Foo<T, U = T[]> {} export function foo(x: Map<number, Foo<string>>): Map<number, Foo<string, string[]>> { return x; }`, });
{ "end_byte": 604, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports53-nested-generic-types.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixIndentedIdentifier.ts_0_303
/// <reference path="fourslash.ts" /> // @Filename: /a.ts ////[|import * as b from "./b"; ////{ //// x/**/ ////}|] // @Filename: /b.ts ////export const x = 0; verify.importFixAtPosition([ `import * as b from "./b"; { b.x }`, `import * as b from "./b"; import { x } from "./b"; { x }`, ]);
{ "end_byte": 303, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixIndentedIdentifier.ts" }
TypeScript/tests/cases/fourslash/unusedFunctionInNamespace1.ts_0_254
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true //// [| namespace greeter { //// // some legit comments //// function function1() { //// }/*1*/ //// } |] verify.rangeAfterCodeFix(`namespace greeter { // some legit comments }`);
{ "end_byte": 254, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedFunctionInNamespace1.ts" }
TypeScript/tests/cases/fourslash/codeFixConvertTypedefToType7.ts_0_1496
/// <reference path='fourslash.ts' /> //// //// /** //// * @typedef {number} FooNum //// */ //// //// /** //// * Comment above //// * the typedef //// * //// * @typedef {(number|string|undefined)} FooSome //// */ //// //// /** //// * @typedef {string} Foo1 //// * //// * @typedef FooPerson //// * type {object} //// * @property {string} id - person's ID //// * @property name {string} // person's name //// * @property {number|undefined} age - person's age //// * //// * @see another content //// * //// * @typedef {object} AnotherFooPerson //// * @property {object} data //// * @property {string} data.name //// * @property {number} data.age //// * @property {object} data.contact //// * @property {string} data.contact.address //// * @property {string} [data.contact.phone] //// * //// * //// * @extends another content //// */ //// verify.codeFixAll({ fixId: 'convertTypedefToType', fixAllDescription: ts.Diagnostics.Convert_all_typedef_to_TypeScript_types.message, newFileContent: ` type FooNum = number; /** * Comment above * the typedef */ type FooSome = (number | string | undefined); type Foo1 = string; interface FooPerson { id: string; name: string; age: number | undefined; } /** * @see another content */ interface AnotherFooPerson { data: { name: string; age: number; contact: { address: string; phone?: string; }; }; } /** * @extends another content */ `, });
{ "end_byte": 1496, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertTypedefToType7.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_singleLineStatements1.ts_0_250
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @noUnusedParameters: true ////export const a = 1; const b = 1; verify.codeFix({ description: "Remove unused declaration for: 'b'", newFileContent: "export const a = 1; " });
{ "end_byte": 250, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_singleLineStatements1.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType34.ts_0_386
/// <reference path='fourslash.ts' /> //// type Item<T> = /*a*/T extends (infer P)[] ? P : never/*b*/; goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to type alias", actionDescription: "Extract to type alias", newContent: `type /*RENAME*/NewType<T> = T extends (infer P)[] ? P : never; type Item<T> = NewType<T>;`, });
{ "end_byte": 386, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType34.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptCompletions3.ts_0_255
///<reference path="fourslash.ts" /> // @allowNonTsExtensions: true // @Filename: Foo.js /////** @type {Array.<number>} */ ////var v; ////v./**/ verify.completions({ marker: "", includes: { name: "concat", kind: "method", kindModifiers: "declare" } });
{ "end_byte": 255, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptCompletions3.ts" }
TypeScript/tests/cases/fourslash/findAllRefsPrivateNameProperties.ts_3_469
/ <reference path='fourslash.ts'/> ////class C { //// /*1*/#foo = 10; //// constructor() { //// this./*2*/#foo = 20; //// /*3*/#foo in this; //// } ////} ////class D extends C { //// constructor() { //// super() //// this.#foo = 20; //// } ////} ////class E { //// /*4*/#foo: number; //// constructor() { //// this./*5*/#foo = 20; //// } ////} verify.baselineFindAllReferences('1', '2', '3', '4', '5');
{ "end_byte": 469, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsPrivateNameProperties.ts" }
TypeScript/tests/cases/fourslash/quickInfoOnElementAccessInWriteLocation3.ts_0_216
/// <reference path='fourslash.ts'/> // @strict: true // @exactOptionalPropertyTypes: true //// declare const xx: { prop?: number }; //// xx['prop'/*1*/] ??= 1; verify.quickInfoAt('1', '(property) prop?: number');
{ "end_byte": 216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnElementAccessInWriteLocation3.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionSwitchCase3.ts_0_231
/// <reference path="fourslash.ts" /> ////switch (null) { //// [|/*start1*/default|]: { //// switch (null) { //// [|/*start2*/default|]: break; //// } //// }; ////} verify.baselineGoToDefinition("start1", "start2");
{ "end_byte": 231, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionSwitchCase3.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionScriptImport.ts_0_449
/// <reference path="fourslash.ts" /> // @filename: scriptThing.ts //// /*1d*/console.log("woooo side effects") // @filename: stylez.css //// /*2d*/div { //// color: magenta; //// } // @filename: moduleThing.ts // not a module, but we should let you jump to it. //// import [|/*1*/"./scriptThing"|]; // not JS/TS, but if we can, you should be able to jump to it. //// import [|/*2*/"./stylez.css"|]; verify.baselineGoToDefinition("1", "2");
{ "end_byte": 449, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionScriptImport.ts" }
TypeScript/tests/cases/fourslash/textChangesPreserveNewlines10.ts_0_871
/// <reference path="fourslash.ts" /> // @Filename: /a.ts //// [|class Foo { //// //// constructor() { //// } //// //// public runCommand(): void { //// let focusedEditor = 1; //// // Only if editor text focus (i.e. not if editor has widget focus). //// if (focusedEditor) { //// return; //// } //// } //// //// public run(): void { } //// }|] //// export const a = new Foo(); verify.moveToNewFile({ newFileContents: { "/a.ts": `import { Foo } from "./Foo"; export const a = new Foo();`, "/Foo.ts": `export class Foo { constructor() { } public runCommand(): void { let focusedEditor = 1; // Only if editor text focus (i.e. not if editor has widget focus). if (focusedEditor) { return; } } public run(): void { } } ` } });
{ "end_byte": 871, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/textChangesPreserveNewlines10.ts" }
TypeScript/tests/cases/fourslash/exportDefaultFunction.ts_0_268
/// <reference path='./fourslash.ts'/> ////export default function func() { //// /*1*/ ////} //// /*2*/ verify.completions({ marker: test.markers(), includes: { name: "func", text: "function func(): void", kind: "function", kindModifiers: "export" }, });
{ "end_byte": 268, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/exportDefaultFunction.ts" }
TypeScript/tests/cases/fourslash/findAllRefsImportEquals.ts_0_141
/// <reference path="fourslash.ts" /> ////import j = N./**/q; ////namespace N { export const q = 0; } verify.baselineFindAllReferences('')
{ "end_byte": 141, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsImportEquals.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionJsModuleNameAtImportName.ts_0_557
/// <reference path='fourslash.ts'/> // @allowJs: true // @Filename: /foo.js //// /*moduleDef*/function notExported() { } //// class Blah { //// abc = 123; //// } //// module.exports.Blah = Blah; // @Filename: /bar.js ////const [|/*importDef*/BlahModule|] = require("./foo.js"); ////new [|/*importUsage*/BlahModule|].Blah() // @Filename: /barTs.ts ////import [|/*importDefTs*/BlahModule|] = require("./foo.js"); ////new [|/*importUsageTs*/BlahModule|].Blah() verify.baselineGoToDefinition("importDef", "importUsage", "importDefTs", "importUsageTs");
{ "end_byte": 557, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionJsModuleNameAtImportName.ts" }
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction27.ts_0_433
/// <reference path='fourslash.ts' /> //// const b = (a: number) /*a*/=>/*b*/ { /* leading */ //// return a; /* trailing */ //// } goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Add or remove braces in an arrow function", actionName: "Remove braces from arrow function", actionDescription: "Remove braces from arrow function", newContent: `const b = (a: number) => /* leading */ a /* trailing */`, });
{ "end_byte": 433, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction27.ts" }
TypeScript/tests/cases/fourslash/quickInfoSignatureWithTrailingComma.ts_0_140
/// <reference path='fourslash.ts'/> ////declare function f<T>(a: T): T; /////**/f(2,); verify.quickInfoAt("", "function f<2>(a: 2): 2");
{ "end_byte": 140, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoSignatureWithTrailingComma.ts" }
TypeScript/tests/cases/fourslash/quickInfoMappedTypeRecursiveInference.ts_0_1301
/// <reference path="fourslash.ts" /> // @Filename: test.ts //// interface A { a: A } //// declare let a: A; //// type Deep<T> = { [K in keyof T]: Deep<T[K]> } //// declare function foo<T>(deep: Deep<T>): T; //// const out/*1*/ = foo/*2*/(a); //// out.a/*3*/ //// out.a.a/*4*/ //// out.a.a.a.a.a.a.a/*5*/ //// //// interface B { [s: string]: B } //// declare let b: B; //// const oub/*6*/ = foo/*7*/(b); //// oub.b/*8*/ //// oub.b.b/*9*/ //// oub.b.a.n.a.n.a/*10*/ verify.quickInfoAt('1', `const out: { a: { a: ...; }; }`); verify.quickInfoAt('2', `function foo<{ a: { a: ...; }; }>(deep: Deep<{ a: { a: ...; }; }>): { a: { a: ...; }; }`); verify.quickInfoAt('3', `(property) a: { a: { a: ...; }; }`); verify.quickInfoAt('4', `(property) a: { a: { a: ...; }; }`); verify.quickInfoAt('5', `(property) a: { a: { a: ...; }; }`); verify.quickInfoAt('6', `const oub: { [x: string]: ...; }`); verify.quickInfoAt('7', `function foo<{ [x: string]: ...; }>(deep: Deep<{ [x: string]: ...; }>): { [x: string]: ...; }`); verify.quickInfoAt('8', `{ [x: string]: ...; }`); verify.quickInfoAt('9', `{ [x: string]: ...; }`); verify.quickInfoAt('10', `{ [x: string]: ...; }`);
{ "end_byte": 1301, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoMappedTypeRecursiveInference.ts" }
TypeScript/tests/cases/fourslash/codeFixWrapDecoratorInParentheses01.ts_0_224
/// <reference path='fourslash.ts' /> ////declare var x: any; ////class C { //// @[|x?.y|] //// bar() { //// //// } ////} verify.codeFix({ description: "Wrap in parentheses", newRangeContent: `(x?.y)` });
{ "end_byte": 224, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixWrapDecoratorInParentheses01.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_import_onlyNamedImports.ts_0_246
/// <reference path='fourslash.ts' /> // @allowJs: true // @target: esnext // @Filename: /a.js ////const x = require("x"); ////x.y; verify.codeFix({ description: "Convert to ES module", newFileContent: `import { y } from "x"; y;`, });
{ "end_byte": 246, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_import_onlyNamedImports.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingMember10.ts_0_381
/// <reference path='fourslash.ts' /> //// class C {} //// const n: number = new C().add(1, 2); verify.codeFix({ index: 0, description: ignoreInterpolations(ts.Diagnostics.Declare_method_0), newFileContent: `class C { add(arg0: number, arg1: number): number { throw new Error("Method not implemented."); } } const n: number = new C().add(1, 2);`, });
{ "end_byte": 381, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember10.ts" }
TypeScript/tests/cases/fourslash/completionInsideObjectLiteralExpressionWithInstantiatedClassType.ts_3_712
/ <reference path="fourslash.ts" /> ////class C1 { //// public a: string; //// protected b: string; //// private c: string; //// //// constructor(a: string, b = "", c = "") { //// this.a = a; //// this.b = b; //// this.c = c; //// } ////} ////class C2 { //// public a: string; //// constructor(a: string) { //// this.a = a; //// } ////} ////function f1(foo: C1 | C2 | { d: number }) {} ////f1({ /*1*/ }); ////function f2(foo: C1 | C2) {} ////f2({ /*2*/ }); //// ////function f3(foo: C2) {} ////f3({ /*3*/ }); verify.completions({ marker: "1", exact: ["a", "d"], }, { marker: "2", exact: ["a"] }, { marker: "3", exact: ["a"] });
{ "end_byte": 712, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionInsideObjectLiteralExpressionWithInstantiatedClassType.ts" }
TypeScript/tests/cases/fourslash/transitiveExportImports2.ts_0_779
/// <reference path='fourslash.ts'/> // @Filename: a.ts ////[|namespace /*A*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}A|] { //// export const x = 0; ////}|] // @Filename: b.ts ////[|export import /*B*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}B|] = [|A|];|] ////[|B|].x; // @Filename: c.ts ////[|import { /*C*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}B|] } from "./b";|] verify.noErrors(); const [A0Def, A0, B0Def, B0, A1, B1, B2Def, B2] = test.ranges(); const aRanges = [A0, A1]; const bRanges = [B0, B1]; const cRanges = [B2]; verify.baselineFindAllReferences("A", "B", "C"); verify.baselineRename(aRanges); verify.baselineRename([B0, B1]); verify.baselineRename(B2);
{ "end_byte": 779, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/transitiveExportImports2.ts" }
TypeScript/tests/cases/fourslash/stringCompletionsImportOrExportSpecifier.ts_0_2661
///<reference path="fourslash.ts" /> // @Filename: exports.ts //// export let foo = 1; //// let someValue = 2; //// let someType = 3; //// export { //// someValue as "__some value", //// someType as "__some type", //// }; // @Filename: values.ts //// import { "/*valueImport0*/" } from "./exports"; //// import { "/*valueImport1*/" as valueImport1 } from "./exports"; //// import { foo as "/*valueImport2*/" } from "./exports"; //// import { foo, "/*valueImport3*/" as valueImport3 } from "./exports"; //// //// export { "/*valueExport0*/" } from "./exports"; //// export { "/*valueExport1*/" as valueExport1 } from "./exports"; //// export { foo as "/*valueExport2*/" } from "./exports"; //// export { foo, "/*valueExport3*/" } from "./exports"; // @Filename: types.ts //// import { type "/*typeImport0*/" } from "./exports"; //// import { type "/*typeImport1*/" as typeImport1 } from "./exports"; //// import { type foo as "/*typeImport2*/" } from "./exports"; //// import { type foo, type "/*typeImport3*/" as typeImport3 } from "./exports"; //// //// export { type "/*typeExport0*/" } from "./exports"; //// export { type "/*typeExport1*/" as typeExport1 } from "./exports"; //// export { type foo as "/*typeExport2*/" } from "./exports"; //// export { type foo, type "/*typeExport3*/" } from "./exports"; verify.completions({ marker: "valueImport0", exact: ["__some type", "__some value", "foo"] }); verify.completions({ marker: "valueImport1", exact: ["__some type", "__some value", "foo"] }); verify.completions({ marker: "valueImport2", exact: [] }); verify.completions({ marker: "valueImport3", exact: ["__some type", "__some value"] }); verify.completions({ marker: "valueExport0", exact: ["__some type", "__some value", "foo"] }); verify.completions({ marker: "valueExport1", exact: ["__some type", "__some value", "foo"] }); verify.completions({ marker: "valueExport2", exact: [] }); verify.completions({ marker: "valueExport3", exact: ["__some type", "__some value"] }); verify.completions({ marker: "typeImport0", exact: ["__some type", "__some value", "foo"] }); verify.completions({ marker: "typeImport1", exact: ["__some type", "__some value", "foo"] }); verify.completions({ marker: "typeImport2", exact: [] }); verify.completions({ marker: "typeImport3", exact: ["__some type", "__some value"] }); verify.completions({ marker: "typeExport0", exact: ["__some type", "__some value", "foo"] }); verify.completions({ marker: "typeExport1", exact: ["__some type", "__some value", "foo"] }); verify.completions({ marker: "typeExport2", exact: [] }); verify.completions({ marker: "typeExport3", exact: ["__some type", "__some value"] });
{ "end_byte": 2661, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/stringCompletionsImportOrExportSpecifier.ts" }
TypeScript/tests/cases/fourslash/getEditsForFileRename_js_simple.ts_0_305
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: /a.js ////import b from "./b.js"; // @Filename: /b.js ////module.exports = 1; verify.getEditsForFileRename({ oldPath: "/b.js", newPath: "/c.js", newFileContents: { "/a.js": `import b from "./c.js";`, }, });
{ "end_byte": 305, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_js_simple.ts" }
TypeScript/tests/cases/fourslash/documentHighlightTemplateStrings.ts_3_373
/ <reference path='fourslash.ts'/> ////type Foo = "[|a|]" | "b"; //// ////class C { //// p: Foo = `[|a|]`; //// m() { //// switch (this.p) { //// case `[|a|]`: //// return 1; //// case "b": //// return 2; //// } //// } ////} const [r0, r1, r2] = test.ranges(); verify.baselineDocumentHighlights(r2);
{ "end_byte": 373, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlightTemplateStrings.ts" }
TypeScript/tests/cases/fourslash/codeFixImplicitThis_ts_cantFixNonFunction.ts_0_105
/// <reference path='fourslash.ts' /> // @noImplicitThis: true ////this; verify.codeFixAvailable([]);
{ "end_byte": 105, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImplicitThis_ts_cantFixNonFunction.ts" }
TypeScript/tests/cases/fourslash/formatV8Directive.ts_0_218
/// <reference path="fourslash.ts" /> // @Filename: foo.js //// function foo() {} //// /*1*/%PrepareFunctionForOptimization(foo)/*2*/; // Don't really care what it does beyond not crashing format.selection("1", "2");
{ "end_byte": 218, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatV8Directive.ts" }
TypeScript/tests/cases/fourslash/quickInfoImportMeta.ts_0_464
///<reference path="fourslash.ts" /> // @module: esnext // @Filename: foo.ts /////// <reference no-default-lib="true"/> /////// <reference path='./bar.d.ts' /> ////im/*1*/port.me/*2*/ta; //@Filename: bar.d.ts /////** //// * The type of `import.meta`. //// * //// * If you need to declare that a given property exists on `import.meta`, //// * this type may be augmented via interface merging. //// */ //// interface ImportMeta { ////} verify.baselineQuickInfo()
{ "end_byte": 464, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoImportMeta.ts" }
TypeScript/tests/cases/fourslash/refactorOverloadListToSingleSignature9.ts_0_1292
/// <reference path="fourslash.ts" /> /////*a1*/function foo(a: string): void; /////*a2*/function foo(a: number): void;/*b2*/ /////*a3*/function foo(a: number | string): void/*b3*/ /*a4*/{ //// /*a5*/console.log(1);/*b5*/ ////}/*b4*//*b1*/ goTo.select("a1", "b1"); verify.refactorAvailable("Convert overload list to single signature", "Convert overload list to single signature", ts.Diagnostics.Convert_overload_list_to_single_signature.message); goTo.select("a2", "b2"); verify.refactorAvailable("Convert overload list to single signature", "Convert overload list to single signature", ts.Diagnostics.Convert_overload_list_to_single_signature.message); goTo.select("a3", "b3"); verify.refactorAvailable("Convert overload list to single signature", "Convert overload list to single signature", ts.Diagnostics.Convert_overload_list_to_single_signature.message); goTo.select("a4", "b4"); verify.not.refactorAvailable("Convert overload list to single signature", "Convert overload list to single signature", ts.Diagnostics.Convert_overload_list_to_single_signature.message); goTo.select("a5", "b5"); verify.not.refactorAvailable("Convert overload list to single signature", "Convert overload list to single signature", ts.Diagnostics.Convert_overload_list_to_single_signature.message);
{ "end_byte": 1292, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorOverloadListToSingleSignature9.ts" }
TypeScript/tests/cases/fourslash/completionListPrivateNamesMethods.ts_0_726
/// <reference path="fourslash.ts"/> //// class Foo { //// #x() {}; //// y() {}; //// } //// class Bar extends Foo { //// #z() {}; //// t() {}; //// constructor() { //// this./*1*/ //// class Baz { //// #z() {}; //// #u() {}; //// v() {}; //// constructor() { //// this./*2*/ //// new Bar()./*3*/ //// } //// } //// } //// } //// //// new Foo()./*4*/ verify.completions({ marker: "1", unsorted: ["#z", "t", "y"] }); verify.completions({ marker: "2", unsorted: ["#z", "#u", "v"] }); verify.completions({ marker: "3", unsorted: ["#z", "t", "y"] }); verify.completions({ marker: "4", exact: ["y"] });
{ "end_byte": 726, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListPrivateNamesMethods.ts" }
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization5.ts_0_244
/// <reference path='fourslash.ts' /> // @strict: true //// class T { //// a: boolean; //// } verify.codeFix({ description: `Add initializer to property 'a'`, newFileContent: `class T { a: boolean = false; }`, index: 2 })
{ "end_byte": 244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization5.ts" }
TypeScript/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion.ts_0_1977
/// <reference path="fourslash.ts"/> // @allowNonTsExtensions: true // @Filename: jsFileJsdocTypedefTagTypeExpressionCompletion_typedef.js //// /** //// * @typedef {/*1*/string | /*2*/number} T.NumberLike //// * @typedef {{/*propertyName*/age: /*3*/number}} T.People //// * @typedef {string | number} T.O.Q.NumberLike //// * @type {/*4*/T./*1TypeMember*/NumberLike} //// */ //// var x; //// /** @type {/*5*/T./*2TypeMember*/O.Q.NumberLike} */ //// var x1; //// /** @type {/*6*/T./*3TypeMember*/People} */ //// var x1; //// /*globalValue*/ const types: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [ { name: "T", kind: "module" }, ]; const values: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [ { name: "x", kind: "var" }, { name: "x1", kind: "var" }, ]; const typeMembers: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [ { name: "NumberLike", kind: "type" }, { name: "People", kind: "type" }, { name: "O", kind: "module", kindModifiers: "export" }, ]; function warnings(entries: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject>): ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> { return entries.map(e => ({ ...e, kind: "warning", kindModifiers: undefined, sortText: completion.SortText.JavascriptIdentifiers })); } verify.completions( { marker: ["1", "2", "3", "4", "5", "6"], includes: [ ...types, ...warnings(values), ...warnings(typeMembers), ], }, { marker: "globalValue", includes: [ ...values, ...warnings(types), ...warnings(typeMembers), ], }, { marker: [1, 2, 3].map(i => `${i}TypeMember`), includes: [ ...typeMembers, ...warnings(types), ...warnings(values), ], }, { marker: "propertyName", exact: undefined, }, );
{ "end_byte": 1977, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsFileJsdocTypedefTagTypeExpressionCompletion.ts" }
TypeScript/tests/cases/fourslash/docCommentTemplateClassDeclProperty01.ts_0_697
/// <reference path='fourslash.ts' /> const singleLineOffset = 3; const multiLineOffset = 11; ////class C { //// /** /*0*/ */ //// foo = (p0) => { //// return p0; //// }; //// /*1*/ //// bar = (p1) => { //// return p1; //// } //// /*2*/ //// baz = function (p2, p3) { //// return p2; //// } ////} verify.docCommentTemplateAt("0", multiLineOffset, `/** * * @param p0 * @returns */`); verify.docCommentTemplateAt("1", multiLineOffset, `/** * * @param p1 * @returns */`); verify.docCommentTemplateAt("2", multiLineOffset, `/** * * @param p2 * @param p3 * @returns */`);
{ "end_byte": 697, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateClassDeclProperty01.ts" }
TypeScript/tests/cases/fourslash/docCommentTemplateRegex.ts_0_174
/// <reference path='fourslash.ts' /> ////var regex = /*0*///*1*/asdf/*2*/ /*3*///*4*/; for (const marker of test.markers()) { verify.noDocCommentTemplateAt(marker); }
{ "end_byte": 174, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateRegex.ts" }
TypeScript/tests/cases/fourslash/codeFixAwaitInSyncFunction3.ts_0_232
/// <reference path='fourslash.ts' /> ////const f = { //// get a() { //// return await Promise.resolve(); //// }, //// get a() { //// await Promise.resolve(); //// }, ////} verify.not.codeFixAvailable();
{ "end_byte": 232, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAwaitInSyncFunction3.ts" }
TypeScript/tests/cases/fourslash/documentHighlightAtInheritedProperties5.ts_3_329
/ <reference path='fourslash.ts'/> // @Filename: file1.ts //// interface C extends D { //// [|prop0|]: string; //// [|prop1|]: number; //// } //// //// interface D extends C { //// [|prop0|]: string; //// [|prop1|]: number; //// } //// //// var d: D; //// d.[|prop1|]; verify.baselineDocumentHighlights();
{ "end_byte": 329, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlightAtInheritedProperties5.ts" }
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax18.ts_0_169
/// <reference path='fourslash.ts' /> //// var index: { (ix: number): [|?|] }; verify.codeFix({ description: "Change '?' to 'any'", newRangeContent: "any", });
{ "end_byte": 169, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax18.ts" }
TypeScript/tests/cases/fourslash/mapCodeNestedWhileReplace.ts_0_404
///<reference path="fourslash.ts"/> // @Filename: /index.ts //// function foo() { //// const x: number = 1; //// const y: number = 2; //// while (x === y) [||]{ //// console.log("hello"); //// console.log("you"); //// } //// return 1; //// } //// verify.baselineMapCode([test.ranges()], [ ` while (x === y) { console.log("goodbye"); console.log("world"); } ` ]);
{ "end_byte": 404, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeNestedWhileReplace.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess23.ts_0_1176
/// <reference path='fourslash.ts' /> //// class A { //// /*a*/public _a: number = 1;/*b*/ //// /*c*/public a: string = "foo";/*d*/ //// } goTo.select("c", "d"); edit.applyRefactor({ refactorName: "Generate 'get' and 'set' accessors", actionName: "Generate 'get' and 'set' accessors", actionDescription: "Generate 'get' and 'set' accessors", newContent: `class A { public _a: number = 1; private /*RENAME*/_a_1: string = "foo"; public get a(): string { return this._a_1; } public set a(value: string) { this._a_1 = value; } }`, }); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Generate 'get' and 'set' accessors", actionName: "Generate 'get' and 'set' accessors", actionDescription: "Generate 'get' and 'set' accessors", newContent: `class A { private _a: number = 1; public get /*RENAME*/a_1(): number { return this._a; } public set a_1(value: number) { this._a = value; } private _a_1: string = "foo"; public get a(): string { return this._a_1; } public set a(value: string) { this._a_1 = value; } }`, });
{ "end_byte": 1176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess23.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType51.ts_0_172
/// <reference path='fourslash.ts' /> //// interface I { f: (this: O, b: number) => /*a*/this/*b*/ }; goTo.select("a", "b"); verify.not.refactorAvailable("Extract type")
{ "end_byte": 172, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType51.ts" }
TypeScript/tests/cases/fourslash/signatureHelpTypeArguments2.ts_0_410
/// <reference path="fourslash.ts"/> /////** some documentation //// * @template T some documentation 2 //// * @template W //// * @template U,V others //// * @param a ok //// * @param b not ok //// */ ////function f<T, U, V, W>(a: number, b: string, c: boolean): void { } ////f</*f0*/; ////f<number, /*f1*/; ////f<number, string, /*f2*/; ////f<number, string, boolean, /*f3*/; verify.baselineSignatureHelp()
{ "end_byte": 410, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTypeArguments2.ts" }
TypeScript/tests/cases/fourslash/extract-method1.ts_0_774
/// <reference path='fourslash.ts' /> //// class Foo { //// someMethod(m: number) { //// /*start*/var x = m; //// x = x * 3; //// var y = 30; //// var z = y + x; //// console.log(z);/*end*/ //// var q = 10; //// return q; //// } //// } goTo.select('start', 'end') edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "function_scope_1", actionDescription: "Extract to method in class 'Foo'", newContent: `class Foo { someMethod(m: number) { this./*RENAME*/newMethod(m); var q = 10; return q; } private newMethod(m: number) { var x = m; x = x * 3; var y = 30; var z = y + x; console.log(z); } }` });
{ "end_byte": 774, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method1.ts" }
TypeScript/tests/cases/fourslash/completionsInExport_invalid.ts_0_271
/// <reference path="fourslash.ts" /> ////function topLevel() {} ////if (!!true) { //// const blockScoped = 0; //// export { /**/ }; ////} verify.completions({ marker: "", exact: ["topLevel", { name: "type", sortText: completion.SortText.GlobalsOrKeywords }] });
{ "end_byte": 271, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsInExport_invalid.ts" }
TypeScript/tests/cases/fourslash/navigationBarNamespaceImportWithNoName.ts_0_540
/// <reference path="fourslash.ts"/> ////import *{} from 'foo'; verify.navigationTree({ "text": "\"navigationBarNamespaceImportWithNoName\"", "kind": "module", "childItems": [ { "text": "<unknown>", "kind": "alias" } ] }); verify.navigationBar([ { "text": "\"navigationBarNamespaceImportWithNoName\"", "kind": "module", "childItems": [ { "text": "<unknown>", "kind": "alias" } ] } ]);
{ "end_byte": 540, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarNamespaceImportWithNoName.ts" }
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue16.ts_0_334
/// <reference path='fourslash.ts' /> //// interface A { //// bar: string //// } //// //// function Foo (a: () => A) { a() } //// Foo(() => { bar: '1' }) verify.codeFixAvailable([ { description: 'Wrap the following body with parentheses which should be an object literal' }, { description: 'Remove unused label' }, ]);
{ "end_byte": 334, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue16.ts" }
TypeScript/tests/cases/fourslash/formatComments.ts_0_514
/// <reference path="fourslash.ts"/> ////_.chain() ////// wow/*callChain1*/ //// .then() ////// waa/*callChain2*/ //// .then(); ////wow( //// 3, ////// uaa/*argument1*/ //// 4 ////// wua/*argument2*/ ////); format.document(); goTo.marker("callChain1"); verify.currentLineContentIs(" // wow"); goTo.marker("callChain2"); verify.currentLineContentIs(" // waa"); goTo.marker("argument1"); verify.currentLineContentIs(" // uaa"); goTo.marker("argument2"); verify.currentLineContentIs(" // wua");
{ "end_byte": 514, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatComments.ts" }
TypeScript/tests/cases/fourslash/refactorConvertExport_defaultToNamed.ts_0_985
/// <reference path='fourslash.ts' /> // @Filename: /a.ts /////*a*/export default function f() {}/*b*/ // @Filename: /b.ts ////import f from "./a"; ////import { default as f } from "./a"; ////import { default as g } from "./a"; ////import f, * as a from "./a"; //// ////export { default } from "./a"; ////export { default as f } from "./a"; ////export { default as i } from "./a"; //// ////import * as a from "./a"; ////a.default(); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert export", actionName: "Convert default export to named export", actionDescription: "Convert default export to named export", newContent: { "/a.ts": `export function f() {}`, "/b.ts": `import { f } from "./a"; import { f } from "./a"; import { f as g } from "./a"; import * as a from "./a"; import { f } from "./a"; export { f as default } from "./a"; export { f } from "./a"; export { f as i } from "./a"; import * as a from "./a"; a.f();`, }, });
{ "end_byte": 985, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertExport_defaultToNamed.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingAttributes2.ts_0_406
/// <reference path='fourslash.ts' /> // @jsx: preserve // @filename: foo.tsx ////interface P { //// a: number; //// b: string; ////} //// ////const A = ({ a, b }: P) => //// <div>{a}{b}</div>; //// ////const Bar = () => //// [|<A a={100}></A>|] verify.codeFix({ index: 0, description: ts.Diagnostics.Add_missing_attributes.message, newRangeContent: `<A a={100} b={""}></A>` });
{ "end_byte": 406, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAttributes2.ts" }
TypeScript/tests/cases/fourslash/documentHighlights_40082.ts_0_216
/// <reference path="fourslash.ts" /> // #40082 // @checkJs: true //// export = (state, messages) => { //// export [|default|] { //// } //// } const [r] = test.ranges(); verify.baselineDocumentHighlights(r);
{ "end_byte": 216, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlights_40082.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFix_sortByDistance.ts_0_612
/// <reference path="fourslash.ts" /> // @module: commonjs // @Filename: /src/admin/utils/db/db.ts //// export const db = {}; // @Filename: /src/admin/utils/db/index.ts //// export * from "./db"; // @Filename: /src/client/helpers/db.ts //// export const db = {}; // @Filename: /src/client/db.ts //// export const db = {}; // @Filename: /src/client/foo.ts //// db/**/ goTo.marker(""); verify.importFixAtPosition([ `import { db } from "./db";\n\ndb`, `import { db } from "./helpers/db";\n\ndb`, `import { db } from "../admin/utils/db";\n\ndb`, `import { db } from "../admin/utils/db/db";\n\ndb` ]);
{ "end_byte": 612, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_sortByDistance.ts" }
TypeScript/tests/cases/fourslash/preparePasteEdits_multipleLocations.ts_0_497
/// <reference path='fourslash.ts' /> // @module: commonjs // @allowJs: true // @Filename: /file1.js //// import { aa, bb } = require("./other"); //// [|const r = 10;|] //// export const s = 12; //// [|export const t = aa + bb + r + s; //// const u = 1;|] // @Filename: /other.js //// export const aa = 1; //// export const bb = 2; //// module.exports = { aa, bb }; verify.preparePasteEdits({ copiedFromFile: "/file1.js", copiedTextRange: test.ranges(), providePasteEdits: true, })
{ "end_byte": 497, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/preparePasteEdits_multipleLocations.ts" }
TypeScript/tests/cases/fourslash/codeFixImportNonExportedMember_all1.ts_0_559
/// <reference path="fourslash.ts" /> // @module: esnext // @filename: /a.ts ////declare function foo(): any; ////declare function bar(): any; ////export declare function baz(): any; // @filename: /b.ts ////import { foo, bar } from "./a"; goTo.file("/b.ts"); verify.codeFixAll({ fixId: "fixImportNonExportedMember", fixAllDescription: ts.Diagnostics.Export_all_referenced_locals.message, newFileContent: { "/a.ts": `export declare function foo(): any; export declare function bar(): any; export declare function baz(): any;` }, });
{ "end_byte": 559, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImportNonExportedMember_all1.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_NoPreviousCall.ts_0_335
/// <reference path='fourslash.ts' /> ////let a = { //// b: () => { //// return { //// c: () => { //// return { d: 0 }; //// } //// }; //// } ////} /////*a*/a && a.b() && a.b.c;/*b*/ goTo.select("a", "b"); verify.not.refactorAvailable("Convert to optional chain expression");
{ "end_byte": 335, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_NoPreviousCall.ts" }
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class_exportModifier1.ts_0_355
/// <reference path='fourslash.ts' /> // @allowNonTsExtensions: true // @Filename: test123.js ////export function /**/MyClass() { ////} ////MyClass.prototype.foo = function() { ////} verify.codeFix({ description: "Convert function to an ES2015 class", newFileContent: `export class MyClass { constructor() { } foo() { } } `, });
{ "end_byte": 355, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class_exportModifier1.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts_0_1295
/// <reference path='fourslash.ts' /> // Should give completions for absolute paths // @Filename: tests/test0.ts //// import * as foo1 from "/tests/cases/f/*import_as0*/ //// import * as foo2 from "/tests/cases/fourslash/*import_as1*/ //// import * as foo3 from "/tests/cases/fourslash//*import_as2*/ //// import foo4 = require("/tests/cases/f/*import_equals0*/ //// import foo5 = require("/tests/cases/fourslash/*import_equals1*/ //// import foo6 = require("/tests/cases/fourslash//*import_equals2*/ //// var foo7 = require("/tests/cases/f/*require0*/ //// var foo8 = require("/tests/cases/fourslash/*require1*/ //// var foo9 = require("/tests/cases/fourslash//*require2*/ // @Filename: f1.ts //// /*f1*/ // @Filename: f2.tsx //// /*f2*/ // @Filename: folder/f1.ts //// /*subf1*/ // @Filename: f3.js //// /*f3*/ // @Filename: f4.jsx //// /*f4*/ // @Filename: e1.ts //// /*e1*/ // @Filename: e2.js //// /*e2*/ const kinds = ["import_as", "import_equals", "require"]; verify.completions( { marker: [...kinds.map(k => `${k}0`), ...kinds.map(k => `${k}1`)], exact: "fourslash", isNewIdentifierLocation: true, }, { marker: kinds.map(k => `${k}2`), exact: ["e1", "f1", "f2", "folder", "tests"], isNewIdentifierLocation: true, });
{ "end_byte": 1295, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts" }
TypeScript/tests/cases/fourslash/completionImportMeta.ts_0_316
/// <reference path='fourslash.ts' /> // @Filename: a.ts ////import./*1*/ // @Filename: b.ts ////import.meta./*2*/ // @Filename: c.ts ////import./*3*/meta verify.completions( { marker: "1", exact: "meta" }, { marker: "2", exact: undefined }, { marker: "3", exact: "meta" } );
{ "end_byte": 316, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionImportMeta.ts" }
TypeScript/tests/cases/fourslash/todoComments7.ts_0_106
//// /* //// [|TODO 1|] //// [|HACK 2|] //// */ verify.todoCommentsInCurrentFile(["TODO", "HACK"]);
{ "end_byte": 106, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/todoComments7.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingMember24.ts_0_327
/// <reference path='fourslash.ts' /> ////[|type Foo = {};|] ////function f(foo: Foo) { //// foo.test(1, 1, ""); ////} verify.codeFix({ description: [ts.Diagnostics.Declare_method_0.message, "test"], index: 0, newRangeContent: `type Foo = { test(arg0: number, arg1: number, arg2: string): unknown; };` });
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember24.ts" }
TypeScript/tests/cases/fourslash/completionForStringLiteralImport2.ts_0_905
/// <reference path='fourslash.ts' /> // Should define spans for replacement that appear after the last directory seperator in triple slash references // @typeRoots: my_typings // @Filename: test.ts //// /// <reference path="./[|some|]/*0*/ //// /// <reference types="[|some|]/*1*/ //// /// <reference path="./sub/[|some|]/*2*/" /> //// /// <reference types="[|some|]/*3*/" /> // @Filename: someFile.ts //// /*someFile*/ // @Filename: sub/someOtherFile.ts //// /*someOtherFile*/ // @Filename: my_typings/some-module/index.d.ts //// export var x = 9; verify.completions( { marker: "0", exact: ["someFile.ts", "my_typings", "sub"], isNewIdentifierLocation: true }, { marker: "1", exact: "some-module", isNewIdentifierLocation: true }, { marker: "2", exact: "someOtherFile.ts", isNewIdentifierLocation: true }, { marker: "3", exact: "some-module", isNewIdentifierLocation: true }, );
{ "end_byte": 905, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralImport2.ts" }
TypeScript/tests/cases/fourslash/quickInfoForJSDocWithHttpLinks.ts_0_518
/// <reference path='fourslash.ts' /> // @checkJs: true // @filename: quickInfoForJSDocWithHttpLinks.js //// /** @typedef {number} /*1*/https://wat */ //// //// /** //// * @typedef {Object} Oops //// * @property {number} /*2*/https://wass //// */ //// //// //// /** @callback /*3*/http://vad */ //// //// /** @see https://hvad */ //// var /*4*/see1 = true //// //// /** @see {@link https://hva} */ //// var /*5*/see2 = true //// //// /** {@link https://hvaD} */ //// var /*6*/see3 = true verify.baselineQuickInfo();
{ "end_byte": 518, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForJSDocWithHttpLinks.ts" }