_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/extract-method_jsxElement1.ts_0_591 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: a.tsx
////function Foo() {
//// return (
//// <div>
//// /*a*/<span></span>/*b*/
//// </div>
//// );
////}
goTo.file("a.tsx");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_1",
actionDescription: "Extract to function in global scope",
newContent:
`function Foo() {
return (
<div>
{newFunction()}
</div>
);
}
function /*RENAME*/newFunction() {
return <span></span>;
}
`
});
| {
"end_byte": 591,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method_jsxElement1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpellingPrivatePropertyName.ts_0_514 | /// <reference path='fourslash.ts' />
////class A {
//// #foo: number;
//// constructor() {
//// [|this.foo = 1;|]
//// }
////}
verify.codeFixAvailable([
{ description: "Change spelling to '#foo'" },
{ description: "Declare property 'foo'" },
{ description: "Add index signature for property 'foo'" },
{ description: "Remove unused declaration for: '#foo'" },
]);
verify.codeFix({
index: 0,
description: "Change spelling to '#foo'",
newRangeContent: "this.#foo = 1;"
});
| {
"end_byte": 514,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingPrivatePropertyName.ts"
} |
TypeScript/tests/cases/fourslash/completionsAfterLessThanToken.ts_0_232 | /// <reference path="fourslash.ts" />
//// function f() {
//// const k: Record</**/
//// }
goTo.marker();
verify.completions({
includes: [
{ name: "string", sortText: completion.SortText.GlobalsOrKeywords }
]
});
| {
"end_byte": 232,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsAfterLessThanToken.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_renameWithinTransformedExports.ts_0_746 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @target: esnext
// @Filename: test.js
//// var Q = require("q");
////
//// module.exports = {
//// fn: function () {
//// var deferred = Q.defer();
//// },
//// method() {
//// Q.defer();
//// },
//// Klass: class {
//// prop = Q.defer();
//// method() {
//// Q.defer();
//// }
//// }
//// }
verify.codeFix({
index: 2,
description: "Convert to ES module",
newFileContent:
`import { defer } from "q";
export function fn() {
var deferred = defer();
}
export function method() {
defer();
}
export class Klass {
prop = defer();
method() {
defer();
}
}`,
});
| {
"end_byte": 746,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_renameWithinTransformedExports.ts"
} |
TypeScript/tests/cases/fourslash/formatAfterPasteInString.ts_0_208 | /// <reference path='fourslash.ts' />
//// /*2*/const x = f('aa/*1*/a').x()
goTo.marker('1');
edit.paste("bb");
format.document();
goTo.marker('2');
verify.currentLineContentIs("const x = f('aabba').x()");
| {
"end_byte": 208,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatAfterPasteInString.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnFunctionPropertyReturnedFromGenericFunction1.ts_0_354 | /// <reference path="fourslash.ts" />
//// function createProps<T>(t: T) {
//// function getProps() {}
//// function createVariants() {}
////
//// getProps.createVariants = createVariants;
//// return getProps;
//// }
////
//// createProps({})./**/createVariants();
verify.quickInfoAt("", "(property) getProps<{}>.createVariants: () => void");
| {
"end_byte": 354,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnFunctionPropertyReturnedFromGenericFunction1.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration_inheritance.ts_0_275 | /// <reference path='fourslash.ts'/>
////class C {
//// constructor(public /*0*/x: string) {
//// /*1*/x;
//// }
////}
////class D extends C {
//// constructor(public /*2*/x: string) {
//// super(/*3*/x);
//// }
////}
verify.baselineFindAllReferences('0', '1', '2', '3')
| {
"end_byte": 275,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration_inheritance.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationWhile.ts_0_407 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_while.baseline
// @Filename: bpSpan_while.ts
////var a = 10;
////while (a == 10) {
//// a++;
////}
////while (a == 10)
////{
//// a++;
////}
////while (a == 10) a++;
////while (a == 10)
//// a++;
////while ((function () {
//// return 30 * a;
////})() !== a) {
//// a--;
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 407,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationWhile.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts_0_694 | /// <reference path='fourslash.ts' />
// Should give completions for all dependencies in package.json
// @Filename: tests/test0.ts
//// import * as foo1 from "m/*import_as0*/
//// import foo2 = require("m/*import_equals0*/
//// var foo3 = require("m/*require0*/
// @Filename: package.json
//// {
//// "dependencies": { "module": "latest" },
//// "devDependencies": { "dev-module": "latest" },
//// "optionalDependencies": { "optional-module": "latest" },
//// "peerDependencies": { "peer-module": "latest" }
//// }
verify.completions({
marker: test.markers(),
exact: ["module", "dev-module", "peer-module", "optional-module"],
isNewIdentifierLocation: true,
});
| {
"end_byte": 694,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_default_addToNamedImports.ts_0_748 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export default function foo() {}
////export const x = 0;
// @Filename: /b.ts
////import { x } from "./a";
////f/**/;
verify.completions({
marker: "",
includes: {
name: "foo",
source: "/a",
sourceDisplay: "./a",
text: "function foo(): void",
kind: "function",
kindModifiers: "export",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences: { includeCompletionsForModuleExports: true },
});
verify.applyCodeActionFromCompletion("", {
name: "foo",
source: "/a",
description: `Update import from "./a"`,
newFileContent: `import foo, { x } from "./a";
f;`,
});
| {
"end_byte": 748,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_default_addToNamedImports.ts"
} |
TypeScript/tests/cases/fourslash/codeFixTopLevelAwait_target_compatibleCompilerOptionsInTsConfig.ts_0_308 | /// <reference path="fourslash.ts" />
// @filename: /dir/a.ts
////declare const p: Promise<number>;
////await p;
////export {};
// @filename: /dir/tsconfig.json
////{
//// "compilerOptions": {
//// "target": "es2017",
//// "module": "esnext"
//// }
////}
verify.not.codeFixAvailable();
| {
"end_byte": 308,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelAwait_target_compatibleCompilerOptionsInTsConfig.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization16.ts_0_379 | /// <reference path='fourslash.ts' />
// @strict: true
// @checkJs: true
// @allowJs: true
// @filename: a.js
////class Foo {
//// /**
//// * @type {string}
//// */
//// a;
////}
verify.codeFix({
description: `Add 'undefined' type to property 'a'`,
newFileContent:
`class Foo {
/**
* @type {string | undefined}
*/
a;
}`,
index: 2
})
| {
"end_byte": 379,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization16.ts"
} |
TypeScript/tests/cases/fourslash/extract-const10.ts_0_428 | /// <reference path='fourslash.ts' />
// @filename: foo.ts
////function foo() {
//// /*a*/const a = [1]/*b*/;
//// return a;
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "constant_scope_1",
actionDescription: "Extract to constant in global scope",
newContent:
`const newLocal = [1];
function foo() {
const a = /*RENAME*/newLocal;
return a;
}`
});
| {
"end_byte": 428,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const10.ts"
} |
TypeScript/tests/cases/fourslash/contextuallyTypedFunctionExpressionGeneric1.ts_0_496 | /// <reference path='fourslash.ts'/>
////interface Comparable<T> {
//// compareTo(other: T): T;
////}
////interface Comparer {
//// <T extends Comparable<T>>(x: T, y: T): T;
////}
////var max2: Comparer = (x/*1*/x, y/*2*/y) => { return x/*3*/x.compareTo(y/*4*/y) };
verify.quickInfos({
1: "(parameter) xx: T extends Comparable<T>",
2: "(parameter) yy: T extends Comparable<T>",
3: "(parameter) xx: T extends Comparable<T>",
4: "(parameter) yy: T extends Comparable<T>"
});
| {
"end_byte": 496,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/contextuallyTypedFunctionExpressionGeneric1.ts"
} |
TypeScript/tests/cases/fourslash/organizeImportsReactJsxDev.ts_0_790 | /// <reference path='fourslash.ts' />
// @allowSyntheticDefaultImports: true
// @moduleResolution: node
// @noUnusedLocals: true
// @target: es2018
// @jsx: react-jsxdev
// @filename: test.tsx
////import React from 'react';
////export default () => <div></div>
// @filename: node_modules/react/package.json
////{
//// "name": "react",
//// "types": "index.d.ts",
////}
// @filename: node_modules/react/index.d.ts
////export = React;
////declare namespace JSX {
//// interface IntrinsicElements { [x: string]: any; }
////}
////declare namespace React {}
// @filename: node_modules/react/jsx-runtime.d.ts
////import './';
// @filename: node_modules/react/jsx-dev-runtime.d.ts
////import './';
goTo.file("test.tsx");
verify.organizeImports(`export default () => <div></div>`);
| {
"end_byte": 790,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsReactJsxDev.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts_0_2371 | /// <reference path='fourslash.ts' />
// @lib: es2017
////namespace N {
//// /**enum prefix */
//// export enum /**enum identifier prefix */ E /**open-brace prefix*/ {
//// /* literal prefix */ a /** comma prefix */,
//// /* literal prefix */ b /** comma prefix */,
//// /* literal prefix */ c
//// /** close brace prefix */ }
//// /** interface prefix */
//// export interface /**interface name prefix */ I /**open-brace prefix*/ {
//// /** property prefix */ a /** colon prefix */: /** enum literal prefix 1*/ E /** dot prefix */. /** enum literal prefix 2*/a;
//// /** property prefix */ b /** colon prefix */: /** enum prefix */ E;
//// /**method signature prefix */foo /**open angle prefix */< /**type parameter name prefix */ X /** closing angle prefix */> /**open paren prefix */(/** parameter prefix */ a/** colon prefix */: /** parameter type prefix */ X /** close paren prefix */) /** colon prefix */: /** return type prefix */ string /** semicolon prefix */;
//// /**close-brace prefix*/ }
/////**close-brace prefix*/ }
////class C implements N.I {}
verify.codeFix({
description: "Implement interface 'N.I'",
newFileContent:
`namespace N {
/**enum prefix */
export enum /**enum identifier prefix */ E /**open-brace prefix*/ {
/* literal prefix */ a /** comma prefix */,
/* literal prefix */ b /** comma prefix */,
/* literal prefix */ c
/** close brace prefix */ }
/** interface prefix */
export interface /**interface name prefix */ I /**open-brace prefix*/ {
/** property prefix */ a /** colon prefix */: /** enum literal prefix 1*/ E /** dot prefix */. /** enum literal prefix 2*/a;
/** property prefix */ b /** colon prefix */: /** enum prefix */ E;
/**method signature prefix */foo /**open angle prefix */< /**type parameter name prefix */ X /** closing angle prefix */> /**open paren prefix */(/** parameter prefix */ a/** colon prefix */: /** parameter type prefix */ X /** close paren prefix */) /** colon prefix */: /** return type prefix */ string /** semicolon prefix */;
/**close-brace prefix*/ }
/**close-brace prefix*/ }
class C implements N.I {
a: N.E.a;
b: N.E;
foo<X /** closing angle prefix */>(a: X /** close paren prefix */): string /** semicolon prefix */ {
throw new Error("Method not implemented.");
}
}`,
});
| {
"end_byte": 2371,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts"
} |
TypeScript/tests/cases/fourslash/toggleMultilineComment4.ts_0_417 | // This is an edgecase. The string contains a multiline comment syntax but it is a string
// and not actually a comment. When toggling it doesn't get escaped or appended comments.
// The result would be a portion of the selection to be "not commented".
//// /*let s[|omeLongVa*/riable = "Some other /*long th*/in|]g";
verify.toggleMultilineComment(`/*let s*//*omeLongVa*//*riable = "Some other /*long th*/in*/g";`); | {
"end_byte": 417,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/toggleMultilineComment4.ts"
} |
TypeScript/tests/cases/fourslash/unusedAmbient1.ts_0_711 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export {};
////declare var [|a|]: string;
// @Filename: /b.d.ts
////declare module 'b' {
//// var [|b|]: string;
//// export {};
////}
goTo.file("/a.ts");
verify.getSuggestionDiagnostics([{
code: ts.Diagnostics._0_is_declared_but_its_value_is_never_read.code,
message: "'a' is declared but its value is never read.",
reportsUnnecessary: true
}]);
verify.getSemanticDiagnostics([]);
goTo.file("/b.d.ts");
verify.getSuggestionDiagnostics([{
code: ts.Diagnostics._0_is_declared_but_its_value_is_never_read.code,
message: "'b' is declared but its value is never read.",
reportsUnnecessary: true
}]);
verify.getSemanticDiagnostics([]);
| {
"end_byte": 711,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedAmbient1.ts"
} |
TypeScript/tests/cases/fourslash/autoImportTypeImport2.ts_0_1103 | /// <reference path="fourslash.ts" />
// @verbatimModuleSyntax: true
// @target: esnext
// @Filename: /foo.ts
//// export const A = 1;
//// export type B = { x: number };
//// export type C = 1;
//// export class D = { y: string };
// @Filename: /test.ts
//// import { A, type C, D } from './foo';
//// const b: B/**/ | C;
//// console.log(A, D);
goTo.marker("");
// importFixes should only place the import in sorted position if the existing imports are sorted as specified,
// otherwise the import should be placed at the end
verify.importFixAtPosition([
`import { A, type B, type C, D } from './foo';
const b: B | C;
console.log(A, D);`],
/*errorCode*/ undefined,
{ organizeImportsTypeOrder: "inline" }
);
verify.importFixAtPosition([
`import { A, type C, D, type B } from './foo';
const b: B | C;
console.log(A, D);`],
/*errorCode*/ undefined,
{ organizeImportsTypeOrder: "last" }
);
verify.importFixAtPosition([
`import { A, type C, D, type B } from './foo';
const b: B | C;
console.log(A, D);`],
/*errorCode*/ undefined,
{ organizeImportsTypeOrder: "first" }
); | {
"end_byte": 1103,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportTypeImport2.ts"
} |
TypeScript/tests/cases/fourslash/tsxCompletion11.ts_0_274 | /// <reference path='fourslash.ts' />
//@module: commonjs
//@jsx: preserve
//@Filename: exporter.tsx
//// export class Thing { }
//@Filename: file.tsx
//// import {Thing} from './exporter';
//// var x1 = <div></**/
verify.completions({ marker: "", includes: "Thing" });
| {
"end_byte": 274,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletion11.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives4.ts_0_173 | /// <reference path='fourslash.ts' />
//// function foo(strs, ...rest) {
//// }
////
//// /*1*/fo/*2*/o /*3*/``/*4*/ /*5*/
verify.noSignatureHelp(...test.markerNames());
| {
"end_byte": 173,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives4.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnObjectLiteralWithOnlySetter.ts_0_598 | /// <reference path='fourslash.ts' />
////function /*1*/makePoint(x: number) {
//// return {
//// b: 10,
//// set x(a: number) { this.b = a; }
//// };
////};
////var /*3*/point = makePoint(2);
////point./*2*/x = 30;
verify.completions({
marker: "2",
exact: [
{ name: "b", text: "(property) b: number" },
{ name: "x", text: "(property) x: number" },
],
});
verify.quickInfos({
1: "function makePoint(x: number): {\n b: number;\n x: number;\n}",
2: "(property) x: number",
3: "var point: {\n b: number;\n x: number;\n}",
});
| {
"end_byte": 598,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnObjectLiteralWithOnlySetter.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports4.ts_0_456 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
////const a = 42;
////const b = 42;
////export class C {
//// method() { return a + b };
////}
verify.codeFixAvailable([
{ description: "Add return type 'number'" },
]);
verify.codeFix({
description: "Add return type 'number'",
index: 0,
newFileContent:
`const a = 42;
const b = 42;
export class C {
method(): number { return a + b };
}`,
});
| {
"end_byte": 456,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports4.ts"
} |
TypeScript/tests/cases/fourslash/interfaceRecursiveInheritanceErrors1.ts_0_178 | /// <reference path="fourslash.ts" />
////interface i8 extends i9 { }
////interface i9 /*1*/extends i8{ }
edit.disableFormatting();
goTo.marker('1');
edit.deleteAtCaret(11);
| {
"end_byte": 178,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/interfaceRecursiveInheritanceErrors1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports46-decorators-experimental.ts_0_2255 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
// @experimentalDecorators: true
// @Filename: /code.ts
//// function classDecorator<T extends Function>() { return (target: T) => target; }
//// function methodDecorator() { return (target: any, key: string, descriptor: PropertyDescriptor) => descriptor;}
//// function parameterDecorator() { return (target: any, key: string, idx: number) => {};}
//// function getterDecorator() { return (target: any, key: string) => {}; }
//// function setterDecorator() { return (target: any, key: string) => {}; }
//// function fieldDecorator() { return (target: any, key: string) => {}; }
//// function foo() { return 42; }
////
//// @classDecorator()
//// export class A {
//// @methodDecorator()
//// sum(...args: number[]) {
//// return args.reduce((a, b) => a + b, 0);
//// }
//// getSelf() {
//// return this;
//// }
//// passParameter(@parameterDecorator() param = foo()) {}
//// @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>() { return (target: T) => target; }
function methodDecorator() { return (target: any, key: string, descriptor: PropertyDescriptor) => descriptor;}
function parameterDecorator() { return (target: any, key: string, idx: number) => {};}
function getterDecorator() { return (target: any, key: string) => {}; }
function setterDecorator() { return (target: any, key: string) => {}; }
function fieldDecorator() { return (target: any, key: string) => {}; }
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;
}
passParameter(@parameterDecorator() param: number = foo()): void {}
@getterDecorator()
get a(): number {
return foo();
}
@setterDecorator()
set a(value) {}
@fieldDecorator() classProp: number = foo();
}`
});
| {
"end_byte": 2255,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports46-decorators-experimental.ts"
} |
TypeScript/tests/cases/fourslash/fixExactOptionalUnassignableProperties7.ts_0_474 | /// <reference path='fourslash.ts'/>
// @strictNullChecks: true
// @exactOptionalPropertyTypes: true
// @Filename: fixExactOptionalUnassignableProperties6.ts
// based on snapshotterInjected.ts in microsoft/playwright
//// class Feh {
//// _requestFinished(error?: string) {
//// this._finishedPromiseCallback({ error/**/ });
//// }
//// private _finishedPromiseCallback: (arg: { error?: string }) => void = () => {};
//// }
verify.codeFixAvailable([ ]); | {
"end_byte": 474,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixExactOptionalUnassignableProperties7.ts"
} |
TypeScript/tests/cases/fourslash/unusedMethodInClass1.ts_0_257 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////class greeter {
//// private function1() {
//// }
////}
verify.codeFix({
description: `Remove unused declaration for: 'function1'`,
newFileContent: "class greeter {\n}",
});
| {
"end_byte": 257,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedMethodInClass1.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsForDefaultExport01.ts_0_248 | /// <reference path='fourslash.ts'/>
/////*1*/export default class /*2*/DefaultExportedClass {
////}
////
////var x: /*3*/DefaultExportedClass;
////
////var y = new /*4*/DefaultExportedClass;
verify.baselineFindAllReferences('1', '2', '3', '4');
| {
"end_byte": 248,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForDefaultExport01.ts"
} |
TypeScript/tests/cases/fourslash/completionListInTypeLiteralInTypeParameter1.ts_0_485 | /// <reference path="fourslash.ts" />
////interface Foo {
//// one: string;
//// two: number;
//// 333: symbol;
//// '4four': boolean;
//// '5 five': object;
//// number: string;
//// Object: number;
////}
////
////interface Bar<T extends Foo> {
//// foo: T;
////}
////
////var foobar: Bar<{/**/
verify.completions({
marker: "",
unsorted: ["one", "two", "\"333\"", "\"4four\"", "\"5 five\"", "number", "Object"],
isNewIdentifierLocation: true
});
| {
"end_byte": 485,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInTypeLiteralInTypeParameter1.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsJsDocTemplateTag_class_js.ts_0_306 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: /a.js
// Both uses of T should be referenced.
/////** @template /*1*/T */
////class C {
//// constructor() {
//// /** @type {/*2*/T} */
//// this.x = null;
//// }
////}
verify.baselineFindAllReferences('1', '2');
| {
"end_byte": 306,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsJsDocTemplateTag_class_js.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts_0_738 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export default function foo() {}
// @Filename: /b.ts
////import f_o_o from "./a";
////f/**/;
verify.completions({
marker: "",
includes: {
name: "foo",
source: "/a",
sourceDisplay: "./a",
text: "function foo(): void",
kind: "function",
kindModifiers: "export",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences: { includeCompletionsForModuleExports: true },
});
verify.applyCodeActionFromCompletion("", {
name: "foo",
source: "/a",
description: `Add import from "./a"`,
newFileContent: `import foo from "./a";
import f_o_o from "./a";
f;`,
});
| {
"end_byte": 738,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts"
} |
TypeScript/tests/cases/fourslash/completionsCombineOverloads.ts_0_244 | /// <reference path="fourslash.ts" />
////interface A { a: number }
////interface B { b: number }
////declare function f(a: A): void;
////declare function f(b: B): void;
////f({ /**/ });
verify.completions({ marker: "", exact: ["a", "b"] });
| {
"end_byte": 244,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsCombineOverloads.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_tripleSlashOrdering.ts_0_1888 | /// <reference path="fourslash.ts" />
// repro from #52263
// @Filename: /tsconfig.json
////{
//// "compilerOptions": {
//// "skipDefaultLibCheck": false
//// }
////}
// @Filename: /a.ts
////export const x = 0;
// @Filename: /b.ts
////// some comment
////
/////// <reference lib="es2017.string" />
////
////const y = x + 1;
// @Filename: /c.ts
////// some comment
////
/////// <reference path="jquery-1.8.3.js" />
////
////const y = x + 1;
// @Filename: /d.ts
////// some comment
////
/////// <reference types="node" />
////
////const y = x + 1;
// @Filename: /e.ts
////// some comment
////
/////// <reference no-default-lib="true" />
////
////const y = x + 1;
// @Filename: /f.ts
////// some comment
////
/////// <amd-module name="NamedModule" />
////
////const y = x + 1;
// @Filename: /g.ts
////// some comment
////
/////// <amd-dependency path="legacy/moduleA" name="moduleA" />
////
////const y = x + 1;
goTo.file("/b.ts");
verify.importFixAtPosition([
`// some comment
/// <reference lib="es2017.string" />
import { x } from "./a";
const y = x + 1;`,
]);
goTo.file("/c.ts");
verify.importFixAtPosition([
`// some comment
/// <reference path="jquery-1.8.3.js" />
import { x } from "./a";
const y = x + 1;`,
]);
goTo.file("/d.ts");
verify.importFixAtPosition([
`// some comment
/// <reference types="node" />
import { x } from "./a";
const y = x + 1;`,
]);
goTo.file("/e.ts");
verify.importFixAtPosition([
`// some comment
/// <reference no-default-lib="true" />
import { x } from "./a";
const y = x + 1;`,
]);
goTo.file("/f.ts");
verify.importFixAtPosition([
`// some comment
/// <amd-module name="NamedModule" />
import { x } from "./a";
const y = x + 1;`,
]);
goTo.file("/g.ts");
verify.importFixAtPosition([
`// some comment
/// <amd-dependency path="legacy/moduleA" name="moduleA" />
import { x } from "./a";
const y = x + 1;`,
]);
| {
"end_byte": 1888,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_tripleSlashOrdering.ts"
} |
TypeScript/tests/cases/fourslash/renameAliasExternalModule.ts_0_299 | /// <reference path='fourslash.ts'/>
// @Filename: a.ts
////module SomeModule { export class SomeClass { } }
////export = SomeModule;
// @Filename: b.ts
////[|import [|{| "contextRangeIndex": 0 |}M|] = require("./a");|]
////import C = [|M|].SomeClass;
verify.baselineRenameAtRangesWithText("M");
| {
"end_byte": 299,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameAliasExternalModule.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionOverriddenMember5.ts_0_206 | /// <reference path="./fourslash.ts"/>
// @noImplicitOverride: true
////class Foo extends (class {
//// /*2*/m() {}
////}) {
//// [|/*1*/override|] m() {}
////}
verify.baselineGoToDefinition("1");
| {
"end_byte": 206,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionOverriddenMember5.ts"
} |
TypeScript/tests/cases/fourslash/inlineVariableTriggerInReference.ts_0_463 | /// <reference path="fourslash.ts" />
////const x = 0;
////const y = /*a*/x/*b*/ + 1;
goTo.select("a", "b");
verify.not.refactorAvailableForTriggerReason("implicit", "Inline variable");
verify.refactorAvailableForTriggerReason("invoked", "Inline variable");
edit.applyRefactor({
refactorName: "Inline variable",
actionName: "Inline variable",
actionDescription: "Inline variable",
newContent: "const y = 0 + 1;",
triggerReason: "invoked"
}); | {
"end_byte": 463,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableTriggerInReference.ts"
} |
TypeScript/tests/cases/fourslash/javaScriptModules16.ts_0_688 | ///<reference path="fourslash.ts" />
// Assignments to 'exports.p' define a property 'p'
// @allowJs: true
// @Filename: myMod.js
//// exports.n = 3;
//// exports.s = 'foo';
//// exports.b = true;
// @Filename: consumer.js
//// var x = require('./myMod');
//// x/**/;
goTo.file('consumer.js');
goTo.marker();
edit.insert('.');
verify.completions({
unsorted: [
...["n", "s", "b"].map(name => ({ name, kind: "property" })),
...["x", "require"].map(name => ({ name, kind: "warning", sortText: completion.SortText.JavascriptIdentifiers })),
],
});
edit.insert('n.');
verify.completions({ includes: { name: "toFixed", kind: "method", kindModifiers: "declare" } });
| {
"end_byte": 688,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javaScriptModules16.ts"
} |
TypeScript/tests/cases/fourslash/renameJsPropertyAssignment3.ts_0_268 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: a.js
////var C = class {
////}
////[|C.[|{| "contextRangeIndex": 0 |}staticProperty|] = "string";|]
////console.log(C.[|staticProperty|]);
verify.baselineRenameAtRangesWithText("staticProperty");
| {
"end_byte": 268,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameJsPropertyAssignment3.ts"
} |
TypeScript/tests/cases/fourslash/completionsRecommended_import.ts_0_1282 | /// <reference path="fourslash.ts" />
// @noLib: true
// @Filename: /a.ts
////export class Cls {}
////export function f(c: Cls) {}
// @Filename: /b.ts
////import { f } from "./a";
// Here we will recommend a new import of 'Cls'
////f(new C/*b0*/);
////f(new /*b1*/);
// @Filename: /c.ts
////import * as alpha from "./a";
// Here we will recommend 'alpha' because it contains 'Cls'.
////alpha.f(new al/*c0*/);
////alpha.f(new /*c1*/);
const preferences: FourSlashInterface.UserPreferences = { includeCompletionsForModuleExports: true };
const classEntry = (isConstructor: boolean): FourSlashInterface.ExpectedCompletionEntry => ({
name: "Cls",
source: "/a",
sourceDisplay: "./a",
kind: "class",
kindModifiers: "export",
text: isConstructor ? "constructor Cls(): Cls" : "class Cls",
hasAction: true,
isRecommended: true,
sortText: completion.SortText.AutoImportSuggestions
});
verify.completions(
{ marker: "b0", includes: classEntry(true), preferences },
{ marker: "b1", includes: classEntry(false), preferences },
{
marker: ["c0", "c1"],
includes: {
name: "alpha",
text: "import alpha",
kind: "alias",
isRecommended: true,
},
preferences,
},
);
| {
"end_byte": 1282,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsRecommended_import.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteral7.ts_0_549 | /// <reference path='fourslash.ts'/>
////type T = "foo" | "bar";
////type U = "oof" | "rab";
////function f(x: T, ...args: U[]) { };
////f("[|/*1*/|]", "[|/*2*/|]", "[|/*3*/|]");
verify.completions(
{ marker: "1", exact: ["foo", "bar"].map(name => ({
name, replacementSpan: test.ranges()[0]
})) },
{ marker: "2", exact: ["oof", "rab"].map(name => ({
name, replacementSpan: test.ranges()[1]
})) },
{ marker: "3", exact: ["oof", "rab"].map(name => ({
name, replacementSpan: test.ranges()[2]
})) },
);
| {
"end_byte": 549,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral7.ts"
} |
TypeScript/tests/cases/fourslash/exportEqualCallableInterface.ts_0_491 | /// <reference path='fourslash.ts'/>
// @Filename: exportEqualCallableInterface_file0.ts
////interface x {
//// (): Date;
//// foo: string;
////}
////export = x;
// @Filename: exportEqualCallableInterface_file1.ts
///////<reference path='exportEqualCallableInterface_file0.ts'/>
////import test = require('./exportEqualCallableInterface_file0');
////var t2: test;
////t2./**/
verify.completions({
marker: "",
exact: completion.functionMembersWithPrototypePlus(["foo"]),
});
| {
"end_byte": 491,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/exportEqualCallableInterface.ts"
} |
TypeScript/tests/cases/fourslash/unusedVariableInClass4.ts_0_238 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: false
////class greeter {
//// [|private greeting: string;|]
////}
verify.codeFix({
description: "Remove unused declaration for: 'greeting'",
newRangeContent: "",
});
| {
"end_byte": 238,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedVariableInClass4.ts"
} |
TypeScript/tests/cases/fourslash/semanticClassificationInTemplateExpressions.ts_0_1275 | /// <reference path="fourslash.ts"/>
////module /*0*/M {
//// export class /*1*/C {
//// static x;
//// }
//// export enum /*2*/E {
//// E1 = 0
//// }
////}
////`abcd${ /*3*/M./*4*/C.x + /*5*/M./*6*/E.E1}efg`
const c = classification("original");
verify.semanticClassificationsAre("original",
c.moduleName("M", test.marker("0").position),
c.className("C", test.marker("1").position),
c.enumName("E", test.marker("2").position),
c.moduleName("M", test.marker("3").position),
c.className("C", test.marker("4").position),
c.moduleName("M", test.marker("5").position),
c.enumName("E", test.marker("6").position));
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("namespace.declaration", "M"),
c2.semanticToken("class.declaration", "C"),
c2.semanticToken("property.declaration.static", "x"),
c2.semanticToken("enum.declaration", "E"),
c2.semanticToken("enumMember.declaration.readonly", "E1"),
c2.semanticToken("namespace", "M"),
c2.semanticToken("class", "C"),
c2.semanticToken("property.static", "x"),
c2.semanticToken("namespace", "M"),
c2.semanticToken("enum", "E"),
c2.semanticToken("enumMember.readonly", "E1"),
);
| {
"end_byte": 1275,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semanticClassificationInTemplateExpressions.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionObjectBindingElementPropertyName01.ts_0_230 | /// <reference path='fourslash.ts'/>
////interface I {
//// /*def*/property1: number;
//// property2: string;
////}
////
////var foo: I;
////var { [|/*use*/property1|]: prop1 } = foo;
verify.baselineGoToDefinition("use");
| {
"end_byte": 230,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionObjectBindingElementPropertyName01.ts"
} |
TypeScript/tests/cases/fourslash/autoImportFileExcludePatterns11.ts_0_938 | /// <reference path="fourslash.ts" />
// @Filename: /src/vs/test.ts
//// import { Parts } from './parts';
//// export class /**/Extended implements Parts {
//// }
// @Filename: /src/vs/parts.ts
//// import { Event } from '../thing';
//// export interface Parts {
//// readonly options: Event;
//// }
// @Filename: /src/event/event.ts
//// export interface Event {
//// (): string;
//// }
// @Filename: /src/thing.ts
//// import { Event } from './event/event';
//// export { Event };
// @Filename: /src/a.ts
//// import './thing'
//// declare module './thing' {
//// interface Event {
//// c: string;
//// }
//// }
verify.codeFix({
description: "Implement interface 'Parts'",
newFileContent:
`import { Event } from '../event/event';
import { Parts } from './parts';
export class Extended implements Parts {
options: Event;
}`,
preferences: {
autoImportFileExcludePatterns: ["src/thing.ts"],
}
});
| {
"end_byte": 938,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportFileExcludePatterns11.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteral_quotePreference4.ts_0_225 | /// <reference path='fourslash.ts'/>
////type T = 0 | 1;
////const t: T = /**/
verify.completions({
marker: "",
includes: [
{ name: "0" },
{ name: "1" },
],
isNewIdentifierLocation: true
});
| {
"end_byte": 225,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral_quotePreference4.ts"
} |
TypeScript/tests/cases/fourslash/findAllReferencesUndefined.ts_0_181 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
//// /**/undefined;
////
//// void undefined;
// @Filename: /b.ts
//// undefined;
verify.baselineFindAllReferences("");
| {
"end_byte": 181,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesUndefined.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsInteractiveReturnType.ts_0_512 | /// <reference path="fourslash.ts" />
//// function foo1 () {
//// return 1
//// }
//// function foo2 (): number {
//// return 1
//// }
//// class C {
//// foo() {
//// return 1
//// }
//// bar() {
//// return this
//// }
//// }
//// const a = () => 1
//// const b = function () { return 1 }
//// const c = (b) => 1
//// const d = b => 1
verify.baselineInlayHints(undefined, {
includeInlayFunctionLikeReturnTypeHints: true,
interactiveInlayHints: true,
});
| {
"end_byte": 512,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveReturnType.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUndeclaredClassInstanceWithTypeParams.ts_0_417 | /// <reference path='fourslash.ts' />
//// class A<T> {
//// a: number;
//// b: string;
//// constructor(public x: T) {}
//// }
//// [|class B {
//// constructor() {
//// this.x = new A(3);
//// }
//// }|]
verify.rangeAfterCodeFix(`
class B {
x: A<number>;
constructor() {
this.x = new A(3);
}
}
`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); | {
"end_byte": 417,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUndeclaredClassInstanceWithTypeParams.ts"
} |
TypeScript/tests/cases/fourslash/unusedParameterInConstructor1AddUnderscore.ts_0_369 | /// <reference path='fourslash.ts' />
// @noUnusedParameters: true
////class C1 {
//// constructor(p1: string, public p2: boolean, public p3: any, p5) { p5; }
////}
verify.codeFix({
index: 1,
description: "Prefix 'p1' with an underscore",
newFileContent:
`class C1 {
constructor(_p1: string, public p2: boolean, public p3: any, p5) { p5; }
}`,
});
| {
"end_byte": 369,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedParameterInConstructor1AddUnderscore.ts"
} |
TypeScript/tests/cases/fourslash/completionsTriggerCharacter.ts_0_2318 | /// <reference path="fourslash.ts" />
// @jsx: preserve
/////** @/*tag*/ */
//////</*comment*/
////const x: "a" | "b" = "[|/*openQuote*/|]"/*closeQuote*/;
////const y: 'a' | 'b' = '[|/*openSingleQuote*/|]'/*closeSingleQuote*/;
////const z: 'a' | 'b' = `[|/*openTemplate*/|]`/*closeTemplate*/;
////const q: "`a`" | "`b`" = "[|`/*openTemplateInQuote*/a`/*closeTemplateInQuote*/|]";
////// "/*quoteInComment*/ </*lessInComment*/
// @Filename: /foo/importMe.ts
////whatever
// @Filename: /a.tsx
////declare global {
//// namespace JSX {
//// interface Element {}
//// interface IntrinsicElements {
//// div: {};
//// }
//// }
////}
////const ctr = </*openTag*/;
////const less = 1 </*lessThan*/;
////const closeTag = <div> foo <//*closeTag*/;
////import something from "./foo//*path*/";
////const divide = 1 //*divide*/
verify.completions(
{ marker: "tag", includes: ["param"], triggerCharacter: "@" },
{ marker: "comment", exact: undefined, triggerCharacter: "<" },
{ marker: "openQuote", exact: [
{ name: "a", replacementSpan: test.ranges()[0] },
{ name: "b", replacementSpan: test.ranges()[0] }
], triggerCharacter: '"' },
{ marker: "closeQuote", exact: undefined, triggerCharacter: '"' },
{ marker: "openSingleQuote", exact: [
{ name: "a", replacementSpan: test.ranges()[1] },
{ name: "b", replacementSpan: test.ranges()[1] }
], triggerCharacter: "'" },
{ marker: "closeSingleQuote", exact: undefined, triggerCharacter: "'" },
{ marker: "openTemplate", exact: [
{ name: "a", replacementSpan: test.ranges()[2] },
{ name: "b", replacementSpan: test.ranges()[2] }
], triggerCharacter: "`" },
{ marker: "closeTemplate", exact: undefined, triggerCharacter: "`" },
{ marker: "quoteInComment", exact: undefined, triggerCharacter: '"' },
{ marker: "lessInComment", exact: undefined, triggerCharacter: "<" },
{ marker: "openTag", includes: "div", triggerCharacter: "<" },
{ marker: "lessThan", exact: undefined, triggerCharacter: "<" },
{ marker: "closeTag", exact: "div>", triggerCharacter: "/" },
{ marker: "path", exact: "importMe", triggerCharacter: "/", isNewIdentifierLocation: true },
{ marker: "divide", exact: undefined, triggerCharacter: "/" },
);
| {
"end_byte": 2318,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsTriggerCharacter.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_escapedBackslashes.ts_0_594 | /// <reference path='fourslash.ts' />
//// console.log(/*0*/"\\[[" + text + "](" + link + ")\\]"/*1*/)
goTo.select("0", "1");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
// Four backslashes here
// = two backslashes in the expected file content
// = one backslash in the string data sent to console.log
// (which is the same as what the user started with)
newContent: 'console.log(`\\\\[[${text}](${link})\\\\]`)',
});
| {
"end_byte": 594,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_escapedBackslashes.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts_0_346 | /// <reference path='fourslash.ts' />
// @noImplicitOverride: true
////abstract class A {
//// abstract x: this;
////}
////
////class C extends A {[| |]}
verify.codeFix({
description: "Implement inherited abstract class",
newFileContent:
`abstract class A {
abstract x: this;
}
class C extends A {
override x: this;
}`,
});
| {
"end_byte": 346,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts"
} |
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc15.ts_0_1031 | /// <reference path='fourslash.ts' />
// @strict: true
/////**
//// * @param {Boolean} x
//// * @param {String} y
//// * @param {Number} z
//// * @param {Object} alpha
//// * @param {date} beta
//// * @param {promise} gamma
//// * @param {array} delta
//// * @param {Array<number>} epsilon
//// * @param {promise<String>} zeta
//// */
////function f(x, y, z, alpha, beta, gamma, delta, epsilon, zeta) {
//// x; y; z; alpha; beta; gamma; delta; epsilon; zeta;
////}
verify.codeFix({
description: "Annotate with type from JSDoc",
index: 9,
newFileContent:
`/**
* @param {Boolean} x
* @param {String} y
* @param {Number} z
* @param {Object} alpha
* @param {date} beta
* @param {promise} gamma
* @param {array} delta
* @param {Array<number>} epsilon
* @param {promise<String>} zeta
*/
function f(x: boolean, y: string, z: number, alpha: object, beta: Date, gamma: Promise<any>, delta: Array<any>, epsilon: Array<number>, zeta: Promise<string>) {
x; y; z; alpha; beta; gamma; delta; epsilon; zeta;
}`,
});
| {
"end_byte": 1031,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc15.ts"
} |
TypeScript/tests/cases/fourslash/completionsClassMemberImportTypeNodeParameter3.ts_0_840 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @FileName: /other/foo.d.ts
//// export declare type Bar = { baz: string };
// @FileName: /other/cls.d.ts
//// export declare class Cls {
//// method(
//// param: import("./foo.js").Bar,
//// ): import("./foo.js").Bar;
//// }
// @FileName: /index.d.ts
//// import { Cls } from "./other/cls.js";
////
//// export declare class Derived extends Cls {
//// /*1*/
//// }
verify.completions({
marker: "1",
includes: [
{
name: "method",
insertText: `method(param: import("./other/foo.js").Bar): import("./other/foo.js").Bar;`,
filterText: "method",
hasAction: undefined,
},
],
preferences: {
includeCompletionsWithClassMemberSnippets: true,
includeCompletionsWithInsertText: true,
},
isNewIdentifierLocation: true,
});
| {
"end_byte": 840,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsClassMemberImportTypeNodeParameter3.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsRootSymbols.ts_0_222 | /// <reference path="fourslash.ts" />
////interface I { /*0*/x: {}; }
////interface J { /*1*/x: {}; }
////declare const o: (I | J) & { /*2*/x: string };
////o./*3*/x;
verify.baselineFindAllReferences('0', '1', '2', '3')
| {
"end_byte": 222,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsRootSymbols.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertExport_namedToDefaultInModuleAugmentation1.ts_0_637 | /// <reference path='fourslash.ts' />
// @Filename: /node_modules/@types/foo/index.d.ts
////export {};
////declare module "foo" {
//// /*a*/export function foo(): void;/*b*/
////}
// @Filename: /b.ts
////import { foo } from "foo";
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert export",
actionName: "Convert named export to default export",
actionDescription: "Convert named export to default export",
newContent: {
"/node_modules/@types/foo/index.d.ts":
`export {};
declare module "foo" {
export default function foo(): void;
}`,
"/b.ts":
`import foo from "foo";`
}
});
| {
"end_byte": 637,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertExport_namedToDefaultInModuleAugmentation1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpellingJs5.ts_0_555 | /// <reference path='fourslash.ts' />
// @allowjs: true
// @noEmit: true
// @filename: a.js
//// var other = {
//// puuce: 4
//// }
//// var Jimmy = 1
//// var John = 2
// @filename: b.js
//// other.puuuce // OK, from another file
//// new Date().getGMTDate() // OK, from another file
//// window.argle // OK, from globalThis
//// self.blargle // OK, from globalThis
////
//// // No suggestions for globals from other files
//// const atoc = setIntegral(() => console.log('ok'), 500)
//// AudioBuffin // etc
//// Jimmy
//// Jon
verify.noErrors()
| {
"end_byte": 555,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingJs5.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_EmptySpanConditionalReturnKeyword.ts_0_668 | /// <reference path='fourslash.ts' />
////let a = { b: { c: 0 } };
////function f(){
//// ret/*a*//*b*/urn a.b ? a.b.c : "whenFalse";
////}
// verify that the refactor is offered for empty spans in return statements.
goTo.select("a", "b");
verify.not.refactorAvailableForTriggerReason("implicit", "Convert to optional chain expression");
edit.applyRefactor({
refactorName: "Convert to optional chain expression",
actionName: "Convert to optional chain expression",
actionDescription: "Convert to optional chain expression",
newContent:
`let a = { b: { c: 0 } };
function f(){
return a.b?.c ?? "whenFalse";
}`,
triggerReason: "invoked"
}); | {
"end_byte": 668,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_EmptySpanConditionalReturnKeyword.ts"
} |
TypeScript/tests/cases/fourslash/formatCatch.ts_0_252 | /// <reference path="fourslash.ts"/>
////try {
////} /*0*/catch {
////}
////
////try {
////} /*1*/catch{
////}
format.document();
for (const marker of test.markers()) {
goTo.marker(marker);
verify.currentLineContentIs("} catch {");
}
| {
"end_byte": 252,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatCatch.ts"
} |
TypeScript/tests/cases/fourslash/extract-const_insideJsxFragment1.ts_0_551 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: a.tsx
////function Foo() {
//// return (
//// <>
//// /*a*/<span></span>/*b*/
//// </>
//// );
////}
goTo.file("a.tsx");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "constant_scope_1",
actionDescription: "Extract to constant in global scope",
newContent:
`const /*RENAME*/newLocal = <span></span>;
function Foo() {
return (
<>
{newLocal}
</>
);
}`
});
| {
"end_byte": 551,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const_insideJsxFragment1.ts"
} |
TypeScript/tests/cases/fourslash/chainedFunctionLambdaArgIndex.ts_0_418 | /// <reference path='fourslash.ts' />
//// class C2 {
//// eventEmitter: any;
//// constructor() {
//// this.eventEmitter.on(5, (msg) => {
//// console.log/**/
//// });
//// }
//// }
goTo.marker();
edit.insert(";");
verify.indentationIs(12);
verify.currentLineContentIs(" console.log;"); // Ensure line is indented correctly and doesn't jump up to previous line on semi-colon
| {
"end_byte": 418,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/chainedFunctionLambdaArgIndex.ts"
} |
TypeScript/tests/cases/fourslash/importTypeCompletions7.ts_0_756 | /// <reference path="fourslash.ts" />
// @target: es2020
// @module: esnext
// @Filename: /foo.d.ts
//// declare namespace Foo {}
//// export = Foo;
// @Filename: /test.ts
//// [|import F/**/|]
goTo.file("/test.ts")
verify.completions({
marker: "",
exact: [{
name: "Foo",
sourceDisplay: "./foo",
source: "./foo",
insertText: "import * as Foo from \"./foo\";",
replacementSpan: test.ranges()[0]
}, {
name: "type",
sortText: completion.SortText.GlobalsOrKeywords,
}],
isNewIdentifierLocation: true,
preferences: {
includeCompletionsForModuleExports: true,
includeCompletionsForImportStatements: true,
includeCompletionsWithInsertText: true
}
});
| {
"end_byte": 756,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importTypeCompletions7.ts"
} |
TypeScript/tests/cases/fourslash/codeFixImportNonExportedMember7.ts_0_542 | /// <reference path="fourslash.ts" />
// @module: esnext
// @filename: /a.ts
////const a = 1
////const b = 1;
////export { a, b };
////
////type T2 = number;
////type T1 = number;
////export type { T1 };
// @filename: /b.ts
////import { T2 } from "./a";
goTo.file("/b.ts");
verify.codeFix({
description: [ts.Diagnostics.Export_0_from_module_1.message, "T2", "./a"],
index: 0,
newFileContent: {
"/a.ts":
`const a = 1
const b = 1;
export { a, b };
type T2 = number;
type T1 = number;
export type { T1, T2 };`,
}
});
| {
"end_byte": 542,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImportNonExportedMember7.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertImport_namedToDefault1.ts_0_1520 | /// <reference path="fourslash.ts" />
// @esModuleInterop: true
// @Filename: /process.d.ts
//// declare module "process" {
//// interface Process {
//// pid: number;
//// addListener(event: string, listener: (...args: any[]) => void): void;
//// }
//// var process: Process;
//// export = process;
//// }
// @Filename: /url.d.ts
//// declare module "url" {
//// export function parse(urlStr: string): any;
//// }
// @Filename: /index.ts
//// [|import { pid, addListener } from "process";|]
//// addListener("message", (m) => {
//// console.log(pid);
//// });
// @Filename: /a.ts
//// [|import { parse } from "url";|]
//// parse("https://www.typescriptlang.org");
goTo.selectRange(test.ranges()[0]);
edit.applyRefactor({
refactorName: "Convert import",
actionName: "Convert named imports to default import",
actionDescription: "Convert named imports to default import",
newContent: `import process from "process";
process.addListener("message", (m) => {
console.log(process.pid);
});`,
});
verify.not.refactorAvailable("Convert import", "Convert named imports to namespace import");
goTo.selectRange(test.ranges()[1]);
edit.applyRefactor({
refactorName: "Convert import",
actionName: "Convert named imports to namespace import",
actionDescription: "Convert named imports to namespace import",
newContent: `import * as url from "url";
url.parse("https://www.typescriptlang.org");`,
});
verify.not.refactorAvailable("Convert import", "Convert named imports to default import"); | {
"end_byte": 1520,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertImport_namedToDefault1.ts"
} |
TypeScript/tests/cases/fourslash/compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.ts_0_426 | /// <reference path="fourslash.ts" />
// @BaselineFile: compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.baseline
// @allowJs: true
// @Filename: b.js
// @emitThisFile: true
////function foo() { } // This has error because js file cannot be overwritten - emitSkipped should be true
// @Filename: a.ts
// @emitThisFile: true
////function foo2() { return 30; } // no error - should emit a.js
verify.baselineGetEmitOutput(); | {
"end_byte": 426,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_defaultAndNamedConflict.ts_0_1171 | /// <reference path="fourslash.ts" />
// @noLib: true
// @Filename: /someModule.ts
//// export const someModule = 0;
//// export default 1;
// @Filename: /index.ts
//// someMo/**/
verify.completions({
marker: "",
exact: completion.globalsPlus([
{
name: "someModule",
source: "/someModule",
sourceDisplay: "./someModule",
text: "(property) default: 1",
kind: "property",
kindModifiers: "export",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
{
name: "someModule",
source: "/someModule",
sourceDisplay: "./someModule",
text: "const someModule: 0",
kind: "const",
kindModifiers: "export",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
], { noLib: true }),
preferences: {
includeCompletionsForModuleExports: true
}
});
verify.applyCodeActionFromCompletion("", {
name: "someModule",
source: "/someModule",
data: { exportName: "default", fileName: "/someModule.ts" },
description: `Add import from "./someModule"`,
newFileContent: `import someModule from "./someModule";
someMo`
});
| {
"end_byte": 1171,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_defaultAndNamedConflict.ts"
} |
TypeScript/tests/cases/fourslash/getEmitOutputWithSyntaxErrors.ts_0_191 | /// <reference path="fourslash.ts" />
// @BaselineFile: getEmitOutputWithSyntaxErrors.baseline
// @Filename: inputFile.ts
// @emitThisFile: true
//// var x:
verify.baselineGetEmitOutput(); | {
"end_byte": 191,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputWithSyntaxErrors.ts"
} |
TypeScript/tests/cases/fourslash/completionListInvalidMemberNames_escapeQuote.ts_0_514 | /// <reference path='fourslash.ts' />
////declare const x: { "\"'": 0 };
////x[|./**/|];
const replacementSpan = test.ranges()[0];
verify.completions({
marker: "",
exact: { name: `"'`, insertText: `["\\"'"]`, replacementSpan },
preferences: { includeInsertTextCompletions: true },
});
verify.completions({
marker: "",
exact: { name: `"'`, insertText: `['"\\'']`, replacementSpan },
preferences: {
includeInsertTextCompletions: true,
quotePreference: "single",
},
});
| {
"end_byte": 514,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInvalidMemberNames_escapeQuote.ts"
} |
TypeScript/tests/cases/fourslash/organizeImportsGroup_Newline.ts_0_327 | /// <reference path="fourslash.ts" />
////import c from "C";
////
////import d from "D";
////import a from "A"; // not count
////import b from "B";
////
////console.log(a, b, c, d)
verify.organizeImports(
`import c from "C";
import a from "A"; // not count
import b from "B";
import d from "D";
console.log(a, b, c, d)`
);
| {
"end_byte": 327,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsGroup_Newline.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsEnum4.ts_0_172 | /// <reference path='fourslash.ts'/>
////const enum Foo {
//// "\t" = 9,
//// "\u007f" = 127,
////}
////Foo[/*1*/"\t"]
////Foo[/*2*/"\u007f"]
verify.baselineQuickInfo();
| {
"end_byte": 172,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsEnum4.ts"
} |
TypeScript/tests/cases/fourslash/javascriptModules22.ts_0_721 | /// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: mod.js
//// function foo() { return {a: "hello, world"}; }
//// module.exports = foo();
// @Filename: mod2.js
//// var x = {name: 'test'};
//// (function createExport(obj){
//// module.exports = {
//// "default": x,
//// "sausages": {eggs: 2}
//// };
//// })();
// @Filename: app.js
//// import {a} from "./mod"
//// import def, {sausages} from "./mod2"
//// a./**/
verify.completions({ marker: "", includes: "toString" });
edit.backspace(2);
edit.insert("def.");
verify.completions({ includes: "name" });
edit.insert("name;\nsausages.");
verify.completions({ includes: "eggs" });
edit.insert("eggs;");
verify.noErrors();
| {
"end_byte": 721,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/javascriptModules22.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsImportType1.ts_0_278 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @Filename: /a.js
//// module.exports.a = 1
// @Filename: /b.js
//// const a = require('./a');
goTo.file('/b.js')
verify.baselineInlayHints(undefined, {
includeInlayVariableTypeHints: true,
});
| {
"end_byte": 278,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsImportType1.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_escapeSequences.ts_0_3426 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////let s = /*a1*/"\0\b\f\t\r\n" + text + "\n"/*a2*/;
goTo.select("a1", "a2");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
newContent: 'let s = `\\0\\b\\f\\t\\r\\n${text}\\n`;'
});
// @Filename: /b.ts
////let s = /*b1*/'"' + text + "'"/*b2*/;
goTo.select("b1", "b2");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
// newContent is: let s = `"${text}'`;
newContent: 'let s = `"${text}\'`;'
});
// @Filename: /c.ts
////let s = /*c1*/'$' + text + "\\"/*c2*/;
goTo.select("c1", "c2");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
// newContent is: let s = `\$${text}\\`;
newContent: 'let s = `\\$${text}\\\\`;'
});
// @Filename: /d.ts
////let s = /*d1*/`$` + text + `\\`/*d2*/;
goTo.select("d1", "d2");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
// newContent is: let s = `\$${text}\\`;
newContent: 'let s = `\\$${text}\\\\`;'
});
// @Filename: /e.ts
////let s = /*e1*/'${' + text + "}"/*e2*/;
goTo.select("e1", "e2");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
// newContent is: let s = `\${${text}}`;
newContent: 'let s = `\\${${text}}`;'
});
// @Filename: /f.ts
////let s = /*f1*/`\${` + text + `}`/*f2*/;
goTo.select("f1", "f2");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
// newContent is: let s = `\${${text}}`;
newContent: 'let s = `\\${${text}}`;'
});
// @Filename: /g.ts
////let s = /*g1*/'\\$' + text + "\\"/*g2*/;
goTo.select("g1", "g2");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
// newContent is: let s = `\\\$${text}\\`;
newContent: 'let s = `\\\\\\$${text}\\\\`;'
});
// @Filename: /h.ts
////let s = /*h1*/"\u0041\u0061" + text + "\0\u0000"/*h2*/;
goTo.select("h1", "h2");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
// newContent is: let s = `\u0041\u0061${text}\0\u0000`;
newContent: 'let s = `\\u0041\\u0061${text}\\0\\u0000`;'
});
// @Filename: /i.ts
////let s = /*i1*/'$`' + text + "`\\"/*i2*/;
goTo.select("i1", "i2");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
// newContent is: let s = `\$\`${text}\`\\`;
newContent: 'let s = `\\$\\`${text}\\`\\\\`;'
});
| {
"end_byte": 3426,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_escapeSequences.ts"
} |
TypeScript/tests/cases/fourslash/completionListInheritedClassMembers.ts_0_1031 | /// <reference path="fourslash.ts"/>
// @filename: a.ts
////interface I {
//// m2(): void;
//// m3(): void;
////}
////
////type T1 = I;
////export interface A1 extends T1 {
//// m1(): void;
////}
////export class A1 {}
////
////type T2 = Partial<I>
////export interface A2 extends T2 {
//// m1(): void;
////}
////export class A2 {}
////
////type T3 = Pick<I, "m3">
////export interface A3 extends T3 {
//// m1(): void;
////}
////export class A3 {}
// @filename: b.ts
////import { A1, A2, A3 } from './a';
////class B1 extends A1 {
//// /*1*/
////}
////class B2 extends A2 {
//// /*2*/
////}
////class B3 extends A3 {
//// /*3*/
////}
verify.completions(
{ marker: "1", unsorted: ["m1", "m2", "m3", ...completion.classElementKeywords], isNewIdentifierLocation: true },
{ marker: "2", unsorted: ["m1", "m2", "m3", ...completion.classElementKeywords], isNewIdentifierLocation: true },
{ marker: "3", unsorted: ["m1", "m3", ...completion.classElementKeywords], isNewIdentifierLocation: true }
);
| {
"end_byte": 1031,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInheritedClassMembers.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForShorthandProperty.ts_0_533 | /// <reference path='fourslash.ts' />
//// var name1 = undefined, id1 = undefined;
//// var /*obj1*/obj1 = {/*name1*/name1, /*id1*/id1};
//// var name2 = "Hello";
//// var id2 = 10000;
//// var /*obj2*/obj2 = {/*name2*/name2, /*id2*/id2};
verify.quickInfos({
obj1: "var obj1: {\n name1: any;\n id1: any;\n}",
name1: "(property) name1: any",
id1: "(property) id1: any",
obj2: "var obj2: {\n name2: string;\n id2: number;\n}",
name2: "(property) name2: string",
id2: "(property) id2: number"
});
| {
"end_byte": 533,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForShorthandProperty.ts"
} |
TypeScript/tests/cases/fourslash/getEditsForFileRename_subDir.ts_0_306 | /// <reference path='fourslash.ts' />
// @Filename: /src/foo/a.ts
////
// @Filename: /src/old.ts
////import a from "./foo/a";
verify.getEditsForFileRename({
oldPath: "/src/old.ts",
newPath: "/src/dir/new.ts",
newFileContents: {
"/src/old.ts":
`import a from "../foo/a";`,
},
});
| {
"end_byte": 306,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_subDir.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_Availability_Anon_nested_this.ts_0_797 | /// <reference path='fourslash.ts' />
//// const zoo = /*x*/f/*w*/unction () {
//// class Animal {
//// weight = 42
//// askWeight() { return this.weight }
//// }
//// const Insect = class {
//// weight = 42
//// askWeight() { return this.weight }
//// }
//// function callTaxi() { this.no = "054 xxx xx xx" }
//// const callPizzaDelivery = function() { this.phone = "064 yyy yy yy"}
//// };
goTo.select("x", "w");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function");
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function");
verify.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
| {
"end_byte": 797,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_Availability_Anon_nested_this.ts"
} |
TypeScript/tests/cases/fourslash/referenceToClass.ts_0_504 | /// <reference path='fourslash.ts'/>
// Class references should work across file and not find local variables.
// @Filename: referenceToClass_1.ts
////class /*1*/foo {
//// public n: /*2*/foo;
//// public foo: number;
////}
////
////class bar {
//// public n: /*3*/foo;
//// public k = new /*4*/foo();
////}
////
////module mod {
//// var k: /*5*/foo = null;
////}
// @Filename: referenceToClass_2.ts
////var k: /*6*/foo;
verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6')
| {
"end_byte": 504,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referenceToClass.ts"
} |
TypeScript/tests/cases/fourslash/codeFixConvertToMappedObjectType3.ts_0_294 | /// <reference path='fourslash.ts' />
//// type K = "foo" | "bar";
//// type SomeType = {
//// [prop: K]: any;
//// }
verify.codeFix({
description: `Convert 'SomeType' to mapped object type`,
newFileContent: `type K = "foo" | "bar";
type SomeType = {
[prop in K]: any;
};`
})
| {
"end_byte": 294,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToMappedObjectType3.ts"
} |
TypeScript/tests/cases/fourslash/extract-method-formatting-objectliteral.ts_0_956 | /// <reference path='fourslash.ts' />
////
//// namespace M {
//// class C {
//// foo() {
//// /*a*/let x = {a:1};
//// let y = {
//// b: 2
//// };
//// let z =
//// {
//// c: 3
//// };/*b*/
//// return x.a + y.b + z.c;
//// }
//// }
//// }
////
goTo.select('a', 'b');
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_1",
actionDescription: "Extract to method in class 'C'",
newContent:
`
namespace M {
class C {
foo() {
let { x, y, z } = this./*RENAME*/newMethod();
return x.a + y.b + z.c;
}
private newMethod() {
let x = { a: 1 };
let y = {
b: 2
};
let z = {
c: 3
};
return { x, y, z };
}
}
}
`
});
| {
"end_byte": 956,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method-formatting-objectliteral.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingImportForReactJsx1.ts_0_762 | /// <reference path='fourslash.ts' />
// @jsx: react-jsx
// @Filename: node_modules/react/index.d.ts
////export declare var React: any;
// @Filename: node_modules/react/package.json
////{
//// "name": "react",
//// "types": "./index.d.ts"
////}
// @Filename: foo.tsx
//// export default function Foo(){
//// return <></>;
//// }
// @Filename: bar.tsx
//// export default function Bar(){
//// return <Foo></Foo>;
//// }
// @Filename: package.json
////{
//// "dependencies": {
//// "react": "*"
//// }
////}
goTo.file('bar.tsx')
verify.codeFixAll({
fixId: "fixMissingImport",
fixAllDescription: "Add all missing imports",
newFileContent:
`import Foo from "./foo";
export default function Bar(){
return <Foo></Foo>;
}`,
});
| {
"end_byte": 762,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingImportForReactJsx1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageRestParam.ts_0_256 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
////function f(a: number, [|...rest |]){
//// a; rest;
////}
////f(1);
////f(2, "s1");
////f(3, "s1", "s2");
////f(3, "s1", "s2", "s3", "s4");
verify.rangeAfterCodeFix("...rest: string[]"); | {
"end_byte": 256,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageRestParam.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnPrivateConstructorCall.ts_0_146 | /// <reference path='fourslash.ts' />
////class A {
//// private constructor() {}
////}
////var x = new A(/*1*/
verify.noSignatureHelp("1");
| {
"end_byte": 146,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnPrivateConstructorCall.ts"
} |
TypeScript/tests/cases/fourslash/jsdocParameterTagSnippetCompletion3.ts_0_630 | ///<reference path="fourslash.ts" />
// Infer types from initializer
// @allowJs: true
// @Filename: a.js
//// /**
//// * @p/*z*/
//// */
//// function zz(a = 3) {}
//// /**
//// * @p/*y*/
//// */
//// function yy({ a = 3 }) {}
//// /**
//// * @p/*x*/
//// */
//// function xx({ a, o: { b, c: [d, e = 1] }}) {}
//// /**
//// * @p/*w*/
//// */
//// function ww({ a, o: { b, c: [d, e] = [1, true] }}) {}
//// /**
//// * @p/*v*/
//// */
//// function vv({ a = [1, true] }) {}
//// function random(a) { return a }
//// /**
//// * @p/*u*/
//// */
//// function uu({ a = random() }) {}
verify.baselineCompletions(); | {
"end_byte": 630,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocParameterTagSnippetCompletion3.ts"
} |
TypeScript/tests/cases/fourslash/jsDocSignature-43394.ts_0_179 | ///<reference path="fourslash.ts" />
/////**
//// * @typedef {Object} Foo
//// * @property {number} ...
//// * /**/@typedef {number} Bar
//// */
verify.baselineSignatureHelp();
| {
"end_byte": 179,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocSignature-43394.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddVoidToPromise.3.ts_0_375 | /// <reference path='fourslash.ts' />
// @target: esnext
// @lib: es2015
// @strict: true
////const p3 = new Promise<number | string>(resolve => resolve());
verify.codeFix({
errorCode: 2794,
description: "Add 'void' to Promise resolved without a value",
index: 0,
newFileContent: `const p3 = new Promise<number | string | void>(resolve => resolve());`
});
| {
"end_byte": 375,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddVoidToPromise.3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixDeleteUnmatchedParameterJS2.ts_0_529 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @filename: /a.js
/////**
//// * @param {number} a
//// * @param {string} b
//// */
////function foo(a) {
//// a;
////}
verify.codeFixAvailable([
{ description: "Delete unused '@param' tag 'b'" },
{ description: "Disable checking for this file" },
]);
verify.codeFix({
description: [ts.Diagnostics.Delete_unused_param_tag_0.message, "b"],
index: 0,
newFileContent:
`/**
* @param {number} a
*/
function foo(a) {
a;
}`
});
| {
"end_byte": 529,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixDeleteUnmatchedParameterJS2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddOptionalParam18.ts_0_150 | /// <reference path="fourslash.ts" />
////[|function f(a: number, c: string) {}|]
////f(1, 1, "");
verify.not.codeFixAvailable("addOptionalParam");
| {
"end_byte": 150,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddOptionalParam18.ts"
} |
TypeScript/tests/cases/fourslash/convertLiteralTypeToMappedType2.ts_0_318 | /// <reference path='fourslash.ts' />
////type Keys = number | string;
////type T = {
//// [Keys]: number;
////}
verify.codeFix({
description: [ts.Diagnostics.Convert_0_to_1_in_0.message, "Keys", "K"],
index: 0,
newFileContent:
`type Keys = number | string;
type T = {
[K in Keys]: number;
}`
});
| {
"end_byte": 318,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/convertLiteralTypeToMappedType2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixNoPropertyAccessFromIndexSignature1.ts_0_381 | /// <reference path='fourslash.ts'/>
// @noPropertyAccessFromIndexSignature: true
//// interface B {
//// [k: string]: string
//// }
//// declare const b: B;
//// b.foo;
verify.codeFix({
description: [ts.Diagnostics.Use_element_access_for_0.message, 'foo'],
index: 0,
newFileContent:
`interface B {
[k: string]: string
}
declare const b: B;
b["foo"];`,
});
| {
"end_byte": 381,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixNoPropertyAccessFromIndexSignature1.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsFunctionIncomplete.ts_0_147 | /// <reference path='fourslash.ts'/>
/////*1*/function /*2*/(param: string) {
////}\
/////*3*/function /*4*/ {
////}\
verify.baselineQuickInfo(); | {
"end_byte": 147,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsFunctionIncomplete.ts"
} |
TypeScript/tests/cases/fourslash/pathCompletionsTypesVersionsWildcard6.ts_0_1335 | /// <reference path="fourslash.ts" />
// This is the same test as pathCompletionsTypesVersionsWildcard5, but
// with the path patterns shuffled to ensure iteration order doesn't matter.
// @module: commonjs
// @Filename: /node_modules/foo/package.json
//// {
//// "types": "index.d.ts",
//// "typesVersions": {
//// "*": {
//// "bar/*": ["dist/*"],
//// "exact-match": ["dist/index.d.ts"],
//// "foo/*": ["dist/*"],
//// "*": ["dist/*"]
//// }
//// }
//// }
// @Filename: /node_modules/foo/nope.d.ts
//// export const nope = 0;
// @Filename: /node_modules/foo/dist/index.d.ts
//// export const index = 0;
// @Filename: /node_modules/foo/dist/blah.d.ts
//// export const blah = 0;
// @Filename: /node_modules/foo/dist/foo/onlyInFooFolder.d.ts
//// export const foo = 0;
// @Filename: /node_modules/foo/dist/subfolder/one.d.ts
//// export const one = 0;
// @Filename: /a.ts
//// import { } from "foo//**/";
verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: ["bar", "exact-match", "foo", "blah", "index", "subfolder"],
});
edit.insert("foo/");
verify.completions({
isNewIdentifierLocation: true,
exact: ["blah", "index", "foo", "subfolder"],
});
edit.insert("foo/");
verify.completions({
isNewIdentifierLocation: true,
exact: ["onlyInFooFolder"],
});
| {
"end_byte": 1335,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsTypesVersionsWildcard6.ts"
} |
TypeScript/tests/cases/fourslash/organizeImportsUnicode2.ts_0_663 | /// <reference path="fourslash.ts" />
//// import {
//// a2,
//// a100,
//// a1,
//// } from './foo';
////
//// console.log(a1, a2, a100);
verify.organizeImports(
`import {
a1,
a100,
a2,
} from './foo';
console.log(a1, a2, a100);`, /*mode*/ undefined, {
organizeImportsIgnoreCase: false,
organizeImportsCollation: "unicode",
organizeImportsNumericCollation: false,
});
verify.organizeImports(
`import {
a1,
a2,
a100,
} from './foo';
console.log(a1, a2, a100);`, /*mode*/ undefined, {
organizeImportsIgnoreCase: false,
organizeImportsCollation: "unicode",
organizeImportsNumericCollation: true,
});
| {
"end_byte": 663,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsUnicode2.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsExportConstEqualToClass.ts_0_202 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////class C {}
////export const /*0*/D = C;
// @Filename: /b.ts
////import { /*1*/D } from "./a";
verify.baselineFindAllReferences('0', '1')
| {
"end_byte": 202,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsExportConstEqualToClass.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_refactorAvailableInvoked2.ts_0_479 | /// <reference path='fourslash.ts' />
////class ns extends ap{
//// constructor() {}
////
//// export function fn() {
//// console.log("Hello"); /*a*//*b*/
//// }
//// fn();
////
////}
goTo.select("a", "b");
verify.refactorAvailableForTriggerReason("invoked", "Move to a new file",
/*actionName*/ undefined,
/*actionDescription*/ undefined,
/*kind*/ undefined,
{
allowTextChangesInNewFiles: true
},
/*includeInteractiveActions*/ true);
| {
"end_byte": 479,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_refactorAvailableInvoked2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements6.ts_0_349 | /// <reference path="fourslash.ts" />
// @noUnusedLocals: true
// @noUnusedParameters: true
////[|function f({
//// a,
//// b,
////
//// c,
////}: any)|] {
//// a;
//// c;
////}
verify.codeFix({
index: 0,
description: "Remove unused declaration for: 'b'",
newRangeContent:
`function f({
a,
c,
}: any)`
});
| {
"end_byte": 349,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements6.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionSatisfiesExpression1.ts_0_258 | /// <reference path="./fourslash.ts"/>
////const STRINGS = {
//// [|/*definition*/title|]: 'A Title',
////} satisfies Record<string,string>;
////
//////somewhere in app
////STRINGS.[|/*usage*/title|]
verify.baselineGoToDefinition("definition", "usage")
| {
"end_byte": 258,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionSatisfiesExpression1.ts"
} |
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc21.ts_0_1363 | /// <reference path='fourslash.ts' />
// @strict: true
/////**
//// * @return {number}
//// */
////function [|f|](x, y) {
//// return x + y;
////}
////
/////**
//// * @return {number}
//// */
////function g(x, y): number {
//// return x + y;
////}
/////**
//// * @param {number} x
//// */
////function h(x: number, y): number {
//// return x + y;
////}
////
/////**
//// * @param {number} x
//// * @param {string} y
//// */
////function i(x: number, y: string) {
//// return x + y;
////}
/////**
//// * @param {number} x
//// * @return {boolean}
//// */
////function j(x: number, y): boolean {
//// return x < y;
////}
// Only first location triggers a suggestion
verify.getSuggestionDiagnostics([{
message: "JSDoc types may be moved to TypeScript types.",
code: 80004,
}]);
verify.codeFix({
description: "Annotate with type from JSDoc",
errorCode: 80004,
newFileContent:
`/**
* @return {number}
*/
function f(x, y): number {
return x + y;
}
/**
* @return {number}
*/
function g(x, y): number {
return x + y;
}
/**
* @param {number} x
*/
function h(x: number, y): number {
return x + y;
}
/**
* @param {number} x
* @param {string} y
*/
function i(x: number, y: string) {
return x + y;
}
/**
* @param {number} x
* @return {boolean}
*/
function j(x: number, y): boolean {
return x < y;
}`,
});
| {
"end_byte": 1363,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc21.ts"
} |
TypeScript/tests/cases/fourslash/completionListOnAliases2.ts_0_1333 | /// <reference path='fourslash.ts' />
////module M {
//// export interface I { }
//// export class C {
//// static property;
//// }
//// export enum E {
//// value = 0
//// }
//// export module N {
//// export var v;
//// }
//// export var V = 0;
//// export function F() { }
//// export import A = M;
////}
////
////import m = M;
////import c = M.C;
////import e = M.E;
////import n = M.N;
////import v = M.V;
////import f = M.F;
////import a = M.A;
////
////m./*1*/;
////var tmp: m./*1Type*/;
////c./*2*/;
////e./*3*/;
////n./*4*/;
////v./*5*/;
////f./*6*/;
////a./*7*/;
////var tmp2: a./*7Type*/;
verify.completions(
// Module m / alias a
{ marker: ["1", "7"], unsorted: ["F", "C", "E", "N", "V", "A"] },
{ marker: ["1Type", "7Type"], unsorted: ["I", "C", "E", "A"] },
// Class C
{
marker: "2",
exact: completion.functionMembersPlus([
{ name: "property", sortText: completion.SortText.LocalDeclarationPriority },
{ name: "prototype", sortText: completion.SortText.LocationPriority },
])
},
// Enum E
{ marker: "3", exact: "value" },
// Module N
{ marker: "4", exact: "v" },
// var V
{ marker: "5", includes: "toFixed" },
// function F
{ marker: "6", includes: "call" },
);
| {
"end_byte": 1333,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListOnAliases2.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.