_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/moduleReferenceValue.ts_0_414 | /// <reference path='fourslash.ts'/>
////var x = 1;
////var r1, r2, r3, r4;
////module M {
//// r1 = x; // undefined
////}
////module M {
//// export var x = 2;
//// r2 = x; // 2
////}
////module M {
//// r3 = x; // 2
////}
////module M {
//// var x = 3;
//// r4 = x; // 3
////}
verify.noErrors();
verify.eval("r1", undefined);
verify.eval("r2", 2);
verify.eval("r3", 2);
verify.eval("r4", 3);
| {
"end_byte": 414,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moduleReferenceValue.ts"
} |
TypeScript/tests/cases/fourslash/goToTypeDefinitionImportMeta.ts_0_301 | /// <reference path='fourslash.ts' />
// @module: esnext
// @Filename: foo.ts
/////// <reference no-default-lib="true"/>
/////// <reference path='./bar.d.ts' />
////import.me/*reference*/ta;
//@Filename: bar.d.ts
////interface /*definition*/ImportMeta {
////}
verify.baselineGoToType("reference");
| {
"end_byte": 301,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToTypeDefinitionImportMeta.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType38.ts_0_168 | /// <reference path='fourslash.ts' />
//// type A = (v: string | number) => /*a*/v is string/*b*/
goTo.select("a", "b");
verify.not.refactorAvailable("Extract type")
| {
"end_byte": 168,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType38.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts_0_751 | /// <reference path='fourslash.ts' />
////interface I {
//// method(a: number, ...b: string[]): boolean;
//// method(a: string, b: number): Function;
//// method(a: string): Function;
////}
////
////class C implements I {}
verify.codeFix({
description: "Implement interface 'I'",
newFileContent:
`interface I {
method(a: number, ...b: string[]): boolean;
method(a: string, b: number): Function;
method(a: string): Function;
}
class C implements I {
method(a: number, ...b: string[]): boolean;
method(a: string, b: number): Function;
method(a: string): Function;
method(a: unknown, b?: unknown, ...rest?: unknown[]): boolean | Function {
throw new Error("Method not implemented.");
}
}`,
});
| {
"end_byte": 751,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport3.ts_0_891 | /// <reference path="fourslash.ts" />
//@noEmit: true
//@Filename: /package.json
////{
//// "dependencies": {
//// "b": "*"
//// }
////}
//@Filename: /node_modules/a/index.d.ts
////export const foo = 0;
//@Filename: /node_modules/a/package.json
////{
//// "name": "a",
//// "types": "./index.d.ts"
////}
//@Filename: /node_modules/b/index.d.ts
////export * from "a";
//@Filename: /node_modules/b/package.json
////{
//// "name": "b",
//// "types": "./index.d.ts"
////}
//@Filename: /src/index.ts
////fo/**/
verify.completions({
marker: test.marker(""),
includes: [
completion.undefinedVarEntry,
{
name: "foo",
source: "/node_modules/b/index",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
...completion.statementKeywordsWithTypes
],
preferences: {
includeCompletionsForModuleExports: true
}
});
| {
"end_byte": 891,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport3.ts"
} |
TypeScript/tests/cases/fourslash/convertFunctionToEs6Class7.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/convertFunctionToEs6Class7.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddConvertToUnknownForNonOverlappingTypes3.ts_0_209 | /// <reference path='fourslash.ts' />
////["words"] as string
verify.codeFix({
description: "Add 'unknown' conversion for non-overlapping types",
newFileContent: `["words"] as unknown as string`
});
| {
"end_byte": 209,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddConvertToUnknownForNonOverlappingTypes3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixTopLevelForAwait_target_compatibleCompilerOptionsInTsConfig.ts_0_318 | /// <reference path="fourslash.ts" />
// @filename: /dir/a.ts
////declare const p: number[];
////for await (const _ of p);
////export {};
// @filename: /dir/tsconfig.json
////{
//// "compilerOptions": {
//// "target": "es2017",
//// "module": "esnext"
//// }
////}
verify.not.codeFixAvailable();
| {
"end_byte": 318,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelForAwait_target_compatibleCompilerOptionsInTsConfig.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_MultiLine_Comment.ts_0_506 | /// <reference path='fourslash.ts' />
//// const foo = /*x*/f/*y*/unction() {
//// // secret
//// let a = 41;
//// /*
//// msg
//// */
//// return a + 1;
//// };
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to arrow function",
actionDescription: "Convert to arrow function",
newContent: `const foo = () => {
// secret
let a = 41;
/*
msg
*/
return a + 1;
};`,
});
| {
"end_byte": 506,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToArrow_MultiLine_Comment.ts"
} |
TypeScript/tests/cases/fourslash/codeFixNoPropertyAccessFromIndexSignature_fixAll.ts_0_1076 | /// <reference path='fourslash.ts'/>
// @noPropertyAccessFromIndexSignature: true
//// interface A {
//// foo: string
//// }
//// interface B {
//// [k: string]: string
//// }
//// interface C {
//// foo: string
//// [k: string]: string
//// }
//// declare const a: A;
//// declare const b: B;
//// declare const c: C;
//// declare const d: C | undefined;
//// a.foo;
//// a["foo"];
//// b.foo;
//// b["foo"];
//// c.foo;
//// c["foo"];
//// c.bar;
//// c["bar"];
//// d?.foo;
//// d?.["foo"];
//// d?.bar;
//// d?.["bar"];
verify.codeFixAll({
fixId: 'fixNoPropertyAccessFromIndexSignature',
fixAllDescription: ts.Diagnostics.Use_element_access_for_all_undeclared_properties.message,
newFileContent:
`interface A {
foo: string
}
interface B {
[k: string]: string
}
interface C {
foo: string
[k: string]: string
}
declare const a: A;
declare const b: B;
declare const c: C;
declare const d: C | undefined;
a.foo;
a["foo"];
b["foo"];
b["foo"];
c.foo;
c["foo"];
c["bar"];
c["bar"];
d?.foo;
d?.["foo"];
d?.["bar"];
d?.["bar"];`,
});
| {
"end_byte": 1076,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixNoPropertyAccessFromIndexSignature_fixAll.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpInParenthetical.ts_0_257 | /// <reference path='fourslash.ts' />
//// class base { constructor (public n: number, public y: string) { } }
//// (new base(/**/
verify.signatureHelp({ marker: "", parameterName: "n" });
edit.insert('0, ');
verify.signatureHelp({ parameterName: "y" });
| {
"end_byte": 257,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpInParenthetical.ts"
} |
TypeScript/tests/cases/fourslash/completionOfInterfaceAndVar.ts_0_416 | /// <reference path='fourslash.ts'/>
////interface AnalyserNode {
////}
////declare var AnalyserNode: {
//// prototype: AnalyserNode;
//// new(): AnalyserNode;
////};
/////**/
verify.completions({
marker: "",
includes: {
name: "AnalyserNode",
text:
`interface AnalyserNode
var AnalyserNode: {
new (): AnalyserNode;
prototype: AnalyserNode;
}`,
kind: "var",
},
});
| {
"end_byte": 416,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionOfInterfaceAndVar.ts"
} |
TypeScript/tests/cases/fourslash/autoImportCompletionExportListAugmentation1.ts_0_1286 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @Filename: /node_modules/@sapphire/pieces/index.d.ts
//// interface Container {
//// stores: unknown;
//// }
////
//// declare class Piece {
//// container: Container;
//// }
////
//// export { Piece, type Container };
// @FileName: /augmentation.ts
//// declare module "@sapphire/pieces" {
//// interface Container {
//// client: unknown;
//// }
//// export { Container };
//// }
// @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": 1286,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportCompletionExportListAugmentation1.ts"
} |
TypeScript/tests/cases/fourslash/inlayHintsInteractiveAnyParameter2.ts_0_399 | /// <reference path="fourslash.ts" />
//// function foo (v: any) {}
//// foo(1);
//// foo('');
//// foo(true);
//// foo(() => 1);
//// foo(function () { return 1 });
//// foo({});
//// foo({ a: 1 });
//// foo([]);
//// foo([1]);
//// foo(foo);
//// foo((1));
//// foo(foo(1));
verify.baselineInlayHints(undefined, {
includeInlayParameterNameHints: "all",
interactiveInlayHints: true
});
| {
"end_byte": 399,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsInteractiveAnyParameter2.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_punctuationPriority.ts_0_96 | /// <reference path="fourslash.ts" />
////console/**/.log();
verify.baselineSmartSelection();
| {
"end_byte": 96,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_punctuationPriority.ts"
} |
TypeScript/tests/cases/fourslash/addMemberNotInNodeModulesDeclarationFile.ts_0_407 | /// <reference path="fourslash.ts" />
// @noImplicitReferences: true
// @traceResolution: true
// @Filename: /node_modules/foo/types.d.ts
//// interface Response {}
// @Filename: /node_modules/foo/package.json
//// { "types": "types.d.ts" }
// @Filename: /foo.ts
//// import { Response } from 'foo'
//// declare const resp: Response
//// resp.test()
goTo.file('/foo.ts')
verify.not.codeFixAvailable()
| {
"end_byte": 407,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/addMemberNotInNodeModulesDeclarationFile.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationArrayLiteralExpressions.ts_0_508 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_arrayLiteralExpressions.baseline
// @Filename: bpSpan_arrayLiteralExpressions.ts
////var a = [10, 20, 30];
////function foo(a: number) {
//// return a;
////}
////a = [foo(30), (function () {
//// return 30;
////})()];
////function bar() {
//// return a;
////}
////var x = bar()[0];
////x = (function () {
//// return a;
////})()[x];
////a[(function () {
//// return x;
////})()];
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 508,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationArrayLiteralExpressions.ts"
} |
TypeScript/tests/cases/fourslash/completionListInTemplateLiteralPartsNegatives1.ts_0_230 | /// <reference path="fourslash.ts" />
////`/*0*/ /*1*/$ /*2*/{ /*3*/$/*4*/{ 10 + 1.1 }/*5*/ 12312/*6*/`
////
////`asdasd$/*7*/{ 2 + 1.1 }/*8*/ 12312 /*9*/{/*10*/
verify.completions({ marker: test.markers(), exact: undefined });
| {
"end_byte": 230,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInTemplateLiteralPartsNegatives1.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_CallExpressionComparison.ts_0_410 | /// <reference path='fourslash.ts' />
////let a = { b: { c: () => { } } };
/////*a*/a && a.b && a.b.c() === 1;/*b*/
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to optional chain expression",
actionName: "Convert to optional chain expression",
actionDescription: "Convert to optional chain expression",
newContent:
`let a = { b: { c: () => { } } };
a?.b?.c() === 1;`
}); | {
"end_byte": 410,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_CallExpressionComparison.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsForImportCallType.ts_0_335 | /// <reference path="fourslash.ts" />
// @Filename: /app.ts
//// export function he/**/llo() {};
// @Filename: /re-export.ts
//// export type app = typeof import("./app")
// @Filename: /indirect-use.ts
//// import type { app } from "./re-export";
//// declare const app: app
//// app.hello();
verify.baselineFindAllReferences("");
| {
"end_byte": 335,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForImportCallType.ts"
} |
TypeScript/tests/cases/fourslash/extract-method31.ts_0_766 | /// <reference path='fourslash.ts' />
//// /*start*/let value: string;
//// switch (Date.now()) {
//// case 1:
//// value = 'foo';
//// break;
//// default:
//// value = 'bar';
//// break;
//// }/*end*/
////
//// console.log(value);
goTo.select("start", "end");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_0",
actionDescription: "Extract to function in global scope",
newContent:
`let value: string = /*RENAME*/newFunction();
console.log(value);
function newFunction() {
let value: string;
switch (Date.now()) {
case 1:
value = 'foo';
break;
default:
value = 'bar';
break;
}
return value;
}
`
});
| {
"end_byte": 766,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method31.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportNodeModules2.ts_0_574 | /// <reference path="fourslash.ts" />
//// [|f1/*0*/();|]
// @Filename: ../package.json
//// { "dependencies": { "fake-module": "latest" } }
// @Filename: ../node_modules/fake-module/notindex.d.ts
//// export var v1 = 5;
//// export function f1();
// @Filename: ../node_modules/fake-module/notindex.js
//// module.exports = {
//// v1: 5,
//// f1: function () {}
//// };
// @Filename: ../node_modules/fake-module/package.json
//// { "main":"./notindex.js", "typings":"./notindex.d.ts" }
verify.importFixAtPosition([
`import { f1 } from "fake-module";
f1();`
]);
| {
"end_byte": 574,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportNodeModules2.ts"
} |
TypeScript/tests/cases/fourslash/inlineVariableParensPropertyAccess.ts_0_1139 | /// <reference path="fourslash.ts" />
////const /*a1*/foo/*b1*/ = {};
////foo.toString();
////const /*a2*/bar/*b2*/ = 0;
////bar.toFixed().toString();
////const /*a3*/pi/*b3*/ = 3.1416;
////pi.toPrecision(2);
goTo.select("a1", "b1");
verify.refactorAvailable("Inline variable");
edit.applyRefactor({
refactorName: "Inline variable",
actionName: "Inline variable",
actionDescription: "Inline variable",
newContent: `({}).toString();
const bar = 0;
bar.toFixed().toString();
const pi = 3.1416;
pi.toPrecision(2);`
});
goTo.select("a2", "b2");
verify.refactorAvailable("Inline variable");
edit.applyRefactor({
refactorName: "Inline variable",
actionName: "Inline variable",
actionDescription: "Inline variable",
newContent: `({}).toString();
(0).toFixed().toString();
const pi = 3.1416;
pi.toPrecision(2);`
});
goTo.select("a3", "b3");
verify.refactorAvailable("Inline variable");
edit.applyRefactor({
refactorName: "Inline variable",
actionName: "Inline variable",
actionDescription: "Inline variable",
newContent: `({}).toString();
(0).toFixed().toString();
(3.1416).toPrecision(2);`
});
| {
"end_byte": 1139,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableParensPropertyAccess.ts"
} |
TypeScript/tests/cases/fourslash/renameExportCrash.ts_0_189 | ///<reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: Foo.js
//// let a;
//// module.exports = /**/a;
//// exports["foo"] = a;
verify.baselineRename("", { });
| {
"end_byte": 189,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameExportCrash.ts"
} |
TypeScript/tests/cases/fourslash/refactorOverloadListToSingleSignature5.ts_0_680 | /// <reference path='fourslash.ts' />
////class A {
//// /*a*/constructor();
//// constructor(a: string);
//// constructor(a: number, b: number);
//// constructor(...rest: symbol[]);/*b*/
//// constructor(...args: any[]) {
//// // body
//// }
////}
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: `class A {
constructor(...args: [] | [a: string] | [a: number, b: number] | [...rest: symbol[]]) {
// body
}
}`,
});
| {
"end_byte": 680,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorOverloadListToSingleSignature5.ts"
} |
TypeScript/tests/cases/fourslash/thisPredicateFunctionCompletions01.ts_0_1471 | /// <reference path="fourslash.ts" />
//// class FileSystemObject {
//// isFile(): this is Item {
//// return this instanceof Item;
//// }
//// isDirectory(): this is Directory {
//// return this instanceof Directory;
//// }
//// isNetworked(): this is (Networked & this) {
//// return !!(this as Networked).host;
//// }
//// constructor(public path: string) {}
//// }
////
//// class Item extends FileSystemObject {
//// constructor(path: string, public content: string) { super(path); }
//// }
//// class Directory extends FileSystemObject {
//// children: FileSystemObject[];
//// }
//// interface Networked {
//// host: string;
//// }
////
//// const obj: FileSystemObject = new Item("/foo", "");
//// if (obj.isFile()) {
//// obj./*1*/;
//// if (obj.isNetworked()) {
//// obj./*2*/;
//// }
//// }
//// if (obj.isDirectory()) {
//// obj./*3*/;
//// if (obj.isNetworked()) {
//// obj./*4*/;
//// }
//// }
//// if (obj.isNetworked()) {
//// obj./*5*/;
//// }
const common: ReadonlyArray<string> = ["isFile", "isDirectory", "isNetworked", "path"];
verify.completions(
{ marker: "1", unsorted: ["content", ...common] },
{ marker: "2", unsorted: ["host", "content", ...common] },
{ marker: "3", unsorted: ["children", ...common] },
{ marker: "4", unsorted: ["host", "children", ...common] },
{ marker: "5", unsorted: ["host", ...common] },
);
| {
"end_byte": 1471,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/thisPredicateFunctionCompletions01.ts"
} |
TypeScript/tests/cases/fourslash/completionListInImportClause03.ts_0_385 | /// <reference path="fourslash.ts" />
////declare module "M1" {
//// export var abc: number;
//// export var def: string;
////}
////
////declare module "M2" {
//// import { abc/**/ } from "M1";
////}
// Ensure we don't filter out the current item.
verify.completions({ marker: "", exact: ["abc", "def", { name: "type", sortText: completion.SortText.GlobalsOrKeywords }] });
| {
"end_byte": 385,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInImportClause03.ts"
} |
TypeScript/tests/cases/fourslash/renameImportAndExport.ts_0_237 | /// <reference path='fourslash.ts' />
////[|import [|{| "contextRangeIndex": 0 |}a|] from "module";|]
////[|export { [|{| "contextRangeIndex": 2 |}a|] };|]
const [r0Def, r0, r1Def, r1] = test.ranges();
verify.baselineRename([r0, r1]);
| {
"end_byte": 237,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameImportAndExport.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics23.ts_0_307 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: a.js
//// function Person(age) {
//// if (age >= 18) {
//// this.canVote = true;
//// } else {
//// this.canVote = false;
//// }
//// }
verify.getSyntacticDiagnostics([]);
verify.getSemanticDiagnostics([]);
| {
"end_byte": 307,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics23.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsOfConstructor.ts_0_471 | /// <reference path="fourslash.ts" />
////class A {
//// /*aCtr*/constructor(s: string) {}
////}
////class B extends A { }
////class C extends B {
//// /*cCtr*/constructor() {
//// super("");
//// }
////}
////class D extends B { }
////class E implements A { }
////const a = new A("a");
////const b = new B("b");
////const c = new C();
////const d = new D("d");
////const e = new E();
verify.noErrors();
verify.baselineFindAllReferences('aCtr', 'cCtr')
| {
"end_byte": 471,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsOfConstructor.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingParam5.ts_0_257 | /// <reference path="fourslash.ts" />
////[|const f = function () {}|]
////
////f("");
verify.codeFix({
description: [ts.Diagnostics.Add_missing_parameter_to_0.message, "f"],
index: 0,
newRangeContent: "const f = function (p0: string) {}"
});
| {
"end_byte": 257,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingParam5.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesClassExpressionStatic.ts_0_534 | /// <reference path='fourslash.ts' />
////let A = class Foo {
//// public [|static|] foo;
//// [|static|] a;
//// constructor(public y: string, private x: string) {
//// }
//// public method() { }
//// private method2() {}
//// public [|static|] static() { }
//// private [|static|] static2() { }
////}
////
////let B = class D {
//// static a;
//// constructor(private x: number) {
//// }
//// private static test() {}
//// public static test2() {}
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 534,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesClassExpressionStatic.ts"
} |
TypeScript/tests/cases/fourslash/autoImportPackageJsonImportsPattern_js.ts_0_339 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @Filename: /package.json
//// {
//// "imports": {
//// "#*": "./src/*.js"
//// }
//// }
// @Filename: /src/something.ts
//// export function something(name: string): any;
// @Filename: /a.ts
//// something/**/
verify.importFixModuleSpecifiers("", ["#something"]);
| {
"end_byte": 339,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPackageJsonImportsPattern_js.ts"
} |
TypeScript/tests/cases/fourslash/extract-method20.ts_0_470 | /// <reference path='fourslash.ts' />
// Shouldn't be able to extract a readonly property initializer outside the constructor
//// class Foo {
//// readonly prop;
//// constructor() {
//// /*a*/this.prop = 10;/*b*/
//// }
//// }
goTo.select('a', 'b')
verify.refactorAvailable('Extract Symbol', 'function_scope_0');
verify.refactorAvailable('Extract Symbol', 'function_scope_1');
verify.not.refactorAvailable('Extract Symbol', 'function_scope_2');
| {
"end_byte": 470,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method20.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_moveJsxImport4.ts_0_645 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @noLib: true
// @libFiles: react.d.ts,lib.d.ts,leftpad.d.ts
// @Filename: file.tsx
//// import React = require('leftpad');
//// [|function F() {
//// const React = import("react");
//// <div/>;
//// }|]
//// React;
verify.moveToNewFile({
newFileContents: {
"/tests/cases/fourslash/file.tsx":
`import React = require('leftpad');
React;`,
// NB: A perfect implementation would not copy over the import
"/tests/cases/fourslash/F.tsx":
`import React = require('leftpad');
function F() {
const React = import("react");
<div />;
}
`,
}
});
| {
"end_byte": 645,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_moveJsxImport4.ts"
} |
TypeScript/tests/cases/fourslash/formattingOnOpenBraceOfFunctions.ts_0_181 | /// <reference path='fourslash.ts' />
/////**/function T2_y()
////{
////Plugin.T1.t1_x();
////}
format.document();
goTo.marker();
verify.currentLineContentIs("function T2_y() {"); | {
"end_byte": 181,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnOpenBraceOfFunctions.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpellingShortName2.ts_0_103 | /// <reference path='fourslash.ts' />
////export let ab = 1;
////abc;
verify.not.codeFixAvailable();
| {
"end_byte": 103,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingShortName2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixPropertyAssignment2.ts_0_227 | /// <reference path='fourslash.ts'/>
////const a = {
//// x /**/= 1
////}
verify.codeFix({
description: [ts.Diagnostics.Change_0_to_1.message, "=", ":"],
index: 0,
newFileContent:
`const a = {
x: 1
}`,
});
| {
"end_byte": 227,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixPropertyAssignment2.ts"
} |
TypeScript/tests/cases/fourslash/paramHelpOnCommaInString.ts_0_292 | /// <reference path='fourslash.ts'/>
////function blah(foo: string, bar: number) {
////}
////blah('hola/*1*/,/*2*/')
// making sure the comma in a string literal doesn't trigger param help on the second function param
verify.signatureHelp({ marker: test.markers(), parameterName: "foo" });
| {
"end_byte": 292,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/paramHelpOnCommaInString.ts"
} |
TypeScript/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration2.ts_3_670 | / <reference path='fourslash.ts'/>
// @Filename: file1.ts
//// class Foo {
//// // This is not valid syntax: parameter property can't be binding pattern
//// constructor(private {[|privateParam|]}: number,
//// public {[|publicParam|]}: string,
//// protected {[|protectedParam|]}: boolean) {
////
//// let localPrivate = [|privateParam|];
//// this.privateParam += 10;
////
//// let localPublic = [|publicParam|];
//// this.publicParam += " Hello!";
////
//// let localProtected = [|protectedParam|];
//// this.protectedParam = false;
//// }
//// }
verify.baselineDocumentHighlights();
| {
"end_byte": 670,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlightAtParameterPropertyDeclaration2.ts"
} |
TypeScript/tests/cases/fourslash/jsDocExtends.ts_0_416 | ///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: dummy.js
//// /**
//// * @extends {Thing<string>}
//// */
//// class MyStringThing extends Thing {
//// constructor() {
//// var x = this.mine;
//// x/**/;
//// }
//// }
// @Filename: declarations.d.ts
//// declare class Thing<T> {
//// mine: T;
//// }
goTo.marker();
verify.quickInfoIs("(local var) x: string");
| {
"end_byte": 416,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocExtends.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateCommentNoExpr.ts_0_408 | /// <reference path='fourslash.ts' />
//// const foo = /* C0 */ /*x*/"/*y*/foo" /* C1 */ + " is"/* C2 */ /* 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 */ /* C3 */",
});
| {
"end_byte": 408,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateCommentNoExpr.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationInvalid.ts_0_208 | /// <reference path='fourslash.ts'/>
// Should not crash when invoked on an invalid location
//// var x1 = 50/*0*/0;
//// var x2 = "hel/*1*/lo";
//// /*2*/
verify.baselineGoToImplementation("0", "1", "2"); | {
"end_byte": 208,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationInvalid.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportFileQuoteStyle2.ts_0_317 | /// <reference path="fourslash.ts" />
//// [|import m2 = require('./module2');
////
//// f1/*0*/();|]
// @Filename: module1.ts
//// export function f1() {}
// @Filename: module2.ts
//// export var v2 = 6;
verify.importFixAtPosition([
`import { f1 } from './module1';
import m2 = require('./module2');
f1();`
]);
| {
"end_byte": 317,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportFileQuoteStyle2.ts"
} |
TypeScript/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning1.ts_0_236 | ///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: a.js
/////** @typedef {number} */
/////*1*/const /*2*/T = 1;
/////** @type {/*3*/T} */
////const n = /*4*/T;
verify.baselineFindAllReferences('1', '2', '3', '4');
| {
"end_byte": 236,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning1.ts"
} |
TypeScript/tests/cases/fourslash/completionsGenericIndexedAccess4.ts_0_1054 | /// <reference path="fourslash.ts" />
////interface CustomElements {
//// 'component-one': {
//// foo?: string;
//// },
//// 'component-two': {
//// bar?: string;
//// }
////}
////
////interface Options<T extends keyof CustomElements> {
//// props: CustomElements[T];
////}
////
////declare function create<T extends 'hello' | 'goodbye'>(name: T, options: Options<T extends 'hello' ? 'component-one' : 'component-two'>): void;
////declare function create<T extends keyof CustomElements>(name: T, options: Options<T>): void;
////
////create('hello', { props: { /*1*/ } })
////create('goodbye', { props: { /*2*/ } })
////create('component-one', { props: { /*3*/ } });
verify.completions({
marker: "1",
exact: [{
name: "foo",
sortText: completion.SortText.OptionalMember
}]
});
verify.completions({
marker: "2",
exact: [{
name: "bar",
sortText: completion.SortText.OptionalMember
}]
});
verify.completions({
marker: "3",
exact: [{
name: "foo",
sortText: completion.SortText.OptionalMember
}]
});
| {
"end_byte": 1054,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsGenericIndexedAccess4.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType29.ts_0_386 | /// <reference path='fourslash.ts' />
//// type Item<T> = T extends (infer P)[] ? /*a*/P/*b*/ : never;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent: `type /*RENAME*/NewType<P> = P;
type Item<T> = T extends (infer P)[] ? NewType<P> : never;`,
});
| {
"end_byte": 386,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType29.ts"
} |
TypeScript/tests/cases/fourslash/completionsImportBaseUrl.ts_0_704 | /// <reference path="fourslash.ts" />
// @Filename: /tsconfig.json
////{
//// "compilerOptions": {
//// "baseUrl": ".",
//// "module": "esnext"
//// }
////}
// @Filename: /src/a.ts
////export const foo = 0;
// @Filename: /src/b.ts
////fo/**/
// Test that it prefers a relative import (see sourceDisplay).
verify.completions({
marker: "",
includes: {
name: "foo",
source: "/src/a",
sourceDisplay: "./a",
text: "const foo: 0",
kind: "const",
kindModifiers: "export",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences: { includeCompletionsForModuleExports: true },
});
| {
"end_byte": 704,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImportBaseUrl.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_JSDocTags4.ts_0_249 | /// <reference path="fourslash.ts" />
/////**
//// * @typedef {object} Foo
//// * @property {string} a
//// * @property {number} b
//// * @property {/**/number} c
//// */
////
/////** @type {Foo} */
////const foo;
verify.baselineSmartSelection();
| {
"end_byte": 249,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_JSDocTags4.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString2.ts_0_423 | /// <reference path='fourslash.ts' />
////const foo = 1;
////const bar = /*start*/"a" + `${foo}`/*end*/;
goTo.select("start", "end");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
newContent: [
"const foo = 1;",
"const bar = `a${foo}`;"
].join("\n")
});
| {
"end_byte": 423,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString2.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationLet.ts_0_448 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_let.baseline
// @Filename: bpSpan_let.ts
////let l1;
////let l2: number;
////let l3, l4, l5 :string, l6;
////let l7 = false;
////let l8: number = 23;
////let l9 = 0, l10 :string = "", l11 = null;
////for(let l11 in {}) { }
////for(let l12 = 0; l12 < 9; l12++) { }
////module M {
//// let ll1 = "s";
//// export let ll2 = 0;
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 448,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationLet.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentClass.ts_0_555 | /// <reference path='fourslash.ts'/>
////class Bar {
//// {| "indentation": 4|}
//// private foo: string = "";
//// {| "indentation": 4|}
//// private f() {
//// var a: any[] = [[1, 2], [3, 4], 5];
//// {| "indentation": 8|}
//// return ((1 + 1));
//// }
//// {| "indentation": 4|}
//// private f2() {
//// if (true) { } { };
//// }
////}
////{| "indentation": 0|}
test.markers().forEach((marker) => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation);
});
| {
"end_byte": 555,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentClass.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddOptionalParam4.ts_0_241 | /// <reference path="fourslash.ts" />
////[|function f() {}|]
////
////f("");
verify.codeFix({
description: [ts.Diagnostics.Add_optional_parameter_to_0.message, "f"],
index: 1,
newRangeContent: "function f(p0?: string) {}"
});
| {
"end_byte": 241,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddOptionalParam4.ts"
} |
TypeScript/tests/cases/fourslash/navigationItemsExportEqualsExpression.ts_0_2242 | // 35477
/// <reference path="fourslash.ts"/>
//// export = function () {}
//// export = function () {
//// return class Foo {
//// }
//// }
////
//// export = () => ""
//// export = () => {
//// return class Foo {
//// }
//// }
////
//// export = function f1() {}
//// export = function f2() {
//// return class Foo {
//// }
//// }
////
//// const abc = 12;
//// export = abc;
//// export = class AB {}
//// export = {
//// a: 1,
//// b: 1,
//// c: {
//// d: 1
//// }
//// }
verify.navigationTree({
"text": '"navigationItemsExportEqualsExpression"',
"kind": "module",
"childItems": [
{
"text": "export=",
"kind": "function",
"kindModifiers": "export"
},
{
"text": "export=",
"kind": "function",
"kindModifiers": "export",
"childItems": [
{
"text": "Foo",
"kind": "class"
}
]
},
{
"text": "export=",
"kind": "function",
"kindModifiers": "export"
},
{
"text": "export=",
"kind": "function",
"kindModifiers": "export",
"childItems": [
{
"text": "Foo",
"kind": "class"
}
]
},
{
"text": "export=",
"kind": "function",
"kindModifiers": "export"
},
{
"text": "export=",
"kind": "function",
"kindModifiers": "export",
"childItems": [
{
"text": "Foo",
"kind": "class"
}
]
},
{
"text": "export=",
"kind": "class",
"kindModifiers": "export"
},
{
"text": "export=",
"kind": "const",
"kindModifiers": "export",
"childItems": [
{
"text": "a",
"kind": "property"
},
{
"text": "b",
"kind": "property"
},
{
"text": "c",
"kind": "property",
"childItems": [
{
"text": "d",
"kind": "property"
}
]
}
]
},
{
"text": "abc",
"kind": "const"
},
{
"text": "export=",
"kind": "const",
"kindModifiers": "export"
}
]
});
| {
"end_byte": 2242,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationItemsExportEqualsExpression.ts"
} |
TypeScript/tests/cases/fourslash/tslibFindAllReferencesOnRuntimeImportWithPaths1.ts_0_707 | /// <reference path="fourslash.ts" />
// @Filename: project/src/foo.ts
////import * as x from /**/"tslib";
// @Filename: project/src/bar.ts
////export default "";
// @Filename: project/src/bal.ts
////
// @Filename: project/src/dir/tslib.d.ts
////export function __importDefault(...args: any): any;
////export function __importStar(...args: any): any;
// @Filename: project/tsconfig.json
////{
//// "compilerOptions": {
//// "moduleResolution": "node",
//// "module": "es2020",
//// "importHelpers": true,
//// "moduleDetection": "force",
//// "paths": {
//// "tslib": ["./src/dir/tslib"]
//// }
//// }
////}
verify.baselineFindAllReferences("");
| {
"end_byte": 707,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tslibFindAllReferencesOnRuntimeImportWithPaths1.ts"
} |
TypeScript/tests/cases/fourslash/formattingReadonly.ts_0_324 | /// <reference path='fourslash.ts' />
////class C {
//// readonly property1: {};/*1*/
//// public readonly property2: {};/*2*/
////}
format.document();
goTo.marker("1");
verify.currentLineContentIs(" readonly property1: {};");
goTo.marker("2");
verify.currentLineContentIs(" public readonly property2: {};");
| {
"end_byte": 324,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingReadonly.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpCallExpressionJs.ts_0_822 | /// <reference path='fourslash.ts'/>
// @checkJs: true
// @allowJs: true
// @Filename: main.js
////function allOptional() { arguments; }
////allOptional(/*1*/);
////allOptional(1, 2, 3);
////function someOptional(x, y) { arguments; }
////someOptional(/*2*/);
////someOptional(1, 2, 3);
////someOptional(); // no error here; x and y are optional in JS
verify.noErrors();
verify.signatureHelp(
{
marker: "1",
text: "allOptional(...args: any[]): void",
parameterCount: 1,
parameterName: "args",
parameterSpan: "...args: any[]",
isVariadic: true,
},
{
marker: "2",
text: "someOptional(x: any, y: any, ...args: any[]): void",
parameterCount: 3,
parameterName: "x",
parameterSpan: "x: any",
isVariadic: true,
});
| {
"end_byte": 822,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpCallExpressionJs.ts"
} |
TypeScript/tests/cases/fourslash/formatImportDeclaration.ts_0_410 | /// <reference path='fourslash.ts' />
////module Foo {/*1*/
////}/*2*/
////
////import bar = Foo;/*3*/
////
////import bar2=Foo;/*4*/
format.document();
goTo.marker("1");
verify.currentLineContentIs("module Foo {");
goTo.marker("2");
verify.currentLineContentIs("}");
goTo.marker("3");
verify.currentLineContentIs("import bar = Foo;");
goTo.marker("4");
verify.currentLineContentIs("import bar2 = Foo;"); | {
"end_byte": 410,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatImportDeclaration.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForGenericPrototypeMember.ts_0_250 | /// <reference path='fourslash.ts'/>
////class C<T> {
//// foo(x: T) { }
////}
////var x = new /*1*/C<any>();
////var y = C.proto/*2*/type;
verify.quickInfos({
1: "constructor C<any>(): C<any>",
2: "(property) C<T>.prototype: C<any>"
});
| {
"end_byte": 250,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForGenericPrototypeMember.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports26-fn-in-object-literal.ts_0_856 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
// fileName: code.ts
////export const extensions = {
//// /**
//// */
//// fn: <T>(actualValue: T, expectedValue: T) => {
//// return actualValue === expectedValue
//// },
//// fn2: function<T>(actualValue: T, expectedValue: T) {
//// return actualValue === expectedValue
//// }
////}
verify.codeFixAll({
fixId: "fixMissingTypeAnnotationOnExports",
fixAllDescription: ts.Diagnostics.Add_all_missing_type_annotations.message,
newFileContent:
`export const extensions = {
/**
*/
fn: <T>(actualValue: T, expectedValue: T): boolean => {
return actualValue === expectedValue
},
fn2: function<T>(actualValue: T, expectedValue: T): boolean {
return actualValue === expectedValue
}
}`
})
| {
"end_byte": 856,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports26-fn-in-object-literal.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringForObjectBindingPatternDefaultValues.ts_0_3219 | /// <reference path='fourslash.ts' />
////declare var console: {
//// log(msg: any): void;
////}
////interface Robot {
//// name: string;
//// skill: string;
////}
////interface MultiRobot {
//// name: string;
//// skills: {
//// primary?: string;
//// secondary?: string;
//// };
////}
////let robot: Robot = { name: "mower", skill: "mowing" };
////let multiRobot: MultiRobot = { name: "mower", skills: { primary: "mowing", secondary: "none" } };
////function getRobot() {
//// return robot;
////}
////function getMultiRobot() {
//// return multiRobot;
////}
////for (let {name: nameA= "noName" } = robot, i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for (let {name: nameA = "noName" } = getRobot(), i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for (let {name: nameA = "noName" } = <Robot>{ name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for (let {
//// skills: {
//// primary: primaryA = "primary",
//// secondary: secondaryA = "secondary"
//// } = { primary: "none", secondary: "none" }
////} = multiRobot, i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for (let {
//// skills: {
//// primary: primaryA = "primary",
//// secondary: secondaryA = "secondary"
//// } = { primary: "none", secondary: "none" }
////} = getMultiRobot(), i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for (let {
//// skills: {
//// primary: primaryA = "primary",
//// secondary: secondaryA = "secondary"
//// } = { primary: "none", secondary: "none" }
////} = <MultiRobot>{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } },
//// i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for (let {name: nameA = "noName", skill: skillA = "skill" } = robot, i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for (let {name: nameA = "noName", skill: skillA = "skill" } = getRobot(), i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for (let {name: nameA = "noName", skill: skillA = "skill" } = <Robot>{ name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for (let {
//// name: nameA = "noName",
//// skills: {
//// primary: primaryA = "primary",
//// secondary: secondaryA = "secondary"
//// } = { primary: "none", secondary: "none" }
////} = multiRobot, i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for (let {
//// name: nameA = "noName",
//// skills: {
//// primary: primaryA = "primary",
//// secondary: secondaryA = "secondary"
//// } = { primary: "none", secondary: "none" }
////} = getMultiRobot(), i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
////for (let {
//// name: nameA = "noName",
//// skills: {
//// primary: primaryA = "primary",
//// secondary: secondaryA = "secondary"
//// } = { primary: "none", secondary: "none" }
////} = <MultiRobot>{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } },
//// i = 0; i < 1; i++) {
//// console.log(primaryA);
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 3219,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringForObjectBindingPatternDefaultValues.ts"
} |
TypeScript/tests/cases/fourslash/formattingGlobalAugmentation1.ts_0_186 | /// <reference path="fourslash.ts"/>
/////*1*/declare global {
////}
format.document();
goTo.marker("1");
verify.currentLineContentIs("declare global {"); | {
"end_byte": 186,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingGlobalAugmentation1.ts"
} |
TypeScript/tests/cases/fourslash/refactorExtractType78.ts_0_435 | /// <reference path='fourslash.ts' />
//// type A = { a: string } | /*1*/{ b: string } | { c: string }/*2*/ | { d: string };
goTo.select("1", "2");
edit.applyRefactor({
refactorName: "Extract type",
actionName: "Extract to type alias",
actionDescription: "Extract to type alias",
newContent:
`type /*RENAME*/NewType = {
b: string;
} | {
c: string;
};
type A = { a: string } | NewType | { d: string };`,
});
| {
"end_byte": 435,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType78.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCannotFindModuleJsxRuntimePragma01.ts_0_508 | /// <reference path='fourslash.ts' />
// @module: preserve
// @target: esnext
// @moduleResolution: bundler
// @jsx: react-jsx
// @Filename: /file.tsx
/////** @jsxImportSource @emotion/react */
////export let jsxExpr = <div />;
test.setTypesRegistry({
"@emotion/react": undefined,
});
verify.codeFixAvailable([{
description: "Install '@types/emotion__react'",
commands: [{
file: "/file.tsx",
type: "install package",
packageName: "@types/emotion__react",
}],
}]);
| {
"end_byte": 508,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCannotFindModuleJsxRuntimePragma01.ts"
} |
TypeScript/tests/cases/fourslash/renameForDefaultExport02.ts_0_563 | /// <reference path='fourslash.ts'/>
////[|export default function /*1*/[|{| "contextRangeIndex": 0 |}DefaultExportedFunction|]() {
//// return /*2*/[|DefaultExportedFunction|]
////}|]
/////**
//// * Commenting [|{| "inComment": true |}DefaultExportedFunction|]
//// */
////
////var x: typeof /*3*/[|DefaultExportedFunction|];
////
////var y = /*4*/[|DefaultExportedFunction|]();
const ranges = test.rangesByText().get("DefaultExportedFunction");
verify.baselineRename(ranges.filter(r => !(r.marker && r.marker.data.inComment)), { findInComments: true, });
| {
"end_byte": 563,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameForDefaultExport02.ts"
} |
TypeScript/tests/cases/fourslash/completionImportModuleSpecifierEndingUnsupportedExtension.ts_0_393 | /// <reference path='fourslash.ts'/>
//@Filename:index.css
//// body {}
//@Filename:module.ts
////import ".//**/"
verify.completions({ marker: "", excludes:"index.css", preferences: {importModuleSpecifierEnding: "js" }, isNewIdentifierLocation: true});
verify.completions({ marker: "", excludes:"index", preferences: {importModuleSpecifierEnding: "index" }, isNewIdentifierLocation: true});
| {
"end_byte": 393,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionImportModuleSpecifierEndingUnsupportedExtension.ts"
} |
TypeScript/tests/cases/fourslash/jsdocDeprecated_suggestion15.ts_0_706 | /// <reference path="fourslash.ts" />
// @module: esnext
// @filename: /a.ts
////export const a = 1;
////export const b = 1;
// @filename: /b.ts
////export {
//// /** @deprecated a is deprecated */
//// a
////} from "./a";
// @filename: /c.ts
////export {
//// a
////} from "./b";
// @filename: /d.ts
////import { [|a|] } from "./c";
////[|a|]
goTo.file("/d.ts")
verify.getSuggestionDiagnostics([
{
"code": 6385,
"message": "'a' is deprecated.",
"reportsDeprecated": true,
"range": test.ranges()[0]
},
{
"code": 6385,
"message": "'a' is deprecated.",
"reportsDeprecated": true,
"range": test.ranges()[1]
},
]);
| {
"end_byte": 706,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocDeprecated_suggestion15.ts"
} |
TypeScript/tests/cases/fourslash/getEmitOutputWithSemanticErrorsForMultipleFiles2.ts_0_567 | /// <reference path="fourslash.ts" />
// @BaselineFile: getEmitOutputWithSemanticErrorsForMultipleFiles2.baseline
// @declaration: true
// @outFile: out.js
// @Filename: inputFile1.ts
// @emitThisFile: true
//// // File to emit, does not contain semantic errors, but --out is passed
//// // expected to not generate declarations because of the semantic errors in the other file
//// var noErrors = true;
// @Filename: inputFile2.ts
//// // File not emitted, and contains semantic errors
//// var semanticError: boolean = "string";
verify.baselineGetEmitOutput();
| {
"end_byte": 567,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputWithSemanticErrorsForMultipleFiles2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports54-generator-generics.ts_0_375 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
// @lib: es2015
//// export function foo(x: Generator<number>) {
//// return x;
//// }
verify.codeFix({
description: "Add return type 'Generator<number>'",
index: 0,
newFileContent:
`export function foo(x: Generator<number>): Generator<number> {
return x;
}`
});
| {
"end_byte": 375,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports54-generator-generics.ts"
} |
TypeScript/tests/cases/fourslash/gotoDefinitionInObjectBindingPattern2.ts_0_271 | /// <reference path='fourslash.ts' />
//// var p0 = ({a/*1*/a}) => {console.log(aa)};
//// function f2({ [|a/*a1*/1|], [|b/*b1*/1|] }: { /*a1_dest*/a1: number, /*b1_dest*/b1: number } = { a1: 0, b1: 0 }) {}
verify.baselineGoToDefinition(
"1",
"a1",
"b1",
); | {
"end_byte": 271,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/gotoDefinitionInObjectBindingPattern2.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_expandSelectionRange2.ts_0_486 | /// <reference path='fourslash.ts' />
//@Filename: /bar.ts
////import { b } from './other';
////const t = b;
// @Filename: /a.ts
////co[|nst a = 1;
////cons|]t b = 1;
////function foo() { }
// @Filename: /other.ts
////export const b = 2;
verify.moveToFile({
newFileContents: {
"/a.ts":
`function foo() { }`,
"/bar.ts":
`import { b } from './other';
const t = b;
const a = 1;
const b = 1;
`,
},
interactiveRefactorArguments: { targetFile: "/bar.ts" }
}); | {
"end_byte": 486,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_expandSelectionRange2.ts"
} |
TypeScript/tests/cases/fourslash/extract-method45.ts_0_1156 | /// <reference path="fourslash.ts" />
////export function fn(m: number) {
//// const mode = m >= 0 ? "a" : "b";
//// let result: number = 0;
////
//// if (mode === "a") {
//// /*a*/for (let i = 0; i < 10; i++) {
//// const rand = Math.random();
//// if (rand > 0.5) {
//// result = rand;
//// break;
//// }
//// }/*b*/
//// }
//// else {
//// result = 0;
//// }
////
//// return result;
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_1",
actionDescription: "Extract to function in module scope",
newContent:
`export function fn(m: number) {
const mode = m >= 0 ? "a" : "b";
let result: number = 0;
if (mode === "a") {
result = /*RENAME*/newFunction(result);
}
else {
result = 0;
}
return result;
}
function newFunction(result: number) {
for (let i = 0; i < 10; i++) {
const rand = Math.random();
if (rand > 0.5) {
result = rand;
break;
}
}
return result;
}
`
});
| {
"end_byte": 1156,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method45.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesSwitchCaseDefault5.ts_0_504 | /// <reference path='fourslash.ts' />
////switch/*1*/ (10) {
//// case/*2*/ 1:
//// case/*3*/ 2:
//// case/*4*/ 4:
//// case/*5*/ 8:
//// foo: switch/*6*/ (20) {
//// case/*7*/ 1:
//// case/*8*/ 2:
//// break/*9*/;
//// default/*10*/:
//// break foo;
//// }
//// case/*11*/ 0xBEEF:
//// default/*12*/:
//// break/*13*/;
//// case 16/*14*/:
////}
verify.baselineDocumentHighlights(test.markers());
| {
"end_byte": 504,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesSwitchCaseDefault5.ts"
} |
TypeScript/tests/cases/fourslash/referencesBloomFilters2.ts_0_447 | /// <reference path='fourslash.ts'/>
// Ensure BloomFilter building logic is correct, by having one reference per file
// @Filename: declaration.ts
////var container = { /*1*/42: 1 };
// @Filename: expression.ts
////function blah() { return (container[42]) === 2; };
// @Filename: stringIndexer.ts
////function blah2() { container["42"] };
// @Filename: redeclaration.ts
////container = { "42" : 18 };
verify.baselineFindAllReferences('1')
| {
"end_byte": 447,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesBloomFilters2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpellingAddSpaces1.ts_0_731 | /// <reference path='fourslash.ts' />
// Repro for https://github.com/microsoft/TypeScript/issues/49557
////enum NamesWithSpaces {
//// "NoSpace",
//// "One Space",
//// "Has Two Spaces",
//// "This Has Three Spaces",
//// "And This Has Four Spaces",
////
//// "Block One",
//// "Block Two",
//// "Block Three",
////
//// "This Has Three Spaces_________________________________________________________",
//// "And This Has Four Spaces_________________________________________________________",
////}
////
//// NamesWithSpaces.[|ThisHasThreeSpaces|];
verify.codeFixAvailable([
{ description: "Change spelling to 'This Has Three Spaces'" },
{ description: "Add missing enum member 'ThisHasThreeSpaces'" },
]); | {
"end_byte": 731,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingAddSpaces1.ts"
} |
TypeScript/tests/cases/fourslash/isInMultiLineCommentInJsxText.ts_0_413 | /// <reference path="fourslash.ts" />
// @Filename: file.jsx
//// <div>
//// // /*0*/
//// /* /*1*/ */
//// /**
//// * /*2*/
//// */
//// foo() /* /*3*/ */
//// // /*4*/
//// /* /*5*/ */
//// /**
//// * /*6*/
//// */
//// </div>
//// <div>
//// // /*7*/
//// /* /*8*/ */
//// /**
//// * /*9*/
//// */
for (let i = 0; i < 10; ++i) {
goTo.marker(i.toString());
verify.not.isInCommentAtPosition();
}
| {
"end_byte": 413,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/isInMultiLineCommentInJsxText.ts"
} |
TypeScript/tests/cases/fourslash/isDefinitionOverloads.ts_0_235 | /// <reference path='fourslash.ts'/>
////function /*1*/f(x: number): void;
////function /*2*/f(x: string): void;
////function /*3*/f(x: number | string) { }
////
////f(1);
////f("a");
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 235,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/isDefinitionOverloads.ts"
} |
TypeScript/tests/cases/fourslash/memberListOfModuleBeforeKeyword.ts_0_476 | /// <reference path='fourslash.ts'/>
////module TypeModule1 {
//// export class C1 { }
//// export class C2 { }
////}
////var x: TypeModule1./*namedType*/
////module TypeModule2 {
//// export class Test3 {}
////}
////
////TypeModule1./*dottedExpression*/
////module TypeModule3 {
//// export class Test3 {}
////}
// Verify the memberlist of module when the following line has a keyword
verify.completions(
{ marker: test.markers(), exact: ["C1", "C2"] },
);
| {
"end_byte": 476,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberListOfModuleBeforeKeyword.ts"
} |
TypeScript/tests/cases/fourslash/removeDeclareKeyword.ts_0_137 | /// <reference path="fourslash.ts" />
//// /**/declare var y;
//// var x = new y;
goTo.marker();
edit.deleteAtCaret('declare'.length);
| {
"end_byte": 137,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/removeDeclareKeyword.ts"
} |
TypeScript/tests/cases/fourslash/extract-method14.ts_0_637 | /// <reference path='fourslash.ts' />
// Don't emit type annotations in JavaScript files
// Also tests that single-variable return extractions don't get superfluous destructuring
// @allowNonTsExtensions: true
// @Filename: foo.js
//// function foo() {
//// var i = 10;
//// /*a*/return i + 1;/*b*/
//// }
goTo.select('a', 'b');
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_1",
actionDescription: "Extract to function in global scope",
newContent:
`function foo() {
var i = 10;
return /*RENAME*/newFunction(i);
}
function newFunction(i) {
return i + 1;
}
`
});
| {
"end_byte": 637,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method14.ts"
} |
TypeScript/tests/cases/fourslash/typeCheckObjectInArrayLiteral.ts_0_142 | /// <reference path="fourslash.ts" />
//// declare function create<T>(initialValues);
//// create([{}]);
goTo.position(0);
edit.insert('');
| {
"end_byte": 142,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/typeCheckObjectInArrayLiteral.ts"
} |
TypeScript/tests/cases/fourslash/referencesBloomFilters.ts_0_489 | /// <reference path='fourslash.ts'/>
// Ensure BloomFilter building logic is correct, by having one reference per file
// @Filename: declaration.ts
////var container = { /*1*/searchProp : 1 };
// @Filename: expression.ts
////function blah() { return (1 + 2 + container.searchProp()) === 2; };
// @Filename: stringIndexer.ts
////function blah2() { container["searchProp"] };
// @Filename: redeclaration.ts
////container = { "searchProp" : 18 };
verify.baselineFindAllReferences('1')
| {
"end_byte": 489,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesBloomFilters.ts"
} |
TypeScript/tests/cases/fourslash/referencesForModifiers.ts_0_783 | /// <reference path='fourslash.ts'/>
////[|/*declareModifier*/declare /*abstractModifier*/abstract class C1 {
//// [|/*staticModifier*/static a;|]
//// [|/*readonlyModifier*/readonly b;|]
//// [|/*publicModifier*/public c;|]
//// [|/*protectedModifier*/protected d;|]
//// [|/*privateModifier*/private e;|]
////}|]
////[|/*constModifier*/const enum E {
////}|]
////[|/*asyncModifier*/async function fn() {}|]
////[|/*exportModifier*/export /*defaultModifier*/default class C2 {}|]
verify.baselineFindAllReferences(
"declareModifier",
"abstractModifier",
"staticModifier",
"readonlyModifier",
"publicModifier",
"protectedModifier",
"privateModifier",
"constModifier",
"asyncModifier",
"exportModifier",
"defaultModifier",)
| {
"end_byte": 783,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForModifiers.ts"
} |
TypeScript/tests/cases/fourslash/isDefinitionSingleReference.ts_0_122 | /// <reference path='fourslash.ts'/>
////function /*1*/f() {}
/////*2*/f();
verify.baselineFindAllReferences('1', '2');
| {
"end_byte": 122,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/isDefinitionSingleReference.ts"
} |
TypeScript/tests/cases/fourslash/renameParameterPropertyDeclaration5.ts_0_276 | /// <reference path='fourslash.ts'/>
//// class Foo {
//// constructor([|protected [ [|{| "contextRangeIndex": 0 |}protectedParam|] ]|]) {
//// let myProtectedParam = [|protectedParam|];
//// }
//// }
verify.baselineRenameAtRangesWithText("protectedParam");
| {
"end_byte": 276,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameParameterPropertyDeclaration5.ts"
} |
TypeScript/tests/cases/fourslash/renameNameOnEnumMember.ts_0_241 | /// <reference path="fourslash.ts"/>
////enum e {
//// firstMember,
//// secondMember,
//// thirdMember
////}
////var enumMember = e.[|/**/thirdMember|];
goTo.marker("");
verify.renameInfoSucceeded("thirdMember", "e.thirdMember"); | {
"end_byte": 241,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameNameOnEnumMember.ts"
} |
TypeScript/tests/cases/fourslash/codeFixImplicitThis_ts_functionExpression.ts_0_403 | /// <reference path='fourslash.ts' />
// @noImplicitThis: true
////class C {
//// m() {
//// return function f() {
//// return this;
//// };
//// }
////}
verify.codeFix({
description: "Convert function expression 'f' to arrow function",
index: 0,
newFileContent:
`class C {
m() {
return () => {
return this;
};
}
}`,
});
| {
"end_byte": 403,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixImplicitThis_ts_functionExpression.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsRedeclaredPropertyInDerivedInterface.ts_0_307 | /// <reference path='fourslash.ts' />
// @noLib: true
////interface A {
//// readonly /*0*/x: number | string;
////}
////interface B extends A {
//// readonly /*1*/x: number;
////}
////const a: A = { /*2*/x: 0 };
////const b: B = { /*3*/x: 0 };
verify.baselineFindAllReferences('0', '1', '2', '3')
| {
"end_byte": 307,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsRedeclaredPropertyInDerivedInterface.ts"
} |
TypeScript/tests/cases/fourslash/formattingOptionsChangeJsx.ts_0_1085 | ///<reference path="fourslash.ts"/>
//@Filename: file.tsx
/////*1*/<Madoka homu={ true } saya={ (true) } />;
////
////<PrimaryButton
//// /*2*/{ ...this._getButtonProps() }
/////>
runTest("1", "<Madoka homu={ true } saya={ (true) } />;", "<Madoka homu={true} saya={(true)} />;");
runTest("2", " { ...this._getButtonProps() }", " {...this._getButtonProps()}");
function runTest(markerName: string, expectedStringWhenTrue: string, expectedStringWhenFalse: string) {
const propertyName = "InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces";
// Go to the correct file
goTo.marker(markerName);
// Set the option to false first
format.setOption(propertyName, false);
// Format
format.document();
// Verify
goTo.marker(markerName);
verify.currentLineContentIs(expectedStringWhenFalse);
// Set the option to true
format.setOption(propertyName, true);
// Format
format.document();
// Verify
goTo.marker(markerName);
verify.currentLineContentIs(expectedStringWhenTrue);
} | {
"end_byte": 1085,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOptionsChangeJsx.ts"
} |
TypeScript/tests/cases/fourslash/smartSelection_mappedTypes.ts_0_154 | /// <reference path="fourslash.ts" />
////type M = { /*1*/-re/*2*/adonly /*3*/[K in ke/*4*/yof any]/*5*/-/*6*/?: any };
verify.baselineSmartSelection(); | {
"end_byte": 154,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartSelection_mappedTypes.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_AccessCallReturnValue.ts_0_415 | /// <reference path='fourslash.ts' />
////let a = { b: () => { return { c: 0 } } }
/////*a*/a && a.b && a.b().c/*b*/;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to optional chain expression",
actionName: "Convert to optional chain expression",
actionDescription: "Convert to optional chain expression",
newContent:
`let a = { b: () => { return { c: 0 } } }
a?.b?.().c;`
}); | {
"end_byte": 415,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_AccessCallReturnValue.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics17.ts_0_146 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: a.js
////function F(a: number) { }
verify.baselineSyntacticDiagnostics();
| {
"end_byte": 146,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics17.ts"
} |
TypeScript/tests/cases/fourslash/completionForMetaProperty.ts_0_435 | /// <reference path='fourslash.ts'/>
////import./*1*/;
////new./*2*/;
////function test() { new./*3*/ }
verify.completions(
{
marker: "1",
exact: [{ name: "meta", text: "(property) ImportMetaExpression.meta: ImportMeta" }]
},
{
marker: "2",
exact: []
},
{
marker: "3",
exact: [{ name: "target", text: "(property) NewTargetExpression.target: () => void" }]
},
); | {
"end_byte": 435,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForMetaProperty.ts"
} |
TypeScript/tests/cases/fourslash/codeFixTopLevelForAwait_notAModule.ts_0_481 | /// <reference path="fourslash.ts" />
// @filename: /dir/a.ts
////declare const p: number[];
////for await (const _ of p);
// @filename: /dir/tsconfig.json
////{
//// "compilerOptions": {
//// "target": "esnext",
//// "module": "esnext"
//// }
////}
verify.codeFix({
description: ts.Diagnostics.Add_export_to_make_this_file_into_a_module.message,
index: 0,
newFileContent:
`declare const p: number[];
for await (const _ of p);
export { };
`
});
| {
"end_byte": 481,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelForAwait_notAModule.ts"
} |
TypeScript/tests/cases/fourslash/jsdocDeprecated_suggestion21.ts_0_559 | /// <reference path="fourslash.ts" />
// @module: esnext
// @filename: /a.ts
////export const a = 1;
////export const b = 1;
// @filename: /b.ts
////export {
//// /** @deprecated a is deprecated */
//// a
////} from "./a";
// @filename: /c.ts
////export {
//// a
////} from "./b";
// @filename: /d.ts
////import * as _ from "./c";
////_.[|a|]
goTo.file("/d.ts")
verify.getSuggestionDiagnostics([
{
"code": 6385,
"message": "'a' is deprecated.",
"reportsDeprecated": true,
"range": test.ranges()[0]
},
]);
| {
"end_byte": 559,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocDeprecated_suggestion21.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_AccessThenCall.ts_0_325 | /// <reference path='fourslash.ts' />
/////*a*/a && a.b && a.b()/*b*/;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to optional chain expression",
actionName: "Convert to optional chain expression",
actionDescription: "Convert to optional chain expression",
newContent:
`a?.b?.();`
}); | {
"end_byte": 325,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_AccessThenCall.ts"
} |
TypeScript/tests/cases/fourslash/organizeImports2.ts_0_265 | /// <reference path="fourslash.ts" />
// Regression test for bug #41417
//// import {
//// Foo
//// , Bar
//// } from "foo"
////
//// console.log(Foo, Bar);
verify.organizeImports(
`import {
Bar,
Foo
} from "foo";
console.log(Foo, Bar);`
); | {
"end_byte": 265,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImports2.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoWidenedTypes.ts_0_413 | /// <reference path='fourslash.ts'/>
////var /*1*/a = null; // var a: any
////var /*2*/b = undefined; // var b: any
////var /*3*/c = { x: 0, y: null }; // var c: { x: number, y: any }
////var /*4*/d = [null, undefined]; // var d: any[]
verify.quickInfos({
1: "var a: any",
2: "var b: any",
3: "var c: {\n x: number;\n y: any;\n}",
4: "var d: any[]"
});
| {
"end_byte": 413,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoWidenedTypes.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts_0_262 | /// <reference path='fourslash.ts'/>
//// var /*0*/dx = "Foo";
////
//// module M { export var /*1*/dx; }
//// module M {
//// var z = 100;
//// export var y = { /*2*/dx, z };
//// }
//// M.y./*3*/dx;
verify.baselineFindAllReferences('0', '1', '2', '3')
| {
"end_byte": 262,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts"
} |
TypeScript/tests/cases/fourslash/emptyExportFindReferences.ts_0_171 | /// <reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: Foo.js
//// /**/module.exports = {
////
//// }
verify.baselineDocumentHighlights(""); | {
"end_byte": 171,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/emptyExportFindReferences.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.