_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
TypeScript/tests/cases/fourslash/isDefinitionShorthandProperty.ts_0_156 | /// <reference path='fourslash.ts'/>
////const /*1*/x = 1;
////const y: { /*2*/x: number } = { /*3*/x };
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 156,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/isDefinitionShorthandProperty.ts"
} |
TypeScript/tests/cases/fourslash/codeFixUnusedIdentifier_importSpecifier1.ts_0_332 | /// <reference path="fourslash.ts" />
// @noUnusedLocals: true
////[|import {
//// a, b, c, d,
//// e, f,
////} from "fs";|]
////
////a;
////b;
////c;
////e;
////f;
verify.codeFix({
index: 0,
description: "Remove unused declaration for: 'd'",
newRangeContent:
`import {
a, b, c,
e, f,
} from "fs";`
});
| {
"end_byte": 332,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixUnusedIdentifier_importSpecifier1.ts"
} |
TypeScript/tests/cases/fourslash/addMethodToInterface1.ts_0_312 | /// <reference path="fourslash.ts" />
//// interface Comparable<T> {
//// /*1*/}
//// interface Comparer {
//// }
//// var max2: Comparer = (x, y) => { return (x.compareTo(y) > 0) ? x : y };
//// var maxResult = max2(1);
edit.disableFormatting();
goTo.marker('1');
edit.insert(" compareTo(): number;\n");
| {
"end_byte": 312,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/addMethodToInterface1.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionInstanceof1.ts_0_173 | /// <reference path="fourslash.ts" />
//// class /*end*/ C {
//// }
//// declare var obj: any;
//// obj [|/*start*/instanceof|] C;
verify.baselineGoToDefinition("start");
| {
"end_byte": 173,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionInstanceof1.ts"
} |
TypeScript/tests/cases/fourslash/formattingOnDocumentReadyFunction.ts_0_430 | /// <reference path='fourslash.ts' />
/////*1*/$ ( document ) . ready ( function ( ) {
/////*2*/ alert ( 'i am ready' ) ;
/////*3*/ } );
format.document();
goTo.marker("1");
verify.currentLineContentIs("$(document).ready(function() {");
goTo.marker("2");
verify.currentLineContentIs(" alert('i am ready');");
goTo.marker("3");
verify.currentLineContentIs("});"); | {
"end_byte": 430,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOnDocumentReadyFunction.ts"
} |
TypeScript/tests/cases/fourslash/incompleteFunctionCallCodefixTypeKeyof.ts_0_552 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
////function existing<T>(value: T) {
//// const keyofTypeof = Object.keys(value)[0] as keyof T;
//// added/*1*/(keyofTypeof);
////}
goTo.marker("1");
verify.codeFix({
description: "Add missing function declaration 'added'",
index: 0,
newFileContent: `function existing<T>(value: T) {
const keyofTypeof = Object.keys(value)[0] as keyof T;
added(keyofTypeof);
}
function added(keyofTypeof: string | number | symbol) {
throw new Error("Function not implemented.");
}
`,
});
| {
"end_byte": 552,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incompleteFunctionCallCodefixTypeKeyof.ts"
} |
TypeScript/tests/cases/fourslash/asConstRefsNoErrors3.ts_0_204 | /// <reference path="fourslash.ts" />
// @checkJs: true
// @Filename: file.js
////class Tex {
//// type = (/** @type {/**/const} */'Text');
////}
verify.baselineGoToDefinition("");
verify.noErrors(); | {
"end_byte": 204,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/asConstRefsNoErrors3.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddConvertToUnknownForNonOverlappingTypes4.ts_0_205 | /// <reference path='fourslash.ts' />
////"words" as object
verify.codeFix({
description: "Add 'unknown' conversion for non-overlapping types",
newFileContent: `"words" as unknown as object`
});
| {
"end_byte": 205,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddConvertToUnknownForNonOverlappingTypes4.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationDestructuringParameterNestedObjectBindingPattern.ts_0_1049 | /// <reference path='fourslash.ts' />
////declare var console: {
//// log(msg: string): void;
////}
////interface Robot {
//// name: string;
//// skills: {
//// primary: string;
//// secondary: string;
//// };
////}
////var robotA: Robot = { name: "mower", skills: { primary: "mowing", secondary: "none" } };
////function foo1({ skills: { primary: primaryA, secondary: secondaryA } }: Robot) {
//// console.log(primaryA);
////}
////function foo2({ name: nameC, skills: { primary: primaryB, secondary: secondaryB } }: Robot) {
//// console.log(secondaryB);
////}
////function foo3({ skills }: Robot) {
//// console.log(skills.primary);
////}
////foo1(robotA);
////foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } });
////foo2(robotA);
////foo2({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } });
////foo3(robotA);
////foo3({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } });
verify.baselineCurrentFileBreakpointLocations();
| {
"end_byte": 1049,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationDestructuringParameterNestedObjectBindingPattern.ts"
} |
TypeScript/tests/cases/fourslash/navigationBarAssignmentTypes.ts_0_1216 | /// <reference path='fourslash.ts'/>
////'use strict'
////const a = {
//// ...b,
//// c,
//// d: 0
////};
verify.navigationTree({
text: "<global>",
kind: "script",
childItems: [
{
text: "a",
kind: "const",
childItems: [
{
text: "b",
kind: "property",
},
{
text: "c",
kind: "property"
},
{
text: "d",
kind: "property"
}
]
}
]
});
verify.navigationBar([
{
text: "<global>",
kind: "script",
childItems: [
{
text: "a",
kind: "const"
}
]
},
{
text: "a",
kind: "const",
childItems: [
{
text: "b",
kind: "property",
},
{
text: "c",
kind: "property"
},
{
text: "d",
kind: "property"
}
],
indent: 1
}
]);
| {
"end_byte": 1216,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/navigationBarAssignmentTypes.ts"
} |
TypeScript/tests/cases/fourslash/fixingTypeParametersQuickInfo.ts_0_394 | /// <reference path='fourslash.ts'/>
////declare function f<T>(x: T, y: (p: T) => T, z: (p: T) => T): T;
////var /*1*/result = /*2*/f(0, /*3*/x => null, /*4*/x => x.blahblah);
verify.quickInfos({
1: "var result: number",
2: "function f<number>(x: number, y: (p: number) => number, z: (p: number) => number): number",
3: "(parameter) x: number",
4: "(parameter) x: number"
});
| {
"end_byte": 394,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixingTypeParametersQuickInfo.ts"
} |
TypeScript/tests/cases/fourslash/extract-method36.ts_0_870 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////export interface A {
//// x: number;
////}
// @Filename: /b.ts
////import { A } from "./a";
////export interface B<T> {
//// payload: T;
////}
////export const b: B<A> = {
//// payload: { x: 1 }
////}
// @Filename: /c.ts
////import { b } from "./b";
////
////class Foo {
//// foo() {
//// const arg = b;
//// /*a*/console.log(arg);/*b*/
//// }
////}
goTo.file("/c.ts");
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_1",
actionDescription: "Extract to method in class 'Foo'",
newContent:
`import { A } from "./a";
import { B, b } from "./b";
class Foo {
foo() {
const arg = b;
this./*RENAME*/newMethod(arg);
}
private newMethod(arg: B<A>) {
console.log(arg);
}
}`
});
| {
"end_byte": 870,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/extract-method36.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoAlias.ts_0_414 | /// <reference path='fourslash.ts'/>
// @Filename: /a.ts
/////**
//// * Doc
//// * @tag Tag text
//// */
////export const x = 0;
// @Filename: /b.ts
////import { x } from "./a";
////x/*b*/;
// @Filename: /c.ts
/////**
//// * Doc 2
//// * @tag Tag text 2
//// */
////import {
//// /**
//// * Doc 3
//// * @tag Tag text 3
//// */
//// x
////} from "./a";
////x/*c*/;
verify.baselineQuickInfo()
| {
"end_byte": 414,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoAlias.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionJsDocImportTag1.ts_0_247 | /// <reference path='fourslash.ts'/>
// @allowJS: true
// @checkJs: true
// @Filename: /b.ts
/////*2*/export interface A { }
// @Filename: /a.js
/////**
//// * @import { A } from [|"./b/*1*/"|]
//// */
verify.baselineGoToDefinition("1");
| {
"end_byte": 247,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionJsDocImportTag1.ts"
} |
TypeScript/tests/cases/fourslash/refactorOverloadListToSingleSignature2.ts_0_1320 | /// <reference path='fourslash.ts' />
/////*a*/declare function foo(): void;
/////**
//// * @param a a string param doc
//// */
////declare function foo(a: string): void;
/////**
//// * @param a a number param doc
//// * @param b b number param doc
//// */
////declare function foo(a: number, b: number): void;
/////**
//// * @param rest rest param doc
//// */
////declare function foo(...rest: symbol[]): void;/*b*/
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert overload list to single signature",
actionName: "Convert overload list to single signature",
actionDescription: ts.Diagnostics.Convert_overload_list_to_single_signature.message,
// we don't delete the param comment on the signature we update because deleting *part* of a comment is... hard
// and we definitely don't want to delete the whole comment. This is probably a good argument for why jsdoc should
// really be uniformly handled as AST nodes, and transformed as such :(
newContent: `/**
* @param rest rest param doc
*/
declare function foo(...args: [] | [
/**
* a string param doc
*/
a: string
] | [
/**
* a number param doc
*/
a: number,
/**
* b number param doc
*/
b: number
] | [
/**
* rest param doc
*/
...rest: symbol[]
]): void;`,
});
| {
"end_byte": 1320,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorOverloadListToSingleSignature2.ts"
} |
TypeScript/tests/cases/fourslash/breakpointValidationExports.ts_0_251 | /// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_exports.baseline
// @Filename: bpSpan_exports.ts
////export * from "a";
////export {a as A} from "a";
////export import e = require("a");
verify.baselineCurrentFileBreakpointLocations(); | {
"end_byte": 251,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/breakpointValidationExports.ts"
} |
TypeScript/tests/cases/fourslash/argumentsIndexExpression.ts_0_143 | /// <reference path="fourslash.ts" />
//// function f() {
//// var x = /**/arguments[0];
//// }
goTo.marker();
verify.quickInfoExists();
| {
"end_byte": 143,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/argumentsIndexExpression.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoCanBeTruncated.ts_0_4211 | /// <reference path="fourslash.ts" />
// @noLib: true
//// interface Foo {
//// _0: 0;
//// _1: 1;
//// _2: 2;
//// _3: 3;
//// _4: 4;
//// _5: 5;
//// _6: 6;
//// _7: 7;
//// _8: 8;
//// _9: 9;
//// _10: 10;
//// _11: 11;
//// _12: 12;
//// _13: 13;
//// _14: 14;
//// _15: 15;
//// _16: 16;
//// _17: 17;
//// _18: 18;
//// _19: 19;
//// _20: 20;
//// _21: 21;
//// _22: 22;
//// _23: 23;
//// _24: 24;
//// _25: 25;
//// _26: 26;
//// _27: 27;
//// _28: 28;
//// _29: 29;
//// _30: 30;
//// _31: 31;
//// _32: 32;
//// _33: 33;
//// _34: 34;
//// _35: 35;
//// _36: 36;
//// _37: 37;
//// _38: 38;
//// _39: 39;
//// _40: 40;
//// _41: 41;
//// _42: 42;
//// _43: 43;
//// _44: 44;
//// _45: 45;
//// _46: 46;
//// _47: 47;
//// _48: 48;
//// _49: 49;
//// _50: 50;
//// _51: 51;
//// _52: 52;
//// _53: 53;
//// _54: 54;
//// _55: 55;
//// _56: 56;
//// _57: 57;
//// _58: 58;
//// _59: 59;
//// _60: 60;
//// _61: 61;
//// _62: 62;
//// _63: 63;
//// _64: 64;
//// _65: 65;
//// _66: 66;
//// _67: 67;
//// _68: 68;
//// _69: 69;
//// _70: 70;
//// _71: 71;
//// _72: 72;
//// _73: 73;
//// _74: 74;
//// _75: 75;
//// _76: 76;
//// _77: 77;
//// _78: 78;
//// _79: 79;
//// _80: 80;
//// _81: 81;
//// _82: 82;
//// _83: 83;
//// _84: 84;
//// _85: 85;
//// _86: 86;
//// _87: 87;
//// _88: 88;
//// _89: 89;
//// _90: 90;
//// _91: 91;
//// _92: 92;
//// _93: 93;
//// _94: 94;
//// _95: 95;
//// _96: 96;
//// _97: 97;
//// _98: 98;
//// _99: 99;
//// _100: 100;
//// _101: 101;
//// _102: 102;
//// _103: 103;
//// _104: 104;
//// _105: 105;
//// _106: 106;
//// _107: 107;
//// _108: 108;
//// _109: 109;
//// _110: 110;
//// _111: 111;
//// _112: 112;
//// _113: 113;
//// _114: 114;
//// _115: 115;
//// _116: 116;
//// _117: 117;
//// _118: 118;
//// _119: 119;
//// _120: 120;
//// _121: 121;
//// _122: 122;
//// _123: 123;
//// _124: 124;
//// _125: 125;
//// _126: 126;
//// _127: 127;
//// _128: 128;
//// _129: 129;
//// _130: 130;
//// _131: 131;
//// _132: 132;
//// _133: 133;
//// _134: 134;
//// _135: 135;
//// _136: 136;
//// _137: 137;
//// _138: 138;
//// _139: 139;
//// _140: 140;
//// _141: 141;
//// _142: 142;
//// _143: 143;
//// _144: 144;
//// _145: 145;
//// _146: 146;
//// _147: 147;
//// _148: 148;
//// _149: 149;
//// _150: 150;
//// _151: 151;
//// _152: 152;
//// _153: 153;
//// _154: 154;
//// _155: 155;
//// _156: 156;
//// _157: 157;
//// _158: 158;
//// _159: 159;
//// _160: 160;
//// _161: 161;
//// _162: 162;
//// _163: 163;
//// _164: 164;
//// _165: 165;
//// _166: 166;
//// _167: 167;
//// _168: 168;
//// _169: 169;
//// _170: 170;
//// _171: 171;
//// _172: 172;
//// _173: 173;
//// _174: 174;
//// _175: 175;
//// _176: 176;
//// _177: 177;
//// _178: 178;
//// _179: 179;
//// _180: 180;
//// _181: 181;
//// _182: 182;
//// _183: 183;
//// _184: 184;
//// _185: 185;
//// _186: 186;
//// _187: 187;
//// _188: 188;
//// _189: 189;
//// _190: 190;
//// _191: 191;
//// _192: 192;
//// _193: 193;
//// _194: 194;
//// _195: 195;
//// _196: 196;
//// _197: 197;
//// _198: 198;
//// _199: 199;
//// _200: 200;
//// _201: 201;
//// _202: 202;
//// _203: 203;
//// _204: 204;
//// _205: 205;
//// _206: 206;
//// _207: 207;
//// _208: 208;
//// _209: 209;
//// _210: 210;
//// _211: 211;
//// _212: 212;
//// _213: 213;
//// _214: 214;
//// _215: 215;
//// _216: 216;
//// _217: 217;
//// _218: 218;
//// _219: 219;
//// _220: 220;
//// _221: 221;
//// _222: 222;
//// _223: 223;
//// _224: 224;
//// _225: 225;
//// _226: 226;
//// _227: 227;
//// _228: 228;
//// _229: 229;
//// _230: 230;
//// _231: 231;
//// _232: 232;
//// _233: 233;
//// _234: 234;
//// _235: 235;
//// _236: 236;
//// _237: 237;
//// _238: 238;
//// _239: 239;
//// _240: 240;
//// _241: 241; | {
"end_byte": 4211,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoCanBeTruncated.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoCanBeTruncated.ts_4212_8603 | //// _242: 242;
//// _243: 243;
//// _244: 244;
//// _245: 245;
//// _246: 246;
//// _247: 247;
//// _248: 248;
//// _249: 249;
//// _250: 250;
//// _251: 251;
//// _252: 252;
//// _253: 253;
//// _254: 254;
//// _255: 255;
//// _256: 256;
//// _257: 257;
//// _258: 258;
//// _259: 259;
//// _260: 260;
//// _261: 261;
//// _262: 262;
//// _263: 263;
//// _264: 264;
//// _265: 265;
//// _266: 266;
//// _267: 267;
//// _268: 268;
//// _269: 269;
//// _270: 270;
//// _271: 271;
//// _272: 272;
//// _273: 273;
//// _274: 274;
//// _275: 275;
//// _276: 276;
//// _277: 277;
//// _278: 278;
//// _279: 279;
//// _280: 280;
//// _281: 281;
//// _282: 282;
//// _283: 283;
//// _284: 284;
//// _285: 285;
//// _286: 286;
//// _287: 287;
//// _288: 288;
//// _289: 289;
//// _290: 290;
//// _291: 291;
//// _292: 292;
//// _293: 293;
//// _294: 294;
//// _295: 295;
//// _296: 296;
//// _297: 297;
//// _298: 298;
//// _299: 299;
//// _300: 300;
//// _301: 301;
//// _302: 302;
//// _303: 303;
//// _304: 304;
//// _305: 305;
//// _306: 306;
//// _307: 307;
//// _308: 308;
//// _309: 309;
//// _310: 310;
//// _311: 311;
//// _312: 312;
//// _313: 313;
//// _314: 314;
//// _315: 315;
//// _316: 316;
//// _317: 317;
//// _318: 318;
//// _319: 319;
//// _320: 320;
//// _321: 321;
//// _322: 322;
//// _323: 323;
//// _324: 324;
//// _325: 325;
//// _326: 326;
//// _327: 327;
//// _328: 328;
//// _329: 329;
//// _330: 330;
//// _331: 331;
//// _332: 332;
//// _333: 333;
//// _334: 334;
//// _335: 335;
//// _336: 336;
//// _337: 337;
//// _338: 338;
//// _339: 339;
//// _340: 340;
//// _341: 341;
//// _342: 342;
//// _343: 343;
//// _344: 344;
//// _345: 345;
//// _346: 346;
//// _347: 347;
//// _348: 348;
//// _349: 349;
//// _350: 350;
//// _351: 351;
//// _352: 352;
//// _353: 353;
//// _354: 354;
//// _355: 355;
//// _356: 356;
//// _357: 357;
//// _358: 358;
//// _359: 359;
//// _360: 360;
//// _361: 361;
//// _362: 362;
//// _363: 363;
//// _364: 364;
//// _365: 365;
//// _366: 366;
//// _367: 367;
//// _368: 368;
//// _369: 369;
//// _370: 370;
//// _371: 371;
//// _372: 372;
//// _373: 373;
//// _374: 374;
//// _375: 375;
//// _376: 376;
//// _377: 377;
//// _378: 378;
//// _379: 379;
//// _380: 380;
//// _381: 381;
//// _382: 382;
//// _383: 383;
//// _384: 384;
//// _385: 385;
//// _386: 386;
//// _387: 387;
//// _388: 388;
//// _389: 389;
//// _390: 390;
//// _391: 391;
//// _392: 392;
//// _393: 393;
//// _394: 394;
//// _395: 395;
//// _396: 396;
//// _397: 397;
//// _398: 398;
//// _399: 399;
//// _400: 400;
//// _401: 401;
//// _402: 402;
//// _403: 403;
//// _404: 404;
//// _405: 405;
//// _406: 406;
//// _407: 407;
//// _408: 408;
//// _409: 409;
//// _410: 410;
//// _411: 411;
//// _412: 412;
//// _413: 413;
//// _414: 414;
//// _415: 415;
//// _416: 416;
//// _417: 417;
//// _418: 418;
//// _419: 419;
//// _420: 420;
//// _421: 421;
//// _422: 422;
//// _423: 423;
//// _424: 424;
//// _425: 425;
//// _426: 426;
//// _427: 427;
//// _428: 428;
//// _429: 429;
//// _430: 430;
//// _431: 431;
//// _432: 432;
//// _433: 433;
//// _434: 434;
//// _435: 435;
//// _436: 436;
//// _437: 437;
//// _438: 438;
//// _439: 439;
//// _440: 440;
//// _441: 441;
//// _442: 442;
//// _443: 443;
//// _444: 444;
//// _445: 445;
//// _446: 446;
//// _447: 447;
//// _448: 448;
//// _449: 449;
//// _450: 450;
//// _451: 451;
//// _452: 452;
//// _453: 453;
//// _454: 454;
//// _455: 455;
//// _456: 456;
//// _457: 457;
//// _458: 458;
//// _459: 459;
//// _460: 460;
//// _461: 461;
//// _462: 462;
//// _463: 463;
//// _464: 464;
//// _465: 465;
//// _466: 466;
//// _467: 467;
//// _468: 468;
//// _469: 469;
//// _470: 470;
//// _471: 471;
//// _472: 472;
//// _473: 473;
//// _474: 474;
//// _475: 475;
//// _476: 476;
//// _477: 477;
//// _478: 478;
//// _479: 479;
//// _480: 480;
//// _481: 481;
//// _482: 482;
//// _483: 483;
//// _484: 484;
//// _485: 485; | {
"end_byte": 8603,
"start_byte": 4212,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoCanBeTruncated.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoCanBeTruncated.ts_8604_11267 | //// _486: 486;
//// _487: 487;
//// _488: 488;
//// _489: 489;
//// _490: 490;
//// _491: 491;
//// _492: 492;
//// _493: 493;
//// _494: 494;
//// _495: 495;
//// _496: 496;
//// _497: 497;
//// _498: 498;
//// _499: 499;
//// }
//// type A/*1*/ = keyof Foo;
//// type Exclude<T, U> = T extends U ? never : T;
//// type Less/*2*/ = Exclude<A, "_0">;
//// function f<T extends A>(s: T, x: Exclude<A, T>, y: string) {}
//// f("_499", /*3*/);
//// type Decomposed/*4*/ = {[K in A]: Foo[K]}
//// type LongTuple/*5*/ = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17.18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70];
//// type DeeplyMapped/*6*/ = {[K in keyof Foo]: {[K2 in keyof Foo]: [K, K2, Foo[K], Foo[K2]]}}
goTo.marker("1");
verify.quickInfoIs(`type A = keyof Foo`);
goTo.marker("2");
verify.quickInfoIs(`type Less = "_1" | "_2" | "_3" | "_4" | "_5" | "_6" | "_7" | "_8" | "_9" | "_10" | "_11" | "_12" | "_13" | "_14" | "_15" | "_16" | "_17" | "_18" | "_19" | "_20" | "_21" | "_22" | "_23" | "_24" | "_25" | ... 473 more ... | "_499"`);
goTo.marker("3");
verify.signatureHelp({
marker: "3",
text: `f(s: "_499", x: "_0" | "_1" | "_2" | "_3" | "_4" | "_5" | "_6" | "_7" | "_8" | "_9" | "_10" | "_11" | "_12" | "_13" | "_14" | "_15" | "_16" | "_17" | "_18" | "_19" | "_20" | "_21" | "_22" | "_23" | "_24" | ... 473 more ... | "_498", y: string): void`
});
goTo.marker("4");
verify.quickInfoIs(`type Decomposed = {
_0: 0;
_1: 1;
_2: 2;
_3: 3;
_4: 4;
_5: 5;
_6: 6;
_7: 7;
_8: 8;
_9: 9;
_10: 10;
_11: 11;
_12: 12;
_13: 13;
_14: 14;
_15: 15;
_16: 16;
_17: 17;
_18: 18;
_19: 19;
_20: 20;
_21: 21;
_22: 22;
_23: 23;
_24: 24;
_25: 25;
_26: 26;
_27: 27;
_28: 28;
_29: 29;
_30: 30;
... 468 more ...;
_499: 499;
}`);
goTo.marker("5");
verify.quickInfoIs(`type LongTuple = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17.18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, ... 27 more ..., 70]`);
goTo.marker("6");
verify.quickInfoIs(`type DeeplyMapped = {
_0: {
_0: ["_0", "_0", 0, 0];
_1: ["_0", "_1", 0, 1];
_2: ["_0", "_2", 0, 2];
_3: ["_0", "_3", 0, 3];
_4: ["_0", "_4", 0, 4];
_5: ["_0", "_5", 0, 5];
_6: ["_0", "_6", 0, 6];
_7: ["_0", "_7", 0, 7];
... 491 more ...;
_499: [...];
};
... 498 more ...;
_499: {
...;
};
}`); | {
"end_byte": 11267,
"start_byte": 8604,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoCanBeTruncated.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForGetterAndSetter.ts_0_502 | /// <reference path='fourslash.ts'/>
//// class Test {
//// constructor() {
//// this.value;
//// }
////
//// /** Getter text */
//// get val/*1*/ue() {
//// return this.value;
//// }
////
//// /** Setter text */
//// set val/*2*/ue(value) {
//// this.value = value;
//// }
//// }
goTo.marker("1");
verify.quickInfoIs("(getter) Test.value: any", "Getter text");
goTo.marker("2");
verify.quickInfoIs("(setter) Test.value: any", "Setter text");
| {
"end_byte": 502,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForGetterAndSetter.ts"
} |
TypeScript/tests/cases/fourslash/jsDocIndentationPreservation3.ts_0_301 | ///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: Foo.js
/////**
//// Does some stuff.
//// Second line.
//// Third line.
////*/
////function foo/**/(){}
goTo.marker();
verify.quickInfoIs("function foo(): void", "Does some stuff.\n Second line.\n\tThird line.");
| {
"end_byte": 301,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsDocIndentationPreservation3.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_typeImport.ts_1_675 | /// <reference path='fourslash.ts' />
// @verbatimModuleSyntax: true
//@module: esnext
//moduleResolution: bundler
// @Filename: /bar.ts
////import {} from "./somefile";
// @Filename: /a.ts
////import { type A } from "./other";
////import type { B } from "./other";
////[|function f(a: B) {}|]
// @Filename: /other.ts
////export type B = {};
////export interface A {
//// x: number;
////}
verify.moveToFile({
newFileContents: {
"/a.ts":
`import { type A } from "./other";
`,
"/bar.ts":
`import type { B } from "./other";
import {} from "./somefile";
function f(a: B) { }
`,
},
interactiveRefactorArguments: { targetFile: "/bar.ts" }
});
| {
"end_byte": 675,
"start_byte": 1,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_typeImport.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFixNewImportNodeModules5.ts_0_678 | /// <reference path="fourslash.ts" />
//// [|f1/*0*/('');|]
// @Filename: package.json
//// { "dependencies": { "package-name": "latest" } }
// @Filename: node_modules/package-name/node_modules/package-name2/bin/lib/libfile.d.ts
//// export function f1(text: string): string;
// @Filename: node_modules/package-name/node_modules/package-name2/bin/lib/libfile.js
//// function f1(text) { }
//// exports.f1 = f1;
// @Filename: node_modules/package-name/node_modules/package-name2/package.json
//// {
//// "main": "bin/lib/libfile.js",
//// "types": "bin/lib/libfile.d.ts"
//// }
verify.codeFixAvailable([
{ description: "Add missing function declaration 'f1'" }
]);
| {
"end_byte": 678,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFixNewImportNodeModules5.ts"
} |
TypeScript/tests/cases/fourslash/referencesForLabel6.ts_0_266 | /// <reference path='fourslash.ts'/>
// References to labels with close names
/////*1*/labela: while (true) {
/////*2*/labelb: while (false) { /*3*/break /*4*/labelb; }
//// break labelc;
////}
verify.baselineFindAllReferences('1', '2', '3', '4');
| {
"end_byte": 266,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForLabel6.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation1.ts_0_211 | /// <reference path='fourslash.ts'/>
// @strict: true
// @exactOptionalPropertyTypes: true
//// declare const xx: { prop?: number };
//// xx.prop/*1*/ = 1;
verify.quickInfoAt('1', '(property) prop?: number');
| {
"end_byte": 211,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation1.ts"
} |
TypeScript/tests/cases/fourslash/getEditsForFileRename_notAffectedByJsFile.ts_0_330 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////export const x = 0;
// @Filename: /a.js
////exports.x = 0;
// @Filename: /b.ts
////import { x } from "./a";
verify.getEditsForFileRename({
oldPath: "/a.ts",
newPath: "/a2.ts",
newFileContents: {
"/b.ts": 'import { x } from "./a2";',
},
});
| {
"end_byte": 330,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_notAffectedByJsFile.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionExpandoElementAccess.ts_0_142 | /// <reference path="fourslash.ts" />
////function f() {}
////f[/*0*/"x"] = 0;
////f[[|/*1*/"x"|]] = 1;
verify.baselineGoToDefinition("1");
| {
"end_byte": 142,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionExpandoElementAccess.ts"
} |
TypeScript/tests/cases/fourslash/findAllReferencesOfJsonModule.ts_3_301 | / <reference path='fourslash.ts' />
// @resolveJsonModule: true
// @module: commonjs
// @esModuleInterop: true
// @Filename: /foo.ts
/////*1*/import /*2*/settings from "./settings.json";
/////*3*/settings;
// @Filename: /settings.json
//// {}
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 301,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/findAllReferencesOfJsonModule.ts"
} |
TypeScript/tests/cases/fourslash/formattingObjectLiteral.ts_0_156 | /// <reference path='fourslash.ts' />
////var clear = {
////"a": 1/**/
////}
format.document();
goTo.marker();
verify.currentLineContentIs(' "a": 1'); | {
"end_byte": 156,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingObjectLiteral.ts"
} |
TypeScript/tests/cases/fourslash/stringLiteralCompletionsInArgUsingInferenceResultFromPreviousArg.ts_0_800 | /// <reference path="fourslash.ts" />
// @strict: true
//// // https://github.com/microsoft/TypeScript/issues/55545
//// enum myEnum {
//// valA = "valA",
//// valB = "valB",
//// }
////
//// interface myEnumParamMapping {
//// ["valA"]: "1" | "2";
//// ["valB"]: "3" | "4";
//// }
////
//// function myFunction<K extends keyof typeof myEnum>(
//// a: K,
//// b: myEnumParamMapping[K],
//// ) {}
////
//// myFunction("valA", "/*ts1*/");
//// myFunction("valA", `/*ts2*/`);
////
//// function myFunction2<K extends keyof typeof myEnum>(
//// a: K,
//// { b }: { b: myEnumParamMapping[K] },
//// ) {}
////
//// myFunction2("valA", { b: "/*ts3*/" });
//// myFunction2("valA", { b: `/*ts4*/` });
verify.completions({
marker: ["ts1", "ts2", "ts3", "ts4"],
exact: ["1", "2"]
});
| {
"end_byte": 800,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/stringLiteralCompletionsInArgUsingInferenceResultFromPreviousArg.ts"
} |
TypeScript/tests/cases/fourslash/jsxTagNameCompletionClosed.ts_0_1624 | /// <reference path="fourslash.ts" />
//@Filename: file.tsx
////interface NestedInterface {
//// Foo: NestedInterface;
//// (props: {}): any;
////}
////
////declare const Foo: NestedInterface;
////
////function fn1() {
//// return <Foo>
//// </*1*/ />
//// </Foo>
////}
////function fn2() {
//// return <Foo>
//// <Fo/*2*/ />
//// </Foo>
////}
////function fn3() {
//// return <Foo>
//// <Foo./*3*/ />
//// </Foo>
////}
////function fn4() {
//// return <Foo>
//// <Foo.F/*4*/ />
//// </Foo>
////}
////function fn5() {
//// return <Foo>
//// <Foo.Foo./*5*/ />
//// </Foo>
////}
////function fn6() {
//// return <Foo>
//// <Foo.Foo.F/*6*/ />
//// </Foo>
////}
var preferences: FourSlashInterface.UserPreferences = {
jsxAttributeCompletionStyle: "braces",
includeCompletionsWithSnippetText: true,
includeCompletionsWithInsertText: true,
};
verify.completions(
{ marker: "1", preferences, includes: { name: "Foo", text: "const Foo: NestedInterface" } },
{ marker: "2", preferences, includes: { name: "Foo", text: "const Foo: NestedInterface" } },
{ marker: "3", preferences, includes: { name: "Foo", text: "(property) NestedInterface.Foo: NestedInterface" } },
{ marker: "4", preferences, includes: { name: "Foo", text: "(property) NestedInterface.Foo: NestedInterface" } },
{ marker: "5", preferences, includes: { name: "Foo", text: "(property) NestedInterface.Foo: NestedInterface" } },
{ marker: "6", preferences, includes: { name: "Foo", text: "(property) NestedInterface.Foo: NestedInterface" } },
)
| {
"end_byte": 1624,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/jsxTagNameCompletionClosed.ts"
} |
TypeScript/tests/cases/fourslash/referencesForInheritedProperties9.ts_3_257 | / <reference path='fourslash.ts'/>
//// class D extends C {
//// /*1*/prop1: string;
//// }
////
//// class C extends D {
//// /*2*/prop1: string;
//// }
////
//// var c: C;
//// c./*3*/prop1;
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 257,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/referencesForInheritedProperties9.ts"
} |
TypeScript/tests/cases/fourslash/organizeImports21.ts_0_783 | /// <reference path="fourslash.ts" />
// @filename: /a.ts
////export interface LocationDefinitions {}
////export interface PersonDefinitions {}
// @filename: /b.ts
////export {
//// /** @deprecated Use LocationDefinitions instead */
//// LocationDefinitions as AddressDefinitions,
//// LocationDefinitions,
//// /** @deprecated Use PersonDefinitions instead */
//// PersonDefinitions as NameDefinitions,
//// PersonDefinitions,
////} from './a';
goTo.file("/b.ts");
verify.organizeImports(
`export {
/** @deprecated Use LocationDefinitions instead */
LocationDefinitions as AddressDefinitions,
LocationDefinitions,
/** @deprecated Use PersonDefinitions instead */
PersonDefinitions as NameDefinitions,
PersonDefinitions
} from './a';
`);
| {
"end_byte": 783,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImports21.ts"
} |
TypeScript/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction11.ts_0_305 | /// <reference path='fourslash.ts' />
// @target: es2015
////async function fn(): PromiseLike<string> {}
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Replace_0_with_Promise_1.message, "PromiseLike<string>", "string"],
newFileContent: `async function fn(): Promise<string> {}`
});
| {
"end_byte": 305,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixReturnTypeInAsyncFunction11.ts"
} |
TypeScript/tests/cases/fourslash/fixExactOptionalUnassignableProperties13.ts_0_768 | /// <reference path='fourslash.ts'/>
// @strictNullChecks: true
// @exactOptionalPropertyTypes: true
//// interface ICP {
//// a?: number
//// }
//// interface J {
//// a?: number | undefined
//// }
//// declare var j: J
//// class CP {
//// #icp: ICP
//// m() { this.#icp/**/ = j; console.log(this.#icp) }
//// }
verify.codeFixAvailable([
{ description: ts.Diagnostics.Add_undefined_to_optional_property_type.message }
]);
verify.codeFix({
description: ts.Diagnostics.Add_undefined_to_optional_property_type.message,
index: 0,
newFileContent:
`interface ICP {
a?: number | undefined
}
interface J {
a?: number | undefined
}
declare var j: J
class CP {
#icp: ICP
m() { this.#icp = j; console.log(this.#icp) }
}`,
});
| {
"end_byte": 768,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixExactOptionalUnassignableProperties13.ts"
} |
TypeScript/tests/cases/fourslash/getOutliningSpansDepthElseIf.ts_0_1594 | /// <reference path="fourslash.ts"/>
// Tests that each 'else if' does not count towards a higher nesting depth.
////if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else[| {
//// 1;
////}|]
verify.outliningSpansInCurrentFile(test.ranges());
| {
"end_byte": 1594,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getOutliningSpansDepthElseIf.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToOptionalChainExpression_ReturnStatementBinary.ts_0_440 | /// <reference path='fourslash.ts' />
////let a = { b: { c: 0 } };
////function f(){
//// return /*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: 0 } };
function f(){
return a?.b?.c;
}`
}); | {
"end_byte": 440,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToOptionalChainExpression_ReturnStatementBinary.ts"
} |
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType9.ts_0_360 | /// <reference path='fourslash.ts' />
////function /*a*/foo<T>/*b*/() {
//// return 1 as T;
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Infer function return type",
actionName: "Infer function return type",
actionDescription: "Infer function return type",
newContent:
`function foo<T>(): T {
return 1 as T;
}`
});
| {
"end_byte": 360,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType9.ts"
} |
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts_0_230 | // @strict: true
/// <reference path='fourslash.ts' />
//// function f(x: [|never?|]) {
//// }
verify.codeFix({
description: "Change 'never?' to 'never'",
errorCode: 17019,
index: 0,
newRangeContent: "never",
});
| {
"end_byte": 230,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_requireImport2.ts_0_467 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @filename: /a.js
////module.exports = 1;
// @filename: /b.js
////var a = require("./a"),
//// b = require("./a"),
//// c = require("./a");
////[|function f() {
//// b;
////}|]
verify.noErrors();
verify.moveToNewFile({
newFileContents: {
"/b.js":
`var a = require("./a"),
c = require("./a");
`,
"/f.js":
`const b = require("./a");
function f() {
b;
}
`,
},
});
| {
"end_byte": 467,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_requireImport2.ts"
} |
TypeScript/tests/cases/fourslash/completionsGeneratorMethodDeclaration.ts_0_435 | /// <reference path="fourslash.ts" />
//// const obj = {
//// a() {},
//// * b/*1*/
//// };
//// const obj2 = {
//// * /*2*/
//// };
//// const obj3 = {
//// async * /*3*/
//// };
//// class Foo {
//// * b/*4*/
//// }
//// class Foo2 {
//// * /*5*/
//// }
//// class Bar {
//// static * b/*6*/
//// }
test.markerNames().forEach(marker => {
verify.completions({
marker,
isNewIdentifierLocation: true
});
});
| {
"end_byte": 435,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsGeneratorMethodDeclaration.ts"
} |
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType20.ts_0_495 | /// <reference path='fourslash.ts' />
////function f1(/*a*//*b*/x, { y }) {
//// return { x, y: 1 };
////}
////function f2(x, { /*c*//*d*/y }) {
//// return { x, y: 1 };
////}
////function f3(x, /*e*//*f*/{ y }) {
//// return { x, y: 1 };
////}
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");
| {
"end_byte": 495,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType20.ts"
} |
TypeScript/tests/cases/fourslash/renameDestructuringAssignmentNestedInFor.ts_0_835 | /// <reference path='fourslash.ts' />
////interface MultiRobot {
//// name: string;
//// skills: {
//// [|[|{| "contextRangeIndex": 0 |}primary|]: string;|]
//// secondary: string;
//// };
////}
////let multiRobot: MultiRobot, [|[|{| "contextRangeIndex": 2 |}primary|]: string|], secondary: string, primaryA: string, secondaryA: string, i: number;
////for ([|{ skills: { [|{| "contextRangeIndex": 4 |}primary|]: primaryA, secondary: secondaryA } } = multiRobot|], i = 0; i < 1; i++) {
//// primaryA;
////}
////for ([|{ skills: { [|{| "contextRangeIndex": 6 |}primary|], secondary } } = multiRobot|], i = 0; i < 1; i++) {
//// [|primary|];
////}
verify.noErrors();
const ranges = test.ranges();
const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3, r4] = ranges;
verify.baselineRename([r0, r2, r1, r3, r4]);
| {
"end_byte": 835,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameDestructuringAssignmentNestedInFor.ts"
} |
TypeScript/tests/cases/fourslash/instanceTypesForGenericType1.ts_0_370 | /// <reference path='fourslash.ts'/>
////class G<T> { // Introduce type parameter T
//// self: G<T>; // Use T as type argument to form instance type
//// f() {
//// this./*1*/self = /*2*/this; // self and this are both of type G<T>
//// }
////}
verify.quickInfos({
1: "(property) G<T>.self: G<T>",
2: "this: this"
});
| {
"end_byte": 370,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/instanceTypesForGenericType1.ts"
} |
TypeScript/tests/cases/fourslash/completionAtCaseClause.ts_0_118 | /// <reference path="fourslash.ts" />
////case /**/
verify.completions({ marker: "", exact: completion.globals });
| {
"end_byte": 118,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionAtCaseClause.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile.ts_0_591 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////// header comment
////
////import './foo';
////import { a, b, alreadyUnused } from './other';
////const p = 0;
////[|const y: Date = p + b;|]
////a; y;
verify.moveToNewFile({
newFileContents: {
"/a.ts":
`// header comment
import './foo';
import { a, alreadyUnused } from './other';
import { y } from './y';
export const p = 0;
a; y;`,
"/y.ts":
`import { p } from './a';
import { b } from './other';
export const y: Date = p + b;
`,
},
preferences: {
quotePreference: "single",
}
});
| {
"end_byte": 591,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionAcrossMultipleProjects.ts_0_436 | /// <reference path="fourslash.ts" />
//@Filename: a.ts
////var /*def1*/x: number;
//@Filename: b.ts
////var /*def2*/x: number;
//@Filename: c.ts
////var /*def3*/x: number;
//@Filename: d.ts
////var /*def4*/x: number;
//@Filename: e.ts
/////// <reference path="a.ts" />
/////// <reference path="b.ts" />
/////// <reference path="c.ts" />
/////// <reference path="d.ts" />
////[|/*use*/x|]++;
verify.baselineGoToDefinition("use");
| {
"end_byte": 436,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionAcrossMultipleProjects.ts"
} |
TypeScript/tests/cases/fourslash/renameJsDocTypeLiteral.ts_0_298 | /// <reference path="fourslash.ts" />
// @allowJs: true
// @checkJs: true
// @filename: /a.js
/////**
//// * @param {Object} options
//// * @param {string} options.foo
//// * @param {number} options.bar
//// */
////function foo(/**/options) {}
goTo.file("/a.js");
verify.baselineRename("", { });
| {
"end_byte": 298,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameJsDocTypeLiteral.ts"
} |
TypeScript/tests/cases/fourslash/formattingOptionsChange.ts_0_3337 | ///<reference path="fourslash.ts"/>
/////*insertSpaceAfterCommaDelimiter*/[1,2, 3];[ 72 , ];
/////*insertSpaceAfterSemicolonInForStatements*/for (i = 0;i; i++);
/////*insertSpaceBeforeAndAfterBinaryOperators*/1+2- 3
/////*insertSpaceAfterKeywordsInControlFlowStatements*/if (true) { }
/////*insertSpaceAfterFunctionKeywordForAnonymousFunctions*/(function () { })
/////*insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis*/(1 )
/////*insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets*/[1 ]; [ ]; []; [,];
/////*insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces*/`${1}`;`${ 1 }`
/////*insertSpaceAfterTypeAssertion*/const bar = <Bar> Thing.getFoo();
/////*insertSpaceBeforeTypeAnnotation*/const bar : number = 1;
/////*placeOpenBraceOnNewLineForFunctions*/class foo {
////}
/////*placeOpenBraceOnNewLineForControlBlocks*/if (true) {
////}
/////*insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces*/{ var t = 1}; var {a,b } = { a: 'sw', b:'r' };function f( { a, b}) { }
/////*insertSpaceAfterOpeningAndBeforeClosingEmptyBraces*/constructor() { }
const defaultFormatOption = format.copyFormatOptions();
runTest("insertSpaceAfterCommaDelimiter", "[1, 2, 3];[72,];", "[1,2,3];[72,];");
runTest("insertSpaceAfterSemicolonInForStatements", "for (i = 0; i; i++);", "for (i = 0;i;i++);");
runTest("insertSpaceBeforeAndAfterBinaryOperators", "1 + 2 - 3", "1+2-3");
runTest("insertSpaceAfterKeywordsInControlFlowStatements", "if (true) { }", "if(true) { }");
runTest("insertSpaceAfterFunctionKeywordForAnonymousFunctions", "(function () { })", "(function() { })");
runTest("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis", " ( 1 )", " (1)");
runTest("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets", "[ 1 ];[];[];[ , ];", "[1];[];[];[,];");
runTest("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces", "`${ 1 }`; `${ 1 }`", "`${1}`; `${1}`");
runTest("insertSpaceAfterTypeAssertion", "const bar = <Bar> Thing.getFoo();", "const bar = <Bar>Thing.getFoo();");
runTest("insertSpaceBeforeTypeAnnotation", "const bar : number = 1;", "const bar: number = 1;");
runTest("placeOpenBraceOnNewLineForFunctions", "class foo", "class foo {");
runTest("placeOpenBraceOnNewLineForControlBlocks", "if (true)", "if (true) {");
runTest("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces", "{ var t = 1 }; var { a, b } = { a: 'sw', b: 'r' }; function f({ a, b }) { }", "{var t = 1}; var {a, b} = {a: 'sw', b: 'r'}; function f({a, b}) {}");
runTest("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces", "constructor() { }", "constructor() {}");
function runTest(propertyName: string, expectedStringWhenTrue: string, expectedStringWhenFalse: string) {
// Go to the correct file
goTo.marker(propertyName);
// Set the option to false first
format.setOption(propertyName, false);
// Format
format.document();
// Verify
goTo.marker(propertyName);
verify.currentLineContentIs(expectedStringWhenFalse);
// Set the option to true
format.setOption(propertyName, true);
// Format
format.document();
// Verify
goTo.marker(propertyName);
verify.currentLineContentIs(expectedStringWhenTrue);
format.setOption(propertyName, defaultFormatOption[propertyName])
} | {
"end_byte": 3337,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formattingOptionsChange.ts"
} |
TypeScript/tests/cases/fourslash/completionEntryOnNarrowedType.ts_0_543 | /// <reference path='fourslash.ts'/>
////function foo(strOrNum: string | number) {
//// /*1*/
//// if (typeof strOrNum === "number") {
//// strOrNum/*2*/;
//// }
//// else {
//// strOrNum/*3*/;
//// }
////}
verify.completions(
{ marker: "1", includes: { name: "strOrNum", text: "(parameter) strOrNum: string | number" } },
{ marker: "2", includes: { name: "strOrNum", text: "(parameter) strOrNum: number" } },
{ marker: "3", includes: { name: "strOrNum", text: "(parameter) strOrNum: string" } },
);
| {
"end_byte": 543,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionEntryOnNarrowedType.ts"
} |
TypeScript/tests/cases/fourslash/getJavaScriptCompletions8.ts_0_280 | ///<reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: Foo.js
/////**
//// * @type {function(): number}
//// */
////var v;
////v()./**/
verify.completions({ marker: "", includes: { name: "toExponential", kind: "method", kindModifiers: "declare" } });
| {
"end_byte": 280,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getJavaScriptCompletions8.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnNarrowedType.ts_0_1551 | /// <reference path='fourslash.ts'/>
// @strictNullChecks: true
////function foo(strOrNum: string | number) {
//// if (typeof /*1*/strOrNum === "number") {
//// return /*2*/strOrNum;
//// }
//// else {
//// return /*3*/strOrNum.length;
//// }
////}
////function bar() {
//// let s: string | undefined;
//// /*4*/s;
//// /*5*/s = "abc";
//// /*6*/s;
////}
////class Foo {
//// #privateProperty: string[] | null;
//// constructor() {
//// this.#privateProperty = null;
//// }
//// testMethod() {
//// if (this.#privateProperty === null)
//// return;
//// this./*7*/#privateProperty;
//// }
////}
verify.quickInfos({
1: "(parameter) strOrNum: string | number",
2: "(parameter) strOrNum: number",
3: "(parameter) strOrNum: string",
4: "let s: string | undefined",
5: "let s: string | undefined",
6: "let s: string",
7: "(property) Foo.#privateProperty: string[]"
});
verify.completions(
{ marker: "1", includes: { name: "strOrNum", text: "(parameter) strOrNum: string | number" } },
{ marker: "2", includes: { name: "strOrNum", text: "(parameter) strOrNum: number" } },
{ marker: "3", includes: { name: "strOrNum", text: "(parameter) strOrNum: string" } },
{ marker: ["4", "5"], includes: { name: "s", text: "let s: string | undefined" } },
{ marker: "6", includes: { name: "s", text: "let s: string" } },
{ marker: "7", includes: { name: "#privateProperty", text: "(property) Foo.#privateProperty: string[]" } }
);
| {
"end_byte": 1551,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnNarrowedType.ts"
} |
TypeScript/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports31-inline-import-default.ts_0_911 | /// <reference path='fourslash.ts'/>
// @isolatedDeclarations: true
// @declaration: true
// @Filename: /person-code.ts
////export type Person = { x: string; }
////export function getPerson() : Person {
//// return null!
////}
// @Filename: /code.ts
////import { getPerson } from "./person-code";
////export default {
//// person: getPerson()
////};
goTo.file("/code.ts");
verify.codeFixAvailable([
{
"description": "Extract default export to variable"
},
{
"description": "Add satisfies and an inline type assertion with 'Person'"
},
{
"description": "Extract to variable and replace with 'newLocal as typeof newLocal'"
}
])
verify.codeFix({
description: "Add satisfies and an inline type assertion with 'Person'",
index: 1,
newFileContent:
`import { getPerson, Person } from "./person-code";
export default {
person: getPerson() satisfies Person as Person
};`
});
| {
"end_byte": 911,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports31-inline-import-default.ts"
} |
TypeScript/tests/cases/fourslash/incrementalJsDocAdjustsLengthsRight.ts_0_879 | /// <reference path="fourslash.ts" />
// @noLib: true
////
/////**
//// * Pad `str` to `width`.
//// *
//// * @param {String} str
//// * @param {Number} wid/*1*/
goTo.marker('1');
edit.insert("th\n@");
const c = classification("original");
verify.syntacticClassificationsAre(
c.comment("/**\n * Pad `str` to `width`.\n *\n * "),
c.punctuation("@"),
c.docCommentTagName("param"),
c.comment(" "),
c.punctuation("{"),
c.identifier("String"),
c.punctuation("}"),
c.comment(" "),
c.parameterName("str"),
c.comment("\n * "),
c.punctuation("@"),
c.docCommentTagName("param"),
c.comment(" "),
c.punctuation("{"),
c.identifier("Number"),
c.punctuation("}"),
c.comment(" "),
c.parameterName("wid"),
c.comment(""), // syntatic classification verification always just uses input text, so the edits don't appear
);
| {
"end_byte": 879,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/incrementalJsDocAdjustsLengthsRight.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsTripleSlash6.ts_0_254 | /// <reference path="fourslash.ts"/>
//// /// <reference path
const c = classification("original");
verify.syntacticClassificationsAre(
c.comment("/// "),
c.punctuation("<"),
c.jsxSelfClosingTagName("reference"),
c.comment(" path"));
| {
"end_byte": 254,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsTripleSlash6.ts"
} |
TypeScript/tests/cases/fourslash/getEditsForFileRename_unaffectedNonRelativePath.ts_0_366 | /// <reference path='fourslash.ts' />
// @Filename: /sub/a.ts
////export const a = 1;
// @Filename: /sub/b.ts
////import { a } from "sub/a";
// @Filename: /tsconfig.json
////{
//// "compilerOptions": {
//// "baseUrl": "."
//// }
////}
verify.getEditsForFileRename({
oldPath: "/sub/b.ts",
newPath: "/sub/c/d.ts",
newFileContents: {},
});
| {
"end_byte": 366,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/getEditsForFileRename_unaffectedNonRelativePath.ts"
} |
TypeScript/tests/cases/fourslash/codeFixCannotFindModule_nodeCoreModules.ts_0_315 | /// <reference path='fourslash.ts' />
// @noImplicitAny: true
// @Filename: /a.ts
////import fs = require("fs");
////fs;
verify.codeFixAvailable([{
description: "Install '@types/node'",
commands: [{
type: "install package",
file: "/a.ts",
packageName: "@types/node",
}],
}]);
| {
"end_byte": 315,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixCannotFindModule_nodeCoreModules.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_refactorAvailable2.ts_0_364 | /// <reference path='fourslash.ts' />
/////*a*/
////namespace ns {
//// export function fn() {
//// }
//// fn();
////}
/////*b*/
goTo.select("a", "b");
verify.refactorAvailable("Move to file",
/*actionName*/ undefined,
/*actionDescription*/ undefined,
/*kind*/ undefined,
{
allowTextChangesInNewFiles : true
},
/*includeInteractiveActions*/ true);
| {
"end_byte": 364,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_refactorAvailable2.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_pathsWithoutBaseUrl2.ts_0_540 | /// <reference path="fourslash.ts" />
// @Filename: /packages/test-package-1/tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "commonjs",
//// "paths": {
//// "test-package-2/*": ["../test-package-2/src/*"]
//// }
//// }
//// }
// @Filename: /packages/test-package-1/src/common/logging.ts
//// export class Logger {};
// @Filename: /packages/test-package-1/src/something/index.ts
//// Logger/**/
goTo.marker("");
verify.importFixAtPosition([`import { Logger } from "../common/logging";\n\nLogger`]);
| {
"end_byte": 540,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_pathsWithoutBaseUrl2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromUsage_allJS.ts_0_716 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @noImplicitAny: true
// @strictNullChecks: true
// @Filename: important.js
////function f(x, y) {
//// x += 0;
//// y += "";
////}
////
////function g(z) {
//// return z * 2;
////}
////
////let x = null;
////function h() {
//// if (!x) x = 2;
////}
verify.codeFixAll({
fixId: "inferFromUsage",
fixAllDescription: "Infer all types from usage",
newFileContent:
`/**
* @param {number} x
* @param {string} y
*/
function f(x, y) {
x += 0;
y += "";
}
/**
* @param {number} z
*/
function g(z) {
return z * 2;
}
/**
* @type {number | null}
*/
let x = null;
function h() {
if (!x) x = 2;
}`,
});
| {
"end_byte": 716,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromUsage_allJS.ts"
} |
TypeScript/tests/cases/fourslash/annotateWithTypeFromJSDoc5.ts_0_281 | /// <reference path='fourslash.ts' />
////class C {
//// /** @type {number | null} */
//// p = null
////}
verify.codeFix({
description: "Annotate with type from JSDoc",
newFileContent:
`class C {
/** @type {number | null} */
p: number | null = null
}`,
});
| {
"end_byte": 281,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/annotateWithTypeFromJSDoc5.ts"
} |
TypeScript/tests/cases/fourslash/formatTypeOperation.ts_0_808 | /// <reference path="fourslash.ts"/>
////type Union = number | {}/*formatBarOperator*/
/////*indent*/
////|string/*autoformat*/
////type Intersection = Foo & Bar;/*formatAmpersandOperator*/
////type Complexed =
//// Foo&
//// Bar|/*unionTypeNoIndent*/
//// Baz;/*intersectionTypeNoIndent*/
format.document();
goTo.marker("formatBarOperator");
verify.currentLineContentIs("type Union = number | {}");
goTo.marker("indent");
verify.indentationIs(4);
goTo.marker("autoformat");
verify.currentLineContentIs(" | string");
goTo.marker("formatAmpersandOperator");
verify.currentLineContentIs("type Intersection = Foo & Bar;");
goTo.marker("unionTypeNoIndent");
verify.currentLineContentIs(" Bar |");
goTo.marker("intersectionTypeNoIndent");
verify.currentLineContentIs(" Baz;"); | {
"end_byte": 808,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/formatTypeOperation.ts"
} |
TypeScript/tests/cases/fourslash/quickInfo_errorSignatureFillsInTypeParameter.ts_0_147 | /// <reference path='fourslash.ts'/>
////declare function f<T>(x: number): T;
////const x/**/ = f();
verify.quickInfoAt("", "const x: unknown");
| {
"end_byte": 147,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfo_errorSignatureFillsInTypeParameter.ts"
} |
TypeScript/tests/cases/fourslash/completionsOptionalReplacementSpan1.ts_0_269 | /// <reference path="fourslash.ts" />
// @lib: dom
//// console.[|cl/*0*/ockwork|];
//// type T = Array["[|toS/*1*/paghetti|]"];
test.ranges().forEach((range, marker) => {
verify.completions({
marker: `${marker}`,
optionalReplacementSpan: range,
});
});
| {
"end_byte": 269,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsOptionalReplacementSpan1.ts"
} |
TypeScript/tests/cases/fourslash/fixNaNEquality_all.ts_0_543 | /// <reference path="fourslash.ts" />
////declare const x: number;
////declare const y: any;
////if (x === NaN) {}
////if (NaN === x) {}
////if (x !== NaN) {}
////if (NaN !== x) {}
////if (NaN === y[0][1]) {}
verify.codeFixAll({
fixId: "fixNaNEquality",
fixAllDescription: ts.Diagnostics.Use_Number_isNaN_in_all_conditions.message,
newFileContent:
`declare const x: number;
declare const y: any;
if (Number.isNaN(x)) {}
if (Number.isNaN(x)) {}
if (!Number.isNaN(x)) {}
if (!Number.isNaN(x)) {}
if (Number.isNaN(y[0][1])) {}`
});
| {
"end_byte": 543,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/fixNaNEquality_all.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAwaitShouldNotCrashIfNotInFunction.ts_0_100 | /// <reference path='fourslash.ts' />
////await a
verify.not.codeFixAvailable("addMissingAwait");
| {
"end_byte": 100,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAwaitShouldNotCrashIfNotInFunction.ts"
} |
TypeScript/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction18.ts_0_360 | /// <reference path='fourslash.ts' />
//// const foo = /*a*/a/*b*/ => { return `abc`; };
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 => \`abc\`;`,
});
| {
"end_byte": 360,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction18.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration4.ts_0_321 | /// <reference path='fourslash.ts' />
////const test: string = foo();
verify.codeFix({
index: 0,
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "foo"],
newFileContent:
`const test: string = foo();
function foo(): string {
throw new Error("Function not implemented.");
}
`
});
| {
"end_byte": 321,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration4.ts"
} |
TypeScript/tests/cases/fourslash/completionListInUnclosedFunction16.ts_3_352 | / <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": 352,
"start_byte": 3,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListInUnclosedFunction16.ts"
} |
TypeScript/tests/cases/fourslash/codeFixConstToLet_all1.ts_0_257 | /// <reference path="fourslash.ts" />
////const a = 1;
////a = 2;
////a = 3;
verify.codeFixAll({
fixId: "fixConvertConstToLet",
fixAllDescription: ts.Diagnostics.Convert_all_const_to_let.message,
newFileContent:
`let a = 1;
a = 2;
a = 3;`
});
| {
"end_byte": 257,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixConstToLet_all1.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInvalidJsxCharacters8.ts_0_474 | /// <reference path='fourslash.ts' />
// @jsx: react
// @filename: main.tsx
////let a = <div>>{"foo"}</div>;
////let b = <div>>{"foo"}</div>;
////let c = <div>>{"foo"}</div>;
verify.codeFixAll({
fixId: "fixInvalidJsxCharacters_expression",
fixAllDescription: ts.Diagnostics.Wrap_all_invalid_characters_in_an_expression_container.message,
newFileContent:
`let a = <div>{">"}{"foo"}</div>;
let b = <div>{">"}{"foo"}</div>;
let c = <div>{">"}{"foo"}</div>;`
});
| {
"end_byte": 474,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInvalidJsxCharacters8.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoForIndexerResultWithConstraint.ts_0_299 | /// <reference path='fourslash.ts'/>
////function foo<T>(x: T) {
//// return x;
////}
////function other2<T extends Date>(arg: T) {
//// var b: { [x: string]: T };
//// var /*1*/r2 = foo(b); // just shows T
////}
verify.quickInfoAt("1", "(local var) r2: {\n [x: string]: T;\n}");
| {
"end_byte": 299,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoForIndexerResultWithConstraint.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingNew5.ts_0_305 | /// <reference path='fourslash.ts' />
////class C {
////}
////
////function foo() {
//// return C;
////}
////
////foo()!();
verify.codeFix({
description: "Add missing 'new' operator to call",
index: 0,
newFileContent:
`class C {
}
function foo() {
return C;
}
new (foo()!)();`
});
| {
"end_byte": 305,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingNew5.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertImport_namespaceToNamed2.ts_0_601 | /// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @filename: /a.js
/////**
//// * [|@import * as types from "types"|]
//// */
////
/////**
//// * @param { types.A } a
//// * @param { types.B } b
//// */
////function f() { }
goTo.selectRange(test.ranges()[0]);
edit.applyRefactor({
refactorName: "Convert import",
actionName: "Convert namespace import to named imports",
actionDescription: "Convert namespace import to named imports",
newContent:
`/**
* @import { A, B } from "types"
*/
/**
* @param { A } a
* @param { B } b
*/
function f() { }`,
});
| {
"end_byte": 601,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertImport_namespaceToNamed2.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoOnObjectLiteralWithOnlyGetter.ts_0_477 | /// <reference path='fourslash.ts' />
////function /*1*/makePoint(x: number) {
//// return {
//// get x() { return x; },
//// };
////};
////var /*4*/point = makePoint(2);
////var /*2*/x = point./*3*/x;
verify.quickInfos({
1: "function makePoint(x: number): {\n readonly x: number;\n}",
2: "var x: number",
4: "var point: {\n readonly x: number;\n}",
});
verify.completions({ marker: "3", exact: { name: "x", text: "(property) x: number" } });
| {
"end_byte": 477,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoOnObjectLiteralWithOnlyGetter.ts"
} |
TypeScript/tests/cases/fourslash/goToDefinitionExternalModuleName.ts_0_209 | /// <reference path='fourslash.ts'/>
// @Filename: b.ts
////import n = require([|'./a/*1*/'|]);
////var x = new n.Foo();
// @Filename: a.ts
//// /*2*/export class Foo {}
verify.baselineGoToDefinition("1");
| {
"end_byte": 209,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/goToDefinitionExternalModuleName.ts"
} |
TypeScript/tests/cases/fourslash/codeFixInferFromFunctionThisUsageLiteral.ts_0_436 | /// <reference path='fourslash.ts' />
// @noImplicitThis: true
////function returnThisMember([| |]) {
//// return this.member;
//// }
////
//// const container = {
//// member: "sample",
//// returnThisMember: returnThisMember,
//// };
verify.codeFix({
description: "Infer 'this' type of 'returnThisMember' from usage",
index: 0,
newRangeContent: "this: { member: string; returnThisMember: () => any; } ",
});
| {
"end_byte": 436,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixInferFromFunctionThisUsageLiteral.ts"
} |
TypeScript/tests/cases/fourslash/signatureHelpWithInterfaceAsIdentifier.ts_0_124 | /// <reference path='fourslash.ts'/>
////interface C {
//// (): void;
////}
////C(/*1*/);
verify.noSignatureHelp("1");
| {
"end_byte": 124,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/signatureHelpWithInterfaceAsIdentifier.ts"
} |
TypeScript/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration02.ts_0_365 | /// <reference path='fourslash.ts' />
////function f</*1*/A/*2*/,B/*3*/
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
goTo.marker(marker);
edit.insert("\n");
verify.indentationIs(indentation);
}
verifyIndentationAfterNewLine("1", 4);
verifyIndentationAfterNewLine("2", 4);
verifyIndentationAfterNewLine("3", 4); | {
"end_byte": 365,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration02.ts"
} |
TypeScript/tests/cases/fourslash/codeFixChangeJSDocSyntax13.ts_0_222 | // @strict: true
/// <reference path='fourslash.ts' />
////class C {
//// p: [|*|] = 12
////}
verify.codeFix({
description: "Change '*' to 'any'",
errorCode: 8020,
index: 0,
newRangeContent: "any",
});
| {
"end_byte": 222,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixChangeJSDocSyntax13.ts"
} |
TypeScript/tests/cases/fourslash/refactorInferFunctionReturnType14.ts_0_560 | /// <reference path='fourslash.ts' />
////function f(x: number): string;
////function f(x: string): number;
////function /*a*/f/*b*/(x: string | number) {
//// return x === 1 ? 1 : "quit";
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Infer function return type",
actionName: "Infer function return type",
actionDescription: "Infer function return type",
newContent:
`function f(x: number): string;
function f(x: string): number;
function f(x: string | number): string | number {
return x === 1 ? 1 : "quit";
}`
});
| {
"end_byte": 560,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorInferFunctionReturnType14.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAwaitInSyncFunction8.ts_0_315 | /// <reference path='fourslash.ts' />
////function f(): number | string {
//// await Promise.resolve(8);
////}
verify.codeFix({
index: 1,
description: "Add async modifier to containing function",
newFileContent:
`async function f(): Promise<number | string> {
await Promise.resolve(8);
}`,
});
| {
"end_byte": 315,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAwaitInSyncFunction8.ts"
} |
TypeScript/tests/cases/fourslash/memberListInReopenedEnum.ts_0_454 | /// <reference path='fourslash.ts'/>
////module M {
//// enum E {
//// A, B
//// }
//// enum E {
//// C = 0, D
//// }
//// var x = E./*1*/
////}
verify.completions({
marker: "1",
exact: [
{ name: "A", text: "(enum member) E.A = 0" },
{ name: "B", text: "(enum member) E.B = 1" },
{ name: "C", text: "(enum member) E.C = 0" },
{ name: "D", text: "(enum member) E.D = 1" },
],
});
| {
"end_byte": 454,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/memberListInReopenedEnum.ts"
} |
TypeScript/tests/cases/fourslash/syntacticClassificationsJsx2.ts_0_1299 | /// <reference path="fourslash.ts"/>
// @Filename: file1.tsx
////let x = <div.name b = "some-value" c = {1}>
//// some jsx text
////</div.name>;
////
////let y = <element.name attr="123"/>
const c = classification("original");
verify.syntacticClassificationsAre(
c.keyword("let"), c.identifier("x"), c.operator("="),
c.punctuation("<"),
c.jsxOpenTagName("div.name"),
c.jsxAttribute("b"), c.operator("="), c.jsxAttributeStringLiteralValue(`"some-value"`),
c.jsxAttribute("c"), c.operator("="), c.punctuation("{"), c.numericLiteral("1"), c.punctuation("}"),
c.punctuation(">"),
c.jsxText(`
some jsx text
`),
c.punctuation("<"), c.punctuation("/"), c.jsxCloseTagName("div.name"), c.punctuation(">"), c.punctuation(";"),
c.keyword("let"), c.identifier("y"), c.operator("="),
c.punctuation("<"),
c.jsxSelfClosingTagName("element.name"),
c.jsxAttribute("attr"), c.operator("="), c.jsxAttributeStringLiteralValue(`"123"`),
c.punctuation("/"), c.punctuation(">")
)
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("variable.declaration", "x"),
c2.semanticToken("variable.declaration", "y"),
);
| {
"end_byte": 1299,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/syntacticClassificationsJsx2.ts"
} |
TypeScript/tests/cases/fourslash/completionListAfterRegularExpressionLiteral01.ts_0_373 | /// <reference path="fourslash.ts" />
////let v = 100;
/////a/./**/
verify.completions({
marker: "",
unsorted: [
"exec",
"test",
"source",
"global",
"ignoreCase",
"multiline",
"lastIndex",
{ name: "compile", sortText: completion.SortText.Deprecated(completion.SortText.LocationPriority) }
]
});
| {
"end_byte": 373,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionListAfterRegularExpressionLiteral01.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess28.ts_0_551 | /// <reference path='fourslash.ts' />
//// class A {
//// /*a*/public static "a": number = 1;/*b*/
//// }
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Generate 'get' and 'set' accessors",
actionName: "Generate 'get' and 'set' accessors",
actionDescription: "Generate 'get' and 'set' accessors",
newContent: `class A {
private static /*RENAME*/"_a": number = 1;
public static get "a"(): number {
return A["_a"];
}
public static set "a"(value: number) {
A["_a"] = value;
}
}`,
});
| {
"end_byte": 551,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess28.ts"
} |
TypeScript/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString10.ts_0_355 | /// <reference path='fourslash.ts' />
////const a = /*x*/`${1}`/*y*/ + "a" + "b" + ` ${2}.`;
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert to template string",
actionName: "Convert to template string",
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
newContent: "const a = `${1}ab ${2}.`;"
});
| {
"end_byte": 355,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_TemplateString10.ts"
} |
TypeScript/tests/cases/fourslash/moveToNewFile_global2.ts_0_480 | /// <reference path='fourslash.ts' />
// @Filename: /a.ts
////interface String {
//// reverse(): string;
////}
////
////[|String.prototype.reverse = function (): string {
//// return this.split("").reverse().join("");
////}|]
verify.moveToNewFile({
newFileContents: {
"/a.ts":
`interface String {
reverse(): string;
}
`,
"/newFile.ts":
`String.prototype.reverse = function(): string {
return this.split("").reverse().join("");
};
`,
}
});
| {
"end_byte": 480,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToNewFile_global2.ts"
} |
TypeScript/tests/cases/fourslash/importNameCodeFix_rootDirs.ts_0_628 | /// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export const a = 0;
// @Filename: /b.ts
////a;
// @Filename: /tsconfig.json
////{
//// "compilerOptions": {
//// "baseUrl": ".",
//// "rootDirs": ["."]
//// }
////}
const nonRelative = 'import { a } from "a";\n\na;';
const relative = nonRelative.replace('"a"', '"./a"');
goTo.file("/b.ts");
verify.importFixAtPosition([nonRelative]);
verify.importFixAtPosition([nonRelative], undefined, { importModuleSpecifierPreference: "non-relative" });
verify.importFixAtPosition([relative], undefined, { importModuleSpecifierPreference: "relative" });
| {
"end_byte": 628,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/importNameCodeFix_rootDirs.ts"
} |
TypeScript/tests/cases/fourslash/organizeImports15.ts_0_373 | /// <reference path="fourslash.ts" />
// @filename: /a.ts
////export const foo = 1;
// @filename: /b.ts
/////**
//// * Module doc comment
//// *
//// * @module
//// */
////
////// comment 1
////
////// comment 2
////
////import { foo } from "./a";
goTo.file("/b.ts");
verify.organizeImports(
`/**
* Module doc comment
*
* @module
*/
// comment 1
// comment 2
`);
| {
"end_byte": 373,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/organizeImports15.ts"
} |
TypeScript/tests/cases/fourslash/quickInfoDisplayPartsInterface.ts_0_127 | /// <reference path='fourslash.ts'/>
////interface /*1*/i {
////}
////var /*2*/iInstance: /*3*/i;
verify.baselineQuickInfo(); | {
"end_byte": 127,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickInfoDisplayPartsInterface.ts"
} |
TypeScript/tests/cases/fourslash/codeFixAddMissingAttributes9.ts_0_454 | /// <reference path='fourslash.ts' />
// @jsx: preserve
// @filename: foo.tsx
////type A = 'a-' | 'b-';
////type B = 'd' | 'c';
////type C = `${A}${B}`;
////const A = (props: { [K in C]: K }) =>
//// <div {...props}></div>;
////
////const Bar = () =>
//// [|<A></A>|]
verify.codeFix({
index: 0,
description: ts.Diagnostics.Add_missing_attributes.message,
newRangeContent: `<A a-d={"a-d"} a-c={"a-c"} b-d={"b-d"} b-c={"b-c"}></A>`
});
| {
"end_byte": 454,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixAddMissingAttributes9.ts"
} |
TypeScript/tests/cases/fourslash/quickfixImplementInterfaceUnreachableTypeUsesRelativeImport.ts_0_593 | /// <reference path="fourslash.ts" />
// @Filename: class.ts
////export class Class { }
// @Filename: interface.ts
////import { Class } from './class';
////
////export interface Foo {
//// x: Class;
////}
// @Filename: index.ts
////import { Foo } from './interface';
////
////class /*1*/X implements Foo {}
goTo.marker("1");
verify.codeFix({
index: 0,
description: "Implement interface 'Foo'",
newFileContent: {
"/tests/cases/fourslash/index.ts":
`import { Class } from './class';
import { Foo } from './interface';
class X implements Foo {
x: Class;
}`
}
});
| {
"end_byte": 593,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/quickfixImplementInterfaceUnreachableTypeUsesRelativeImport.ts"
} |
TypeScript/tests/cases/fourslash/renameCommentsAndStrings3.ts_0_347 | /// <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"
////}|]
const [rDef, ...ranges] = test.ranges();
verify.baselineRename(ranges[0], { findInComments: true });
| {
"end_byte": 347,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/renameCommentsAndStrings3.ts"
} |
TypeScript/tests/cases/fourslash/completionsSymbolMembers.ts_0_704 | /// <reference path="fourslash.ts" />
////declare const Symbol: (s: string) => symbol;
////const s = Symbol("s");
////interface I { [s]: number };
////declare const i: I;
////i[|./*i*/|];
////
////namespace N { export const s2 = Symbol("s2"); }
////interface J { [N.s2]: number; }
////declare const j: J;
////j[|./*j*/|];
verify.completions(
{
marker: "i",
exact: { name: "s", insertText: "[s]", replacementSpan: test.ranges()[0] },
preferences: { includeInsertTextCompletions: true },
},
{
marker: "j",
exact: { name: "N", insertText: "[N]", replacementSpan: test.ranges()[1] },
preferences: { includeInsertTextCompletions: true },
}
);
| {
"end_byte": 704,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/completionsSymbolMembers.ts"
} |
TypeScript/tests/cases/fourslash/moveToFile_reExports3.ts_0_473 | /// <reference path='fourslash.ts' />
// @module: esnext
//@Filename: /a.ts
////export function foo() { }
////[|export function bar() {}|]
// @Filename: /b.ts
////export function baz() { }
////export * from "./a";
verify.moveToFile({
newFileContents: {
"/a.ts":
`export function foo() { }
`,
"/b.ts":
`export function baz() { }
export function bar() { }
export * from "./a";`,
},
interactiveRefactorArguments: { targetFile: "/b.ts" },
});
| {
"end_byte": 473,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/moveToFile_reExports3.ts"
} |
TypeScript/tests/cases/fourslash/indentationInComments.ts_0_565 | /// <reference path='fourslash.ts' />
//// // /*0_0*/
//// /* /*0_1*/
//// some text /*0_2*/
//// some text /*1_0*/
//// * some text /*0_3*/
//// /*0_4*/
//// */
//// function foo() {
//// // /*4_0*/
//// /** /*4_1*/
//// * /*4_2*/
//// * /*4_3*/
//// /*7_0*/
//// */
//// /* /*4_4*/ */
//// }
for (let i = 0; i < 5; ++i) {
goTo.marker(`0_${i}`);
verify.indentationIs(0);
goTo.marker(`4_${i}`);
verify.indentationIs(4);
}
goTo.marker(`1_0`);
verify.indentationIs(1);
goTo.marker(`7_0`);
verify.indentationIs(7);
| {
"end_byte": 565,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/indentationInComments.ts"
} |
TypeScript/tests/cases/fourslash/esModuleInteropFindAllReferences2.ts_0_384 | /// <reference path="fourslash.ts"/>
// Tests that we don't always add an indirect user, which causes problems if the module is already available globally.
// @esModuleInterop: true
// @Filename: /a.d.ts
////export as namespace abc;
/////*1*/export const /*2*/x: number;
// @Filename: /b.ts
////import a from "./a";
////a./*3*/x;
verify.baselineFindAllReferences('1', '2', '3');
| {
"end_byte": 384,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/esModuleInteropFindAllReferences2.ts"
} |
TypeScript/tests/cases/fourslash/codeFixSpelling_optionalChain.ts_0_249 | /// <reference path="fourslash.ts" />
// @strict: true
////function f(x: string | null) {
//// [|x?.toLowrCase();|]
////}
verify.rangeAfterCodeFix(
`x?.toLowerCase();`,
/*includeWhiteSpace*/ false,
/*errorCode*/ undefined,
/*index*/ 0);
| {
"end_byte": 249,
"start_byte": 0,
"url": "https://github.com/microsoft/TypeScript/blob/main/tests/cases/fourslash/codeFixSpelling_optionalChain.ts"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.