_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/refactorExtractType83.ts_0_408 | /// <reference path='fourslash.ts' />
//// type A = { a: str/*1*/ing } | { b: string } | { c: string }/*2*/;
goTo.select("1", "2");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent:
`type /*RENAME*/NewType = {
a: string;
} | {
b: string;
} | {
c: string;
};
type A = NewType;`,
});
| {
"end_byte": 408,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType83.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCalledES2015Import8.ts_0_409 | /// <reference path='fourslash.ts' />
// @esModuleInterop: true
// @Filename: foo.d.ts
////declare class foo(): void;
////declare namespace foo {}
////export = foo;
// @Filename: index.ts
////[|import * as foo from "./foo";|]
////new foo();
goTo.file(1);
verify.codeFix({
description: `Replace import with 'import foo from "./foo";'.`,
newRangeContent: `import foo from "./foo";`,
index: 0,
});
| {
"end_byte": 409,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCalledES2015Import8.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationLocal_04.ts_0_226 | /// <reference path='fourslash.ts'/>
// Should return definition of function when invoked on the declaration
//// function [|he/*local_var*/llo|]() {}
////
//// hello();
////
verify.baselineGoToImplementation("local_var");
| {
"end_byte": 226,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationLocal_04.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageRestParam3JS.ts_0_446 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noImplicitAny: true
// @Filename: important.js
/////** @param {number} a */
////function f(a, [|...rest|]){
//// a;
//// rest.push(22);
////}
verify.codeFix({
description: "Infer parameter types from usage",
index: 0,
newFileContent:
`/**
* @param {number} a
* @param {number[]} rest
*/
function f(a, ...rest){
a;
rest.push(22);
}`,
});
| {
"end_byte": 446,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageRestParam3JS.ts"
} |
TypeScript/tests/cases/fourslash/tsxCompletion5.ts_0_312 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// div: { ONE: string; TWO: number; }
//// }
//// }
//// var x = <div ONE/**//>;
verify.completions({ marker: "", exact: ["ONE", "TWO"] });
| {
"end_byte": 312,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletion5.ts"
} |
TypeScript/tests/cases/fourslash/inlineVariableExportedVariable.ts_0_440 | /// <reference path="fourslash.ts" />
////export const /*a1*/x/*b1*/ = 1;
////const /*a2*/y/*b2*/ = 2;
////const /*a3*/z/*b3*/ = 3;
////const u = x + 1;
////const v = 2 + y;
////export { y };
////export { z as w };
goTo.select("a1", "b1");
verify.not.refactorAvailable("Inline variable");
goTo.select("a2", "b2");
verify.not.refactorAvailable("Inline variable");
goTo.select("a3", "b3");
verify.not.refactorAvailable("Inline variable"); | {
"end_byte": 440,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableExportedVariable.ts"
} |
TypeScript/tests/cases/fourslash/completionsCombineOverloads_returnType.ts_0_244 | /// <reference path="fourslash.ts" />
////interface A { a: number }
////interface B { b: number }
////declare function f(n: number): A;
////declare function f(s: string): B;
////f()./**/
verify.completions({ marker: "", exact: ["a", "b"] });
| {
"end_byte": 244,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsCombineOverloads_returnType.ts"
} |
TypeScript/tests/cases/fourslash/completionsOverridingMethod12.ts_0_1999 | /// <reference path="fourslash.ts" />
// @Filename: a.ts
// @newline: LF
// Case: modifier order
////abstract class A {
//// public get P(): string {
//// return "";
//// }
////}
////
////abstract class B extends A {
//// abstract /*a*/
////}
////
////abstract class B1 extends A {
//// abstract override /*b*/
////}
verify.completions({
marker: "a",
isNewIdentifierLocation: true,
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithClassMemberSnippets: true,
},
includes: [
{
name: "P",
sortText: completion.SortText.LocationPriority,
insertText: "abstract get P(): string;",
filterText: "P",
hasAction: true,
source: completion.CompletionSource.ClassMemberSnippet,
},
],
});
verify.completions({
marker: "b",
isNewIdentifierLocation: true,
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithClassMemberSnippets: true,
},
includes: [
{
name: "P",
sortText: completion.SortText.LocationPriority,
insertText: "abstract override get P(): string;",
filterText: "P",
hasAction: true,
source: completion.CompletionSource.ClassMemberSnippet,
},
],
});
verify.applyCodeActionFromCompletion("b", {
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithClassMemberSnippets: true,
},
name: "P",
source: completion.CompletionSource.ClassMemberSnippet,
description: "Update modifiers of 'P'",
newFileContent:
`abstract class A {
public get P(): string {
return "";
}
}
abstract class B extends A {
abstract
}
abstract class B1 extends A {
}`
}); | {
"end_byte": 1999,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingMethod12.ts"
} |
TypeScript/tests/cases/fourslash/memberCompletionOnTypeParameters.ts_0_706 | /// <reference path='fourslash.ts'/>
////interface IFoo {
//// x: number;
//// y: string;
////}
////
////function foo<S, T extends IFoo, U extends Object, V extends IFoo>() {
//// var s:S, t: T, u: U, v: V;
//// s./*S*/; // no constraint, no completion
//// t./*T*/; // IFoo
//// u./*U*/; // IFoo
//// v./*V*/; // IFoo
////}
verify.completions(
{ marker: "S", exact: undefined },
{ marker: ["T", "V"], exact: [{ name: "x", text: "(property) IFoo.x: number" }, { name: "y", text: "(property) IFoo.y: string" }]},
{ marker: "U", unsorted: ["constructor", "toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable"] },
);
| {
"end_byte": 706,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberCompletionOnTypeParameters.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationUnaryExpressions.ts_0_305 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_unaryExpressions.baseline
// @Filename: bpSpan_unaryExpressions.ts
////var x = 10;
////var y = 20;
////x++;
////y--;
////typeof (function foo() {
//// return y;
////})();
////++x;
////++y;
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 305,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationUnaryExpressions.ts"
} |
TypeScript/tests/cases/fourslash/formatSignatures.ts_0_770 | /// <reference path="fourslash.ts"/>
////type Foo = {
//// (
//// call: any/*callAutoformat*/
/////*callIndent*/
//// ): void;
//// new (
//// constr: any/*constrAutoformat*/
/////*constrIndent*/
//// ): void;
//// method(
//// whatever: any/*methodAutoformat*/
/////*methodIndent*/
//// ): void;
////};
format.document();
goTo.marker("callAutoformat");
verify.currentLineContentIs(" call: any");
goTo.marker("callIndent");
verify.indentationIs(8);
goTo.marker("constrAutoformat");
verify.currentLineContentIs(" constr: any");
goTo.marker("constrIndent");
verify.indentationIs(8);
goTo.marker("methodAutoformat");
verify.currentLineContentIs(" whatever: any");
goTo.marker("methodIndent");
verify.indentationIs(8); | {
"end_byte": 770,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatSignatures.ts"
} |
TypeScript/tests/cases/fourslash/formattingIndentSwitchCase.ts_0_620 | /// <reference path='fourslash.ts'/>
////let foo = 1;
////switch (foo) {
/////*1*/case 0:
/////*2*/break;
/////*3*/default:
/////*4*/break;
////}
format.setOption('indentSwitchCase', true);
format.document();
goTo.marker('1');
verify.indentationIs(4);
goTo.marker('2');
verify.indentationIs(8);
goTo.marker('3');
verify.indentationIs(4);
goTo.marker('4');
verify.indentationIs(8);
format.setOption('indentSwitchCase', false);
format.document();
goTo.marker('1');
verify.indentationIs(0);
goTo.marker('2');
verify.indentationIs(4);
goTo.marker('3');
verify.indentationIs(0);
goTo.marker('4');
verify.indentationIs(4);
| {
"end_byte": 620,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingIndentSwitchCase.ts"
} |
TypeScript/tests/cases/fourslash/classRenamingErrorRecovery.ts_0_248 | /// <reference path="fourslash.ts" />
////class Foo/*1*//*2*/ { public Bar() { } }
goTo.marker("1");
edit.backspace(3);
edit.insert("Pizza");
verify.currentLineContentIs("class Pizza { public Bar() { } }");
verify.not.errorExistsAfterMarker("2"); | {
"end_byte": 248,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/classRenamingErrorRecovery.ts"
} |
TypeScript/tests/cases/fourslash/extract-method28.ts_0_483 | /// <reference path='fourslash.ts' />
/////*a*/console.log(0) //
////console.log(0)/*b*/
format.setFormatOptions({ ...format.copyFormatOptions(), semicolons: ts.SemicolonPreference.Insert });
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_0",
actionDescription: "Extract to function in global scope",
newContent:
`/*RENAME*/newFunction();
function newFunction() {
console.log(0); //
console.log(0);
}
`
});
| {
"end_byte": 483,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method28.ts"
} |
TypeScript/tests/cases/fourslash/addDeclareToModule.ts_0_139 | /// <reference path="fourslash.ts" />
//// /**/module mAmbient {
//// module m3 { }
//// }
goTo.marker('');
edit.insert("declare ");
| {
"end_byte": 139,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/addDeclareToModule.ts"
} |
TypeScript/tests/cases/fourslash/syntaxErrorAfterImport1.ts_0_303 | /// <reference path='fourslash.ts' />
////declare module "extmod" {
//// module IntMod {
//// class Customer {
//// constructor(name: string);
//// }
//// }
////}
////import ext = require('extmod');
////import int = ext.IntMod;
////var x = new int/*0*/
goTo.marker("0");
edit.insert("."); | {
"end_byte": 303,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntaxErrorAfterImport1.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptQuickInfo5.ts_0_221 | /// <reference path='fourslash.ts'/>
// @allowNonTsExtensions: true
// @Filename: Foo.js
/////** @param {{b:number}} [a] */
////function /**/f(a) { }
verify.quickInfoAt("", "function f(a?: {\n b: number;\n}): void"); | {
"end_byte": 221,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptQuickInfo5.ts"
} |
TypeScript/tests/cases/fourslash/renameLabel6.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/renameLabel6.ts"
} |
TypeScript/tests/cases/fourslash/extract-const_jsxElement4.ts_0_523 | /// <reference path="fourslash.ts" />
// @jsx: preserve
// @filename: a.tsx
////function Foo() {
//// const foo = [
//// /*a*/<div>' <span></span></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>' <span></span></div>;
function Foo() {
const foo = [
/*RENAME*/newLocal
];
}`
});
| {
"end_byte": 523,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const_jsxElement4.ts"
} |
TypeScript/tests/cases/fourslash/referencesForStringLiteralPropertyNames7.ts_0_251 | /// <reference path='fourslash.ts'/>
// @Filename: foo.js
// @noEmit: true
// @allowJs: true
// @checkJs: true
////var x = { "/*1*/someProperty": 0 }
////x["/*2*/someProperty"] = 3;
////x.someProperty = 5;
verify.baselineFindAllReferences('1', '2')
| {
"end_byte": 251,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForStringLiteralPropertyNames7.ts"
} |
TypeScript/tests/cases/fourslash/unusedTypeParametersInInterface1.ts_0_224 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
//// [|interface I<T> {}|]
verify.codeFix({
description: "Remove type parameters",
newRangeContent: "interface I {}",
});
| {
"end_byte": 224,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedTypeParametersInInterface1.ts"
} |
TypeScript/tests/cases/fourslash/typeAssertionsFormatting.ts_0_254 | /// <reference path='fourslash.ts' />
////( < any > publisher);/*1*/
//// < any > 3;/*2*/
format.document();
goTo.marker("1");
verify.currentLineContentIs("(<any>publisher);");
goTo.marker("2");
verify.currentLineContentIs("<any>3;"); | {
"end_byte": 254,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/typeAssertionsFormatting.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesThis.ts_0_2891 | /// <reference path='fourslash.ts' />
////[|this|];
////[|th/**/is|];
////
////function f() {
//// this;
//// this;
//// () => this;
//// () => {
//// if (this) {
//// this;
//// }
//// else {
//// this.this;
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
////}
////
////module m {
//// function f() {
//// this;
//// this;
//// () => this;
//// () => {
//// if (this) {
//// this;
//// }
//// else {
//// this.this;
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
//// }
////}
////
////class A {
//// public b = this.method1;
////
//// public method1() {
//// this;
//// this;
//// () => this;
//// () => {
//// if (this) {
//// this;
//// }
//// else {
//// this.this;
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
//// }
////
//// private method2() {
//// this;
//// this;
//// () => this;
//// () => {
//// if (this) {
//// this;
//// }
//// else {
//// this.this;
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
//// }
////
//// public static staticB = this.staticMethod1;
////
//// public static staticMethod1() {
//// this;
//// this;
//// () => this;
//// () => {
//// if (this) {
//// this;
//// }
//// else {
//// this.this;
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
//// }
////
//// private static staticMethod2() {
//// this;
//// this;
//// () => this;
//// () => {
//// if (this) {
//// this;
//// }
//// else {
//// this.this;
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
//// }
////}
////
////var x = {
//// f() {
//// this;
//// },
//// g() {
//// this;
//// }
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 2891,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesThis.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType70.ts_0_562 | /// <reference path='fourslash.ts' />
////type Foo<T1, T2, T3> = {
//// fn: /*a*/(a: T1, b: T2, c: T3, a1: T1, a2: T2, a3: T3) => void;/*b*/
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent: [
"type /*RENAME*/NewType<T1, T2, T3> = (a: T1, b: T2, c: T3, a1: T1, a2: T2, a3: T3) => void;",
"",
"type Foo<T1, T2, T3> = {",
" fn: NewType<T1, T2, T3>;",
"}"
].join("\n"),
});
| {
"end_byte": 562,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType70.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageNumberPriority.ts_0_274 | /// <reference path='fourslash.ts' />
////function f(x, y) {
//// return x + y
////}
////f(1, 2)
verify.codeFix({
description: "Infer parameter types from usage",
index: 0,
newFileContent:
`function f(x: number, y: number) {
return x + y
}
f(1, 2)`,
});
| {
"end_byte": 274,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageNumberPriority.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_ConditionalStrictMode.ts_0_396 | /// <reference path='fourslash.ts' />
// @strict: true
////interface Foo {
//// bar?:{
//// baz: string;
//// }
////}
////declare let foo: Foo;
/////*a*/foo.bar ? foo.bar.baz : "whenFalse";/*b*/
// Offer the refactor for ternary expressions if type of baz is not null, unknown, or undefined
goTo.select("a", "b");
verify.refactorAvailable("Convert to optional chain expression");
| {
"end_byte": 396,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_ConditionalStrictMode.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_paramDecorator.ts_0_328 | /// <reference path='fourslash.ts' />
////declare function required(target: Object, propertyKey: string | symbol, parameterIndex: number)
////class C {
//// /*a*/bar/*b*/(@required a: number, b: number) {
////
//// }
////}
goTo.select("a", "b");
verify.not.refactorAvailable("Convert parameters to destructured object"); | {
"end_byte": 328,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_paramDecorator.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_filteredByPackageJson_peerDependencies.ts_0_937 | /// <reference path="fourslash.ts" />
//@noEmit: true
//@Filename: /package.json
////{
//// "peerDependencies": {
//// "react": "*"
//// }
////}
//@Filename: /node_modules/react/index.d.ts
////export declare var React: any;
//@Filename: /node_modules/react/package.json
////{
//// "name": "react",
//// "types": "./index.d.ts"
////}
//@Filename: /node_modules/fake-react/index.d.ts
////export declare var ReactFake: any;
//@Filename: /node_modules/fake-react/package.json
////{
//// "name": "fake-react",
//// "types": "./index.d.ts"
////}
//@Filename: /src/index.ts
////const x = Re/**/
verify.completions({
marker: test.marker(""),
isNewIdentifierLocation: true,
includes: {
name: "React",
hasAction: true,
source: "/node_modules/react/index",
sortText: completion.SortText.AutoImportSuggestions
},
excludes: "ReactFake",
preferences: {
includeCompletionsForModuleExports: true
}
});
| {
"end_byte": 937,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_filteredByPackageJson_peerDependencies.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceClassExpression.ts_0_261 | /// <reference path='fourslash.ts' />
////interface I { x: number; }
////new class implements I {};
verify.codeFix({
description: "Implement interface 'I'",
newFileContent:
`interface I { x: number; }
new class implements I {
x: number;
};`,
});
| {
"end_byte": 261,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceClassExpression.ts"
} |
TypeScript/tests/cases/fourslash/mapCodeNestedForOfInsertion.ts_0_366 | ///<reference path="fourslash.ts"/>
// @Filename: /index.ts
//// function foo() {
//// for (const x of [1, 2, 3])[||] {
//// console.log("hello");
//// console.log("you");
//// }
//// return 1;
//// }
////
verify.baselineMapCode([test.ranges()], [
`
for (const y of [1, 2, 3]) {
console.log("goodbye");
console.log("world");
}
`
]); | {
"end_byte": 366,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeNestedForOfInsertion.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageVariableJS.ts_0_323 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noEmit: true
// @noImplicitAny: true
// @Filename: important.js
////[|var x;|]
////function f() {
//// x++;
////}
verify.rangeAfterCodeFix("/**\n * @type {number}\n*/\nvar x;", /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, 0);
| {
"end_byte": 323,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageVariableJS.ts"
} |
TypeScript/tests/cases/fourslash/autoImportPathsConfigDir.ts_0_362 | /// <reference path="fourslash.ts" />
// @Filename: tsconfig.json
//// {
//// "compilerOptions": {
//// "paths": {
//// "@root/*": ["${configDir}/src/*"]
//// }
//// }
//// }
// @Filename: src/one.ts
//// export const one = 1;
// @Filename: src/foo/two.ts
//// one/**/
verify.importFixModuleSpecifiers("", ["@root/one"]);
| {
"end_byte": 362,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPathsConfigDir.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_notAtTopLevel.ts_0_192 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @target: esnext
// @Filename: /a.js
////(function() {
//// module.exports = 0;
////})();
verify.getSuggestionDiagnostics([]);
| {
"end_byte": 192,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_notAtTopLevel.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType21.ts_0_406 | /// <reference path='fourslash.ts' />
//// type A<T, U> = () => <T>(v: T) => (v: /*a*/T/*b*/) => <T>(v: T) => 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: NewType<T>) => <T>(v: T) => U;`,
});
| {
"end_byte": 406,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType21.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringVariableStatement.ts_0_647 | /// <reference path='fourslash.ts' />
////interface Robot {
//// name: string;
//// skill: string;
////}
////declare var console: {
//// log(msg: string): void;
////}
////var hello = "hello";
////var robotA: Robot = { name: "mower", skill: "mowing" };
////var robotB: Robot = { name: "trimmer", skill: "trimming" };
////var { name: nameA } = robotA;
////var { name: nameB, skill: skillB } = robotB;
////var { name: nameC, skill: skillC } = { name: "Edger", skill: "cutting edges" };
////if (nameA == nameB) {
//// console.log(skillB);
////}
////else {
//// console.log(nameC);
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 647,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringVariableStatement.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUseBigIntLiteralWithNumericSeparators.ts_0_178 | /// <reference path="fourslash.ts" />
////6_402_373_705_728_000; // 18! < 2 ** 53
////0x16_BE_EC_CA_73_00_00; // 18! < 2 ** 53
verify.not.codeFixAvailable("useBigintLiteral");
| {
"end_byte": 178,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUseBigIntLiteralWithNumericSeparators.ts"
} |
TypeScript/tests/cases/fourslash/autoImportPackageJsonImportsPreference2.ts_0_415 | /// <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: "project-relative"
});
| {
"end_byte": 415,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPackageJsonImportsPreference2.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesLoopBreakContinue3.ts_0_1873 | /// <reference path='fourslash.ts' />
////var arr = [1, 2, 3, 4];
////label1: for (var n in arr) {
//// break;
//// continue;
//// break label1;
//// continue label1;
////
//// label2: for (var i = 0; i < arr[n]; i++) {
//// break label1;
//// continue label1;
////
//// break;
//// continue;
//// break label2;
//// continue label2;
////
//// function foo() {
//// label3: [|w/**/hile|] (true) {
//// [|break|];
//// [|continue|];
//// [|break|] label3;
//// [|continue|] label3;
////
//// // these cross function boundaries
//// break label1;
//// continue label1;
//// break label2;
//// continue label2;
////
//// label4: do {
//// break;
//// continue;
//// break label4;
//// continue label4;
////
//// [|break|] label3;
//// [|continue|] label3;
////
//// switch (10) {
//// case 1:
//// case 2:
//// break;
//// break label4;
//// default:
//// continue;
//// }
////
//// // these cross function boundaries
//// break label1;
//// continue label1;
//// break label2;
//// continue label2;
//// () => { break; }
//// } while (true)
//// }
//// }
//// }
////}
////
////label5: while (true) break label5;
////
////label7: while (true) continue label5;
verify.baselineDocumentHighlights();
| {
"end_byte": 1873,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesLoopBreakContinue3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingMember31.ts_0_353 | /// <reference path='fourslash.ts' />
////class C {
//// "new"(x: number) {}
////}
////[|const foo: C = {}|];
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newRangeContent:
`const foo: C = {
new: function(x: number): void {
throw new Error("Function not implemented.");
}
}`
});
| {
"end_byte": 353,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingMember31.ts"
} |
TypeScript/tests/cases/fourslash/preparePasteEdits_resolvedIdentifiers.ts_0_441 | /// <reference path='./fourslash.ts' />
// @Filename: /file2.ts
////import { b } from './file1';
////export const a = 1;
//// [|function MyFunction() {}
//// namespace MyFunction {
//// export const value = b;
//// }|]
////const c = a + 20;
////const t = 9;
// @Filename: /file1.ts
////export const b = 2;
verify.preparePasteEdits({
copiedFromFile: "/file2.ts",
copiedTextRange: test.ranges(),
providePasteEdits: true,
})
| {
"end_byte": 441,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/preparePasteEdits_resolvedIdentifiers.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType_js5.ts_0_690 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: a.js
//// /**
//// * @template {number} T
//// * @template {string} U
//// * @param {T} b
//// * @param {U} c
//// * @returns {/*a*/T | U/*b*/}
//// */
//// function a(b, c) {}
goTo.file('a.js')
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to typedef",
actionDescription: "Extract to typedef",
newContent: `/**
* @template {number} T
* @template {string} U
* @typedef {T | U} /*RENAME*/NewType
*/
/**
* @template {number} T
* @template {string} U
* @param {T} b
* @param {U} c
* @returns {NewType<T, U>}
*/
function a(b, c) {}`,
});
| {
"end_byte": 690,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType_js5.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_namedExport3.ts_0_349 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////const a = 1;
////[|const b = a + 1;|]
////export const c = a + b;
verify.moveToNewFile({
newFileContents: {
"/a.ts":
`import { b } from "./b";
export const a = 1;
export const c = a + b;`,
"/b.ts":
`import { a } from "./a";
export const b = a + 1;
`,
}
});
| {
"end_byte": 349,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_namedExport3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpelling12.ts_0_403 | /// <reference path='fourslash.ts' />
// @noImplicitOverride: true
// @allowJs: true
// @checkJs: true
// @Filename: a.js
////class A {
//// doSomething() {}
////}
////class B extends A {
//// /** @override */
//// [|doSomethang|]() {}
////}
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Change_spelling_to_0.message, "doSomething"],
newRangeContent: "doSomething"
});
| {
"end_byte": 403,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpelling12.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsFunctionParameterTypes2.ts_0_631 | /// <reference path="fourslash.ts" />
////class C {}
////namespace N { export class Foo {} }
////interface Foo {}
////function f1(a = 1) {}
////function f2(a = "a") {}
////function f3(a = true) {}
////function f4(a = { } as Foo) {}
////function f5(a = <Foo>{}) {}
////function f6(a = {} as const) {}
////function f7(a = (({} as const))) {}
////function f8(a = new C()) {}
////function f9(a = new N.C()) {}
////function f10(a = ((((new C()))))) {}
////function f11(a = { a: 1, b: 1 }) {}
////function f12(a = ((({ a: 1, b: 1 })))) {}
verify.baselineInlayHints(undefined, {
includeInlayFunctionParameterTypeHints: true
});
| {
"end_byte": 631,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsFunctionParameterTypes2.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionExpandoClass1.ts_0_277 | /// <reference path="fourslash.ts" />
// @strict: true
// @allowJs: true
// @checkJs: true
// @filename: index.js
//// const Core = {}
////
//// Core.Test = class { }
////
//// Core.Test.prototype.foo = 10
////
//// new Core.Tes/*1*/t()
verify.baselineGoToDefinition("1");
| {
"end_byte": 277,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionExpandoClass1.ts"
} |
TypeScript/tests/cases/fourslash/formattingMultipleMappedType.ts_0_1258 | /// <reference path='fourslash.ts' />
/////*x1*/type x1<T> = {[K in keyof T]: number}
/////*x2*/type x2<T> = { [K in keyof T]: number }
/////*x3*/type x3<T> = { [K in keyof T]: number}
/////*x4*/type x4<T> = {[K in keyof T]: number }
/////*x5*/type x5<T> = { [K in keyof T]: number}
/////*x6*/type x6<T> = {[K in keyof T]: number }
/////*x7*/type x7<T> = { [K in keyof T]: number }
/////*x8*/type x8<T> = { [K in keyof T]: number };
////
/////*y1*/type y1 = {foo: number}
/////*y2*/type y2 = { foo: number }
/////*y3*/type y3 = { foo: number}
/////*y4*/type y4 = {foo: number }
/////*y5*/type y5 = { foo: number}
/////*y6*/type y6 = {foo: number }
/////*y7*/type y7 = { foo: number }
/////*y8*/type y8 = { foo: number };
format.document();
for (let index = 1; index < 8; index++) {
goTo.marker(`x${index}`);
verify.currentLineContentIs(`type x${index}<T> = { [K in keyof T]: number }`);
}
goTo.marker(`x8`);
verify.currentLineContentIs(`type x8<T> = { [K in keyof T]: number };`);
for (let index = 1; index < 8; index++) {
goTo.marker(`y${index}`);
verify.currentLineContentIs(`type y${index} = { foo: number }`);
}
goTo.marker(`y8`);
verify.currentLineContentIs(`type y8 = { foo: number };`); | {
"end_byte": 1258,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingMultipleMappedType.ts"
} |
TypeScript/tests/cases/fourslash/completionsIsTypeOnlyCompletion.ts_0_443 | /// <reference path='fourslash.ts'/>
// @noLib: true
// @Filename: /abc.ts
////export type Abc = number;
// @Filename: /user.ts
//// import { Abc } from "./abc";
////function f(Abc: Ab/**/) {}
verify.completions({
marker: "",
// Should not have an import completion for 'Abc', should use the local one
exact: completion.typeKeywordsPlus(["Abc"]),
preferences: {
includeCompletionsForModuleExports: true,
},
});
| {
"end_byte": 443,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsIsTypeOnlyCompletion.ts"
} |
TypeScript/tests/cases/fourslash/completionsSelfDeclaring2.ts_0_379 | /// <reference path="fourslash.ts" />
//// function f1<T>(x: T) {}
//// f1({ abc/*1*/ });
//// function f2<T extends { xyz: number }>(x: T) {}
//// f2({ x/*2*/ });
verify.completions({
marker: "1",
exact: completion.globalsPlus(["f1", "f2"]),
isNewIdentifierLocation: true
});
verify.completions({
marker: "2",
exact: ["xyz"],
isNewIdentifierLocation: false
});
| {
"end_byte": 379,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsSelfDeclaring2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixTopLevelAwait_module_missingCompilerOptionsInTsConfig.ts_0_276 | /// <reference path="fourslash.ts" />
// @filename: /dir/a.ts
////declare const p: Promise<number>;
////await p;
////export {};
// @filename: /dir/tsconfig.json
////{
////}
// cannot fix module when default options are applied
verify.not.codeFixAvailable("fixModuleOption");
| {
"end_byte": 276,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelAwait_module_missingCompilerOptionsInTsConfig.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_ElementAccessExpression2.ts_0_402 | /// <reference path='fourslash.ts' />
////const a = {
//// b: { c: 1 }
////}
/////*a*/a && a.b && a.b['c']/*b*/
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to optional chain expression",
actionName: "Convert to optional chain expression",
actionDescription: "Convert to optional chain expression",
newContent:
`const a = {
b: { c: 1 }
}
a?.b?.['c']`
});
| {
"end_byte": 402,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_ElementAccessExpression2.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsTypeofImport.ts_0_200 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
/////*1*/export const /*2*/x = 0;
////declare const a: typeof import("./a");
////a./*3*/x;
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 200,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsTypeofImport.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedFunction08.ts_3_324 | / <reference path="fourslash.ts" />
////function foo(x: string, y: number, z: boolean) {
//// function bar(a: number, b: string = "hello", c: typeof x = "hello") {
//// var v = /*1*/
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"], isNewIdentifierLocation: true });
| {
"end_byte": 324,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedFunction08.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingAwait_iterables.ts_0_1144 | /// <reference path="fourslash.ts" />
////async function fn(a: Promise<string[]>) {
//// [...a];
//// for (const c of a) { c; }
//// for await (const c of a) { c; }
////}
verify.codeFix({
description: ts.Diagnostics.Add_await.message,
index: 0,
newFileContent:
`async function fn(a: Promise<string[]>) {
[...await a];
for (const c of a) { c; }
for await (const c of a) { c; }
}`
});
verify.codeFix({
description: ts.Diagnostics.Add_await.message,
index: 1,
newFileContent:
`async function fn(a: Promise<string[]>) {
[...a];
for (const c of await a) { c; }
for await (const c of a) { c; }
}`
});
verify.codeFix({
description: ts.Diagnostics.Add_await.message,
index: 2,
newFileContent:
`async function fn(a: Promise<string[]>) {
[...a];
for (const c of a) { c; }
for await (const c of await a) { c; }
}`
});
verify.codeFixAll({
fixAllDescription: ts.Diagnostics.Fix_all_expressions_possibly_missing_await.message,
fixId: "addMissingAwait",
newFileContent:
`async function fn(a: Promise<string[]>) {
[...await a];
for (const c of await a) { c; }
for await (const c of await a) { c; }
}`
});
| {
"end_byte": 1144,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAwait_iterables.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddVoidToPromiseJS.1.ts_0_421 | /// <reference path='fourslash.ts' />
// @target: esnext
// @lib: es2015
// @strict: true
// @allowJS: true
// @checkJS: true
// @filename: main.js
////const p1 = new Promise(resolve => resolve());
verify.codeFix({
errorCode: 2810,
description: "Add 'void' to Promise resolved without a value",
index: 2,
newFileContent: `const p1 = /** @type {Promise<void>} */(new Promise(resolve => resolve()));`
});
| {
"end_byte": 421,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddVoidToPromiseJS.1.ts"
} |
TypeScript/tests/cases/fourslash/updateToClassStatics.ts_0_847 | /// <reference path="fourslash.ts" />
//// module TypeScript {
//// export class PullSymbol {}
//// export class Diagnostic {}
//// export class SymbolAndDiagnostics<TSymbol extends PullSymbol> {
//// constructor(public symbol: TSymbol,
//// public diagnostics: Diagnostic) {
//// }
//// /**/
//// public static create<TSymbol extends PullSymbol>(symbol: TSymbol, diagnostics: Diagnostic): SymbolAndDiagnostics<TSymbol> {
//// return new SymbolAndDiagnostics<TSymbol>(symbol, diagnostics);
//// }
//// }
//// }
//// module TypeScript {
//// var x : TypeScript.SymbolAndDiagnostics;
//// }
goTo.marker();
// We've had some invalidation errors where adding a member to a generic type with statics could cause a crash to occur
edit.insert("someNewProperty = 0;");
| {
"end_byte": 847,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/updateToClassStatics.ts"
} |
TypeScript/tests/cases/fourslash/completionEntryForClassMembers3.ts_0_709 | ///<reference path="fourslash.ts" />
////interface IFoo {
//// bar(): void;
////}
////class Foo1 implements IFoo {
//// zap() { }
//// /*1*/
////}
////class Foo2 implements IFoo {
//// zap() { }
//// b/*2*/() { }
////}
////class Foo3 implements IFoo {
//// zap() { }
//// b/*3*/: any;
////}
function verifyHasBar() {
verify.completions({
unsorted: [
{ name: "bar", text: "(method) IFoo.bar(): void", kind: "method" },
...completion.classElementKeywords,
],
isNewIdentifierLocation: true,
});
}
goTo.marker("1");
verifyHasBar();
edit.insert("b");
verifyHasBar();
goTo.marker("2");
verifyHasBar();
goTo.marker("3");
verifyHasBar(); | {
"end_byte": 709,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionEntryForClassMembers3.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpConstructorOverload.ts_0_583 | /// <reference path='fourslash.ts'/>
////class clsOverload { constructor(); constructor(test: string); constructor(test?: string) { } }
////var x = new clsOverload(/*1*/);
////var y = new clsOverload(/*2*/'');
verify.signatureHelp(
{
marker: "1",
overloadsCount: 2,
text: "clsOverload(): clsOverload",
parameterCount: 0,
},
{
marker: "2",
overloadsCount: 2,
text: "clsOverload(test: string): clsOverload",
parameterCount: 1,
parameterName: "test",
parameterSpan: "test: string",
},
);
| {
"end_byte": 583,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpConstructorOverload.ts"
} |
TypeScript/tests/cases/fourslash/goToTypeDefinition_typeReference.ts_0_214 | /// <reference path='fourslash.ts' />
//// type User = { name: string };
//// type Box<T> = { value: T };
//// declare const boxedUser: Box<User>
//// /*reference*/boxedUser
verify.baselineGoToType("reference");
| {
"end_byte": 214,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToTypeDefinition_typeReference.ts"
} |
TypeScript/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile4.ts_0_328 | /// <reference path='fourslash.ts' />
// @allowjs: true
// @noEmit: true
// @checkJs: true
// @Filename: a.js
////var x = "";
////
////[|"test \
////"; x = 1;|]
// Disable checking for next line
verify.rangeAfterCodeFix(`"test \\
";
// @ts-ignore
x = 1;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
| {
"end_byte": 328,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile4.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarItemsClass5.ts_0_678 | /// <reference path="fourslash.ts" />
////class Foo {}
////let Foo = 1;
verify.navigationTree({
text: "<global>",
kind: "script",
childItems: [
{
text: "Foo",
kind: "let"
},
{
text: "Foo",
kind: "class"
}
]
});
verify.navigationBar([
{
text: "<global>",
kind: "script",
childItems: [
{
text: "Foo",
kind: "let"
},
{
text: "Foo",
kind: "class"
}
]
},
{
text: "Foo",
kind: "class",
indent: 1
}
])
| {
"end_byte": 678,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsClass5.ts"
} |
TypeScript/tests/cases/fourslash/completionsAsserts.ts_0_176 | /// <reference path="fourslash.ts" />
////declare function assert(argument1: any): asserts a/**/
verify.completions({
marker: "",
includes: { name: "argument1" }
});
| {
"end_byte": 176,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsAsserts.ts"
} |
TypeScript/tests/cases/fourslash/quickInfo_notInsideComment.ts_0_105 | /// <reference path='fourslash.ts' />
////a/* /**/ */.b
goTo.marker("");
verify.not.quickInfoExists();
| {
"end_byte": 105,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfo_notInsideComment.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpAtEOF2.ts_0_132 | /// <reference path='fourslash.ts' />
////console.log()
/////**/
verify.noSignatureHelpForTriggerReason({ kind: "invoked" }, "");
| {
"end_byte": 132,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpAtEOF2.ts"
} |
TypeScript/tests/cases/fourslash/noErrorsAfterCompletionsRequestWithinGenericFunction2.ts_0_311 | ///<reference path="fourslash.ts"/>
// @strict: true
////
//// // repro from #50818#issuecomment-1278324638
////
//// declare function func<T extends { foo: 1 }>(arg: T): void;
//// func({ foo: 1, bar/*1*/: 1 });
goTo.marker("1");
edit.insert("2");
verify.completions({ exact: undefined });
verify.noErrors();
| {
"end_byte": 311,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/noErrorsAfterCompletionsRequestWithinGenericFunction2.ts"
} |
TypeScript/tests/cases/fourslash/renameRestBindingElement.ts_0_332 | /// <reference path='fourslash.ts' />
////interface I {
//// a: number;
//// b: number;
//// c: number;
////}
////function foo([|{ a, ...[|{| "contextRangeIndex": 0 |}rest|] }: I|]) {
//// [|rest|];
////}
const [r0Def, r0, r1] = test.ranges();
verify.baselineRename(r0, { providePrefixAndSuffixTextForRename: true });
| {
"end_byte": 332,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameRestBindingElement.ts"
} |
TypeScript/tests/cases/fourslash/formatNoSpaceBeforeCloseBrace2.ts_0_125 | /// <reference path="fourslash.ts"/>
////new Foo(1, );
format.document();
verify.currentFileContentIs(`new Foo(1,);`);
| {
"end_byte": 125,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatNoSpaceBeforeCloseBrace2.ts"
} |
TypeScript/tests/cases/fourslash/renameObjectSpread.ts_0_525 | /// <reference path='fourslash.ts'/>
////interface A1 { [|[|{| "contextRangeIndex": 0 |}a|]: number|] };
////interface A2 { [|[|{| "contextRangeIndex": 2 |}a|]?: number|] };
////let a1: A1;
////let a2: A2;
////let a12 = { ...a1, ...a2 };
////a12.[|a|];
const [r0Def, r0, r1Def, r1, r2] = test.ranges();
verify.baselineRename([
// A1 unions with A2, so rename A1.a and a12.a
r0,
// A1 unions with A2, so rename A2.a and a12.a
r1,
// a12.a unions A1.a and A2.a, so rename A1.a, A2.a and a12.a
r2,
]);
| {
"end_byte": 525,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameObjectSpread.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType15.ts_0_366 | /// <reference path='fourslash.ts' />
//// type A<T = boolean> = /*a*/string/*b*/ | number | T;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent: `type /*RENAME*/NewType = string;
type A<T = boolean> = NewType | number | T;`,
});
| {
"end_byte": 366,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType15.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_multipleStatements2.ts_0_1465 | /// <reference path='fourslash.ts' />
//@Filename: /bar.ts
////import { } from './somefile';
////const a = 12;
//@Filename: /a.ts
//// [|export type ProblemKind =
//// | "NoResolution"
//// | "UntypedResolution"
//// | "FalseESM"
//// | "FalseCJS"
//// | "CJSResolvesToESM"
//// | "Wildcard"
//// | "UnexpectedESMSyntax"
//// | "UnexpectedCJSSyntax"
//// | "FallbackCondition"
//// | "CJSOnlyExportsDefault"
//// | "FalseExportDefault";
//// export interface Problem {
//// kind: ProblemKind;
//// entrypoint: string;
//// }
//// export interface ProblemSummary {
//// kind: ProblemKind;
//// title: string;
//// messages: {
//// messageText: string;
//// messageHtml: string;
//// }[];
//// }|]
verify.moveToFile({
newFileContents: {
"/a.ts":
``,
"/bar.ts":
`import { } from './somefile';
const a = 12;
export type ProblemKind = "NoResolution" |
"UntypedResolution" |
"FalseESM" |
"FalseCJS" |
"CJSResolvesToESM" |
"Wildcard" |
"UnexpectedESMSyntax" |
"UnexpectedCJSSyntax" |
"FallbackCondition" |
"CJSOnlyExportsDefault" |
"FalseExportDefault";
export interface Problem {
kind: ProblemKind;
entrypoint: string;
}
export interface ProblemSummary {
kind: ProblemKind;
title: string;
messages: {
messageText: string;
messageHtml: string;
}[];
}
`,
},
interactiveRefactorArguments: { targetFile: "/bar.ts" }
}); | {
"end_byte": 1465,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_multipleStatements2.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoCommentsClassMembers.ts_0_4390 | /// <reference path='fourslash.ts' />
/////** This is comment for c1*/
////class c/*1*/1 {
//// /** p1 is property of c1*/
//// public p/*2*/1: number;
//// /** sum with property*/
//// public p/*3*/2(/** number to add*/b: number) {
//// return this.p1 + b;
//// }
//// /** getter property 1*/
//// public get p/*6*/3() {
//// return this.p/*8q*/2(this.p1);
//// }
//// /** setter property 1*/
//// public set p/*10*/3(/** this is value*/value: number) {
//// this.p1 = this.p/*13q*/2(value);
//// }
//// /** pp1 is property of c1*/
//// private p/*14*/p1: number;
//// /** sum with property*/
//// private p/*15*/p2(/** number to add*/b: number) {
//// return this.p1 + b;
//// }
//// /** getter property 2*/
//// private get p/*18*/p3() {
//// return this.p/*20q*/p2(this.pp1);
//// }
//// /** setter property 2*/
//// private set p/*22*/p3( /** this is value*/value: number) {
//// this.pp1 = this.p/*25q*/p2(value);
//// }
//// /** Constructor method*/
//// constru/*26*/ctor() {
//// }
//// /** s1 is static property of c1*/
//// static s/*27*/1: number;
//// /** static sum with property*/
//// static s/*28*/2(/** number to add*/b: number) {
//// return c1.s1 + b;
//// }
//// /** static getter property*/
//// static get s/*32*/3() {
//// return c1.s/*35q*/2(c1.s1);
//// }
//// /** setter property 3*/
//// static set s/*37*/3( /** this is value*/value: number) {
//// c1.s1 = c1.s/*42q*/2(value);
//// }
//// public nc_/*43*/p1: number;
//// public nc_/*44*/p2(b: number) {
//// return this.nc_p1 + b;
//// }
//// public get nc_/*46*/p3() {
//// return this.nc/*47q*/_p2(this.nc_p1);
//// }
//// public set nc/*48*/_p3(value: number) {
//// this.nc_p1 = this.nc/*49q*/_p2(value);
//// }
//// private nc/*50*/_pp1: number;
//// private nc_/*51*/pp2(b: number) {
//// return this.nc_pp1 + b;
//// }
//// private get nc/*53*/_pp3() {
//// return this.nc_/*54q*/pp2(this.nc_pp1);
//// }
//// private set nc_p/*55*/p3(value: number) {
//// this.nc_pp1 = this./*56q*/nc_pp2(value);
//// }
//// static nc/*57*/_s1: number;
//// static nc/*58*/_s2(b: number) {
//// return c1.nc_s1 + b;
//// }
//// static get nc/*60*/_s3() {
//// return c1.nc/*61q*/_s2(c1.nc_s1);
//// }
//// static set nc/*62*/_s3(value: number) {
//// c1.nc_s1 = c1.nc_/*63q*/s2(value);
//// }
////}
////var i/*64*/1 = new c/*65q*/1();
////var i1/*66*/_p = i1.p1;
////var i1/*68*/_f = i1.p/*69*/2;
////var i1/*70*/_r = i1.p/*71q*/2(20);
////var i1_p/*72*/rop = i1./*73*/p3;
////i1./*74*/p3 = i1_/*75*/prop;
////var i1_/*76*/nc_p = i1.n/*77*/c_p1;
////var i1/*78*/_ncf = i1.nc_/*79*/p2;
////var i1_/*80*/ncr = i1.nc/*81q*/_p2(20);
////var i1_n/*82*/cprop = i1.n/*83*/c_p3;
////i1.nc/*84*/_p3 = i1_/*85*/ncprop;
////var i1_/*86*/s_p = /*87*/c1./*88*/s1;
////var i1_s/*89*/_f = c1./*90*/s2;
////var i1_/*91*/s_r = c1.s/*92q*/2(20);
////var i1_s/*93*/_prop = c1.s/*94*/3;
////c1.s/*95*/3 = i1_s/*96*/_prop;
////var i1_s/*97*/_nc_p = c1.n/*98*/c_s1;
////var i1_s_/*99*/ncf = c1.nc/*100*/_s2;
////var i1_s_/*101*/ncr = c1.n/*102q*/c_s2(20);
////var i1_s_n/*103*/cprop = c1.nc/*104*/_s3;
////c1.nc/*105*/_s3 = i1_s_nc/*106*/prop;
////var i1/*107*/_c = c/*108*/1;
////
////class cProperties {
//// private val: number;
//// /** getter only property*/
//// public get p1() {
//// return this.val;
//// }
//// public get nc_p1() {
//// return this.val;
//// }
//// /**setter only property*/
//// public set p2(value: number) {
//// this.val = value;
//// }
//// public set nc_p2(value: number) {
//// this.val = value;
//// }
////}
////var cProperties_i = new cProperties();
////cProperties_i./*110*/p2 = cProperties_i.p/*111*/1;
////cProperties_i.nc/*112*/_p2 = cProperties_i.nc/*113*/_p1;
////class cWithConstructorProperty {
//// /**
//// * this is class cWithConstructorProperty's constructor
//// * @param a this is first parameter a
//// */
//// /*119*/constructor(/**more info about a*/public a: number) {
//// var b/*118*/bbb = 10;
//// th/*116*/is./*114*/a = /*115*/a + 2 + bb/*117*/bb;
//// }
////}
verify.baselineQuickInfo()
| {
"end_byte": 4390,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoCommentsClassMembers.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingTypeof1.ts_0_356 | /// <reference path='fourslash.ts' />
//// declare module "foo" {
//// const a = "foo"
//// export = a
//// }
//// const x: import("foo") = import("foo");
verify.codeFix({
description: "Add missing 'typeof'",
newFileContent: `declare module "foo" {
const a = "foo"
export = a
}
const x: typeof import("foo") = import("foo");`
});
| {
"end_byte": 356,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingTypeof1.ts"
} |
TypeScript/tests/cases/fourslash/renameAlias.ts_0_231 | /// <reference path='fourslash.ts'/>
////module SomeModule { export class SomeClass { } }
////[|import [|{| "contextRangeIndex": 0 |}M|] = SomeModule;|]
////import C = [|M|].SomeClass;
verify.baselineRenameAtRangesWithText("M");
| {
"end_byte": 231,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameAlias.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts_0_1173 | /// <reference path='fourslash.ts'/>
// Use `/src` to test that directory names are not included in conversion from module path to identifier.
// @noLib: true
// @Filename: /src/foo-bar.ts
////export = 0;
// @Filename: /src/b.ts
////exp/*0*/
////fooB/*1*/
goTo.marker("0");
const preferences: FourSlashInterface.UserPreferences = { includeCompletionsForModuleExports: true };
const exportEntry: FourSlashInterface.ExpectedCompletionEntryObject = {
name: "fooBar",
source: "/src/foo-bar",
sourceDisplay: "./foo-bar",
text: "(property) export=: 0",
kind: "property",
kindModifiers: "export",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
};
verify.completions(
{
marker: "0",
exact: completion.globalsPlus([], { noLib: true }),
preferences
},
{
marker: "1",
exact: completion.globalsPlus([exportEntry], { noLib: true }),
preferences
}
);
verify.applyCodeActionFromCompletion("0", {
name: "fooBar",
source: "/src/foo-bar",
description: `Add import from "./foo-bar"`,
newFileContent: `import fooBar = require("./foo-bar")
exp
fooB`,
});
| {
"end_byte": 1173,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_exportEquals_anonymous.ts"
} |
TypeScript/tests/cases/fourslash/contextualTypingReturnExpressions.ts_0_228 | /// <reference path='fourslash.ts'/>
////interface A { }
////var f44: (x: A) => (y: A) => A = /*1*/x => /*2*/y => /*3*/x;
verify.quickInfos({
1: "(parameter) x: A",
2: "(parameter) y: A",
3: "(parameter) x: A"
});
| {
"end_byte": 228,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/contextualTypingReturnExpressions.ts"
} |
TypeScript/tests/cases/fourslash/extract-method-not-for-empty.ts_0_120 | /// <reference path='fourslash.ts' />
////"/**/foo";
goTo.marker("");
verify.not.refactorAvailable('Extract Symbol');
| {
"end_byte": 120,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method-not-for-empty.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType7.ts_0_478 | /// <reference path='fourslash.ts' />
//// function foo(a: /*a*/number/*b*/, b?: number, ...c: number[]): boolean {
//// return false as boolean;
//// }
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent: `type /*RENAME*/NewType = number;
function foo(a: NewType, b?: number, ...c: number[]): boolean {
return false as boolean;
}`,
});
| {
"end_byte": 478,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType7.ts"
} |
TypeScript/tests/cases/fourslash/formattingOfModuleExport.ts_0_176 | /// <reference path="fourslash.ts"/>
////module MemoryAnalyzer {
//// export module Foo.Charting { }
//// /**/
goTo.marker();
edit.insert("}");
verify.indentationIs(0);
| {
"end_byte": 176,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOfModuleExport.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_namelessClass.ts_0_673 | /// <reference path='fourslash.ts' />
// @Filename: f.ts
////export default class {
//// /*a*/constructor/*b*/(a: string, b: string) { }
////}
// @Filename: a.ts
////import C from "./f";
////const c = new C("a", "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 class {
constructor({ a, b }: { a: string; b: string; }) { }
}`
});
goTo.file("a.ts");
verify.currentFileContentIs(`import C from "./f";
const c = new C({ a: "a", b: "b" });`) | {
"end_byte": 673,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_namelessClass.ts"
} |
TypeScript/tests/cases/fourslash/formattingJsxTexts3.ts_0_335 | /// <reference path='fourslash.ts' />
// Github issue #41925
//@Filename: file.tsx
//// function foo() {
//// const bar = "Oh no";
////
//// return (
//// <div>"{bar}"</div>
//// )
//// }
format.document();
verify.currentFileContentIs(
`function foo() {
const bar = "Oh no";
return (
<div>"{bar}"</div>
)
}`); | {
"end_byte": 335,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingJsxTexts3.ts"
} |
TypeScript/tests/cases/fourslash/prototypeProperty.ts_0_250 | /// <reference path='fourslash.ts'/>
////class A {}
////A./*1*/prototype;
////A./*2*/
verify.quickInfoAt("1", "(property) A.prototype: A");
verify.completions({ marker: "2", includes: [{ name: "prototype", text: "(property) A.prototype: A" }] });
| {
"end_byte": 250,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/prototypeProperty.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoJsDocTagsFunctionOverload04.ts_0_1828 | /// <reference path='fourslash.ts'/>
// @Filename: quickInfoJsDocTagsFunctionOverload04.ts
////declare function /*1*/foo(): void;
////
/////**
//// * Doc foo overloaded
//// */
////declare function /*2*/foo(x: number): void
goTo.marker("1");
verify.verifyQuickInfoDisplayParts(
"function",
"declare",
{ start: 17, length: 3 },
[
{text:"function",kind:"keyword"},
{text:" ",kind:"space"},
{text:"foo",kind:"functionName"},
{text:"(",kind:"punctuation"},
{text:")",kind:"punctuation"},
{text:":",kind:"punctuation"},
{text:" ",kind:"space"},
{text:"void",kind:"keyword"},
{text:" ",kind:"space"},
{text:"(",kind:"punctuation"},
{text:"+",kind:"operator"},
{text:"1",kind:"numericLiteral"},
{text:" ",kind:"space"},
{text:"overload",kind:"text"},
{text:")",kind:"punctuation"}
],
[]);
goTo.marker("2");
verify.verifyQuickInfoDisplayParts(
"function",
"declare",
{ start: 78, length: 3 },
[
{text:"function",kind:"keyword"},
{text:" ",kind:"space"},
{text:"foo",kind:"functionName"},
{text:"(",kind:"punctuation"},
{text:"x",kind:"parameterName"},
{text:":",kind:"punctuation"},
{text:" ",kind:"space"},
{text:"number",kind:"keyword"},
{text:")",kind:"punctuation"},
{text:":",kind:"punctuation"},
{text:" ",kind:"space"},
{text:"void",kind:"keyword"},
{text:" ",kind:"space"},
{text:"(",kind:"punctuation"},
{text:"+",kind:"operator"},
{text:"1",kind:"numericLiteral"},
{text:" ",kind:"space"},
{text:"overload",kind:"text"},
{text:")",kind:"punctuation"}
],
[{ text: "Doc foo overloaded", kind: "text" }]);
| {
"end_byte": 1828,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTagsFunctionOverload04.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageCallbackParameter7.ts_0_224 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noImplicitAny: false
// @filename: /foo.js
/////** @type {(x: number) => number} */
////const foo = x => x + 1;
verify.not.codeFixAvailable();
| {
"end_byte": 224,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageCallbackParameter7.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess36.ts_0_643 | /// <reference path='fourslash.ts' />
////class Foo {
//// /**
//// * Property description
//// */
//// /*a*/_prop!: string; // comment/*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 Foo {
/**
* Property description
*/
private _prop!: string; // comment
public get /*RENAME*/prop(): string {
return this._prop;
}
public set prop(value: string) {
this._prop = value;
}
}`
});
| {
"end_byte": 643,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess36.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType44.ts_0_330 | /// <reference path='fourslash.ts' />
//// type A<T> = /*a*/B.C.D<T>/*b*/;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent: `type /*RENAME*/NewType<T> = B.C.D<T>;
type A<T> = NewType<T>;`,
});
| {
"end_byte": 330,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType44.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportAmbient0.ts_0_270 | /// <reference path="fourslash.ts" />
//// [|f1/*0*/();|]
// @Filename: ambientModule.ts
//// declare module "ambient-module" {
//// export function f1();
//// export var v1;
//// }
verify.importFixAtPosition([
`import { f1 } from "ambient-module";
f1();`
]);
| {
"end_byte": 270,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportAmbient0.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType54.ts_0_378 | /// <reference path='fourslash.ts' />
//// interface I { f: /*a*/(this: O, b: number) => this/*b*/ };
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent: `type /*RENAME*/NewType = (this: O, b: number) => this;
interface I { f: NewType };`,
});
| {
"end_byte": 378,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType54.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess26.ts_0_596 | /// <reference path='fourslash.ts' />
//// class A {
//// public _a: string = "";
//// /*a*/public "a": number = 1;/*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 {
public _a: string = "";
private /*RENAME*/"_a_1": number = 1;
public get "a"(): number {
return this["_a_1"];
}
public set "a"(value: number) {
this["_a_1"] = value;
}
}`,
});
| {
"end_byte": 596,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess26.ts"
} |
TypeScript/tests/cases/fourslash/extract-method4.ts_0_352 | /// <reference path='fourslash.ts' />
//// let a = 1, b = 2, c = 3, d = 4;
//// namespace NS {
//// class Q {
//// foo() {
//// a = /*1*/b = c/*2*/ = d;
//// }
//// }
//// }
// Should rewrite to a = newFunc(); function() { return b = c = d; }
goTo.select('1', '2');
verify.not.refactorAvailable('Extract Symbol');
| {
"end_byte": 352,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method4.ts"
} |
TypeScript/tests/cases/fourslash/typeArgCompletion.ts_0_224 | /// <reference path="fourslash.ts"/>
////class Base {
////}
////class Derived extends Base {
////}
////interface I1<T extends Base>{
////}
////var x1: I1<Deri/**/>;
verify.completions({ marker: "", includes: "Derived" });
| {
"end_byte": 224,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/typeArgCompletion.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue13.ts_0_403 | /// <reference path='fourslash.ts' />
//// interface A {
//// bar: string
//// }
////
//// const a: () => A = () => {
//// { bar: '1' }
//// }
verify.codeFixAvailable([
{ description: ts.Diagnostics.Add_a_return_statement.message },
{ description: ts.Diagnostics.Remove_braces_from_arrow_function_body.message },
{ description: ts.Diagnostics.Remove_unused_label.message }
]);
| {
"end_byte": 403,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue13.ts"
} |
TypeScript/tests/cases/fourslash/recursiveClassReference.ts_0_231 | /// <reference path="fourslash.ts" />
//// declare module Thing { }
////
//// module Thing {
//// var /**/x: Mode;
//// }
////
//// module Thing {
//// export class Mode { }
//// }
goTo.marker();
verify.quickInfoExists();
| {
"end_byte": 231,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/recursiveClassReference.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixWithPrologue.ts_0_1379 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////"use strict";
////export class A { }
// @Filename: /b.ts
////"use strict";
////export class B extends A { }
// @Filename: /c.ts
/////*---------------------------------------------------------------------------------------------
//// * Copyright (c) Microsoft Corporation. All rights reserved.
//// * Licensed under the MIT License. See License.txt in the project root for license information.
//// *--------------------------------------------------------------------------------------------*/
////"use strict";
////export class B extends A { }
goTo.file("/b.ts");
verify.codeFix({
description: ignoreInterpolations(ts.Diagnostics.Add_import_from_0),
newFileContent:
`"use strict";
import { A } from "./a";
export class B extends A { }`,
});
goTo.file("/c.ts");
verify.codeFix({
description: ignoreInterpolations(ts.Diagnostics.Add_import_from_0),
newFileContent:
`/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
"use strict";
import { A } from "./a";
export class B extends A { }`,
}); | {
"end_byte": 1379,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixWithPrologue.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportFile3.ts_0_247 | /// <reference path="fourslash.ts" />
//// [|let t: XXX/*0*/.I;|]
// @Filename: ./module.ts
//// export module XXX {
//// export interface I {
//// }
//// }
verify.importFixAtPosition([
`import { XXX } from "./module";
let t: XXX.I;`
]); | {
"end_byte": 247,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportFile3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingAttributes7.ts_0_390 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: foo.tsx
////interface P {
//// a: number;
//// b?: string;
////}
////
////const A = ({ a, b }: P) =>
//// <div>{a}{b}</div>;
////
////const Bar = () =>
//// [|<A></A>|]
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_attributes.message,
newRangeContent: `<A a={0}></A>`
});
| {
"end_byte": 390,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAttributes7.ts"
} |
TypeScript/tests/cases/fourslash/formattingHexLiteral.ts_0_99 | /// <reference path='fourslash.ts' />
////var x = 0x1,y;
format.document(); // should not crash
| {
"end_byte": 99,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingHexLiteral.ts"
} |
TypeScript/tests/cases/fourslash/referencesForIndexProperty3.ts_0_313 | /// <reference path='fourslash.ts'/>
// References to a property of the apparent type using string indexer
////interface Object {
//// /*1*/toMyString();
////}
////
////var y: Object;
////y./*2*/toMyString();
////
////var x = {};
////x["/*3*/toMyString"]();
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 313,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForIndexProperty3.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionDifferentFile.ts_0_917 | /// <reference path='fourslash.ts' />
// @Filename: goToDefinitionDifferentFile_Definition.ts
////var /*remoteVariableDefinition*/remoteVariable;
////function /*remoteFunctionDefinition*/remoteFunction() { }
////class /*remoteClassDefinition*/remoteClass { }
////interface /*remoteInterfaceDefinition*/remoteInterface{ }
////module /*remoteModuleDefinition*/remoteModule{ export var foo = 1;}
// @Filename: goToDefinitionDifferentFile_Consumption.ts
/////*remoteVariableReference*/remoteVariable = 1;
/////*remoteFunctionReference*/remoteFunction();
////var foo = new /*remoteClassReference*/remoteClass();
////class fooCls implements /*remoteInterfaceReference*/remoteInterface { }
////var fooVar = /*remoteModuleReference*/remoteModule.foo;
verify.baselineGetDefinitionAtPosition("remoteVariableReference", "remoteFunctionReference", "remoteClassReference", "remoteInterfaceReference", "remoteModuleReference");
| {
"end_byte": 917,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionDifferentFile.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_multiple.ts_0_452 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////export {}; // make this a module
////const a = 0, b = 0;
////[|const x = 0;
////a;
////const y = 1;
////b;|]
////x; y;
verify.moveToNewFile({
newFileContents: {
"/a.ts":
`import { x, y } from "./x";
export {}; // make this a module
export const a = 0, b = 0;
x; y;`,
"/x.ts":
`import { a, b } from "./a";
export const x = 0;
a;
export const y = 1;
b;
`,
},
});
| {
"end_byte": 452,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_multiple.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsTypeParameterInClass.ts_0_789 | /// <reference path='fourslash.ts'/>
////class /*1*/c</*2*/T> {
//// /*3*/constructor(/*4*/a: /*5*/T) {
//// }
//// /*6*/method</*7*/U>(/*8*/a: /*9*/U, /*10*/b: /*11*/T) {
//// return /*12*/a;
//// }
////}
////var /*13*/cInstance = new /*14*/c("Hello");
////var /*15*/cVal = /*16*/c;
/////*17*/cInstance./*18*/method("hello", "cello");
////class /*19*/c2</*20*/T extends /*21*/c<string>> {
//// /*22*/constructor(/*23*/a: /*24*/T) {
//// }
//// /*25*/method</*26*/U extends /*27*/c<string>>(/*28*/a: /*29*/U, /*30*/b: /*31*/T) {
//// return /*32*/a;
//// }
////}
////var /*33*/cInstance1 = new /*34*/c2(/*35*/cInstance);
////var /*36*/cVal2 = /*37*/c2;
/////*38*/cInstance1./*39*/method(/*40*/cInstance, /*41*/cInstance);
verify.baselineQuickInfo(); | {
"end_byte": 789,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsTypeParameterInClass.ts"
} |
TypeScript/tests/cases/fourslash/formatObjectBindingPattern_restElementWithPropertyName.ts_0_143 | /// <reference path='fourslash.ts' />
////const { ...a: b } = {};
format.document();
verify.currentFileContentIs("const { ...a: b } = {};");
| {
"end_byte": 143,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatObjectBindingPattern_restElementWithPropertyName.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.