_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/codeFixRemoveUnnecessaryAwait_mixedUnion.ts_0_262 | /// <reference path="fourslash.ts" />
// @target: esnext
//// async function fn1(a: Promise<void> | void) {
//// await a;
//// }
////
//// async function fn2<T extends Promise<void> | void>(a: T) {
//// await a;
//// }
verify.getSuggestionDiagnostics([]);
| {
"end_byte": 262,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixRemoveUnnecessaryAwait_mixedUnion.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsPropertyDeclarations.ts_0_397 | /// <reference path="fourslash.ts" />
// @strict: true
//// class C {
//// a = 1
//// b: number = 2
//// c;
//// d;
////
//// constructor(value: number) {
//// this.d = value;
//// if (value <= 0) {
//// this.d = null;
//// }
//// }
//// }
verify.baselineInlayHints(undefined, {
includeInlayPropertyDeclarationTypeHints: true,
});
| {
"end_byte": 397,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsPropertyDeclarations.ts"
} |
TypeScript/tests/cases/fourslash/tsxCompletion15.ts_0_2162 | /// <reference path='fourslash.ts' />
//@module: commonjs
//@jsx: preserve
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//@Filename: exporter.tsx
//// export module M {
//// export declare function SFCComp(props: { Three: number; Four: string }): JSX.Element;
//// }
//@Filename: file.tsx
//// import * as Exp from './exporter';
//// var x1 = <Exp.M.SFCComp></[|/*1*/|]>;
//// var x2 = <Exp.M.SFCComp></[|Exp./*2*/|]>;
//// var x3 = <Exp.M.SFCComp></[|Exp.M./*3*/|]>;
//// var x4 = <Exp.M.SFCComp></[|Exp.M.SFCComp/*4*/|]
//// var x5 = <Exp.M.SFCComp></[|Exp.M.SFCComp/*5*/|]>;
//// var x6 = <Exp.M.SFCComp></ [|Exp./*6*/|]>;
//// var x7 = <Exp.M.SFCComp></[|/*7*/Exp.M.SFCComp|]>;
//// var x8 = <Exp.M.SFCComp></[|Exp/*8*/|]>;
//// var x9 = <Exp.M.SFCComp></[|Exp.M./*9*/|]>;
//// var x10 = <Exp.M.SFCComp></ [|/*10*/Exp.M.Foo.Bar.Baz.Wut|]>;
//// var x11 = <Exp.M.SFCComp></[|Exp./*11*/M.SFCComp|]>;
//// var x12 = <Exp.M.SFCComp><div><span /></div></[|Exp.M./*12*/SFCComp|]>;
const ranges = test.ranges();
verify.completions(
{ marker: '1', exact: 'Exp.M.SFCComp', optionalReplacementSpan: ranges[0] },
{ marker: '2', exact: 'Exp.M.SFCComp', optionalReplacementSpan: ranges[1] },
{ marker: '3', exact: 'Exp.M.SFCComp', optionalReplacementSpan: ranges[2] },
{ marker: '4', exact: 'Exp.M.SFCComp>', optionalReplacementSpan: ranges[3] },
{ marker: '5', exact: 'Exp.M.SFCComp', optionalReplacementSpan: ranges[4] },
{ marker: '6', exact: 'Exp.M.SFCComp', optionalReplacementSpan: ranges[5] },
{ marker: '7', exact: 'Exp.M.SFCComp', optionalReplacementSpan: ranges[6] },
{ marker: '8', exact: 'Exp.M.SFCComp', optionalReplacementSpan: ranges[7] },
{ marker: '9', exact: 'Exp.M.SFCComp', optionalReplacementSpan: ranges[8] },
{ marker: '10', exact: 'Exp.M.SFCComp', optionalReplacementSpan: ranges[9] },
{ marker: '11', exact: 'Exp.M.SFCComp', optionalReplacementSpan: ranges[10] },
{ marker: '12', exact: 'Exp.M.SFCComp', optionalReplacementSpan: ranges[11] },
);
| {
"end_byte": 2162,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletion15.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingConstInForOfLoop2.ts_0_271 | /// <reference path='fourslash.ts' />
////for (x of []) {}
////for (y of []) {}
verify.codeFixAll({
fixId: "addMissingConst",
fixAllDescription: "Add 'const' to all unresolved variables",
newFileContent:
`for (const x of []) {}
for (const y of []) {}`
});
| {
"end_byte": 271,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingConstInForOfLoop2.ts"
} |
TypeScript/tests/cases/fourslash/completionListInTypeLiteralInTypeParameter5.ts_0_311 | /// <reference path="fourslash.ts" />
////interface Foo {
//// one: string;
//// two: number;
////}
////
////interface Bar<T extends Foo> {
//// foo: T;
////}
////
////var foobar: Bar<{ prop1: string } & {/**/
verify.completions({ marker: "", exact: ["one", "two"], isNewIdentifierLocation: true });
| {
"end_byte": 311,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInTypeLiteralInTypeParameter5.ts"
} |
TypeScript/tests/cases/fourslash/completionsCombineOverloads_restParameter.ts_0_404 | /// <reference path="fourslash.ts" />
////interface A { a: number }
////interface B { b: number }
////interface C { c: number }
////declare function f(a: A): void;
////declare function f(...bs: B[]): void;
////declare function f(...cs: C[]): void;
////f({ /*1*/ });
////f({ a: 1 }, { /*2*/ });
verify.completions(
{ marker: "1", exact: ["a", "b", "c"] },
{ marker: "2", exact: ["b", "c"] },
);
| {
"end_byte": 404,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsCombineOverloads_restParameter.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports45-decorators.ts_0_2098 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
// @Filename: /code.ts
//// function classDecorator<T extends Function> (value: T, context: ClassDecoratorContext) {}
//// function methodDecorator<This> (
//// target: (...args: number[])=> number,
//// context: ClassMethodDecoratorContext<This, (this: This, ...args: number[]) => number>) {}
//// function getterDecorator(value: Function, context: ClassGetterDecoratorContext) {}
//// function setterDecorator(value: Function, context: ClassSetterDecoratorContext) {}
//// function fieldDecorator(value: undefined, context: ClassFieldDecoratorContext) {}
//// function foo() { return 42;}
////
//// @classDecorator
//// export class A {
//// @methodDecorator
//// sum(...args: number[]) {
//// return args.reduce((a, b) => a + b, 0);
//// }
//// getSelf() {
//// return this;
//// }
//// @getterDecorator
//// get a() {
//// return foo();
//// }
//// @setterDecorator
//// set a(value) {}
////
//// @fieldDecorator classProp = foo();
//// }
verify.codeFixAll({
fixId: "fixMissingTypeAnnotationOnExports",
fixAllDescription: ts.Diagnostics.Add_all_missing_type_annotations.message,
newFileContent:
`function classDecorator<T extends Function> (value: T, context: ClassDecoratorContext) {}
function methodDecorator<This> (
target: (...args: number[])=> number,
context: ClassMethodDecoratorContext<This, (this: This, ...args: number[]) => number>) {}
function getterDecorator(value: Function, context: ClassGetterDecoratorContext) {}
function setterDecorator(value: Function, context: ClassSetterDecoratorContext) {}
function fieldDecorator(value: undefined, context: ClassFieldDecoratorContext) {}
function foo() { return 42;}
@classDecorator
export class A {
@methodDecorator
sum(...args: number[]): number {
return args.reduce((a, b) => a + b, 0);
}
getSelf(): this {
return this;
}
@getterDecorator
get a(): number {
return foo();
}
@setterDecorator
set a(value) {}
@fieldDecorator classProp: number = foo();
}`
});
| {
"end_byte": 2098,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports45-decorators.ts"
} |
TypeScript/tests/cases/fourslash/genericDerivedTypeAcrossModuleBoundary1.ts_0_437 | /// <reference path='fourslash.ts'/>
////module M {
//// export class C1 { }
//// export class C2<T> { }
////}
////var c = new M.C2<number>();
////module N {
//// export class D1 extends M.C1 { }
//// export class D2<T> extends M.C2<T> { }
////}
////var n = new N.D1();
////var /*1*/n2 = new N.D2<number>();
////var /*2*/n3 = new N.D2();
verify.quickInfos({
1: "var n2: N.D2<number>",
2: "var n3: N.D2<unknown>"
});
| {
"end_byte": 437,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericDerivedTypeAcrossModuleBoundary1.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesReadonly1.ts_0_134 | /// <reference path="fourslash.ts" />
////interface I {
//// [|readonly|] prop: string;
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 134,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesReadonly1.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames4.ts_0_200 | /// <reference path='fourslash.ts'/>
////class Foo {
//// /*1*/public /*2*/____bar() { return 0; }
////}
////
////var x: Foo;
////x./*3*/____bar;
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 200,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames4.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsParameterNamesInSpan2.ts_0_713 | /// <reference path="fourslash.ts" />
//// function foo1 (a: number, b: number) {}
//// function foo2 (c: number, d: number) {}
//// function foo3 (e: number, f: number) {}
//// function foo4 (g: number, h: number) {}
//// function foo5 (i: number, j: number) {}
//// function foo6 (k: number, l: number) {}
//// foo1(/*a*/1, /*b*/2);
//// foo2(/*c*/1, /*d*/2);
//// foo3(/*e*/1, /*f*/2);
//// foo4(/*g*/1, /*h*/2);
//// foo5(/*i*/1, /*j*/2);
//// foo6(/*k*/1, /*l*/2);
const start = test.markerByName('c');
const end = test.markerByName('h');
const span = { start: start.position, length: end.position - start.position };
verify.baselineInlayHints(span, {
includeInlayParameterNameHints: "literals",
});
| {
"end_byte": 713,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsParameterNamesInSpan2.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentOnFunctionParameters.ts_0_708 | /// <reference path='fourslash.ts' />
////function foo(a,
//// /*2*/b,/*0*/
//// //ABC/*3*/
//// /*4*/c
//// ) {
////};
////var x = [
//// /*5*///DEF/*1*/
//// 1,/*6*/
//// 2/*7*/
////]
goTo.marker("0");
edit.insert("\n");
verify.indentationIs(4);
goTo.marker("2");
verify.currentLineContentIs(" b,");
goTo.marker("3");
verify.currentLineContentIs(" //ABC");
goTo.marker("4");
verify.currentLineContentIs(" c");
goTo.marker("1");
edit.insert("\n");
verify.indentationIs(4);
goTo.marker("5");
verify.currentLineContentIs(" //DEF");
goTo.marker("6");
verify.currentLineContentIs(" 1,");
goTo.marker("7");
verify.currentLineContentIs(" 2");
| {
"end_byte": 708,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentOnFunctionParameters.ts"
} |
TypeScript/tests/cases/fourslash/codeFixImportNonExportedMember3.ts_0_428 | /// <reference path="fourslash.ts" />
// @module: esnext
// @filename: /a.ts
////let foo = 1, bar = 1;
////export const baz = 1;
// @filename: /b.ts
////import { bar } from "./a";
goTo.file("/b.ts");
verify.codeFix({
description: [ts.Diagnostics.Export_0_from_module_1.message, "bar", "./a"],
index: 0,
newFileContent: {
"/a.ts":
`let foo = 1, bar = 1;
export const baz = 1;
export { bar };
`,
}
});
| {
"end_byte": 428,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImportNonExportedMember3.ts"
} |
TypeScript/tests/cases/fourslash/jsxAttributeCompletionStyleNone.ts_0_1841 | /// <reference path="fourslash.ts" />
// @Filename: foo.tsx
//// declare namespace JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// foo: {
//// prop_a: boolean;
//// prop_b: string;
//// prop_c: any;
//// prop_d: { p1: string; }
//// prop_e: string | undefined;
//// prop_f: boolean | undefined | { p1: string; };
//// prop_g: { p1: string; } | undefined;
//// prop_h?: string;
//// prop_i?: boolean;
//// prop_j?: { p1: string; };
//// }
//// }
//// }
////
//// <foo [|prop_/**/|] />
verify.completions({
marker: "",
exact: [
{
name: "prop_a",
isSnippet: undefined,
},
{
name: "prop_b",
isSnippet: undefined,
},
{
name: "prop_c",
isSnippet: undefined,
},
{
name: "prop_d",
isSnippet: undefined,
},
{
name: "prop_e",
isSnippet: undefined,
},
{
name: "prop_f",
isSnippet: undefined,
},
{
name: "prop_g",
isSnippet: undefined,
},
{
name: "prop_h",
isSnippet: undefined,
sortText: completion.SortText.OptionalMember,
},
{
name: "prop_i",
isSnippet: undefined,
sortText: completion.SortText.OptionalMember,
},
{
name: "prop_j",
isSnippet: undefined,
sortText: completion.SortText.OptionalMember,
}
],
preferences: {
jsxAttributeCompletionStyle: "none",
includeCompletionsWithSnippetText: true
}
}); | {
"end_byte": 1841,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsxAttributeCompletionStyleNone.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionShorthandProperty04.ts_0_179 | /// <reference path="./fourslash.ts"/>
////interface Foo {
//// /*2*/foo(): void
////}
////
////let x: Foo = {
//// [|f/*1*/oo|]
////}
verify.baselineGoToDefinition("1");
| {
"end_byte": 179,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionShorthandProperty04.ts"
} |
TypeScript/tests/cases/fourslash/importTypeCompletions3.ts_0_635 | /// <reference path="fourslash.ts" />
// @target: esnext
// @filename: /foo.ts
////export interface Foo {}
// @filename: /bar.ts
////[|import type { F/**/ }|]
goTo.file("/bar.ts")
verify.completions({
marker: "",
exact: [{
name: "Foo",
sourceDisplay: "./foo",
source: "./foo",
insertText: "import type { Foo } from \"./foo\";",
replacementSpan: test.ranges()[0]
}],
isNewIdentifierLocation: true,
preferences: {
includeCompletionsForModuleExports: true,
includeCompletionsForImportStatements: true,
includeCompletionsWithInsertText: true
}
});
| {
"end_byte": 635,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importTypeCompletions3.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportExportEqualsCommonJSInteropOn.ts_0_1036 | /// <reference path="fourslash.ts" />
// @Module: commonjs
// @EsModuleInterop: true
// @Filename: /foo.d.ts
////declare module "bar" {
//// const bar: number;
//// export = bar;
////}
////declare module "foo" {
//// const foo: number;
//// export = foo;
////}
////declare module "es" {
//// const es = 0;
//// export default es;
////}
// @Filename: /a.ts
////import bar = require("bar");
////
////foo
// @Filename: /b.ts
////foo
// @Filename: /c.ts
////import es from "es";
////import bar = require("bar");
////
////foo
// 1. Should match existing imports of 'export ='
goTo.file('/a.ts');
verify.importFixAtPosition([`import bar = require("bar");
import foo = require("foo");
foo`]);
// 2. Should default to default import
goTo.file('/b.ts');
verify.importFixAtPosition([`import foo from "foo";
foo`]);
// 3. Importing an 'export default' doesn’t count toward the usage heursitic
goTo.file('/c.ts');
verify.importFixAtPosition([`import es from "es";
import bar = require("bar");
import foo = require("foo");
foo`]); | {
"end_byte": 1036,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportExportEqualsCommonJSInteropOn.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCannotFindModule.ts_0_590 | /// <reference path='fourslash.ts' />
// @moduleResolution: node
// @noImplicitAny: true
// @Filename: /node_modules/abs/index.js
////not read
// @Filename: /a.ts
////import * as abs from "abs";
////abs;
// @Filename: /b.ts
////const x: import("abs").T = 0;
test.setTypesRegistry({
"abs": undefined,
});
for (const file of ["/a.ts", "/b.ts"]) {
goTo.file(file);
verify.codeFixAvailable([{
description: "Install '@types/abs'",
commands: [{
type: "install package",
file,
packageName: "@types/abs",
}],
}]);
}
| {
"end_byte": 590,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCannotFindModule.ts"
} |
TypeScript/tests/cases/fourslash/moduleNodeNextAutoImport3.ts_0_440 | /// <reference path="fourslash.ts" />
// @Filename: /tsconfig.json
//// { "compilerOptions": { "module": "nodenext" } }
// @Filename: /package.json
//// { "type": "module" }
// @Filename: /mobx.d.mts
//// export declare function autorun(): void;
// @Filename: /index.ts
//// autorun/**/
// @Filename: /utils.ts
//// import "./mobx.mjs";
goTo.marker("");
verify.importFixAtPosition([`import { autorun } from "./mobx.mjs";
autorun`]);
| {
"end_byte": 440,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moduleNodeNextAutoImport3.ts"
} |
TypeScript/tests/cases/fourslash/jsdocLink_rename1.ts_0_161 | /// <reference path='fourslash.ts'/>
//// interface A/**/ {}
//// /**
//// * {@link A()} is ok
//// */
//// declare const a: A
verify.baselineRename('', {})
| {
"end_byte": 161,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocLink_rename1.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateCommentTrailingStr.ts_0_444 | /// <reference path='fourslash.ts' />
//// const foo = /* C0 */ /*x*/"/*y*/foo" /* C1 */ + " is" /* C2 */ + 42 + " years old"/* C3 */
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
newContent:
"const foo = /* C0 */ `foo is\${ /* C1 */ /* C2 */42} years old` /* C3 */",
});
| {
"end_byte": 444,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateCommentTrailingStr.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl2.ts_0_584 | /// <reference path="fourslash.ts" />
// @Filename: /tsconfig.json
////{
//// "compilerOptions": {
//// "baseUrl": "./a"
//// }
////}
// @Filename: /a/b/x.ts
////export function f1() { };
// @Filename: /a/c/y.ts
////[|f1/*0*/();|]
goTo.file("/a/c/y.ts");
// Order the baseUrl import first, because the relative import climbs up to the base url.
verify.importFixAtPosition([
`import { f1 } from "b/x";
f1();`,
]);
verify.importFixAtPosition([
`import { f1 } from "../b/x";
f1();`,
], /*errorCode*/ undefined, {
importModuleSpecifierPreference: "relative",
});
| {
"end_byte": 584,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl2.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnClosingJsx.ts_0_149 | /// <reference path="fourslash.ts" />
// @Filename: foo.tsx
////let x = <div>
//// /*$*/</div >
goTo.marker("$");
verify.not.quickInfoExists();
| {
"end_byte": 149,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnClosingJsx.ts"
} |
TypeScript/tests/cases/fourslash/tsxFindAllReferencesUnionElementType2.ts_3_478 | / <reference path='fourslash.ts' />
//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
//// class RC1 extends React.Component<{}, {}> {
//// render() {
//// return null;
//// }
//// }
//// class RC2 extends React.Component<{}, {}> {
//// render() {
//// return null;
//// }
//// private method() { }
//// }
//// /*1*/var /*2*/RCComp = RC1 || RC2;
//// /*3*/</*4*/RCComp />
verify.baselineFindAllReferences('1', '2', '3', '4');
| {
"end_byte": 478,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxFindAllReferencesUnionElementType2.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_getCanonicalFileName.ts_0_361 | /// <reference path="fourslash.ts" />
// @Filename: /howNow/node_modules/brownCow/index.d.ts
////export const foo: number;
// @Filename: /howNow/a.ts
////foo;
// Before fixing this bug, we compared a canonicalized `hownow` to a non-canonicalized `howNow`.
goTo.file("/howNow/a.ts");
verify.importFixAtPosition([
`import { foo } from "brownCow";
foo;`,
]);
| {
"end_byte": 361,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_getCanonicalFileName.ts"
} |
TypeScript/tests/cases/fourslash/completionsConditionalMember.ts_0_372 | /// <reference path="fourslash.ts" />
////declare function f<T extends string>(
//// p: { a: T extends 'foo' ? { x: string } : { y: string } }
////): void;
////
////f<'foo'>({ a: { /*1*/ } });
////f<string>({ a: { /*2*/ } });
verify.completions({
marker: '1',
exact: [{
name: 'x'
}]
});
verify.completions({
marker: '2',
exact: [{
name: 'y'
}]
});
| {
"end_byte": 372,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsConditionalMember.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpellingJs1.ts_0_481 | /// <reference path='fourslash.ts' />
// @allowjs: true
// @noEmit: true
// @filename: a.js
//// function f() {
//// var locals = 2
//// [|locale|].toFixed()
//// return locals
//// }
verify.noErrors()
verify.codeFixAvailable([
{ description: "Change spelling to 'locals'" },
]);
verify.codeFix({
description: "Change spelling to 'locals'",
index: 0,
newFileContent:
`function f() {
var locals = 2
locals.toFixed()
return locals
}`,
});
| {
"end_byte": 481,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingJs1.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_01.ts_0_1177 | /// <reference path='fourslash.ts'/>
// Should handle shorthand property assignments of class constructors when invoked on member of interface
//// interface Foo {
//// someFunction(): void;
//// }
////
//// interface FooConstructor {
//// new (): Foo
//// }
////
//// interface Bar {
//// Foo: FooConstructor;
//// }
////
//// // Class expression that gets used in a bar implementation
//// var x = class [|Foo|] {
//// createBarInClassExpression(): Bar {
//// return {
//// Foo
//// };
//// }
////
//// someFunction() {}
//// };
////
//// // Class declaration that gets used in a bar implementation. This class has multiple definitions
//// // (the class declaration and the interface above), but we only want the class returned
//// class [|Foo|] {
////
//// }
////
//// function createBarUsingClassDeclaration(): Bar {
//// return {
//// Foo
//// };
//// }
////
//// // Class expression that does not get used in a bar implementation
//// var y = class Foo {
//// someFunction() {}
//// };
////
//// createBarUsingClassDeclaration().Fo/*reference*/o;
verify.baselineGoToImplementation("reference"); | {
"end_byte": 1177,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_01.ts"
} |
TypeScript/tests/cases/fourslash/suggestionOfUnusedVariableWithExternalModule.ts_0_805 | /// <reference path='fourslash.ts' />
//@allowJs: true
// @Filename: /mymodule.js
////(function ([|root|], factory) {
//// module.exports = factory();
////}(this, function () {
//// var [|unusedVar|] = "something";
//// return {};
////}));
// @Filename: /app.js
//////@ts-check
////require("./mymodule");
const [range0, range1] = test.ranges();
goTo.file("/app.js");
verify.getSuggestionDiagnostics([]);
goTo.file("/mymodule.js");
verify.getSuggestionDiagnostics([
{
message: "'root' is declared but its value is never read.",
code: 6133,
range: range0,
reportsUnnecessary: true,
},
{
message: "'unusedVar' is declared but its value is never read.",
code: 6133,
range: range1,
reportsUnnecessary: true,
},
]);
| {
"end_byte": 805,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/suggestionOfUnusedVariableWithExternalModule.ts"
} |
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc11.ts_0_305 | /// <reference path='fourslash.ts' />
/////**
//// * @param {?} x
//// * @returns {number}
//// */
////var f = (x) => x
verify.codeFix({
index: 0,
description: "Annotate with type from JSDoc",
newFileContent:
`/**
* @param {?} x
* @returns {number}
*/
var f = (x: any): number => x`,
});
| {
"end_byte": 305,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc11.ts"
} |
TypeScript/tests/cases/fourslash/arityErrorAfterSignatureHelp.ts_0_444 | ///<reference path="fourslash.ts"/>
// @strict: true
////
//// declare function f(x: string, y: number): any;
////
//// /*1*/f/*2*/(/*3*/)
goTo.marker("3");
verify.signatureHelp({
triggerReason: {
kind: "invoked"
}
})
edit.insert(`"`)
edit.insert(`"`)
verify.signatureHelp({
triggerReason: {
kind: "retrigger"
}
})
verify.not.codeFixAvailable(); // trigger typecheck
verify.errorExistsBetweenMarkers("1", "2");
| {
"end_byte": 444,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/arityErrorAfterSignatureHelp.ts"
} |
TypeScript/tests/cases/fourslash/toggleLineComment4.ts_0_336 | // If at least one line is not commented then comment all lines again.
//// //const a[| = 1;
//// const b = 2
//// //const c =|] 3;
////
//// ////const d[| = 4;
//// //const e = 5;
//// ////const e =|] 6;
verify.toggleLineComment(
`// //const a = 1;
//const b = 2
// //const c = 3;
//const d = 4;
const e = 5;
//const e = 6;`); | {
"end_byte": 336,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/toggleLineComment4.ts"
} |
TypeScript/tests/cases/fourslash/completionEntryForShorthandPropertyAssignment.ts_0_172 | ///<reference path="fourslash.ts" />
//// var person: {name:string; id:number} = {n/**/
verify.completions({ marker: "", includes: { name: "name", kind: "property" } });
| {
"end_byte": 172,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionEntryForShorthandPropertyAssignment.ts"
} |
TypeScript/tests/cases/fourslash/renameDestructuringAssignmentInFor.ts_0_636 | /// <reference path='fourslash.ts' />
////interface I {
//// [|[|{| "contextRangeIndex": 0 |}property1|]: number;|]
//// property2: string;
////}
////var elems: I[];
////
////var p2: number, [|[|{| "contextRangeIndex": 2 |}property1|]: number|];
////for ([|{ [|{| "contextRangeIndex": 4 |}property1|] } = elems[0]|]; p2 < 100; p2++) {
//// p2 = [|property1|]++;
////}
////for ([|{ [|{| "contextRangeIndex": 7 |}property1|]: p2 } = elems[0]|]; p2 < 100; p2++) {
////}
verify.noErrors();
const ranges = test.ranges();
const [r0Def, r0, r1Def, r1, r2Def, r2, r3, r4Def, r4] = ranges;
verify.baselineRename([r0, r4, r1, r2, r3]);
| {
"end_byte": 636,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameDestructuringAssignmentInFor.ts"
} |
TypeScript/tests/cases/fourslash/completionsPaths_pathMapping_parentDirectory.ts_0_471 | /// <reference path="fourslash.ts" />
// @Filename: /src/a.ts
////import { } from "foo//**/";
// @Filename: /oof/x.ts
////export const x = 0;
// @Filename: /tsconfig.json
////{
//// "compilerOptions": {
//// "baseUrl": "src",
//// "paths": {
//// "foo/*": ["../oof/*"]
//// }
//// }
////}
verify.completions({
marker: "",
exact: { name: "x", kind: "script", kindModifiers: ".ts" },
isNewIdentifierLocation: true,
});
| {
"end_byte": 471,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsPaths_pathMapping_parentDirectory.ts"
} |
TypeScript/tests/cases/fourslash/refactorKind_rewriteParametersToDestructured.ts_0_224 | /// <reference path='fourslash.ts' />
//// function(/*a*/a: number, b: number/*b*/): number {}
goTo.select("a", "b");
verify.refactorKindAvailable("refactor.rewrite",
[
"refactor.rewrite.parameters.toDestructured"
]);
| {
"end_byte": 224,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorKind_rewriteParametersToDestructured.ts"
} |
TypeScript/tests/cases/fourslash/formattingInDestructuring2.ts_0_314 | /// <reference path='fourslash.ts'/>
/////*1*/function drawText( { text = "", location: [x, y]= [0, 0], bold = false }) {
//// // Draw text
////}
format.document();
goTo.marker("1");
verify.currentLineContentIs("function drawText({ text = \"\", location: [x, y] = [0, 0], bold = false }) {"); | {
"end_byte": 314,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingInDestructuring2.ts"
} |
TypeScript/tests/cases/fourslash/renameJsPrototypeProperty02.ts_0_282 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: a.js
////function bar() {
////}
////[|bar.prototype.[|{| "contextRangeIndex": 0 |}x|] = 10;|]
////var t = new bar();
////[|t.[|{| "contextRangeIndex": 2 |}x|] = 11;|]
verify.baselineRenameAtRangesWithText("x");
| {
"end_byte": 282,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameJsPrototypeProperty02.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesAbstract03.ts_0_468 | /// <reference path='fourslash.ts' />
// Tests that we don't crash when encountering an abstract class in these scopes:
////function f() {
//// [|abstract|] class A {
//// [|abstract|] m(): void;
//// }
//// abstract class B {}
////}
////switch (0) {
//// case 0:
//// [|abstract|] class A { [|abstract|] m(): void; }
//// default:
//// [|abstract|] class B { [|abstract|] m(): void; }
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 468,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesAbstract03.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_import_sideEffect.ts_0_275 | /// <reference path='fourslash.ts' />
// Test that we leave it alone if the name is a keyword.
// @allowJs: true
// @target: esnext
// @Filename: /a.js
////require("foo");
verify.codeFix({
description: "Convert to ES module",
newFileContent: 'import "foo";',
});
| {
"end_byte": 275,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_import_sideEffect.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration1.ts_0_271 | /// <reference path='fourslash.ts' />
////foo();
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "foo"],
newFileContent:
`foo();
function foo() {
throw new Error("Function not implemented.");
}
`
});
| {
"end_byte": 271,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration1.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedFunction13.ts_3_311 | / <reference path="fourslash.ts" />
////interface MyType {
////}
////
////function foo(x: string, y: number, z: boolean) {
//// function bar(a: number, b: string = "hello", c: typeof x = "hello") {
//// var v = (p: /*1*/
//// }
////}
verify.completions({ marker: "1", includes: "MyType" });
| {
"end_byte": 311,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedFunction13.ts"
} |
TypeScript/tests/cases/fourslash/renamePrivateFields1.ts_0_227 | /// <reference path='fourslash.ts' />
////class Foo {
//// [|[|{| "contextRangeIndex": 0 |}#foo|] = 1;|]
////
//// getFoo() {
//// return this.[|#foo|];
//// }
////}
verify.baselineRenameAtRangesWithText("#foo");
| {
"end_byte": 227,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renamePrivateFields1.ts"
} |
TypeScript/tests/cases/fourslash/autoImportPackageJsonImports_js.ts_0_347 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @Filename: /package.json
//// {
//// "imports": {
//// "#thing": "./src/something.js"
//// }
//// }
// @Filename: /src/something.ts
//// export function something(name: string): any;
// @Filename: /a.ts
//// something/**/
verify.importFixModuleSpecifiers("", ["#thing"]);
| {
"end_byte": 347,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPackageJsonImports_js.ts"
} |
TypeScript/tests/cases/fourslash/referencesForClassParameter.ts_0_379 | /// <reference path='fourslash.ts'/>
// Reference to a class parameter.
////var p = 2;
////
////class p { }
////
////class foo {
//// constructor (/*1*/public /*2*/p: any) {
//// }
////
//// public f(p) {
//// this./*3*/p = p;
//// }
////
////}
////
////var n = new foo(undefined);
////n./*4*/p = null;
verify.baselineFindAllReferences('1', '2', '3', '4');
| {
"end_byte": 379,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForClassParameter.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsForVariableInImplementsClause01.ts_3_155 | / <reference path="fourslash.ts"/>
////var Base = class { };
////class C extends Base implements /**/Base { }
verify.baselineFindAllReferences("");
| {
"end_byte": 155,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForVariableInImplementsClause01.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsTripleSlash3.ts_0_551 | /// <reference path="fourslash.ts"/>
//// /// <reference path="./module.ts" types="node" />
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.jsxAttribute("types"),
c.operator("="),
c.jsxAttributeStringLiteralValue("\"node\""),
c.comment(" "),
c.punctuation("/>"));
| {
"end_byte": 551,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsTripleSlash3.ts"
} |
TypeScript/tests/cases/fourslash/indentationInAmdIife.ts_0_971 | /// <reference path="fourslash.ts"/>
//// function foo(a?,b?) { b(a); }
////
//// (foo)(1, function() {/*4_1*/
//// });
////
//// // No line-breaks in the expression part of the call expression
////
//// (foo)
//// (1, function () {/*8_0*/
//// });
//// (foo)(1,
//// function () {/*8_1*/
//// });
//// (foo)(1, function()
//// {/*4_2*/
//// });
////
//// // Contains line-breaks in the expression part of the call expression.
////
//// (
//// foo)(1, function () {/*8_4*/
//// });
//// (foo
//// )(1, function () {/*4_3*/
//// });
//// (foo
//// )
//// (1, function () {/*8_2*/
//// });
//// (foo
//// )(1,
//// function () {/*8_3*/
//// });
//// (foo
//// )(1, function()
//// {/*4_4*/
//// });
for (let i = 1; i < 5; ++i) {
goTo.marker(`4_${i}`);
edit.insertLine("");
verify.indentationIs(4);
}
for (let i = 1; i < 5; ++i) {
goTo.marker(`8_${i}`);
edit.insertLine("");
verify.indentationIs(8);
}
| {
"end_byte": 971,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indentationInAmdIife.ts"
} |
TypeScript/tests/cases/fourslash/completionListOutsideOfForLoop01.ts_0_133 | /// <reference path='fourslash.ts' />
////for (let i = 0; i < 10; i++) i;/*1*/
verify.completions({ marker: "1", excludes: "i" });
| {
"end_byte": 133,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListOutsideOfForLoop01.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsForObjectSpread.ts_0_326 | /// <reference path='fourslash.ts'/>
////interface A1 { readonly /*0*/a: string };
////interface A2 { /*1*/a?: number };
////let a1: A1;
////let a2: A2;
////let a12 = { ...a1, ...a2 };
////a12./*2*/a;
////a1./*3*/a;
const [r0Def, r0, r1Def, r1, r2, r3] = test.ranges();
verify.baselineFindAllReferences('0', '1', '2', '3')
| {
"end_byte": 326,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForObjectSpread.ts"
} |
TypeScript/tests/cases/fourslash/quickinfoIsConsistent.ts_0_258 | /// <reference path="fourslash.ts"/>
////declare var /*1*/f: (x: number) => number;
////function baz() {
//// var x = /*2*/f(3);
//// /*3*/f(3);
////}
for (const val of [1, 2, 3]) {
verify.quickInfoAt("" + val, "var f: (x: number) => number");
}
| {
"end_byte": 258,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickinfoIsConsistent.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingConstInForLoopWithObjectDestructuring2.ts_0_341 | /// <reference path='fourslash.ts' />
////for ({ x, y } of [{ x: 0, y: 1 }]) { }
////for ({ x } of [{ x: 0 }]) { }
verify.codeFixAll({
fixId: "addMissingConst",
fixAllDescription: "Add 'const' to all unresolved variables",
newFileContent:
`for (const { x, y } of [{ x: 0, y: 1 }]) { }
for (const { x } of [{ x: 0 }]) { }`
});
| {
"end_byte": 341,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingConstInForLoopWithObjectDestructuring2.ts"
} |
TypeScript/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts_0_476 | /// <reference path='fourslash.ts' />
const multiLineOffset = 11;
////class C {
//// /*0*/
//// [Symbol.iterator]() {
//// return undefined;
//// }
//// /*1*/
//// [1 + 2 + 3 + Math.rand()](x: number, y: string, z = true) { }
////}
verify.docCommentTemplateAt("0", multiLineOffset,
`/**
*
* @returns
*/`);
verify.docCommentTemplateAt("1", multiLineOffset,
`/**
*
* @param x
* @param y
* @param z
*/`);
| {
"end_byte": 476,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts"
} |
TypeScript/tests/cases/fourslash/unusedTypeParametersInClass3.ts_1_287 | /// <reference path='fourslash.ts' />
// @noUnusedParameters: true
////[|class greeter<X, Y, Z> |] {
//// public a: X;
//// public b: Z;
////}
verify.codeFix({
description: "Remove unused declaration for: 'Y'",
index: 0,
newRangeContent: "class greeter<X, Z> ",
});
| {
"end_byte": 287,
"start_byte": 1,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedTypeParametersInClass3.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsOverloadCall1.ts_1_733 | /// <reference path="fourslash.ts" />
//// interface Call {
//// (a: number): void
//// (b: number, c: number): void
//// new (d: number): Call
//// }
//// declare const call: Call;
//// call(1);
//// call(1, 2);
//// new call(1);
//// declare function foo(w: number): void
//// declare function foo(a: number, b: number): void;
//// declare function foo(a: number | undefined, b: number | undefined): void;
//// foo(1)
//// foo(1, 2)
//// class Class {
//// constructor(a: number);
//// constructor(b: number, c: number);
//// constructor(b: number, c?: number) { }
//// }
//// new Class(1)
//// new Class(1, 2)
verify.baselineInlayHints(undefined, {
includeInlayParameterNameHints: "literals",
});
| {
"end_byte": 733,
"start_byte": 1,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsOverloadCall1.ts"
} |
TypeScript/tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts_0_326 | /// <reference path="fourslash.ts" />
////const o = { x: [[|.|][||]/**/
const [r0, r1] = test.ranges();
verify.getSyntacticDiagnostics([
{ code: 1109, message: "Expression expected.", range: r0 },
{ code: 1003, message: "Identifier expected.", range: r1 },
]);
verify.completions({ marker: "", exact: undefined });
| {
"end_byte": 326,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts"
} |
TypeScript/tests/cases/fourslash/todoComments9.ts_0_112 | //// /*
//// [|TODO HACK|]
//// [|HACK TODO|]
//// */
verify.todoCommentsInCurrentFile(["TODO", "HACK"]); | {
"end_byte": 112,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/todoComments9.ts"
} |
TypeScript/tests/cases/fourslash/completionListAfterRegularExpressionLiteral04.ts_0_223 | /// <reference path="fourslash.ts" />
////let v = 100;
////let x = /absidey/ /**/
// Should not be blocked since there is a
// space separating us from the regex flags.
verify.completions({ marker: "", includes: "v" });
| {
"end_byte": 223,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAfterRegularExpressionLiteral04.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesAsyncAwait2.ts_0_233 | /// <reference path='fourslash.ts' />
////[|a/**/sync|] function f() {
//// [|await|] 100;
//// [|await|] [|await|] 200;
//// return [|await|] async function () {
//// await 300;
//// }
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 233,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesAsyncAwait2.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateSimple.ts_0_679 | /// <reference path='fourslash.ts' />
//// const foo = "/*x*/f/*y*/oobar rocks"
goTo.select("x", "y");
verify.not.refactorAvailable(ts.Diagnostics.Convert_to_template_string.message);
verify.refactorAvailableForTriggerReason("invoked", ts.Diagnostics.Convert_to_template_string.message);
verify.not.refactorAvailableForTriggerReason("implicit", ts.Diagnostics.Convert_to_template_string.message);
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
triggerReason: "invoked",
newContent:
`const foo = \`foobar rocks\``,
});
| {
"end_byte": 679,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateSimple.ts"
} |
TypeScript/tests/cases/fourslash/organizeImports10.ts_0_486 | /// <reference path="fourslash.ts" />
// @Filename: /module.ts
////import type { ZodType } from './declaration';
////
/////** Intended to be used in combination with {@link ZodType} */
////export function fun() { /* ... */ }
// @Filename: /declaration.ts
//// type ZodType = {};
//// export type { ZodType }
verify.organizeImports(`import type { ZodType } from './declaration';
/** Intended to be used in combination with {@link ZodType} */
export function fun() { /* ... */ }`
);
| {
"end_byte": 486,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImports10.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsPrimitiveJsDoc.ts_0_233 | // @noLib: true
/// <reference path='fourslash.ts'/>
/////**
//// * @param {/*1*/number} n
//// * @returns {/*2*/number}
//// */
////function f(n: /*3*/number): /*4*/number {}
verify.baselineFindAllReferences('1', '2', '3', '4');
| {
"end_byte": 233,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsPrimitiveJsDoc.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringVariableStatementArrayBindingPattern.ts_0_563 | /// <reference path='fourslash.ts' />
////declare var console: {
//// log(msg: string): void;
////}
////type Robot = [number, string, string];
////var robotA: Robot = [1, "mower", "mowing"];
////var robotB: Robot = [2, "trimmer", "trimming"];
////let [, nameA] = robotA;
////let [numberB] = robotB;
////let [numberA2, nameA2, skillA2] = robotA;
////let [numberC2] = [3, "edging", "Trimming edges"];
////let [numberC, nameC, skillC] = [3, "edging", "Trimming edges"];
////let [numberA3, ...robotAInfo] = robotA;
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 563,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringVariableStatementArrayBindingPattern.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoWithNestedDestructuredParameterInLambda.ts_0_441 | /// <reference path='fourslash.ts' />
// @filename: a.tsx
////import * as React from 'react';
////interface SomeInterface {
//// someBoolean: boolean,
//// someString: string;
////}
////interface SomeProps {
//// someProp: SomeInterface;
////}
////export const /*1*/SomeStatelessComponent = ({someProp: { someBoolean, someString}}: SomeProps) => (<div>{`${someBoolean}${someString}`});
goTo.marker("1");
verify.quickInfoExists();
| {
"end_byte": 441,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoWithNestedDestructuredParameterInLambda.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCorrectReturnValue18.ts_0_556 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// }
//// interface ElementAttributesProperty { props; }
//// }
//// class Comp { props: { t: () => number } }
//// var x = <Comp t={() => { 1 }} />;
verify.codeFixAvailable([
{ description: ts.Diagnostics.Add_a_return_statement.message },
{ description: ts.Diagnostics.Remove_braces_from_arrow_function_body.message },
{ description: `Infer type of 'props' from usage` }
]);
| {
"end_byte": 556,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCorrectReturnValue18.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCalledES2015Import13.ts_0_419 | /// <reference path='fourslash.ts' />
// @esModuleInterop: true
// @Filename: foo.d.ts
////declare function foo(): void;
////declare namespace foo {}
////export = foo;
// @Filename: index.ts
////import * as Foo from "./foo";
////[|new Foo()|];
goTo.file(1);
verify.codeFix({
description: `Use synthetic 'default' member.`,
newFileContent: `import * as Foo from "./foo";
new Foo.default();`,
index: 2,
});
| {
"end_byte": 419,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCalledES2015Import13.ts"
} |
TypeScript/tests/cases/fourslash/fixNaNEquality5.ts_0_234 | /// <reference path="fourslash.ts" />
////declare const x: any;
////[|if (NaN !== x[0][1]) {}|]
verify.codeFix({
index: 0,
description: "Use `!Number.isNaN(...)`.",
newRangeContent: "if (!Number.isNaN(x[0][1])) {}",
});
| {
"end_byte": 234,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixNaNEquality5.ts"
} |
TypeScript/tests/cases/fourslash/noQuickInfoForLabel.ts_0_201 | /// <reference path='fourslash.ts'/>
//// /*1*/label : while(true){
//// break /*2*/label;
//// }
goTo.marker('1');
verify.not.quickInfoExists();
goTo.marker('2');
verify.not.quickInfoExists();
| {
"end_byte": 201,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/noQuickInfoForLabel.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationForIn.ts_0_500 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_forIn.baseline
// @Filename: bpSpan_forIn.ts
////for (var x in String) {
//// WScript.Echo(x);
////}
////for (x in String) {
//// WScript.Echo(x);
////}
////for (var x2 in String)
////{
//// WScript.Echo(x2);
////}
////for (x in String)
////{
//// WScript.Echo(x);
////}
////var z = 10;
////for (x in function foo() {
//// return new String();
////}) {
//// z++;
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 500,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationForIn.ts"
} |
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax16.ts_0_172 | /// <reference path='fourslash.ts' />
//// var f: { [K in keyof number]: [|*|] };
verify.codeFix({
description: "Change '*' to 'any'",
newRangeContent: "any",
});
| {
"end_byte": 172,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax16.ts"
} |
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType11.ts_0_855 | /// <reference path='fourslash.ts' />
////interface F1 { x: number; y: number; }
////type T1 = [number, number];
////
////function /*a*/foo/*b*/(num: number) {
//// switch (num) {
//// case 1:
//// return { x: num, y: num } as F1;
//// case 2:
//// return [num, num] as T1;
//// default:
//// return num;
//// }
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Infer function return type",
actionName: "Infer function return type",
actionDescription: "Infer function return type",
newContent:
`interface F1 { x: number; y: number; }
type T1 = [number, number];
function foo(num: number): number | F1 | T1 {
switch (num) {
case 1:
return { x: num, y: num } as F1;
case 2:
return [num, num] as T1;
default:
return num;
}
}`
});
| {
"end_byte": 855,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType11.ts"
} |
TypeScript/tests/cases/fourslash/completionsTypeAssertionKeywords.ts_0_250 | /// <reference path='fourslash.ts'/>
////const a = {
//// b: 42 as /*0*/
////};
////
////1 as /*1*/
////
////const b = 42 as /*2*/
////
////var c = </*3*/>42
verify.completions({ marker: test.markers(), exact: completion.typeAssertionKeywords });
| {
"end_byte": 250,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsTypeAssertionKeywords.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingAwait_propertyAccess.ts_0_273 | /// <reference path="fourslash.ts" />
////async function fn(a: Promise<{ x: string }>) {
//// a.x;
////}
verify.codeFix({
description: ts.Diagnostics.Add_await.message,
index: 0,
newFileContent:
`async function fn(a: Promise<{ x: string }>) {
(await a).x;
}`
});
| {
"end_byte": 273,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAwait_propertyAccess.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionJSDoc.ts_0_769 | /// <reference path='fourslash.ts' />
/////**
//// * Return the boolean state of attribute from an element
//// * /*a*/@param/*b*/ el The source of the attributes.
//// * @param atty Name of the attribute or a string of candidate attribute names.
//// * @param def Default boolean value when attribute is undefined.
//// */
////export function /*c*/getBoolFromAttribute/*d*/(
//// /*e*//** inline JSDoc *//*f*/ attr: string | string[],
//// def: boolean = false): boolean { }
goTo.select("a", "b");
verify.not.refactorAvailable("Convert parameters to destructured object");
goTo.select("c", "d");
verify.refactorAvailable("Convert parameters to destructured object");
goTo.select("e", "f");
verify.refactorAvailable("Convert parameters to destructured object"); | {
"end_byte": 769,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionJSDoc.ts"
} |
TypeScript/tests/cases/fourslash/extract-method33.ts_0_818 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////export interface A {
//// x: number;
////}
// @Filename: /b.ts
////import { A } from "./a";
////export interface B<T> {
//// payload: T;
////}
////export const b: B<A> = {
//// payload: { x: 1 }
////}
// @Filename: /c.ts
////import { b } from "./b";
////
////function foo() {
//// const prop = b;
//// /*a*/console.log(prop);/*b*/
////}
goTo.file("/c.ts");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_1",
actionDescription: "Extract to function in module scope",
newContent:
`import { A } from "./a";
import { B, b } from "./b";
function foo() {
const prop = b;
/*RENAME*/newFunction(prop);
}
function newFunction(prop: B<A>) {
console.log(prop);
}
`
});
| {
"end_byte": 818,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method33.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionJsDocImportTag4.ts_0_243 | /// <reference path='fourslash.ts'/>
// @allowJS: true
// @checkJs: true
// @Filename: /b.ts
////export interface /*2*/A { }
// @Filename: /a.js
/////**
//// * @import { [|A/*1*/|] } from "./b";
//// */
verify.baselineGoToDefinition("1");
| {
"end_byte": 243,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionJsDocImportTag4.ts"
} |
TypeScript/tests/cases/fourslash/refactorOverloadListToSingleSignature7.ts_0_593 | /// <reference path='fourslash.ts' />
////interface A {
//// /*a*/new (): void;
//// new (a: string): void;
//// new (a: number, b: number): void;
//// new (...rest: symbol[]): void;/*b*/
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert overload list to single signature",
actionName: "Convert overload list to single signature",
actionDescription: ts.Diagnostics.Convert_overload_list_to_single_signature.message,
newContent: `interface A {
new(...args: [] | [a: string] | [a: number, b: number] | [...rest: symbol[]]): void;
}`,
});
| {
"end_byte": 593,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorOverloadListToSingleSignature7.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceMemberTypeAlias.ts_0_454 | /// <reference path='fourslash.ts' />
////type MyType = [string, number];
////interface I { x: MyType; test(a: MyType): void; }
////class C implements I {}
verify.codeFix({
description: "Implement interface 'I'",
newFileContent:
`type MyType = [string, number];
interface I { x: MyType; test(a: MyType): void; }
class C implements I {
x: MyType;
test(a: MyType): void {
throw new Error("Method not implemented.");
}
}`,
});
| {
"end_byte": 454,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceMemberTypeAlias.ts"
} |
TypeScript/tests/cases/fourslash/thisPredicateFunctionCompletions03.ts_0_1255 | /// <reference path="fourslash.ts" />
//// class RoyalGuard {
//// isLeader(): this is LeadGuard {
//// return this instanceof LeadGuard;
//// }
//// isFollower(): this is FollowerGuard {
//// return this instanceof FollowerGuard;
//// }
//// }
////
//// class LeadGuard extends RoyalGuard {
//// lead(): void {};
//// }
////
//// class FollowerGuard extends RoyalGuard {
//// follow(): void {};
//// }
////
//// let a: RoyalGuard = new FollowerGuard();
//// if (a.is/*1*/Leader()) {
//// a./*2*/;
//// }
//// else if (a.is/*3*/Follower()) {
//// a./*4*/;
//// }
////
//// interface GuardInterface {
//// isLeader(): this is LeadGuard;
//// isFollower(): this is FollowerGuard;
//// }
////
//// let b: GuardInterface;
//// if (b.is/*5*/Leader()) {
//// b./*6*/;
//// }
//// else if (b.is/*7*/Follower()) {
//// b./*8*/;
//// }
////
//// let leader/*13*/Status = a.isLeader();
//// function isLeaderGuard(g: RoyalGuard) {
//// return g.isLeader();
//// }
//// let checked/*14*/LeaderStatus = isLeader/*15*/Guard(a);
verify.completions(
{ marker: ["2", "6"], unsorted: ["lead", "isLeader", "isFollower"] },
{ marker: ["4", "8"], unsorted: ["follow", "isLeader", "isFollower"] },
);
| {
"end_byte": 1255,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/thisPredicateFunctionCompletions03.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixReExport.ts_0_353 | /// <reference path='fourslash.ts' />
// Test that we are not fooled by a re-export existing in the file already
// @Filename: /a.ts
////export const x = 0";
// @Filename: /b.ts
////[|export { x } from "./a";
////x;|]
goTo.file("/b.ts");
verify.rangeAfterCodeFix(`import { x } from "./a";
export { x } from "./a";
x;`, /*includeWhiteSpace*/ true);
| {
"end_byte": 353,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixReExport.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixUMDGlobal0.ts_0_385 | /// <reference path="fourslash.ts" />
// @AllowSyntheticDefaultImports: false
// @Module: es2015
// @Filename: a/f1.ts
//// [|export function test() { };
//// bar1/*0*/.bar;|]
// @Filename: a/foo.d.ts
//// export declare function bar(): number;
//// export as namespace bar1;
verify.importFixAtPosition([
`import * as bar1 from "./foo";
export function test() { };
bar1.bar;`
]); | {
"end_byte": 385,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixUMDGlobal0.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportNodeModules0.ts_0_387 | /// <reference path="fourslash.ts" />
//// [|f1/*0*/();|]
// @Filename: ../package.json
//// { "dependencies": { "fake-module": "latest" } }
// @Filename: ../node_modules/fake-module/index.ts
//// export var v1 = 5;
//// export function f1();
// @Filename: ../node_modules/fake-module/package.json
//// {}
verify.importFixAtPosition([
`import { f1 } from "fake-module";
f1();`
]);
| {
"end_byte": 387,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportNodeModules0.ts"
} |
TypeScript/tests/cases/fourslash/referencesForLabel3.ts_0_175 | /// <reference path='fourslash.ts'/>
// References to unused label
/////*1*/label: while (true) {
//// var label = "label";
////}
verify.baselineFindAllReferences('1');
| {
"end_byte": 175,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForLabel3.ts"
} |
TypeScript/tests/cases/fourslash/completionListInstanceProtectedMembers4.ts_0_689 | /// <reference path='fourslash.ts'/>
////class Base {
//// private privateMethod() { }
//// private privateProperty;
////
//// protected protectedMethod() { }
//// protected protectedProperty;
////
//// public publicMethod() { }
//// public publicProperty;
////
//// protected protectedOverriddenMethod() { }
//// protected protectedOverriddenProperty;
////}
////
////class C1 extends Base {
//// public protectedOverriddenMethod() { }
//// public protectedOverriddenProperty;
////}
////
//// var c: C1;
//// c./*1*/
verify.completions({ marker: "1", exact: ["protectedOverriddenMethod", "protectedOverriddenProperty", "publicMethod", "publicProperty"] });
| {
"end_byte": 689,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInstanceProtectedMembers4.ts"
} |
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class5.ts_0_370 | /// <reference path='fourslash.ts' />
// @allowNonTsExtensions: true
// @Filename: foo.js
////function Foo() {
//// this.a = 0;
////}
////Foo.prototype["a b c"] = function () {
////}
verify.codeFix({
description: "Convert function to an ES2015 class",
newFileContent:
`class Foo {
constructor() {
this.a = 0;
}
"a b c"() {
}
}
`
});
| {
"end_byte": 370,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertFunctionToEs6Class5.ts"
} |
TypeScript/tests/cases/fourslash/renameUMDModuleAlias1.ts_3_350 | / <reference path='fourslash.ts' />
// @Filename: 0.d.ts
//// export function doThing(): string;
//// export function doTheOtherThing(): void;
//// [|export as namespace [|{| "contextRangeIndex": 0 |}myLib|];|]
// @Filename: 1.ts
//// /// <reference path="0.d.ts" />
//// [|myLib|].doThing();
verify.baselineRenameAtRangesWithText("myLib");
| {
"end_byte": 350,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameUMDModuleAlias1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_importSpecifier4.ts_0_300 | /// <reference path="fourslash.ts" />
// @noUnusedLocals: true
////[|import {
//// a,
//// b,
//// c,
////} from "fs";|]
////
////a;
////c;
verify.codeFix({
index: 0,
description: "Remove unused declaration for: 'b'",
newRangeContent:
`import {
a,
c,
} from "fs";`
});
| {
"end_byte": 300,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_importSpecifier4.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringParameterNestedObjectBindingPatternDefaultValues.ts_0_1451 | /// <reference path='fourslash.ts' />
////declare var console: {
//// log(msg: string): void;
////}
////interface Robot {
//// name: string;
//// skills: {
//// primary?: string;
//// secondary?: string;
//// };
////}
////var robotA: Robot = { name: "mower", skills: { primary: "mowing", secondary: "none" } };
////function foo1(
//// {
//// skills: {
//// primary: primaryA = "primary",
//// secondary: secondaryA = "secondary"
//// } = { primary: "SomeSkill", secondary: "someSkill" }
//// }: Robot = robotA) {
//// console.log(primaryA);
////}
////function foo2(
//// {
//// name: nameC = "name",
//// skills: {
//// primary: primaryB = "primary",
//// secondary: secondaryB = "secondary"
//// } = { primary: "SomeSkill", secondary: "someSkill" }
//// }: Robot = robotA) {
//// console.log(secondaryB);
////}
////function foo3({ skills = { primary: "SomeSkill", secondary: "someSkill" } }: Robot = robotA) {
//// console.log(skills.primary);
////}
////foo1(robotA);
////foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } });
////foo2(robotA);
////foo2({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } });
////foo3(robotA);
////foo3({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } });
verify.baselineCurrentFileBreakpointLocations();
| {
"end_byte": 1451,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringParameterNestedObjectBindingPatternDefaultValues.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesTryCatchFinally4.ts_0_298 | /// <reference path='fourslash.ts' />
////try/*1*/ {
//// try/*2*/ {
//// }
//// catch/*3*/ (x) {
//// }
////
//// try/*4*/ {
//// }
//// finally/*5*/ {/*8*/
//// }
////}
////catch/*6*/ (e) {
////}
////finally/*7*/ {
////}
verify.baselineDocumentHighlights(test.markers()); | {
"end_byte": 298,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesTryCatchFinally4.ts"
} |
TypeScript/tests/cases/fourslash/editClearsJsDocCache.ts_0_304 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: /a.js
/////** @type {/*type*/number} */
////let /*x*/x;
verify.quickInfoAt("x", "let x: number");
goTo.marker("type");
edit.replace(test.markers()[0].position, "number".length, "string");
verify.quickInfoAt("x", "let x: string");
| {
"end_byte": 304,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/editClearsJsDocCache.ts"
} |
TypeScript/tests/cases/fourslash/autoImportCompletionExportListAugmentation3.ts_0_1247 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @Filename: /node_modules/@sapphire/pieces/index.d.ts
//// export interface Container {
//// stores: unknown;
//// }
////
//// declare class Piece {
//// container: Container;
//// }
////
//// export { Piece };
// @FileName: /augmentation.ts
//// declare module "@sapphire/pieces" {
//// interface Container {
//// client: unknown;
//// }
//// }
// @Filename: /index.ts
//// import { Piece } from "@sapphire/pieces";
//// class FullPiece extends Piece {
//// /*1*/
//// }
const preferences = {
includeCompletionsWithClassMemberSnippets: true,
includeCompletionsWithInsertText: true,
};
verify.completions({
marker: "1",
includes: [
{
name: "container",
insertText: "container: Container;",
filterText: "container",
hasAction: true,
source: "ClassMemberSnippet/",
},
],
preferences,
isNewIdentifierLocation: true,
});
verify.applyCodeActionFromCompletion("1", {
name: "container",
source: "ClassMemberSnippet/",
description: `Includes imports of types referenced by 'container'`,
newFileContent: `import { Container, Piece } from "@sapphire/pieces";
class FullPiece extends Piece {
}`,
preferences,
}); | {
"end_byte": 1247,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportCompletionExportListAugmentation3.ts"
} |
TypeScript/tests/cases/fourslash/completionListInComments.ts_0_186 | /// <reference path='fourslash.ts' />
////var foo = '';
////( // f/**/
// Completion list should not be available within comments
verify.completions({ marker: "", exact: undefined });
| {
"end_byte": 186,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInComments.ts"
} |
TypeScript/tests/cases/fourslash/importStatementCompletions_quotes.ts_0_688 | /// <reference path="fourslash.ts" />
// @Filename: /mod.ts
//// export const foo = 0;
// @Filename: /single.ts
//// import * as fs from 'fs';
//// [|import f/**/|]
verify.completions({
isNewIdentifierLocation: true,
marker: "",
exact: [{
name: "foo",
source: "./mod",
insertText: `import { foo$1 } from './mod';`, // <-- single quotes
isSnippet: true,
replacementSpan: test.ranges()[0],
sourceDisplay: "./mod",
}, {
name: "type",
sortText: completion.SortText.GlobalsOrKeywords,
}],
preferences: {
includeCompletionsForImportStatements: true,
includeInsertTextCompletions: true,
includeCompletionsWithSnippetText: true,
}
});
| {
"end_byte": 688,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importStatementCompletions_quotes.ts"
} |
TypeScript/tests/cases/fourslash/tsxGoToDefinitionClasses.ts_0_512 | /// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements { }
//// interface ElementAttributesProperty { props; }
//// }
//// class /*ct*/MyClass {
//// props: {
//// /*pt*/foo: string;
//// }
//// }
//// var x = <[|My/*c*/Class|] />;
//// var y = <MyClass [|f/*p*/oo|]= 'hello' />;
//// var z = <[|MyCl/*w*/ass|] wrong= 'hello' />;
verify.baselineGoToDefinition(
"c",
"p",
"w",
);
| {
"end_byte": 512,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxGoToDefinitionClasses.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction29.ts_0_374 | /// <reference path='fourslash.ts' />
////const a = /*a*/()/*b*/ => {
//// return {} as {}
////};
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Add or remove braces in an arrow function",
actionName: "Remove braces from arrow function",
actionDescription: "Remove braces from arrow function",
newContent: `const a = () => ({} as {});`,
});
| {
"end_byte": 374,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction29.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddConvertToUnknownForNonOverlappingTypes1.ts_0_193 | /// <reference path='fourslash.ts' />
////0 as string
verify.codeFix({
description: "Add 'unknown' conversion for non-overlapping types",
newFileContent: `0 as unknown as string`
});
| {
"end_byte": 193,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddConvertToUnknownForNonOverlappingTypes1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax22.ts_0_168 | /// <reference path='fourslash.ts' />
//// var index: { [s: string]: [|*|] };
verify.codeFix({
description: "Change '*' to 'any'",
newRangeContent: "any",
});
| {
"end_byte": 168,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax22.ts"
} |
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType25.ts_0_428 | /// <reference path='fourslash.ts' />
////function /*a*//*b*/f() {
//// return {
//// [-1]: 0
//// } as const
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Infer function return type",
actionName: "Infer function return type",
actionDescription: "Infer function return type",
newContent:
`function f(): { readonly [-1]: 0; } {
return {
[-1]: 0
} as const
}`
});
| {
"end_byte": 428,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType25.ts"
} |
TypeScript/tests/cases/fourslash/completionListObjectMembersInTypeLocationWithTypeof.ts_0_579 | /// <reference path="fourslash.ts" />
// @strict: true
// repro from https://github.com/microsoft/TypeScript/issues/54480
//// const languageService = { getCompletions() {} }
//// type A = Parameters<typeof languageService./*1*/>
////
//// declare const obj: { dance: () => {} } | undefined
//// type B = Parameters<typeof obj./*2*/>
verify.completions({
marker: "1",
includes: [{ name: "getCompletions", text: "(method) getCompletions(): void" }],
});
verify.completions({
marker: "2",
includes: [{ name: "dance", text: "(property) dance: () => {}" }],
});
| {
"end_byte": 579,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListObjectMembersInTypeLocationWithTypeof.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_notInCommonjsProject_yesIfSomeEsModule.ts_0_248 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @Filename: /a.js
////exports.x = 0;
// @Filename: /b.js
////export const y = 0;
verify.codeFix({
description: "Convert to ES module",
newFileContent: "export const x = 0;",
});
| {
"end_byte": 248,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_notInCommonjsProject_yesIfSomeEsModule.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.