github.com/evanw/esbuild@v0.21.4/internal/bundler_tests/snapshots/snapshots_ts.txt (about) 1 TestEnumRulesFrom_TypeScript_5_0 2 ---------- /out/supported.js ---------- 3 // supported.ts 4 console.log( 5 // a number or string literal, 6 123 /* X0 */, 7 "x" /* X1 */, 8 // a unary +, -, or ~ applied to a numeric constant expression, 9 1 /* X2 */, 10 -2 /* X3 */, 11 -4 /* X4 */, 12 // a binary +, -, *, /, %, **, <<, >>, >>>, |, &, ^ applied to two numeric constant expressions, 13 3 /* X5 */, 14 -1 /* X6 */, 15 6 /* X7 */, 16 0.5 /* X8 */, 17 1 /* X9 */, 18 8 /* X10 */, 19 4 /* X11 */, 20 -5 /* X12 */, 21 2147483643 /* X13 */, 22 13 /* X14 */, 23 4 /* X15 */, 24 9 /* X16 */, 25 // a template expression where each substitution expression is a constant expression, 26 "x0" /* X17 */, 27 "0x" /* X18 */, 28 "xy" /* X19 */, 29 "NaN" /* X20 */, 30 "Infinity" /* X21 */, 31 "-Infinity" /* X22 */, 32 "0" /* X23 */, 33 // a template expression where each substitution expression is a constant expression, 34 "A0BxC-31246D" /* X24 */, 35 // a parenthesized constant expression, 36 321 /* X25 */, 37 // a dotted name that references an enum member with an enum literal type, or 38 123 /* X26 */, 39 "123x" /* X27 */, 40 "x123" /* X28 */, 41 "a123b" /* X29 */, 42 123 /* X30 */, 43 "123x" /* X31 */, 44 "x123" /* X32 */, 45 "a123b" /* X33 */, 46 // a dotted name indexed by a string literal (e.g. x.y["z"]) that references an enum member with an enum literal type." 47 "x" /* X34 */, 48 "xy" /* X35 */, 49 "yx" /* X36 */, 50 "axb" /* X37 */, 51 "x" /* X38 */, 52 "xy" /* X39 */, 53 "yx" /* X40 */, 54 "axb" /* X41 */ 55 ); 56 57 ---------- /out/not-supported.js ---------- 58 // not-supported.ts 59 var NonIntegerNumberToString = ((NonIntegerNumberToString2) => { 60 NonIntegerNumberToString2["SUPPORTED"] = "1"; 61 NonIntegerNumberToString2["UNSUPPORTED"] = "" + 1.5; 62 return NonIntegerNumberToString2; 63 })(NonIntegerNumberToString || {}); 64 console.log( 65 "1" /* SUPPORTED */, 66 NonIntegerNumberToString.UNSUPPORTED 67 ); 68 var OutOfBoundsNumberToString = ((OutOfBoundsNumberToString2) => { 69 OutOfBoundsNumberToString2["SUPPORTED"] = "1000000000"; 70 OutOfBoundsNumberToString2["UNSUPPORTED"] = "" + 1e12; 71 return OutOfBoundsNumberToString2; 72 })(OutOfBoundsNumberToString || {}); 73 console.log( 74 "1000000000" /* SUPPORTED */, 75 OutOfBoundsNumberToString.UNSUPPORTED 76 ); 77 console.log( 78 "null" /* NULL */, 79 "true" /* TRUE */, 80 "false" /* FALSE */, 81 "123" /* BIGINT */ 82 ); 83 84 ================================================================================ 85 TestExportTypeIssue379 86 ---------- /out.js ---------- 87 // a.ts 88 var a_exports = {}; 89 __export(a_exports, { 90 foo: () => foo 91 }); 92 var foo = 123; 93 94 // b.ts 95 var b_exports = {}; 96 __export(b_exports, { 97 foo: () => foo2 98 }); 99 var foo2 = 123; 100 101 // c.ts 102 var c_exports = {}; 103 __export(c_exports, { 104 foo: () => foo3 105 }); 106 var foo3 = 123; 107 108 // d.ts 109 var d_exports = {}; 110 __export(d_exports, { 111 foo: () => foo4 112 }); 113 var foo4 = 123; 114 115 // entry.ts 116 console.log(a_exports, b_exports, c_exports, d_exports); 117 118 ================================================================================ 119 TestTSAbstractClassFieldUseAssign 120 ---------- /out.js ---------- 121 const keepThis = Symbol("keepThis"); 122 keepThis; 123 class Foo { 124 } 125 (() => new Foo())(); 126 127 ================================================================================ 128 TestTSAbstractClassFieldUseDefine 129 ---------- /out.js ---------- 130 const keepThisToo = Symbol("keepThisToo"); 131 class Foo { 132 keepThis; 133 [keepThisToo]; 134 } 135 (() => new Foo())(); 136 137 ================================================================================ 138 TestTSCommonJSVariableInESMTypeModule 139 ---------- /out.js ---------- 140 // entry.ts 141 module.exports = null; 142 143 ================================================================================ 144 TestTSComputedClassFieldUseDefineFalse 145 ---------- /out.js ---------- 146 var _a, _b, _c; 147 q, _c = r, _b = x, _a = y; 148 class Foo { 149 constructor() { 150 this[_c] = s; 151 this[_a] = z; 152 } 153 } 154 __decorateClass([ 155 dec 156 ], Foo.prototype, _b, 2); 157 __decorateClass([ 158 dec 159 ], Foo.prototype, _a, 2); 160 new Foo(); 161 162 ================================================================================ 163 TestTSComputedClassFieldUseDefineTrue 164 ---------- /out.js ---------- 165 var _a, _b; 166 class Foo { 167 [q]; 168 [r] = s; 169 [_b = x]; 170 [_a = y] = z; 171 } 172 __decorateClass([ 173 dec 174 ], Foo.prototype, _b, 2); 175 __decorateClass([ 176 dec 177 ], Foo.prototype, _a, 2); 178 new Foo(); 179 180 ================================================================================ 181 TestTSComputedClassFieldUseDefineTrueLower 182 ---------- /out.js ---------- 183 var _a, _b, _c, _d; 184 _d = q, _c = r, _b = x, _a = y; 185 class Foo { 186 constructor() { 187 __publicField(this, _d); 188 __publicField(this, _c, s); 189 __publicField(this, _b); 190 __publicField(this, _a, z); 191 } 192 } 193 __decorateClass([ 194 dec 195 ], Foo.prototype, _b, 2); 196 __decorateClass([ 197 dec 198 ], Foo.prototype, _a, 2); 199 new Foo(); 200 201 ================================================================================ 202 TestTSConstEnumComments 203 ---------- /out.js ---------- 204 // foo.ts 205 console.log({ 206 "should have comments": [ 207 1 /* %/* */, 208 1 /* %/* */ 209 ], 210 "should not have comments": [ 211 2, 212 2 213 ] 214 }); 215 216 ================================================================================ 217 TestTSDeclareClass 218 ---------- /out.js ---------- 219 // entry.ts 220 var foo = bar(); 221 222 ================================================================================ 223 TestTSDeclareClassFields 224 ---------- /out.js ---------- 225 // define-false/index.ts 226 () => null, c, () => null, C; 227 var Foo = class { 228 }; 229 (() => new Foo())(); 230 231 // define-true/index.ts 232 var _a; 233 var Bar = class { 234 constructor() { 235 __publicField(this, "a"); 236 __publicField(this, _a); 237 } 238 static A; 239 static [(_a = (() => null, c), () => null, C)]; 240 }; 241 (() => new Bar())(); 242 243 ================================================================================ 244 TestTSDeclareConst 245 ---------- /out.js ---------- 246 // entry.ts 247 var foo = bar(); 248 249 ================================================================================ 250 TestTSDeclareConstEnum 251 ---------- /out.js ---------- 252 // entry.ts 253 var foo = bar(); 254 255 ================================================================================ 256 TestTSDeclareEnum 257 ---------- /out.js ---------- 258 // entry.ts 259 var foo = bar(); 260 261 ================================================================================ 262 TestTSDeclareFunction 263 ---------- /out.js ---------- 264 // entry.ts 265 var foo = bar(); 266 267 ================================================================================ 268 TestTSDeclareLet 269 ---------- /out.js ---------- 270 // entry.ts 271 var foo = bar(); 272 273 ================================================================================ 274 TestTSDeclareNamespace 275 ---------- /out.js ---------- 276 // entry.ts 277 var foo = bar(); 278 279 ================================================================================ 280 TestTSDeclareVar 281 ---------- /out.js ---------- 282 // entry.ts 283 var foo = bar(); 284 285 ================================================================================ 286 TestTSEnumCrossModuleInliningAccess 287 ---------- /out/entry.js ---------- 288 // enums.ts 289 var c_num = /* @__PURE__ */ ((c_num2) => { 290 c_num2[c_num2["x"] = 123] = "x"; 291 return c_num2; 292 })(c_num || {}); 293 var d_num = /* @__PURE__ */ ((d_num2) => { 294 d_num2[d_num2["x"] = 123] = "x"; 295 return d_num2; 296 })(d_num || {}); 297 var e_num = /* @__PURE__ */ ((e_num2) => { 298 e_num2[e_num2["x"] = 123] = "x"; 299 return e_num2; 300 })(e_num || {}); 301 var c_str = /* @__PURE__ */ ((c_str2) => { 302 c_str2["x"] = "abc"; 303 return c_str2; 304 })(c_str || {}); 305 var d_str = /* @__PURE__ */ ((d_str2) => { 306 d_str2["x"] = "abc"; 307 return d_str2; 308 })(d_str || {}); 309 var e_str = /* @__PURE__ */ ((e_str2) => { 310 e_str2["x"] = "abc"; 311 return e_str2; 312 })(e_str || {}); 313 314 // entry.ts 315 inlined = [ 316 123 /* x */, 317 123 /* x */, 318 "abc" /* x */, 319 "abc" /* x */ 320 ]; 321 not_inlined = [ 322 c_num?.x, 323 d_num?.["x"], 324 e_num, 325 c_str?.x, 326 d_str?.["x"], 327 e_str 328 ]; 329 330 ================================================================================ 331 TestTSEnumCrossModuleInliningDefinitions 332 ---------- /out/entry.js ---------- 333 // enums.ts 334 var a = ((a2) => { 335 a2[a2["implicit_number"] = 0] = "implicit_number"; 336 a2[a2["explicit_number"] = 123] = "explicit_number"; 337 a2["explicit_string"] = "xyz"; 338 a2[a2["non_constant"] = foo] = "non_constant"; 339 return a2; 340 })(a || {}); 341 342 // entry.ts 343 console.log([ 344 0 /* implicit_number */, 345 123 /* explicit_number */, 346 "xyz" /* explicit_string */, 347 a.non_constant 348 ]); 349 350 ================================================================================ 351 TestTSEnumCrossModuleInliningMinifyIndexIntoDot 352 ---------- /out.js ---------- 353 // entry.ts 354 inlined = [ 355 obj.abc, 356 obj.xyz, 357 obj?.abc, 358 obj?.xyz, 359 obj?.prop.abc, 360 obj?.prop.xyz 361 ]; 362 notInlined = [ 363 obj["a b c" /* foo2 */], 364 obj["x y z" /* bar2 */], 365 obj?.["a b c" /* foo2 */], 366 obj?.["x y z" /* bar2 */], 367 obj?.prop["a b c" /* foo2 */], 368 obj?.prop["x y z" /* bar2 */] 369 ]; 370 371 ================================================================================ 372 TestTSEnumCrossModuleInliningReExport 373 ---------- /out/entry.js ---------- 374 // entry.js 375 console.log([ 376 "a" /* x */, 377 "b" /* x */, 378 "c" /* x */ 379 ]); 380 381 ================================================================================ 382 TestTSEnumCrossModuleTreeShaking 383 ---------- /out/entry.js ---------- 384 // enums.ts 385 var a_keep = /* @__PURE__ */ ((a_keep2) => { 386 a_keep2[a_keep2["x"] = false] = "x"; 387 return a_keep2; 388 })(a_keep || {}); 389 var b_keep = ((b_keep2) => { 390 b_keep2[b_keep2["x"] = foo] = "x"; 391 return b_keep2; 392 })(b_keep || {}); 393 var c_keep = /* @__PURE__ */ ((c_keep2) => { 394 c_keep2[c_keep2["x"] = 3] = "x"; 395 return c_keep2; 396 })(c_keep || {}); 397 var d_keep = /* @__PURE__ */ ((d_keep2) => { 398 d_keep2[d_keep2["x"] = 4] = "x"; 399 return d_keep2; 400 })(d_keep || {}); 401 var e_keep = {}; 402 403 // entry.ts 404 console.log([ 405 1 /* x */, 406 2 /* x */, 407 "" /* x */ 408 ]); 409 console.log([ 410 a_keep.x, 411 b_keep.x, 412 c_keep, 413 d_keep.y, 414 e_keep.x 415 ]); 416 417 ================================================================================ 418 TestTSEnumDefine 419 ---------- /out/entry.js ---------- 420 var a = /* @__PURE__ */ ((a2) => { 421 a2[a2["b"] = 123] = "b"; 422 a2[a2["c"] = 123 /* b */] = "c"; 423 return a2; 424 })(a || {}); 425 426 ================================================================================ 427 TestTSEnumExportClause 428 ---------- /out/entry.js ---------- 429 // entry.ts 430 console.log([ 431 1 /* A */, 432 2 /* B */, 433 3 /* C */, 434 4 /* D */ 435 ]); 436 437 ================================================================================ 438 TestTSEnumJSX 439 ---------- /out/element.js ---------- 440 export var Foo = /* @__PURE__ */ ((Foo2) => { 441 Foo2["Div"] = "div"; 442 return Foo2; 443 })(Foo || {}); 444 console.log(/* @__PURE__ */ React.createElement("div" /* Div */, null)); 445 446 ---------- /out/fragment.js ---------- 447 export var React = /* @__PURE__ */ ((React2) => { 448 React2["Fragment"] = "div"; 449 return React2; 450 })(React || {}); 451 console.log(/* @__PURE__ */ React.createElement("div" /* Fragment */, null, "test")); 452 453 ---------- /out/nested-element.js ---------- 454 var x; 455 ((x2) => { 456 let y; 457 ((y2) => { 458 let Foo; 459 ((Foo2) => { 460 Foo2["Div"] = "div"; 461 })(Foo = y2.Foo || (y2.Foo = {})); 462 })(y = x2.y || (x2.y = {})); 463 })(x || (x = {})); 464 ((x2) => { 465 let y; 466 ((y2) => { 467 console.log(/* @__PURE__ */ React.createElement("div" /* Div */, null)); 468 })(y = x2.y || (x2.y = {})); 469 })(x || (x = {})); 470 471 ---------- /out/nested-fragment.js ---------- 472 var x; 473 ((x2) => { 474 let y; 475 ((y2) => { 476 let React; 477 ((React2) => { 478 React2["Fragment"] = "div"; 479 })(React = y2.React || (y2.React = {})); 480 })(y = x2.y || (x2.y = {})); 481 })(x || (x = {})); 482 ((x2) => { 483 let y; 484 ((y2) => { 485 console.log(/* @__PURE__ */ y2.React.createElement("div" /* Fragment */, null, "test")); 486 })(y = x2.y || (x2.y = {})); 487 })(x || (x = {})); 488 489 ================================================================================ 490 TestTSEnumSameModuleInliningAccess 491 ---------- /out/entry.js ---------- 492 // entry.ts 493 var c_num = /* @__PURE__ */ ((c_num2) => { 494 c_num2[c_num2["x"] = 123] = "x"; 495 return c_num2; 496 })(c_num || {}); 497 var d_num = /* @__PURE__ */ ((d_num2) => { 498 d_num2[d_num2["x"] = 123] = "x"; 499 return d_num2; 500 })(d_num || {}); 501 var e_num = /* @__PURE__ */ ((e_num2) => { 502 e_num2[e_num2["x"] = 123] = "x"; 503 return e_num2; 504 })(e_num || {}); 505 var c_str = /* @__PURE__ */ ((c_str2) => { 506 c_str2["x"] = "abc"; 507 return c_str2; 508 })(c_str || {}); 509 var d_str = /* @__PURE__ */ ((d_str2) => { 510 d_str2["x"] = "abc"; 511 return d_str2; 512 })(d_str || {}); 513 var e_str = /* @__PURE__ */ ((e_str2) => { 514 e_str2["x"] = "abc"; 515 return e_str2; 516 })(e_str || {}); 517 inlined = [ 518 123 /* x */, 519 123 /* x */, 520 "abc" /* x */, 521 "abc" /* x */ 522 ]; 523 not_inlined = [ 524 c_num?.x, 525 d_num?.["x"], 526 e_num, 527 c_str?.x, 528 d_str?.["x"], 529 e_str 530 ]; 531 532 ================================================================================ 533 TestTSEnumTreeShaking 534 ---------- /out/simple-member.js ---------- 535 // simple-member.ts 536 console.log(123 /* y */); 537 538 ---------- /out/simple-enum.js ---------- 539 // simple-enum.ts 540 var x = /* @__PURE__ */ ((x2) => { 541 x2[x2["y"] = 123] = "y"; 542 return x2; 543 })(x || {}); 544 console.log(x); 545 546 ---------- /out/sibling-member.js ---------- 547 // sibling-member.ts 548 console.log(123 /* y */, 246 /* z */); 549 550 ---------- /out/sibling-enum-before.js ---------- 551 // sibling-enum-before.ts 552 console.log(x); 553 var x = /* @__PURE__ */ ((x2) => { 554 x2[x2["y"] = 123] = "y"; 555 return x2; 556 })(x || {}); 557 var x = /* @__PURE__ */ ((x2) => { 558 x2[x2["z"] = 246] = "z"; 559 return x2; 560 })(x || {}); 561 562 ---------- /out/sibling-enum-middle.js ---------- 563 // sibling-enum-middle.ts 564 var x = /* @__PURE__ */ ((x2) => { 565 x2[x2["y"] = 123] = "y"; 566 return x2; 567 })(x || {}); 568 console.log(x); 569 var x = /* @__PURE__ */ ((x2) => { 570 x2[x2["z"] = 246] = "z"; 571 return x2; 572 })(x || {}); 573 574 ---------- /out/sibling-enum-after.js ---------- 575 // sibling-enum-after.ts 576 var x = /* @__PURE__ */ ((x2) => { 577 x2[x2["y"] = 123] = "y"; 578 return x2; 579 })(x || {}); 580 var x = /* @__PURE__ */ ((x2) => { 581 x2[x2["z"] = 246] = "z"; 582 return x2; 583 })(x || {}); 584 console.log(x); 585 586 ---------- /out/namespace-before.js ---------- 587 // namespace-before.ts 588 ((x2) => { 589 console.log(x2, y); 590 })(x || (x = {})); 591 var x = /* @__PURE__ */ ((x2) => { 592 x2[x2["y"] = 123] = "y"; 593 return x2; 594 })(x || {}); 595 596 ---------- /out/namespace-after.js ---------- 597 // namespace-after.ts 598 var x = /* @__PURE__ */ ((x2) => { 599 x2[x2["y"] = 123] = "y"; 600 return x2; 601 })(x || {}); 602 ((x2) => { 603 console.log(x2, y); 604 })(x || (x = {})); 605 606 ================================================================================ 607 TestTSEnumUseBeforeDeclare 608 ---------- /out/entry.js ---------- 609 // entry.ts 610 function before() { 611 console.log(0 /* FOO */); 612 } 613 function after() { 614 console.log(0 /* FOO */); 615 } 616 export { 617 after, 618 before 619 }; 620 621 ================================================================================ 622 TestTSExperimentalDecoratorScopeIssue2147 623 ---------- /out.js ---------- 624 let foo = 1; 625 class Foo { 626 method1(foo2 = 2) { 627 } 628 method2(foo2 = 3) { 629 } 630 } 631 __decorateClass([ 632 __decorateParam(0, dec(foo)) 633 ], Foo.prototype, "method1", 1); 634 __decorateClass([ 635 __decorateParam(0, dec(() => foo)) 636 ], Foo.prototype, "method2", 1); 637 class Bar { 638 static { 639 this.x = class { 640 static { 641 this.y = () => { 642 let bar = 1; 643 let Baz = class { 644 method1() { 645 } 646 method2() { 647 } 648 method3(bar2) { 649 } 650 method4(bar2) { 651 } 652 }; 653 __decorateClass([ 654 dec(bar) 655 ], Baz.prototype, "method1", 1); 656 __decorateClass([ 657 dec(() => bar) 658 ], Baz.prototype, "method2", 1); 659 __decorateClass([ 660 __decorateParam(0, dec(() => bar)) 661 ], Baz.prototype, "method3", 1); 662 __decorateClass([ 663 __decorateParam(0, dec(() => bar)) 664 ], Baz.prototype, "method4", 1); 665 Baz = __decorateClass([ 666 dec(bar), 667 dec(() => bar) 668 ], Baz); 669 return Baz; 670 }; 671 } 672 }; 673 } 674 } 675 676 ================================================================================ 677 TestTSExperimentalDecorators 678 ---------- /out.js ---------- 679 // all.ts 680 var Foo = class { 681 constructor(arg0, arg1) { 682 this.mDef = 1; 683 } 684 method(arg0, arg1) { 685 return new Foo(); 686 } 687 static sMethod(arg0, arg1) { 688 return new Foo(); 689 } 690 }; 691 Foo.sDef = new Foo(); 692 __decorateClass([ 693 x, 694 y 695 ], Foo.prototype, "mUndef", 2); 696 __decorateClass([ 697 x, 698 y 699 ], Foo.prototype, "mDef", 2); 700 __decorateClass([ 701 x, 702 y, 703 __decorateParam(0, x0), 704 __decorateParam(0, y0), 705 __decorateParam(1, x1), 706 __decorateParam(1, y1) 707 ], Foo.prototype, "method", 1); 708 __decorateClass([ 709 x, 710 y 711 ], Foo.prototype, "mDecl", 2); 712 __decorateClass([ 713 x, 714 y 715 ], Foo.prototype, "mAbst", 2); 716 __decorateClass([ 717 x, 718 y 719 ], Foo, "sUndef", 2); 720 __decorateClass([ 721 x, 722 y 723 ], Foo, "sDef", 2); 724 __decorateClass([ 725 x, 726 y, 727 __decorateParam(0, x0), 728 __decorateParam(0, y0), 729 __decorateParam(1, x1), 730 __decorateParam(1, y1) 731 ], Foo, "sMethod", 1); 732 __decorateClass([ 733 x, 734 y 735 ], Foo, "mDecl", 2); 736 Foo = __decorateClass([ 737 x.y(), 738 new y.x(), 739 __decorateParam(0, x0), 740 __decorateParam(0, y0), 741 __decorateParam(1, x1), 742 __decorateParam(1, y1) 743 ], Foo); 744 745 // all_computed.ts 746 var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; 747 var Foo2 = class { 748 constructor() { 749 this[_j] = 1; 750 this[_f] = 2; 751 } 752 [(_k = mUndef(), _j = mDef(), _i = method())](arg0, arg1) { 753 return new Foo2(); 754 } 755 static [(_h = mDecl(), _g = mAbst(), xUndef(), _f = xDef(), yUndef(), _e = yDef(), _d = sUndef(), _c = sDef(), _b = sMethod(), _a = mDecl(), _b)](arg0, arg1) { 756 return new Foo2(); 757 } 758 }; 759 Foo2[_e] = 3; 760 Foo2[_c] = new Foo2(); 761 __decorateClass([ 762 x, 763 y 764 ], Foo2.prototype, _k, 2); 765 __decorateClass([ 766 x, 767 y 768 ], Foo2.prototype, _j, 2); 769 __decorateClass([ 770 x, 771 y, 772 __decorateParam(0, x0), 773 __decorateParam(0, y0), 774 __decorateParam(1, x1), 775 __decorateParam(1, y1) 776 ], Foo2.prototype, _i, 1); 777 __decorateClass([ 778 x, 779 y 780 ], Foo2.prototype, _h, 2); 781 __decorateClass([ 782 x, 783 y 784 ], Foo2.prototype, _g, 2); 785 __decorateClass([ 786 x, 787 y 788 ], Foo2, _d, 2); 789 __decorateClass([ 790 x, 791 y 792 ], Foo2, _c, 2); 793 __decorateClass([ 794 x, 795 y, 796 __decorateParam(0, x0), 797 __decorateParam(0, y0), 798 __decorateParam(1, x1), 799 __decorateParam(1, y1) 800 ], Foo2, _b, 1); 801 __decorateClass([ 802 x, 803 y 804 ], Foo2, _a, 2); 805 Foo2 = __decorateClass([ 806 x?.[_ + "y"](), 807 new y?.[_ + "x"]() 808 ], Foo2); 809 810 // a.ts 811 var a_class = class { 812 fn() { 813 return new a_class(); 814 } 815 }; 816 a_class.z = new a_class(); 817 a_class = __decorateClass([ 818 x(() => 0), 819 y(() => 1) 820 ], a_class); 821 var a = a_class; 822 823 // b.ts 824 var b_class = class { 825 fn() { 826 return new b_class(); 827 } 828 }; 829 b_class.z = new b_class(); 830 b_class = __decorateClass([ 831 x(() => 0), 832 y(() => 1) 833 ], b_class); 834 var b = b_class; 835 836 // c.ts 837 var c = class { 838 fn() { 839 return new c(); 840 } 841 }; 842 c.z = new c(); 843 c = __decorateClass([ 844 x(() => 0), 845 y(() => 1) 846 ], c); 847 848 // d.ts 849 var d = class { 850 fn() { 851 return new d(); 852 } 853 }; 854 d.z = new d(); 855 d = __decorateClass([ 856 x(() => 0), 857 y(() => 1) 858 ], d); 859 860 // e.ts 861 var e_default = class { 862 }; 863 e_default = __decorateClass([ 864 x(() => 0), 865 y(() => 1) 866 ], e_default); 867 868 // f.ts 869 var f = class { 870 fn() { 871 return new f(); 872 } 873 }; 874 f.z = new f(); 875 f = __decorateClass([ 876 x(() => 0), 877 y(() => 1) 878 ], f); 879 880 // g.ts 881 var g_default = class { 882 }; 883 g_default = __decorateClass([ 884 x(() => 0), 885 y(() => 1) 886 ], g_default); 887 888 // h.ts 889 var h = class { 890 fn() { 891 return new h(); 892 } 893 }; 894 h.z = new h(); 895 h = __decorateClass([ 896 x(() => 0), 897 y(() => 1) 898 ], h); 899 900 // i.ts 901 var i_class = class { 902 }; 903 __decorateClass([ 904 x(() => 0), 905 y(() => 1) 906 ], i_class.prototype, "foo", 2); 907 var i = i_class; 908 909 // j.ts 910 var j = class { 911 foo() { 912 } 913 }; 914 __decorateClass([ 915 x(() => 0), 916 y(() => 1) 917 ], j.prototype, "foo", 1); 918 919 // k.ts 920 var k_default = class { 921 foo(x2) { 922 } 923 }; 924 __decorateClass([ 925 __decorateParam(0, x(() => 0)), 926 __decorateParam(0, y(() => 1)) 927 ], k_default.prototype, "foo", 1); 928 929 // arguments.ts 930 function dec(x2) { 931 } 932 function fn(x2) { 933 var _a2; 934 class Foo3 { 935 [_a2 = arguments[0]]() { 936 } 937 } 938 __decorateClass([ 939 dec(arguments[0]) 940 ], Foo3.prototype, _a2, 1); 941 return Foo3; 942 } 943 944 // entry.js 945 console.log(Foo, Foo2, a, b, c, d, e_default, f, g_default, h, i, j, k_default, fn); 946 947 ================================================================================ 948 TestTSExperimentalDecoratorsKeepNames 949 ---------- /out.js ---------- 950 // entry.ts 951 var Foo = class { 952 }; 953 __name(Foo, "Foo"); 954 Foo = __decorateClass([ 955 decoratorMustComeAfterName 956 ], Foo); 957 export { 958 Foo 959 }; 960 961 ================================================================================ 962 TestTSExperimentalDecoratorsManglePropsAssignSemantics 963 ---------- /out.js ---------- 964 // entry.ts 965 var Foo = class { 966 constructor() { 967 this.prop1 = null; 968 this.a = null; 969 this["prop3"] = null; 970 this["prop4_"] = null; 971 this[/* @__KEY__ */ "prop5"] = null; 972 this.b = null; 973 } 974 }; 975 __decorateClass([ 976 dec(1) 977 ], Foo.prototype, "prop1", 2); 978 __decorateClass([ 979 dec(2) 980 ], Foo.prototype, "a", 2); 981 __decorateClass([ 982 dec(3) 983 ], Foo.prototype, "prop3", 2); 984 __decorateClass([ 985 dec(4) 986 ], Foo.prototype, "prop4_", 2); 987 __decorateClass([ 988 dec(5) 989 ], Foo.prototype, /* @__KEY__ */ "prop5", 2); 990 __decorateClass([ 991 dec(6) 992 ], Foo.prototype, /* @__KEY__ */ "b", 2); 993 994 ================================================================================ 995 TestTSExperimentalDecoratorsManglePropsDefineSemantics 996 ---------- /out.js ---------- 997 // entry.ts 998 var Foo = class { 999 prop1 = null; 1000 a = null; 1001 ["prop3"] = null; 1002 ["prop4_"] = null; 1003 [/* @__KEY__ */ "prop5"] = null; 1004 [/* @__KEY__ */ "b"] = null; 1005 }; 1006 __decorateClass([ 1007 dec(1) 1008 ], Foo.prototype, "prop1", 2); 1009 __decorateClass([ 1010 dec(2) 1011 ], Foo.prototype, "a", 2); 1012 __decorateClass([ 1013 dec(3) 1014 ], Foo.prototype, "prop3", 2); 1015 __decorateClass([ 1016 dec(4) 1017 ], Foo.prototype, "prop4_", 2); 1018 __decorateClass([ 1019 dec(5) 1020 ], Foo.prototype, /* @__KEY__ */ "prop5", 2); 1021 __decorateClass([ 1022 dec(6) 1023 ], Foo.prototype, /* @__KEY__ */ "b", 2); 1024 1025 ================================================================================ 1026 TestTSExperimentalDecoratorsManglePropsMethods 1027 ---------- /out.js ---------- 1028 // entry.ts 1029 var Foo = class { 1030 prop1() { 1031 } 1032 a() { 1033 } 1034 ["prop3"]() { 1035 } 1036 ["prop4_"]() { 1037 } 1038 [/* @__KEY__ */ "prop5"]() { 1039 } 1040 [/* @__KEY__ */ "b"]() { 1041 } 1042 }; 1043 __decorateClass([ 1044 dec(1) 1045 ], Foo.prototype, "prop1", 1); 1046 __decorateClass([ 1047 dec(2) 1048 ], Foo.prototype, "a", 1); 1049 __decorateClass([ 1050 dec(3) 1051 ], Foo.prototype, "prop3", 1); 1052 __decorateClass([ 1053 dec(4) 1054 ], Foo.prototype, "prop4_", 1); 1055 __decorateClass([ 1056 dec(5) 1057 ], Foo.prototype, /* @__KEY__ */ "prop5", 1); 1058 __decorateClass([ 1059 dec(6) 1060 ], Foo.prototype, /* @__KEY__ */ "b", 1); 1061 1062 ================================================================================ 1063 TestTSExperimentalDecoratorsManglePropsStaticAssignSemantics 1064 ---------- /out.js ---------- 1065 // entry.ts 1066 var Foo = class { 1067 static { 1068 this.prop1 = null; 1069 } 1070 static { 1071 this.a = null; 1072 } 1073 static { 1074 this["prop3"] = null; 1075 } 1076 static { 1077 this["prop4_"] = null; 1078 } 1079 static { 1080 this[/* @__KEY__ */ "prop5"] = null; 1081 } 1082 static { 1083 this.b = null; 1084 } 1085 }; 1086 __decorateClass([ 1087 dec(1) 1088 ], Foo, "prop1", 2); 1089 __decorateClass([ 1090 dec(2) 1091 ], Foo, "a", 2); 1092 __decorateClass([ 1093 dec(3) 1094 ], Foo, "prop3", 2); 1095 __decorateClass([ 1096 dec(4) 1097 ], Foo, "prop4_", 2); 1098 __decorateClass([ 1099 dec(5) 1100 ], Foo, /* @__KEY__ */ "prop5", 2); 1101 __decorateClass([ 1102 dec(6) 1103 ], Foo, /* @__KEY__ */ "b", 2); 1104 1105 ================================================================================ 1106 TestTSExperimentalDecoratorsManglePropsStaticDefineSemantics 1107 ---------- /out.js ---------- 1108 // entry.ts 1109 var Foo = class { 1110 static prop1 = null; 1111 static a = null; 1112 static ["prop3"] = null; 1113 static ["prop4_"] = null; 1114 static [/* @__KEY__ */ "prop5"] = null; 1115 static [/* @__KEY__ */ "b"] = null; 1116 }; 1117 __decorateClass([ 1118 dec(1) 1119 ], Foo, "prop1", 2); 1120 __decorateClass([ 1121 dec(2) 1122 ], Foo, "a", 2); 1123 __decorateClass([ 1124 dec(3) 1125 ], Foo, "prop3", 2); 1126 __decorateClass([ 1127 dec(4) 1128 ], Foo, "prop4_", 2); 1129 __decorateClass([ 1130 dec(5) 1131 ], Foo, /* @__KEY__ */ "prop5", 2); 1132 __decorateClass([ 1133 dec(6) 1134 ], Foo, /* @__KEY__ */ "b", 2); 1135 1136 ================================================================================ 1137 TestTSExperimentalDecoratorsManglePropsStaticMethods 1138 ---------- /out.js ---------- 1139 // entry.ts 1140 var Foo = class { 1141 static prop1() { 1142 } 1143 static a() { 1144 } 1145 static ["prop3"]() { 1146 } 1147 static ["prop4_"]() { 1148 } 1149 static [/* @__KEY__ */ "prop5"]() { 1150 } 1151 static [/* @__KEY__ */ "b"]() { 1152 } 1153 }; 1154 __decorateClass([ 1155 dec(1) 1156 ], Foo, "prop1", 1); 1157 __decorateClass([ 1158 dec(2) 1159 ], Foo, "a", 1); 1160 __decorateClass([ 1161 dec(3) 1162 ], Foo, "prop3", 1); 1163 __decorateClass([ 1164 dec(4) 1165 ], Foo, "prop4_", 1); 1166 __decorateClass([ 1167 dec(5) 1168 ], Foo, /* @__KEY__ */ "prop5", 1); 1169 __decorateClass([ 1170 dec(6) 1171 ], Foo, /* @__KEY__ */ "b", 1); 1172 1173 ================================================================================ 1174 TestTSExperimentalDecoratorsNoConfig 1175 ---------- /out.js ---------- 1176 // entry.ts 1177 var Foo = @x.y() @(new y.x()) class _Foo { 1178 @x @y mUndef; 1179 @x @y mDef = 1; 1180 @x @y method() { 1181 return new _Foo(); 1182 } 1183 @x @y accessor aUndef; 1184 @x @y accessor aDef = 1; 1185 @x @y static sUndef; 1186 @x @y static sDef = new _Foo(); 1187 @x @y static sMethod() { 1188 return new _Foo(); 1189 } 1190 @x @y static accessor asUndef; 1191 @x @y static accessor asDef = 1; 1192 @x @y #mUndef; 1193 @x @y #mDef = 1; 1194 @x @y #method() { 1195 return new _Foo(); 1196 } 1197 @x @y accessor #aUndef; 1198 @x @y accessor #aDef = 1; 1199 @x @y static #sUndef; 1200 @x @y static #sDef = 1; 1201 @x @y static #sMethod() { 1202 return new _Foo(); 1203 } 1204 @x @y static accessor #asUndef; 1205 @x @y static accessor #asDef = 1; 1206 }; 1207 export { 1208 Foo as default 1209 }; 1210 1211 ================================================================================ 1212 TestTSExportDefaultTypeIssue316 1213 ---------- /out.js ---------- 1214 // keep/declare-class.ts 1215 var declare_class_default = foo; 1216 var bar = 123; 1217 1218 // keep/declare-let.ts 1219 var declare_let_default = foo; 1220 var bar2 = 123; 1221 1222 // keep/interface-merged.ts 1223 var foo2 = class _foo { 1224 static { 1225 this.x = new _foo(); 1226 } 1227 }; 1228 var interface_merged_default = foo2; 1229 var bar3 = 123; 1230 1231 // keep/interface-nested.ts 1232 if (true) { 1233 } 1234 var interface_nested_default = foo; 1235 var bar4 = 123; 1236 1237 // keep/type-nested.ts 1238 if (true) { 1239 } 1240 var type_nested_default = foo; 1241 var bar5 = 123; 1242 1243 // keep/value-namespace.ts 1244 var foo3; 1245 ((foo5) => { 1246 foo5.num = 0; 1247 })(foo3 || (foo3 = {})); 1248 var value_namespace_default = foo3; 1249 var bar6 = 123; 1250 1251 // keep/value-namespace-merged.ts 1252 var foo4; 1253 ((foo5) => { 1254 foo5.num = 0; 1255 })(foo4 || (foo4 = {})); 1256 var value_namespace_merged_default = foo4; 1257 var bar7 = 123; 1258 1259 // remove/interface.ts 1260 var bar8 = 123; 1261 1262 // remove/interface-exported.ts 1263 var bar9 = 123; 1264 1265 // remove/type.ts 1266 var bar10 = 123; 1267 1268 // remove/type-exported.ts 1269 var bar11 = 123; 1270 1271 // remove/type-only-namespace.ts 1272 var bar12 = 123; 1273 1274 // remove/type-only-namespace-exported.ts 1275 var bar13 = 123; 1276 1277 // entry.ts 1278 var entry_default = [ 1279 declare_class_default, 1280 bar, 1281 declare_let_default, 1282 bar2, 1283 interface_merged_default, 1284 bar3, 1285 interface_nested_default, 1286 bar4, 1287 type_nested_default, 1288 bar5, 1289 value_namespace_default, 1290 bar6, 1291 value_namespace_merged_default, 1292 bar7, 1293 bar8, 1294 bar9, 1295 bar10, 1296 bar11, 1297 bar12, 1298 bar13 1299 ]; 1300 export { 1301 entry_default as default 1302 }; 1303 1304 ================================================================================ 1305 TestTSExportEquals 1306 ---------- /out.js ---------- 1307 // b.ts 1308 var require_b = __commonJS({ 1309 "b.ts"(exports, module) { 1310 function foo() { 1311 } 1312 module.exports = [123, foo]; 1313 } 1314 }); 1315 1316 // a.ts 1317 var import_b = __toESM(require_b()); 1318 console.log(import_b.default); 1319 1320 ================================================================================ 1321 TestTSExportMissingES6 1322 ---------- /out.js ---------- 1323 // foo.ts 1324 var foo_exports = {}; 1325 1326 // entry.js 1327 console.log(foo_exports); 1328 1329 ================================================================================ 1330 TestTSExportNamespace 1331 ---------- /out.js ---------- 1332 // b.ts 1333 var Foo = class { 1334 }; 1335 ((Foo2) => { 1336 Foo2.foo = 1; 1337 })(Foo || (Foo = {})); 1338 ((Foo2) => { 1339 Foo2.bar = 2; 1340 })(Foo || (Foo = {})); 1341 1342 // a.ts 1343 console.log(new Foo()); 1344 1345 ================================================================================ 1346 TestTSImplicitExtensions 1347 ---------- /out.js ---------- 1348 // pick-js.js 1349 console.log("correct"); 1350 1351 // pick-ts.ts 1352 console.log("correct"); 1353 1354 // pick-jsx.jsx 1355 console.log("correct"); 1356 1357 // pick-tsx.tsx 1358 console.log("correct"); 1359 1360 // order-js.ts 1361 console.log("correct"); 1362 1363 // order-jsx.ts 1364 console.log("correct"); 1365 1366 // node_modules/pkg/foo-js.ts 1367 console.log("correct"); 1368 1369 // node_modules/pkg/foo-jsx.tsx 1370 console.log("correct"); 1371 1372 // node_modules/pkg-exports/abc-js.ts 1373 console.log("correct"); 1374 1375 // node_modules/pkg-exports/abc-jsx.tsx 1376 console.log("correct"); 1377 1378 // node_modules/pkg-exports/lib/foo-js.ts 1379 console.log("correct"); 1380 1381 // node_modules/pkg-exports/lib/foo-jsx.tsx 1382 console.log("correct"); 1383 1384 // node_modules/pkg-imports/abc-js.ts 1385 console.log("correct"); 1386 1387 // node_modules/pkg-imports/abc-jsx.tsx 1388 console.log("correct"); 1389 1390 // node_modules/pkg-imports/lib/foo-js.ts 1391 console.log("correct"); 1392 1393 // node_modules/pkg-imports/lib/foo-jsx.tsx 1394 console.log("correct"); 1395 1396 ================================================================================ 1397 TestTSImportCTS 1398 ---------- /out.js ---------- 1399 // required.cjs 1400 var require_required = __commonJS({ 1401 "required.cjs"() { 1402 console.log("works"); 1403 } 1404 }); 1405 1406 // entry.ts 1407 require_required(); 1408 1409 ================================================================================ 1410 TestTSImportEmptyNamespace 1411 ---------- /out.js ---------- 1412 // entry.ts 1413 function foo() { 1414 } 1415 foo(); 1416 1417 ================================================================================ 1418 TestTSImportEqualsBundle 1419 ---------- /out.js ---------- 1420 // entry.ts 1421 import { foo } from "pkg"; 1422 var used = foo.used; 1423 export { 1424 used 1425 }; 1426 1427 ================================================================================ 1428 TestTSImportEqualsEliminationTest 1429 ---------- /out.js ---------- 1430 // entry.ts 1431 var a = foo.a; 1432 var b = a.b; 1433 var c = b.c; 1434 var bar = c; 1435 export { 1436 bar 1437 }; 1438 1439 ================================================================================ 1440 TestTSImportEqualsTreeShakingFalse 1441 ---------- /out.js ---------- 1442 import { foo } from "pkg"; 1443 const used = foo.used; 1444 export { used }; 1445 1446 ================================================================================ 1447 TestTSImportEqualsTreeShakingTrue 1448 ---------- /out.js ---------- 1449 import { foo } from "pkg"; 1450 const used = foo.used; 1451 export { used }; 1452 1453 ================================================================================ 1454 TestTSImportEqualsUndefinedImport 1455 ---------- /out.js ---------- 1456 // import.ts 1457 var value = 123; 1458 1459 // entry.ts 1460 var value_copy = value; 1461 var foo = value_copy; 1462 console.log(foo); 1463 1464 ================================================================================ 1465 TestTSImportInNodeModulesNameCollisionWithCSS 1466 ---------- /out.js ---------- 1467 // node_modules/pkg/js_ts_css.js 1468 function js_ts_css_default() { 1469 } 1470 1471 // node_modules/pkg/ts_css.ts 1472 function ts_css_default() { 1473 } 1474 1475 // node_modules/pkg/js_ts.js 1476 function js_ts_default() { 1477 } 1478 1479 // node_modules/pkg/index.ts 1480 js_ts_css_default(); 1481 ts_css_default(); 1482 js_ts_default(); 1483 1484 ---------- /out.css ---------- 1485 /* node_modules/pkg/js_ts_css.css */ 1486 .js_ts_css { 1487 } 1488 1489 /* node_modules/pkg/ts_css.css */ 1490 .ts_css { 1491 } 1492 1493 ================================================================================ 1494 TestTSImportMTS 1495 ---------- /out.js ---------- 1496 // imported.mts 1497 console.log("works"); 1498 1499 ================================================================================ 1500 TestTSImportMissingUnusedES6 1501 ---------- /out.js ---------- 1502 1503 ================================================================================ 1504 TestTSImportTypeOnlyFile 1505 ---------- /out.js ---------- 1506 // entry.ts 1507 var foo = bar(); 1508 1509 ================================================================================ 1510 TestTSImportVsLocalCollisionAllTypes 1511 ---------- /out.js ---------- 1512 // entry.ts 1513 var a; 1514 var b = 0; 1515 var c; 1516 function d() { 1517 } 1518 var e = class { 1519 }; 1520 console.log(a, b, c, d, e); 1521 1522 ================================================================================ 1523 TestTSImportVsLocalCollisionMixed 1524 ---------- /out.js ---------- 1525 // other.ts 1526 var real = 123; 1527 1528 // entry.ts 1529 var a; 1530 var b = 0; 1531 var c; 1532 function d() { 1533 } 1534 var e = class { 1535 }; 1536 console.log(a, b, c, d, e, real); 1537 1538 ================================================================================ 1539 TestTSMinifiedBundleCommonJS 1540 ---------- /out.js ---------- 1541 var t=e(r=>{r.foo=function(){return 123}});var n=e((l,c)=>{c.exports={test:!0}});var{foo:f}=t();console.log(f(),n()); 1542 1543 ================================================================================ 1544 TestTSMinifiedBundleES6 1545 ---------- /out.js ---------- 1546 function o(){return 123}console.log(o()); 1547 1548 ================================================================================ 1549 TestTSMinifyDerivedClass 1550 ---------- /out.js ---------- 1551 class Foo extends Bar { 1552 constructor() { 1553 super(); 1554 this.foo = 1; 1555 this.bar = 2; 1556 foo(), bar(); 1557 } 1558 } 1559 1560 ================================================================================ 1561 TestTSMinifyEnum 1562 ---------- /a.js ---------- 1563 var Foo=(e=>(e[e.A=0]="A",e[e.B=1]="B",e[e.C=e]="C",e))(Foo||{}); 1564 1565 ---------- /b.js ---------- 1566 export var Foo=(e=>(e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=e]="Z",e))(Foo||{}); 1567 1568 ================================================================================ 1569 TestTSMinifyEnumCrossFileInlineStringsIntoTemplates 1570 ---------- /out.js ---------- 1571 // entry.ts 1572 console.log(` 1573 SameFile.STR = str 1 1574 SameFile.NUM = 123 1575 CrossFile.STR = str 2 1576 CrossFile.NUM = 321 1577 `); 1578 1579 ================================================================================ 1580 TestTSMinifyEnumPropertyNames 1581 ---------- /out.js ---------- 1582 // entry.ts 1583 var Foo = class { 1584 100 = 100; 1585 200 = 200; 1586 300 = 300; 1587 "str 1" = "str 1" /* STR */; 1588 123 = 123 /* NUM */; 1589 "str 2" = "str 2" /* STR */; 1590 321 = 321 /* NUM */; 1591 }; 1592 shouldNotBeComputed( 1593 class { 1594 100 = 100; 1595 200 = 200; 1596 300 = 300; 1597 "str 1" = "str 1" /* STR */; 1598 123 = 123 /* NUM */; 1599 "str 2" = "str 2" /* STR */; 1600 321 = 321 /* NUM */; 1601 }, 1602 { 1603 100: 100, 1604 200: 200, 1605 300: 300, 1606 "str 1": "str 1" /* STR */, 1607 123: 123 /* NUM */, 1608 "str 2": "str 2" /* STR */, 1609 321: 321 /* NUM */ 1610 } 1611 ); 1612 mustBeComputed( 1613 { ["__proto__"]: null }, 1614 { ["__proto__"]: null }, 1615 class { 1616 ["constructor"]() { 1617 } 1618 }, 1619 class { 1620 ["constructor"]() { 1621 } 1622 }, 1623 class { 1624 static ["prototype"]() { 1625 } 1626 }, 1627 class { 1628 static ["prototype"]() { 1629 } 1630 } 1631 ); 1632 1633 ================================================================================ 1634 TestTSMinifyNamespace 1635 ---------- /a.js ---------- 1636 var Foo;(e=>{let a;(p=>foo(e,p))(a=e.Bar||={})})(Foo||={}); 1637 1638 ---------- /b.js ---------- 1639 export var Foo;(e=>{let a;(p=>foo(e,p))(a=e.Bar||={})})(Foo||={}); 1640 1641 ================================================================================ 1642 TestTSMinifyNamespaceNoArrow 1643 ---------- /a.js ---------- 1644 var Foo;(function(e){let a;(function(p){foo(e,p)})(a=e.Bar||={})})(Foo||={}); 1645 1646 ---------- /b.js ---------- 1647 export var Foo;(function(e){let a;(function(p){foo(e,p)})(a=e.Bar||={})})(Foo||={}); 1648 1649 ================================================================================ 1650 TestTSMinifyNamespaceNoLogicalAssignment 1651 ---------- /a.js ---------- 1652 var Foo;(e=>{let a;(p=>foo(e,p))(a=e.Bar||(e.Bar={}))})(Foo||(Foo={})); 1653 1654 ---------- /b.js ---------- 1655 export var Foo;(e=>{let a;(p=>foo(e,p))(a=e.Bar||(e.Bar={}))})(Foo||(Foo={})); 1656 1657 ================================================================================ 1658 TestTSMinifyNestedEnum 1659 ---------- /a.js ---------- 1660 function foo(){let u;return(n=>(n[n.A=0]="A",n[n.B=1]="B",n[n.C=n]="C"))(u||={}),u} 1661 1662 ---------- /b.js ---------- 1663 export function foo(){let e;return(n=>(n[n.X=0]="X",n[n.Y=1]="Y",n[n.Z=n]="Z"))(e||={}),e} 1664 1665 ================================================================================ 1666 TestTSMinifyNestedEnumNoArrow 1667 ---------- /a.js ---------- 1668 function foo(){let u;return function(n){n[n.A=0]="A",n[n.B=1]="B",n[n.C=n]="C"}(u||={}),u} 1669 1670 ---------- /b.js ---------- 1671 export function foo(){let e;return function(n){n[n.X=0]="X",n[n.Y=1]="Y",n[n.Z=n]="Z"}(e||={}),e} 1672 1673 ================================================================================ 1674 TestTSMinifyNestedEnumNoLogicalAssignment 1675 ---------- /a.js ---------- 1676 function foo(){let u;return(n=>(n[n.A=0]="A",n[n.B=1]="B",n[n.C=n]="C"))(u||(u={})),u} 1677 1678 ---------- /b.js ---------- 1679 export function foo(){let e;return(n=>(n[n.X=0]="X",n[n.Y=1]="Y",n[n.Z=n]="Z"))(e||(e={})),e} 1680 1681 ================================================================================ 1682 TestTSNamespaceKeepNames 1683 ---------- /out.js ---------- 1684 // entry.ts 1685 var ns; 1686 ((ns2) => { 1687 ns2.foo = /* @__PURE__ */ __name(() => { 1688 }, "foo"); 1689 function bar() { 1690 } 1691 ns2.bar = bar; 1692 __name(bar, "bar"); 1693 class Baz { 1694 static { 1695 __name(this, "Baz"); 1696 } 1697 } 1698 ns2.Baz = Baz; 1699 })(ns || (ns = {})); 1700 1701 ================================================================================ 1702 TestTSNamespaceKeepNamesTargetES2015 1703 ---------- /out.js ---------- 1704 // entry.ts 1705 var ns; 1706 ((ns2) => { 1707 ns2.foo = /* @__PURE__ */ __name(() => { 1708 }, "foo"); 1709 function bar() { 1710 } 1711 ns2.bar = bar; 1712 __name(bar, "bar"); 1713 const _Baz = class _Baz { 1714 }; 1715 __name(_Baz, "Baz"); 1716 let Baz = _Baz; 1717 ns2.Baz = _Baz; 1718 })(ns || (ns = {})); 1719 1720 ================================================================================ 1721 TestTSPreferJSOverTSInsideNodeModules 1722 ---------- /out/main.js ---------- 1723 // Users/user/project/src/relative/path.ts 1724 console.log("success"); 1725 1726 // Users/user/project/node_modules/package/path.js 1727 console.log("success"); 1728 1729 // Users/user/project/src/relative2/path.js 1730 console.log("success"); 1731 1732 // Users/user/project/node_modules/package2/path.js 1733 console.log("success"); 1734 1735 ================================================================================ 1736 TestTSPrintNonFiniteNumberInsideWith 1737 ---------- /out.js ---------- 1738 var Foo = /* @__PURE__ */ ((Foo2) => { 1739 Foo2[Foo2["NAN"] = NaN] = "NAN"; 1740 Foo2[Foo2["POS_INF"] = Infinity] = "POS_INF"; 1741 Foo2[Foo2["NEG_INF"] = -Infinity] = "NEG_INF"; 1742 return Foo2; 1743 })(Foo || {}); 1744 //! It's ok to use "NaN" and "Infinity" here 1745 console.log( 1746 NaN /* NAN */, 1747 Infinity /* POS_INF */, 1748 -Infinity /* NEG_INF */ 1749 ); 1750 checkPrecedence( 1751 1 / NaN /* NAN */, 1752 1 / Infinity /* POS_INF */, 1753 1 / -Infinity /* NEG_INF */ 1754 ); 1755 //! We must not use "NaN" or "Infinity" inside "with" 1756 with (x) { 1757 console.log( 1758 0 / 0 /* NAN */, 1759 1 / 0 /* POS_INF */, 1760 -1 / 0 /* NEG_INF */ 1761 ); 1762 checkPrecedence( 1763 1 / (0 / 0) /* NAN */, 1764 1 / (1 / 0) /* POS_INF */, 1765 1 / (-1 / 0) /* NEG_INF */ 1766 ); 1767 } 1768 1769 ================================================================================ 1770 TestTSSiblingEnum 1771 ---------- /out/number.js ---------- 1772 export var x = /* @__PURE__ */ ((x2) => { 1773 x2[x2["y"] = 0] = "y"; 1774 x2[x2["yy"] = 0 /* y */] = "yy"; 1775 return x2; 1776 })(x || {}); 1777 var x = /* @__PURE__ */ ((x2) => { 1778 x2[x2["z"] = 1] = "z"; 1779 return x2; 1780 })(x || {}); 1781 ((x2) => { 1782 console.log(y, z); 1783 })(x || (x = {})); 1784 console.log(0 /* y */, 1 /* z */); 1785 1786 ---------- /out/string.js ---------- 1787 export var x = /* @__PURE__ */ ((x2) => { 1788 x2["y"] = "a"; 1789 x2["yy"] = "a" /* y */; 1790 return x2; 1791 })(x || {}); 1792 var x = /* @__PURE__ */ ((x2) => { 1793 x2["z"] = "a" /* y */; 1794 return x2; 1795 })(x || {}); 1796 ((x2) => { 1797 console.log(y, z); 1798 })(x || (x = {})); 1799 console.log("a" /* y */, "a" /* z */); 1800 1801 ---------- /out/propagation.js ---------- 1802 export var a = /* @__PURE__ */ ((a2) => { 1803 a2[a2["b"] = 100] = "b"; 1804 return a2; 1805 })(a || {}); 1806 export var x = /* @__PURE__ */ ((x2) => { 1807 x2[x2["c"] = 100 /* b */] = "c"; 1808 x2[x2["d"] = 200] = "d"; 1809 x2[x2["e"] = 4e4] = "e"; 1810 x2[x2["f"] = 1e4] = "f"; 1811 return x2; 1812 })(x || {}); 1813 var x = /* @__PURE__ */ ((x2) => { 1814 x2[x2["g"] = 625] = "g"; 1815 return x2; 1816 })(x || {}); 1817 console.log(100 /* b */, 100 /* b */, 625 /* g */, 625 /* g */); 1818 1819 ---------- /out/nested-number.js ---------- 1820 export var foo; 1821 ((foo2) => { 1822 let x; 1823 ((x2) => { 1824 x2[x2["y"] = 0] = "y"; 1825 x2[x2["yy"] = 0 /* y */] = "yy"; 1826 })(x = foo2.x || (foo2.x = {})); 1827 })(foo || (foo = {})); 1828 ((foo2) => { 1829 let x; 1830 ((x2) => { 1831 x2[x2["z"] = 1] = "z"; 1832 })(x = foo2.x || (foo2.x = {})); 1833 })(foo || (foo = {})); 1834 ((foo2) => { 1835 let x; 1836 ((x2) => { 1837 console.log(y, z); 1838 console.log(0 /* y */, 1 /* z */); 1839 })(x = foo2.x || (foo2.x = {})); 1840 })(foo || (foo = {})); 1841 1842 ---------- /out/nested-string.js ---------- 1843 export var foo; 1844 ((foo2) => { 1845 let x; 1846 ((x2) => { 1847 x2["y"] = "a"; 1848 x2["yy"] = "a" /* y */; 1849 })(x = foo2.x || (foo2.x = {})); 1850 })(foo || (foo = {})); 1851 ((foo2) => { 1852 let x; 1853 ((x2) => { 1854 x2["z"] = "a" /* y */; 1855 })(x = foo2.x || (foo2.x = {})); 1856 })(foo || (foo = {})); 1857 ((foo2) => { 1858 let x; 1859 ((x2) => { 1860 console.log(y, z); 1861 console.log("a" /* y */, "a" /* z */); 1862 })(x = foo2.x || (foo2.x = {})); 1863 })(foo || (foo = {})); 1864 1865 ---------- /out/nested-propagation.js ---------- 1866 export var n; 1867 ((n2) => { 1868 let a; 1869 ((a2) => { 1870 a2[a2["b"] = 100] = "b"; 1871 })(a = n2.a || (n2.a = {})); 1872 })(n || (n = {})); 1873 ((n2) => { 1874 let x; 1875 ((x2) => { 1876 x2[x2["c"] = 100 /* b */] = "c"; 1877 x2[x2["d"] = 200] = "d"; 1878 x2[x2["e"] = 4e4] = "e"; 1879 x2[x2["f"] = 1e4] = "f"; 1880 })(x = n2.x || (n2.x = {})); 1881 })(n || (n = {})); 1882 ((n2) => { 1883 let x; 1884 ((x2) => { 1885 x2[x2["g"] = 625] = "g"; 1886 })(x = n2.x || (n2.x = {})); 1887 console.log(100 /* b */, 100 /* b */, 100 /* b */, 625 /* g */, 625 /* g */, 625 /* g */); 1888 })(n || (n = {})); 1889 1890 ================================================================================ 1891 TestTSSiblingNamespace 1892 ---------- /out/let.js ---------- 1893 export var x; 1894 ((x2) => { 1895 x2.y = 123; 1896 })(x || (x = {})); 1897 ((x2) => { 1898 x2.z = x2.y; 1899 })(x || (x = {})); 1900 1901 ---------- /out/function.js ---------- 1902 export var x; 1903 ((x2) => { 1904 function y() { 1905 } 1906 x2.y = y; 1907 })(x || (x = {})); 1908 ((x2) => { 1909 x2.z = x2.y; 1910 })(x || (x = {})); 1911 1912 ---------- /out/class.js ---------- 1913 export var x; 1914 ((x2) => { 1915 class y { 1916 } 1917 x2.y = y; 1918 })(x || (x = {})); 1919 ((x2) => { 1920 x2.z = x2.y; 1921 })(x || (x = {})); 1922 1923 ---------- /out/namespace.js ---------- 1924 export var x; 1925 ((x2) => { 1926 let y; 1927 ((y2) => { 1928 0; 1929 })(y = x2.y || (x2.y = {})); 1930 })(x || (x = {})); 1931 ((x2) => { 1932 x2.z = x2.y; 1933 })(x || (x = {})); 1934 1935 ---------- /out/enum.js ---------- 1936 export var x; 1937 ((x2) => { 1938 let y; 1939 ((y2) => { 1940 })(y = x2.y || (x2.y = {})); 1941 })(x || (x = {})); 1942 ((x2) => { 1943 x2.z = x2.y; 1944 })(x || (x = {})); 1945 1946 ================================================================================ 1947 TestTSSideEffectsFalseWarningTypeDeclarations 1948 ---------- /out.js ---------- 1949 1950 ================================================================================ 1951 TestTSThisIsUndefinedWarning 1952 ---------- /out/warning1.js ---------- 1953 // warning1.ts 1954 var foo = void 0; 1955 export { 1956 foo 1957 }; 1958 1959 ---------- /out/warning2.js ---------- 1960 // warning2.ts 1961 var foo = (void 0).foo; 1962 export { 1963 foo 1964 }; 1965 1966 ---------- /out/warning3.js ---------- 1967 // warning3.ts 1968 var foo = void 0 ? (void 0).foo : null; 1969 export { 1970 foo 1971 }; 1972 1973 ---------- /out/silent1.js ---------- 1974 // silent1.ts 1975 var foo = void 0; 1976 export { 1977 foo 1978 }; 1979 1980 ---------- /out/silent2.js ---------- 1981 // silent2.ts 1982 var foo = void 0; 1983 export { 1984 foo 1985 }; 1986 1987 ================================================================================ 1988 TestThisInsideFunctionTS 1989 ---------- /out.js ---------- 1990 // entry.ts 1991 function foo(x = this) { 1992 console.log(this); 1993 } 1994 var objFoo = { 1995 foo(x = this) { 1996 console.log(this); 1997 } 1998 }; 1999 var Foo = class { 2000 constructor() { 2001 this.x = this; 2002 } 2003 static { 2004 this.y = this.z; 2005 } 2006 foo(x = this) { 2007 console.log(this); 2008 } 2009 static bar(x = this) { 2010 console.log(this); 2011 } 2012 }; 2013 new Foo(foo(objFoo)); 2014 if (nested) { 2015 let bar = function(x = this) { 2016 console.log(this); 2017 }; 2018 bar2 = bar; 2019 const objBar = { 2020 foo(x = this) { 2021 console.log(this); 2022 } 2023 }; 2024 class Bar { 2025 constructor() { 2026 this.x = this; 2027 } 2028 static { 2029 this.y = this.z; 2030 } 2031 foo(x = this) { 2032 console.log(this); 2033 } 2034 static bar(x = this) { 2035 console.log(this); 2036 } 2037 } 2038 new Bar(bar(objBar)); 2039 } 2040 var bar2; 2041 2042 ================================================================================ 2043 TestThisInsideFunctionTSNoBundle 2044 ---------- /out.js ---------- 2045 function foo(x = this) { 2046 console.log(this); 2047 } 2048 const objFoo = { 2049 foo(x = this) { 2050 console.log(this); 2051 } 2052 }; 2053 class Foo { 2054 constructor() { 2055 this.x = this; 2056 } 2057 static { 2058 this.y = this.z; 2059 } 2060 foo(x = this) { 2061 console.log(this); 2062 } 2063 static bar(x = this) { 2064 console.log(this); 2065 } 2066 } 2067 new Foo(foo(objFoo)); 2068 if (nested) { 2069 let bar2 = function(x = this) { 2070 console.log(this); 2071 }; 2072 var bar = bar2; 2073 const objBar = { 2074 foo(x = this) { 2075 console.log(this); 2076 } 2077 }; 2078 class Bar { 2079 constructor() { 2080 this.x = this; 2081 } 2082 static { 2083 this.y = this.z; 2084 } 2085 foo(x = this) { 2086 console.log(this); 2087 } 2088 static bar(x = this) { 2089 console.log(this); 2090 } 2091 } 2092 new Bar(bar2(objBar)); 2093 } 2094 2095 ================================================================================ 2096 TestThisInsideFunctionTSNoBundleUseDefineForClassFields 2097 ---------- /out.js ---------- 2098 function foo(x = this) { 2099 console.log(this); 2100 } 2101 const objFoo = { 2102 foo(x = this) { 2103 console.log(this); 2104 } 2105 }; 2106 class Foo { 2107 x = this; 2108 static y = this.z; 2109 foo(x = this) { 2110 console.log(this); 2111 } 2112 static bar(x = this) { 2113 console.log(this); 2114 } 2115 } 2116 new Foo(foo(objFoo)); 2117 if (nested) { 2118 let bar2 = function(x = this) { 2119 console.log(this); 2120 }; 2121 var bar = bar2; 2122 const objBar = { 2123 foo(x = this) { 2124 console.log(this); 2125 } 2126 }; 2127 class Bar { 2128 x = this; 2129 static y = this.z; 2130 foo(x = this) { 2131 console.log(this); 2132 } 2133 static bar(x = this) { 2134 console.log(this); 2135 } 2136 } 2137 new Bar(bar2(objBar)); 2138 } 2139 2140 ================================================================================ 2141 TestThisInsideFunctionTSUseDefineForClassFields 2142 ---------- /out.js ---------- 2143 // entry.ts 2144 function foo(x = this) { 2145 console.log(this); 2146 } 2147 var objFoo = { 2148 foo(x = this) { 2149 console.log(this); 2150 } 2151 }; 2152 var Foo = class { 2153 x = this; 2154 static y = this.z; 2155 foo(x = this) { 2156 console.log(this); 2157 } 2158 static bar(x = this) { 2159 console.log(this); 2160 } 2161 }; 2162 new Foo(foo(objFoo)); 2163 if (nested) { 2164 let bar = function(x = this) { 2165 console.log(this); 2166 }; 2167 bar2 = bar; 2168 const objBar = { 2169 foo(x = this) { 2170 console.log(this); 2171 } 2172 }; 2173 class Bar { 2174 x = this; 2175 static y = this.z; 2176 foo(x = this) { 2177 console.log(this); 2178 } 2179 static bar(x = this) { 2180 console.log(this); 2181 } 2182 } 2183 new Bar(bar(objBar)); 2184 } 2185 var bar2;