_id
stringlengths
21
254
text
stringlengths
1
93.7k
metadata
dict
TypeScript/tests/cases/fourslash/constructorQuickInfo.ts_0_264
/// <reference path='fourslash.ts'/> ////class SS<T>{} //// ////var x/*1*/1 = new SS<number>(); ////var x/*2*/2 = new SS(); ////var x/*3*/3 = new SS; verify.quickInfos({ 1: "var x1: SS<number>", 2: "var x2: SS<unknown>", 3: "var x3: SS<unknown>" });
{ "end_byte": 264, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/constructorQuickInfo.ts" }
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsUsing.ts_0_210
/// <reference path="fourslash.ts" /> // @lib: esnext ////using a/*a*/ = "a"; ////const f = async () => { //// await using /*b*/b = { async [Symbol.asyncDispose]() {} }; ////}; verify.baselineQuickInfo();
{ "end_byte": 210, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsUsing.ts" }
TypeScript/tests/cases/fourslash/indentationAfterModuleImport.ts_0_215
/// <reference path="fourslash.ts"/> ////declare module "fs" { }; ////import im = module("fs");/**/ goTo.marker(); edit.insert("\n"); // [Smart Indent] Auto indent after module import decl verify.indentationIs(0);
{ "end_byte": 215, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indentationAfterModuleImport.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportNodeModules3.ts_0_256
/// <reference path="fourslash.ts" /> // @Filename: /a.ts //// [|f1/*0*/();|] // @Filename: /node_modules/@types/random/index.d.ts //// export var v1 = 5; //// export function f1(); verify.importFixAtPosition([ `import { f1 } from "random"; f1();` ]);
{ "end_byte": 256, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportNodeModules3.ts" }
TypeScript/tests/cases/fourslash/completionsAfterKeywordsInBlock.ts_0_1313
/// <reference path="fourslash.ts" /> ////class C1 { //// method(map: Map<string, string>, key: string, defaultValue: string) { //// try { //// return map.get(key)!; //// } //// catch { //// return default/*1*/ //// } //// } ////} ////class C2 { //// method(map: Map<string, string>, key: string, defaultValue: string) { //// if (map.has(key)) { //// return map.get(key)!; //// } //// else { //// return default/*2*/ //// } //// } ////} ////class C3 { //// method(map: Map<string, string>, key: string, returnValue: string) { //// try { //// return map.get(key)!; //// } //// catch { //// return return/*3*/ //// } //// } ////} ////class C4 { //// method(map: Map<string, string>, key: string, returnValue: string) { //// if (map.has(key)) { //// return map.get(key)!; //// } //// else { //// return return/*4*/ //// } //// } ////} verify.completions({ marker: ["1", "2"], includes: [{ name: "defaultValue", sortText: completion.SortText.LocationPriority }] }, { marker: ["3", "4"], includes: [{ name: "returnValue", sortText: completion.SortText.LocationPriority }] });
{ "end_byte": 1313, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsAfterKeywordsInBlock.ts" }
TypeScript/tests/cases/fourslash/renameParameterPropertyDeclaration1.ts_3_313
/ <reference path='fourslash.ts'/> //// class Foo { //// constructor([|private [|{| "contextRangeIndex": 0 |}privateParam|]: number|]) { //// let localPrivate = [|privateParam|]; //// this.[|privateParam|] += 10; //// } //// } verify.baselineRenameAtRangesWithText("privateParam");
{ "end_byte": 313, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameParameterPropertyDeclaration1.ts" }
TypeScript/tests/cases/fourslash/completionListAfterNumericLiteral.ts_0_796
/// <reference path='fourslash.ts' /> // @Filename: f1.ts ////0./*dotOnNumberExpressions1*/ // @Filename: f2.ts ////0.0./*dotOnNumberExpressions2*/ // @Filename: f3.ts ////0.0.0./*dotOnNumberExpressions3*/ // @Filename: f4.ts ////0./** comment *//*dotOnNumberExpressions4*/ // @Filename: f5.ts ////(0)./*validDotOnNumberExpressions1*/ // @Filename: f6.ts ////(0.)./*validDotOnNumberExpressions2*/ // @Filename: f7.ts ////(0.0)./*validDotOnNumberExpressions3*/ verify.completions( { marker: ["dotOnNumberExpressions1", "dotOnNumberExpressions4"], exact: undefined }, { marker: ["dotOnNumberExpressions2", "dotOnNumberExpressions3", "validDotOnNumberExpressions1", "validDotOnNumberExpressions2", "validDotOnNumberExpressions3"], includes: "toExponential" }, );
{ "end_byte": 796, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAfterNumericLiteral.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedInterfaceInNamespace2.ts_0_251
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true ////namespace greeter { //// [| export interface interface2 { //// } //// interface interface1 { //// } |] ////} verify.rangeAfterCodeFix(`export interface interface2 { }`);
{ "end_byte": 251, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedInterfaceInNamespace2.ts" }
TypeScript/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnonymous_Comment2.ts_0_383
/// <reference path='fourslash.ts' /> ////const foo = /*a*/()/*b*/ => // comment ////1 goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert arrow function or function expression", actionName: "Convert to anonymous function", actionDescription: "Convert to anonymous function", newContent: `const foo = function() { // comment return 1; }` });
{ "end_byte": 383, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertArrowFunctionOrFunctionExpression_ToAnonymous_Comment2.ts" }
TypeScript/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity2.ts_0_547
/// <reference path='fourslash.ts'/> ////declare function f(s: string); ////declare function f(n: number); ////declare function f(s: string, b: boolean); ////declare function f(n: number, b: boolean); //// ////f(1/**/ var verify.signatureHelp({ marker: "", overloadsCount: 4, text: "f(n: number): any", parameterName: "n", parameterSpan: "n: number", }); edit.insert(", "); verify.signatureHelp({ overloadsCount: 4, text: "f(n: number, b: boolean): any", parameterName: "b", parameterSpan: "b: boolean", });
{ "end_byte": 547, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity2.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType_js9.ts_0_448
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: a.js //// /** @type { /*a*/string | number/*b*/ | boolean } */ //// var x; goTo.file('a.js') goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to typedef", actionDescription: "Extract to typedef", newContent: `/** * @typedef {string | number} /*RENAME*/NewType */ /** @type { NewType | boolean } */ var x;`, });
{ "end_byte": 448, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType_js9.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports29-inline.ts_0_468
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true // fileName: code.ts ////function getString() { //// return "" ////} ////export const exp = { //// prop: getString() ////}; verify.codeFix({ description: "Add satisfies and an inline type assertion with 'string'", index: 1, newFileContent: `function getString() { return "" } export const exp = { prop: getString() satisfies string as string };` });
{ "end_byte": 468, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports29-inline.ts" }
TypeScript/tests/cases/fourslash/extract-method10.ts_0_450
/// <reference path='fourslash.ts' /> //// export {}; // Make this a module //// (x => x)(/*1*/x => x/*2*/)(1); goTo.select('1', '2'); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: 'function_scope_0', actionDescription: "Extract to function in module scope", newContent: `export {}; // Make this a module (x => x)(/*RENAME*/newFunction())(1); function newFunction(): (x: any) => any { return x => x; } ` });
{ "end_byte": 450, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method10.ts" }
TypeScript/tests/cases/fourslash/indentationInArrays.ts_0_423
/// <reference path="fourslash.ts"/> //// function foo() { //// [/*8_0*/1,2,3]; //// [1/*8_1*/,2,3]; //// [1,/*8_2*/2,3]; //// [ //// 1,/*8_3*/2,3]; //// [1,2,3/*8_4*/]; //// [ //// 1,2,3/*8_5*/]; //// [1,2,3]/*8_6*/; //// [ //// 1,2,3]/*8_7*/; //// } for (let i = 0; i < 8; ++i) { goTo.marker(`8_${i}`); edit.insertLine(""); verify.indentationIs(8); }
{ "end_byte": 423, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indentationInArrays.ts" }
TypeScript/tests/cases/fourslash/formattingofSingleLineBlockConstructs.ts_0_1267
///<reference path="fourslash.ts"/> ////module InternalModule/*1*/{} ////interface MyInterface/*2*/{} ////enum E/*3*/{} ////class MyClass/*4*/{ ////constructor()/*cons*/{} //// public MyFunction()/*5*/{return 0;} ////public get Getter()/*6*/{} ////public set Setter(x)/*7*/{}} ////function foo()/*8*/{{}} ////(function()/*10*/{}); ////(() =>/*11*/{}); ////var x :/*12*/{}; format.document(); goTo.marker('1'); verify.currentLineContentIs("module InternalModule { }"); goTo.marker('2'); verify.currentLineContentIs("interface MyInterface { }"); goTo.marker('3'); verify.currentLineContentIs("enum E { }"); goTo.marker('4'); verify.currentLineContentIs("class MyClass {"); goTo.marker('cons'); verify.currentLineContentIs(" constructor() { }"); goTo.marker('5'); verify.currentLineContentIs(" public MyFunction() { return 0; }"); goTo.marker('6'); verify.currentLineContentIs(" public get Getter() { }"); goTo.marker('7'); verify.currentLineContentIs(" public set Setter(x) { }"); goTo.marker('8'); verify.currentLineContentIs("function foo() { { } }"); goTo.marker('10'); verify.currentLineContentIs("(function() { });"); goTo.marker('11'); verify.currentLineContentIs("(() => { });"); goTo.marker('12'); verify.currentLineContentIs("var x: {};");
{ "end_byte": 1267, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingofSingleLineBlockConstructs.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics13.ts_0_140
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: a.js ////var v: () => number; verify.baselineSyntacticDiagnostics();
{ "end_byte": 140, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics13.ts" }
TypeScript/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity.ts_0_543
/// <reference path='fourslash.ts'/> ////declare function f(s: string); ////declare function f(n: number); ////declare function f(s: string, b: boolean); ////declare function f(n: number, b: boolean); //// ////f(1/**/ verify.signatureHelp({ marker: "", overloadsCount: 4, text: "f(n: number): any", parameterName: "n", parameterSpan: "n: number", }); edit.insert(", "); verify.signatureHelp({ overloadsCount: 4, text: "f(n: number, b: boolean): any", parameterName: "b", parameterSpan: "b: boolean", });
{ "end_byte": 543, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity.ts" }
TypeScript/tests/cases/fourslash/completionsImportFromJSXTag.ts_0_650
/// <reference path="fourslash.ts" /> // @jsx: react // @Filename: /types.d.ts //// declare namespace JSX { //// interface IntrinsicElements { a } //// } // @Filename: /Box.tsx //// export function Box(props: any) { return null; } // @Filename: /App.tsx //// export function App() { //// return ( //// <div className="App"> //// <Box/**/ //// </div> //// ) //// } verify.applyCodeActionFromCompletion("", { name: "Box", source: "/Box", description: `Add import from "./Box"`, newFileContent: `import { Box } from "./Box"; export function App() { return ( <div className="App"> <Box </div> ) }` });
{ "end_byte": 650, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsImportFromJSXTag.ts" }
TypeScript/tests/cases/fourslash/codeFixSpellingAddSpaces5.ts_0_910
/// <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.[|AndThisHasFourSpaces_________________________________________________________|]; verify.codeFixAvailable([ { description: "Change spelling to 'And This Has Four Spaces_________________________________________________________'" }, { description: "Add missing enum member 'AndThisHasFourSpaces_________________________________________________________'" }, ]);
{ "end_byte": 910, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpellingAddSpaces5.ts" }
TypeScript/tests/cases/fourslash/completionListInUnclosedFunction04.ts_3_245
/ <reference path="fourslash.ts" /> ////function foo(x: string, y: number, z: boolean) { //// function bar(a: number, b: string, c: typeof x = /*1*/ verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b"]})
{ "end_byte": 245, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedFunction04.ts" }
TypeScript/tests/cases/fourslash/moveToFile_expandSelectionRange6.ts_0_371
/// <reference path='fourslash.ts' /> //@Filename: /bar.ts //// // @Filename: /a.ts ////[|function|] f() { ////function inner() {} ////} ////const a = 1; verify.moveToFile({ newFileContents: { "/a.ts": `const a = 1;`, "/bar.ts": ` function f() { function inner() { } } `, }, interactiveRefactorArguments: { targetFile: "/bar.ts" } });
{ "end_byte": 371, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_expandSelectionRange6.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports27-non-exported-bidings.ts_0_558
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true // fileName: code.ts ////let p = { x: 1, y: 2} ////const a = 1, b = 10, { x, y } = p, c = 1; ////export { x, y } ////export const d = a + b + c; verify.codeFixAll({ fixId: "fixMissingTypeAnnotationOnExports", fixAllDescription: ts.Diagnostics.Add_all_missing_type_annotations.message, newFileContent: `let p = { x: 1, y: 2} const x: number = p.x; const y: number = p.y; const a = 1, b = 10, c = 1; export { x, y } export const d: number = a + b + c;` })
{ "end_byte": 558, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports27-non-exported-bidings.ts" }
TypeScript/tests/cases/fourslash/extract-method41.ts_0_490
/// <reference path='fourslash.ts' /> ////function bar(fn: () => void) {} //// ////class Foo { //// x: number; //// foo() { //// /*start*/bar(() => { //// () => { //// () => { //// this.x; //// } //// } //// });/*end*/ //// } ////} goTo.select("start", "end"); verify.refactorAvailable("Extract Symbol", "function_scope_1"); verify.not.refactorAvailable("Extract Symbol", "function_scope_2");
{ "end_byte": 490, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method41.ts" }
TypeScript/tests/cases/fourslash/completionForComputedStringProperties.ts_0_397
/// <reference path="fourslash.ts" /> //// const p2 = "p2"; //// interface A { //// ["p1"]: string; //// [p2]: string; //// } //// declare const a: A; //// a[|./**/|] verify.completions({ marker: "", exact: [ { name: "p1" }, { name: "p2", insertText: '[p2]', replacementSpan: test.ranges()[0] }, ], preferences: { includeInsertTextCompletions: true }, });
{ "end_byte": 397, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionForComputedStringProperties.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_import_includeDefaultUses.ts_0_273
/// <reference path='fourslash.ts' /> // @allowJs: true // @target: esnext // @Filename: /a.js ////const x = /*a*/require/*b*/("x"); ////x(); ////x.y; verify.codeFix({ description: "Convert to ES module", newFileContent: `import x, { y } from "x"; x(); y;`, });
{ "end_byte": 273, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_import_includeDefaultUses.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesIfElseBroken.ts_0_359
/// <reference path='fourslash.ts' /> ////[|if|] (true) { //// var x = 1; ////} ////[|else if|] () ////[|else if|] ////[|else|] /* whar garbl */ [|if|] (i/**/f (true) { } else { }) ////else // It would be nice if in the future, // We could include that last 'else'. verify.baselineDocumentHighlights(); verify.baselineDocumentHighlights("");
{ "end_byte": 359, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesIfElseBroken.ts" }
TypeScript/tests/cases/fourslash/renameJsExports02.ts_0_211
/// <reference path='fourslash.ts'/> // @allowJs: true // @Filename: a.js ////module.exports = class /*1*/A {} // @Filename: b.js ////const /*2*/A = require("./a"); verify.baselineFindAllReferences('1', '2')
{ "end_byte": 211, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameJsExports02.ts" }
TypeScript/tests/cases/fourslash/moduleEnumModule.ts_0_186
/// <reference path="fourslash.ts" /> ////module A { //// var o; ////} ////enum A { //// /**/c ////} ////module A { //// var p; ////} goTo.marker(); verify.quickInfoExists();
{ "end_byte": 186, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moduleEnumModule.ts" }
TypeScript/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile8.ts_0_395
/// <reference path='fourslash.ts' /> // @allowjs: true // @noEmit: true // @checkJs: true // @Filename: a.js ////var x = 0; //// ////function f(_a) {[| //// /** comment for f */ //// f(x()); ////|]} // Disable checking for next line verify.rangeAfterCodeFix(` /** comment for f */ // @ts-ignore f(x());`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
{ "end_byte": 395, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile8.ts" }
TypeScript/tests/cases/fourslash/semanticClassificationWithUnionTypes.ts_0_1374
////module /*0*/M { //// export interface /*1*/I { //// } ////} //// ////interface /*2*/I { ////} ////class /*3*/C { ////} //// ////var M: /*4*/M./*5*/I | /*6*/I | /*7*/C; ////var I: typeof M | typeof /*8*/C; const c = classification("original"); verify.semanticClassificationsAre("original", c.moduleName("M", test.marker("0").position), c.interfaceName("I", test.marker("1").position), c.interfaceName("I", test.marker("2").position), c.className("C", test.marker("3").position), c.moduleName("M", test.marker("4").position), c.interfaceName("I", test.marker("5").position), c.interfaceName("I", test.marker("6").position), c.className("C", test.marker("7").position), c.className("C", test.marker("8").position)); const c2 = classification("2020"); verify.semanticClassificationsAre("2020", c2.semanticToken("variable", "M"), c2.semanticToken("interface.declaration", "I"), c2.semanticToken("interface.declaration", "I"), c2.semanticToken("class.declaration", "C"), c2.semanticToken("variable.declaration", "M"), c2.semanticToken("variable", "M"), c2.semanticToken("interface", "I"), c2.semanticToken("interface", "I"), c2.semanticToken("class", "C"), c2.semanticToken("class.declaration", "I"), c2.semanticToken("variable", "M"), c2.semanticToken("class", "C"), );
{ "end_byte": 1374, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/semanticClassificationWithUnionTypes.ts" }
TypeScript/tests/cases/fourslash/completionListInArrowFunctionInUnclosedCallSite01.ts_0_354
/// <reference path='fourslash.ts' /> ////declare function foo(...params: any[]): any; ////function getAllFiles(rootFileNames: string[]) { //// var processedFiles = rootFileNames.map(fileName => foo(/*1*/ verify.completions({ marker: "1", includes: ["fileName", "rootFileNames", "getAllFiles", "foo"], isNewIdentifierLocation: true, });
{ "end_byte": 354, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInArrowFunctionInUnclosedCallSite01.ts" }
TypeScript/tests/cases/fourslash/completionInUncheckedJSFile.ts_3_554
/ <reference path="fourslash.ts" /> // @allowJs: true // @checkJs: false // @Filename: index.js ////function hello() { //// ////} //// ////const goodbye = 5; //// ////console./*0*/ verify.completions({ marker: "0", includes: [ { name: "hello", sortText: completion.SortText.JavascriptIdentifiers, isFromUncheckedFile: true }, { name: "goodbye", sortText: completion.SortText.JavascriptIdentifiers, isFromUncheckedFile: true } ] });
{ "end_byte": 554, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionInUncheckedJSFile.ts" }
TypeScript/tests/cases/fourslash/moveToFile_unresolvedImport.ts_0_362
/// <reference path='fourslash.ts' /> // @Filename: /bar.ts ////const a = 1; // @Filename: /a.ts ////import { a } from 'doesnt-exist'; ////[|a();|] verify.moveToFile({ newFileContents: { "/a.ts": ``, "/bar.ts": `import { a } from 'doesnt-exist'; const a = 1; a(); `, }, interactiveRefactorArguments: { targetFile: "/bar.ts" } });
{ "end_byte": 362, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_unresolvedImport.ts" }
TypeScript/tests/cases/fourslash/jsDocFunctionSignatures7.ts_0_320
///<reference path="fourslash.ts" /> // @allowJs: true // @Filename: Foo.js /////** //// * @param {string} p0 //// * @param {string} [p1] //// */ ////function Test(p0, p1) { //// this.P0 = p0; //// this.P1 = p1; ////} //// //// ////var /**/test = new Test(""); goTo.marker(); verify.quickInfoIs('var test: Test');
{ "end_byte": 320, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocFunctionSignatures7.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType19.ts_0_403
/// <reference path='fourslash.ts' /> //// type A<B, C, D = B> = /*a*/Partial<C | string | D>/*b*/ & D | C; goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to type alias", actionDescription: "Extract to type alias", newContent: `type /*RENAME*/NewType<C, D> = Partial<C | string | D>; type A<B, C, D = B> = NewType<C, D> & D | C;`, });
{ "end_byte": 403, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType19.ts" }
TypeScript/tests/cases/fourslash/formattingVoid.ts_0_865
///<reference path="fourslash.ts"/> /////*1*/ var x: () => void ; /////*2*/ var y: void ; /////*3*/ function test(a:void,b:string){} /////*4*/ var a, b, c, d; /////*5*/ void a ; /////*6*/ void (0); /////*7*/ b=void(c=1,d=2); format.document(); // formatting on function return type => void goTo.marker("1"); verify.currentLineContentIs('var x: () => void;'); // formatting on variable type goTo.marker("2"); verify.currentLineContentIs('var y: void;'); // formatting on function with void argument type goTo.marker("3"); verify.currentLineContentIs('function test(a: void, b: string) { }'); // formatting on void operator goTo.marker("5"); verify.currentLineContentIs('void a;'); goTo.marker("6"); verify.currentLineContentIs('void (0);'); goTo.marker("7"); verify.currentLineContentIs('b = void (c = 1, d = 2);');
{ "end_byte": 865, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingVoid.ts" }
TypeScript/tests/cases/fourslash/organizeImports6.ts_0_673
/// <reference path="fourslash.ts" /> // Regression test for GH#43107 //// import * as something from "path"; /* small comment */ // single line one. //// /* some comment here //// * and there //// */ //// import * as somethingElse from "anotherpath"; //// import * as anotherThing from "someopath"; /* small comment */ // single line one. //// /* some comment here //// * and there //// */ //// import * as anotherThingElse from "someotherpath"; //// //// anotherThing; verify.organizeImports( `/* some comment here * and there */ import * as anotherThing from "someopath"; /* small comment */ // single line one. /* some comment here * and there */ anotherThing;`);
{ "end_byte": 673, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImports6.ts" }
TypeScript/tests/cases/fourslash/jsxBraceCompletionPosition.ts_3_1152
/ <reference path="fourslash.ts" /> //@Filename: file.tsx //// declare var React: any; //// //// var x = <div a="/*2*/" b={/*3*/}> //// /*1*/ //// </div>; //// var y = <div>/*4*/</div> //// var z = <div> //// hello /*5*/ //// </div> //// var z2 = <div> { /*6*/ //// </div> //// var z3 = <div> //// { //// /*7*/ //// } //// </div> goTo.marker('1'); verify.not.isValidBraceCompletionAtPosition('('); verify.isValidBraceCompletionAtPosition('{'); goTo.marker('2'); verify.not.isValidBraceCompletionAtPosition('('); verify.not.isValidBraceCompletionAtPosition('{'); goTo.marker('3'); verify.not.isValidBraceCompletionAtPosition('('); verify.isValidBraceCompletionAtPosition('{'); goTo.marker('4'); verify.not.isValidBraceCompletionAtPosition('('); verify.isValidBraceCompletionAtPosition('{'); goTo.marker('5'); verify.not.isValidBraceCompletionAtPosition('('); verify.isValidBraceCompletionAtPosition('{'); goTo.marker('6'); verify.not.isValidBraceCompletionAtPosition('('); verify.isValidBraceCompletionAtPosition('{'); goTo.marker('7'); verify.not.isValidBraceCompletionAtPosition('('); verify.isValidBraceCompletionAtPosition('{');
{ "end_byte": 1152, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsxBraceCompletionPosition.ts" }
TypeScript/tests/cases/fourslash/quickInfoSignatureOptionalParameterFromUnion1.ts_0_341
/// <reference path='fourslash.ts'/> // https://github.com/microsoft/TypeScript/issues/55574 //// declare const optionals: //// | ((a?: { a: true }) => unknown) //// | ((b?: { b: true }) => unknown); //// //// /**/optionals(); verify.quickInfoAt( "", `const optionals: (arg0?: { a: true; } & { b: true; }) => unknown`, );
{ "end_byte": 341, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoSignatureOptionalParameterFromUnion1.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports43-expando-functions-2.ts_1_441
/// <reference path='fourslash.ts'/> // @isolatedDeclarations: true // @declaration: true // @lib: es2019 // @Filename: /code.ts ////const foo = () => {} ////foo/*a*/["a"] = "A"; ////foo["b"] = "C" verify.codeFix({ description: "Add annotation of type '{ (): void; a: string; b: string; }'", index: 1, newFileContent: `const foo: { (): void; a: string; b: string; } = () => {} foo["a"] = "A"; foo["b"] = "C"` });
{ "end_byte": 441, "start_byte": 1, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports43-expando-functions-2.ts" }
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_thisParam.ts_0_508
/// <reference path='fourslash.ts' /> ////function foo(this: void, /*a*/t: string, s: string/*b*/) { //// return s; ////} ////foo("a", "b"); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert parameters to destructured object", actionName: "Convert parameters to destructured object", actionDescription: "Convert parameters to destructured object", newContent: `function foo(this: void, { t, s }: { t: string; s: string; }) { return s; } foo({ t: "a", s: "b" });` });
{ "end_byte": 508, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_thisParam.ts" }
TypeScript/tests/cases/fourslash/jsxElementExtendsNoCrash2.ts_0_119
/// <reference path="fourslash.ts" /> // @filename: index.tsx //// <T extends/> verify.getSuggestionDiagnostics([]);
{ "end_byte": 119, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsxElementExtendsNoCrash2.ts" }
TypeScript/tests/cases/fourslash/getJavaScriptCompletions13.ts_0_857
/// <reference path="fourslash.ts" /> // @allowNonTsExtensions: true // @Filename: file1.js ////var file1Identifier = 1; ////interface Foo { FooProp: number }; // @Filename: file2.js ////var file2Identifier1 = 2; ////var file2Identifier2 = 2; /////*1*/ ////file2Identifier2./*2*/ verify.completions( { marker: "1", includes: [ "file2Identifier1", "file2Identifier2", { name: "file1Identifier", sortText: completion.SortText.GlobalsOrKeywords } ], excludes: "FooProp" }, { marker: "2", includes: [ { name: "file2Identifier1", sortText: completion.SortText.JavascriptIdentifiers }, { name: "file2Identifier2", sortText: completion.SortText.JavascriptIdentifiers } ], excludes: ["file1Identifier", "FooProp"] }, );
{ "end_byte": 857, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptCompletions13.ts" }
TypeScript/tests/cases/fourslash/completionListOnFunctionCallWithOptionalArgument.ts_0_180
/// <reference path="fourslash.ts" /> //// declare function Foo(arg1?: Function): { q: number }; //// Foo(function () { } )./**/; verify.completions({ marker: "", exact: "q" });
{ "end_byte": 180, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListOnFunctionCallWithOptionalArgument.ts" }
TypeScript/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts_0_497
/// <reference path='fourslash.ts' /> //// function f(templateStrings, x, y, z) { return 10; } //// function g(templateStrings, x, y, z) { return ""; } //// //// f `a ${ g `/*1*/alpha/*2*/ ${/*3*/ 12/*4*/3 /*5*/} beta /*6*/${ /*7*/456 /*8*/} gamma/*9*/` } b ${ g `/*10*/txt/*11*/` } c ${ g `/*12*/aleph /*13*/$/*14*/{ 12/*15*/3 } beit/*16*/` } d`; verify.signatureHelp({ marker: test.markers(), text: "g(templateStrings: any, x: any, y: any, z: any): string", parameterCount: 4, });
{ "end_byte": 497, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts" }
TypeScript/tests/cases/fourslash/completionListInNestedNamespaceName.ts_0_556
/// <reference path='fourslash.ts'/> ////namespace A { //// export namespace B { //// export interface C {} //// } ////} //// ////interface T1 extends A/*1*/ //// ////declare const t2: A/*2*/ //// ////const t3 = (x: A/*3*/) => {} //// ////interface T4 { //// c: A/*4*/ ////} for (const marker of test.markers()) { goTo.marker(marker); edit.insert("."); verify.completions({ exact: ["B"] }); edit.insert("B."); verify.completions({ exact: ["C"] }); edit.insert("C."); verify.completions({ exact: undefined }); }
{ "end_byte": 556, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInNestedNamespaceName.ts" }
TypeScript/tests/cases/fourslash/gotoDefinitionPropertyAccessExpressionHeritageClause.ts_0_244
/// <reference path='fourslash.ts' /> //// class B {} //// function foo() { //// return {/*refB*/B: B}; //// } //// class C extends (foo()).[|/*B*/B|] {} //// class C1 extends foo().[|/*B1*/B|] {} verify.baselineGoToDefinition("B", "B1");
{ "end_byte": 244, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/gotoDefinitionPropertyAccessExpressionHeritageClause.ts" }
TypeScript/tests/cases/fourslash/refactorExtractType48.ts_0_484
/// <reference path='fourslash.ts' /> //// type Crazy<T> = /*a*/T extends [infer P, ((infer R) extends string ? string : never)] ? P & R : string/*b*/; goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to type alias", actionDescription: "Extract to type alias", newContent: `type /*RENAME*/NewType<T> = T extends [infer P, ((infer R) extends string ? string : never)] ? P & R : string; type Crazy<T> = NewType<T>;`, });
{ "end_byte": 484, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractType48.ts" }
TypeScript/tests/cases/fourslash/formatEmptyParamList.ts_0_168
/// <reference path='fourslash.ts' /> ////function f( f: function){/*1*/ goTo.marker("1"); edit.insert("}"); verify.currentLineContentIs("function f(f: function) { }");
{ "end_byte": 168, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatEmptyParamList.ts" }
TypeScript/tests/cases/fourslash/getOccurrencesIsDefinitionOfComputedProperty.ts_0_183
/// <reference path='fourslash.ts' /> ////let o = { /*1*/["/*2*/foo"]: 12 }; ////let y = o./*3*/foo; ////let z = o['/*4*/foo']; verify.baselineFindAllReferences('1', '2', '3', '4');
{ "end_byte": 183, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOccurrencesIsDefinitionOfComputedProperty.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportExportEqualsESNextInteropOff.ts_0_285
/// <reference path="fourslash.ts" /> // @Module: esnext // @Filename: /foo.d.ts ////declare module "foo" { //// const foo: number; //// export = foo; ////} // @Filename: /index.ts ////foo goTo.file('/index.ts'); verify.importFixAtPosition([`import * as foo from "foo"; foo`]);
{ "end_byte": 285, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportExportEqualsESNextInteropOff.ts" }
TypeScript/tests/cases/fourslash/findAllRefsExportAsNamespace.ts_0_354
/// <reference path='fourslash.ts' /> // `export as namespace` results in global search. // @Filename: /node_modules/a/index.d.ts ////export function /*0*/f(): void; ////export as namespace A; // @Filename: /b.ts ////import { /*1*/f } from "a"; // @Filename: /c.ts ////A./*2*/f(); verify.noErrors(); verify.baselineFindAllReferences('0', '1', '2')
{ "end_byte": 354, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsExportAsNamespace.ts" }
TypeScript/tests/cases/fourslash/autoImportSortCaseSensitivity1.ts_0_1253
/// <reference path="fourslash.ts" /> // @Filename: /exports1.ts //// export const a = 0; //// export const A = 1; //// export const b = 2; //// export const B = 3; //// export const c = 4; //// export const C = 5; // @Filename: /exports2.ts //// export const d = 0; //// export const D = 1; //// export const e = 2; //// export const E = 3; // Ambiguous in whole file: use user preference, default to case-sensitive // @Filename: /index0.ts //// import { A, B, C } from "./exports1"; //// a/*0*/ // Ambiguous in target import: use user preference, look at other imports in file // @Filename: /index1.ts //// import { A, a, B, b } from "./exports1"; //// import { E } from "./exports2"; //// d/*1*/ goTo.marker("0"); verify.importFixAtPosition([`import { a, A, B, C } from "./exports1";\na`]); verify.importFixAtPosition([`import { a, A, B, C } from "./exports1";\na`], /*errorCode*/ undefined, { organizeImportsIgnoreCase: true }); goTo.marker("1"); verify.importFixAtPosition([ `import { A, a, B, b } from "./exports1"; import { d, E } from "./exports2"; d`]); verify.importFixAtPosition([ `import { A, a, B, b } from "./exports1"; import { E, d } from "./exports2"; d`], /*errorCode*/ undefined, { organizeImportsIgnoreCase: false });
{ "end_byte": 1253, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportSortCaseSensitivity1.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToEsModule_exportEqualsClass.ts_0_348
/// <reference path='fourslash.ts' /> // @allowJs: true // @target: esnext // @Filename: /a.js ////const b = require("./b"); ////module.exports = class C { //// m() { //// b.x; //// } ////}; verify.codeFix({ description: "Convert to ES module", newFileContent: `import { x } from "./b"; export default class C { m() { x; } };`, });
{ "end_byte": 348, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToEsModule_exportEqualsClass.ts" }
TypeScript/tests/cases/fourslash/quickInfoLink4.ts_0_205
///<reference path="fourslash.ts" /> ////type A = 1 | 2; //// ////switch (0 as A) { //// /** {@link /**/A} */ //// case 1: //// case 2: //// break; ////} verify.noErrors() verify.baselineQuickInfo();
{ "end_byte": 205, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoLink4.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionConstructorOverloads.ts_0_834
/// <reference path='fourslash.ts' /> ////class ConstructorOverload { //// [|/*constructorOverload1*/constructor|](); //// /*constructorOverload2*/constructor(foo: string); //// /*constructorDefinition*/constructor(foo: any) { } ////} //// ////var constructorOverload = new [|/*constructorOverloadReference1*/ConstructorOverload|](); ////var constructorOverload = new [|/*constructorOverloadReference2*/ConstructorOverload|]("foo"); //// ////class Extended extends ConstructorOverload { //// readonly name = "extended"; ////} ////var extended1 = new [|/*extendedRef1*/Extended|](); ////var extended2 = new [|/*extendedRef2*/Extended|]("foo"); verify.baselineGoToDefinition( "constructorOverloadReference1", "constructorOverloadReference2", "constructorOverload1", "extendedRef1", "extendedRef2", );
{ "end_byte": 834, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionConstructorOverloads.ts" }
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsTypeParameterInFunctionLikeInTypeAlias.ts_3_241
/ <reference path='fourslash.ts'/> //// type MixinCtor<A> = new () => /*0*/A & { constructor: MixinCtor</*1*/A> }; //// type MixinCtor<A> = new () => A & { constructor: { constructor: MixinCtor</*2*/A> } }; verify.baselineQuickInfo();
{ "end_byte": 241, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsTypeParameterInFunctionLikeInTypeAlias.ts" }
TypeScript/tests/cases/fourslash/importNameCodeFixOptionalImport1.ts_0_325
/// <reference path="fourslash.ts" /> // @Filename: a/f1.ts //// [|foo/*0*/();|] // @Filename: a/node_modules/bar/index.ts //// export function foo() {}; // @Filename: a/foo.ts //// export { foo } from "bar"; verify.importFixAtPosition([ `import { foo } from "bar"; foo();`, `import { foo } from "./foo"; foo();`, ]);
{ "end_byte": 325, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixOptionalImport1.ts" }
TypeScript/tests/cases/fourslash/switchCompletions.ts_0_1058
/// <reference path="fourslash.ts" /> //// enum E { A, B } //// declare const e: E; //// switch (e) { //// case E.A: //// return 0; //// case E./*1*/ //// } //// declare const f: 1 | 2 | 3; //// switch (f) { //// case 1: //// return 1; //// case /*2*/ //// } //// declare const f2: 'foo' | 'bar' | 'baz'; //// switch (f2) { //// case 'bar': //// return 1; //// case '/*3*/' //// } //// //// // repro from #52874 //// declare let x: "foo" | "bar"; //// switch (x) { //// case ('/*4*/') //// } verify.completions( { marker: "1", isNewIdentifierLocation: false, includes: ["B"], excludes: "A", }, { marker: "2", isNewIdentifierLocation: false, excludes: "1", includes: ["2", "3"], }, { marker: "3", isNewIdentifierLocation: false, includes: ["foo", "baz"], excludes: "bar", }, { marker: "4", isNewIdentifierLocation: false, includes: ["foo", "bar"], } );
{ "end_byte": 1058, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/switchCompletions.ts" }
TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_recursiveFunction.ts_0_581
/// <reference path='fourslash.ts' /> ////const f = function foo(/*a*/a: number, b: number/*b*/) { //// foo(1, 2); ////} ////function foo(a: number, b: number) { } ////foo(3, 4); goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Convert parameters to destructured object", actionName: "Convert parameters to destructured object", actionDescription: "Convert parameters to destructured object", newContent: `const f = function foo({ a, b }: { a: number; b: number; }) { foo({ a: 1, b: 2 }); } function foo(a: number, b: number) { } foo(3, 4);` });
{ "end_byte": 581, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_recursiveFunction.ts" }
TypeScript/tests/cases/fourslash/inlayHintsNoVariableTypeHints.ts_0_144
/// <reference path="fourslash.ts" /> //// const a = 123; verify.baselineInlayHints(undefined, { includeInlayVariableTypeHints: false });
{ "end_byte": 144, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/inlayHintsNoVariableTypeHints.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionPrivateName.ts_0_511
/// <reference path='fourslash.ts' /> //// class A { //// [|/*pnMethodDecl*/#method|]() { } //// [|/*pnFieldDecl*/#foo|] = 3; //// get [|/*pnPropGetDecl*/#prop|]() { return ""; } //// set [|/*pnPropSetDecl*/#prop|](value: string) { } //// constructor() { //// this.[|/*pnFieldUse*/#foo|] //// this.[|/*pnMethodUse*/#method|] //// this.[|/*pnPropUse*/#prop|] //// } //// } verify.baselineGoToDefinition( "pnFieldUse", "pnMethodUse", "pnPropUse", );
{ "end_byte": 511, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionPrivateName.ts" }
TypeScript/tests/cases/fourslash/completionsOverridingMethod8.ts_0_1327
/// <reference path="fourslash.ts" /> // @newline: LF // @Filename: /types1.ts //// export interface I { foo: string } // @Filename: /types2.ts //// import { I } from "./types1"; //// export interface Base { method(p: I): void } // @Filename: /index.ts //// import { Base } from "./types2"; //// export class C implements Base { //// /**/ //// } goTo.marker(""); verify.completions({ marker: "", isNewIdentifierLocation: true, preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, includes: [{ name: "method", sortText: completion.SortText.LocationPriority, insertText: "method(p: I): void {\n}", hasAction: true, source: completion.CompletionSource.ClassMemberSnippet, filterText: "method", }], }); verify.applyCodeActionFromCompletion("", { preferences: { includeCompletionsWithInsertText: true, includeCompletionsWithSnippetText: false, includeCompletionsWithClassMemberSnippets: true, }, name: "method", source: completion.CompletionSource.ClassMemberSnippet, description: "Includes imports of types referenced by 'method'", newFileContent: `import { I } from "./types1"; import { Base } from "./types2"; export class C implements Base { }` });
{ "end_byte": 1327, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOverridingMethod8.ts" }
TypeScript/tests/cases/fourslash/multilineCommentBeforeOpenBrace.ts_0_403
/// <reference path='fourslash.ts' /> ////function test() /*1*//* %^ */ ////{ //// if (true) /*2*//* %^ */ //// { //// } ////} ////function a() { //// /* %^ */ }/*3*/ format.document(); goTo.marker('1'); verify.currentLineContentIs('function test() /* %^ */ {'); goTo.marker('2'); verify.currentLineContentIs(' if (true) /* %^ */ {'); goTo.marker('3'); verify.currentLineContentIs('}');
{ "end_byte": 403, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/multilineCommentBeforeOpenBrace.ts" }
TypeScript/tests/cases/fourslash/quickInfoInvalidLocations.ts_0_995
/// <reference path='fourslash.ts' /> ////inter/*invalid1*/face IFoo { //// new(): IFoo; //// [indexer: string]: number; //// method(value: number): string; //// property: string; /////*invalid2*/} //// ////class bar imple/*invalid4*/ments IFoo { //// constructor( /*invalid5*/ ) { //// //// } //// //// pu/*invalid6*/blic method(value: string): string { //// retu/*invalid7*/rn null; //// } //// //// public property: string /*invalid8*/= "string"; //// //// public ge/*invalid9*/t value() { //// return 0; //// } ////} //// //// ////mod/*invalid10*/ule m1 { //// va/*invalid11*/r varibale = 0; //// //// function foo(arg1: number) { //// ret/*invalid13*/urn string; //// } //// //// class foo { //// //// } //// //// var object = { //// value1: "string", //// value2: { //// value21: number //// /*invalid14*/} //// }; ////} goTo.eachMarker(() => verify.not.quickInfoExists());
{ "end_byte": 995, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoInvalidLocations.ts" }
TypeScript/tests/cases/fourslash/tsxCompletion9.ts_0_672
/// <reference path='fourslash.ts' /> //@Filename: file.tsx //// declare module JSX { //// interface Element { } //// interface IntrinsicElements { //// div: { ONE: string; TWO: number; } //// } //// } //// var x1 = <div> /*1*/ hello /*2*/ world /*3*/</div>; //// var x2 = <div> /*4*/ <div></div> /*5*/ world /*6*/</div>; //// var x3 = <div>/*7*/<div/>/*8*/world/*9*/</div>; //// var x4 = <div>/*10*/</div>; //// <div/> //// /*end*/ //// for (var i = 1; i <= 10; i++) { verify.completions({ marker: String(i), exact: undefined }); } verify.completions({ marker: "end", includes: { name: "null", sortText: completion.SortText.GlobalsOrKeywords } });
{ "end_byte": 672, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/tsxCompletion9.ts" }
TypeScript/tests/cases/fourslash/goToImplementationLocal_08.ts_0_233
/// <reference path='fourslash.ts'/> // Should be able to go to ambient function declarations //// declare function [|someFunction|](): () => void; //// someFun/*reference*/ction(); verify.baselineGoToImplementation("reference");
{ "end_byte": 233, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToImplementationLocal_08.ts" }
TypeScript/tests/cases/fourslash/codeFixCalledES2015Import4.ts_0_426
/// <reference path='fourslash.ts' /> // @esModuleInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} ////export = foo; // @Filename: index.ts ////import * as foo from "./foo"; ////[|foo|](); goTo.file(1); verify.codeFix({ description: `Replace import with 'import foo = require("./foo");'.`, newFileContent: `import foo = require("./foo"); foo();`, index: 1, });
{ "end_byte": 426, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCalledES2015Import4.ts" }
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_BinaryWithCallExpression.ts_0_398
/// <reference path='fourslash.ts' /> ////let a = { b: { c: () => { } } }; /////*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: { c: () => { } } }; a?.b?.c();` });
{ "end_byte": 398, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_BinaryWithCallExpression.ts" }
TypeScript/tests/cases/fourslash/completionListClassPrivateFields_JS.ts_0_462
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: a.js ////class A { //// #private = 1; ////} //// ////class B extends A { //// /**/ ////} verify.completions({ marker: "", exact: [ ...completion.classElementInJsKeywords, { name: "A", sortText: completion.SortText.JavascriptIdentifiers }, { name: "B", sortText: completion.SortText.JavascriptIdentifiers }, ], isNewIdentifierLocation: true });
{ "end_byte": 462, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListClassPrivateFields_JS.ts" }
TypeScript/tests/cases/fourslash/getEmitOutputWithEarlySemanticErrors.ts_0_293
/// <reference path="fourslash.ts" /> // @BaselineFile: getEmitOutputWithEarlySyntacticErrors.baseline // @Filename: inputFile1.ts // @emitThisFile: true //// // File contains early errors. All outputs should be skipped. //// const uninitialized_const_error; verify.baselineGetEmitOutput();
{ "end_byte": 293, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEmitOutputWithEarlySemanticErrors.ts" }
TypeScript/tests/cases/fourslash/extract-method24.ts_0_522
/// <reference path='fourslash.ts' /> //// function M() { //// let a = [1,2,3]; //// let x = 0; //// console.log(/*a*/a[x]/*b*/); //// } goTo.select('a', 'b') edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "function_scope_1", actionDescription: "Extract to function in global scope", newContent: `function M() { let a = [1,2,3]; let x = 0; console.log(/*RENAME*/newFunction(a, x)); } function newFunction(a: number[], x: number): any { return a[x]; } ` });
{ "end_byte": 522, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method24.ts" }
TypeScript/tests/cases/fourslash/codeFixAddMissingParam1.ts_0_254
/// <reference path="fourslash.ts" /> ////[|function f() {}|] //// ////const a = 1; ////f(a); verify.codeFix({ description: [ts.Diagnostics.Add_missing_parameter_to_0.message, "f"], index: 0, newRangeContent: "function f(a: number) {}" });
{ "end_byte": 254, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingParam1.ts" }
TypeScript/tests/cases/fourslash/jsDocDontBreakWithNamespaces.ts_0_501
///<reference path="fourslash.ts" /> // @allowJs: true // @Filename: jsDocDontBreakWithNamespaces.js /////** //// * @returns {module:@nodefuel/web~Webserver~wsServer#hello} Websocket server object //// */ ////function foo() { } ////foo(''/*foo*/); //// /////** //// * @type {module:xxxxx} */ //// */ ////function bar() { } ////bar(''/*bar*/); //// /////** @type {function(module:xxxx, module:xxxx): module:xxxxx} */ ////function zee() { } ////zee(''/*zee*/); // #31298 verify.baselineSignatureHelp()
{ "end_byte": 501, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocDontBreakWithNamespaces.ts" }
TypeScript/tests/cases/fourslash/quickInfoNestedExportEqualExportDefault.ts_0_154
/// <reference path="fourslash.ts" /> //// export = (state, messages) => { //// export/*1*/ default/*2*/ { //// } //// } verify.baselineQuickInfo()
{ "end_byte": 154, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoNestedExportEqualExportDefault.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_deleteWrite2.ts_0_300
/// <reference path='fourslash.ts' /> // @noLib: true // @noUnusedLocals: true ////export class C { //// private p: number; //// //// m() { this.p = 0; } ////} verify.codeFix({ description: "Remove unused declaration for: 'p'", newFileContent: `export class C { m() { } }`, });
{ "end_byte": 300, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_deleteWrite2.ts" }
TypeScript/tests/cases/fourslash/renameForDefaultExport06.ts_0_377
/// <reference path='fourslash.ts'/> // @Filename: foo.ts ////export default class DefaultExportedClass { ////} /////* //// * Commenting DefaultExportedClass //// */ //// ////var x: DefaultExportedClass; //// ////var y = new /**/[|DefaultExportedClass|]; goTo.marker(); verify.renameInfoSucceeded("DefaultExportedClass", '"/tests/cases/fourslash/foo".DefaultExportedClass');
{ "end_byte": 377, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameForDefaultExport06.ts" }
TypeScript/tests/cases/fourslash/breakpointValidationExportAssignment.ts_0_233
/// <reference path='fourslash.ts' /> // @BaselineFile: bpSpan_exportAssignment.baseline // @Filename: bpSpan_exportAssignment.ts ////class a { //// public c; ////} ////export = a; verify.baselineCurrentFileBreakpointLocations();
{ "end_byte": 233, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationExportAssignment.ts" }
TypeScript/tests/cases/fourslash/referencesForGlobals5.ts_0_336
/// <reference path='fourslash.ts'/> // Global module reference. // @Filename: referencesForGlobals_1.ts ////module globalModule { //// export var x; ////} //// /////*1*/import /*2*/globalAlias = globalModule; // @Filename: referencesForGlobals_2.ts ////var m = /*3*/globalAlias; verify.baselineFindAllReferences('1', '2', '3');
{ "end_byte": 336, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForGlobals5.ts" }
TypeScript/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaces.ts_0_191
/// <reference path='fourslash.ts' /> ////var aa = 1; ////interface /*interfaceName1*/ ////interface a/*interfaceName2*/ verify.completions({ marker: test.markers(), exact: undefined });
{ "end_byte": 191, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAtIdentifierDefinitionLocations_interfaces.ts" }
TypeScript/tests/cases/fourslash/findAllRefsForModule.ts_0_634
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: /a.ts ////export const x = 0; // @Filename: /b.ts ////[|import { x } from "/*0*/[|{| "contextRangeIndex": 0 |}./a|]";|] // @Filename: /c/sub.js ////[|const a = require("/*1*/[|{| "contextRangeIndex": 2 |}../a|]");|] // @Filename: /d.ts //// /// <reference path="/*2*/[|./a.ts|]" /> const [r0Def, r0, r1Def, r1, r2] = test.ranges(); const ranges = [r0, r1, r2]; // Testing that it works with documentHighlights too verify.baselineFindAllReferences('0', '1', '2'); verify.baselineDocumentHighlights(ranges, { filesToSearch: ["/b.ts", "/c/sub.js", "/d.ts"] });
{ "end_byte": 634, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsForModule.ts" }
TypeScript/tests/cases/fourslash/codeFixInferFromUsagePartialParameterListJS.ts_0_479
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @noImplicitAny: true // @strictNullChecks: true // @Filename: important.js /////** //// * @param {*} y //// */ ////function f(x, y, z) { //// return x ////} ////f(1, 2, 3) verify.codeFix({ description: "Infer parameter types from usage", index: 0, newFileContent: `/** * @param {*} y * @param {number} x * @param {number} z */ function f(x, y, z) { return x } f(1, 2, 3)`, });
{ "end_byte": 479, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsagePartialParameterListJS.ts" }
TypeScript/tests/cases/fourslash/refactorExtractTypeRemoveGrammarError2.ts_0_383
/// <reference path='fourslash.ts' /> // @Filename: a.ts ////type Foo<T extends /*a*/{ x: string = a }/*b*/> = T goTo.select("a", "b"); edit.applyRefactor({ refactorName: "Extract type", actionName: "Extract to type alias", actionDescription: "Extract to type alias", newContent: `type /*RENAME*/NewType = { x: string; }; type Foo<T extends NewType> = T`, });
{ "end_byte": 383, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorExtractTypeRemoveGrammarError2.ts" }
TypeScript/tests/cases/fourslash/codeFixUndeclaredClassInstance.ts_0_408
/// <reference path='fourslash.ts' /> //// class A { //// a: number; //// b: string; //// constructor(public x: any) {} //// } //// [|class B { //// constructor() { //// this.x = new A(3); //// } //// }|] verify.rangeAfterCodeFix(` class B { x: A; constructor() { this.x = new A(3); } } `, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
{ "end_byte": 408, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUndeclaredClassInstance.ts" }
TypeScript/tests/cases/fourslash/jsdocDeprecated_suggestion11.ts_0_546
///<reference path="fourslash.ts" /> // @filename: /foo.ts /////** @deprecated */ ////export function foo() {} // @filename: /test.ts ////import { [|foo|] } from "./foo"; ////[|foo|]; goTo.file("/test.ts"); const [r0, r1] = test.ranges(); verify.getSuggestionDiagnostics([ { "code": 6385, "message": "'foo' is deprecated.", "reportsDeprecated": true, "range": r0 }, { "code": 6385, "message": "'foo' is deprecated.", "reportsDeprecated": true, "range": r1 } ]);
{ "end_byte": 546, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsdocDeprecated_suggestion11.ts" }
TypeScript/tests/cases/fourslash/autoImportPackageJsonImportsLength2.ts_0_351
/// <reference path="fourslash.ts" /> // @module: nodenext // @Filename: /package.json //// { //// "imports": { //// "#*": "./src/*.ts" //// } //// } // @Filename: /src/a/b/c/something.ts //// export function something(name: string): any; // @Filename: /a.ts //// something/**/ verify.importFixModuleSpecifiers("", ["#a/b/c/something"]);
{ "end_byte": 351, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/autoImportPackageJsonImportsLength2.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts_0_392
/// <reference path='fourslash.ts' /> ////function /*defFNumber*/f(strs: TemplateStringsArray, x: number): void; ////function /*defFBool*/f(strs: TemplateStringsArray, x: boolean): void; ////function f(strs: TemplateStringsArray, x: number | boolean) {} //// ////[|/*useFNumber*/f|]`${0}`; ////[|/*useFBool*/f|]`${false}`; verify.baselineGoToDefinition( "useFNumber", "useFBool" );
{ "end_byte": 392, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts" }
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_jsdocTypeParameter.ts_0_299
/// <reference path='fourslash.ts' /> // @allowJs: true // @Filename: /a.js /////** //// * @type {<T>() => void} //// */ ////export const x = 0; verify.codeFix({ description: "Remove type parameters", index: 0, newFileContent: `/** * @type {() => void} */ export const x = 0;`, });
{ "end_byte": 299, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_jsdocTypeParameter.ts" }
TypeScript/tests/cases/fourslash/findAllRefsConstructorFunctions.ts_0_316
/// <reference path="fourslash.ts" /> // @allowJs: true // @Filename: /a.js ////function f() { //// /*1*/this./*2*/x = 0; ////} ////f.prototype.setX = function() { //// /*3*/this./*4*/x = 1; ////} ////f.prototype.useX = function() { this./*5*/x; } verify.baselineFindAllReferences('1', '2', '3', '4', '5');
{ "end_byte": 316, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefsConstructorFunctions.ts" }
TypeScript/tests/cases/fourslash/codeFixConvertToTypeOnlyExport2.ts_0_514
/// <reference path="fourslash.ts" /> // @isolatedModules: true // @Filename: /a.ts ////export type A = {}; ////export const B = {}; ////export type C = {}; // @Filename: /b.ts ////export { A, B, C } from './a'; goTo.file("/b.ts"); verify.codeFix({ index: 0, description: ts.Diagnostics.Convert_to_type_only_export.message, errorCode: ts.Diagnostics.Re_exporting_a_type_when_0_is_enabled_requires_using_export_type.code, newFileContent: `export { B } from './a'; export type { A, C } from './a'; ` });
{ "end_byte": 514, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConvertToTypeOnlyExport2.ts" }
TypeScript/tests/cases/fourslash/codeFixTopLevelAwait_target_existingCompilerOptionsInTsConfig.ts_0_507
/// <reference path="fourslash.ts" /> // @filename: /dir/a.ts ////declare const p: Promise<number>; ////await p; ////export {}; // @filename: /dir/tsconfig.json ////{ //// "compilerOptions": { //// "target": "es2015" //// } ////} verify.codeFix({ description: [ts.Diagnostics.Set_the_target_option_in_your_configuration_file_to_0.message, "es2017"], index: 1, newFileContent: { "/dir/tsconfig.json": `{ "compilerOptions": { "target": "es2017" } }` } });
{ "end_byte": 507, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixTopLevelAwait_target_existingCompilerOptionsInTsConfig.ts" }
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString6.ts_0_430
/// <reference path='fourslash.ts' /> ////const foo = 1; ////const bar = /*start*/"a" + `${foo}` + "b"/*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}b`;" ].join("\n") });
{ "end_byte": 430, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString6.ts" }
TypeScript/tests/cases/fourslash/unusedConstantInFunction1.ts_0_181
/// <reference path='fourslash.ts' /> // @noUnusedLocals: true //// [| function f1 () { //// const x: string = "x"; //// } |] verify.rangeAfterCodeFix(`function f1 () { }`);
{ "end_byte": 181, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/unusedConstantInFunction1.ts" }
TypeScript/tests/cases/fourslash/completionsPaths_pathMapping_notInNestedDirectory.ts_0_367
/// <reference path="fourslash.ts" /> // @Filename: /user.ts ////import {} from "something//**/"; // @Filename: /tsconfig.json ////{ //// "compilerOptions": { //// "baseUrl": ".", //// "paths": { //// "mapping/*": ["whatever"], //// } //// } ////} verify.completions({ marker: "", exact: [], isNewIdentifierLocation: true });
{ "end_byte": 367, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsPaths_pathMapping_notInNestedDirectory.ts" }
TypeScript/tests/cases/fourslash/findAllRefs_importType_js.2.ts_0_348
/// <reference path='fourslash.ts' /> // @allowJs: true // @checkJs: true // @Filename: /a.js ////module.exports = class C {}; ////module.exports./**/D = class D {}; // @Filename: /b.js /////** @type {import("./a")} */ ////const x = 0; /////** @type {import("./a").D} */ ////const y = 0; verify.noErrors(); verify.baselineFindAllReferences("");
{ "end_byte": 348, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllRefs_importType_js.2.ts" }
TypeScript/tests/cases/fourslash/goToDefinitionDynamicImport2.ts_3_250
/ <reference path='fourslash.ts' /> // @Filename: foo.ts //// export function /*Destination*/bar() { return "bar"; } //// var x = import("./foo"); //// x.then(foo => { //// foo.[|b/*1*/ar|](); //// }) verify.baselineGoToDefinition("1");
{ "end_byte": 250, "start_byte": 3, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionDynamicImport2.ts" }
TypeScript/tests/cases/fourslash/extractFunctionContainingThis2.ts_0_678
/// <reference path='fourslash.ts' /> ////function test(this: { bar: string }, foo: string) { //// /*start*/console.log(this); //// console.log(foo); /*end*/ ////} goTo.select("start", "end"); verify.refactorAvailable("Extract Symbol", "function_scope_0"); goTo.select("start", "end"); edit.applyRefactor({ refactorName: "Extract Symbol", actionName: "function_scope_1", actionDescription: "Extract to function in global scope", newContent: `function test(this: { bar: string }, foo: string) { /*RENAME*/newFunction.call(this, foo); } function newFunction(this: { bar: string; }, foo: string) { console.log(this); console.log(foo); } ` });
{ "end_byte": 678, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extractFunctionContainingThis2.ts" }
TypeScript/tests/cases/fourslash/organizeImportsGroup_MultiNewlines.ts_0_307
/// <reference path="fourslash.ts" /> ////import c from "C"; //// //// ////import d from "D"; ////import a from "A"; ////import b from "B"; //// ////console.log(a, b, c, d) verify.organizeImports( `import c from "C"; import a from "A"; import b from "B"; import d from "D"; console.log(a, b, c, d)` );
{ "end_byte": 307, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImportsGroup_MultiNewlines.ts" }
TypeScript/tests/cases/fourslash/genericMethodParam.ts_0_399
/// <reference path='fourslash.ts' /> //// class C<T> { //// /*1*/ //// } //// /*2*/ verify.noErrors(); goTo.marker('1'); edit.insertLine("constructor(){}"); edit.insertLine("foo(a: T) {"); edit.insertLine(" return a;"); edit.insertLine("}"); verify.noErrors(); goTo.marker('2'); edit.insertLine("var x = new C<number>();"); edit.insertLine("var y: number = x.foo(5);"); verify.noErrors();
{ "end_byte": 399, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/genericMethodParam.ts" }
TypeScript/tests/cases/fourslash/codeFixMissingCallParentheses11.ts_0_1405
/// <reference path='fourslash.ts'/> // @strictNullChecks: true ////class Foo { //// #test = () => true; //// run() { //// if (this.#test) { //// console.log('test') //// } //// this.#test && console.log('test'); //// } ////} //// ////function foo() { //// function test() { return Math.random() > 0.5; } //// test ? console.log('test') : undefined; //// test && console.log('test'); ////} //// ////function foo() { //// const x = { //// foo: { //// bar() { return true; } //// } //// } //// x.foo.bar ? console.log('test') : undefined; //// if (x.foo.bar) {} //// x.foo.bar && console.log('test'); ////} verify.codeFixAll({ fixAllDescription: ts.Diagnostics.Add_all_missing_call_parentheses.message, fixId: "fixMissingCallParentheses", newFileContent: `class Foo { #test = () => true; run() { if (this.#test()) { console.log('test') } this.#test() && console.log('test'); } } function foo() { function test() { return Math.random() > 0.5; } test() ? console.log('test') : undefined; test() && console.log('test'); } function foo() { const x = { foo: { bar() { return true; } } } x.foo.bar() ? console.log('test') : undefined; if (x.foo.bar()) {} x.foo.bar() && console.log('test'); }`, });
{ "end_byte": 1405, "start_byte": 0, "url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingCallParentheses11.ts" }