_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/organizeImportsAttributes3.ts_0_722
/// <reference path="fourslash.ts" /> ////import { A } from "./a"; ////import { C } from "./a" assert { type: "a" }; ////import { Z } from "./z"; ////import { A as D } from "./a" assert { type: "b" }; ////import { E } from "./a" assert { type: /* comment*/ "a" }; ////import { F } from "./a" assert {type: "a" }; ////import { Y } from "./a" assert{ type: "b" /* comment*/}; ////import { B } from "./a"; //// ////export type G = A | B | C | D | E | F | Y | Z; verify.organizeImports( `import { A, B } from "./a"; import { C, E, F } from "./a" assert { type: "a" }; import { A as D, Y } from "./a" assert { type: "b" }; import { Z } from "./z"; export type G = A | B | C | D | E | F | Y | Z;`);
{ "end_byte": 722, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsAttributes3.ts" }
TypeScript/tests/cases/fourslash/importTypeFormatting.ts_0_220
/// <reference path="fourslash.ts"/> ////var y: import("./c2").mytype; ////var z: import ("./c2").mytype; format.document(); verify.currentFileContentIs( `var y: import("./c2").mytype; var z: import("./c2").mytype;`);
{ "end_byte": 220, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importTypeFormatting.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptCompletions4.ts_0_278
///<reference path="fourslash.ts" /> // @allowNonTsExtensions: true // @Filename: Foo.js /////** @return {number} */ ////function foo(a,b) { } ////foo(1,2)./**/ verify.completions({ marker: "", includes: { name: "toExponential", kind: "method", kindModifiers: "declare" } });
{ "end_byte": 278, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptCompletions4.ts" }
TypeScript/tests/cases/fourslash/quickInfoOnElementAccessInWriteLocation4.ts_0_315
/// <reference path='fourslash.ts'/> // @strict: true //// interface Serializer { //// set value(v: string | number | boolean); //// get value(): string; //// } //// declare let box: Serializer; //// box['value'/*1*/] = true; verify.quickInfoAt('1', '(property) Serializer.value: string | number | boolean');
{ "end_byte": 315, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnElementAccessInWriteLocation4.ts" }
TypeScript/tests/cases/fourslash/signatureHelpInFunctionCall.ts_0_142
/// <reference path='fourslash.ts' /> ////var items = []; ////items.forEach(item => { //// for (/**/ ////}); verify.noSignatureHelp("");
{ "end_byte": 142, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpInFunctionCall.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess41.ts_0_546
/// <reference path='fourslash.ts' /> // @strict: true ////class A { //// /*a*/"\\foo": "";/*b*/ ////} goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Generate 'get' and 'set' accessors", actionName: "Generate 'get' and 'set' accessors", actionDescription: "Generate 'get' and 'set' accessors", newContent: `class A { private /*RENAME*/"_\\\\foo": ""; public get "\\\\foo"(): "" { return this["_\\\\foo"]; } public set "\\\\foo"(value: "") { this["_\\\\foo"] = value; } }` });
{ "end_byte": 546, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess41.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType33.ts_0_172
/// <reference path='fourslash.ts' /> //// type Item<T> = T extends (infer /*a*/P/*b*/)[] ? P : never 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/refactorExtractType33.ts" }
TypeScript/tests/cases/fourslash/smartIndentStatementSwitch.ts_0_561
/// <reference path='fourslash.ts'/> ////function Foo() { //// var x; //// switch (x) { //// {| "indentation": 8 |} //// } //// {| "indentation": 4 |} //// switch (x) { //// {| "indentation": 8 |} //// case 1: //// {| "indentation": 12 |} //// break; //// {| "indentation": 8 |} // since we just saw "break" //// } //// {| "indentation": 4 |} ////} test.markers().forEach((marker) => { verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation); });
{ "end_byte": 561, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentStatementSwitch.ts" }
TypeScript/tests/cases/fourslash/codeFixForgottenThisPropertyAccess04.ts_0_215
/// <reference path='fourslash.ts' /> // @jsx: react // @jsxFactory: factory // @Filename: /a.tsx ////export class C { //// foo() { //// return <a.div />; //// } ////} verify.not.codeFixAvailable();
{ "end_byte": 215, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixForgottenThisPropertyAccess04.ts" }
TypeScript/tests/cases/fourslash/codeFixOverrideModifier17.ts_0_493
/// <reference path='fourslash.ts' /> // @experimentalDecorators: true // @noImplicitOverride: true ////function decorator() { //// return (target: any, key: any, descriptor: PropertyDescriptor) => descriptor; ////} ////class A { //// foo() {} ////} ////class B extends A { //// @decorator() //// /** //// * comment //// */ //// [|foo() {}|] ////} verify.codeFix({ description: "Add 'override' modifier", newRangeContent: "override foo() {}", index: 0 })
{ "end_byte": 493, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixOverrideModifier17.ts" }
TypeScript/tests/cases/fourslash/completionListInObjectBindingPattern02.ts_0_229
/// <reference path='fourslash.ts'/> ////interface I { //// property1: number; //// property2: string; ////} //// ////var foo: I; ////var { property1, /**/ } = foo; verify.completions({ marker: "", exact: "property2" });
{ "end_byte": 229, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectBindingPattern02.ts" }
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType1.ts_0_373
/// <reference path='fourslash.ts' /> ////interface I<X> { //// x: { readonly [K in keyof X]: X[K] }; ////} ////class C<Y> implements I<Y> {} verify.codeFix({ description: "Implement interface 'I<Y>'", newFileContent: `interface I<X> { x: { readonly [K in keyof X]: X[K] }; } class C<Y> implements I<Y> { x: { readonly [K in keyof Y]: Y[K]; }; }`, });
{ "end_byte": 373, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType1.ts" }
TypeScript/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature03.ts_0_367
/// <reference path="fourslash.ts" /> ////interface I<TString, TNumber> { //// [s: string]: TString; //// [s: number]: TNumber; ////} //// ////declare function foo<TString, TNumber>(obj: I<TString, TNumber>): { str: TString/*1*/ } verify.completions({ marker: "1", includes: ["I", "TString", "TNumber"], excludes: ["foo", "obj"], // not types });
{ "end_byte": 367, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInClosedObjectTypeLiteralInSignature03.ts" }
TypeScript/tests/cases/fourslash/stringLiteralCompletionsForTypeIndexedAccess.ts_0_281
/// <reference path="fourslash.ts" /> //// type Foo = { a: string; b: number; c: boolean; }; //// type A = Foo["/*1*/"]; //// type AorB = Foo["a" | "/*2*/"]; verify.completions({ marker: ["1"], exact: ["a", "b", "c"] }); verify.completions({ marker: ["2"], exact: ["b", "c"] });
{ "end_byte": 281, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/stringLiteralCompletionsForTypeIndexedAccess.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageGetter2.ts_0_233
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////class C { //// [|get x() |]{ //// return undefined; //// } ////} ////(new C).x = 1; verify.rangeAfterCodeFix("get x(): number", undefined, undefined, 0);
{ "end_byte": 233, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageGetter2.ts" }
TypeScript/tests/cases/fourslash/formattingAwait.ts_0_294
/// <reference path='fourslash.ts'/> ////async function f() { //// for await (const x of g()) { //// console.log(x); //// } ////} format.document(); verify.currentFileContentIs( `async function f() { for await (const x of g()) { console.log(x); } }` );
{ "end_byte": 294, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingAwait.ts" }
TypeScript/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias3.ts_0_160
/// <reference path='fourslash.ts'/> //// type constructorType<T1, T2> = new <T/*1*/, /*2*/ verify.completions({ marker: test.markers(), exact: undefined });
{ "end_byte": 160, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias3.ts" }
TypeScript/tests/cases/fourslash/formatTypeAlias.ts_0_327
/// <reference path="fourslash.ts"/> ////type Alias = /*typeKeyword*/ /////*indent*/ ////number;/*autoformat*/ format.document(); goTo.marker("typeKeyword"); verify.currentLineContentIs("type Alias ="); goTo.marker("indent"); verify.indentationIs(4); goTo.marker("autoformat"); verify.currentLineContentIs(" number;");
{ "end_byte": 327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatTypeAlias.ts" }
TypeScript/tests/cases/fourslash/completionListInExportClause02.ts_0_294
/// <reference path='fourslash.ts'/> ////declare module "M1" { //// export var V; ////} ////var W; ////declare module "M2" { //// export { /**/ } from "M1" ////} verify.completions({ marker: "", exact: [ "V", { name: "type", sortText: completion.SortText.GlobalsOrKeywords }, ] });
{ "end_byte": 294, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInExportClause02.ts" }
TypeScript/tests/cases/fourslash/inlineVariableTemplateString11.ts_0_428
/// <reference path="fourslash.ts" /> ////const /*a*/pizza/*b*/ = "🍕"; ////export const prompt = `Hello, would you like some ${((pizza))}?`; goTo.select("a", "b"); verify.refactorAvailable("Inline variable"); edit.applyRefactor({ refactorName: "Inline variable", actionName: "Inline variable", actionDescription: "Inline variable", newContent: "export const prompt = `Hello, would you like some 🍕?`;" });
{ "end_byte": 428, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableTemplateString11.ts" }
TypeScript/tests/cases/fourslash/codeFixSpelling7.ts_0_260
/// <reference path='fourslash.ts' /> ////namespace Foo { //// export type nums = number; ////} ////let x: Foo.[|num|]; verify.codeFix({ index: 0, description: [ts.Diagnostics.Change_spelling_to_0.message, "nums"], newRangeContent: "nums" });
{ "end_byte": 260, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpelling7.ts" }
TypeScript/tests/cases/fourslash/moveToNewFile_typeImport2.ts_0_344
/// <reference path="fourslash.ts" /> // @filename: /a.ts ////export interface A { //// x: number; ////} // @Filename: /b.ts ////import { type A } from "./a"; ////[|function f(a: A) {}|] verify.moveToNewFile({ newFileContents: { "/b.ts": "", "/f.ts": `import type { A } from "./a"; function f(a: A) { } `, }, });
{ "end_byte": 344, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_typeImport2.ts" }
TypeScript/tests/cases/fourslash/outliningSpansForFunction.ts_0_1292
/// <reference path="fourslash.ts"/> ////[|( //// a: number, //// b: number ////) => { //// return a + b; ////}|]; //// ////(a: number, b: number) =>[| { //// return a + b; ////}|] //// ////const f1 = function[| ( //// a: number //// b: number ////) { //// return a + b; ////}|] //// ////const f2 = function (a: number, b: number)[| { //// return a + b; ////}|] //// ////function f3[| ( //// a: number //// b: number ////) { //// return a + b; ////}|] //// ////function f4(a: number, b: number)[| { //// return a + b; ////}|] //// ////class Foo[| { //// constructor[|( //// a: number, //// b: number //// ) { //// this.a = a; //// this.b = b; //// }|] //// //// m1[|( //// a: number, //// b: number //// ) { //// return a + b; //// }|] //// //// m1(a: number, b: number)[| { //// return a + b; //// }|] ////}|] //// ////declare function foo(props: any): void; ////foo[|( //// a =>[| { //// //// }|] ////)|] //// ////foo[|( //// (a) =>[| { //// //// }|] ////)|] //// ////foo[|( //// (a, b, c) =>[| { //// //// }|] ////)|] //// ////foo[|([| //// (a, //// b, //// c) => { //// //// }|] ////)|] verify.outliningSpansInCurrentFile(test.ranges());
{ "end_byte": 1292, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/outliningSpansForFunction.ts" }
TypeScript/tests/cases/fourslash/formatAsyncComputedMethod.ts_0_187
/// <reference path="fourslash.ts"/> ////class C { //// /*method*/async [0]() { } ////} format.document(); goTo.marker("method"); verify.currentLineContentIs(" async [0]() { }");
{ "end_byte": 187, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatAsyncComputedMethod.ts" }
TypeScript/tests/cases/fourslash/codeFixClassExtendAbstractPrivateProperty.ts_0_433
/// <reference path='fourslash.ts' /> // @noImplicitOverride: true //// abstract class A { //// private abstract x: number; //// m() { this.x; } // Avoid unused private //// } //// //// class C extends A {[| |]} // We don't know how to fix this problem. We can: // 1) Make x protected, and then insert. // 2) Make x private, and then insert. // 3) Make x not abstract. // So we offer no fixes. verify.not.codeFixAvailable();
{ "end_byte": 433, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassExtendAbstractPrivateProperty.ts" }
TypeScript/tests/cases/fourslash/codeFixAddOptionalParam15.ts_0_138
/// <reference path="fourslash.ts" /> ////function f(a: number, b: number) {} ////f(); verify.not.codeFixAvailable("addOptionalParam");
{ "end_byte": 138, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddOptionalParam15.ts" }
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction2.ts_0_283
/// <reference path='fourslash.ts' /> // @target: es2015 ////async function fn(): boolean {} verify.codeFix({ index: 0, description: [ts.Diagnostics.Replace_0_with_Promise_1.message, "boolean", "boolean"], newFileContent: `async function fn(): Promise<boolean> {}` });
{ "end_byte": 283, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction2.ts" }
TypeScript/tests/cases/fourslash/quickfixAddMissingConstraint5.ts_0_992
/// <reference path="fourslash.ts" /> // @strict: true // @filename: /foo.ts ////export interface RendererElement { //// [key: string]: any ////} //// ////export interface VNode<HostElement extends RendererElement> { //// target: HostElement | null; ////} //// ////export function cloneVNode<U>(vnode: VNode<U>): VNode<U> { //// const cloned: VNode<RendererElement> = { //// target: vnode.target, //// } //// return cloned; ////} goTo.file("/foo.ts"); verify.codeFixAll({ fixId: "addMissingConstraint", fixAllDescription: ts.Diagnostics.Add_extends_constraint_to_all_type_parameters.message, newFileContent: `export interface RendererElement { [key: string]: any } export interface VNode<HostElement extends RendererElement> { target: HostElement | null; } export function cloneVNode<U extends RendererElement>(vnode: VNode<U>): VNode<U> { const cloned: VNode<RendererElement> = { target: vnode.target, } return cloned; }` })
{ "end_byte": 992, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickfixAddMissingConstraint5.ts" }
TypeScript/tests/cases/fourslash/completionsJSDocImportTagAttributesEmptyModuleSpecifier1.ts_0_357
/// <reference path='fourslash.ts' /> // @strict: true // @checkJs: true // @allowJs: true // @filename: global.d.ts //// interface ImportAttributes { //// type: "json"; //// } // @filename: index.js //// /** @import * as ns from "" with { type: "/**/" } */ verify.completions({ marker: "", exact: ["json"], isNewIdentifierLocation: false, });
{ "end_byte": 357, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsJSDocImportTagAttributesEmptyModuleSpecifier1.ts" }
TypeScript/tests/cases/fourslash/signatureHelpForOptionalMethods.ts_0_409
// #39672 // <reference path='fourslash.ts'/> // @strict: true //// interface Obj { //// optionalMethod?: (current: any) => any; //// }; //// //// const o: Obj = { //// optionalMethod(/*1*/) { //// return {}; //// } //// }; verify.signatureHelp( { marker: "1", text: 'optionalMethod(current: any): any', parameterName: "current", parameterSpan: "current: any", }, );
{ "end_byte": 409, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpForOptionalMethods.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesStringLiterals.ts_0_147
/// <reference path='fourslash.ts' /> ////var x = "[|string|]"; ////function f(a = "[|initial value|]") { } verify.baselineDocumentHighlights();
{ "end_byte": 147, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesStringLiterals.ts" }
TypeScript/tests/cases/fourslash/findAllRefsClassExpression0.ts_0_241
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////export = class /*0*/A { //// m() { /*1*/A; } ////}; // @Filename: /b.ts ////import /*2*/A = require("./a"); /////*3*/A; verify.baselineFindAllReferences('0', '1', '2', '3')
{ "end_byte": 241, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsClassExpression0.ts" }
TypeScript/tests/cases/fourslash/tsxCompletionInFunctionExpressionOfChildrenCallback1.ts_0_788
/// <reference path='fourslash.ts' /> //@module: commonjs //@jsx: preserve // @Filename: 1.tsx //// declare module JSX { //// interface Element { } //// interface IntrinsicElements { //// } //// interface ElementAttributesProperty { props; } //// interface ElementChildrenAttribute { children; } //// } //// interface IUser { //// Name: string; //// } //// interface IFetchUserProps { //// children: (user: IUser) => any; //// } //// function FetchUser(props: IFetchUserProps) { return undefined; } //// function UserName() { //// return ( //// <FetchUser> //// { user => ( //// <h1>{ user./**/ }</h1> //// )} //// </FetchUser> //// ); //// } verify.completions({ marker: "", exact: "Name" });
{ "end_byte": 788, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletionInFunctionExpressionOfChildrenCallback1.ts" }
TypeScript/tests/cases/fourslash/navigationItemsPrefixMatch.ts_0_1126
/// <reference path="fourslash.ts"/> // @noLib: true ////[|{| "name": "Shapes", "kind": "module" |}module Shapes { //// [|{| "name": "Point", "kind": "class", "kindModifiers": "export", "containerName": "Shapes", "containerKind": "module" |}export class Point { //// [|{| "name": "originality", "kind": "property", "kindModifiers": "private", "containerName": "Point", "containerKind": "class" |}private originality = 0.0;|] //// //// [|{| "name": "distanceFromOrig", "kind": "property", "kindModifiers": "private", "containerName": "Point", "containerKind": "class" |}private distanceFromOrig = 0.0;|] //// //// [|{| "name": "distanceFarFarAway", "kind": "getter", "containerName": "Point", "containerKind": "class" |}get distanceFarFarAway(): number { return 0; }|] //// }|] ////}|] //// ////var [|{| "name": "xyz", "kind": "var" |}xyz = new Shapes.Point()|]; for (const range of test.ranges()) { const { name } = range.marker.data; verify.navigateTo({ pattern: name.slice(0, name.length - 1), expected: [{ ...range.marker.data, range, matchKind: "prefix" }], }); }
{ "end_byte": 1126, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationItemsPrefixMatch.ts" }
TypeScript/tests/cases/fourslash/addDuplicateSetter.ts_0_155
/// <reference path="fourslash.ts" /> //// class C { //// set foo(value) { } //// /**/ //// } goTo.marker(); edit.insert("set foo(value) { }");
{ "end_byte": 155, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/addDuplicateSetter.ts" }
TypeScript/tests/cases/fourslash/refactorConvertExport_defaultToNamed2.ts_0_1007
/// <reference path='fourslash.ts' /> // @Filename: /a.ts ////const f = () => {}; /////*a*/export default 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": `const f = () => {}; export { 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": 1007, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertExport_defaultToNamed2.ts" }
TypeScript/tests/cases/fourslash/completionListStaticProtectedMembers4.ts_0_2157
/// <reference path='fourslash.ts'/> ////class Base { //// private static privateMethod() { } //// private static privateProperty; //// //// protected static protectedMethod() { } //// protected static protectedProperty; //// //// public static publicMethod() { } //// public static publicProperty; //// //// protected static protectedOverriddenMethod() { } //// protected static protectedOverriddenProperty; ////} //// /////// Make the protected members public ////class C4 extends Base { //// public static protectedOverriddenMethod() { } //// public static protectedOverriddenProperty; ////} ////class Derived extends C4 { //// test() { //// Derived./*1*/ //// } ////} //// Derived./*2*/ const publicCompletions: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> = completion.functionMembersPlus([ { name: "publicMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "publicProperty", sortText: completion.SortText.LocalDeclarationPriority }, ]); verify.completions( { // Sub class, everything but private is visible marker: "1", unsorted: [ { name: "prototype", sortText: completion.SortText.LocationPriority }, { name: "protectedOverriddenMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "protectedOverriddenProperty", sortText: completion.SortText.LocalDeclarationPriority }, { name: "protectedMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "protectedProperty", sortText: completion.SortText.LocalDeclarationPriority }, ...publicCompletions ], }, { // Can see protected methods elevated to public marker: "2", unsorted: [ { name: "prototype", sortText: completion.SortText.LocationPriority }, { name: "protectedOverriddenMethod", sortText: completion.SortText.LocalDeclarationPriority }, { name: "protectedOverriddenProperty", sortText: completion.SortText.LocalDeclarationPriority }, ...publicCompletions, ], }, );
{ "end_byte": 2157, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListStaticProtectedMembers4.ts" }
TypeScript/tests/cases/fourslash/constructorFindAllReferences4.ts_0_194
/// <reference path="fourslash.ts" /> ////export class C { //// /**/protected constructor() { } //// public foo() { } ////} //// ////new C().foo(); verify.baselineFindAllReferences("");
{ "end_byte": 194, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/constructorFindAllReferences4.ts" }
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue8.ts_0_310
/// <reference path='fourslash.ts' /> //// function Foo (a: (() => number) | (() => undefined) ) { a() } //// Foo(() => { 1 }) verify.codeFixAvailable([ { description: ts.Diagnostics.Add_a_return_statement.message }, { description: ts.Diagnostics.Remove_braces_from_arrow_function_body.message } ]);
{ "end_byte": 310, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue8.ts" }
TypeScript/tests/cases/fourslash/exhaustiveCaseCompletions2.ts_0_1687
/// <reference path="fourslash.ts" /> // Import-related cases // @newline: LF // @Filename: /dep.ts //// export enum E { //// A = 0, //// B = "B", //// C = "C", //// } //// declare const u: E.A | E.B | 1; //// export { u }; // @Filename: /main.ts //// import { u } from "./dep"; //// switch (u) { //// case/*1*/ //// } // @Filename: /other.ts //// import * as d from "./dep"; //// declare const u: d.E; //// switch (u) { //// case/*2*/ //// } verify.completions( { marker: "1", isNewIdentifierLocation: false, includes: [ { name: "case E.A: ...", source: completion.CompletionSource.SwitchCases, sortText: completion.SortText.GlobalsOrKeywords, insertText: `case E.A: case E.B: case 1:`, hasAction: true, }, ], preferences: { includeCompletionsWithInsertText: true, }, }, { marker: "2", isNewIdentifierLocation: false, includes: [ { name: "case d.E.A: ...", source: completion.CompletionSource.SwitchCases, sortText: completion.SortText.GlobalsOrKeywords, insertText: `case d.E.A: case d.E.B: case d.E.C:`, }, ], preferences: { includeCompletionsWithInsertText: true, }, }, ); verify.applyCodeActionFromCompletion("1", { name: "case E.A: ...", source: "SwitchCases/", description: "Includes imports of types referenced by 'case E.A: ...'", newFileContent: `import { E, u } from "./dep"; switch (u) { case }`, });
{ "end_byte": 1687, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/exhaustiveCaseCompletions2.ts" }
TypeScript/tests/cases/fourslash/stringCompletionsVsEscaping.ts_0_1153
/// <reference path="fourslash.ts" /> //// type Value<P extends string> = `var(--\\\\, ${P})` //// export const value: Value<'one' | 'two'> = "/*1*/" //// //// export const test: `\ntest\n` = '/*2*/' //// //// export const doubleQuoted1: `"double-quoted"` = '/*3*/' //// export const doubleQuoted2: `"double-quoted"` = "/*4*/" //// //// export const singleQuoted2: `'single-quoted'` = "/*5*/" //// export const singleQuoted2: `'single-quoted'` = '/*6*/' //// //// export const backtickQuoted1: '`backtick-quoted`' = "/*7*/" //// export const backtickQuoted2: '`backtick-quoted`' = `/*8*/` verify.completions({ marker: "1", exact: ["var(--\\\\\\\\, one)", "var(--\\\\\\\\, two)"] }); verify.completions({ marker: "2", exact: ["\\ntest\\n"] }); verify.completions({ marker: "3", exact: ['"double-quoted"'] }); verify.completions({ marker: "4", exact: ['\\\"double-quoted\\\"'] }); verify.completions({ marker: "5", exact: ["'single-quoted'"] }); verify.completions({ marker: "6", exact: ["\\'single-quoted\\'"] }); verify.completions({ marker: "7", exact: ["`backtick-quoted`"] }); verify.completions({ marker: "8", exact: ["\\`backtick-quoted\\`"] });
{ "end_byte": 1153, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/stringCompletionsVsEscaping.ts" }
TypeScript/tests/cases/fourslash/quickInfoEnumMembersAcceptNonAsciiStrings.ts_0_508
/// <reference path='fourslash.ts' /> //// enum Demo { //// /*Emoji*/Emoji = '🍎', //// /*Hebrew*/Hebrew = 'תפוח', //// /*Chinese*/Chinese = '苹果', //// /*Japanese*/Japanese = 'りんご', //// } verify.quickInfoAt("Emoji", '(enum member) Demo.Emoji = "🍎"'); verify.quickInfoAt("Hebrew",'(enum member) Demo.Hebrew = "תפוח"'); verify.quickInfoAt("Chinese", '(enum member) Demo.Chinese = "苹果"'); verify.quickInfoAt("Japanese",'(enum member) Demo.Japanese = "りんご"');
{ "end_byte": 508, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoEnumMembersAcceptNonAsciiStrings.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingAwait_signatures.ts_0_1266
/// <reference path="fourslash.ts" /> ////async function fn(a: Promise<() => void>, b: Promise<() => void> | (() => void), C: Promise<{ new(): any }>) { //// a(); //// b(); //// new C(); ////} verify.codeFix({ description: ts.Diagnostics.Add_await.message, index: 0, newFileContent: `async function fn(a: Promise<() => void>, b: Promise<() => void> | (() => void), C: Promise<{ new(): any }>) { (await a)(); b(); new C(); }` }); verify.codeFix({ description: ts.Diagnostics.Add_await.message, index: 1, newFileContent: `async function fn(a: Promise<() => void>, b: Promise<() => void> | (() => void), C: Promise<{ new(): any }>) { a(); (await b)(); new C(); }` }); verify.codeFix({ description: ts.Diagnostics.Add_await.message, index: 2, newFileContent: `async function fn(a: Promise<() => void>, b: Promise<() => void> | (() => void), C: Promise<{ new(): any }>) { a(); b(); new (await C)(); }` }); verify.codeFixAll({ fixAllDescription: ts.Diagnostics.Fix_all_expressions_possibly_missing_await.message, fixId: "addMissingAwait", newFileContent: `async function fn(a: Promise<() => void>, b: Promise<() => void> | (() => void), C: Promise<{ new(): any }>) { (await a)(); (await b)(); new (await C)(); }` });
{ "end_byte": 1266, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAwait_signatures.ts" }
TypeScript/tests/cases/fourslash/completionInJSDocFunctionNew.ts_1_292
///<reference path="fourslash.ts" /> // @allowJs: true // @Filename: Foo.js /////** @type {function (new: string, string): string} */ ////var f = function () { return new/**/; } verify.completions({ marker: "", includes: { name: "new", sortText: completion.SortText.GlobalsOrKeywords } });
{ "end_byte": 292, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionInJSDocFunctionNew.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageConstructor.ts_0_582
/// <reference path='fourslash.ts' /> // @strictNullChecks: true ////class TokenType { //// label; //// token; //// constructor([|label, token? |]) { //// this.label = label; //// this.token = token || "N/A"; //// } ////} ////new TokenType("HI"); verify.codeFix({ description: "Infer parameter types from usage", index: 2, newFileContent: `class TokenType { label; token; constructor(label: string, token?: string | undefined ) { this.label = label; this.token = token || "N/A"; } } new TokenType("HI");`, });
{ "end_byte": 582, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageConstructor.ts" }
TypeScript/tests/cases/fourslash/noQuickInfoInWhitespace.ts_0_425
/// <reference path='fourslash.ts'/> ////class C { /////*1*/ private _mspointerupHandler(args) { //// if (args.button === 3) { //// return null; /////*2*/ } else if (args.button === 4) { /////*3*/ return null; //// } //// } ////} goTo.marker('1'); verify.not.quickInfoExists(); goTo.marker('2'); verify.not.quickInfoExists(); goTo.marker('3'); verify.not.quickInfoExists();
{ "end_byte": 425, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/noQuickInfoInWhitespace.ts" }
TypeScript/tests/cases/fourslash/codeFixAddParameterNames6.ts_0_278
/// <reference path='fourslash.ts' /> // @noImplicitAny: true ////function fn(f: (...number) => unknown) {} verify.codeFix({ index: 0, description: ts.Diagnostics.Add_parameter_name.message, newFileContent: `function fn(f: (...arg0: number[]) => unknown) {}`, });
{ "end_byte": 278, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddParameterNames6.ts" }
TypeScript/tests/cases/fourslash/codefixEnableJsxFlag_missingCompilerOptionsInJsconfig.ts_0_389
/// <reference path='fourslash.ts' /> // @Filename: /dir/a.tsx ////export const Component = () => <></> // @Filename: /dir/jsconfig.json ////{ ////} goTo.file("/dir/a.tsx"); verify.codeFix({ description: "Enable the '--jsx' flag in your configuration file", newFileContent: { "/dir/jsconfig.json": `{ "compilerOptions": { "jsx": "react" } }`, }, });
{ "end_byte": 389, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codefixEnableJsxFlag_missingCompilerOptionsInJsconfig.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsageVariable4.ts_0_249
/// <reference path='fourslash.ts' /> // @noImplicitAny: false ////[|let foo;|] //// ////foo?.(); ////foo = () => {} verify.codeFix({ description: "Infer type of 'foo' from usage", index: 0, newRangeContent: "let foo: () => void;" });
{ "end_byte": 249, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageVariable4.ts" }
TypeScript/tests/cases/fourslash/extract-const-callback-function-this3.ts_0_608
/// <reference path='fourslash.ts' /> ////declare function fWithThis(fn: (this: { a: string }, a: string) => string): void; ////fWithThis(/*a*/function (this: { a: string }, a) { return this.a; }/*b*/); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "constant_scope_0", actionDescription: "Extract to constant in enclosing scope", newContent: `declare function fWithThis(fn: (this: { a: string }, a: string) => string): void; const newLocal = function(this: { a: string; }, a: string): string { return this.a; }; fWithThis(/*RENAME*/newLocal);` });
{ "end_byte": 608, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const-callback-function-this3.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports9.ts_0_356
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true ////function foo( ){ //// return 42; ////} ////const a = foo(); ////export = a; verify.codeFix({ description: "Add annotation of type 'number'", index: 0, newFileContent: `function foo( ){ return 42; } const a: number = foo(); export = a;`, });
{ "end_byte": 356, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports9.ts" }
TypeScript/tests/cases/fourslash/completionListBuilderLocations_properties.ts_0_292
/// <reference path='fourslash.ts' /> ////var aa = 1; ////class A1 { //// public static /*property1*/ ////} ////class A2 { //// public static a/*property2*/ ////} verify.completions({ marker: test.markers(), exact: completion.classElementKeywords, isNewIdentifierLocation: true });
{ "end_byte": 292, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListBuilderLocations_properties.ts" }
TypeScript/tests/cases/fourslash/codeFixSpellingPrivatePropertyNameNotInScope.ts_0_354
/// <reference path='fourslash.ts' /> ////class A { //// #foo: number; //// constructor() { //// } ////} ////let a = new A(); ////[|a.foo = 1;|] verify.codeFixAvailable([ { description: "Declare property 'foo'" }, { description: "Add index signature for property 'foo'" }, { description: "Remove unused declaration for: '#foo'" } ]);
{ "end_byte": 354, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingPrivatePropertyNameNotInScope.ts" }
TypeScript/tests/cases/fourslash/codeFixDeleteUnmatchedParameter2.ts_0_453
/// <reference path='fourslash.ts' /> // @filename: a.ts /////** //// * @param {number} a //// * @param {string} b //// */ ////function foo(a: number) { //// a; ////} verify.codeFixAvailable([ { description: "Delete unused '@param' tag 'b'" }, ]); verify.codeFix({ description: [ts.Diagnostics.Delete_unused_param_tag_0.message, "b"], index: 0, newFileContent: `/** * @param {number} a */ function foo(a: number) { a; }` });
{ "end_byte": 453, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixDeleteUnmatchedParameter2.ts" }
TypeScript/tests/cases/fourslash/pathCompletionsTypesVersionsLocal.ts_0_418
/// <reference path="fourslash.ts" /> // @Filename: /package.json //// { //// "typesVersions": { //// "*": { //// "*": ["./src/*"] //// } //// } //// } // @Filename: /src/add.ts //// export function add(a: number, b: number) { return a + b; } // @Filename: /src/index.ts //// import { add } from ".//**/"; verify.completions({ marker: "", isNewIdentifierLocation: true, exact: ["add"], });
{ "end_byte": 418, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsTypesVersionsLocal.ts" }
TypeScript/tests/cases/fourslash/formatTypeAnnotation1.ts_0_370
/// <reference path='fourslash.ts' /> ////function foo(x: number, y?: string): number {} ////interface Foo { //// x: number; //// y?: number; ////} format.setOption("insertSpaceBeforeTypeAnnotation", true); format.document(); verify.currentFileContentIs( `function foo(x : number, y ?: string) : number { } interface Foo { x : number; y ?: number; }` );
{ "end_byte": 370, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatTypeAnnotation1.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports13.ts_0_477
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true //// function foo() { //// return { x: 1, y: 1 }; //// } //// export const { x: abcd, y: defg } = foo(); verify.codeFix({ description: ts.Diagnostics.Extract_binding_expressions_to_variable.message, index: 0, newFileContent: `function foo() { return { x: 1, y: 1 }; } const dest = foo(); export const abcd: number = dest.x; export const defg: number = dest.y;` });
{ "end_byte": 477, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports13.ts" }
TypeScript/tests/cases/fourslash/organizeImportsType10.ts_0_1071
/// <reference path="fourslash.ts" /> ////import { //// type Type1, //// type Type2, //// func4, //// type Type3, //// type Type4, //// type Type5, //// type Type7, //// type Type8, //// type Type9, //// func1, //// func2, //// type Type6, //// func3, //// func5, //// func6, //// func7, //// func8, //// func9, ////} from "foo"; ////interface Use extends Type1, Type2, Type3, Type4, Type5, Type6, Type7, Type8, Type9 {} ////console.log(func1, func2, func3, func4, func5, func6, func7, func8, func9); verify.organizeImports( `import { type Type1, type Type2, type Type3, type Type4, type Type5, type Type6, type Type7, type Type8, type Type9, func1, func2, func3, func4, func5, func6, func7, func8, func9, } from "foo"; interface Use extends Type1, Type2, Type3, Type4, Type5, Type6, Type7, Type8, Type9 {} console.log(func1, func2, func3, func4, func5, func6, func7, func8, func9);`, /*mode*/ undefined, { organizeImportsIgnoreCase: true });
{ "end_byte": 1071, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsType10.ts" }
TypeScript/tests/cases/fourslash/goToImplementationNamespace_03.ts_0_637
/// <reference path='fourslash.ts'/> // Should handle types that are members of a namespace in type references and heritage clauses //// namespace Foo { //// export interface Bar { //// hello(): void; //// } //// //// class [|BarImpl|] implements Bar { //// hello() {} //// } //// } //// //// class [|Baz|] implements Foo.Bar { //// hello() {} //// } //// //// var someVar1 : Foo.Bar = [|{ hello: () => {/**1*/} }|]; //// //// var someVar2 = <Foo.Bar> [|{ hello: () => {/**2*/} }|]; //// //// function whatever(x: Foo.Ba/*reference*/r) { //// //// } verify.baselineGoToImplementation("reference");
{ "end_byte": 637, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationNamespace_03.ts" }
TypeScript/tests/cases/fourslash/inlayHintsPropertyDeclarations2.ts_0_452
/// <reference path="fourslash.ts" /> // @strict: true // @target: esnext //// class C { //// accessor a = 1 //// accessor b: number = 2 //// accessor c; //// accessor d; //// //// constructor(value: number) { //// this.d = value; //// if (value <= 0) { //// this.d = null; //// } //// } //// } verify.baselineInlayHints(undefined, { includeInlayPropertyDeclarationTypeHints: true, });
{ "end_byte": 452, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsPropertyDeclarations2.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionOverriddenMember8.ts_0_289
/// <reference path="./fourslash.ts"/> // @noImplicitOverride: true // @Filename: ./a.ts ////export class A { //// /*2*/m() {} ////} // @Filename: ./b.ts ////import { A } from "./a"; ////class B extends A { //// [|/*1*/override|] m() {} ////} verify.baselineGoToDefinition("1");
{ "end_byte": 289, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionOverriddenMember8.ts" }
TypeScript/tests/cases/fourslash/inlayHintsRestParameters2.ts_0_548
/// <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" });
{ "end_byte": 548, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsRestParameters2.ts" }
TypeScript/tests/cases/fourslash/completionsOverridingMethodCrash1.ts_0_787
/// <reference path="fourslash.ts" /> // @newline: LF // @Filename: a.ts ////declare class Component<T> { //// setState(stateHandler: ((oldState: T, newState: T) => void)): void; ////} //// ////class SubComponent extends Component<{}> { //// /*$*/ ////} verify.completions({ marker: "$", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, includes: [ { name: "setState", sortText: completion.SortText.LocationPriority, insertText: "setState(stateHandler: (oldState: {}, newState: {}) => void): void {\n}", filterText: "setState", } ] });
{ "end_byte": 787, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingMethodCrash1.ts" }
TypeScript/tests/cases/fourslash/renameDefaultImportDifferentName.ts_0_594
/// <reference path='fourslash.ts' /> // @Filename: B.ts ////[|export default class /*1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}C|] { //// test() { //// } ////}|] // @Filename: A.ts ////[|import /*2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}B|] from "./B";|] ////let b = new [|B|](); ////b.test(); const [CDef, C, B0Def, B0, B1] = test.ranges(); const bRanges = [B0, B1]; verify.baselineFindAllReferences('1', '2'); verify.baselineRename(C); verify.baselineRename(bRanges); verify.baselineDocumentHighlights("1");
{ "end_byte": 594, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameDefaultImportDifferentName.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_import_objectBindingPattern_complex.ts_0_287
/// <reference path='fourslash.ts' /> // @allowJs: true // @target: esnext // @Filename: /a.js ////const { x: { a, b } } = require("x"); ////a; b; verify.codeFix({ description: "Convert to ES module", newFileContent: `import x from "x"; const { x: { a, b } } = x; a; b;`, });
{ "end_byte": 287, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_import_objectBindingPattern_complex.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties32.ts_0_389
/// <reference path="fourslash.ts" /> // @filename: E.ts ////export enum E { //// A, //// B, ////} // @filename: foo.ts ////import { E } from "./E" ////type T = { //// e: E, ////} ////[|const t: T = { }|] goTo.file('foo.ts'); verify.codeFix({ index: 0, description: ts.Diagnostics.Add_missing_properties.message, newRangeContent: `const t: T = { e: E.A }`, });
{ "end_byte": 389, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties32.ts" }
TypeScript/tests/cases/fourslash/quickInfoRecursiveObjectLiteral.ts_0_101
///<reference path="fourslash.ts" /> ////var a = { f: /**/a verify.quickInfoAt("", "var a: any");
{ "end_byte": 101, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoRecursiveObjectLiteral.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingEnumMember3.ts_0_242
/// <reference path='fourslash.ts' /> ////enum E { //// a, //// b = 1, //// c ////} ////E.d verify.codeFix({ description: "Add missing enum member 'd'", newFileContent: `enum E { a, b = 1, c, d } E.d` });
{ "end_byte": 242, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingEnumMember3.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_typeParameter5.ts_0_346
/// <reference path="fourslash.ts" /> // @noUnusedLocals: true // @noUnusedParameters: true ////function f< //// T1, //// T2, //// //// //// T3, ////>(a: T1, b: T3) {} verify.codeFix({ index: 0, description: "Remove unused declaration for: 'T2'", newFileContent: `function f< T1, T3, >(a: T1, b: T3) {}` });
{ "end_byte": 346, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_typeParameter5.ts" }
TypeScript/tests/cases/fourslash/completionsObjectLiteralExpressions10.ts_0_1028
/// <reference path="fourslash.ts" /> //// interface TTTT { //// aaa: string, //// bbb?: number //// } //// const uuu: TTTT = { //// get aaa() { //// return "" //// } //// /**/ //// } verify.completions({ marker: "", includes: [{ name: "bbb", sortText: completion.SortText.OptionalMember, hasAction: true, source: completion.CompletionSource.ObjectLiteralMemberWithComma, }], preferences: { allowIncompleteCompletions: true, includeInsertTextCompletions: true, }, }); verify.applyCodeActionFromCompletion("", { name: "bbb", description: `Add missing comma for object member completion 'bbb'.`, source: completion.CompletionSource.ObjectLiteralMemberWithComma, newFileContent: `interface TTTT { aaa: string, bbb?: number } const uuu: TTTT = { get aaa() { return "" }, }`, preferences: { allowIncompleteCompletions: true, includeInsertTextCompletions: true, }, });
{ "end_byte": 1028, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsObjectLiteralExpressions10.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_parameter_modifier.ts_0_435
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true // @noUnusedParameters: true ////export class Example { //// prop: any; //// constructor(private readonly arg: any) { //// this.prop = arg; //// } ////} verify.codeFix({ description: "Remove unused declaration for: 'arg'", newFileContent: `export class Example { prop: any; constructor(arg: any) { this.prop = arg; } }`, });
{ "end_byte": 435, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_parameter_modifier.ts" }
TypeScript/tests/cases/fourslash/completionAfterNewline2.ts_0_415
/// <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 = 5 as const /*1*/ /////*2*/ verify.completions( { marker: "1", exact: undefined }, { marker: "2", exact: completion.globalsPlus([ { name: "foo", }, ]), } );
{ "end_byte": 415, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionAfterNewline2.ts" }
TypeScript/tests/cases/fourslash/codeFixSpellingJs8.ts_0_183
/// <reference path='fourslash.ts' /> // @allowjs: true // @noEmit: true // @filename: a.js //// var locals = {} //// // @ts-expect-error //// Object.keys(locale) verify.noErrors()
{ "end_byte": 183, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingJs8.ts" }
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts_0_634
/// <reference path='fourslash.ts' /> //// function f(templateStrings: string[], p1_o1: string): number; //// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; //// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; //// function f(...foo[]: any) { return ""; } //// //// f `${/*1*/ /*2*/ /*3*/ verify.signatureHelp({ marker: test.markers(), overloadsCount: 3, text: "f(templateStrings: string[], p1_o1: string): number", argumentCount: 2, parameterCount: 2, parameterName: "p1_o1", parameterSpan: "p1_o1: string", });
{ "end_byte": 634, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts" }
TypeScript/tests/cases/fourslash/genericsFormatting.ts_0_1857
/// <reference path='fourslash.ts' /> /////*inClassDeclaration*/class Foo < T1 , T2 > { /////*inMethodDeclaration*/ public method < T3, T4 > ( a: T1, b: Array < T4 > ): Map < T1 , T2, Array < T3 > > { //// } ////} /////*typeArguments*/var foo = new Foo < number, Array < number > > ( ); /////*typeArgumentsWithTypeLiterals*/foo = new Foo < { bar : number }, Array < { baz : string } > > ( ); //// ////interface IFoo { /////*inNewSignature*/new < T > ( a: T); /////*inOptionalMethodSignature*/op?< T , M > (a: T, b : M ); ////} //// ////foo()<number, string, T >(); ////(a + b)<number, string, T >(); //// /////*inFunctionDeclaration*/function bar <T> () { /////*inClassExpression*/ return class < T2 > { //// } ////} /////*expressionWithTypeArguments*/class A < T > extends bar < T >( ) < T > { ////} format.document(); goTo.marker("inClassDeclaration"); verify.currentLineContentIs("class Foo<T1, T2> {"); goTo.marker("inMethodDeclaration"); verify.currentLineContentIs(" public method<T3, T4>(a: T1, b: Array<T4>): Map<T1, T2, Array<T3>> {"); goTo.marker("typeArguments"); verify.currentLineContentIs("var foo = new Foo<number, Array<number>>();"); goTo.marker("typeArgumentsWithTypeLiterals"); verify.currentLineContentIs("foo = new Foo<{ bar: number }, Array<{ baz: string }>>();"); goTo.marker("inNewSignature"); verify.currentLineContentIs(" new <T>(a: T);"); goTo.marker("inOptionalMethodSignature"); verify.currentLineContentIs(" op?<T, M>(a: T, b: M);"); goTo.marker("inFunctionDeclaration"); verify.currentLineContentIs("function bar<T>() {"); goTo.marker("inClassExpression"); verify.currentLineContentIs(" return class <T2> {"); goTo.marker("expressionWithTypeArguments"); verify.currentLineContentIs("class A<T> extends bar<T>()<T> {");
{ "end_byte": 1857, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericsFormatting.ts" }
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc18.ts_0_329
/// <reference path='fourslash.ts' /> ////class C { //// /** @param {number} value */ //// set c(value) { return value } ////} verify.codeFix({ description: "Annotate with type from JSDoc", index: 0, newFileContent: `class C { /** @param {number} value */ set c(value: number) { return value } }`, });
{ "end_byte": 329, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc18.ts" }
TypeScript/tests/cases/fourslash/referencesForNoContext.ts_0_426
/// <reference path='fourslash.ts'/> ////module modTest { //// //Declare //// export var modVar:number; //// /*1*/ //// //// //Increments //// modVar++; //// //// class testCls{ //// /*2*/ //// } //// //// function testFn(){ //// //Increments //// modVar++; //// } /*3*/ /////*4*/ //// module testMod { //// } ////} verify.baselineFindAllReferences('1', '2', '3', '4')
{ "end_byte": 426, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForNoContext.ts" }
TypeScript/tests/cases/fourslash/completionEntryForDeferredMappedTypeMembers.ts_0_348
/// <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 = foo(a); //// out./*1*/a //// out.a./*2*/a //// out.a.a./*3*/a verify.completions({ marker: test.markers(), exact: "a" });
{ "end_byte": 348, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionEntryForDeferredMappedTypeMembers.ts" }
TypeScript/tests/cases/fourslash/inlayHintsInteractiveFunctionParameterTypes5.ts_0_224
/// <reference path="fourslash.ts" /> ////const foo: 1n = 1n; ////export function fn(b = foo) {} verify.baselineInlayHints(undefined, { includeInlayFunctionParameterTypeHints: true, interactiveInlayHints: true });
{ "end_byte": 224, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveFunctionParameterTypes5.ts" }
TypeScript/tests/cases/fourslash/recursiveGenerics2.ts_0_171
/// <reference path="fourslash.ts" /> //// class S18<B, B, A, B> extends S18<A[], { S19: A; (): A }[]> { } //// /**/ goTo.marker(); edit.insert('(new S18()).S18 = 0;');
{ "end_byte": 171, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/recursiveGenerics2.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingConstInForInLoop1.ts_0_182
/// <reference path='fourslash.ts' /> ////for (x in []) {} verify.codeFix({ description: "Add 'const' to unresolved variable", newFileContent: "for (const x in []) {}" });
{ "end_byte": 182, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingConstInForInLoop1.ts" }
TypeScript/tests/cases/fourslash/formatRemoveSemicolons1.ts_0_957
/// <reference path="fourslash.ts" /> ////; (function f() { })(); ////const a = 3; ////+ 4; ////const b = 3 ////+ 4; ////const c = 3 + ////4; ////class C { //// prop; //// ["p"]; //// zero: void; //// ["one"] = {}; //// ["two"]; //// ; ////} ////a; ////`b`; ////b; ////(3); ////4; //// / regex /; ////; ////[]; /////** blah */[0]; ////interface I { //// new; //// (); //// foo; //// (); ////} ////type T = { //// new; //// (); //// foo; //// (); ////} format.setFormatOptions({ ...format.copyFormatOptions(), semicolons: ts.SemicolonPreference.Remove }); format.document(); verify.currentFileContentIs(`; (function f() { })() const a = 3; + 4 const b = 3 + 4 const c = 3 + 4 class C { prop ["p"] zero: void ["one"] = {}; ["two"] ; } a; \`b\` b; (3) 4; / regex / ; []; /** blah */[0] interface I { new; () foo; () } type T = { new; () foo; () }`);
{ "end_byte": 957, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatRemoveSemicolons1.ts" }
TypeScript/tests/cases/fourslash/completionsImportTypeKeyword.ts_0_609
/// <reference path="fourslash.ts" /> // @module: nodenext // @Filename: /os.d.ts //// declare module "os" { //// export function type(): string; //// } // @Filename: /index.ts //// type/**/ verify.completions({ marker: "", includes: [ { name: "type", sortText: completion.SortText.GlobalsOrKeywords, }, { name: "type", source: "os", sourceDisplay: "os", hasAction: true, sortText: completion.SortText.AutoImportSuggestions } ], preferences: { includeCompletionsForModuleExports: true, allowIncompleteCompletions: true, }, });
{ "end_byte": 609, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImportTypeKeyword.ts" }
TypeScript/tests/cases/fourslash/quickInfoJsDocTags2.ts_0_159
/// <reference path='fourslash.ts'/> // @Filename: quickInfoJsDocTags2.ts /////** Doc */ ////const /**/x = 0; verify.quickInfoAt("", "const x: 0", "Doc");
{ "end_byte": 159, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTags2.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixUMDGlobalReact0.ts_0_950
/// <reference path="fourslash.ts" /> // @jsx: react // @allowSyntheticDefaultImports: false // @module: es2015 // @moduleResolution: node // @Filename: /node_modules/@types/react/index.d.ts ////export = React; ////export as namespace React; ////declare namespace React { //// export class Component { render(): JSX.Element | null; } ////} ////declare global { //// namespace JSX { //// interface Element {} //// } ////} // @Filename: /a.tsx ////[|import { Component } from "react"; ////export class MyMap extends Component { } ////<MyMap/>;|] // @Filename: /b.tsx ////[|import { Component } from "react"; ////<></>;|] goTo.file("/a.tsx"); verify.importFixAtPosition([ `import * as React from "react"; import { Component } from "react"; export class MyMap extends Component { } <MyMap/>;`]); goTo.file("/b.tsx"); verify.importFixAtPosition([ `import * as React from "react"; import { Component } from "react"; <></>;`]);
{ "end_byte": 950, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixUMDGlobalReact0.ts" }
TypeScript/tests/cases/fourslash/unusedParameterInLambda1AddUnderscore.ts_0_218
/// <reference path='fourslash.ts' /> // @noUnusedParameters: true ////(x: number) => {} verify.codeFix({ description: "Prefix 'x' with an underscore", index: 1, newFileContent: "(_x: number) => {}", });
{ "end_byte": 218, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedParameterInLambda1AddUnderscore.ts" }
TypeScript/tests/cases/fourslash/completionsInRequire.ts_0_448
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: foo.js ////var foo = require("/**/" //// ////foo(); //// /////** //// * @return {void} //// */ ////function foo() { ////} // @Filename: package.json //// { "dependencies": { "fake-module": "latest" } } // @Filename: node_modules/fake-module/index.js /////* fake-module */ verify.completions({ marker: "", exact: ["fake-module"], isNewIdentifierLocation: true })
{ "end_byte": 448, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsInRequire.ts" }
TypeScript/tests/cases/fourslash/quickInfoContextualTyping.ts_0_5428
/// <reference path='fourslash.ts' /> ////// DEFAULT INTERFACES ////interface IFoo { //// n: number; //// s: string; //// f(i: number, s: string): string; //// a: number[]; ////} ////interface IBar { //// foo: IFoo; ////} ////// CONTEXT: Class property declaration ////class C1T5 { //// /*1*/foo: (i: number, s: string) => number = function(/*2*/i) { //// return /*3*/i; //// } ////} ////// CONTEXT: Module property declaration ////module C2T5 { //// export var /*4*/foo: (i: number, s: string) => number = function(/*5*/i) { //// return /*6*/i; //// } ////} ////// CONTEXT: Variable declaration ////var /*7*/c3t1: (s: string) => string = (function(/*8*/s) { return /*9*/s }); ////var /*10*/c3t2 = <IFoo>({ //// n: 1 ////}) ////var /*11*/c3t3: number[] = []; ////var /*12*/c3t4: () => IFoo = function() { return <IFoo>({}) }; ////var /*13*/c3t5: (n: number) => IFoo = function(/*14*/n) { return <IFoo>({}) }; ////var /*15*/c3t6: (n: number, s: string) => IFoo = function(/*16*/n, /*17*/s) { return <IFoo>({}) }; ////var /*18*/c3t7: { //// (n: number): number; //// (s1: string): number; ////}; ////var /*20*/c3t8: (n: number, s: string) => number = function(/*21*/n) { return n; }; ////var /*22*/c3t9: number[][] = [[],[]]; ////var /*23*/c3t10: IFoo[] = [<IFoo>({}),<IFoo>({})]; ////var /*24*/c3t11: {(n: number, s: string): string;}[] = [function(/*25*/n, /*26*/s) { return s; }]; ////var /*27*/c3t12: IBar = { //// /*28*/foo: <IFoo>({}) ////} ////var /*29*/c3t13 = <IFoo>({ //// /*30*/f: function(/*31*/i, /*32*/s) { return s; } ////}) ////var /*33*/c3t14 = <IFoo>({ //// /*34*/a: [] ////}) ////// CONTEXT: Class property assignment ////class C4T5 { //// /*35*/foo: (i: number, s: string) => string; //// constructor() { //// this.foo = function(/*36*/i, /*37*/s) { //// return s; //// } //// } ////} ////// CONTEXT: Module property assignment ////module C5T5 { //// export var /*38*/foo: (i: number, s: string) => string; //// foo = function(/*39*/i, /*40*/s) { //// return s; //// } ////} ////// CONTEXT: Variable assignment ////var /*41*/c6t5: (n: number) => IFoo; ////c6t5 = <(n: number) => IFoo>function(/*42*/n) { return <IFoo>({}) }; ////// CONTEXT: Array index assignment ////var /*43*/c7t2: IFoo[]; /////*44*/c7t2[0] = <IFoo>({n: 1}); ////// CONTEXT: Object property assignment ////interface IPlaceHolder { //// t1: (s: string) => string; //// t2: IFoo; //// t3: number[]; //// t4: () => IFoo; //// t5: (n: number) => IFoo; //// t6: (n: number, s: string) => IFoo; //// t7: { //// (n: number, s: string): number; //// //(s1: string, s2: string): number; //// }; //// t8: (n: number, s: string) => number; //// t9: number[][]; //// t10: IFoo[]; //// t11: {(n: number, s: string): string;}[]; //// t12: IBar; //// t13: IFoo; //// t14: IFoo; //// } ////var objc8: { //// t1: (s: string) => string; //// t2: IFoo; //// t3: number[]; //// t4: () => IFoo; //// t5: (n: number) => IFoo; //// t6: (n: number, s: string) => IFoo; //// t7: { //// (n: number, s: string): number; //// //(s1: string, s2: string): number; //// }; //// t8: (n: number, s: string) => number; //// t9: number[][]; //// t10: IFoo[]; //// t11: {(n: number, s: string): string;}[]; //// t12: IBar; //// t13: IFoo; //// t14: IFoo; ////} = <IPlaceHolder>({}); ////objc8./*45*/t1 = (function(/*46*/s) { return s }); ////objc8./*47*/t2 = <IFoo>({ //// n: 1 ////}); ////objc8./*48*/t3 = []; ////objc8./*49*/t4 = function() { return <IFoo>({}) }; ////objc8./*50*/t5 = function(/*51*/n) { return <IFoo>({}) }; ////objc8./*52*/t6 = function(/*53*/n, /*54*/s) { return <IFoo>({}) }; ////objc8./*55*/t7 = function(n: number) { return n }; ////objc8./*56*/t8 = function(/*57*/n) { return n; }; ////objc8./*58*/t9 = [[],[]]; ////objc8./*59*/t10 = [<IFoo>({}),<IFoo>({})]; ////objc8./*60*/t11 = [function (/*61*/n, /*62*/s) { return s; }]; ////objc8./*63*/t12 = { //// /*64*/foo: <IFoo>({}) ////} ////objc8./*65*/t13 = <IFoo>({ //// /*66*/f: function(/*67*/i, /*68*/s) { return s; } ////}) ////objc8./*69*/t14 = <IFoo>({ //// /*70*/a: [] ////}) ////// CONTEXT: Function call ////function c9t5(f: (n: number) => IFoo) {}; ////c9t5(function(/*71*/n) { //// return <IFoo>({}); ////}); ////// CONTEXT: Return statement ////var /*72*/c10t5: () => (n: number) => IFoo = function() { return function(/*73*/n) { return <IFoo>({}) } }; ////// CONTEXT: Newing a class ////class C11t5 { constructor(f: (n: number) => IFoo) { } }; ////var i = new C11t5(function(/*74*/n) { return <IFoo>({}) }); ////// CONTEXT: Type annotated expression ////var /*75*/c12t1 = <(s: string) => string> (function (/*76*/s) { return s }); ////var /*77*/c12t2 = <IFoo> ({ //// n: 1 ////}); ////var /*78*/c12t3 = <number[]> []; ////var /*79*/c12t4 = <() => IFoo> function() { return <IFoo>({}) }; ////var /*80*/c12t5 = <(n: number) => IFoo> function(/*81*/n) { return <IFoo>({}) }; ////var /*82*/c12t6 = <(n: number, s: string) => IFoo> function(/*83*/n, /*84*/s) { return <IFoo>({}) }; ////var /*85*/c12t7 = <{ //// (n: number, s: string): number; //// //(s1: string, s2: string): number; ////}> function(n:number) { return n }; ////var /*86*/c12t8 = <(n: number, s: string) => number> function (/*87*/n) { return n; };
{ "end_byte": 5428, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoContextualTyping.ts" }
TypeScript/tests/cases/fourslash/quickInfoContextualTyping.ts_5429_6703
////var /*88*/c12t9 = <number[][]> [[],[]]; ////var /*89*/c12t10 = <IFoo[]> [<IFoo>({}),<IFoo>({})]; ////var /*90*/c12t11 = <{ (n: number, s: string): string; }[]>[function (/*91*/n, /*92*/s) { return s; }]; ////var /*93*/c12t12 = <IBar> { //// /*94*/foo: <IFoo>({}) ////} ////var /*95*/c12t13 = <IFoo> ({ //// /*96*/f: function(/*97*/i, /*98*/s) { return s; } ////}) ////var /*99*/c12t14 = <IFoo> ({ //// /*100*/a: [] ////}) ////// CONTEXT: Contextual typing declarations ////// contextually typing function declarations ////function EF1(a: number, b:number):number; ////function /*101*/EF1(/*102*/a,/*103*/b) { return a+b; } ////var efv = EF1(1,2); ////// contextually typing from ambient class declarations ////declare class Point ////{ //// constructor(x: number, y: number); //// x: number; //// y: number; //// add(dx: number, dy: number): Point; //// static origin: Point; ////} ////Point./*110*/origin = new /*111*/Point(0, 0); ////Point.prototype./*112*/add = function (/*113*/dx, /*114*/dy) { //// return new Point(this.x + dx, this.y + dy); ////}; ////Point.prototype = { //// x: 0, //// y: 0, //// /*115*/add: function (/*116*/dx, /*117*/dy) { //// return new Point(this.x + dx, this.y + dy); //// } ////};
{ "end_byte": 6703, "start_byte": 5429, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoContextualTyping.ts" }
TypeScript/tests/cases/fourslash/quickInfoContextualTyping.ts_6705_11020
verify.quickInfos({ 1: "(property) C1T5.foo: (i: number, s: string) => number", 2: "(parameter) i: number", 3: "(parameter) i: number", 4: "var C2T5.foo: (i: number, s: string) => number", 5: "(parameter) i: number", 6: "(parameter) i: number", 7: "var c3t1: (s: string) => string", 8: "(parameter) s: string", 9: "(parameter) s: string", 10: "var c3t2: IFoo", 11: "var c3t3: number[]", 12: "var c3t4: () => IFoo", 13: "var c3t5: (n: number) => IFoo", 14: "(parameter) n: number", 15: "var c3t6: (n: number, s: string) => IFoo", 16: "(parameter) n: number", 17: "(parameter) s: string", 18: "var c3t7: {\n (n: number): number;\n (s1: string): number;\n}", 20: "var c3t8: (n: number, s: string) => number", 21: "(parameter) n: number", 22: "var c3t9: number[][]", 23: "var c3t10: IFoo[]", 24: "var c3t11: ((n: number, s: string) => string)[]", 25: "(parameter) n: number", 26: "(parameter) s: string", 27: "var c3t12: IBar", 28: "(property) IBar.foo: IFoo", 29: "var c3t13: IFoo", 30: "(method) IFoo.f(i: number, s: string): string", 31: "(parameter) i: number", 32: "(parameter) s: string", 33: "var c3t14: IFoo", 34: "(property) IFoo.a: number[]", 35: "(property) C4T5.foo: (i: number, s: string) => string", 36: "(parameter) i: number", 37: "(parameter) s: string", 38: "var C5T5.foo: (i: number, s: string) => string", 39: "(parameter) i: number", 40: "(parameter) s: string", 41: "var c6t5: (n: number) => IFoo", 42: "(parameter) n: number", 43: "var c7t2: IFoo[]", 44: "var c7t2: IFoo[]", 45: "(property) t1: (s: string) => string", 46: "(parameter) s: string", 47: "(property) t2: IFoo", 48: "(property) t3: number[]", 49: "(property) t4: () => IFoo", 50: "(property) t5: (n: number) => IFoo", 51: "(parameter) n: number", 52: "(property) t6: (n: number, s: string) => IFoo", 53: "(parameter) n: number", 54: "(parameter) s: string", 55: "(property) t7: (n: number, s: string) => number", 56: "(property) t8: (n: number, s: string) => number", 57: "(parameter) n: number", 58: "(property) t9: number[][]", 59: "(property) t10: IFoo[]", 60: "(property) t11: ((n: number, s: string) => string)[]", 61: "(parameter) n: number", 62: "(parameter) s: string", 63: "(property) t12: IBar", 64: "(property) IBar.foo: IFoo", 65: "(property) t13: IFoo", 66: "(method) IFoo.f(i: number, s: string): string", 67: "(parameter) i: number", 68: "(parameter) s: string", 69: "(property) t14: IFoo", 70: "(property) IFoo.a: number[]", 71: "(parameter) n: number", 72: "var c10t5: () => (n: number) => IFoo", 73: "(parameter) n: number", 74: "(parameter) n: number", 75: "var c12t1: (s: string) => string", 76: "(parameter) s: string", 77: "var c12t2: IFoo", 78: "var c12t3: number[]", 79: "var c12t4: () => IFoo", 80: "var c12t5: (n: number) => IFoo", 81: "(parameter) n: number", 82: "var c12t6: (n: number, s: string) => IFoo", 83: "(parameter) n: number", 84: "(parameter) s: string", 85: "var c12t7: (n: number, s: string) => number", 86: "var c12t8: (n: number, s: string) => number", 87: "(parameter) n: number", 88: "var c12t9: number[][]", 89: "var c12t10: IFoo[]", 90: "var c12t11: ((n: number, s: string) => string)[]", 91: "(parameter) n: number", 92: "(parameter) s: string", 93: "var c12t12: IBar", 94: "(property) IBar.foo: IFoo", 95: "var c12t13: IFoo", 96: "(method) IFoo.f(i: number, s: string): string", 97: "(parameter) i: number", 98: "(parameter) s: string", 99: "var c12t14: IFoo", 100: "(property) IFoo.a: number[]", 101: "function EF1(a: number, b: number): number", 102: "(parameter) a: any", 103: "(parameter) b: any", 110: "(property) Point.origin: Point", 111: "constructor Point(x: number, y: number): Point", 112: "(method) Point.add(dx: number, dy: number): Point", 113: "(parameter) dx: number", 114: "(parameter) dy: number", 115: "(method) Point.add(dx: number, dy: number): Point", 116: "(parameter) dx: number", 117: "(parameter) dy: number" });
{ "end_byte": 11020, "start_byte": 6705, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoContextualTyping.ts" }
TypeScript/tests/cases/fourslash/moveToFile_differentDirectories2.ts_0_628
/// <reference path='fourslash.ts' /> //@moduleResolution: bundler //@module: esnext // @Filename: /src/dir1/a.ts ////import { b } from './other'; ////const a = 10; ////[|const y = b + a;|] ////y; // @Filename: /src/dir1/other.ts ////export const b = 1; //@Filename: /src/dir2/bar.ts //// verify.moveToFile({ newFileContents: { "/src/dir1/a.ts": `import { y } from '../dir2/bar'; export const a = 10; y;`, "/src/dir2/bar.ts": `import { a } from '../dir1/a'; import { b } from '../dir1/other'; export const y = b + a; `, }, interactiveRefactorArguments: { targetFile: "/src/dir2/bar.ts" } });
{ "end_byte": 628, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_differentDirectories2.ts" }
TypeScript/tests/cases/fourslash/quickinfoForUnionProperty.ts_0_466
/// <reference path="fourslash.ts"/> ////interface One { //// commonProperty: number; //// commonFunction(): number; ////} //// ////interface Two { //// commonProperty: string //// commonFunction(): number; ////} //// ////var /*1*/x : One | Two; //// ////x./*2*/commonProperty; ////x./*3*/commonFunction; verify.quickInfos({ 1: "var x: One | Two", 2: "(property) commonProperty: string | number", 3: "(method) commonFunction(): number" });
{ "end_byte": 466, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickinfoForUnionProperty.ts" }
TypeScript/tests/cases/fourslash/completionsJSDocTags.ts_0_1466
///<reference path="fourslash.ts" /> //// /** //// * This is class Foo. //// * @mytag comment1 comment2 //// */ //// class Foo { //// /** //// * This is the constructor. //// * @myjsdoctag this is a comment //// */ //// constructor(value: number) {} //// /** //// * method1 documentation //// * @mytag comment1 comment2 //// */ //// static method1() {} //// /** //// * @mytag //// */ //// method2() {} //// /** //// * @mytag comment1 comment2 //// */ //// property1: string; //// /** //// * @mytag1 some comments //// * some more comments about mytag1 //// * @mytag2 //// * here all the comments are on a new line //// * @mytag3 //// * @mytag //// */ //// property2: number; //// /** //// * @returns {number} a value //// */ //// method3(): number { return 3; } //// /** //// * @param {string} foo A value. //// * @returns {number} Another value //// * @mytag //// */ //// method4(foo: string): number { return 3; } //// /** @mytag */ //// method5() {} //// /** method documentation //// * @mytag a JSDoc tag //// */ //// newMethod() {} //// } //// var foo = new Foo(4); //// Foo.method1(); //// foo.method2(); //// foo.method3(); //// foo.method4(); //// foo.property1; //// foo.property2; //// foo.method5(); //// foo.newMet/*14*/ verify.baselineCompletions()
{ "end_byte": 1466, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsJSDocTags.ts" }
TypeScript/tests/cases/fourslash/derivedClassRegionCheck.ts_0_745
/// <reference path="fourslash.ts" /> // @strict: true // @Filename: index.ts //// export {}; //// interface ComplicatedTypeBase { //// [s: string]: ABase; //// } //// interface ComplicatedTypeDerived { //// [s: string]: ADerived; //// } //// interface ABase { //// a: string; //// } //// interface ADerived { //// b: string; //// } //// class Base { //// foo!: ComplicatedTypeBase; //// } //// [|class Derived extends Base { //// foo!: ComplicatedTypeDerived; //// }|] //// /*e*/ const [r0] = test.ranges(); // Baseline const expected = test.getSemanticDiagnostics(); // Reset checker goTo.marker("e"); edit.insert(" "); verify.getRegionSemanticDiagnostics([r0], expected); verify.getSemanticDiagnostics(expected);
{ "end_byte": 745, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/derivedClassRegionCheck.ts" }
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction7.ts_0_176
/// <reference path='fourslash.ts' /> //// const foo = /*a*/a/*b*/ => { }; goTo.select("a", "b"); verify.not.refactorAvailable("Add or remove braces in an arrow function");
{ "end_byte": 176, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction7.ts" }
TypeScript/tests/cases/fourslash/tsxRename1.ts_0_453
/// <reference path='fourslash.ts' /> //@Filename: file.tsx //// declare module JSX { //// interface Element { } //// interface IntrinsicElements { //// [|[|{| "contextRangeIndex": 0 |}div|]: { //// name?: string; //// isOpen?: boolean; //// };|] //// span: { n: string; }; //// } //// } //// var x = [|<[|{| "contextRangeIndex": 2 |}div|] />|]; verify.baselineRenameAtRangesWithText("div");
{ "end_byte": 453, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxRename1.ts" }
TypeScript/tests/cases/fourslash/renameReferenceFromLinkTag2.ts_0_199
/// <reference path="fourslash.ts" /> // @Filename: /a.ts ////enum E { //// /** {@link /**/Foo} */ //// Foo ////} ////interface Foo { //// foo: E.Foo; ////} verify.baselineRename("", {});
{ "end_byte": 199, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameReferenceFromLinkTag2.ts" }
TypeScript/tests/cases/fourslash/insertInterfaceAndCheckTypeLiteralField.ts_0_231
/// <reference path="fourslash.ts" /> //// /*addC*/ //// interface G<T, U> { } //// var v2: G<{ a: /*checkParam*/C }, C>; goTo.marker('addC'); edit.insert('interface C { }'); goTo.marker('checkParam'); verify.quickInfoExists();
{ "end_byte": 231, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/insertInterfaceAndCheckTypeLiteralField.ts" }
TypeScript/tests/cases/fourslash/exportEqualNamespaceClassESModuleInterop.ts_0_628
/// <reference path='fourslash.ts'/> // @esModuleInterop: true // @moduleResolution: node // @target: es2015 // @module: esnext // @Filename: /node_modules/@bar/foo/index.d.ts //// export = Foo; //// declare class Foo {} //// declare namespace Foo {} // class/namespace declaration causes the issue // @Filename: /node_modules/foo/index.d.ts //// import * as Foo from "@bar/foo"; //// export = Foo; // @Filename: /index.ts //// import Foo from "foo"; //// /**/ goTo.file("/index.ts"); verify.completions({ marker: "", includes: ["Foo"], preferences: { includeCompletionsForModuleExports: true } });
{ "end_byte": 628, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/exportEqualNamespaceClassESModuleInterop.ts" }
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateOtherExprSeq.ts_0_394
/// <reference path='fourslash.ts' /> //// const foo = "/*x*/f/*y*/oobar is " + 42 * 6 / 4 + " years old" goTo.select("x", "y"); edit.applyRefactor({ refactorName: "Convert to template string", actionName: "Convert to template string", actionDescription: ts.Diagnostics.Convert_to_template_string.message, newContent: `const foo = \`foobar is \${42 * 6 / 4} years old\``, });
{ "end_byte": 394, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateOtherExprSeq.ts" }