_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/parameterInfoOnParameterType.ts_0_201 | /// <reference path="fourslash.ts"/>
////function foo(a: string) { };
////var b = "test";
////foo("test"/*1*/);
////foo(b/*2*/);
verify.signatureHelp({ marker: test.markers(), parameterName: "a" });
| {
"end_byte": 201,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/parameterInfoOnParameterType.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties46.ts_0_274 | /// <reference path='fourslash.ts' />
// @strict: true
//// type T = { t: string };
//// declare function f(arg?: T): void;
//// f([|{}|]);
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newRangeContent:
`{
t: ""
}`,
});
| {
"end_byte": 274,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties46.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts_0_411 | /// <reference path='fourslash.ts' />
//// function f(templateStrings, x, y, z) { return 10; }
//// function g(templateStrings, x, y, z) { return ""; }
////
//// f ` ${/*1*/ /*2*/
verify.signatureHelp({
marker: test.markers(),
text: "f(templateStrings: any, x: any, y: any, z: any): number",
argumentCount: 2,
parameterCount: 4,
parameterName: "x",
parameterSpan: "x: any",
});
| {
"end_byte": 411,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingAwait_initializer2.ts_0_319 | /// <reference path="fourslash.ts" />
////async function fn(a: Promise<string>) {
//// const x = a;
//// x.toLowerCase();
////}
verify.codeFix({
description: "Add 'await' to initializer for 'x'",
index: 0,
newFileContent:
`async function fn(a: Promise<string>) {
const x = await a;
x.toLowerCase();
}`
});
| {
"end_byte": 319,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAwait_initializer2.ts"
} |
TypeScript/tests/cases/fourslash/completionsLiteralFromInferenceWithinInferredType1.ts_0_509 | /// <reference path="fourslash.ts" />
// @Filename: /a.tsx
//// declare function test<T>(a: {
//// [K in keyof T]: {
//// b?: keyof T;
//// };
//// }): void;
////
//// test({
//// foo: {},
//// bar: {
//// b: "/*ts*/",
//// },
//// });
////
//// test({
//// foo: {},
//// bar: {
//// b: /*ts2*/,
//// },
//// });
verify.completions({ marker: ["ts"], exact: ["foo", "bar"] });
verify.completions({ marker: ["ts2"], includes: ['"foo"', '"bar"'], isNewIdentifierLocation: false });
| {
"end_byte": 509,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsLiteralFromInferenceWithinInferredType1.ts"
} |
TypeScript/tests/cases/fourslash/docCommentTemplateWithExistingJSDoc.ts_0_215 | /// <reference path='fourslash.ts' />
/////** /**/ */
////
/////**
//// * @param {string} a
//// * @param {string} b
//// */
////function foo(a, b) {
//// return a + b;
////}
verify.noDocCommentTemplateAt("");
| {
"end_byte": 215,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateWithExistingJSDoc.ts"
} |
TypeScript/tests/cases/fourslash/completionListInObjectLiteral7.ts_0_351 | /// <reference path='fourslash.ts'/>
////type Foo = { foo: boolean };
////function f<T>(shape: Foo): any;
////function f<T>(shape: () => Foo): any;
////function f(arg: any) {
//// return arg;
////}
////
////f({ /*1*/ });
////f(() => ({ /*2*/ }));
////f(() => (({ /*3*/ })));
verify.completions({
marker: ["1", "2", "3"],
exact: ["foo"]
});
| {
"end_byte": 351,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectLiteral7.ts"
} |
TypeScript/tests/cases/fourslash/completionListInObjectBindingPattern13.ts_0_285 | /// <reference path='fourslash.ts'/>
////interface I {
//// x: number;
//// y: string;
//// z: boolean;
////}
////
////interface J {
//// x: string;
//// y: string;
////}
////
////let { /**/ }: I | J = { x: 10 };
verify.completions({ marker: "", exact: ["x", "y"] });
| {
"end_byte": 285,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectBindingPattern13.ts"
} |
TypeScript/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard6.ts_0_665 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @Filename: /node_modules/foo/package.json
//// {
//// "name": "foo",
//// "main": "dist/index.js",
//// "module": "dist/index.mjs",
//// "types": "dist/index.d.ts",
//// "exports": {
//// "./*": "./dist/*?.d.ts"
//// }
//// }
// @Filename: /node_modules/foo/dist/index.d.ts
//// export const index = 0;
// @Filename: /node_modules/foo/dist/blah?.d.ts
//// export const blah = 0;
// @Filename: /index.mts
//// import { } from "foo//**/";
verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: [
{ name: "blah", kind: "script", kindModifiers: "" },
]
});
| {
"end_byte": 665,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard6.ts"
} |
TypeScript/tests/cases/fourslash/semanticModernClassificationConstructorTypes.ts_0_545 | //// Object.create(null);
//// const x = Promise.resolve(Number.MAX_VALUE);
//// if (x instanceof Promise) {}
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("class.defaultLibrary", "Object"),
c2.semanticToken("member.defaultLibrary", "create"),
c2.semanticToken("variable.declaration.readonly", "x"),
c2.semanticToken("class.defaultLibrary", "Number"),
c2.semanticToken("property.readonly.defaultLibrary", "MAX_VALUE"),
c2.semanticToken("variable.readonly", "x"),
);; | {
"end_byte": 545,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semanticModernClassificationConstructorTypes.ts"
} |
TypeScript/tests/cases/fourslash/completionsWithDeprecatedTag8.ts_0_587 | /// <reference path="fourslash.ts" />
////class C {
//// /** @deprecated */
//// p: number;
//// m() {
//// return (/**/)
//// }
////}
verify.completions({
marker: "",
includes: [{
name: "p",
kind: "property",
kindModifiers: "deprecated",
insertText: "this.p",
sortText: completion.SortText.Deprecated(completion.SortText.SuggestedClassMembers),
source: completion.CompletionSource.ThisProperty
}],
preferences: {
includeInsertTextCompletions: true
},
isNewIdentifierLocation: true
});
| {
"end_byte": 587,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsWithDeprecatedTag8.ts"
} |
TypeScript/tests/cases/fourslash/fsEditMarkerPositions.ts_0_299 | /// <reference path='fourslash.ts' />
////var n = 'test';
////var p = 5 /*1*/
////var q = 'marker goes here ->(/*here*/right here)<-';
// Test that edits preserve marker positions later in the file
goTo.marker('1');
edit.insert(';');
goTo.marker('here');
verify.textAtCaretIs('right here'); | {
"end_byte": 299,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fsEditMarkerPositions.ts"
} |
TypeScript/tests/cases/fourslash/jsdocLink2.ts_0_381 | ///<reference path="fourslash.ts" />
// @Filename: jsdocLink2.ts
//// class C {
//// }
// @Filename: script.ts
//// /**
//// * {@link C}
//// * @wat Makes a {@link C}. A default one.
//// * {@link C()}
//// * {@link C|postfix text}
//// * {@link unformatted postfix text}
//// * @see {@link C} its great
//// */
//// function /**/CC() {
//// }
verify.baselineQuickInfo();
| {
"end_byte": 381,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocLink2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties17.ts_0_357 | /// <reference path='fourslash.ts' />
////interface Foo<T> {
//// foo(): T;
////}
////[|const x: Foo<string> = {};|]
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newRangeContent: `const x: Foo<string> = {
foo: function(): string {
throw new Error("Function not implemented.");
}
};`,
});
| {
"end_byte": 357,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties17.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_FnArgIndent.ts_0_461 | /// <reference path='fourslash.ts' />
////console.log(function /*a*/()/*b*/ {
//// console.log(1);
//// console.log(2);
//// return 3;
////})
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to arrow function",
actionDescription: "Convert to arrow function",
newContent: `console.log(() => {
console.log(1);
console.log(2);
return 3;
})`,
});
| {
"end_byte": 461,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_FnArgIndent.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports42-static-readonly-class-symbol.ts_0_367 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
// @lib: es2019
// @Filename: /code.ts
////class A {
//// static readonly p1 = Symbol();
////}
verify.codeFix({
description: "Add annotation of type 'unique symbol'",
index: 0,
newFileContent:
`class A {
static readonly p1: unique symbol = Symbol();
}`
}); | {
"end_byte": 367,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports42-static-readonly-class-symbol.ts"
} |
TypeScript/tests/cases/fourslash/completionListsThroughTransitiveBaseClasses.ts_0_692 | /// <reference path='fourslash.ts'/>
////declare class A {
//// static foo;
////}
////declare class B extends A {
//// static bar;
////}
////declare class C extends B {
//// static baz;
////}
////
////C./*1*/
////B./*2*/
////A./*3*/
goTo.eachMarker((_, i) => {
const all = [
{ name: "foo", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "bar", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "baz", sortText: completion.SortText.LocalDeclarationPriority }
];
verify.completions({ includes: all.slice(0, 3 - i), excludes: all.slice(3 - i).map(e => e.name) });
edit.insert("foo;");
});
verify.noErrors();
| {
"end_byte": 692,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListsThroughTransitiveBaseClasses.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts_0_264 | /// <reference path='fourslash.ts'/>
////interface I {
//// /*1*/property1: number;
//// property2: string;
////}
////
////var foo: I;
////var [ { property1: prop1 }, { /*2*/property1, property2 } ] = [foo, foo];
verify.baselineFindAllReferences('1', '2')
| {
"end_byte": 264,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts"
} |
TypeScript/tests/cases/fourslash/completionsObjectLiteralExpressions3.ts_0_981 | /// <reference path="fourslash.ts" />
////interface T {
//// aaa?: string;
//// foo(): void;
//// }
//// const obj: T = {
//// foo() {
//
//// }
//// /**/
//// }
verify.completions({
marker: "",
includes: [{
name: "aaa",
sortText: completion.SortText.OptionalMember,
hasAction: true,
source: completion.CompletionSource.ObjectLiteralMemberWithComma,
}],
preferences: {
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
},
});
verify.applyCodeActionFromCompletion("", {
name: "aaa",
description: `Add missing comma for object member completion 'aaa'.`,
source: completion.CompletionSource.ObjectLiteralMemberWithComma,
newFileContent:
`interface T {
aaa?: string;
foo(): void;
}
const obj: T = {
foo() {
},
}`,
preferences: {
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
},
});
| {
"end_byte": 981,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsObjectLiteralExpressions3.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_inheritedConstructor.ts_0_646 | /// <reference path='fourslash.ts' />
////class Foo {
//// /*a*/constructor/*b*/(t: string, s: string) { }
////}
////class Bar extends Foo { }
////var bar = new Bar("a", "b");
////var foo = new Foo("c", "d");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `class Foo {
constructor({ t, s }: { t: string; s: string; }) { }
}
class Bar extends Foo { }
var bar = new Bar({ t: "a", s: "b" });
var foo = new Foo({ t: "c", s: "d" });`
}); | {
"end_byte": 646,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_inheritedConstructor.ts"
} |
TypeScript/tests/cases/fourslash/completionListAfterStringLiteralTypeWithNoSubstitutionTemplateLiteral.ts_0_257 | /// <reference path="fourslash.ts" />
////let count: 'one' | 'two';
////count = `[|/**/|]`
const replacementSpan = test.ranges()[0]
verify.completions({ marker: "", exact: [
{ name: "one", replacementSpan },
{ name: "two", replacementSpan }
] });
| {
"end_byte": 257,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAfterStringLiteralTypeWithNoSubstitutionTemplateLiteral.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString9.ts_0_696 | /// <reference path='fourslash.ts' />
////const a = 1;
////const b = 1;
////const c = 1;
////const d = 1;
////const d = /*start*/"start" + ` / a start ${a} a end / b start ${b} b end / ` + c + ` / d start ${d} d end / ` + "end"/*end*/;
goTo.select("start", "end");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
newContent: [
"const a = 1;",
"const b = 1;",
"const c = 1;",
"const d = 1;",
"const d = `start / a start ${a} a end / b start ${b} b end / ${c} / d start ${d} d end / end`;"
].join("\n")
});
| {
"end_byte": 696,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString9.ts"
} |
TypeScript/tests/cases/fourslash/referencesForClassMembers.ts_0_364 | /// <reference path='fourslash.ts'/>
////class Base {
//// /*a1*/a: number;
//// /*method1*/method(): void { }
////}
////class MyClass extends Base {
//// /*a2*/a;
//// /*method2*/method() { }
////}
////
////var c: MyClass;
////c./*a3*/a;
////c./*method3*/method();
verify.baselineFindAllReferences('a1', 'a2', 'a3', 'method1', 'method2', 'method3')
| {
"end_byte": 364,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForClassMembers.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_allParamsOptional.ts_0_486 | /// <reference path='fourslash.ts' />
////function f(/*a*/a?: number, b: string = "1"/*b*/): string {
//// return b;
////}
////f();
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `function f({ a, b = "1" }: { a?: number; b?: string; } = {}): string {
return b;
}
f();`
}); | {
"end_byte": 486,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_allParamsOptional.ts"
} |
TypeScript/tests/cases/fourslash/jsDocPropertyDescription10.ts_0_343 | ///<reference path="fourslash.ts" />
//// class MultipleClass {
//// /** Something generic */
//// [key: number | symbol | `data-${string}` | `data-${number}`]: string;
//// }
//// function multipleClass(e: typeof MultipleClass) {
//// console.log(e./*multipleClass*/anything);
//// }
verify.quickInfoAt("multipleClass", "any");
| {
"end_byte": 343,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocPropertyDescription10.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType22.ts_0_406 | /// <reference path='fourslash.ts' />
//// type A<T, U> = () => <T>(v: T) => (v: T) => <T>(v: /*a*/T/*b*/) => U;
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;
type A<T, U> = () => <T>(v: T) => (v: T) => <T>(v: NewType<T>) => U;`,
});
| {
"end_byte": 406,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType22.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_MultiLine.ts_0_418 | /// <reference path='fourslash.ts' />
//// const foo = /*x*/f/*y*/unction() {
//// let a = 41;
//// return a + 1;
//// };
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to arrow function",
actionDescription: "Convert to arrow function",
newContent: `const foo = () => {
let a = 41;
return a + 1;
};`,
});
| {
"end_byte": 418,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_MultiLine.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts_0_472 | /// <reference path='fourslash.ts' />
//// function f(templateStrings, x, y, z) { return 10; }
//// function g(templateStrings, x, y, z) { return ""; }
////
//// f ` qwerty ${/*1*/ /*2*/123/*3*/ /*4*/} asdf ${ 41234 } zxcvb ${ g ` ` } `
verify.signatureHelp({
marker: test.markers(),
text: "f(templateStrings: any, x: any, y: any, z: any): number",
argumentCount: 4,
parameterCount: 4,
parameterName: "x",
parameterSpan: "x: any",
});
| {
"end_byte": 472,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_overloads3.ts_0_549 | /// <reference path='fourslash.ts' />
// @Filename: /add.ts
////
// @Filename: /a.ts
////function add(x: number, y: number): number;
////[|function add(x: string, y: string): string;
////function add(x: any, y: any) {
//// return x + y;
////}|]
verify.moveToFile({
newFileContents: {
"/a.ts": "",
"/add.ts":
`
function add(x: number, y: number): number;
function add(x: string, y: string): string;
function add(x: any, y: any) {
return x + y;
}
`
},
interactiveRefactorArguments: { targetFile: "/add.ts" },
});
| {
"end_byte": 549,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_overloads3.ts"
} |
TypeScript/tests/cases/fourslash/parenthesisFatArrows.ts_0_193 | /// <reference path="fourslash.ts"/>
////x => x;
////(y) => y;
/////**/
////(y) => y;
////x => x;
verify.noErrors();
verify.not.errorExistsBeforeMarker();
verify.not.errorExistsAfterMarker(); | {
"end_byte": 193,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/parenthesisFatArrows.ts"
} |
TypeScript/tests/cases/fourslash/formattingOnEnterInStrings.ts_0_294 | /// <reference path='fourslash.ts' />
////var x = /*1*/"unclosed string literal\/*2*/
goTo.marker("2");
edit.insertLine("");
edit.insertLine("");
goTo.marker("1");
// Enter in open string literals should not affect formating
verify.currentLineContentIs('var x = "unclosed string literal\\');
| {
"end_byte": 294,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnEnterInStrings.ts"
} |
TypeScript/tests/cases/fourslash/getOutliningForSingleLineComments.ts_0_1592 | /// <reference path="fourslash.ts"/>
////[|// Single line comments at the start of the file
////// line 2
////// line 3
////// line 4|]
////module Sayings[| {
////
//// [|/*
//// */|]
//// [|// A sequence of
//// // single line|]
//// [|/*
//// and block
//// */|]
//// [|// comments
//// //|]
//// export class Sample[| {
//// }|]
////}|]
////
////interface IFoo[| {
//// [|// all consecutive single line comments should be in one block regardless of their number or empty lines/spaces inbetween
////
//// // comment 2
//// // comment 3
////
//// //comment 4
//// /// comment 5
//// ///// comment 6
////
//// //comment 7
//// ///comment 8
//// // comment 9
//// // //comment 10
////
////
////
////
////
////
////
////
////
////
////
////
////
////
////
////
////
////
////
////
//// // // //comment 11
//// // comment 12
//// // comment 13
//// // comment 14
//// // comment 15
////
//// // comment 16
//// // comment 17
//// // comment 18
//// // comment 19
//// // comment 20
//// // comment 21|]
////
//// getDist(): number; // One single line comment should not be collapsed
////}|]
////
////// One single line comment should not be collapsed
////class WithOneSingleLineComment[| {
////}|]
////
////function Foo()[| {
//// [|// comment 1
//// // comment 2|]
//// this.method = function (param)[| {
//// }|]
////
//// [|// comment 1
//// // comment 2|]
//// function method(param)[| {
//// }|]
////}|]
verify.outliningSpansInCurrentFile(test.ranges());
| {
"end_byte": 1592,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOutliningForSingleLineComments.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentStatementTryCatchFinally.ts_0_1036 | /// <reference path='fourslash.ts'/>
////function tryCatch() {
//// {| "indentation": 4 |}
//// try {
//// {| "indentation": 8 |}
//// }
//// {| "indentation": 4 |}
//// catch (err) {
//// {| "indentation": 8 |}
//// }
//// {| "indentation": 4 |}
////}
////
////function tryFinally() {
//// {| "indentation": 4 |}
//// try {
//// {| "indentation": 8 |}
//// }
//// {| "indentation": 4 |}
//// finally {
//// {| "indentation": 8 |}
//// }
//// {| "indentation": 4 |}
////}
////
////function tryCatchFinally() {
//// {| "indentation": 4 |}
//// try {
//// {| "indentation": 8 |}
//// }
//// {| "indentation": 4 |}
//// catch (err) {
//// {| "indentation": 8 |}
//// }
//// {| "indentation": 4 |}
//// finally {
//// {| "indentation": 8 |}
//// }
//// {| "indentation": 4 |}
////}
test.markers().forEach((marker) => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation);
}); | {
"end_byte": 1036,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentStatementTryCatchFinally.ts"
} |
TypeScript/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts_0_855 | /// <reference path='fourslash.ts'/>
// @Filename: mergedDeclarationsWithExportAssignment1_file0.ts
////class Foo {
//// doStuff(x: number): number;
////}
////module Foo {
//// export var x: number;
////}
////export = Foo;
// @Filename: mergedDeclarationsWithExportAssignment1_file1.ts
///////<reference path='mergedDeclarationsWithExportAssignment1_file0.ts'/>
////import /*1*/Foo = require('./mergedDeclarationsWithExportAssignment1_file0');
////var /*3*/z = new /*2*/Foo();
////var /*5*/r2 = Foo./*4*/x;
verify.quickInfos({
1: [
"(alias) class Foo",
"(alias) namespace Foo",
"import Foo = require('./mergedDeclarationsWithExportAssignment1_file0')"
].join("\n"),
3: "var z: Foo",
5: "var r2: number",
});
verify.completions(
{ marker: "2", includes: "Foo" },
{ marker: "4", includes: "x" },
);
| {
"end_byte": 855,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts"
} |
TypeScript/tests/cases/fourslash/autoImportPackageJsonImportsPreference1.ts_0_407 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @Filename: /package.json
//// {
//// "imports": {
//// "#*": "./src/*.ts"
//// }
//// }
// @Filename: /src/a/b/c/something.ts
//// export function something(name: string): any;
// @Filename: /a.ts
//// something/**/
verify.importFixModuleSpecifiers("", ["./src/a/b/c/something"], {
importModuleSpecifierPreference: "relative"
});
| {
"end_byte": 407,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPackageJsonImportsPreference1.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForIn.ts_0_125 | /// <reference path='fourslash.ts' />
////var obj;
////for (var /**/p in obj) { }
verify.quickInfoAt("", "var p: string");
| {
"end_byte": 125,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForIn.ts"
} |
TypeScript/tests/cases/fourslash/renameLabel5.ts_0_260 | /// <reference path="fourslash.ts" />
////loop1: for (let i = 0; i <= 10; i++) {
//// loop2: for (let j = 0; j <= 10; j++) {
//// if (i === 5) continue /**/loop1;
//// if (j === 5) break loop2;
//// }
////}
verify.baselineRename("", {});
| {
"end_byte": 260,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameLabel5.ts"
} |
TypeScript/tests/cases/fourslash/codeFixWrapJsxInFragment2.ts_0_210 | /// <reference path='fourslash.ts' />
// @jsx: react
// @Filename: /a.tsx
////[|<a></a><a />|]
verify.rangeAfterCodeFix(`<><a></a><a /></>`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0);
| {
"end_byte": 210,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixWrapJsxInFragment2.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsImportDefault.ts_0_291 | /// <reference path='fourslash.ts' />
// @Filename: f.ts
////export { foo as default };
////function /*start*/foo(a: number, b: number) {
//// return a + b;
////}
// @Filename: b.ts
////import bar from "./f";
////bar(1, 2);
verify.noErrors();
verify.baselineFindAllReferences('start')
| {
"end_byte": 291,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsImportDefault.ts"
} |
TypeScript/tests/cases/fourslash/completionListForObjectSpread.ts_0_1164 | /// <reference path='fourslash.ts'/>
////let o = { a: 1, b: 'no' }
////let o2 = { b: 'yes', c: true }
////let swap = { a: 'yes', b: -1 };
////let addAfter: { a: number, b: string, c: boolean } =
//// { ...o, c: false }
////let addBefore: { a: number, b: string, c: boolean } =
//// { c: false, ...o }
////let ignore: { a: number, b: string } =
//// { b: 'ignored', ...o }
////ignore./*1*/a;
////let combinedNestedChangeType: { a: number, b: boolean, c: number } =
//// { ...{ a: 1, ...{ b: false, c: 'overriden' } }, c: -1 }
////combinedNestedChangeType./*2*/a;
////let spreadNull: { a: number } =
//// { a: 7, ...null }
////let spreadUndefined: { a: number } =
//// { a: 7, ...undefined }
////spreadNull./*3*/a;
////spreadUndefined./*4*/a;
const a: FourSlashInterface.ExpectedCompletionEntry = { name: "a", text: "(property) a: number" };
verify.completions(
{
marker: "1",
exact: [a, { name: "b", text: "(property) b: string" }],
},
{
marker: "2",
exact: [a, { name: "b", text: "(property) b: boolean" }, { name: "c", text: "(property) c: number" }],
},
{ marker: ["3", "4"], exact: a },
);
| {
"end_byte": 1164,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListForObjectSpread.ts"
} |
TypeScript/tests/cases/fourslash/extract-const_jsxElement7.ts_0_503 | /// <reference path="fourslash.ts" />
// @jsx: preserve
// @filename: a.tsx
////function Foo() {
//// const foo = [
//// /*a*/<div>' {1}</div>/*b*/
//// ];
////}
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 newLocal = <div>' {1}</div>;
function Foo() {
const foo = [
/*RENAME*/newLocal
];
}`
});
| {
"end_byte": 503,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const_jsxElement7.ts"
} |
TypeScript/tests/cases/fourslash/renameForDefaultExport09.ts_0_331 | /// <reference path='fourslash.ts'/>
// @Filename: foo.ts
////function /**/[|f|]() {
//// return 100;
////}
////
////export default f;
////
////var x: typeof f;
////
////var y = f();
////
/////**
//// * Commenting f
//// */
////namespace f {
//// var local = 100;
////}
goTo.marker();
verify.renameInfoSucceeded("f", "f"); | {
"end_byte": 331,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameForDefaultExport09.ts"
} |
TypeScript/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts_0_177 | /// <reference path='fourslash.ts'/>
////var x = { "/*1*/someProperty": 0 }
////x[/*2*/"someProperty"] = 3;
////x.someProperty = 5;
verify.baselineFindAllReferences('1', '2')
| {
"end_byte": 177,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts"
} |
TypeScript/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_varDeclarations.ts_0_220 | /// <reference path='fourslash.ts' />
////var aa = 1;
////var /*varName1*/
////var a/*varName2*/
////var a2,/*varName3*/
////var a2, a/*varName4*/
verify.completions({ marker: test.markers(), exact: undefined });
| {
"end_byte": 220,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_varDeclarations.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType73.ts_0_290 | /// <reference path='fourslash.ts' />
// @Filename: a.ts
////interface Foo<T extends { prop: T }> {}
// @Filename: b.ts
////interface Foo<T extends { prop: /*a*/T/*b*/ }> {}
goTo.file("b.ts");
goTo.select("a", "b");
verify.not.refactorAvailable("Extract type", "Extract to type alias");
| {
"end_byte": 290,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType73.ts"
} |
TypeScript/tests/cases/fourslash/genericFunctionSignatureHelp3.ts_0_1740 | /// <reference path='fourslash.ts'/>
////function foo1<T>(x: number, callback: (y1: T) => number) { }
////function foo2<T>(x: number, callback: (y2: T) => number) { }
////function foo3<T>(x: number, callback: (y3: T) => number) { }
////function foo4<T>(x: number, callback: (y4: T) => number) { }
////function foo5<T>(x: number, callback: (y5: T) => number) { }
////function foo6<T>(x: number, callback: (y6: T) => number) { }
////function foo7<T>(x: number, callback: (y7: T) => number) { }
//// IDE shows the results on the right of each line, fourslash says different
////foo1(/*1*/ // signature help shows y as T
////foo2(1,/*2*/ // signature help shows y as {}
////foo3(1, (/*3*/ // signature help shows y as T
////foo4<string>(1,/*4*/ // signature help shows y as string
////foo5<string>(1, (/*5*/ // signature help shows y as T
////foo6(1, </*6*/ // signature help shows y as {}
////foo7(1, <string>(/*7*/ // signature help shows y as T
verify.signatureHelp(
{ marker: "1", text: "foo1(x: number, callback: (y1: unknown) => number): void" },
{ marker: "2", text: "foo2(x: number, callback: (y2: unknown) => number): void" },
{ marker: "3", text: "callback(y3: unknown): number" },
{ marker: "4", text: "foo4(x: number, callback: (y4: string) => number): void" },
{ marker: "5", text: "callback(y5: string): number" },
);
goTo.marker('6');
verify.signatureHelp({ text: "foo6(x: number, callback: (y6: unknown) => number): void" });
edit.insert('string>(null,null);'); // need to make this line parse so we can get reasonable LS answers to later tests
verify.signatureHelp({ marker: "7", text: "foo7(x: number, callback: (y7: unknown) => number): void" });
| {
"end_byte": 1740,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericFunctionSignatureHelp3.ts"
} |
TypeScript/tests/cases/fourslash/unclosedStringLiteralErrorRecovery4.ts_0_160 | /// <reference path="fourslash.ts" />
////function alpha() {
//// var x = "x
/////**/var y = "y";
////}
goTo.marker();
verify.not.errorExistsAfterMarker(); | {
"end_byte": 160,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unclosedStringLiteralErrorRecovery4.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentInCallExpressions.ts_0_352 | /// <reference path='fourslash.ts'/>
////module My.App {
//// export var appModule = angular.module("app", [
//// ]).config([() => {
//// configureStates/*1*/($stateProvider);
//// }]).run(My.App.setup);
////}
goTo.marker("1")
edit.insert("\n");
verify.indentationIs(12); // 4 (module block) + 4 (function block) + 4 (call expression) | {
"end_byte": 352,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentInCallExpressions.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageMultipleParameters.ts_0_397 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
//// function f([|a, b, c, d: number, e = 0, ...d |]) {
//// }
//// f(1, "string", { a: 1 }, {shouldNotBeHere: 2}, {shouldNotBeHere: 2}, 3, "string");
verify.rangeAfterCodeFix("a: number, b: string, c: { a: number; }, d: number, e = 0, ...d: (string | number)[]", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1);
| {
"end_byte": 397,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageMultipleParameters.ts"
} |
TypeScript/tests/cases/fourslash/tsxQuickInfo2.ts_3_487 | / <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// div: any
//// }
//// }
//// var x1 = <di/*1*/v></di/*2*/v>
//// class MyElement {}
//// var z = <My/*3*/Element></My/*4*/Element>
verify.quickInfos({
1: "(property) JSX.IntrinsicElements.div: any",
2: "(property) JSX.IntrinsicElements.div: any",
3: "class MyElement",
4: "class MyElement"
});
| {
"end_byte": 487,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxQuickInfo2.ts"
} |
TypeScript/tests/cases/fourslash/isInMultiLineCommentOnlyTrivia.ts_0_1009 | /// <reference path="fourslash.ts" />
//// /* x */
//// /**
//// * @param this doesn't make sense here.
//// */
//// // x
const firstCommentStart = 0;
const firstCommentEnd = 7;
goTo.position(firstCommentStart);
verify.not.isInCommentAtPosition();
goTo.position(firstCommentStart + 1);
verify.isInCommentAtPosition();
goTo.position(firstCommentEnd - 1);
verify.isInCommentAtPosition();
goTo.position(firstCommentEnd);
verify.not.isInCommentAtPosition();
const multilineJsDocStart = firstCommentEnd + 1;
const multilineJsDocEnd = multilineJsDocStart + 49;
goTo.position(multilineJsDocStart);
verify.not.isInCommentAtPosition();
goTo.position(multilineJsDocStart + 1);
verify.isInCommentAtPosition();
goTo.position(multilineJsDocEnd - 1);
verify.isInCommentAtPosition();
goTo.position(multilineJsDocEnd);
verify.not.isInCommentAtPosition();
const singleLineCommentStart = multilineJsDocEnd + 1;
goTo.position(singleLineCommentStart + 1);
verify.isInCommentAtPosition(/*onlyMultiLineDiverges*/ true); | {
"end_byte": 1009,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/isInMultiLineCommentOnlyTrivia.ts"
} |
TypeScript/tests/cases/fourslash/completionsOverridingMethod7.ts_0_1403 | /// <reference path="fourslash.ts" />
// @Filename: a.ts
// @newline: LF
// Case: abstract overloads
////abstract class Base {
//// abstract M<T>(t: T): void;
//// abstract M<T>(t: T, x: number): void;
////}
////
////abstract class Derived extends Base {
//// abstract /*a*/
////}
verify.completions({
marker: "a",
isNewIdentifierLocation: true,
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithClassMemberSnippets: true,
},
includes: [
{
name: "M",
sortText: completion.SortText.LocationPriority,
insertText:
`abstract M<T>(t: T): void;
abstract M<T>(t: T, x: number): void;`,
filterText: "M",
hasAction: true,
source: completion.CompletionSource.ClassMemberSnippet,
},
],
});
verify.applyCodeActionFromCompletion("a", {
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithClassMemberSnippets: true,
},
name: "M",
source: completion.CompletionSource.ClassMemberSnippet,
description: "Update modifiers of 'M'",
newFileContent:
`abstract class Base {
abstract M<T>(t: T): void;
abstract M<T>(t: T, x: number): void;
}
abstract class Derived extends Base {
}`
});
| {
"end_byte": 1403,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingMethod7.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType80.ts_0_524 | /// <reference path='fourslash.ts' />
//// type B = string;
//// type C = number;
////
//// export function foo<T extends boolean | /*1*/B | C/*2*/>(x: T): T {
//// return x;
//// }
goTo.select("1", "2");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent:
`type B = string;
type C = number;
type /*RENAME*/NewType = B | C;
export function foo<T extends boolean | NewType>(x: T): T {
return x;
}`,
});
| {
"end_byte": 524,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType80.ts"
} |
TypeScript/tests/cases/fourslash/tsxCompletion6.ts_0_313 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// div: { ONE: string; TWO: number; }
//// }
//// }
//// var x = <div ONE='hello' /**/ />;
verify.completions({ marker: "", exact: "TWO" });
| {
"end_byte": 313,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletion6.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationLocal_07.ts_0_233 | /// <reference path='fourslash.ts'/>
// Should be able to go to ambient function declarations
//// declare function [|someFunction|](): () => void;
//// someFun/*reference*/ction();
verify.baselineGoToImplementation("reference");
| {
"end_byte": 233,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationLocal_07.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromFunctionThisUsageObjectPropertyShorthand.ts_0_429 | /// <reference path='fourslash.ts' />
// @noImplicitThis: true
////function returnThisMember([| |]) {
//// return this.member;
//// }
////
//// interface Container {
//// member: string;
//// returnThisMember(): string;
//// }
////
//// const container: Container = {
//// member: "sample",
//// returnThisMember,
//// };
////
//// container.returnThisMember();
verify.rangeAfterCodeFix("this: Container");
| {
"end_byte": 429,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromFunctionThisUsageObjectPropertyShorthand.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsCommonJsRequire.ts_0_223 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: /a.js
//// function f() { }
//// export { f }
// @Filename: /b.js
//// const { f } = require('./a')
//// /**/f
verify.baselineFindAllReferences("");
| {
"end_byte": 223,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsCommonJsRequire.ts"
} |
TypeScript/tests/cases/fourslash/definition.ts_0_209 | /// <reference path='fourslash.ts'/>
// @Filename: b.ts
////import n = require([|'./a/*1*/'|]);
////var x = new n.Foo();
// @Filename: a.ts
//// /*2*/export class Foo {}
verify.baselineGoToDefinition("1");
| {
"end_byte": 209,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/definition.ts"
} |
TypeScript/tests/cases/fourslash/completionPropertyFromConstraint.ts_0_483 | /// <reference path="fourslash.ts"/>
//// interface Styles {
//// alignContent: string | null;
//// alignItems: string | null;
//// alignmentBaseline: string | null;
//// // etc..
//// [key: string]: any
//// }
////
//// interface StyleMap {
//// [name: string]: Partial<Styles>
//// }
////
//// declare function createStyles<T extends StyleMap>(styles: T): T
////
//// createStyles({
//// x: {
//// '/*1*/': ''
//// }
//// });
verify.baselineCompletions();
| {
"end_byte": 483,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionPropertyFromConstraint.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoSpecialPropertyAssignment.ts_0_291 | // @allowJs: true
// @Filename: /a.js
////class C {
//// constructor() {
//// /** Doc */
//// this./*write*/x = 0;
//// this./*read*/x;
//// }
////}
verify.quickInfoAt("write", "(property) C.x: any", "Doc");
verify.quickInfoAt("read", "(property) C.x: number", "Doc");
| {
"end_byte": 291,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoSpecialPropertyAssignment.ts"
} |
TypeScript/tests/cases/fourslash/completionsOverridingMethod11.ts_0_1265 | /// <reference path="fourslash.ts" />
// @Filename: a.ts
// @newline: LF
// Case: formatting: no semicolons
////function foo() {
//// const a = 1
//// const b = 2
//// foo()
//// return a + b
////}
////
////interface Base {
//// a: string
//// b(a: string): void
//// c(a: string): string
//// c(a: number): number
////}
////class Sub implements Base {
//// /*a*/
////}
verify.completions({
marker: "a",
isNewIdentifierLocation: true,
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithClassMemberSnippets: true,
},
includes: [
{
name: "a",
sortText: completion.SortText.LocationPriority,
insertText: "a: string",
filterText: "a"
},
{
name: "b",
sortText: completion.SortText.LocationPriority,
insertText:
`b(a: string): void {
}`,
filterText: "b"
},
{
name: "c",
sortText: completion.SortText.LocationPriority,
insertText:
`c(a: string): string
c(a: number): number
c(a: unknown): string | number {
}`,
filterText: "c"
},
],
}); | {
"end_byte": 1265,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingMethod11.ts"
} |
TypeScript/tests/cases/fourslash/completionEntryForUnionProperty2.ts_0_1005 | ///<reference path="fourslash.ts" />
////interface One {
//// commonProperty: string;
//// commonFunction(): number;
//// anotherProperty: Record<string, number>;
////}
////
////interface Two {
//// commonProperty: number;
//// commonFunction(): number;
//// anotherProperty: { foo: number }
////}
////
////var x : One | Two;
////
////x.commonProperty./*1*/;
////x.anotherProperty./*2*/;
verify.completions({
marker: "1",
exact: [
{ name: "toLocaleString", text: "(method) toLocaleString(): string (+1 overload)", documentation: "Returns a date converted to a string using the current locale." },
{ name: "toString", text: "(method) toString(): string (+1 overload)", documentation: "Returns a string representation of a string." },
{ name: "valueOf", text: "(method) valueOf(): string | number", documentation: "Returns the primitive value of the specified object." },
],
});
verify.completions({
marker: '2',
includes: { name: 'foo' }
})
| {
"end_byte": 1005,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionEntryForUnionProperty2.ts"
} |
TypeScript/tests/cases/fourslash/autoImportVerbatimCJS1.ts_0_750 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @verbatimModuleSyntax: true
// @allowJs: true
// @Filename: /node_modules/@types/node/path.d.ts
//// declare module 'path' {
//// namespace path {
//// interface PlatformPath {
//// normalize(p: string): string;
//// join(...paths: string[]): string;
//// resolve(...pathSegments: string[]): string;
//// isAbsolute(p: string): boolean;
//// }
//// }
//// const path: path.PlatformPath;
//// export = path;
//// }
// @Filename: /cool-name.js
//// module.exports = {
//// explode: () => {}
//// }
// @Filename: /a.ts
//// /**/
verify.baselineAutoImports("", ["normalize", "join", "path", "explode"]);
| {
"end_byte": 750,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportVerbatimCJS1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports39-extract-arr-to-variable.ts_0_997 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
// @lib: es2019
// @Filename: /code.ts
////let c: string[] = [];
////export let o = {
//// p: [
//// ...c
//// ]
////}
verify.codeFix({
description: `Mark array literal as const`,
applyChanges: true,
index: 2,
newFileContent:
`let c: string[] = [];
export let o = {
p: [
...c
] as const
}`
});
verify.codeFix({
description: `Extract to variable and replace with 'newLocal as typeof newLocal'`,
applyChanges: true,
index: 1,
newFileContent:
`let c: string[] = [];
const newLocal = [
...c
] as const;
export let o = {
p: newLocal as typeof newLocal
}`
});
verify.codeFix({
description: `Add annotation of type 'readonly string[]'`,
applyChanges: true,
index: 0,
newFileContent:
`let c: string[] = [];
const newLocal: readonly string[] = [
...c
] as const;
export let o = {
p: newLocal as typeof newLocal
}`
});
| {
"end_byte": 997,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports39-extract-arr-to-variable.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptQuickInfo6.ts_0_195 | /// <reference path='fourslash.ts'/>
// @allowNonTsExtensions: true
// @Filename: Foo.js
/////** @type {function(this:number)} */
////function f() { /**/this }
verify.quickInfoAt("", "number"); | {
"end_byte": 195,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptQuickInfo6.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesIsDefinitionOfParameter.ts_0_146 | /// <reference path='fourslash.ts' />
////function f(/*1*/x: number) {
//// return /*2*/x + 1
////}
verify.baselineFindAllReferences('1', '2');
| {
"end_byte": 146,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesIsDefinitionOfParameter.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction31.ts_0_429 | /// <reference path='fourslash.ts' />
////const a = /*a*/()/*b*/ => {
//// return (
//// // comment
//// 1
//// );
////};
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 a = () => (
// comment
1
);`,
});
| {
"end_byte": 429,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction31.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnConstructorWithGenericParameter.ts_0_542 | /// <reference path='fourslash.ts' />
////interface I {
//// x: number;
////}
////class Foo<T> {
//// y: T;
////}
////class A {
//// foo() { }
////}
////class B extends A {
//// constructor(a: Foo<I>, b: number) {
//// super();
//// }
////}
////var x = new /*2*/B(/*1*/
verify.signatureHelp({ marker: "1", text: "B(a: Foo<I>, b: number): B" });
edit.insert("null,");
verify.signatureHelp({ text: "B(a: Foo<I>, b: number): B" });
edit.insert("10);");
verify.quickInfoAt("2", "constructor B(a: Foo<I>, b: number): B");
| {
"end_byte": 542,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnConstructorWithGenericParameter.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUndeclaredMethodObjectLiteralArgs.ts_0_1417 | /// <reference path='fourslash.ts' />
//// class A {
//// constructor() {
//// this.foo1(null, {}, { a: 1, b: "2"});
//// const bar = this.foo2(null, {}, { a: 1, b: "2"});
//// const baz: number = this.foo3(null, {}, { a: 1, b: "2"});
//// }[|
//// |]
//// }
verify.codeFix({
description: "Declare method 'foo1'",
index: 0,
newRangeContent: `
foo1(arg0: null, arg1: {}, arg2: { a: number; b: string; }) {
throw new Error("Method not implemented.");
}
`,
applyChanges: true
});
verify.codeFix({
description: "Declare method 'foo2'",
index: 0,
newRangeContent: `
foo2(arg0: null, arg1: {}, arg2: { a: number; b: string; }) {
throw new Error("Method not implemented.");
}
foo1(arg0: null, arg1: {}, arg2: { a: number; b: string; }) {
throw new Error("Method not implemented.");
}
`,
applyChanges: true
});
verify.codeFix({
description: "Declare method 'foo3'",
index: 0,
newRangeContent: `
foo3(arg0: null, arg1: {}, arg2: { a: number; b: string; }): number {
throw new Error("Method not implemented.");
}
foo2(arg0: null, arg1: {}, arg2: { a: number; b: string; }) {
throw new Error("Method not implemented.");
}
foo1(arg0: null, arg1: {}, arg2: { a: number; b: string; }) {
throw new Error("Method not implemented.");
}
`
});
| {
"end_byte": 1417,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUndeclaredMethodObjectLiteralArgs.ts"
} |
TypeScript/tests/cases/fourslash/squiggleIllegalClassExtension.ts_0_162 | /// <reference path="fourslash.ts"/>
////class Foo extends /*1*/Bar/*2*/ { }
verify.errorExistsBetweenMarkers("1", "2");
verify.numberOfErrorsInCurrentFile(1);
| {
"end_byte": 162,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/squiggleIllegalClassExtension.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarItemsBindingPatterns.ts_0_2390 | /// <reference path='fourslash.ts'/>
////'use strict'
////var foo, {}
////var bar, []
////let foo1, {a, b}
////const bar1, [c, d]
////var {e, x: [f, g]} = {a:1, x:[]};
////var { h: i = function j() {} } = obj;
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "let"
},
{
"text": "b",
"kind": "let"
},
{
"text": "bar",
"kind": "var"
},
{
"text": "bar1",
"kind": "const"
},
{
"text": "c",
"kind": "const"
},
{
"text": "d",
"kind": "const"
},
{
"text": "e",
"kind": "var"
},
{
"text": "f",
"kind": "var"
},
{
"text": "foo",
"kind": "var"
},
{
"text": "foo1",
"kind": "let"
},
{
"text": "g",
"kind": "var"
},
{
"text": "i",
"kind": "var"
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "let"
},
{
"text": "b",
"kind": "let"
},
{
"text": "bar",
"kind": "var"
},
{
"text": "bar1",
"kind": "const"
},
{
"text": "c",
"kind": "const"
},
{
"text": "d",
"kind": "const"
},
{
"text": "e",
"kind": "var"
},
{
"text": "f",
"kind": "var"
},
{
"text": "foo",
"kind": "var"
},
{
"text": "foo1",
"kind": "let"
},
{
"text": "g",
"kind": "var"
},
{
"text": "i",
"kind": "var"
}
]
}
]);
| {
"end_byte": 2390,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsBindingPatterns.ts"
} |
TypeScript/tests/cases/fourslash/formattingDoubleLessThan.ts_0_239 | ///<reference path="fourslash.ts"/>
// https://github.com/microsoft/TypeScript/issues/14589
/////*1*/if (<number>foo < <number>bar) {}
format.document();
goTo.marker("1")
verify.currentLineContentIs(`if (<number>foo < <number>bar) { }`)
| {
"end_byte": 239,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingDoubleLessThan.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsJsDocParameterNames.ts_0_394 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @Filename: /a.js
//// var x
//// x.foo(1, 2);
//// /**
//// * @type {{foo: (a: number, b: number) => void}}
//// */
//// var y
//// y.foo(1, 2)
//// /**
//// * @type {string}
//// */
//// var z = ""
goTo.file('/a.js')
verify.baselineInlayHints(undefined, {
includeInlayParameterNameHints: "literals"
});
| {
"end_byte": 394,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsJsDocParameterNames.ts"
} |
TypeScript/tests/cases/fourslash/unusedVariableInNamespace3.ts_0_351 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////namespace greeter {
//// [|let a = "dummy entry", b, c = 0;|]
//// export function function1() {
//// use(a, b);
//// }
////}
verify.codeFix({
description: "Remove unused declaration for: 'c'",
index: 0,
newRangeContent: 'let a = "dummy entry", b;',
});
| {
"end_byte": 351,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedVariableInNamespace3.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsObjectLiteral.ts_0_1818 | /// <reference path="fourslash.ts"/>
////var v = 10e0;
////var x = {
//// p1: 1,
//// p2: 2,
//// any: 3,
//// function: 4,
//// var: 5,
//// void: void 0,
//// v: v += v,
////};
const c = classification("original");
verify.syntacticClassificationsAre(
c.keyword("var"), c.identifier("v"), c.operator("="), c.numericLiteral("10e0"), c.punctuation(";"),
c.keyword("var"), c.identifier("x"), c.operator("="), c.punctuation("{"),
c.identifier("p1"), c.punctuation(":"), c.numericLiteral("1"), c.punctuation(","),
c.identifier("p2"), c.punctuation(":"), c.numericLiteral("2"), c.punctuation(","),
c.identifier("any"), c.punctuation(":"), c.numericLiteral("3"), c.punctuation(","),
c.identifier("function"), c.punctuation(":"), c.numericLiteral("4"), c.punctuation(","),
c.identifier("var"), c.punctuation(":"), c.numericLiteral("5"), c.punctuation(","),
c.identifier("void"), c.punctuation(":"), c.keyword("void"), c.numericLiteral("0"), c.punctuation(","),
c.identifier("v"), c.punctuation(":"), c.identifier("v"), c.operator("+="), c.identifier("v"), c.punctuation(","),
c.punctuation("}"), c.punctuation(";"));
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("variable.declaration", "v"),
c2.semanticToken("variable.declaration", "x"),
c2.semanticToken("property.declaration", "p1"),
c2.semanticToken("property.declaration", "p2"),
c2.semanticToken("property.declaration", "any"),
c2.semanticToken("property.declaration", "function"),
c2.semanticToken("property.declaration", "var"),
c2.semanticToken("property.declaration", "void"),
c2.semanticToken("property.declaration", "v"),
c2.semanticToken("variable", "v"),
c2.semanticToken("variable", "v"),
);
| {
"end_byte": 1818,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsObjectLiteral.ts"
} |
TypeScript/tests/cases/fourslash/inlineVariableTemplateString1.ts_0_424 | /// <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": 424,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableTemplateString1.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_selectionOnImports.ts_0_233 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////export {};
////[|import foo from "./foo";|]
// No refactor available if every statement in the range is an import, since we don't move those.
verify.noMoveToNewFile();
| {
"end_byte": 233,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_selectionOnImports.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports51-slightly-more-complex-generics-with-default.ts_0_410 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
////export interface Foo<T, U = T[]> {}
////export function foo(x: Foo<string>) {
//// return x;
////}
verify.codeFix({
description: "Add return type 'Foo<string>'",
index: 0,
newFileContent:
`export interface Foo<T, U = T[]> {}
export function foo(x: Foo<string>): Foo<string> {
return x;
}`,
});
| {
"end_byte": 410,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports51-slightly-more-complex-generics-with-default.ts"
} |
TypeScript/tests/cases/fourslash/organizeImports9.ts_0_178 | /// <reference path="fourslash.ts" />
////import { a as a, b, c, d as d, e as e } from "foo";
////a(b, d);
verify.organizeImports(
`import { a, b, d } from "foo";
a(b, d);`
);
| {
"end_byte": 178,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImports9.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_importedFunction2.ts_0_654 | /// <reference path='fourslash.ts' />
// @Filename: f.ts
////export default function f(/*a*/a: number, b: string/*b*/): string {
//// return b;
////}
// @Filename: a.ts
////import g from "./f";
////g(4, "b");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `export default function f({ a, b }: { a: number; b: string; }): string {
return b;
}`
});
goTo.file("a.ts");
verify.currentFileContentIs(`import g from "./f";
g({ a: 4, b: "b" });`) | {
"end_byte": 654,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_importedFunction2.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType4.ts_0_308 | /// <reference path='fourslash.ts' />
//// var x: /*a*/1/*b*/ = 1;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent: `type /*RENAME*/NewType = 1;
var x: NewType = 1;`,
});
| {
"end_byte": 308,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType4.ts"
} |
TypeScript/tests/cases/fourslash/jsdocNullableUnion.ts_0_487 | ///<reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @checkJs: true
// @Filename: Foo.js
/////**
//// * @param {never | {x: string}} p1
//// * @param {undefined | {y: number}} p2
//// * @param {null | {z: boolean}} p3
//// * @returns {void} nothing
//// */
////function f(p1, p2, p3) {
//// p1./*1*/;
//// p2./*2*/;
//// p3./*3*/;
////}
verify.completions(
{ marker: "1", exact: "x" },
{ marker: "2", exact: "y" },
{ marker: "3", exact: "z" },
);
| {
"end_byte": 487,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocNullableUnion.ts"
} |
TypeScript/tests/cases/fourslash/refactorKind_rewriteFunctionOverloadList.ts_0_252 | /// <reference path='fourslash.ts' />
//// /*a*/declare function foo(): void;
//// declare function foo(a: string): void;/*b*/
goTo.select("a", "b");
verify.refactorKindAvailable("refactor.rewrite",
[
"refactor.rewrite.function.overloadList"
]);
| {
"end_byte": 252,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorKind_rewriteFunctionOverloadList.ts"
} |
TypeScript/tests/cases/fourslash/invertedFunduleAfterQuickInfo.ts_0_232 | /// <reference path="fourslash.ts" />
////module M {
//// module A {
//// var o;
//// }
//// function A(/**/x: number): void { }
////}
goTo.marker();
verify.quickInfoExists();
verify.numberOfErrorsInCurrentFile(1); | {
"end_byte": 232,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/invertedFunduleAfterQuickInfo.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType_js_Union_CommentBeforeMember.ts_0_415 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: a.js
////type Bar = /*a*/[|string | /* oops */ boolean|]/*b*/;
goTo.file('a.js')
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to typedef",
actionDescription: "Extract to typedef",
newContent:
`/**
* @typedef {string | boolean} /*RENAME*/NewType
*/
type Bar = NewType;`,
});
| {
"end_byte": 415,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType_js_Union_CommentBeforeMember.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageCallbackParameter4.ts_0_552 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noImplicitAny: false
// @filename: /foo.js
////function foo(names) {
//// return names.filter(function (name, index) {
//// return name === "foo" && index === 1;
//// });
////}
verify.codeFix({
description: "Infer parameter types from usage",
index: 1,
newFileContent:
`function foo(names) {
return names.filter(function (/** @type {string} */ name, /** @type {number} */ index) {
return name === "foo" && index === 1;
});
}`
});
| {
"end_byte": 552,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageCallbackParameter4.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess35.ts_0_1140 | /// <reference path='fourslash.ts' />
//// class A {
//// /*a*/public/*b*/ /*c*/a/*d*/ = () => {
//// /*e*/return/*f*/ /*g*/1/*h*/;
//// }
//// /*i*/b/*j*/: /*k*/number/*l*/ = /*m*/1/*n*/
//// /*o*/public /*p*/ c: number = 1; /*q*/
//// /*r*/d = 1
//// /*s*/public e/*t*/ = /*u*/ 1
//// f = 1/*v*/ /*w*/
//// g = 1/*x*/
//// };
goTo.select("a", "b");
verify.not.refactorAvailable();
goTo.select("c", "d");
verify.refactorAvailable("Generate 'get' and 'set' accessors");
goTo.select("e", "f");
verify.not.refactorAvailable();
goTo.select("g", "h");
verify.not.refactorAvailable();
goTo.select("i", "j");
verify.not.refactorAvailable();
goTo.select("k", "l");
verify.not.refactorAvailable();
goTo.select("m", "n");
verify.not.refactorAvailable();
goTo.select("o", "p");
verify.not.refactorAvailable();
goTo.select("q", "r");
verify.not.refactorAvailable();
goTo.select("s", "t");
verify.refactorAvailable("Generate 'get' and 'set' accessors");
goTo.select("u", "v");
verify.not.refactorAvailable();
goTo.select("w", "x");
verify.refactorAvailable("Generate 'get' and 'set' accessors");
| {
"end_byte": 1140,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess35.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType47.ts_0_219 | /// <reference path='fourslash.ts' />
//// type Crazy<T> = T extends [infer P, (/*a*/infer R extends string ? string : never/*b*/)] ? P & R : string;
goTo.select("a", "b");
verify.not.refactorAvailable("Extract type") | {
"end_byte": 219,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType47.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_export_alias.ts_0_313 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @target: esnext
// @Filename: /a.js
////const exportsAlias = exports;
////exportsAlias.f = function() {};
////module.exports = exportsAlias;
verify.codeFix({
description: "Convert to ES module",
newFileContent: `
export function f() {}
`,
});
| {
"end_byte": 313,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_export_alias.ts"
} |
TypeScript/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile7.ts_0_334 | /// <reference path='fourslash.ts' />
// @allowjs: true
// @noEmit: true
// @checkJs: true
// @Filename: a.js
////var x = 0;
////
////function f(_a) {[|
//// x();
////|]}
// Disable checking for next line
verify.rangeAfterCodeFix(`// @ts-ignore
x();`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
| {
"end_byte": 334,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile7.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarItemsClass6.ts_0_439 | /// <reference path="fourslash.ts"/>
////function Z() { }
////
////Z.foo = 42
////
////class Z { }
verify.navigationTree({
text: "<global>",
kind: "script",
childItems: [
{
text: "Z",
kind: "class",
childItems: [
{
text: "constructor",
kind: "constructor"
},
{
text: "foo"
}
]
},
{
text: "Z",
kind: "class"
}
]
});
| {
"end_byte": 439,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsClass6.ts"
} |
TypeScript/tests/cases/fourslash/codeFixOverrideModifier3.ts_0_344 | /// <reference path='fourslash.ts' />
// @noImplicitOverride: true
//// class E extends (class {
//// foo () {}
//// bar () {}
//// }) {
//// override foo () {}
//// [|bar () {}|]
//// baz() {}
//// }
verify.codeFix({
description: "Add 'override' modifier",
newRangeContent: "override bar () {}",
index: 0
})
| {
"end_byte": 344,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixOverrideModifier3.ts"
} |
TypeScript/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts_3_584 | / <reference path='fourslash.ts'/>
// @Filename: file1.ts
//// class Foo {
//// constructor(private /*1*/privateParam: number,
//// public /*2*/publicParam: string,
//// protected /*3*/protectedParam: boolean) {
////
//// let localPrivate = privateParam;
//// this.privateParam += 10;
////
//// let localPublic = publicParam;
//// this.publicParam += " Hello!";
////
//// let localProtected = protectedParam;
//// this.protectedParam = false;
//// }
//// }
verify.baselineFindAllReferences('1', '2', '3')
| {
"end_byte": 584,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts"
} |
TypeScript/tests/cases/fourslash/typeErrorAfterStringCompletionsInNestedCall2.ts_0_1386 | ///<reference path="fourslash.ts"/>
// @strict: true
////
//// type ActionFunction<
//// TExpressionEvent extends { type: string },
//// out TEvent extends { type: string }
//// > = {
//// ({ event }: { event: TExpressionEvent }): void;
//// _out_TEvent?: TEvent;
//// };
////
//// interface MachineConfig<TEvent extends { type: string }> {
//// types: {
//// events: TEvent;
//// };
//// on: {
//// [K in TEvent["type"]]?: ActionFunction<
//// Extract<TEvent, { type: K }>,
//// TEvent
//// >;
//// };
//// }
////
//// declare function raise<
//// TExpressionEvent extends { type: string },
//// TEvent extends { type: string }
//// >(
//// resolve: ({ event }: { event: TExpressionEvent }) => TEvent
//// ): {
//// ({ event }: { event: TExpressionEvent }): void;
//// _out_TEvent?: TEvent;
//// };
////
//// declare function createMachine<TEvent extends { type: string }>(
//// config: MachineConfig<TEvent>
//// ): void;
////
//// createMachine({
//// types: {
//// events: {} as { type: "FOO" } | { type: "BAR" },
//// },
//// on: {
//// [|/*error*/FOO|]: raise(({ event }) => {
//// return {
//// type: "BAR/*1*/" as const,
//// };
//// }),
//// },
//// });
goTo.marker("1");
edit.insert(`x`)
verify.completions({ exact: ["FOO", "BAR"] });
verify.baselineSyntacticAndSemanticDiagnostics() | {
"end_byte": 1386,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/typeErrorAfterStringCompletionsInNestedCall2.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_Param.ts_0_388 | /// <reference path='fourslash.ts' />
//// const foo = /*x*/f/*y*/unction(a, b, c) {
//// return a + b + c;
//// };
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to arrow function",
actionDescription: "Convert to arrow function",
newContent: `const foo = (a, b, c) => a + b + c;`,
});
| {
"end_byte": 388,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_Param.ts"
} |
TypeScript/tests/cases/fourslash/noErrorsAfterCompletionsRequestWithinGenericFunction1.ts_0_238 | ///<reference path="fourslash.ts"/>
// @strict: true
////
//// declare function func<T extends { foo: 1 }>(arg: T): void;
//// func({ foo: 1, bar/*1*/: 1 });
goTo.marker("1");
verify.completions({ exact: undefined });
verify.noErrors();
| {
"end_byte": 238,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/noErrorsAfterCompletionsRequestWithinGenericFunction1.ts"
} |
TypeScript/tests/cases/fourslash/formatSelectionEditAtEndOfRange.ts_0_202 | /// <reference path="fourslash.ts" />
//// /*1*/var x = 1;/*2*/
//// void 0;
format.setOption("semicolons", "remove");
format.selection("1", "2");
verify.currentFileContentIs(
`var x = 1
void 0;`
);
| {
"end_byte": 202,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatSelectionEditAtEndOfRange.ts"
} |
TypeScript/tests/cases/fourslash/formatNoSpaceBeforeCloseBrace1.ts_0_152 | /// <reference path="fourslash.ts"/>
////new Foo(1, /* comment */ );
format.document();
verify.currentFileContentIs(`new Foo(1, /* comment */);`);
| {
"end_byte": 152,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatNoSpaceBeforeCloseBrace1.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsModuleDotExports.ts_0_218 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: /a.js
/////*1*/const b = require("/*2*/./b");
// @Filename: /b.js
/////*3*/module.exports = 0;
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 218,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsModuleDotExports.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_import_arrayBindingPattern.ts_0_281 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @target: esnext
// @Filename: /a.js
////const [x, y] = /*a*/require/*b*/("x");
////x; y;
verify.codeFix({
description: "Convert to ES module",
newFileContent: `import _x from "x";
const [x, y] = _x;
x; y;`,
});
| {
"end_byte": 281,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_import_arrayBindingPattern.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.