_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/organizeImportsType11.ts_0_1023 | /// <reference path="fourslash.ts" />
////import {
//// type Type1,
//// type Type2,
//// func4,
//// type Type3,
//// type Type4,
//// type Type5,
//// type Type7,
//// type Type8,
//// type Type9,
//// func1,
//// func2,
//// type Type6,
//// func3,
//// func5,
//// func6,
//// func7,
//// func8,
//// func9,
////} from "foo";
////interface Use extends Type1, Type2, Type3, Type4, Type5, Type6, Type7, Type8, Type9 {}
////console.log(func1, func2, func3, func4, func5, func6, func7, func8, func9);
verify.organizeImports(
`import {
type Type1,
type Type2,
type Type3,
type Type4,
type Type5,
type Type6,
type Type7,
type Type8,
type Type9,
func1,
func2,
func3,
func4,
func5,
func6,
func7,
func8,
func9,
} from "foo";
interface Use extends Type1, Type2, Type3, Type4, Type5, Type6, Type7, Type8, Type9 {}
console.log(func1, func2, func3, func4, func5, func6, func7, func8, func9);`
);
| {
"end_byte": 1023,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsType11.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports12.ts_0_459 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
//// function foo() {
//// return { x: 1, y: 1 };
//// }
//// export const { x, y } = foo();
verify.codeFix({
description: ts.Diagnostics.Extract_binding_expressions_to_variable.message,
index: 0,
newFileContent:
`function foo() {
return { x: 1, y: 1 };
}
const dest = foo();
export const x: number = dest.x;
export const y: number = dest.y;`
});
| {
"end_byte": 459,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports12.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationNamespace_02.ts_0_247 | /// <reference path='fourslash.ts'/>
// Should handle property access expressions on namespaces
//// module Foo {
//// export function [|hello|]() {}
//// }
////
//// Foo.hell/*reference*/o();
verify.baselineGoToImplementation("reference"); | {
"end_byte": 247,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationNamespace_02.ts"
} |
TypeScript/tests/cases/fourslash/unusedVariableInForLoop5FSAddUnderscore.ts_0_259 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////for (const elem in ["a", "b", "c"]) {}
verify.codeFix({
index: 1,
description: "Prefix 'elem' with an underscore",
newFileContent: 'for (const _elem in ["a", "b", "c"]) {}',
});
| {
"end_byte": 259,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedVariableInForLoop5FSAddUnderscore.ts"
} |
TypeScript/tests/cases/fourslash/completionsForSelfTypeParameterInConstraint1.ts_0_377 | /// <reference path='fourslash.ts' />
//// type StateMachine<Config> = {
//// initial?: "states" extends keyof Config ? keyof Config["states"] : never;
//// states?: Record<string, {}>;
//// };
//// declare function createMachine<Config extends StateMachine</*1*/>>(
//// config: Config,
//// ): void;
verify.completions({
marker: ["1"],
includes: ["Config"],
});
| {
"end_byte": 377,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsForSelfTypeParameterInConstraint1.ts"
} |
TypeScript/tests/cases/fourslash/completionsCommentsFunctionDeclaration.ts_0_537 | /// <reference path='fourslash.ts' />
/////** This comment should appear for foo*/
////function foo() {
////}
////foo/*3*/();
/////** This is comment for function signature*/
////function fooWithParameters(/** this is comment about a*/a: string,
//// /** this is comment for b*/
//// b: number) {
//// var d = /*7*/a;
////}
////fooWithParameters/*9*/("a",10);
// ambient declaration
/////**
////* Does something
////* @param a a string
////*/
////declare function fn(a: string);
////fn("hello");
verify.baselineCompletions()
| {
"end_byte": 537,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsCommentsFunctionDeclaration.ts"
} |
TypeScript/tests/cases/fourslash/completionInFunctionLikeBody_includesPrimitiveTypes.ts_0_583 | /// <reference path='fourslash.ts'/>
//// class Foo<T> { }
//// class Bar { }
//// function includesTypes() {
//// new Foo</*1*/
//// }
//// function excludesTypes1() {
//// new Bar</*2*/
//// }
//// function excludesTypes2() {
//// 1</*3*/
//// }
verify.completions(
{
marker: ["1"],
includes: [
{ name: "string", sortText: completion.SortText.GlobalsOrKeywords },
{ name: "String", sortText: completion.SortText.GlobalsOrKeywords },
],
},
{
marker: ["2", "3"],
excludes: ["string"]
}
);
| {
"end_byte": 583,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionInFunctionLikeBody_includesPrimitiveTypes.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarVariables.ts_0_1611 | /// <reference path="fourslash.ts"/>
////var x = 0;
////let y = 1;
////const z = 2;
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "x",
"kind": "var"
},
{
"text": "y",
"kind": "let"
},
{
"text": "z",
"kind": "const"
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "x",
"kind": "var"
},
{
"text": "y",
"kind": "let"
},
{
"text": "z",
"kind": "const"
}
]
}
]);
// @Filename: file2.ts
////var {a} = 0;
////let {a: b} = 0;
////const [c] = 0;
goTo.file("file2.ts");
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "var"
},
{
"text": "b",
"kind": "let"
},
{
"text": "c",
"kind": "const"
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "var"
},
{
"text": "b",
"kind": "let"
},
{
"text": "c",
"kind": "const"
}
]
}
]);
| {
"end_byte": 1611,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarVariables.ts"
} |
TypeScript/tests/cases/fourslash/findAllReferencesJsOverloadedFunctionParameter.ts_0_403 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @Filename: foo.js
/////**
//// * @overload
//// * @param {number} x
//// * @returns {number}
//// *
//// * @overload
//// * @param {string} x
//// * @returns {string}
//// *
//// * @param {unknown} x
//// * @returns {unknown}
//// */
////function foo(x/*1*/) {
//// return x;
////}
verify.baselineFindAllReferences("1");
| {
"end_byte": 403,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesJsOverloadedFunctionParameter.ts"
} |
TypeScript/tests/cases/fourslash/bestCommonTypeObjectLiterals.ts_0_875 | /// <reference path='fourslash.ts'/>
////var a = { name: 'bob', age: 18 };
////var b = { name: 'jim', age: 20 };
////var /*1*/c = [a, b];
////var a1 = { name: 'bob', age: 18 };
////var b1 = { name: 'jim', age: 20, dob: new Date() };
////var /*2*/c1 = [a1, b1];
////var a2 = { name: 'bob', age: 18, address: 'springfield' };
////var b2 = { name: 'jim', age: 20, dob: new Date() };
////var /*3*/c2 = [a2, b2];
////interface I {
//// name: string;
//// age: number;
////}
////var i: I;
////var /*4*/c3 = [i, a];
verify.quickInfos({
1: "var c: {\n name: string;\n age: number;\n}[]",
2: "var c1: {\n name: string;\n age: number;\n}[]",
3:
`var c2: ({
name: string;
age: number;
address: string;
} | {
name: string;
age: number;
dob: Date;
})[]`,
4: "var c3: {\n name: string;\n age: number;\n}[]"
});
| {
"end_byte": 875,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/bestCommonTypeObjectLiterals.ts"
} |
TypeScript/tests/cases/fourslash/completionListAfterObjectLiteral1.ts_0_127 | /// <reference path="fourslash.ts" />
////var v = { x: 4, y: 3 }./**/
verify.completions({ marker: "", exact: ["x", "y"] });
| {
"end_byte": 127,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAfterObjectLiteral1.ts"
} |
TypeScript/tests/cases/fourslash/completionListEnumMembers.ts_0_434 | /// <reference path='fourslash.ts' />
////enum Foo {
//// bar,
//// baz
////}
////
////var v = Foo./*valueReference*/ba;
////var t :Foo./*typeReference*/ba;
////Foo.bar./*enumValueReference*/;
verify.completions(
{ marker: ["valueReference", "typeReference"], exact: ["bar", "baz"] },
{ marker: "enumValueReference", unsorted: ["toString", "toFixed", "toExponential", "toPrecision", "valueOf", "toLocaleString"] },
);
| {
"end_byte": 434,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListEnumMembers.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageBindingElement.ts_0_219 | /// <reference path='fourslash.ts' />
////function f([car, cdr]) {
//// return car + cdr + 1
////}
// When inferFromUsage supports it, it should infer number for both variables
verify.getSuggestionDiagnostics([]);
| {
"end_byte": 219,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageBindingElement.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteral_quotePreference8.ts_0_592 | /// <reference path='fourslash.ts'/>
// @filename: /a.ts
////export const a = null;
// @filename: /b.ts
////import { a } from './a';
////
////const foo = { '"a name\'s all good but it\'s better with more"': null };
////foo[|./**/|]
goTo.file("/b.ts");
verify.completions({
marker: "",
exact: [
{ name: "\"a name's all good but it's better with more\"", insertText: "['\"a name\\'s all good but it\\'s better with more\"']", replacementSpan: test.ranges()[0] },
],
preferences: {
includeInsertTextCompletions: true,
quotePreference: "auto"
}
});
| {
"end_byte": 592,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral_quotePreference8.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinition_filteringMappedType.ts_0_235 | ///<reference path="fourslash.ts"/>
////const obj = { /*def*/a: 1, b: 2 };
////const filtered: { [P in keyof typeof obj as P extends 'b' ? never : P]: 0; } = { a: 0 };
////filtered.[|/*ref*/a|];
verify.baselineGoToDefinition("ref");
| {
"end_byte": 235,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinition_filteringMappedType.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_typeParameter4.ts_0_330 | /// <reference path="fourslash.ts" />
// @noUnusedLocals: true
// @noUnusedParameters: true
////function f<
//// T1,
//// T2,
//// T3,
////>(a: T1, b: T3) {}
verify.codeFix({
index: 0,
description: "Remove unused declaration for: 'T2'",
newFileContent:
`function f<
T1,
T3,
>(a: T1, b: T3) {}`
});
| {
"end_byte": 330,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_typeParameter4.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsFunctionExpression.ts_0_229 | /// <reference path='fourslash.ts'/>
////var /*1*/x = function /*2*/foo() {
//// /*3*/foo();
////};
////var /*4*/y = function () {
////};
////(function /*5*/foo1() {
//// /*6*/foo1();
////})();
verify.baselineQuickInfo(); | {
"end_byte": 229,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsFunctionExpression.ts"
} |
TypeScript/tests/cases/fourslash/codeFixRequireInTs_all.ts_0_442 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////const a = [|require("a")|];
////const b = [|require("b")|];
////const { c } = [|require("c")|];
////const { d } = [|require("d")|];
verify.codeFixAll({
fixId: "requireInTs",
fixAllDescription: ts.Diagnostics.Convert_all_require_to_import.message,
newFileContent:
`import a = require("a");
import b = require("b");
import { c } from "c";
import { d } from "d";`,
});
| {
"end_byte": 442,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRequireInTs_all.ts"
} |
TypeScript/tests/cases/fourslash/getImportsNone.ts_0_198 | ///<reference path="fourslash.ts"/>
// @Filename: /index.ts
//// function foo() {
//// return 1;
//// }
//// function bar() {
//// return 2;
//// }
////
verify.getImports('/index.ts', [])
| {
"end_byte": 198,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getImportsNone.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingEnumMember2.ts_0_205 | /// <reference path='fourslash.ts' />
////enum E {
//// a = 1
////}
////E.b
verify.codeFix({
description: "Add missing enum member 'b'",
newFileContent: `enum E {
a = 1,
b
}
E.b`
});
| {
"end_byte": 205,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingEnumMember2.ts"
} |
TypeScript/tests/cases/fourslash/formattingOnEnterInComments.ts_0_284 | /// <reference path='fourslash.ts' />
////module me {
//// class A {
//// /*
//// */*1*/
//// /*2*/}
////}
goTo.marker("1");
edit.insertLine("");
goTo.marker("2");
// The formating of the close curly should not be affected
verify.currentLineContentIs(' }');
| {
"end_byte": 284,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnEnterInComments.ts"
} |
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc19.ts_0_410 | /// <reference path='fourslash.ts' />
// @strict: true
/////**
//// * @template T
//// * @param {number} a
//// * @param {T} b
//// */
////function f(a, b) {
//// return a || b;
////}
verify.codeFix({
description: "Annotate with type from JSDoc",
index: 2,
newFileContent:
`/**
* @template T
* @param {number} a
* @param {T} b
*/
function f<T>(a: number, b: T) {
return a || b;
}`,
});
| {
"end_byte": 410,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc19.ts"
} |
TypeScript/tests/cases/fourslash/typeOfSymbol_localSymbolOfExport.ts_0_419 | /// <reference path='fourslash.ts'/>
////export function f() {}
////[|1|];
const ranges = test.ranges();
const symbolsInScope = test.symbolsInScope(ranges[0]);
const f = symbolsInScope.find(s => s.name === "f");
if (f === undefined) throw new Error("'f' not in scope");
if (f.exportSymbol === undefined) throw new Error("Expected to get the local symbol");
verify.typeOfSymbolAtLocation(ranges[0], f, "() => void");
| {
"end_byte": 419,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/typeOfSymbol_localSymbolOfExport.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts_0_729 | /// <reference path='fourslash.ts' />
//// function f(templateStrings: TemplateStringsArray, p1_o1: string): number;
//// function f(templateStrings: TemplateStringsArray, p1_o2: number, p2_o2: number, p3_o2: number): string;
//// function f(templateStrings: TemplateStringsArray, p1_o3: string, p2_o3: boolean, p3_o3: number): boolean;
//// function f(...foo[]: any) { return ""; }
////
//// f `${/*1*/ "s/*2*/tring" /*3*/ } ${
verify.signatureHelp({
marker: test.markers(),
overloadsCount: 3,
text: "f(templateStrings: TemplateStringsArray, p1_o3: string, p2_o3: boolean, p3_o3: number): boolean",
argumentCount: 3,
parameterCount: 4,
parameterName: "p1_o3",
parameterSpan: "p1_o3: string",
});
| {
"end_byte": 729,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpellingJs9.ts_0_1366 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: codeFixSpellingJs9.js
//// class C {
//// numble = 1
//// mumble() {
//// return this.[|numbles|]
//// }
//// }
//// class D extends C { }
//// const c = new C()
//// c.[|numbles|] = 3
//// c.[|mumbles|]()
//// const d = new D()
//// d.[|numbles|] = 4
//// d.[|mumbles()|]
//// class Person {
//// getFavoriteColor() {
////
//// }
//// }
////
//// const person = new Person();
//// person.[|getFavoriteColour|]();
//// person.[|getFavoriteColoxr|]();
//// function deco() { }
//// @deco
//// class Art {
//// style = true
//// }
//// const a = new Art()
//// a.[|stylo|]
//// @deco
//// class Double extends Art { }
//// const db = new Double()
//// db.[|stylo|]
verify.codeFixAll({
fixId: "fixSpelling",
fixAllDescription: "Fix all detected spelling errors",
newFileContent:
`class C {
numble = 1
mumble() {
return this.numble
}
}
class D extends C { }
const c = new C()
c.numble = 3
c.mumble()
const d = new D()
d.numbles = 4
d.mumbles()
class Person {
getFavoriteColor() {
}
}
const person = new Person();
person.getFavoriteColor();
person.getFavoriteColor();
function deco() { }
@deco
class Art {
style = true
}
const a = new Art()
a.stylo
@deco
class Double extends Art { }
const db = new Double()
db.stylo`,
});
| {
"end_byte": 1366,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingJs9.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsInteractiveFunctionParameterTypes4.ts_0_410 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @Filename: /a.js
////class Foo {
//// #value = 0;
//// get foo() { return this.#value; }
//// /**
//// * @param {number} value
//// */
//// set foo(value) { this.#value = value; }
////}
verify.baselineInlayHints(undefined, {
includeInlayFunctionParameterTypeHints: true,
interactiveInlayHints: true
});
| {
"end_byte": 410,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveFunctionParameterTypes4.ts"
} |
TypeScript/tests/cases/fourslash/codefixEnableJsxFlag_missingCompilerOptionsInTsconfig.ts_0_389 | /// <reference path='fourslash.ts' />
// @Filename: /dir/a.tsx
////export const Component = () => <></>
// @Filename: /dir/tsconfig.json
////{
////}
goTo.file("/dir/a.tsx");
verify.codeFix({
description: "Enable the '--jsx' flag in your configuration file",
newFileContent: {
"/dir/tsconfig.json":
`{
"compilerOptions": {
"jsx": "react"
}
}`,
},
});
| {
"end_byte": 389,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codefixEnableJsxFlag_missingCompilerOptionsInTsconfig.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnon_Comment.ts_0_502 | /// <reference path='fourslash.ts' />
//// const foo = /*x*/a/*y*/ => {
//// // secret word
//// return a + 1;
//// /*
//// hidden msg
//// */
//// };
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to anonymous function",
actionDescription: "Convert to anonymous function",
newContent: `const foo = function(a) {
// secret word
return a + 1;
/*
hidden msg
*/
};`,
});
| {
"end_byte": 502,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnon_Comment.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_quoteStyle.ts_0_394 | /// <reference path="fourslash.ts" />
// @module: esnext
// @Filename: /a.ts
////export const foo = 0;
// @Filename: /b.ts
////fo/**/
goTo.marker("");
verify.applyCodeActionFromCompletion("", {
name: "foo",
source: "/a",
description: `Add import from "./a"`,
preferences: {
quotePreference: "single",
},
newFileContent: `import { foo } from './a';
fo`,
});
| {
"end_byte": 394,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_quoteStyle.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsClassConstructor.ts_0_1081 | /// <reference path='fourslash.ts'/>
////class c {
//// /*1*/constructor() {
//// }
////}
////var /*2*/cInstance = new /*3*/c();
////var /*4*/cVal = /*5*/c;
////class cWithOverloads {
//// /*6*/constructor(x: string);
//// /*7*/constructor(x: number);
//// /*8*/constructor(x: any) {
//// }
////}
////var /*9*/cWithOverloadsInstance = new /*10*/cWithOverloads("hello");
////var /*11*/cWithOverloadsInstance2 = new /*12*/cWithOverloads(10);
////var /*13*/cWithOverloadsVal = /*14*/cWithOverloads;
////class cWithMultipleOverloads {
//// /*15*/constructor(x: string);
//// /*16*/constructor(x: number);
//// /*17*/constructor(x: boolean);
//// /*18*/constructor(x: any) {
//// }
////}
////var /*19*/cWithMultipleOverloadsInstance = new /*20*/cWithMultipleOverloads("hello");
////var /*21*/cWithMultipleOverloadsInstance2 = new /*22*/cWithMultipleOverloads(10);
////var /*23*/cWithMultipleOverloadsInstance3 = new /*24*/cWithMultipleOverloads(true);
////var /*25*/cWithMultipleOverloadsVal = /*26*/cWithMultipleOverloads;
verify.baselineQuickInfo(); | {
"end_byte": 1081,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsClassConstructor.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixUMDGlobalReact1.ts_0_752 | /// <reference path="fourslash.ts" />
// @jsx: react
// @allowSyntheticDefaultImports: false
// @module: es2015
// @moduleResolution: node
// @Filename: /node_modules/@types/react/index.d.ts
////export = React;
////export as namespace React;
////declare namespace React {
//// export class Component { render(): JSX.Element | null; }
////}
////declare global {
//// namespace JSX {
//// interface Element {}
//// }
////}
// @Filename: /a.tsx
////[|import { Component } from "react";
////export class MyMap extends Component { }
////<MyMap></MyMap>;|]
goTo.file("/a.tsx");
verify.importFixAtPosition([
`import * as React from "react";
import { Component } from "react";
export class MyMap extends Component { }
<MyMap></MyMap>;`]);
| {
"end_byte": 752,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixUMDGlobalReact1.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoJsDocTags3.ts_0_544 | /// <reference path="fourslash.ts" />
// @Filename: quickInfoJsDocTags3.ts
////interface Foo {
//// /**
//// * comment
//// * @author Me <me@domain.tld>
//// * @see x (the parameter)
//// * @param {number} x - x comment
//// * @param {number} y - y comment
//// * @throws {Error} comment
//// */
//// method(x: number, y: number): void;
////}
////
////class Bar implements Foo {
//// /**/method(): void {
//// throw new Error("Method not implemented.");
//// }
////}
verify.baselineQuickInfo();
| {
"end_byte": 544,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoJsDocTags3.ts"
} |
TypeScript/tests/cases/fourslash/thisBindingInLambda.ts_0_207 | /// <reference path="fourslash.ts" />
////class Greeter {
//// constructor() {
//// [].forEach((anything)=>{
//// console.log(th/**/is);
//// });
//// }
////}
verify.quickInfoAt("", "this: this");
| {
"end_byte": 207,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/thisBindingInLambda.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_function1.ts_0_115 | /// <reference path="fourslash.ts" />
////const f1 = () => {
//// /**/
////};
verify.baselineSmartSelection();
| {
"end_byte": 115,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_function1.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationInterface_02.ts_0_668 | /// <reference path='fourslash.ts'/>
// Should go to definitions in object literals in return statements of functions with the type of the interface
//// interface Fo/*interface_definition*/o { hello: () => void }
////
//// let x: number = 9;
////
//// function createFoo(): Foo {
//// if (x === 2) {
//// return [|{
//// hello() {}
//// }|];
//// }
//// return [|{
//// hello() {}
//// }|];
//// }
////
//// let createFoo2 = (): Foo => [|({hello() {}})|];
////
//// function createFooLike() {
//// return {
//// hello() {}
//// };
//// }
verify.baselineGoToImplementation("interface_definition"); | {
"end_byte": 668,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationInterface_02.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnGenericWithConstraints1.ts_0_205 | /// <reference path='fourslash.ts'/>
////interface Fo/*1*/o<T/*2*/T extends Date> {}
verify.quickInfos({
1: "interface Foo<TT extends Date>",
2: "(type parameter) TT in Foo<TT extends Date>"
});
| {
"end_byte": 205,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnGenericWithConstraints1.ts"
} |
TypeScript/tests/cases/fourslash/unusedTypeParametersInFunction3.ts_0_271 | /// <reference path='fourslash.ts' />
// @noUnusedParameters: true
//// [|function f1<X, Y, Z>(a: X) {a;var b:Z;b}|]
verify.codeFix({
description: "Remove unused declaration for: 'Y'",
index: 0,
newRangeContent: "function f1<X, Z>(a: X) {a;var b:Z;b}",
});
| {
"end_byte": 271,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedTypeParametersInFunction3.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_ConditionalWithBinaryCondition2.ts_0_566 | /// <reference path='fourslash.ts' />
// @strict: true
////interface Foo {
//// bar:{
//// baz: string;
//// }
////}
////declare let foo: Foo;
/////*a*/foo && foo.bar ? foo.bar.baz : "whenFalse";/*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:
`interface Foo {
bar:{
baz: string;
}
}
declare let foo: Foo;
foo?.bar?.baz ?? "whenFalse";`
}); | {
"end_byte": 566,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_ConditionalWithBinaryCondition2.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarItemsStaticAndNonStaticNoMerge.ts_0_1130 | ////class C {
//// static x;
//// x;
////}
// Anonymous classes are still included.
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "C",
"kind": "class",
"childItems": [
{
"text": "x",
"kind": "property",
"kindModifiers": "static"
},
{
"text": "x",
"kind": "property"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "C",
"kind": "class"
}
]
},
{
"text": "C",
"kind": "class",
"childItems": [
{
"text": "x",
"kind": "property",
"kindModifiers": "static"
},
{
"text": "x",
"kind": "property"
}
],
"indent": 1
}
]);
| {
"end_byte": 1130,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarItemsStaticAndNonStaticNoMerge.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsGlobalModuleAugmentation.ts_0_243 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////export {};
////declare global {
//// /*1*/function /*2*/f(): void;
////}
// @Filename: /b.ts
/////*3*/f();
verify.noErrors();
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 243,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsGlobalModuleAugmentation.ts"
} |
TypeScript/tests/cases/fourslash/importStatementCompletions4.ts_0_476 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: /a.js
////import Foo /*a*/
////
////function fromBar() {}
// @Filename: /b.jsx
////import Foo /*b*/
////
////function fromBar() {}
verify.completions({
marker: ["a", "b"],
exact: {
name: "from",
sortText: completion.SortText.GlobalsOrKeywords,
},
preferences: {
includeCompletionsForImportStatements: true,
includeInsertTextCompletions: true,
},
});
| {
"end_byte": 476,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importStatementCompletions4.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_jsx3.ts_0_736 | /// <reference path="fourslash.ts" />
// @jsx: react
// @module: esnext
// @esModuleInterop: true
// @moduleResolution: node
// @Filename: /node_modules/react/index.d.ts
////export = React;
////export as namespace React;
////declare namespace React {
//// class Component {}
////}
// @Filename: /node_modules/react-native/index.d.ts
////import * as React from "react";
////export class Text extends React.Component {};
// @Filename: /a.tsx
////import React from "react";
////<Text></[|Text|]>;
goTo.file("/a.tsx");
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Add_import_from_0.message, "react-native"],
newFileContent:
`import React from "react";
import { Text } from "react-native";
<Text></Text>;`
});
| {
"end_byte": 736,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_jsx3.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixExistingImport4.ts_0_276 | /// <reference path="fourslash.ts" />
//// [|import d from "./module";
//// f1/*0*/();|]
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
//// export default var d1 = 6;
verify.importFixAtPosition([
`import d, { f1 } from "./module";
f1();`
]);
| {
"end_byte": 276,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixExistingImport4.ts"
} |
TypeScript/tests/cases/fourslash/documentHighlights_moduleImport_filesToSearchWithInvalidFile.ts_0_426 | /// <reference path="fourslash.ts" />
// @Filename: /node_modules/@types/foo/index.d.ts
////export const x: number;
// @Filename: /a.ts
////import * as foo from "foo";
////foo.[|x|];
// @Filename: /b.ts
////import { [|x|] } from "foo";
// @Filename: /c.ts
////import { x } from "foo";
const [r0, r1] = test.ranges();
verify.baselineDocumentHighlights(test.ranges(), { filesToSearch: ["/a.ts", "/b.ts", "/unknown.ts"] });
| {
"end_byte": 426,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlights_moduleImport_filesToSearchWithInvalidFile.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsTripleSlash11.ts_0_410 | /// <reference path="fourslash.ts"/>
//// /// <reference path="./module.ts" /
const c = classification("original");
verify.syntacticClassificationsAre(
c.comment("/// "),
c.punctuation("<"),
c.jsxSelfClosingTagName("reference"),
c.comment(" "),
c.jsxAttribute("path"),
c.operator("="),
c.jsxAttributeStringLiteralValue("\"./module.ts\""),
c.comment(" "),
c.comment("/"));
| {
"end_byte": 410,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsTripleSlash11.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration13.ts_0_532 | /// <reference path='fourslash.ts' />
// @filename: /test.ts
////export const x = 1;
// @filename: /foo.ts
////import * as test from "./test";
////test.foo(1, "", { x: 1, y: 1 });
goTo.file("/foo.ts");
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "foo"],
newFileContent: {
"/test.ts":
`export const x = 1;
export function foo(arg0: number, arg1: string, arg2: { x: number; y: number; }) {
throw new Error("Function not implemented.");
}
`
}
});
| {
"end_byte": 532,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration13.ts"
} |
TypeScript/tests/cases/fourslash/noSuggestionDiagnosticsOnParseError.ts_0_400 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////export {};
////const a = 1 d;
// Only give suggestions for nodes that do NOT have parse errors
verify.getSuggestionDiagnostics([{
message: "Variable 'd' implicitly has an 'any' type, but a better type may be inferred from usage.",
code: 7043,
range: {
fileName: "/a.ts",
pos: 23,
end: 24,
}
}]);
| {
"end_byte": 400,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/noSuggestionDiagnosticsOnParseError.ts"
} |
TypeScript/tests/cases/fourslash/formatMultilineConditionalExpressions.ts_0_603 | /// <reference path="fourslash.ts" />
// @Filename: index.tsx
//// !!true ? (
//// <div>a</div>
//// ) : (
//// <div>b</div>
//// )
////
//// const y = true
//// ? 0 : (
//// 1
//// );
////
//// const yy = true
//// ? 0
//// : (
//// 1
//// );
////
//// const z = true ? (() => {
//// console.log('hello');
//// }) : (
//// 1
//// );
////
//// const a = true ? {
//// p: true
//// } : {
//// p: false
//// };
////
//// const b = {
//// x: 'x'
//// } ? (
//// 1
//// ) : (
//// 0
//// );
verify.formatDocumentChangesNothing();
| {
"end_byte": 603,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatMultilineConditionalExpressions.ts"
} |
TypeScript/tests/cases/fourslash/memberCompletionInForEach1.ts_0_426 | /// <reference path='fourslash.ts'/>
////var x: string[] = [];
////x.forEach(function (y) { y/*1*/
////x.forEach(y => y/*2*/
goTo.marker('1');
edit.insert('.');
verify.completions({ exact: completion.stringMembers });
edit.insert('});'); // need the following lines to not have parse errors in order for completion list to appear
goTo.marker('2');
edit.insert('.');
verify.completions({ exact: completion.stringMembers });
| {
"end_byte": 426,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberCompletionInForEach1.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoInJsdocInTsFile1.ts_0_1376 | /// <reference path='fourslash.ts' />
//// /** @type {() => { /*1*/data: string[] }} */
//// function test(): { data: string[] } {
//// return {
//// data: [],
//// };
//// }
////
//// /** @returns {{ /*2*/data: string[] }} */
//// function test2(): { data: string[] } {
//// return {
//// data: [],
//// };
//// }
////
//// /** @type {{ /*3*/bar: string; }} */
//// const test3 = { bar: '' };
////
//// type SomeObj = { bar: string; };
//// /** @type {SomeObj/*4*/} */
//// const test4 = { bar: '' }
////
//// /**
//// * @param/*5*/ stuff/*6*/ Stuff to do stuff with
//// */
//// function doStuffWithStuff(stuff: { quantity: number }) {}
////
//// declare const stuff: { quantity: number };
//// /** @see {doStuffWithStuff/*7*/} */
//// if (stuff.quantity) {}
////
//// /** @type {(a/*8*/: string) => void} */
//// function test2(a: string) {}
verify.quickInfoAt("1", "");
verify.quickInfoAt("2", "");
verify.quickInfoAt("3", "");
verify.quickInfoAt("4", `type SomeObj = {
bar: string;
}`);
verify.quickInfoAt(
"5",
`(parameter) stuff: {
quantity: number;
}`,
"Stuff to do stuff with"
);
verify.quickInfoAt(
"6",
`(parameter) stuff: {
quantity: number;
}`,
"Stuff to do stuff with"
);
verify.quickInfoAt(
"7",
`function doStuffWithStuff(stuff: {
quantity: number;
}): void`,
);
verify.quickInfoAt("8", "");
| {
"end_byte": 1376,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoInJsdocInTsFile1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageExistingJSDoc.ts_0_2161 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noImplicitAny: true
// @strictNullChecks: false
// @Filename: important.js
/////** @param x no types here! */
/////**
//// * 1
//// * @param x a duplicate!
//// * @param y yy
//// */
/////**
//// * 2
//// * @param z zz
//// */
////function f(x) {
//// return x * 1
////}
////
////var o = {
//// /** 1
//// * @return First one
//// */
//// // intrusive comment (should not be deleted)
//// /** 2
//// * @see also
//// */
//// /** 3
//// * @return Second one
//// * @extends {C<number>} nothing really
//// * @class
//// * @this {*} doesn't make sense here
//// * @enum wat
//// */
//// /**
//// * @typedef {number} Meter or something
//// * @typedef {Object} Position Comment!
//// * @property {number} x what a horrible place for a type
//// * @property {number} y please don't do this
//// */
//// /**
//// * @template {string} T postfix comment
//// * @callback Action not sure what this will do
//// * @param {T} thing
//// * @returns {string} oh no
//// */
//// get m() { return undefined }
////}
////o.m = 1
verify.codeFixAll({
fixId: "inferFromUsage",
fixAllDescription: "Infer all types from usage",
newFileContent:
`/**
* 1
* 2
* @param {number} x no types here!
* @param x a duplicate!
* @param y yy
* @param z zz
*/
function f(x) {
return x * 1
}
var o = {
// intrusive comment (should not be deleted)
/**
* 1
* 2
* 3
* @returns {number} First one
* @see {also}
* @return Second one
* @extends {C<number>} nothing really
* @class
* @this {*} doesn't make sense here
* @enum {wat}
* @typedef {number} Meter or something
* @typedef {Object} Position Comment!
* @property {number} x what a horrible place for a type
* @property {number} y please don't do this
* @template {string} T postfix comment
* @callback Action not sure what this will do
* @param {T} thing
* @returns {string} oh no
*/
get m() { return undefined }
}
o.m = 1`,
});
| {
"end_byte": 2161,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageExistingJSDoc.ts"
} |
TypeScript/tests/cases/fourslash/linkedEditingJsxTag8.ts_0_220 | /// <reference path='fourslash.ts' />
// @FileName: /mismatchedNames.tsx
////const A = thing;
////const B = thing;
////const jsx = (
//// </*8*/A>
//// </B>
////);
verify.linkedEditing( {
"8": undefined,
}); | {
"end_byte": 220,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/linkedEditingJsxTag8.ts"
} |
TypeScript/tests/cases/fourslash/completionOfAwaitPromise7.ts_0_395 | /// <reference path='fourslash.ts'/>
////async function foo(x: Promise<string>) {
//// console.log
//// [|x./**/|]
////}
const replacementSpan = test.ranges()[0];
verify.completions({
marker: "",
includes: [
"then",
{ name: "trim", insertText: ';(await x).trim', replacementSpan },
],
preferences: {
includeInsertTextCompletions: true,
},
});
| {
"end_byte": 395,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionOfAwaitPromise7.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoInheritDoc2.ts_0_398 | /// <reference path="fourslash.ts" />
// @noEmit: true
// @allowJs: true
// @Filename: quickInfoInheritDoc2.ts
////class Base<T> {
//// /**
//// * Base.prop
//// */
//// prop: T | undefined;
////}
////
////class SubClass<T> extends Base<T> {
//// /**
//// * @inheritdoc
//// * SubClass.prop
//// */
//// /*1*/prop: T | undefined;
////}
verify.baselineQuickInfo(); | {
"end_byte": 398,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoInheritDoc2.ts"
} |
TypeScript/tests/cases/fourslash/organizeImportsPathsUnicode4.ts_0_856 | /// <reference path="fourslash.ts" />
//// import * as Ab from "./Ab";
//// import * as _aB from "./_aB";
//// import * as aB from "./aB";
//// import * as _Ab from "./_Ab";
////
//// console.log(_aB, _Ab, aB, Ab);
verify.organizeImports(
`import * as _Ab from "./_Ab";
import * as _aB from "./_aB";
import * as Ab from "./Ab";
import * as aB from "./aB";
console.log(_aB, _Ab, aB, Ab);`, /*mode*/ undefined, {
organizeImportsIgnoreCase: false,
organizeImportsCollation: "unicode",
organizeImportsCaseFirst: "upper",
});
verify.organizeImports(
`import * as _aB from "./_aB";
import * as _Ab from "./_Ab";
import * as aB from "./aB";
import * as Ab from "./Ab";
console.log(_aB, _Ab, aB, Ab);`, /*mode*/ undefined, {
organizeImportsIgnoreCase: false,
organizeImportsCollation: "unicode",
organizeImportsCaseFirst: "lower",
});
| {
"end_byte": 856,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsPathsUnicode4.ts"
} |
TypeScript/tests/cases/fourslash/codefixCrashExportGlobal.ts_0_545 | /// <reference path='fourslash.ts' />
// @Filename: bar.ts
//// import * as foo from './foo'
//// export as namespace foo
//// export = foo;
////
//// declare global {
//// const foo: typeof foo;
//// }
// @Filename: foo.d.ts
//// interface Root {
//// /**
//// * A .default property for ES6 default import compatibility
//// */
//// default: Root;
//// }
////
//// declare const root: Root;
//// export = root;
goTo.file("bar.ts");
verify.not.codeFixAvailable();
goTo.file("foo.d.ts");
verify.not.codeFixAvailable();
| {
"end_byte": 545,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codefixCrashExportGlobal.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties22.ts_0_369 | /// <reference path="fourslash.ts" />
// @lib: es2020
////const x: Iterable<number> = {}
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newFileContent:
`const x: Iterable<number> = {
[Symbol.iterator]: function(): Iterator<number, any, any> {
throw new Error("Function not implemented.");
}
}`,
});
| {
"end_byte": 369,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties22.ts"
} |
TypeScript/tests/cases/fourslash/addInterfaceToNotSatisfyConstraint.ts_0_249 | /// <reference path="fourslash.ts" />
//// interface A {
//// a: number;
//// }
//// /**/
//// interface C<T extends A> {
//// x: T;
//// }
////
//// var v2: C<B>; // should not work
goTo.marker();
edit.insert("interface B { b: string; }");
| {
"end_byte": 249,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/addInterfaceToNotSatisfyConstraint.ts"
} |
TypeScript/tests/cases/fourslash/refactorToReturnTypeWithImportAssertions.ts_0_765 | /// <reference path="fourslash.ts" />
// @module: NodeNext
// @traceResolution: true
// @filename: node_modules/inner/index.d.mts
//// export const esm = true;
// @filename: node_modules/inner/package.json
//// { "name": "inner", "exports": { "./mjs": "./index.mjs" } }
// @filename: foo.ts
//// export /*a*/function/*b*/ fn() {
//// return import("inner/mjs")
//// }
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Infer function return type",
actionName: "Infer function return type",
actionDescription: "Infer function return type",
newContent:
`export function fn(): Promise<typeof import("/tests/cases/fourslash/node_modules/inner/index", { with: { "resolution-mode": "import" } })> {
return import("inner/mjs")
}`
});
| {
"end_byte": 765,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorToReturnTypeWithImportAssertions.ts"
} |
TypeScript/tests/cases/fourslash/autoImportFileExcludePatterns1.ts_0_519 | /// <reference path="fourslash.ts"/>
// @module: commonjs
// @Filename: /project/node_modules/aws-sdk/clients/s3.d.ts
//// export declare class S3 {}
// @Filename: /project/index.ts
//// S3/**/
const autoImportFileExcludePatterns = ["/**/node_modules/aws-sdk"];
verify.completions({
marker: "",
excludes: "S3",
preferences: {
includeCompletionsForModuleExports: true,
autoImportFileExcludePatterns,
}
});
verify.importFixAtPosition([], /*errorCode*/ undefined, { autoImportFileExcludePatterns });
| {
"end_byte": 519,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportFileExcludePatterns1.ts"
} |
TypeScript/tests/cases/fourslash/jsdocDeprecated_suggestion6.ts_0_1018 | // @Filename: a.tsx
//// /** @deprecated */
//// type Props = {}
//// /** @deprecated */
//// const Component = (props: [|Props|]) => props && <div />;
//// <[|Component|] old="old" new="new" />
//// /** @deprecated */
//// type Options = {}
//// /** @deprecated */
//// const deprecatedFunction = (options: [|Options|]) => { options }
//// [|deprecatedFunction|]({});
goTo.file('a.tsx')
const ranges = test.ranges();
verify.getSuggestionDiagnostics([
{
message: "'Props' is deprecated.",
code: 6385,
range: ranges[0],
reportsDeprecated: true,
},
{
message: "'Component' is deprecated.",
code: 6385,
range: ranges[1],
reportsDeprecated: true
},
{
message: "'Options' is deprecated.",
code: 6385,
range: ranges[2],
reportsDeprecated: true,
},
{
message: "'deprecatedFunction' is deprecated.",
code: 6385,
range: ranges[3],
reportsDeprecated: true,
}
]) | {
"end_byte": 1018,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocDeprecated_suggestion6.ts"
} |
TypeScript/tests/cases/fourslash/codeFixConvertToTypeOnlyImport7.ts_0_779 | /// <reference path="fourslash.ts" />
// @module: esnext
// @verbatimModuleSyntax: true
// @Filename: /b.ts
////export interface I {}
////export const foo = {};
// @Filename: /c.ts
//// export interface C {}
// @Filename: /d.ts
//// export interface D {}
//// export function d() {}
// @Filename: /a.ts
//// import { I, type foo } from "./b";
//// import { C } from "./c";
//// import { D, d } from "./d";
//// export declare const x: typeof foo;
//// d();
goTo.file("/a.ts");
verify.codeFixAll({
fixId: "convertToTypeOnlyImport",
fixAllDescription: ts.Diagnostics.Fix_all_with_type_only_imports.message,
newFileContent:
`import type { I, foo } from "./b";
import type { C } from "./c";
import { type D, d } from "./d";
export declare const x: typeof foo;
d();`,
});
| {
"end_byte": 779,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToTypeOnlyImport7.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_all.ts_0_1058 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////export default function ad() {}
////export const a0 = 0;
// @Filename: /b.ts
////export default function bd() {}
////export const b0 = 0;
// @Filename: /c.ts
////export default function cd() {}
////export const c0 = 0;
// @Filename: /d.ts
////export default function dd() {}
////export const d0 = 0;
////export const d1 = 1;
// @Filename: /e.d.ts
////declare function e(): void;
////export = e;
// @Filename: /user.ts
////import * as b from "./b";
////import { } from "./c";
////import dd from "./d";
////
////ad; ad; a0; a0;
////bd; bd; b0; b0;
////cd; cd; c0; c0;
////dd; dd; d0; d0; d1; d1;
////e; e;
goTo.file("/user.ts");
verify.codeFixAll({
fixId: "fixMissingImport",
fixAllDescription: "Add all missing imports",
newFileContent:
`import ad, { a0 } from "./a";
import bd, * as b from "./b";
import cd, { c0 } from "./c";
import dd, { d0, d1 } from "./d";
import e = require("./e");
ad; ad; a0; a0;
bd; bd; b.b0; b.b0;
cd; cd; c0; c0;
dd; dd; d0; d0; d1; d1;
e; e;`,
});
| {
"end_byte": 1058,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_all.ts"
} |
TypeScript/tests/cases/fourslash/codeFixTopLevelAwait_module_noTsConfig.ts_0_178 | /// <reference path="fourslash.ts" />
// @filename: /dir/a.ts
////declare const p: Promise<number>;
////await p;
////export {};
verify.not.codeFixAvailable("fixModuleOption");
| {
"end_byte": 178,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelAwait_module_noTsConfig.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportAllowSyntheticDefaultImports2.ts_0_367 | /// <reference path="fourslash.ts" />
// @AllowSyntheticDefaultImports: false
// @Module: system
// @Filename: a/f1.ts
//// [|export var x = 0;
//// bar/*0*/();|]
// @Filename: a/foo.d.ts
//// declare function bar(): number;
//// export = bar;
//// export as namespace bar;
verify.importFixAtPosition([
`import * as bar from "./foo";
export var x = 0;
bar();`
]); | {
"end_byte": 367,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportAllowSyntheticDefaultImports2.ts"
} |
TypeScript/tests/cases/fourslash/completionsInJsxTag.ts_0_938 | /// <reference path="fourslash.ts" />
// @jsx: preserve
// @Filename: /a.tsx
////declare namespace JSX {
//// interface Element {}
//// interface IntrinsicElements {
//// div: {
//// /** Doc */
//// foo: string
//// /** Label docs */
//// "aria-label": string
//// }
//// }
////}
////class Foo {
//// render() {
//// <div /*1*/ ></div>;
//// <div /*2*/ />
//// }
////}
verify.completions({
marker: ["1", "2"],
exact: [
{
name: "aria-label",
text: "(property) \"aria-label\": string",
documentation: "Label docs",
kind: "property",
kindModifiers: "declare",
},
{
name: "foo",
text: "(property) foo: string",
documentation: "Doc",
kind: "property",
kindModifiers: "declare",
},
],
});
| {
"end_byte": 938,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsInJsxTag.ts"
} |
TypeScript/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf.ts_0_778 | /// <reference path='fourslash.ts' />
////interface MultiRobot {
//// name: string;
//// skills: {
//// [|[|{| "contextRangeIndex": 0 |}primary|]: string;|]
//// secondary: string;
//// };
////}
////let multiRobots: MultiRobot[];
////let [|[|{| "contextRangeIndex": 2 |}primary|]: string|], secondary: string, primaryA: string, secondaryA: string;
////for ([|{ skills: { [|{| "contextRangeIndex": 4 |}primary|]: primaryA, secondary: secondaryA } } of multiRobots|]) {
//// primaryA;
////}
////for ([|{ skills: { [|{| "contextRangeIndex": 6 |}primary|], secondary } } of multiRobots|]) {
//// [|primary|];
////}
verify.noErrors();
const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3, r4] = test.ranges();
verify.baselineRename([r0, r2, r1, r3, r4]);
| {
"end_byte": 778,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf.ts"
} |
TypeScript/tests/cases/fourslash/toggleMultilineComment9.ts_0_397 | // When there's is only whitespace, insert comment. If there is whitespace but theres a comment in bewteen, then uncomment.
//// /*let var1[| = 1;*/
//// |]
////
//// [|
//// /*let var2 = 2;*/|]
////
//// [|
////
//// |]
////
//// [||]
////
//// let var3[||] = 3;
verify.toggleMultilineComment(
`let var1 = 1;
let var2 = 2;
/*
*/
/**/
let var3/**/ = 3;`); | {
"end_byte": 397,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/toggleMultilineComment9.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementClassMemberAnonymousClass.ts_0_269 | /// <reference path='fourslash.ts' />
//// class A {
//// foo() {
//// return class { x: number; }
//// }
//// bar() {
//// return new class { x: number; }
//// }
//// }
//// class C implements A {[| |]}
verify.not.codeFixAvailable();
| {
"end_byte": 269,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementClassMemberAnonymousClass.ts"
} |
TypeScript/tests/cases/fourslash/mapCodeNestedClassIfInsertion.ts_0_396 | ///<reference path="fourslash.ts"/>
// @Filename: /index.ts
//// class MyClass {
//// x = 1;
//// foo() {
//// return 1;
//// }
//// bar() {
//// if (true)[||] {
//// return 2;
//// }
//// }
//// baz() {
//// return 3;
//// }
//// }
////
verify.baselineMapCode([test.ranges()], [
`
if (false) {
return "hello";
}
`
]); | {
"end_byte": 396,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/mapCodeNestedClassIfInsertion.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingParam15.ts_0_137 | /// <reference path="fourslash.ts" />
////function f(a: number, b: number) {}
////f();
verify.not.codeFixAvailable("addMissingParam");
| {
"end_byte": 137,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingParam15.ts"
} |
TypeScript/tests/cases/fourslash/completionsWithOptionalPropertiesGeneric.ts_0_389 | /// <reference path="fourslash.ts" />
// @strict: true
//// interface MyOptions {
//// hello?: boolean;
//// world?: boolean;
//// }
//// declare function bar<T extends MyOptions>(options?: Partial<T>): void;
//// bar({ hello, /*1*/ });
verify.completions({
marker: '1',
includes: [
{
sortText: completion.SortText.OptionalMember,
name: 'world'
},
]
})
| {
"end_byte": 389,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsWithOptionalPropertiesGeneric.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertExport_exportNodeKinds.ts_0_1689 | /// <reference path='fourslash.ts' />
// @Filename: /fn.ts
////export function f() {}
// @Filename: /cls.ts
////export class C {}
// @Filename: /interface.ts
////export interface I {}
// @Filename: /enum.ts
////export const enum E {}
// @Filename: /namespace.ts
////export namespace N {}
// @Filename: /type.ts
////export type T = number;
// @Filename: /var_unused.ts
////export const x = 0;
// @Filename: /var_unused_noInitializer.ts
////export const x;
// @Filename: /var_used.ts
////export const x = 0;
////x;
// @Filename: /var_with_type.ts
////export const fn: (n: number) => number = (n) => 1;
const tests: { [fileName: string]: string | undefined } = {
fn: `export default function f() {}`,
cls: `export default class C {}`,
interface: `export default interface I {}`,
enum:
`const enum E {}
export default E;
`,
namespace:
`namespace N {}
export default N;
`,
type:
`type T = number;
export default T;
`,
var_unused: `export default 0;`,
var_unused_noInitializer: undefined,
var_used:
`const x = 0;
export default x;
x;`,
var_with_type:
`const fn: (n: number) => number = (n) => 1;
export default fn;
`,
};
for (const name in tests) {
const newContent = tests[name];
const fileName = `/${name}.ts`;
goTo.selectAllInFile(fileName);
if (newContent === undefined) {
verify.refactorsAvailable([]);
}
else {
edit.applyRefactor({
refactorName: "Convert export",
actionName: "Convert named export to default export",
actionDescription: "Convert named export to default export",
newContent: { [fileName]: newContent },
});
}
}
| {
"end_byte": 1689,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertExport_exportNodeKinds.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_promoteTypeOnly6.ts_0_856 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @allowImportingTsExtensions: false
// @Filename: /exports.ts
//// export interface SomeInterface {}
//// export class SomePig {}
// @Filename: /a.ts
//// import type { SomePig } from "./exports.ts";
//// new SomePig/**/
verify.completions({
marker: "",
includes: [{
name: "SomePig",
source: completion.CompletionSource.TypeOnlyAlias,
hasAction: true,
}]
});
verify.applyCodeActionFromCompletion("", {
name: "SomePig",
source: completion.CompletionSource.TypeOnlyAlias,
description: `Remove 'type' from import declaration from "./exports.ts"`,
newFileContent:
`import { SomePig } from "./exports.js";
new SomePig`,
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
},
});
| {
"end_byte": 856,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_promoteTypeOnly6.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForNamedTupleMember.ts_0_106 | /// <reference path="fourslash.ts" />
////type foo = [/**/x: string];
verify.quickInfoAt("", "string");
| {
"end_byte": 106,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForNamedTupleMember.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarMerging.ts_0_5770 | /// <reference path="fourslash.ts"/>
// @Filename: file1.ts
////module a {
//// function foo() {}
////}
////module b {
//// function foo() {}
////}
////module a {
//// function bar() {}
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "module",
"childItems": [
{
"text": "bar",
"kind": "function"
},
{
"text": "foo",
"kind": "function"
}
]
},
{
"text": "b",
"kind": "module",
"childItems": [
{
"text": "foo",
"kind": "function"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "module"
},
{
"text": "b",
"kind": "module"
}
]
},
{
"text": "a",
"kind": "module",
"childItems": [
{
"text": "bar",
"kind": "function"
},
{
"text": "foo",
"kind": "function"
}
],
"indent": 1
},
{
"text": "b",
"kind": "module",
"childItems": [
{
"text": "foo",
"kind": "function"
}
],
"indent": 1
}
]);
// Does not merge unlike declarations.
// @Filename: file2.ts
////module a {}
////function a() {}
goTo.file("file2.ts");
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "function"
},
{
"text": "a",
"kind": "module"
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "function"
},
{
"text": "a",
"kind": "module"
}
]
},
{
"text": "a",
"kind": "function",
"indent": 1
},
{
"text": "a",
"kind": "module",
"indent": 1
}
]);
// Merges recursively
// @Filename: file3.ts
////module a {
//// interface A {
//// foo: number;
//// }
////}
////module a {
//// interface A {
//// bar: number;
//// }
////}
goTo.file("file3.ts");
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "module",
"childItems": [
{
"text": "A",
"kind": "interface",
"childItems": [
{
"text": "bar",
"kind": "property"
},
{
"text": "foo",
"kind": "property"
}
]
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "module"
}
]
},
{
"text": "a",
"kind": "module",
"childItems": [
{
"text": "A",
"kind": "interface"
}
],
"indent": 1
},
{
"text": "A",
"kind": "interface",
"childItems": [
{
"text": "bar",
"kind": "property"
},
{
"text": "foo",
"kind": "property"
}
],
"indent": 2
}
]);
// Does not merge 'module A' with 'module A.B'
// @Filename: file4.ts
////module A { export var x; }
////module A.B { export var y; }
goTo.file("file4.ts");
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "A",
"kind": "module",
"childItems": [
{
"text": "x",
"kind": "var",
"kindModifiers": "export"
}
]
},
{
"text": "A.B",
"kind": "module",
"childItems": [
{
"text": "y",
"kind": "var",
"kindModifiers": "export"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "A",
"kind": "module"
},
{
"text": "A.B",
"kind": "module"
}
]
},
{
"text": "A",
"kind": "module",
"childItems": [
{
"text": "x",
"kind": "var",
"kindModifiers": "export"
}
],
"indent": 1
},
{
"text": "A.B",
"kind": "module",
"childItems": [
{
"text": "y",
"kind": "var",
"kindModifiers": "export"
}
],
"indent": 1
}
]);
| {
"end_byte": 5770,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarMerging.ts"
} |
TypeScript/tests/cases/fourslash/organizeImportsType6.ts_0_1139 | /// <reference path="fourslash.ts" />
//// import { type a, A, b } from "foo";
//// interface Use extends A {}
//// console.log(a, b);
verify.organizeImports(
`import { type a, A, b } from "foo";
interface Use extends A {}
console.log(a, b);`,
/*mode*/ undefined,
{ organizeImportsTypeOrder: "inline" });
edit.replaceLine(0, 'import { type a, A, b } from "foo1";');
verify.organizeImports(
`import { type a, A, b } from "foo1";
interface Use extends A {}
console.log(a, b);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: "auto", organizeImportsTypeOrder: "inline" });
edit.replaceLine(0, 'import { type a, A, b } from "foo2";');
verify.organizeImports(
`import { type a, A, b } from "foo2";
interface Use extends A {}
console.log(a, b);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: true, organizeImportsTypeOrder: "inline" });
edit.replaceLine(0, 'import { type a, A, b } from "foo3";');
verify.organizeImports(
`import { A, type a, b } from "foo3";
interface Use extends A {}
console.log(a, b);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: false, organizeImportsTypeOrder: "inline" }); | {
"end_byte": 1139,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsType6.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingConstToCommaSeparatedInitializer4.ts_0_105 | /// <reference path='fourslash.ts' />
////let y: any;
////x = 0, y = 0;
verify.not.codeFixAvailable();
| {
"end_byte": 105,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingConstToCommaSeparatedInitializer4.ts"
} |
TypeScript/tests/cases/fourslash/formatArrayOrObjectLiteralsInVariableList.ts_0_243 | /// <reference path='fourslash.ts' />
////var v30 = [1, 2], v31, v32, v33 = [0], v34 = {'a': true}, v35;/**/
format.document();
goTo.marker("");
verify.currentLineContentIs("var v30 = [1, 2], v31, v32, v33 = [0], v34 = { 'a': true }, v35;"); | {
"end_byte": 243,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatArrayOrObjectLiteralsInVariableList.ts"
} |
TypeScript/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts_0_235 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters:true
////class greeter {
//// [| constructor() {
//// var unused = 20;
//// } |]
////}
verify.rangeAfterCodeFix(`constructor() {
}`);
| {
"end_byte": 235,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionComments1.ts_0_484 | /// <reference path='fourslash.ts' />
////function /*a*/foo/*b*/(a: number /** a */, b: number /** b */) {
//// return 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: `function foo({ a, b }: { a: number /** a */; b: number /** b */; }) {
return a + b;
}`
}); | {
"end_byte": 484,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionComments1.ts"
} |
TypeScript/tests/cases/fourslash/completionsWritingSpreadArgument.ts_0_283 | /// <reference path='fourslash.ts'/>
////
//// const [] = [Math.min(./*marker*/)]
////
goTo.marker("marker");
verify.completions({ exact: undefined });
edit.insert(".");
verify.completions({ exact: undefined });
edit.insert(".");
verify.completions({ exact: completion.globals });
| {
"end_byte": 283,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsWritingSpreadArgument.ts"
} |
TypeScript/tests/cases/fourslash/unusedTypeParametersInMethods1.ts_0_284 | /// <reference path='fourslash.ts' />
// @noUnusedParameters: true
//// class A {
//// [|public f1<X, Y, Z>(a: X)|] { a; var b: Z; b }
//// }
verify.codeFix({
index: 0,
description: "Remove unused declaration for: 'Y'",
newRangeContent: "public f1<X, Z>(a: X)",
});
| {
"end_byte": 284,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedTypeParametersInMethods1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration27.ts_0_465 | /// <reference path="fourslash.ts" />
// @strict: true
////interface Foo {
//// a?: ((e: any) => void);
////}
////
////const foo: Foo = {
//// a: fn
////}
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "fn"],
newFileContent:
`interface Foo {
a?: ((e: any) => void);
}
const foo: Foo = {
a: fn
}
function fn(e: any): void {
throw new Error("Function not implemented.");
}
`
});
| {
"end_byte": 465,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration27.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUndeclaredPropertyAccesses.ts_0_556 | /// <reference path='fourslash.ts' />
//// interface I { x: number; }
//// let i: I;
//// i.y;
//// i.foo();
//// enum E { a,b }
//// let e: typeof E;
//// e.a;
//// e.c;
//// let obj = { a: 1, b: "asdf"};
//// obj.c;
//// type T<U> = I | U;
//// let t: T<number>;
//// t.x;
verify.codeFixAvailable([
"Declare property 'y'",
"Add index signature for property 'y'",
"Declare method 'foo'",
"Declare property 'foo'",
"Add index signature for property 'foo'",
"Add missing enum member 'c'",
].map(description => ({ description })));
| {
"end_byte": 556,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUndeclaredPropertyAccesses.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationModuleAmbient.ts_0_251 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_moduleAmbient.baseline
// @Filename: bpSpan_moduleAmbient.ts
////declare module Bar {
////}
////declare module Foo {
//// var x;
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 251,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationModuleAmbient.ts"
} |
TypeScript/tests/cases/fourslash/tsxRename5.ts_0_478 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props }
//// }
//// class MyClass {
//// props: {
//// name?: string;
//// size?: number;
//// }
////
//// [|var [|{| "contextRangeIndex": 0 |}nn|]: string;|]
//// var x = <MyClass name={[|nn|]}></MyClass>;
verify.baselineRenameAtRangesWithText("nn");
| {
"end_byte": 478,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxRename5.ts"
} |
TypeScript/tests/cases/fourslash/deprecatedInheritedJSDocOverload.ts_1_1393 | //// interface PartialObserver<T> {}
//// interface Subscription {}
//// interface Unsubscribable {}
////
//// export interface Subscribable<T> {
//// subscribe(observer?: PartialObserver<T>): Unsubscribable;
//// /** @deprecated Base deprecation 1 */
//// subscribe(next: null | undefined, error: null | undefined, complete: () => void): Unsubscribable;
//// /** @deprecated Base deprecation 2 */
//// subscribe(next: null | undefined, error: (error: any) => void, complete?: () => void): Unsubscribable;
//// /** @deprecated Base deprecation 3 */
//// subscribe(next: (value: T) => void, error: null | undefined, complete: () => void): Unsubscribable;
//// subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): Unsubscribable;
//// }
//// interface ThingWithDeprecations<T> extends Subscribable<T> {
//// subscribe(observer?: PartialObserver<T>): Subscription;
//// /** @deprecated 'real' deprecation */
//// subscribe(next: null | undefined, error: null | undefined, complete: () => void): Subscription;
//// /** @deprecated 'real' deprecation */
//// subscribe(next: null | undefined, error: (error: any) => void, complete?: () => void): Subscription;
//// }
//// declare const a: ThingWithDeprecations<void>
//// a.subscribe/**/(() => {
//// console.log('something happened');
//// });
verify.baselineQuickInfo(); | {
"end_byte": 1393,
"start_byte": 1,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/deprecatedInheritedJSDocOverload.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization_all_1.ts_0_1105 | /// <reference path='fourslash.ts' />
// @strict: true
//// abstract class A { abstract a (); }
////
//// class TT { constructor () {} }
////
//// class AT extends A { a () {} }
////
//// class Foo {}
////
//// class T {
////
//// a: string;
////
//// static b: string;
////
//// private c: string;
////
//// d: number | undefined;
////
//// e: string | number;
////
//// f: 1;
////
//// g: "123" | "456";
////
//// h: boolean;
////
//// i: TT;
////
//// j: A;
////
//// k: AT;
////
//// l: Foo;
//// }
verify.codeFixAll({
fixId: 'addMissingPropertyDefiniteAssignmentAssertions',
fixAllDescription: "Add definite assignment assertions to all uninitialized properties",
newFileContent: `abstract class A { abstract a (); }
class TT { constructor () {} }
class AT extends A { a () {} }
class Foo {}
class T {
a!: string;
static b: string;
private c!: string;
d: number | undefined;
e!: string | number;
f!: 1;
g!: "123" | "456";
h!: boolean;
i!: TT;
j!: A;
k!: AT;
l!: Foo;
}`
}); | {
"end_byte": 1105,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization_all_1.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesConst04.ts_0_223 | /// <reference path='fourslash.ts' />
////export const class C {
//// private static c/*1*/onst f/*2*/oo;
//// constructor(public con/*3*/st foo) {
//// }
////}
verify.baselineDocumentHighlights(["1", "2", "3"]); | {
"end_byte": 223,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesConst04.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction3.ts_0_344 | /// <reference path='fourslash.ts' />
//// const foo = /*a*/a/*b*/ => 1;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Add or remove braces in an arrow function",
actionName: "Add braces to arrow function",
actionDescription: "Add braces to arrow function",
newContent: `const foo = a => {
return 1;
};`,
});
| {
"end_byte": 344,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction3.ts"
} |
TypeScript/tests/cases/fourslash/completionListInTypedObjectLiteralsWithPartialPropertyNames2.ts_0_218 | /// <reference path="fourslash.ts" />
////interface MyPoint {
//// x1: number;
//// y1: number;
////}
////var p15: MyPoint = {
//// /**/x1: 0,
////};
verify.completions({ marker: "", exact: ["x1", "y1"] });
| {
"end_byte": 218,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInTypedObjectLiteralsWithPartialPropertyNames2.ts"
} |
TypeScript/tests/cases/fourslash/completionsClassPropertiesAfterPrivateProperty.ts_0_250 | /// <reference path="fourslash.ts" />
//// interface X {
//// bla: string;
//// }
//// class Y implements X {
//// private blub = "";
//// /**/
//// }
verify.completions({ marker: "", includes: "bla", isNewIdentifierLocation: true });
| {
"end_byte": 250,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsClassPropertiesAfterPrivateProperty.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionExternalModuleName5.ts_0_168 | /// <reference path='fourslash.ts'/>
// @Filename: a.ts
////declare module /*2*/[|"external/*1*/"|] {
//// class Foo { }
////}
verify.baselineGoToDefinition("1");
| {
"end_byte": 168,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionExternalModuleName5.ts"
} |
TypeScript/tests/cases/fourslash/jsDocAugmentsAndExtends.ts_0_730 | ///<reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @Filename: dummy.js
//// /**
//// * @augments {Thing<number>}
//// * [|@extends {Thing<string>}|]
//// */
//// class MyStringThing extends Thing {
//// constructor() {
//// super();
//// var x = this.mine;
//// x/**/;
//// }
//// }
// @Filename: declarations.d.ts
//// declare class Thing<T> {
//// mine: T;
//// }
// if more than one tag is present, report an error and take the type of the first entry.
goTo.marker();
verify.quickInfoIs("(local var) x: number");
verify.getSemanticDiagnostics([{
message: "Class declarations cannot have more than one '@augments' or '@extends' tag.",
code: 8025
}]);
| {
"end_byte": 730,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocAugmentsAndExtends.ts"
} |
TypeScript/tests/cases/fourslash/pathCompletionsAllowTsExtensions.ts_0_780 | /// <reference path="fourslash.ts" />
// @moduleResolution: bundler
// @allowImportingTsExtensions: true
// @noEmit: true
// @Filename: /project/foo.ts
//// export const foo = 0;
// @Filename: /project/main.ts
//// import {} from ".//**/"
// Extensionless by default
verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: ["foo"],
});
// .ts extension when allowImportingTsExtensions is true and setting is js...
verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: ["foo.ts"],
preferences: {
importModuleSpecifierEnding: "js",
},
});
// ...or when another import uses .ts extension
edit.insert(`foo.ts"\nimport {} from "./`);
verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: ["foo.ts"],
});
| {
"end_byte": 780,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsAllowTsExtensions.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts_0_441 | /// <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: "templateStrings",
parameterSpan: "templateStrings: any",
});
| {
"end_byte": 441,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingAwait_initializer3.ts_0_617 | /// <reference path="fourslash.ts" />
////async function fn(a: number, b: Promise<number>) {
//// const x = b;
//// const y = b;
//// fn(x, b);
//// fn(y, b);
//// x.toFixed();
//// y.then;
////
//// b + b;
//// x + b;
//// x + x.toFixed();
////}
verify.codeFixAll({
fixAllDescription: ts.Diagnostics.Fix_all_expressions_possibly_missing_await.message,
fixId: "addMissingAwait",
newFileContent:
`async function fn(a: number, b: Promise<number>) {
const x = await b;
const y = b;
fn(x, b);
fn(await y, b);
x.toFixed();
y.then;
await b + await b;
x + await b;
x + x.toFixed();
}`
});
| {
"end_byte": 617,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAwait_initializer3.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_prologueDirectives2.ts_0_509 | /// <reference path='fourslash.ts' />
// @module: commonjs
// @allowJs: true
// @Filename: /foo.js
////exports.foo = function () {};
// @Filename: /a.js
////"use strict";
////const foo = require("./foo");
////[|function b() {
//// return this;
////}|]
////b();
verify.moveToNewFile({
newFileContents: {
"/a.js":
`"use strict";
const { b } = require("./b");
const foo = require("./foo");
b();`,
"/b.js":
`"use strict";
function b() {
return this;
}
exports.b = b;
`,
},
});
| {
"end_byte": 509,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_prologueDirectives2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties47.ts_0_361 | /// <reference path='fourslash.ts' />
// @strict: true
//// interface A {
//// a: number;
//// b: string;
//// }
//// function f(_obj: (A | undefined)[]): string {
//// return "";
//// }
//// [|f([{}]);|]
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newRangeContent:
`f([{
a: 0,
b: ""
}]);`,
});
| {
"end_byte": 361,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties47.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.