_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/completionsImport_reexportTransient.ts_0_681 | /// <reference path="fourslash.ts" />
// @esModuleInterop: true
// @Filename: /transient.d.ts
//// declare const map: { [K in "one"]: number };
//// export = map;
// @Filename: /r1.ts
//// export { one } from "./transient";
// @Filename: /r2.ts
//// export { one } from "./r1";
// @Filename: /index.ts
//// one/**/
goTo.marker("");
verify.completions({
marker: "",
exact: completion.globalsPlus([{
name: "one",
source: "./transient",
sourceDisplay: "./transient",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
}]),
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: true,
}
});
| {
"end_byte": 681,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_reexportTransient.ts"
} |
TypeScript/tests/cases/fourslash/completionListBuilderLocations_VariableDeclarations.ts_0_785 | /// <reference path='fourslash.ts' />
////var x = a/*var1*/
////var x = (b/*var2*/
////var x = (c, d/*var3*/
//// var y : any = "", x = a/*var4*/
//// var y : any = "", x = (a/*var5*/
////class C{}
////var y = new C(/*var6*/
//// class C{}
//// var y = new C(0, /*var7*/
////var y = [/*var8*/
////var y = [0, /*var9*/
////var y = `${/*var10*/
////var y = `${10} dd ${ /*var11*/
////var y = 10; y=/*var12*/
// first declaration
verify.completions({
marker: ["var1"],
exact: completion.globalsPlus(["C", "y"]),
isNewIdentifierLocation: true
});
verify.completions({
marker: ["var2", "var3", "var4", "var5", "var6", "var7", "var8", "var9", "var10", "var11", "var12"],
exact: completion.globalsPlus(["C", "x", "y"]),
isNewIdentifierLocation: true
});
| {
"end_byte": 785,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListBuilderLocations_VariableDeclarations.ts"
} |
TypeScript/tests/cases/fourslash/ambientVariablesWithSameName.ts_0_176 | ///<reference path="fourslash.ts"/>
////declare module M {
//// export var x: string;
////}
////declare var x: number;
goTo.eof();
edit.insertLine('');
verify.noErrors();
| {
"end_byte": 176,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/ambientVariablesWithSameName.ts"
} |
TypeScript/tests/cases/fourslash/renameCommentsAndStrings1.ts_0_288 | /// <reference path="fourslash.ts" />
///////<reference path="./Bar.ts" />
////[|function [|{| "contextRangeIndex": 0 |}Bar|]() {
//// // This is a reference to Bar in a comment.
//// "this is a reference to Bar in a string"
////}|]
verify.baselineRenameAtRangesWithText("Bar");
| {
"end_byte": 288,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameCommentsAndStrings1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfacePropertyFromParentConstructorFunction.ts_0_265 | /// <reference path='fourslash.ts' />
//// class A {
//// constructor(public x: number) { }
//// }
////
//// class B implements A {[| |]}
verify.codeFixAvailable([]);
// TODO: (arozga) Get this working.
/*
verify.rangeAfterCodeFix(`
public x: number;
`);
*/
| {
"end_byte": 265,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfacePropertyFromParentConstructorFunction.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnMergedInterfaces.ts_0_423 | /// <reference path='fourslash.ts'/>
////module M {
//// interface A<T> {
//// (): string;
//// (x: T): T;
//// }
//// interface A<T> {
//// (x: T, y: number): T;
//// <U>(x: U, y: T): U;
//// }
//// var a: A<boolean>;
//// var r = a();
//// var r2 = a(true);
//// var r3 = a(true, 2);
//// var /*1*/r4 = a(1, true);
////}
verify.quickInfoAt("1", "var r4: number");
| {
"end_byte": 423,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnMergedInterfaces.ts"
} |
TypeScript/tests/cases/fourslash/completionsThisProperties_globalSameName.ts_0_1153 | /// <reference path="fourslash.ts" />
// @Filename: globals.d.ts
//// declare var foot: string;
// @Filename: index.ts
//// class Service {
//// foot!: number;
//// serve() {
//// foot/**/
//// }
//// }
verify.completions({
marker: "",
unsorted: [
"arguments",
completion.globalThisEntry,
...completion.globalsVars,
{
name: "foot",
insertText: "this.foot",
kind: "property",
sortText: completion.SortText.SuggestedClassMembers,
source: completion.CompletionSource.ThisProperty,
text: "(property) Service.foot: number"
},
{
name: "foot",
insertText: undefined,
kind: "var",
kindModifiers: "declare",
sortText: completion.SortText.GlobalsOrKeywords,
text: "var foot: string"
},
"Service",
completion.undefinedVarEntry,
{
name: "serve",
insertText: "this.serve",
kind: "method",
sortText: completion.SortText.SuggestedClassMembers,
source: completion.CompletionSource.ThisProperty
},
...completion.insideMethodKeywords
],
preferences: {
includeInsertTextCompletions: true
}
});
| {
"end_byte": 1153,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsThisProperties_globalSameName.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceConstructorName2.ts_0_369 | /// <reference path='fourslash.ts' />
////interface I {
//// constructor(): number;
////}
////class C implements I {}
verify.codeFix({
description: "Implement interface 'I'",
newFileContent:
`interface I {
constructor(): number;
}
class C implements I {
["constructor"](): number {
throw new Error("Method not implemented.");
}
}`,
});
| {
"end_byte": 369,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceConstructorName2.ts"
} |
TypeScript/tests/cases/fourslash/fixNaNEquality2.ts_0_221 | /// <reference path="fourslash.ts" />
////declare const x: number;
////[|if (NaN === x) {}|]
verify.codeFix({
index: 0,
description: "Use `Number.isNaN(x)`.",
newRangeContent: "if (Number.isNaN(x)) {}",
});
| {
"end_byte": 221,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixNaNEquality2.ts"
} |
TypeScript/tests/cases/fourslash/completionListBeforeNewScope02.ts_0_150 | /// <reference path='fourslash.ts' />
////a/*1*/
////
////{
//// let aaaaaa = 10;
////}
verify.completions({ marker: "1", excludes: "aaaaaa" });
| {
"end_byte": 150,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListBeforeNewScope02.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsageStringIndexSignature.ts_0_233 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
////function f([|a |]) {
//// return a['hi'];
////}
verify.rangeAfterCodeFix("a: { [x: string]: any; }",/*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, 0);
| {
"end_byte": 233,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsageStringIndexSignature.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_SubexpressionWithSuffix1.ts_0_504 | /// <reference path='fourslash.ts' />
////let a = { b: { c: 0 } };
////let foo;
////let bar;
/////*a*/a && a.b && a.b.c/*b*/ && foo && bar;
// verify that we stop at an invalid suffix sequence.
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: 0 } };
let foo;
let bar;
a?.b?.c && foo && bar;`
}); | {
"end_byte": 504,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_SubexpressionWithSuffix1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax11.ts_0_266 | // @strict: true
/// <reference path='fourslash.ts' />
//// var f = function f(x: [|string?|]) {
//// }
verify.codeFix({
description: "Change 'string?' to 'string | undefined'",
errorCode: 17019,
index: 1,
newRangeContent: "string | undefined",
});
| {
"end_byte": 266,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax11.ts"
} |
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType16.ts_0_782 | /// <reference path='fourslash.ts' />
////function /*a*//*b*/f1() {
//// return { x: 1, y: 1 };
////}
////func/*c*//*d*/tion f2() {
//// return { x: 1, y: 1 };
////}
////function f3(/*e*//*f*/) {
//// return { x: 1, y: 1 };
////}
////function f4() {/*g*//*h*/
//// return { x: 1, y: 1 };
////}
////function f5() {
//// return { x: 1, y: 1 /*i*//*j*/};
////}
goTo.select("a", "b");
verify.refactorAvailable("Infer function return type");
goTo.select("c", "d");
verify.refactorAvailable("Infer function return type");
goTo.select("e", "f");
verify.refactorAvailable("Infer function return type");
goTo.select("g", "h");
verify.not.refactorAvailable("Infer function return type");
goTo.select("i", "j");
verify.not.refactorAvailable("Infer function return type");
| {
"end_byte": 782,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType16.ts"
} |
TypeScript/tests/cases/fourslash/unusedVariableWithTrivia1.ts_0_387 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////[|namespace greeter {
//// // do not remove comment
//// let a = 0;
//// // comment
//// let b = 0;
//// b;
////}|]
verify.codeFix({
description: "Remove unused declaration for: 'a'",
newRangeContent: `namespace greeter {
// do not remove comment
// comment
let b = 0;
b;
}`
});
| {
"end_byte": 387,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedVariableWithTrivia1.ts"
} |
TypeScript/tests/cases/fourslash/incompleteFunctionCallCodefix2.ts_0_233 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
////function f(new C(100, 3, undefined)
verify.codeFixAvailable([
{ "description": "Infer parameter types from usage" }
]); // Parse error, so no unused diagnostics
| {
"end_byte": 233,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incompleteFunctionCallCodefix2.ts"
} |
TypeScript/tests/cases/fourslash/genericTypeAliasIntersectionCompletions.ts_0_893 | /// <reference path="fourslash.ts" />
//// type MixinCtor<A, B> = new () => A & B & { constructor: MixinCtor<A, B> };
//// function merge<A, B>(a: { prototype: A }, b: { prototype: B }): MixinCtor<A, B> {
//// let merged = function() { }
//// Object.assign(merged.prototype, a.prototype, b.prototype);
//// return <MixinCtor<A, B>><any>merged;
//// }
////
//// class TreeNode {
//// value: any;
//// }
////
//// abstract class LeftSideNode extends TreeNode {
//// abstract right(): TreeNode;
//// left(): TreeNode {
//// return null;
//// }
//// }
////
//// abstract class RightSideNode extends TreeNode {
//// abstract left(): TreeNode;
//// right(): TreeNode {
//// return null;
//// };
//// }
////
//// var obj = new (merge(LeftSideNode, RightSideNode))();
//// obj./**/
verify.completions({ marker: "", unsorted: ["right", "left", "value", "constructor"] });
| {
"end_byte": 893,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericTypeAliasIntersectionCompletions.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixExportAsDefault.ts_0_393 | /// <reference path="fourslash.ts" />
// @Filename: /foo.ts
////const foo = 'foo'
////export { foo as default }
// @Filename: /index.ts
//// foo/**/
verify.applyCodeActionFromCompletion("", {
name: "foo",
source: "/foo",
description: `Add import from "./foo"`,
newFileContent: `import foo from "./foo";\n\nfoo`,
preferences: {
includeCompletionsForModuleExports: true
}
});
| {
"end_byte": 393,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixExportAsDefault.ts"
} |
TypeScript/tests/cases/fourslash/formattingInDestructuring5.ts_0_446 | /// <reference path='fourslash.ts'/>
//// let a, b;
//// /*1*/if (false)[a, b] = [1, 2];
//// /*2*/if (true) [a, b] = [1, 2];
//// /*3*/var a = [1, 2, 3].map(num => num) [0];
format.document();
goTo.marker("1");
verify.currentLineContentIs("if (false) [a, b] = [1, 2];");
goTo.marker("2");
verify.currentLineContentIs("if (true) [a, b] = [1, 2];");
goTo.marker("3");
verify.currentLineContentIs("var a = [1, 2, 3].map(num => num)[0];"); | {
"end_byte": 446,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingInDestructuring5.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesNonStringImportAssertion.ts_0_180 | /// <reference path="fourslash.ts" />
// @module: nodenext
////import * as react from "react" assert { cache: /**/0 };
////react.Children;
verify.baselineDocumentHighlights("");
| {
"end_byte": 180,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesNonStringImportAssertion.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedTemplate01.ts_0_174 | /// <reference path='fourslash.ts' />
////var x;
////var y = (p) => `abc ${ /*1*/
verify.completions({ marker: "1", includes: ["p", "x"], isNewIdentifierLocation: true });
| {
"end_byte": 174,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedTemplate01.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_super1.ts_0_407 | /// <reference path='fourslash.ts' />
// @noUnusedParameters: true
//// class Base {
//// constructor(x: number) {} // Remove unused parameter
//// }
////
//// class Derived extends Base {
//// constructor(x: number) {
//// super(x);
//// }
//// }
// No codefix to remove a non-last parameter in a callback
verify.codeFixAvailable([{ description: "Prefix 'x' with an underscore" }]);
| {
"end_byte": 407,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_super1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts_0_311 | /// <reference path='fourslash.ts' />
////namespace N {
//// export interface I { y: I; }
////}
////class C1 implements N.I {}
verify.codeFix({
description: "Implement interface 'N.I'",
newFileContent:
`namespace N {
export interface I { y: I; }
}
class C1 implements N.I {
y: N.I;
}`,
});
| {
"end_byte": 311,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.ts_0_378 | /// <reference path='fourslash.ts' />
// @allowSyntheticDefaultImports: true
// @Filename: /export.ts
////const /*0*/foo = 1;
////export = /*1*/foo;
// @Filename: /re-export.ts
////export { /*2*/default } from "./export";
// @Filename: /re-export-dep.ts
////import /*3*/fooDefault from "./re-export";
verify.noErrors();
verify.baselineFindAllReferences('0', '1', '2', '3')
| {
"end_byte": 378,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.ts"
} |
TypeScript/tests/cases/fourslash/semicolonFormattingInsideAStringLiteral.ts_0_240 | /// <reference path='fourslash.ts' />
//// var x = "string/**/
goTo.marker();
edit.insert(';');
// Semicolon Formating should not be triggered inside an unterminated string literal
verify.currentLineContentIs(' var x = "string;');
| {
"end_byte": 240,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semicolonFormattingInsideAStringLiteral.ts"
} |
TypeScript/tests/cases/fourslash/formatSelectionWithTrivia8.ts_0_263 | /// <reference path="fourslash.ts" />
// Same as formatSelectionWithTrivia2, but range is immediately proceeded by a token
/////*begin*/;
////
/////*end*/console.log();
format.selection('begin', 'end');
verify.currentFileContentIs(";\n\nconsole.log();");
| {
"end_byte": 263,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatSelectionWithTrivia8.ts"
} |
TypeScript/tests/cases/fourslash/textChangesPreserveNewlines9.ts_0_912 | /// <reference path="fourslash.ts" />
////function foo() {
//// /*1*/if (true) {
//// console.log(1);
//// } else {
//// console.log(1);
//// }
////
//// do {
//// console.log(1);
//// }
////
//// while (true);
////
//// try {
//// console.log(1);
//// } catch {
//// void 0;
//// } finally {
//// void 0;
//// }/*2*/
////}
goTo.select("1", "2");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_1",
actionDescription: "Extract to function in global scope",
newContent:
`function foo() {
/*RENAME*/newFunction();
}
function newFunction() {
if (true) {
console.log(1);
} else {
console.log(1);
}
do {
console.log(1);
}
while (true);
try {
console.log(1);
} catch {
void 0;
} finally {
void 0;
}
}
`
});
| {
"end_byte": 912,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/textChangesPreserveNewlines9.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration6.ts_0_403 | /// <reference path='fourslash.ts' />
////namespace Foo {
//// export const x = 0;
////}
////
////Foo.test();
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "test"],
newFileContent:
`namespace Foo {
export const x = 0;
export function test() {
throw new Error("Function not implemented.");
}
}
Foo.test();`
});
| {
"end_byte": 403,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration6.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpCallExpressionTuples.ts_0_1587 | /// <reference path='fourslash.ts'/>
//// function fnTest(str: string, num: number) { }
//// declare function wrap<A extends any[], R>(fn: (...a: A) => R) : (...a: A) => R;
//// var fnWrapped = wrap(fnTest);
//// fnWrapped/*3*/(/*1*/'', /*2*/5);
//// function fnTestVariadic (str: string, ...num: number[]) { }
//// var fnVariadicWrapped = wrap(fnTestVariadic);
//// fnVariadicWrapped/*4*/(/*5*/'', /*6*/5);
//// function fnNoParams () { }
//// var fnNoParamsWrapped = wrap(fnNoParams);
//// fnNoParamsWrapped/*7*/(/*8*/);
verify.quickInfoAt("3", "var fnWrapped: (str: string, num: number) => void");
verify.signatureHelp(
{
marker: "1",
text: "fnWrapped(str: string, num: number): void",
parameterCount: 2,
parameterName: "str",
parameterSpan: "str: string",
},
{
marker: "2",
parameterName: "num",
parameterSpan: "num: number",
},
);
verify.quickInfoAt("4", "var fnVariadicWrapped: (str: string, ...num: number[]) => void");
verify.signatureHelp(
{
marker: "5",
text: "fnVariadicWrapped(str: string, ...num: number[]): void",
parameterCount: 2,
parameterName: "str",
parameterSpan: "str: string",
isVariadic: true,
},
{
marker: "6",
parameterName: "num",
parameterSpan: "...num: number[]",
isVariadic: true,
},
);
verify.quickInfoAt("7", "var fnNoParamsWrapped: () => void");
verify.signatureHelp(
{
marker: "8",
text: "fnNoParamsWrapped(): void",
parameterCount: 0,
}
);
| {
"end_byte": 1587,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpCallExpressionTuples.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedFunction14.ts_3_368 | / <reference path="fourslash.ts" />
////interface MyType {
////}
////
////function foo(x: string, y: number, z: boolean) {
//// function bar(a: number, b: string = "hello", c: typeof x = "hello") {
//// var v = (p: MyType) => /*1*/
//// }
////}
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v", "p"] });
| {
"end_byte": 368,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedFunction14.ts"
} |
TypeScript/tests/cases/fourslash/autoImportPackageJsonImportsPattern_ts_ts.ts_0_345 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @Filename: /package.json
//// {
//// "imports": {
//// "#*.ts": "./src/*.ts"
//// }
//// }
// @Filename: /src/something.ts
//// export function something(name: string): any;
// @Filename: /a.ts
//// something/**/
verify.importFixModuleSpecifiers("", ["#something.ts"]);
| {
"end_byte": 345,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPackageJsonImportsPattern_ts_ts.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterfaceClassMerge.ts_0_414 | /// <reference path='fourslash.ts' />
/////*1*/interface /*2*/Numbers {
//// p: number;
////}
/////*3*/interface /*4*/Numbers {
//// m: number;
////}
/////*5*/class /*6*/Numbers {
//// f(n: number) {
//// return this.p + this.m + n;
//// }
////}
////let i: /*7*/Numbers = new /*8*/Numbers();
////let x = i.f(i.p + i.m);
verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6', '7', '8');
| {
"end_byte": 414,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterfaceClassMerge.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpForSignatureWithUnreachableType.ts_0_546 | /// <reference path="fourslash.ts" />
// @Filename: /node_modules/foo/node_modules/bar/index.d.ts
////export interface SomeType {
//// x?: number;
////}
// @Filename: /node_modules/foo/index.d.ts
////import { SomeType } from "bar";
////export function func<T extends SomeType>(param: T): void;
////export function func<T extends SomeType>(param: T, other: T): void;
// @Filename: /usage.ts
////import { func } from "foo";
////func({/*1*/});
verify.signatureHelp({
marker: "1",
overloadsCount: 2,
text: "func(param: {}): void"
}); | {
"end_byte": 546,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpForSignatureWithUnreachableType.ts"
} |
TypeScript/tests/cases/fourslash/unusedVariableInForLoop6FSAddUnderscore.ts_0_263 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////for ([|const elem of |]["a", "b", "c"]) {}
verify.codeFix({
description: "Prefix 'elem' with an underscore",
index: 1,
newFileContent: 'for (const _elem of ["a", "b", "c"]) {}',
});
| {
"end_byte": 263,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedVariableInForLoop6FSAddUnderscore.ts"
} |
TypeScript/tests/cases/fourslash/formatOnOpenCurlyBraceRemoveNewLine.ts_0_219 | /// <reference path="fourslash.ts"/>
//// if(true)
//// /**/ }
format.setOption("PlaceOpenBraceOnNewLineForControlBlocks", false);
goTo.marker("");
edit.insert("{");
verify.currentFileContentIs(
`if (true) { }`);
| {
"end_byte": 219,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatOnOpenCurlyBraceRemoveNewLine.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringAssignmentForArrayBindingPatternDefaultValues.ts_0_3878 | /// <reference path='fourslash.ts' />
////declare var console: {
//// log(msg: any): void;
////}
////type Robot = [number, string, string];
////type MultiSkilledRobot = [string, [string, string]];
////let robotA: Robot = [1, "mower", "mowing"];
////function getRobot() {
//// return robotA;
////}
////let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]];
////let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]];
////function getMultiRobot() {
//// return multiRobotA;
////}
////let nameA: string, primarySkillA: string, secondarySkillA: string;
////let numberB: number, nameB: string;
////let numberA2: number, nameA2: string, skillA2: string, nameMA: string;
////let numberA3: number, robotAInfo: (number | string)[], multiRobotAInfo: (string | [string, string])[];
////let i: number;
////for ([, nameA = "name"] = robotA, i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for ([, nameA = "name"] = getRobot(), i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for ([, nameA = "name"] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) {
//// console.log(nameA);
////}
////for ([, [
//// primarySkillA = "primary",
//// secondarySkillA = "secondary"
////] = ["none", "none"]] = multiRobotA, i = 0; i < 1; i++) {
//// console.log(primarySkillA);
////}
////for ([, [
//// primarySkillA = "primary",
//// secondarySkillA = "secondary"
////] = ["none", "none"]] = getMultiRobot(), i = 0; i < 1; i++) {
//// console.log(primarySkillA);
////}
////for ([, [
//// primarySkillA = "primary",
//// secondarySkillA = "secondary"
////] = ["none", "none"]] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) {
//// console.log(primarySkillA);
////}
////for ([numberB = -1] = robotA, i = 0; i < 1; i++) {
//// console.log(numberB);
////}
////for ([numberB = -1] = getRobot(), i = 0; i < 1; i++) {
//// console.log(numberB);
////}
////for ([numberB = -1] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) {
//// console.log(numberB);
////}
////for ([nameB = "name"] = multiRobotA, i = 0; i < 1; i++) {
//// console.log(nameB);
////}
////for ([nameB = "name"] = getMultiRobot(), i = 0; i < 1; i++) {
//// console.log(nameB);
////}
////for ([nameB = "name"] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) {
//// console.log(nameB);
////}
////for ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = robotA, i = 0; i < 1; i++) {
//// console.log(nameA2);
////}
////for ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = getRobot(), i = 0; i < 1; i++) {
//// console.log(nameA2);
////}
////for ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) {
//// console.log(nameA2);
////}
////for ([nameMA = "noName",
//// [
//// primarySkillA = "primary",
//// secondarySkillA = "secondary"
//// ] = ["none", "none"]
//// ] = multiRobotA, i = 0; i < 1; i++) {
//// console.log(nameMA);
////}
////for ([nameMA = "noName",
//// [
//// primarySkillA = "primary",
//// secondarySkillA = "secondary"
//// ] = ["none", "none"]
////] = getMultiRobot(), i = 0; i < 1; i++) {
//// console.log(nameMA);
////}
////for ([nameMA = "noName",
//// [
//// primarySkillA = "primary",
//// secondarySkillA = "secondary"
//// ] = ["none", "none"]
////] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) {
//// console.log(nameMA);
////}
////for ([numberA3 = -1, ...robotAInfo] = robotA, i = 0; i < 1; i++) {
//// console.log(numberA3);
////}
////for ([numberA3 = -1, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) {
//// console.log(numberA3);
////}
////for ([numberA3 = -1, ...robotAInfo] = <Robot>[2, "trimmer", "trimming"], i = 0; i < 1; i++) {
//// console.log(numberA3);
////}
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 3878,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringAssignmentForArrayBindingPatternDefaultValues.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsTripleSlash4.ts_0_209 | /// <reference path="fourslash.ts"/>
//// /// <
const c = classification("original");
verify.syntacticClassificationsAre(
c.comment("/// <")); // Don't classify until we recognize the element name
| {
"end_byte": 209,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsTripleSlash4.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesPublic1.ts_0_1510 | /// <reference path='fourslash.ts' />
////module m {
//// export class C1 {
//// [|public|] pub1;
//// [|public|] pub2;
//// private priv1;
//// private priv2;
//// protected prot1;
//// protected prot2;
////
//// [|public|] public;
//// private private;
//// protected protected;
////
//// [|public|] constructor([|public|] a, private b, protected c, [|public|] d, private e, protected f) {
//// this.public = 10;
//// this.private = 10;
//// this.protected = 10;
//// }
////
//// [|public|] get x() { return 10; }
//// [|public|] set x(value) { }
////
//// [|public|] static statPub;
//// private static statPriv;
//// protected static statProt;
//// }
////
//// export interface I1 {
//// }
////
//// export declare module ma.m1.m2.m3 {
//// interface I2 {
//// }
//// }
////
//// export module mb.m1.m2.m3 {
//// declare var foo;
////
//// export class C2 {
//// public pub1;
//// private priv1;
//// protected prot1;
////
//// protected constructor(public public, protected protected, private private) {
//// public = private = protected;
//// }
//// }
//// }
////
//// declare var ambientThing: number;
//// export var exportedThing = 10;
//// declare function foo(): string;
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 1510,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesPublic1.ts"
} |
TypeScript/tests/cases/fourslash/indentationInAsyncExpressions.ts_0_322 | /// <reference path="fourslash.ts"/>
//// async function* foo() {
//// yield /*8_0*/await 1;
//// yield await /*8_1*/1;
//// yield
//// await /*8_2*/1;
//// yield await 1/*8_3*/;
//// }
for (let i = 0; i < 4; ++i) {
goTo.marker(`8_${i}`);
edit.insertLine("");
verify.indentationIs(8);
} | {
"end_byte": 322,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indentationInAsyncExpressions.ts"
} |
TypeScript/tests/cases/fourslash/functionTypes.ts_0_713 | /// <reference path='fourslash.ts'/>
////var f: Function;
////function g() { }
////
////class C {
//// h: () => void ;
//// i(): number { return 5; }
//// static j = (e) => e;
//// static k() { return 'hi';}
////}
////var l = () => void 0;
////var z = new C;
////
////f./*1*/apply(this, [1]);
////g./*2*/arguments;
////z.h./*3*/bind(undefined, 1, 2);
////z.i./*4*/call(null)
////C.j./*5*/length === 1;
////typeof C.k./*6*/caller === 'function';
////l./*7*/prototype = Object.prototype;
verify.noErrors();
verify.completions(
{ marker: ["1", "2", "3", "4", "5", "6"], exact: completion.functionMembersWithPrototype },
{ marker: "7", exact: completion.functionMembersPlus(["prototype"]) },
);
| {
"end_byte": 713,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/functionTypes.ts"
} |
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc7.ts_0_356 | /// <reference path='fourslash.ts' />
/////**
//// * @param {number} x
//// * @returns {number}
//// */
////function f(x) {
//// return x;
////}
verify.codeFix({
description: "Annotate with type from JSDoc",
index: 0,
newFileContent:
`/**
* @param {number} x
* @returns {number}
*/
function f(x: number): number {
return x;
}`,
});
| {
"end_byte": 356,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc7.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_filteredByPackageJson_ambient.ts_0_2766 | /// <reference path="fourslash.ts" />
//@noEmit: true
//@Filename: /package.json
////{
//// "dependencies": {
//// "react-syntax-highlighter": "*",
//// "declared-by-foo": "*"
//// }
////}
//@Filename: /node_modules/@types/foo/index.d.ts
////declare module "foo" {
//// export const foo: any;
////}
////declare module "declared-by-foo" {
//// export const declaredBySomethingNotInPackageJson: any;
////}
//@Filename: /node_modules/@types/foo/package.json
////{
//// "name": "@types/node"
////}
//@Filename: /node_modules/@types/react-syntax-highlighter/index.d.ts
////declare module "react-syntax-highlighter/sub" {
//// const agate: any;
//// export default agate;
////}
////declare module "something-else" {
//// export const somethingElse: any;
////}
//@Filename: /node_modules/@types/react-syntax-highlighter/package.json
////{
//// "name": "@types/react-syntax-highlighter"
////}
//@Filename: /src/ambient.ts
////declare module "local" {
//// export const local: any';
////}
//@Filename: /src/index.ts
////fo/*1*/
////aga/*2*/
////somethi/*3*/
////declaredBy/*4*/
////loca/*5*/
// 1. Ambient modules declared in node_modules should be included if
// a) the declaring package is in package.json, or
// b) the ambient module name is in package.json
verify.completions({
marker: test.marker("1"),
exact: completion.globals,
preferences: {
includeCompletionsForModuleExports: true
}
});
// sub-modules count
verify.completions({
marker: test.marker("2"),
includes: {
name: "agate",
source: "react-syntax-highlighter/sub",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences: {
includeCompletionsForModuleExports: true
}
});
// not in package.json but declared by something in package.json
verify.completions({
marker: test.marker("3"),
includes: {
name: "somethingElse",
source: "something-else",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences: {
includeCompletionsForModuleExports: true
}
});
// in package.json but declared by something not in package.json
verify.completions({
marker: test.marker("4"),
includes: {
name: "declaredBySomethingNotInPackageJson",
source: "declared-by-foo",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences: {
includeCompletionsForModuleExports: true
}
});
// 2. Ambient modules declared outside of node_modules should always be included
verify.completions({
marker: test.marker("5"),
includes: {
name: "local",
source: "local",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
preferences: {
includeCompletionsForModuleExports: true
}
});
| {
"end_byte": 2766,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_filteredByPackageJson_ambient.ts"
} |
TypeScript/tests/cases/fourslash/referencesForExportedValues.ts_0_259 | /// <reference path='fourslash.ts'/>
////module M {
//// /*1*/export var /*2*/variable = 0;
////
//// // local use
//// var x = /*3*/variable;
////}
////
////// external use
////M./*4*/variable
verify.baselineFindAllReferences('1', '2', '3', '4');
| {
"end_byte": 259,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForExportedValues.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess_all.ts_0_642 | /// <reference path='fourslash.ts' />
////class C extends Object {
//// constructor() {
//// this;
//// this;
//// super();
//// }
////}
////class D extends Object {
//// constructor() {
//// this;
//// super();
//// }
////}
verify.codeFixAll({
fixId: "classSuperMustPrecedeThisAccess",
fixAllDescription: "Make all 'super()' calls the first statement in their constructor",
newFileContent: `class C extends Object {
constructor() {
super();
this;
this;
}
}
class D extends Object {
constructor() {
super();
this;
}
}`,
});
| {
"end_byte": 642,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess_all.ts"
} |
TypeScript/tests/cases/fourslash/inlineVariableRefactorAvailability.ts_0_361 | /// <reference path="fourslash.ts" />
////const/*a*/ /*b*/x/*c*/ = /*d*/1;
////const y = x + 2;
goTo.marker("a");
verify.not.refactorAvailable("Inline variable");
goTo.marker("b");
verify.refactorAvailable("Inline variable");
goTo.marker("c");
verify.refactorAvailable("Inline variable");
goTo.marker("d");
verify.not.refactorAvailable("Inline variable");
| {
"end_byte": 361,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlineVariableRefactorAvailability.ts"
} |
TypeScript/tests/cases/fourslash/renameReferenceFromLinkTag3.ts_0_218 | /// <reference path="fourslash.ts" />
// @filename: a.ts
////interface Foo {
//// foo: E.Foo;
////}
// @Filename: b.ts
////enum E {
//// /** {@link /**/Foo} */
//// Foo
////}
verify.baselineRename("", {});
| {
"end_byte": 218,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameReferenceFromLinkTag3.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesConst01.ts_0_197 | /// <reference path='fourslash.ts' />
////[|const|] enum E1 {
//// v1,
//// v2
////}
////
/////*2*/const c = 0;
verify.baselineDocumentHighlights();
verify.baselineDocumentHighlights("2");
| {
"end_byte": 197,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesConst01.ts"
} |
TypeScript/tests/cases/fourslash/codeFixClassPropertyInitialization_all_4.ts_0_733 | /// <reference path='fourslash.ts' />
// @strict: true
// @checkJs: true
// @allowJs: true
// @filename: a.js
////class A {
//// /**
//// * comment
//// * @type {string}
//// */
//// a;
////}
////class B {
//// /** @type {string} */
//// a;
////}
////class C {
//// /**
//// * @type {string}
//// */
//// a;
////}
verify.codeFixAll({
fixId: 'addMissingPropertyUndefinedType',
fixAllDescription: "Add undefined type to all uninitialized properties",
newFileContent:
`class A {
/**
* comment
* @type {string | undefined}
*/
a;
}
class B {
/** @type {string | undefined} */
a;
}
class C {
/**
* @type {string | undefined}
*/
a;
}`
});
| {
"end_byte": 733,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixClassPropertyInitialization_all_4.ts"
} |
TypeScript/tests/cases/fourslash/exportDefaultClass.ts_0_244 | /// <reference path='./fourslash.ts'/>
////export default class C {
//// method() { /*1*/ }
////}
//// /*2*/
verify.completions({ marker: test.markers(), includes: { name: "C", text: "class C", kind: "class", kindModifiers: "export" } });
| {
"end_byte": 244,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/exportDefaultClass.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction6.ts_0_350 | /// <reference path='fourslash.ts' />
//// const foo = /*a*/a/*b*/ => { return 1; };
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Add or remove braces in an arrow function",
actionName: "Remove braces from arrow function",
actionDescription: "Remove braces from arrow function",
newContent: `const foo = a => 1;`,
});
| {
"end_byte": 350,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction6.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnThis4.ts_0_513 | /// <reference path='fourslash.ts' />
////interface ContextualInterface {
//// m: number;
//// method(this: this, n: number);
////}
////let o: ContextualInterface = {
//// m: 12,
//// method(n) {
//// let x = this/*1*/.m;
//// }
////}
////interface ContextualInterface2 {
//// (this: void, n: number): void;
////}
////let contextualInterface2: ContextualInterface2 = function (th/*2*/is, n) { }
verify.quickInfos({
1: "this: ContextualInterface",
2: "(parameter) this: void"
});
| {
"end_byte": 513,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnThis4.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_promoteTypeOnly3.ts_0_817 | /// <reference path="fourslash.ts" />
// @module: es2015
// @Filename: /exports.ts
//// export interface SomeInterface {}
//// export class SomePig {}
// @Filename: /a.ts
//// import { type SomePig } from "./exports.js";
//// new SomePig/**/
verify.completions({
marker: "",
includes: [{
name: "SomePig",
source: completion.CompletionSource.TypeOnlyAlias,
hasAction: true,
}]
});
verify.applyCodeActionFromCompletion("", {
name: "SomePig",
source: completion.CompletionSource.TypeOnlyAlias,
description: `Remove 'type' from import of 'SomePig' from "./exports.js"`,
newFileContent:
`import { SomePig } from "./exports.js";
new SomePig`,
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
},
});
| {
"end_byte": 817,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_promoteTypeOnly3.ts"
} |
TypeScript/tests/cases/fourslash/getOutliningForObjectDestructuring.ts_0_644 | /// <reference path="fourslash.ts"/>
////const[| {
//// a,
//// b,
//// c
////}|] =[| {
//// a: 1,
//// b: 2,
//// c: 3
////}|]
////const[| {
//// a:[| {
//// a_1,
//// a_2,
//// a_3:[| {
//// a_3_1,
//// a_3_2,
//// a_3_3,
//// }|],
//// }|],
//// b,
//// c
////}|] =[| {
//// a:[| {
//// a_1: 1,
//// a_2: 2,
//// a_3:[| {
//// a_3_1: 1,
//// a_3_2: 1,
//// a_3_3: 1
//// }|],
//// }|],
//// b: 2,
//// c: 3
////}|]
verify.outliningSpansInCurrentFile(test.ranges(), "code");
| {
"end_byte": 644,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOutliningForObjectDestructuring.ts"
} |
TypeScript/tests/cases/fourslash/unusedTypeParametersInLambda3.ts_0_334 | /// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
//// class A<Dummy> { public x: Dummy }
//// var x : {
//// [|new <T, U, K>(a: T): A<U>;|]
//// }
verify.codeFix({
description: "Remove unused declaration for: 'K'",
index: 0,
newRangeContent: "new <T, U>(a: T): A<U>;",
});
| {
"end_byte": 334,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedTypeParametersInLambda3.ts"
} |
TypeScript/tests/cases/fourslash/completionForStringLiteral_quotePreference.ts_0_382 | /// <reference path='fourslash.ts'/>
////enum A {
//// A,
//// B,
//// C
////}
////interface B {
//// a: keyof typeof A;
////}
////const b: B = {
//// a: /**/
////}
verify.completions({
marker: "",
includes: [
{ name: "'A'" },
{ name: "'B'" },
{ name: "'C'" },
],
preferences: {
quotePreference: 'single',
},
});
| {
"end_byte": 382,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForStringLiteral_quotePreference.ts"
} |
TypeScript/tests/cases/fourslash/organizeImportsType3.ts_0_521 | /// <reference path="fourslash.ts" />
//// import {
//// d,
//// type d as D,
//// type c,
//// c as C,
//// b,
//// b as B,
//// type A,
//// a
//// } from './foo';
//// console.log(A, a, B, b, c, C, d, D);
verify.organizeImports(
`import {
type A,
b as B,
c as C,
type d as D,
a,
b,
type c,
d
} from './foo';
console.log(A, a, B, b, c, C, d, D);`,
/*mode*/ undefined,
{ organizeImportsIgnoreCase: false, organizeImportsTypeOrder: "inline" }
);
| {
"end_byte": 521,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsType3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingConstToCommaSeparatedInitializer1.ts_0_220 | /// <reference path='fourslash.ts' />
////x = 0, y = 0;
verify.codeFixAll({
fixId: "addMissingConst",
fixAllDescription: "Add 'const' to all unresolved variables",
newFileContent: "const x = 0, y = 0;"
});
| {
"end_byte": 220,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingConstToCommaSeparatedInitializer1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_parameter5.ts_0_365 | /// <reference path="fourslash.ts" />
// @noUnusedLocals: true
// @noUnusedParameters: true
////[|function f(
//// a: number,
//// b: number,
//// c: number,
////)|] {
//// b;
//// c;
////}
verify.codeFix({
index: 0,
description: "Remove unused declaration for: 'a'",
newRangeContent:
`function f(
b: number,
c: number,
)`
});
| {
"end_byte": 365,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_parameter5.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration22.ts_0_728 | /// <reference path="fourslash.ts" />
// @jsx: preserve
// @filename: foo.tsx
////interface P {
//// onClick: (a: number, b: string) => void;
////}
////
////const A = ({ onClick }: P) =>
//// <div onClick={onClick}></div>;
////
////const B = () =>
//// <A onClick={handleClick}></A>
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "handleClick"],
newFileContent:
`interface P {
onClick: (a: number, b: string) => void;
}
const A = ({ onClick }: P) =>
<div onClick={onClick}></div>;
const B = () =>
<A onClick={handleClick}></A>
function handleClick(a: number, b: string): void {
throw new Error("Function not implemented.");
}
`
});
| {
"end_byte": 728,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration22.ts"
} |
TypeScript/tests/cases/fourslash/scopeOfUnionProperties.ts_0_148 | /// <reference path='fourslash.ts'/>
////function f(s: string | number) {
//// s.constr/*1*/uctor
////}
verify.baselineDocumentHighlights("1");
| {
"end_byte": 148,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/scopeOfUnionProperties.ts"
} |
TypeScript/tests/cases/fourslash/codeFixConvertToTypeOnlyImport11.ts_0_553 | /// <reference path="fourslash.ts" />
// @verbatimModuleSyntax: true
// @module: esnext
// @moduleResolution: bundler
// @target: esnext
// @filename: /a.ts
////export interface f {}
////export interface I {}
// @Filename: /b.ts
////import { I, f } from "./a";
////export { type I, f };
goTo.file("/b.ts");
verify.codeFixAvailable([
{ description: "Use 'import type'" },
{ description: "Use 'type I'" },
{ description: "Use 'import type'" },
{ description: "Use 'type f'" },
{ description: "Convert to type-only export" },
]);
| {
"end_byte": 553,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToTypeOnlyImport11.ts"
} |
TypeScript/tests/cases/fourslash/jsdocLink6.ts_0_297 | /// <reference path='fourslash.ts' />
// @filename: /a.ts
////export default function A() { }
////export function B() { };
// @Filename: /b.ts
////import A, { B } from "./a";
/////**
//// * {@link A}
//// * {@link B}
//// */
////export default function /**/f() { }
verify.baselineQuickInfo();
| {
"end_byte": 297,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocLink6.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_AccessCallCallReturnValue.ts_0_431 | /// <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": 431,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_AccessCallCallReturnValue.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_interfaceNoIntersection.ts_0_362 | /// <reference path='fourslash.ts' />
////interface IFoo {
//// method(x: string, y: string): void;
////}
////interface IBar {
//// method(x: number): void;
////}
////const x: IFoo & IBar = {
//// method(/*a*/x: string, y: string/*b*/): void {},
////};
goTo.select("a", "b");
verify.not.refactorAvailable("Convert parameters to destructured object");
| {
"end_byte": 362,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_interfaceNoIntersection.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports17-unique-symbol.ts_0_298 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
// @lib: es2019
//// export const a = Symbol();
verify.codeFix({
description: "Add annotation of type 'unique symbol'",
index: 0,
newFileContent:
`export const a: unique symbol = Symbol();`
});
| {
"end_byte": 298,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports17-unique-symbol.ts"
} |
TypeScript/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts_0_256 | /// <reference path='fourslash.ts' />
/////*top*/
////namespace n1.
//// /*n2*/ n2.
//// /*n3*/ n3 {
////}
verify.docCommentTemplateAt("top", /*indentation*/ 3,
"/** */");
verify.noDocCommentTemplateAt("n2");
verify.noDocCommentTemplateAt("n3");
| {
"end_byte": 256,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts"
} |
TypeScript/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard2.ts_0_992 | /// <reference path="fourslash.ts" />
// @module: nodenext
// @Filename: /node_modules/salesforce-pageobjects/package.json
//// {
//// "name": "salesforce-pageobjects",
//// "version": "1.0.0",
//// "exports": {
//// "./*": {
//// "types": "./dist/*.d.ts",
//// "import": "./dist/*.mjs",
//// "default": "./dist/*.js"
//// }
//// }
//// }
// @Filename: /node_modules/salesforce-pageobjects/dist/action/pageObjects/actionRenderer.d.ts
//// export const actionRenderer = 0;
// @Filename: /index.mts
//// import { } from "salesforce-pageobjects//**/";
verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: [{ name: "action", kind: "directory" }]
});
edit.insert("action/");
verify.completions({
isNewIdentifierLocation: true,
exact: [{ name: "pageObjects", kind: "directory" }],
});
edit.insert("pageObjects/");
verify.completions({
isNewIdentifierLocation: true,
exact: [{ name: "actionRenderer", kind: "script" }],
});
| {
"end_byte": 992,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard2.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_symlink_own_package_2.ts_0_349 | /// <reference path="fourslash.ts" />
// @Filename: /packages/a/test.ts
// @Symlink: /node_modules/a/test.ts
////x;
// @Filename: /packages/a/utils.ts
// @Symlink: /node_modules/a/utils.ts
////import {} from "a/utils";
////export const x = 0;
goTo.file("/packages/a/test.ts");
verify.importFixAtPosition([
`import { x } from "./utils";
x;`,
]);
| {
"end_byte": 349,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_symlink_own_package_2.ts"
} |
TypeScript/tests/cases/fourslash/completionListInObjectLiteral3.ts_0_233 | /// <reference path='fourslash.ts'/>
////interface IASTNode {
//// name: string;
//// children: IASTNode[];
////}
////var ast2: IASTNode = {
//// /**/
////}
verify.completions({ marker: "", exact: ["children", "name"] });
| {
"end_byte": 233,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInObjectLiteral3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAwaitInSyncFunction13.ts_0_350 | /// <reference path='fourslash.ts' />
////const f: () => Promise<number | string> = () => {
//// await Promise.resolve('foo');
////}
verify.codeFix({
index: 2,
description: "Add async modifier to containing function",
newFileContent:
`const f: () => Promise<number | string> = async () => {
await Promise.resolve('foo');
}`,
});
| {
"end_byte": 350,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAwaitInSyncFunction13.ts"
} |
TypeScript/tests/cases/fourslash/jsDocSee1.ts_0_585 | ///<reference path="fourslash.ts" />
//// interface [|/*def1*/Foo|] {
//// foo: string
//// }
//// namespace NS {
//// export interface [|/*def2*/Bar|] {
//// baz: Foo
//// }
//// }
//// /** @see {/*use1*/[|Foo|]} foooo*/
//// const a = ""
//// /** @see {NS./*use2*/[|Bar|]} ns.bar*/
//// const b = ""
//// /** @see /*use3*/[|Foo|] f1*/
//// const c = ""
//// /** @see NS./*use4*/[|Bar|] ns.bar*/
//// const [|/*def3*/d|] = ""
//// /** @see /*use5*/[|d|] dd*/
//// const e = ""
verify.baselineGetDefinitionAtPosition("use1", "use2", "use3", "use4", "use5"); | {
"end_byte": 585,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocSee1.ts"
} |
TypeScript/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment4.ts_0_487 | /// <reference path='fourslash.ts'/>
//// export interface ConfigFiles {
//// jspm: string;
//// 'jspm:browser': string;
//// }
//// function foo(c: ConfigFiles) {}
//// foo({
//// j/*0*/: "",
//// "[|/*1*/|]": "",
//// })
const replacementSpan = test.ranges()[0]
verify.completions(
{ marker: "0", exact: ['"jspm:browser"', "jspm"] },
{ marker: "1", exact: [
{ name: "jspm", replacementSpan },
{ name: "jspm:browser", replacementSpan }
] }
);
| {
"end_byte": 487,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment4.ts"
} |
TypeScript/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts_0_146 | /// <reference path='fourslash.ts'/>
////let p, b;
////
////p, [{ /*1*/a: p, b }] = [{ a: 10, b: true }];
verify.baselineFindAllReferences('1')
| {
"end_byte": 146,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts"
} |
TypeScript/tests/cases/fourslash/completionsObjectLiteralExpressions7.ts_2_2338 | /// <reference path="fourslash.ts" />
// @Filename: a.ts
//// interface I {
//// aaa: number,
//// bbb: number,
//// }
////
//// interface U {
//// a: number,
//// b: {
//// c: {
//// d: {
//// aaa: number,
//// }
//// }
////
//// },
//// }
//// const num: U = {} as any;
////
//// const l: I = {
//// ...num.b.c.d
//// /*a*/
//// }
// @Filename: b.ts
//// interface pp {
//// aaa: string;
//// bbb: number;
//// }
////
//// const abc: pp = {
//// aaa: "",
//// bbb: 1,
//// }
////
//// const cab: pp = {
//// ...abc
//// /*b*/
//// }
verify.completions({
marker: "a",
includes: [{
name: "bbb",
sortText: completion.SortText.LocationPriority,
hasAction: true,
source: completion.CompletionSource.ObjectLiteralMemberWithComma,
}],
preferences: {
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
},
});
verify.applyCodeActionFromCompletion("a", {
name: "bbb",
description: `Add missing comma for object member completion 'bbb'.`,
source: completion.CompletionSource.ObjectLiteralMemberWithComma,
newFileContent:
`interface I {
aaa: number,
bbb: number,
}
interface U {
a: number,
b: {
c: {
d: {
aaa: number,
}
}
},
}
const num: U = {} as any;
const l: I = {
...num.b.c.d,
}`,
preferences: {
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
},
});
verify.completions({
marker: "b",
includes: [{
name: "aaa",
sortText: completion.SortText.MemberDeclaredBySpreadAssignment,
hasAction: true,
source: completion.CompletionSource.ObjectLiteralMemberWithComma,
}],
preferences: {
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
},
});
verify.applyCodeActionFromCompletion("b", {
name: "aaa",
description: `Add missing comma for object member completion 'aaa'.`,
source: completion.CompletionSource.ObjectLiteralMemberWithComma,
newFileContent:
`interface pp {
aaa: string;
bbb: number;
}
const abc: pp = {
aaa: "",
bbb: 1,
}
const cab: pp = {
...abc,
}`,
preferences: {
allowIncompleteCompletions: true,
includeInsertTextCompletions: true,
},
}); | {
"end_byte": 2338,
"start_byte": 2,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsObjectLiteralExpressions7.ts"
} |
TypeScript/tests/cases/fourslash/incrementalParsing1.ts_0_516 | /// <reference path="fourslash.ts"/>
//// function foo() {
//// function getOccurrencesAtPosition() {
//// switch (node) {
//// enum /*1*/
//// }
////
//// return undefined;
////
//// function keywordToReferenceEntry() {
//// }
//// }
////
//// return {
//// getEmitOutput: (filename): Bar => null,
//// };
//// }
// Force a syntax tree ot be created.
verify.noMatchingBracePositionInCurrentFile(0);
goTo.marker('1');
edit.insert('Fo');
| {
"end_byte": 516,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incrementalParsing1.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnMergedModule.ts_0_400 | /// <reference path='fourslash.ts'/>
////module M2 {
//// export interface A {
//// foo: string;
//// }
//// var a: A;
//// var r = a.foo + a.bar;
////}
////module M2 {
//// export interface A {
//// bar: number;
//// }
//// var a: A;
//// var r = a.fo/*1*/o + a.bar;
////}
verify.quickInfoAt("1", "(property) M2.A.foo: string", undefined);
verify.noErrors();
| {
"end_byte": 400,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnMergedModule.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingProperties13.ts_0_413 | /// <reference path='fourslash.ts' />
////interface Foo {
//// a: number;
//// b: number;
//// c: () => void;
////}
////function f(foo: Foo) {}
////[|f({ a: 10 })|];
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_properties.message,
newRangeContent:
`f({
a: 10,
b: 0,
c: function(): void {
throw new Error("Function not implemented.");
}
})`
});
| {
"end_byte": 413,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingProperties13.ts"
} |
TypeScript/tests/cases/fourslash/importFixWithMultipleModuleExportAssignment.ts_0_352 | /// <reference path="fourslash.ts" />
// @module: esnext
// @allowJs: true
// @checkJs: true
// @Filename: /a.js
////function f() {}
////module.exports = f;
////module.exports = 42;
// @Filename: /b.js
////export const foo = 0;
// @Filename: /c.js
////foo
goTo.file("/c.js");
verify.importFixAtPosition([
`const { foo } = require("./b");
foo`]);
| {
"end_byte": 352,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importFixWithMultipleModuleExportAssignment.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentOnUnclosedTupleTypeLiteral01.ts_0_218 | /// <reference path='fourslash.ts' />
////var x: [string, number,
////{| "indent": 4 |}
test.markers().forEach(marker => {
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent);
}); | {
"end_byte": 218,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentOnUnclosedTupleTypeLiteral01.ts"
} |
TypeScript/tests/cases/fourslash/goToImplementationInterfaceMethod_02.ts_0_520 | /// <reference path='fourslash.ts'/>
// Should return implementations when left hand side of function call is an abstract class
//// interface Foo {
//// he/*declaration*/llo(): void
//// }
////
//// abstract class AbstractBar implements Foo {
//// abstract hello(): void;
//// }
////
//// class Bar extends AbstractBar {
//// [|hello|]() {}
//// }
////
//// function whatever(a: AbstractBar) {
//// a.he/*function_call*/llo();
//// }
verify.baselineGoToImplementation("function_call", "declaration"); | {
"end_byte": 520,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationInterfaceMethod_02.ts"
} |
TypeScript/tests/cases/fourslash/memberListInWithBlock2.ts_0_199 | /// <reference path='fourslash.ts'/>
////interface IFoo {
//// a: number;
////}
////
////with (x) {
//// var y: IFoo = { /*1*/ };
////}
verify.completions({ marker: "1", exact: undefined });
| {
"end_byte": 199,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberListInWithBlock2.ts"
} |
TypeScript/tests/cases/fourslash/referencesForFunctionOverloads.ts_0_275 | /// <reference path='fourslash.ts'/>
// Function overloads should be highlighted together.
/////*1*/function /*2*/foo(x: string);
/////*3*/function /*4*/foo(x: string, y: number) {
//// /*5*/foo('', 43);
////}
verify.baselineFindAllReferences('1', '2', '3', '4', '5');
| {
"end_byte": 275,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForFunctionOverloads.ts"
} |
TypeScript/tests/cases/fourslash/autoImportSpecifierExcludeRegexes3.ts_0_649 | /// <reference path="fourslash.ts" />
// @module: preserve
// @Filename: /node_modules/pkg/package.json
//// {
//// "name": "pkg",
//// "version": "1.0.0",
//// "exports": {
//// ".": "./index.js",
//// "./utils": "./utils.js"
//// }
//// }
// @Filename: /node_modules/pkg/utils.d.ts
//// export function add(a: number, b: number) {}
// @Filename: /node_modules/pkg/index.d.ts
//// export * from "./utils";
// @Filename: /src/index.ts
//// add/**/
verify.importFixModuleSpecifiers("", ["pkg", "pkg/utils"]);
verify.importFixModuleSpecifiers("", ["pkg/utils"], { autoImportSpecifierExcludeRegexes: ["^pkg$"] });
| {
"end_byte": 649,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportSpecifierExcludeRegexes3.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixExistingImportEquals0.ts_0_434 | /// <reference path="fourslash.ts" />
//// [|import ns = require("ambient-module");
//// var x = v1/*0*/ + 5;|]
// @Filename: ambientModule.ts
//// declare module "ambient-module" {
//// export function f1();
//// export var v1;
//// }
verify.importFixAtPosition([
`import ns = require("ambient-module");
var x = ns.v1 + 5;`,
`import { v1 } from "ambient-module";
import ns = require("ambient-module");
var x = v1 + 5;`,
]);
| {
"end_byte": 434,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixExistingImportEquals0.ts"
} |
TypeScript/tests/cases/fourslash/extract-const_jsxSelfClosingElement1.ts_0_549 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: a.tsx
////function Foo() {
//// return (
//// <div>
//// /*a*/<br />/*b*/
//// </div>
//// );
////}
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 = <br />;
function Foo() {
return (
<div>
{newLocal}
</div>
);
}`
});
| {
"end_byte": 549,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const_jsxSelfClosingElement1.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_ReturnStatementConditional.ts_0_462 | /// <reference path='fourslash.ts' />
////let a = { b: { c: 0 } };
////function f(){
//// return /*a*/a.b ? a.b.c : "whenFalse"/*b*/;
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to optional chain expression",
actionName: "Convert to optional chain expression",
actionDescription: "Convert to optional chain expression",
newContent:
`let a = { b: { c: 0 } };
function f(){
return a.b?.c ?? "whenFalse";
}`
}); | {
"end_byte": 462,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_ReturnStatementConditional.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_defaultExport.ts_0_375 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////[|export default function f() { }|]
////f();
// @Filename: /user.ts
////import f from "./a";
////f();
verify.moveToNewFile({
newFileContents: {
"/a.ts":
`import f from "./f";
f();`,
"/f.ts":
`export default function f() { }
`,
"/user.ts":
`import f from "./f";
f();`,
},
});
| {
"end_byte": 375,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_defaultExport.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts_0_417 | /// <reference path='fourslash.ts' />
//// function f(templateStrings, x, y, z) { return 10; }
//// function g(templateStrings, x, y, z) { return ""; }
////
//// f ` ${ 123 } ${/*1*/ } `
verify.signatureHelp({
marker: test.markers(),
text: "f(templateStrings: any, x: any, y: any, z: any): number",
argumentCount: 3,
parameterCount: 4,
parameterName: "y",
parameterSpan: "y: any",
});
| {
"end_byte": 417,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts"
} |
TypeScript/tests/cases/fourslash/whiteSpaceTrimming3.ts_0_193 | /// <reference path="fourslash.ts" />
////let t = "foo \
////bar \
////"/*1*/
goTo.marker('1');
edit.insert(";");
verify.currentFileContentIs("let t = \"foo \\\nbar \\ \n\";");
| {
"end_byte": 193,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/whiteSpaceTrimming3.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_prologueDirectives7.ts_0_415 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////"use strict";
////[|function b() {
//// return this;
////}|]
////"prologue directive like statement";
////b();
verify.moveToNewFile({
newFileContents: {
"/a.ts":
`"use strict";
import { b } from "./b";
"prologue directive like statement";
b();`,
"/b.ts":
`"use strict";
export function b() {
return this;
}
`,
},
});
| {
"end_byte": 415,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_prologueDirectives7.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionAmbiants.ts_0_822 | /// <reference path='fourslash.ts' />
////declare var /*ambientVariableDefinition*/ambientVar;
////declare function /*ambientFunctionDefinition*/ambientFunction();
////declare class ambientClass {
//// /*constructorDefinition*/constructor();
//// static /*staticMethodDefinition*/method();
//// public /*instanceMethodDefinition*/method();
////}
////
/////*ambientVariableReference*/ambientVar = 1;
/////*ambientFunctionReference*/ambientFunction();
////var ambientClassVariable = new /*constructorReference*/ambientClass();
////ambientClass./*staticMethodReference*/method();
////ambientClassVariable./*instanceMethodReference*/method();
verify.baselineGetDefinitionAtPosition("ambientVariableReference", "ambientFunctionReference", "constructorReference", "staticMethodReference", "instanceMethodReference");
| {
"end_byte": 822,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionAmbiants.ts"
} |
TypeScript/tests/cases/fourslash/referencesInComment.ts_0_228 | /// <reference path='fourslash.ts'/>
////// References to /*1*/foo or b/*2*/ar
/////* in comments should not find fo/*3*/o or bar/*4*/ */
////class foo { }
////var bar = 0;
verify.baselineFindAllReferences('1', '2', '3', '4')
| {
"end_byte": 228,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesInComment.ts"
} |
TypeScript/tests/cases/fourslash/completionsImport_tsx.ts_0_450 | /// <reference path="fourslash.ts" />
// @noLib: true
// @jsx: preserve
// @Filename: /a.tsx
////export type Bar = 0;
////export default function Foo() {};
// @Filename: /b.tsx
////<Fo/**/ />;
verify.completions({
marker: "",
includes: { name: "Foo", source: "/a", hasAction: true, sortText: completion.SortText.AutoImportSuggestions },
excludes: "Bar",
preferences: {
includeCompletionsForModuleExports: true,
},
});
| {
"end_byte": 450,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImport_tsx.ts"
} |
TypeScript/tests/cases/fourslash/extract-const9.ts_0_371 | /// <reference path='fourslash.ts' />
// @filename: foo.ts
////const foo = 1 * /*a*/(((((2 + 2)))))/*b*/;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "constant_scope_0",
actionDescription: "Extract to constant in enclosing scope",
newContent:
`const newLocal = 2 + 2;
const foo = 1 * /*RENAME*/newLocal;`
});
| {
"end_byte": 371,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-const9.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsTripleSlash14.ts_0_167 | /// <reference path="fourslash.ts"/>
//// /// nonElement
const c = classification("original");
verify.syntacticClassificationsAre(
c.comment("/// nonElement"));
| {
"end_byte": 167,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsTripleSlash14.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration16.ts_0_259 | /// <reference path='fourslash.ts' />
// @moduleResolution: node
// @filename: /node_modules/test/index.js
////export const x = 1;
// @filename: /foo.ts
////import * as test from "test";
////test.foo();
goTo.file("/foo.ts");
verify.not.codeFixAvailable();
| {
"end_byte": 259,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration16.ts"
} |
TypeScript/tests/cases/fourslash/documentHighlights_windowsPath.ts_0_199 | /// <reference path='fourslash.ts' />
//@Filename: C:\a\b\c.ts
////var /*1*/[|x|] = 1;
const range = test.ranges()[0];
verify.baselineDocumentHighlights(range, { filesToSearch: [range.fileName] }); | {
"end_byte": 199,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/documentHighlights_windowsPath.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports23-heritage-formatting.ts_0_940 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
////function mixin<T extends new (...a: any) => any>(ctor: T): T {
//// return ctor;
////}
////class Point2D { x = 0; y = 0; }
////interface I{}
////export class Point3D extends
//// /** Base class */
//// mixin(Point2D)
//// // Test
//// implements I
//// {
//// z = 0;
////}
verify.codeFixAvailable([
{ description: ts.Diagnostics.Extract_base_class_to_variable.message }
]);
verify.codeFix({
description: ts.Diagnostics.Extract_base_class_to_variable.message,
index: 0,
newFileContent:
`function mixin<T extends new (...a: any) => any>(ctor: T): T {
return ctor;
}
class Point2D { x = 0; y = 0; }
interface I{}
const Point3DBase: typeof Point2D =
/** Base class */
mixin(Point2D);
export class Point3D extends Point3DBase
// Test
implements I
{
z = 0;
}`
});
| {
"end_byte": 940,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports23-heritage-formatting.ts"
} |
TypeScript/tests/cases/fourslash/getOccurrencesThrow5.ts_0_914 | /// <reference path='fourslash.ts' />
////function f(a: number) {
//// try {
//// throw "Hello";
////
//// try {
//// throw 10;
//// }
//// catch (x) {
//// return 100;
//// }
//// finally {
//// throw 10;
//// }
//// }
//// catch (x) {
//// throw "Something";
//// }
//// finally {
//// throw "Also something";
//// }
//// if (a > 0) {
//// return (function () {
//// return;
//// return;
//// return;
////
//// if (false) {
//// return true;
//// }
//// throw "Hello!";
//// })() || true;
//// }
////
//// throw 10;
////
//// var unusued = [1, 2, 3, 4].map(x => { [|thr/**/ow|] 4 })
////
//// return;
//// return true;
//// throw false;
////}
verify.baselineDocumentHighlights();
| {
"end_byte": 914,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesThrow5.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedTaggedTemplate02.ts_0_185 | /// <reference path='fourslash.ts' />
////var x;
////var y = (p) => x `abc ${ 123 } ${ /*1*/
verify.completions({ marker: "1", includes: ["p", "x"], isNewIdentifierLocation: true });
| {
"end_byte": 185,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedTaggedTemplate02.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.