diff --git a/crates/swc/tests/errors/module/esnext/import-assign/input.ts b/crates/swc/tests/errors/module/esnext/import-assign/input.ts index 971be600fb5cb..f7985661358f9 100644 --- a/crates/swc/tests/errors/module/esnext/import-assign/input.ts +++ b/crates/swc/tests/errors/module/esnext/import-assign/input.ts @@ -1,3 +1,8 @@ import homura = require("homura"); export import madoka = require("madoka"); + + + +// avoid unused import be stripped +export { homura }; diff --git a/crates/swc/tests/errors/module/esnext/import-assign/output.swc-stderr b/crates/swc/tests/errors/module/esnext/import-assign/output.swc-stderr index 18708ce67df2b..5ccaa6bfae163 100644 --- a/crates/swc/tests/errors/module/esnext/import-assign/output.swc-stderr +++ b/crates/swc/tests/errors/module/esnext/import-assign/output.swc-stderr @@ -13,4 +13,6 @@ 2 | 3 | export import madoka = require("madoka"); : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 4 | + 5 | `---- diff --git a/crates/swc/tests/fixture/issues-1xxx/1515/case1/output/index.ts b/crates/swc/tests/fixture/issues-1xxx/1515/case1/output/index.ts index 221442743588c..2e5e64a2e0815 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1515/case1/output/index.ts +++ b/crates/swc/tests/fixture/issues-1xxx/1515/case1/output/index.ts @@ -16,7 +16,7 @@ class ServiceError extends Error { _define_property._(this, "name", "ServiceError.BadResponse"); } } -(function(ServiceError1) { +(function(ServiceError) { let Code; (function(Code) { Code[Code["serviceNotFound"] = 404] = "serviceNotFound"; @@ -26,7 +26,7 @@ class ServiceError extends Error { Code[Code["timedOut"] = 504] = "timedOut"; Code[Code["badRequest"] = 400] = "badRequest"; Code[Code["badResponse"] = 422] = "badResponse"; - })(Code = ServiceError1.Code || (ServiceError1.Code = {})); + })(Code = ServiceError.Code || (ServiceError.Code = {})); class ServiceNotFound extends ServiceError { constructor(...args){ super(...args); @@ -35,11 +35,11 @@ class ServiceError extends Error { _define_property._(this, "name", "ServiceError.ServiceNotFound"); } } - ServiceError1.ServiceNotFound = ServiceNotFound; + ServiceError.ServiceNotFound = ServiceNotFound; function toMessageBody(error) { return { code: ServiceError.Code.implementation }; } - ServiceError1.toMessageBody = toMessageBody; + ServiceError.toMessageBody = toMessageBody; })(ServiceError || (ServiceError = {})); diff --git a/crates/swc/tests/fixture/issues-2xxx/2423/output/index.map b/crates/swc/tests/fixture/issues-2xxx/2423/output/index.map index f6ea20a45ff72..7ba6bf780d84e 100644 --- a/crates/swc/tests/fixture/issues-2xxx/2423/output/index.map +++ b/crates/swc/tests/fixture/issues-2xxx/2423/output/index.map @@ -1,5 +1,5 @@ { - "mappings": ";AAAA,IAAUA;;QACOC,MAAAA,IAAI;IACV,SAASC;QACZC,QAAQC,GAAG,CAACH;IAChB;MAFgBC,IAAAA;GAFVF,MAAAA", + "mappings": ";;UAAUA;IACC,MAAMC,MAAAA,IAAI;IACV,SAASC;QACZC,QAAQC,GAAG,CAACH;IAChB;MAFgBC,IAAAA;AAGpB,GALUF,MAAAA", "names": [ "A", "v", diff --git a/crates/swc/tests/fixture/issues-2xxx/2423/output/index.ts b/crates/swc/tests/fixture/issues-2xxx/2423/output/index.ts index f8b89d8565132..69321d20b5ec9 100644 --- a/crates/swc/tests/fixture/issues-2xxx/2423/output/index.ts +++ b/crates/swc/tests/fixture/issues-2xxx/2423/output/index.ts @@ -1,7 +1,7 @@ "use strict"; var A; (function(A) { - var v = A.v = 25; + const v = A.v = 25; function a() { console.log(v); } diff --git a/crates/swc/tests/fixture/issues-3xxx/3073/1/output/index.ts b/crates/swc/tests/fixture/issues-3xxx/3073/1/output/index.ts index 5583a26af79c4..b2870519f826f 100644 --- a/crates/swc/tests/fixture/issues-3xxx/3073/1/output/index.ts +++ b/crates/swc/tests/fixture/issues-3xxx/3073/1/output/index.ts @@ -1,7 +1,7 @@ var n; (function(n) { var ref; - ref = { + var a = (ref = { a: 1 - }, n.a = ref.a, ref; + }, n.a = ref.a, ref).a; })(n || (n = {})); diff --git a/crates/swc/tests/fixture/issues-3xxx/3073/2/output/index.ts b/crates/swc/tests/fixture/issues-3xxx/3073/2/output/index.ts index 954ea553b8638..abd877a028a4b 100644 --- a/crates/swc/tests/fixture/issues-3xxx/3073/2/output/index.ts +++ b/crates/swc/tests/fixture/issues-3xxx/3073/2/output/index.ts @@ -1,8 +1,8 @@ var Foo; (function(Foo) { var ref; - ref = { + var _ref = (ref = { a: 1, b: 2 - }, Foo.A = ref.a, Foo.B = ref.b, ref; + }, Foo.A = ref.a, Foo.B = ref.b, ref), A = _ref.a, B = _ref.b; })(Foo || (Foo = {})); diff --git a/crates/swc/tests/fixture/issues-3xxx/3686/1/output/index.ts b/crates/swc/tests/fixture/issues-3xxx/3686/1/output/index.ts index 69fc8dbf3e47b..caf42498806f7 100644 --- a/crates/swc/tests/fixture/issues-3xxx/3686/1/output/index.ts +++ b/crates/swc/tests/fixture/issues-3xxx/3686/1/output/index.ts @@ -21,7 +21,7 @@ _ts_decorate._([ ServiceError = _ts_decorate._([ CD ], ServiceError); -(function(ServiceError1) { +(function(ServiceError) { let Code; (function(Code) { Code[Code["serviceNotFound"] = 404] = "serviceNotFound"; @@ -31,17 +31,17 @@ ServiceError = _ts_decorate._([ Code[Code["timedOut"] = 504] = "timedOut"; Code[Code["badRequest"] = 400] = "badRequest"; Code[Code["badResponse"] = 422] = "badResponse"; - })(Code = ServiceError1.Code || (ServiceError1.Code = {})); + })(Code = ServiceError.Code || (ServiceError.Code = {})); class ServiceNotFound extends ServiceError { // Service was probably not registered, or using the wrong channel code = 404; name = "ServiceError.ServiceNotFound"; } - ServiceError1.ServiceNotFound = ServiceNotFound; + ServiceError.ServiceNotFound = ServiceNotFound; function toMessageBody(error) { return { code: ServiceError.Code.implementation }; } - ServiceError1.toMessageBody = toMessageBody; + ServiceError.toMessageBody = toMessageBody; })(ServiceError || (ServiceError = {})); diff --git a/crates/swc/tests/fixture/issues-4xxx/4108/1/output/index.ts b/crates/swc/tests/fixture/issues-4xxx/4108/1/output/index.ts index 13384f275217a..542f2016a22c4 100644 --- a/crates/swc/tests/fixture/issues-4xxx/4108/1/output/index.ts +++ b/crates/swc/tests/fixture/issues-4xxx/4108/1/output/index.ts @@ -120,7 +120,7 @@ function _sendTransactionsWithManualRetry() { case 4: return [ 4, - sendTransactions(connection, wallet, instructions, filteredSigners, SequenceType.StopOnFailure, "single") + sendTransactions(connection, wallet, instructions, filteredSigners, 2, "single") ]; case 5: txs = _state.sent().txs; @@ -196,7 +196,7 @@ export var sendTransactions = function() { connection: connection, signedTransaction: signedTxns[i1] }); - if (!(sequenceType !== SequenceType.Parallel)) return [ + if (!(sequenceType !== 1)) return [ 3, 7 ]; @@ -227,7 +227,7 @@ export var sendTransactions = function() { console.log("Failed at txn index:", i1); console.log("Caught failure:", e); failCallback(signedTxns[i1], i1); - if (!(sequenceType === SequenceType.StopOnFailure)) return [ + if (!(sequenceType === 2)) return [ 3, 5 ]; @@ -264,7 +264,7 @@ export var sendTransactions = function() { } }); }; - sequenceType = _arguments.length > 4 && _arguments[4] !== void 0 ? _arguments[4] : SequenceType.Parallel, commitment = _arguments.length > 5 && _arguments[5] !== void 0 ? _arguments[5] : "singleGossip", successCallback = _arguments.length > 6 && _arguments[6] !== void 0 ? _arguments[6] : function(txid, ind) {}, failCallback = _arguments.length > 7 && _arguments[7] !== void 0 ? _arguments[7] : function(txid, ind) { + sequenceType = _arguments.length > 4 && _arguments[4] !== void 0 ? _arguments[4] : 1, commitment = _arguments.length > 5 && _arguments[5] !== void 0 ? _arguments[5] : "singleGossip", successCallback = _arguments.length > 6 && _arguments[6] !== void 0 ? _arguments[6] : function(txid, ind) {}, failCallback = _arguments.length > 7 && _arguments[7] !== void 0 ? _arguments[7] : function(txid, ind) { return false; }, block = _arguments.length > 8 ? _arguments[8] : void 0, beforeTransactions = _arguments.length > 9 && _arguments[9] !== void 0 ? _arguments[9] : [], afterTransactions = _arguments.length > 10 && _arguments[10] !== void 0 ? _arguments[10] : []; if (!wallet.publicKey) throw new WalletNotConnectedError(); @@ -327,7 +327,7 @@ export var sendTransactions = function() { 4 ]; case 7: - if (!(sequenceType !== SequenceType.Parallel)) return [ + if (!(sequenceType !== 1)) return [ 3, 9 ]; diff --git a/crates/swc/tests/fixture/issues-4xxx/4897/output/index.ts b/crates/swc/tests/fixture/issues-4xxx/4897/output/index.ts index ef7c37972f827..2e64e0f237122 100644 --- a/crates/swc/tests/fixture/issues-4xxx/4897/output/index.ts +++ b/crates/swc/tests/fixture/issues-4xxx/4897/output/index.ts @@ -22,6 +22,6 @@ define([ } var Foo; (function(Foo) { - var Bar = Foo.Bar = 1234; + const Bar = Foo.Bar = 1234; })(Foo || (Foo = {})); }); diff --git a/crates/swc/tests/fixture/issues-4xxx/4988/output/index.ts b/crates/swc/tests/fixture/issues-4xxx/4988/output/index.ts index a36f35f12a5b5..faa3538451e4f 100644 --- a/crates/swc/tests/fixture/issues-4xxx/4988/output/index.ts +++ b/crates/swc/tests/fixture/issues-4xxx/4988/output/index.ts @@ -10,4 +10,4 @@ Object.defineProperty(exports, "flakySuite", { }); const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard"); const _testUtils = /*#__PURE__*/ _interop_require_wildcard._(require("vs/base/test/common/testUtils")); -var flakySuite = _testUtils.flakySuite; +const flakySuite = _testUtils.flakySuite; diff --git a/crates/swc/tests/fixture/issues-6xxx/6791/1/output/input.ts b/crates/swc/tests/fixture/issues-6xxx/6791/1/output/input.ts index 2ad0bccdc1a05..d1e887b6b58e1 100644 --- a/crates/swc/tests/fixture/issues-6xxx/6791/1/output/input.ts +++ b/crates/swc/tests/fixture/issues-6xxx/6791/1/output/input.ts @@ -1,3 +1,3 @@ -var l; -import { test as o } from "test"; -(l || (l = {})).Hello = "World!", o(l.Hello); +var o; +import { test as r } from "test"; +(o || (o = {})).Hello = "World!", r("World!"); diff --git a/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.d.ts b/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.d.ts index 91db346f08744..957cf93822d19 100644 --- a/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.d.ts +++ b/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/async/index.d.ts @@ -13,4 +13,16 @@ * * @param size Size of the ID. The default size is 21. * @returns A promise with a random string. + */ /** + * Generate an array of random bytes collected from hardware noise. + * + * ```js + * import { random } from 'nanoid/async' + * random(5).then(bytes => { + * bytes //=> [10, 67, 212, 67, 89] + * }) + * ``` + * + * @param bytes Size of the array. + * @returns A promise with a random bytes array. */ export { }; diff --git a/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.d.ts b/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.d.ts index 1e4cce9c52d31..604cc919fad57 100644 --- a/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.d.ts +++ b/crates/swc/tests/fixture/jsc-paths/vercel-site/1/output/node_modules/.pnpm/nanoid@4.0.2/node_modules/nanoid/non-secure/index.d.ts @@ -9,4 +9,18 @@ * * @param size Size of the ID. The default size is 21. * @returns A random string. + */ /** + * Generate a unique ID based on a custom alphabet. + * This method uses the non-secure predictable random generator + * with bigger collision probability. + * + * @param alphabet Alphabet used to generate the ID. + * @param defaultSize Size of the ID. The default size is 21. + * @returns A random string generator. + * + * ```js + * import { customAlphabet } from 'nanoid/non-secure' + * const nanoid = customAlphabet('0123456789абвгдеё', 5) + * model.id = //=> "8ё56а" + * ``` */ export { }; diff --git a/crates/swc/tests/fixture/sourcemap/011/output/CommentControlller.map b/crates/swc/tests/fixture/sourcemap/011/output/CommentControlller.map index d0b9f76175c33..8ae6cebc95b9f 100644 --- a/crates/swc/tests/fixture/sourcemap/011/output/CommentControlller.map +++ b/crates/swc/tests/fixture/sourcemap/011/output/CommentControlller.map @@ -1,5 +1,5 @@ { - "mappings": ";;;AAAA,SAASA,IAAI,EAAEC,UAAU,EAAEC,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAEC,SAAS,EAAEC,eAAe,QAAQ,iBAAiB;AAElG,SACIC,wBAAwB,EACxBC,uBAAuB,EACvBC,uBAAuB,QACpB,gCAAgC;AACvC,SAASC,kCAAkC,QAAQ,0DAA0D;AAC7G,SAASC,OAAO,QAAQ,wCAAwC;AAChE,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,YAAY,QAAQ,mCAAmC;AAChE,SAASC,IAAI,QAAQ,mCAAmC;AACxD,SAASA,QAAQC,QAAQ,QAAQ,kCAAkC;AACnE,SAASC,gBAAgB,QAAQ,uCAAuC;AAIxE,WAAaC,oBAAN;IACHC,YAAoBC,eAAgC;8BAAhCA;IAAkC;IAI/CC,cACH,AAAaC,EAAU,EACvB,AAAQC,gBAAkC,EAC1C,AAAQC,IAAc,EACxB;QACE,OAAO,IAAI,CAACJ,cAAc,CAACK,MAAM,CAACH,IAAIC,kBAAkBC,KAAKF,EAAE;IACnE;IAIOI,cAAc,AAAaJ,EAAU,EAAE,AAAQE,IAAc,EAAE;QAClE,OAAO,IAAI,CAACJ,cAAc,CAACO,MAAM,CAACL,IAAIE,KAAKF,EAAE;IACjD;AACJ;;IAfKhB,UAAUQ;IACVT,IAAIK;IAEAN,aAAAA,MAAM;IACNH,aAAAA;IACAc,aAAAA;;;;eADyB,4CAAA;eACZ,oCAAA;;GARTG;;IAaRZ,UAAUQ;IACVX,OAAOM;IACcL,aAAAA,MAAM;IAAmBW,aAAAA;;;;eAAa,oCAAA;;GAfnDG;AAAAA;IAFZhB,WAAWM;IACXD,gBAAgBI,mCAAmCC;;;eAEZ,0CAAA;;GAD3BM", + "mappings": ";;;AAAA,SAASA,IAAI,EAAEC,UAAU,EAAEC,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAEC,SAAS,EAAEC,eAAe,QAAQ,iBAAiB;AAElG,SACIC,wBAAwB,EACxBC,uBAAuB,EACvBC,uBAAuB,QACpB,gCAAgC;AACvC,SAASC,kCAAkC,QAAQ,0DAA0D;AAC7G,SAASC,OAAO,QAAQ,wCAAwC;AAChE,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,YAAY,QAAQ,mCAAmC;AAChE,SAASC,IAAI,QAAQ,mCAAmC;AACxD,SAASA,QAAQC,QAAQ,QAAQ,kCAAkC;AACnE,SAASC,gBAAgB,QAAQ,uCAAuC;AAIxE,WAAaC,oBAAN;IACHC,YAAY,AAAQC,cAA8B,CAAE;aAAhCA,iBAAAA;IAAkC;IAI/CC,cACH,AAAaC,EAAU,EACvB,AAAQC,gBAAkC,EAC1C,AAAQC,IAAc,EACxB;QACE,OAAO,IAAI,CAACJ,cAAc,CAACK,MAAM,CAACH,IAAIC,kBAAkBC,KAAKF,EAAE;IACnE;IAIOI,cAAc,AAAaJ,EAAU,EAAE,AAAQE,IAAc,EAAE;QAClE,OAAO,IAAI,CAACJ,cAAc,CAACO,MAAM,CAACL,IAAIE,KAAKF,EAAE;IACjD;AACJ;;IAfKhB,UAAUQ;IACVT,IAAIK;IAEAN,aAAAA,MAAM;IACNH,aAAAA;IACAc,aAAAA;;;;eADyB,4CAAA;eACZ,oCAAA;;GARTG;;IAaRZ,UAAUQ;IACVX,OAAOM;IACcL,aAAAA,MAAM;IAAmBW,aAAAA;;;;eAAa,oCAAA;;GAfnDG;AAAAA;IAFZhB,WAAWM;IACXD,gBAAgBI,mCAAmCC;;;eAEZ,0CAAA;;GAD3BM", "names": [ "Body", "Controller", diff --git a/crates/swc/tests/fixture/sourcemap/012/output/CommentService.map b/crates/swc/tests/fixture/sourcemap/012/output/CommentService.map index e5374a8c5a3a2..d07a937673cf6 100644 --- a/crates/swc/tests/fixture/sourcemap/012/output/CommentService.map +++ b/crates/swc/tests/fixture/sourcemap/012/output/CommentService.map @@ -1,5 +1,5 @@ { - "mappings": ";;;AAAA,SAASA,KAAK,EAAEC,cAAcC,kBAAkB,QAAQ,WAAW;AACnE,SACEC,kBAAkB,EAClBC,UAAU,EACVC,4BAA4B,EAC5BC,iBAAiB,QACZ,iBAAiB;AACxB,SAASC,WAAW,EAAEC,gBAAgB,QAAQ,mBAAmB;AAEjE,SAASC,OAAO,QAAyB,wCAAwC;AAGjF,SAASC,IAAI,QAAsB,kCAAkC;AAGrE,WAAaC,iBAAN;IACLC,YACqCC,cACHC,WACKC,WACrC;4BAHmCF;yBACHC;0BACKC;IACpC;IAEH,MAAMC,QAAQC,SAAiB,EAA4B;QACzD,MAAMC,UAAU,MAAM,IAAI,CAACL,YAAY,CAACM,QAAQ,CAACF;QAEjD,IAAI,CAACC,SAAS;YACZ,MAAM,IAAIZ;QACZ;QAEA,OAAOY,QAAQE,QAAQ,CAAC;IAC1B;IAEA,MAAMC,OACJH,OAAyB,EACzBI,MAAc,EACdC,MAAc,EACY;QAC1B,MAAMC,UAAU,MAAM,IAAI,CAACT,UAAU,CAACU,YAAY;QAElDD,QAAQE,gBAAgB;QAExB,IAAI;YACF,MAAMC,iBAAiB,MAAM,IAAI,CAACd,YAAY,CAACQ,MAAM,CAAC;gBACpD,GAAGH,OAAO;gBACVU,QAAQL;gBACRD;YACF;YAEA,IAAI,CAACK,gBAAgB;gBACnB,MAAM,IAAItB,6BAA6B;YACzC;YAEA,MAAM,EAAEwB,aAAa,EAAE,GAAG,MAAM,IAAI,CAACf,SAAS,CAACgB,SAAS,CACtD;gBAAEC,KAAKJ,eAAeL,MAAM;YAAC,GAC7B;gBACEU,OAAO;oBAAEC,UAAUN,eAAeO,EAAE;gBAAC;YACvC,GACA;gBAAEC,kBAAkB;YAAM;YAG5B,IAAIN,kBAAkB,GAAG;gBACvB,MAAM,IAAIxB,6BAA6B;YACzC;YAEA,MAAMmB,QAAQY,iBAAiB;YAE/B,OAAOT,eAAeP,QAAQ,CAAC;QACjC,EAAE,OAAOiB,OAAO;YACd,MAAMb,QAAQc,gBAAgB;YAE9B,MAAMD;QACR,SAAU;YACRb,QAAQe,UAAU;QACpB;IACF;IAEA,MAAMC,OACJvB,SAAiB,EACjBC,OAAyB,EACzBK,MAAc,EACY;QAC1B,MAAM,EAAEK,MAAM,EAAE,GAAG,MAAM,IAAI,CAACZ,OAAO,CAACC;QAEtC,IAAIW,OAAOM,EAAE,KAAKX,QAAQ;YACxB,MAAM,IAAIpB;QACZ;QAEA,MAAMsC,iBAAiB,MAAM,IAAI,CAAC5B,YAAY,CAAC6B,iBAAiB,CAACzB,WAAWC,SAAS;YACnFyB,KAAK;QACP;QAEA,IAAI,CAACF,gBAAgB;YACnB,MAAM,IAAIpC,6BAA6B;QACzC;QAEA,OAAOoC,eAAerB,QAAQ,CAAC;IACjC;IAEA,MAAMwB,OAAO3B,SAAiB,EAAEM,MAAc,EAAiB;QAC7D,MAAMC,UAAU,MAAM,IAAI,CAACT,UAAU,CAACU,YAAY;QAElDD,QAAQE,gBAAgB;QAExB,IAAI;YACF,MAAM,EAAEE,MAAM,EAAEN,MAAM,EAAE,GAAG,MAAM,IAAI,CAACN,OAAO,CAACC;YAE9C,IAAIW,OAAOM,EAAE,KAAKX,QAAQ;gBACxB,MAAM,IAAIpB;YACZ;YAEA,MAAM,EAAE0C,YAAY,EAAE,GAAG,MAAM,IAAI,CAAChC,YAAY,CAACiC,SAAS,CAAC;gBAAEf,KAAKd;YAAU;YAE5E,MAAM,EAAEY,aAAa,EAAE,GAAG,MAAM,IAAI,CAACf,SAAS,CAACgB,SAAS,CACtD;gBAAEC,KAAKT;YAAO,GACd;gBACEyB,OAAO;oBAAEd,UAAUhB;gBAAU;YAC/B,GACA;gBAAEkB,kBAAkB;YAAM;YAG5B,IAAIU,iBAAiB,KAAKhB,kBAAkB,GAAG;gBAC7C,MAAM,IAAIxB,6BAA6B;YACzC;YAEA,MAAMmB,QAAQY,iBAAiB;QACjC,EAAE,OAAOC,OAAO;YACd,MAAMb,QAAQc,gBAAgB;YAE9B,MAAMD;QACR,SAAU;YACRb,QAAQe,UAAU;QACpB;IACF;AACF;AAtHa5B;IADZP;IAGIG,aAAAA,YAAYE,QAAQuC,IAAI;IACxBzC,aAAAA,YAAYG,KAAKsC,IAAI;IACrBxC,aAAAA;;;eAFgD,iCAAA;eACN,iCAAA;eACM,8CAAA;;GAJxCG", + "mappings": ";;;AAAA,SAASA,KAAK,EAAEC,cAAcC,kBAAkB,QAAQ,WAAW;AACnE,SACEC,kBAAkB,EAClBC,UAAU,EACVC,4BAA4B,EAC5BC,iBAAiB,QACZ,iBAAiB;AACxB,SAASC,WAAW,EAAEC,gBAAgB,QAAQ,mBAAmB;AAEjE,SAASC,OAAO,QAAyB,wCAAwC;AAGjF,SAASC,IAAI,QAAsB,kCAAkC;AAGrE,WAAaC,iBAAN;IACLC,YACE,AAAmCC,YAAoC,EACvE,AAAgCC,SAA8B,EAC9D,AAAqCC,UAA8B,CACnE;aAHmCF,eAAAA;aACHC,YAAAA;aACKC,aAAAA;IACpC;IAEH,MAAMC,QAAQC,SAAiB,EAA4B;QACzD,MAAMC,UAAU,MAAM,IAAI,CAACL,YAAY,CAACM,QAAQ,CAACF;QAEjD,IAAI,CAACC,SAAS;YACZ,MAAM,IAAIZ;QACZ;QAEA,OAAOY,QAAQE,QAAQ,CAAC;IAC1B;IAEA,MAAMC,OACJH,OAAyB,EACzBI,MAAc,EACdC,MAAc,EACY;QAC1B,MAAMC,UAAU,MAAM,IAAI,CAACT,UAAU,CAACU,YAAY;QAElDD,QAAQE,gBAAgB;QAExB,IAAI;YACF,MAAMC,iBAAiB,MAAM,IAAI,CAACd,YAAY,CAACQ,MAAM,CAAC;gBACpD,GAAGH,OAAO;gBACVU,QAAQL;gBACRD;YACF;YAEA,IAAI,CAACK,gBAAgB;gBACnB,MAAM,IAAItB,6BAA6B;YACzC;YAEA,MAAM,EAAEwB,aAAa,EAAE,GAAG,MAAM,IAAI,CAACf,SAAS,CAACgB,SAAS,CACtD;gBAAEC,KAAKJ,eAAeL,MAAM;YAAC,GAC7B;gBACEU,OAAO;oBAAEC,UAAUN,eAAeO,EAAE;gBAAC;YACvC,GACA;gBAAEC,kBAAkB;YAAM;YAG5B,IAAIN,kBAAkB,GAAG;gBACvB,MAAM,IAAIxB,6BAA6B;YACzC;YAEA,MAAMmB,QAAQY,iBAAiB;YAE/B,OAAOT,eAAeP,QAAQ,CAAC;QACjC,EAAE,OAAOiB,OAAO;YACd,MAAMb,QAAQc,gBAAgB;YAE9B,MAAMD;QACR,SAAU;YACRb,QAAQe,UAAU;QACpB;IACF;IAEA,MAAMC,OACJvB,SAAiB,EACjBC,OAAyB,EACzBK,MAAc,EACY;QAC1B,MAAM,EAAEK,MAAM,EAAE,GAAG,MAAM,IAAI,CAACZ,OAAO,CAACC;QAEtC,IAAIW,OAAOM,EAAE,KAAKX,QAAQ;YACxB,MAAM,IAAIpB;QACZ;QAEA,MAAMsC,iBAAiB,MAAM,IAAI,CAAC5B,YAAY,CAAC6B,iBAAiB,CAACzB,WAAWC,SAAS;YACnFyB,KAAK;QACP;QAEA,IAAI,CAACF,gBAAgB;YACnB,MAAM,IAAIpC,6BAA6B;QACzC;QAEA,OAAOoC,eAAerB,QAAQ,CAAC;IACjC;IAEA,MAAMwB,OAAO3B,SAAiB,EAAEM,MAAc,EAAiB;QAC7D,MAAMC,UAAU,MAAM,IAAI,CAACT,UAAU,CAACU,YAAY;QAElDD,QAAQE,gBAAgB;QAExB,IAAI;YACF,MAAM,EAAEE,MAAM,EAAEN,MAAM,EAAE,GAAG,MAAM,IAAI,CAACN,OAAO,CAACC;YAE9C,IAAIW,OAAOM,EAAE,KAAKX,QAAQ;gBACxB,MAAM,IAAIpB;YACZ;YAEA,MAAM,EAAE0C,YAAY,EAAE,GAAG,MAAM,IAAI,CAAChC,YAAY,CAACiC,SAAS,CAAC;gBAAEf,KAAKd;YAAU;YAE5E,MAAM,EAAEY,aAAa,EAAE,GAAG,MAAM,IAAI,CAACf,SAAS,CAACgB,SAAS,CACtD;gBAAEC,KAAKT;YAAO,GACd;gBACEyB,OAAO;oBAAEd,UAAUhB;gBAAU;YAC/B,GACA;gBAAEkB,kBAAkB;YAAM;YAG5B,IAAIU,iBAAiB,KAAKhB,kBAAkB,GAAG;gBAC7C,MAAM,IAAIxB,6BAA6B;YACzC;YAEA,MAAMmB,QAAQY,iBAAiB;QACjC,EAAE,OAAOC,OAAO;YACd,MAAMb,QAAQc,gBAAgB;YAE9B,MAAMD;QACR,SAAU;YACRb,QAAQe,UAAU;QACpB;IACF;AACF;AAtHa5B;IADZP;IAGIG,aAAAA,YAAYE,QAAQuC,IAAI;IACxBzC,aAAAA,YAAYG,KAAKsC,IAAI;IACrBxC,aAAAA;;;eAFgD,iCAAA;eACN,iCAAA;eACM,8CAAA;;GAJxCG", "names": [ "Model", "Connection", diff --git a/crates/swc/tests/fixture/sourcemap/013/output/PistController.map b/crates/swc/tests/fixture/sourcemap/013/output/PistController.map index 5f46472413d1a..13777cfbcedd4 100644 --- a/crates/swc/tests/fixture/sourcemap/013/output/PistController.map +++ b/crates/swc/tests/fixture/sourcemap/013/output/PistController.map @@ -1,5 +1,5 @@ { - "mappings": ";;;AAAA,SACIA,IAAI,EACJC,UAAU,EACVC,MAAM,EACNC,GAAG,EACHC,KAAK,EACLC,IAAI,EACJC,GAAG,EACHC,SAAS,EACTC,eAAe,QACZ,iBAAiB;AAExB,SACIC,qBAAqB,EACrBC,oBAAoB,EACpBC,qBAAqB,EACrBC,iBAAiB,EACjBC,4BAA4B,EAC5BC,oBAAoB,EACpBC,oBAAoB,QACjB,gCAAgC;AACvC,SAASC,kCAAkC,QAAQ,0DAA0D;AAC7G,SAASX,QAAQY,QAAQ,QAAQ,kCAAkC;AACnE,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SAASC,aAAa,QAAQ,iCAAiC;AAC/D,SAASC,YAAY,QAAQ,mCAAmC;AAChE,SAASC,IAAI,QAAQ,mCAAmC;AACxD,SAASA,QAAQC,QAAQ,QAAQ,kCAAkC;AACnE,SAASC,gBAAgB,QAAQ,uCAAuC;AACxE,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,OAAO,QAAQ,wCAAwC;AAIhE,WAAaC,iBAAN;IACHC,YAAoBC,aAAkCC,eAAgC;2BAAlED;8BAAkCC;IAAkC;IAGjFC,WAAW;QACd,OAAO,IAAI,CAACF,WAAW,CAACG,MAAM;IAClC;IAGOC,QAAQ,AAAaC,EAAU,EAAE;QACpC,OAAO,IAAI,CAACL,WAAW,CAACM,OAAO,CAACD;IACpC;IAIOE,WAAW,AAAQC,aAA4B,EAAE,AAAQC,IAAc,EAAE;QAC5E,OAAO,IAAI,CAACT,WAAW,CAACU,MAAM,CAACF,eAAeC,KAAKJ,EAAE;IACzD;IAIOM,WACH,AAAaN,EAAU,EACvB,AAAQO,aAA4B,EACpC,AAAQH,IAAc,EACxB;QACE,OAAO,IAAI,CAACT,WAAW,CAACa,MAAM,CAACR,IAAIO,eAAeH,KAAKJ,EAAE;IAC7D;IAIOS,WAAW,AAAaT,EAAU,EAAE,AAAQI,IAAc,EAAE;QAC/D,OAAO,IAAI,CAACT,WAAW,CAACe,MAAM,CAACV,IAAII,KAAKJ,EAAE;IAC9C;IAKOW,kBACH,AAAaX,EAAU,EACvB,AAAQY,gBAAkC,EAC1C,AAAQR,IAAc,EACxB;QACE,OAAO,IAAI,CAACR,cAAc,CAACS,MAAM,CAACO,kBAAkBZ,IAAII,KAAKJ,EAAE;IACnE;AACJ;;IA1CK9B,IAAIQ;;;GAHIe;;IAQRvB,IAAIS;IACWR,aAAAA,MAAM;;;;;GATbsB;;IAaRnB,UAAUa;IACVf,KAAKS;IACad,aAAAA;IAAsCqB,aAAAA;;;eAAhB,yCAAA;eAA6B,oCAAA;;GAf7DK;;IAmBRnB,UAAUa;IACVd,IAAIS;IAEAX,aAAAA,MAAM;IACNJ,aAAAA;IACAqB,aAAAA;;;;eADsB,yCAAA;eACT,oCAAA;;GAxBTK;;IA6BRnB,UAAUa;IACVlB,OAAOQ;IACWN,aAAAA,MAAM;IAAmBiB,aAAAA;;;;eAAa,oCAAA;;GA/BhDK;;IAmCRlB,gBAAgBQ,mCAAmCS;IACnDlB,UAAUa;IACVf,KAAKQ;IAEDT,aAAAA,MAAM;IACNJ,aAAAA;IACAqB,aAAAA;;;;eADyB,4CAAA;eACZ,oCAAA;;GAzCTK;AAAAA;IAFZzB,WAAWQ;IACXD,gBAAgBQ,mCAAmCC;;;eAEf,uCAAA;eAAqC,0CAAA;;GAD7DS", + "mappings": ";;;AAAA,SACIA,IAAI,EACJC,UAAU,EACVC,MAAM,EACNC,GAAG,EACHC,KAAK,EACLC,IAAI,EACJC,GAAG,EACHC,SAAS,EACTC,eAAe,QACZ,iBAAiB;AAExB,SACIC,qBAAqB,EACrBC,oBAAoB,EACpBC,qBAAqB,EACrBC,iBAAiB,EACjBC,4BAA4B,EAC5BC,oBAAoB,EACpBC,oBAAoB,QACjB,gCAAgC;AACvC,SAASC,kCAAkC,QAAQ,0DAA0D;AAC7G,SAASX,QAAQY,QAAQ,QAAQ,kCAAkC;AACnE,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SAASC,aAAa,QAAQ,iCAAiC;AAC/D,SAASC,YAAY,QAAQ,mCAAmC;AAChE,SAASC,IAAI,QAAQ,mCAAmC;AACxD,SAASA,QAAQC,QAAQ,QAAQ,kCAAkC;AACnE,SAASC,gBAAgB,QAAQ,uCAAuC;AACxE,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,OAAO,QAAQ,wCAAwC;AAIhE,WAAaC,iBAAN;IACHC,YAAY,AAAQC,WAAwB,EAAE,AAAQC,cAA8B,CAAE;aAAlED,cAAAA;aAAkCC,iBAAAA;IAAkC;IAGjFC,WAAW;QACd,OAAO,IAAI,CAACF,WAAW,CAACG,MAAM;IAClC;IAGOC,QAAQ,AAAaC,EAAU,EAAE;QACpC,OAAO,IAAI,CAACL,WAAW,CAACM,OAAO,CAACD;IACpC;IAIOE,WAAW,AAAQC,aAA4B,EAAE,AAAQC,IAAc,EAAE;QAC5E,OAAO,IAAI,CAACT,WAAW,CAACU,MAAM,CAACF,eAAeC,KAAKJ,EAAE;IACzD;IAIOM,WACH,AAAaN,EAAU,EACvB,AAAQO,aAA4B,EACpC,AAAQH,IAAc,EACxB;QACE,OAAO,IAAI,CAACT,WAAW,CAACa,MAAM,CAACR,IAAIO,eAAeH,KAAKJ,EAAE;IAC7D;IAIOS,WAAW,AAAaT,EAAU,EAAE,AAAQI,IAAc,EAAE;QAC/D,OAAO,IAAI,CAACT,WAAW,CAACe,MAAM,CAACV,IAAII,KAAKJ,EAAE;IAC9C;IAKOW,kBACH,AAAaX,EAAU,EACvB,AAAQY,gBAAkC,EAC1C,AAAQR,IAAc,EACxB;QACE,OAAO,IAAI,CAACR,cAAc,CAACS,MAAM,CAACO,kBAAkBZ,IAAII,KAAKJ,EAAE;IACnE;AACJ;;IA1CK9B,IAAIQ;;;GAHIe;;IAQRvB,IAAIS;IACWR,aAAAA,MAAM;;;;;GATbsB;;IAaRnB,UAAUa;IACVf,KAAKS;IACad,aAAAA;IAAsCqB,aAAAA;;;eAAhB,yCAAA;eAA6B,oCAAA;;GAf7DK;;IAmBRnB,UAAUa;IACVd,IAAIS;IAEAX,aAAAA,MAAM;IACNJ,aAAAA;IACAqB,aAAAA;;;;eADsB,yCAAA;eACT,oCAAA;;GAxBTK;;IA6BRnB,UAAUa;IACVlB,OAAOQ;IACWN,aAAAA,MAAM;IAAmBiB,aAAAA;;;;eAAa,oCAAA;;GA/BhDK;;IAmCRlB,gBAAgBQ,mCAAmCS;IACnDlB,UAAUa;IACVf,KAAKQ;IAEDT,aAAAA,MAAM;IACNJ,aAAAA;IACAqB,aAAAA;;;;eADyB,4CAAA;eACZ,oCAAA;;GAzCTK;AAAAA;IAFZzB,WAAWQ;IACXD,gBAAgBQ,mCAAmCC;;;eAEf,uCAAA;eAAqC,0CAAA;;GAD7DS", "names": [ "Body", "Controller", diff --git a/crates/swc/tests/fixture/sourcemap/014/output/UserController.map b/crates/swc/tests/fixture/sourcemap/014/output/UserController.map index 87f8ad103c9e9..cb7b355835bfc 100644 --- a/crates/swc/tests/fixture/sourcemap/014/output/UserController.map +++ b/crates/swc/tests/fixture/sourcemap/014/output/UserController.map @@ -1,5 +1,5 @@ { - "mappings": ";;;AAAA,SACIA,UAAU,EACVC,IAAI,EACJC,SAAS,EACTC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,kBAAkB,EAClBC,eAAe,QACZ,iBAAiB;AAExB,SACIC,qBAAqB,EACrBC,oBAAoB,EACpBC,oBAAoB,QACjB,gCAAgC;AACvC,SAASC,aAAa,QAAQ,iCAAiC;AAC/D,SAASC,aAAa,QAAQ,iCAAiC;AAC/D,SAASC,YAAY,QAAQ,mCAAmC;AAChE,SAASC,IAAI,QAAQ,mCAAmC;AACxD,SAASA,QAAQC,QAAQ,QAAQ,kCAAkC;AACnE,SAASC,kCAAkC,QAAQ,0DAA0D;AAC7G,SAASC,WAAW,QAAQ,2BAA2B;AAIvD,WAAaC,iBAAN;IACHC,YAAoBC,YAA0B;2BAA1BA;IAA4B;IAEhD,MACMC,OAAO,AAAQC,aAA4B,EAAE;QAC/C,OAAO,IAAI,CAACF,WAAW,CAACG,MAAM,CAACD;IACnC;IAEA,MAEME,OACF,AAAaC,MAAc,EAC3B,AAAQC,aAA4B,EACpC,AAAQC,IAAc,EACxB;QACE,IAAIA,KAAKC,EAAE,KAAKH,QAAQ;YACpB,MAAM,IAAInB;QACd;QAEA,OAAO,IAAI,CAACc,WAAW,CAACI,MAAM,CAACC,QAAQC;IAC3C;AACJ;;IAlBKzB,KAAKQ;IACQN,aAAAA;;;eAAsB,yCAAA;;GAJ3Be;;IAQRhB,UAAUW;IACVT,IAAIM;IAEAL,aAAAA,MAAM;IACNF,aAAAA;IACAW,aAAAA;;;;eADsB,yCAAA;eACT,oCAAA;;GAbTI;AAAAA;IAFZlB,WAAWQ;IACXD,gBAAgBS,mCAAmCD;;;eAEf,uCAAA;;GADxBG", + "mappings": ";;;AAAA,SACIA,UAAU,EACVC,IAAI,EACJC,SAAS,EACTC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,kBAAkB,EAClBC,eAAe,QACZ,iBAAiB;AAExB,SACIC,qBAAqB,EACrBC,oBAAoB,EACpBC,oBAAoB,QACjB,gCAAgC;AACvC,SAASC,aAAa,QAAQ,iCAAiC;AAC/D,SAASC,aAAa,QAAQ,iCAAiC;AAC/D,SAASC,YAAY,QAAQ,mCAAmC;AAChE,SAASC,IAAI,QAAQ,mCAAmC;AACxD,SAASA,QAAQC,QAAQ,QAAQ,kCAAkC;AACnE,SAASC,kCAAkC,QAAQ,0DAA0D;AAC7G,SAASC,WAAW,QAAQ,2BAA2B;AAIvD,WAAaC,iBAAN;IACHC,YAAY,AAAQC,WAAwB,CAAE;aAA1BA,cAAAA;IAA4B;IAEhD,MACMC,OAAO,AAAQC,aAA4B,EAAE;QAC/C,OAAO,IAAI,CAACF,WAAW,CAACG,MAAM,CAACD;IACnC;IAEA,MAEME,OACF,AAAaC,MAAc,EAC3B,AAAQC,aAA4B,EACpC,AAAQC,IAAc,EACxB;QACE,IAAIA,KAAKC,EAAE,KAAKH,QAAQ;YACpB,MAAM,IAAInB;QACd;QAEA,OAAO,IAAI,CAACc,WAAW,CAACI,MAAM,CAACC,QAAQC;IAC3C;AACJ;;IAlBKzB,KAAKQ;IACQN,aAAAA;;;eAAsB,yCAAA;;GAJ3Be;;IAQRhB,UAAUW;IACVT,IAAIM;IAEAL,aAAAA,MAAM;IACNF,aAAAA;IACAW,aAAAA;;;;eADsB,yCAAA;eACT,oCAAA;;GAbTI;AAAAA;IAFZlB,WAAWQ;IACXD,gBAAgBS,mCAAmCD;;;eAEf,uCAAA;;GADxBG", "names": [ "Controller", "Post", diff --git a/crates/swc/tests/fixture/ts-inline-enum/default/output/index.ts b/crates/swc/tests/fixture/ts-inline-enum/default/output/index.ts index 784528133fca1..e902e906b0414 100644 --- a/crates/swc/tests/fixture/ts-inline-enum/default/output/index.ts +++ b/crates/swc/tests/fixture/ts-inline-enum/default/output/index.ts @@ -6,12 +6,6 @@ var Foo2; (function(Foo2) { Foo2["hello"] = "42"; })(Foo2 || (Foo2 = {})); -console.log(Foo.hello, Foo2.hello); +console.log(42, "42"); console.log("hello", "こんにちは", "안녕하세요", "你好"); var Hello; -(function(Hello) { - Hello["en"] = "hello"; - Hello["ja-JP"] = "こんにちは"; - Hello["ko-KR"] = "안녕하세요"; - Hello["zh-CN"] = "你好"; -})(Hello || (Hello = {})); diff --git a/crates/swc/tests/fixture/ts-inline-enum/lhs/output/index.ts b/crates/swc/tests/fixture/ts-inline-enum/lhs/output/index.ts index 8d6268a6fbe83..68b26832eac36 100644 --- a/crates/swc/tests/fixture/ts-inline-enum/lhs/output/index.ts +++ b/crates/swc/tests/fixture/ts-inline-enum/lhs/output/index.ts @@ -1,7 +1,4 @@ var Foo; -(function(Foo) { - Foo[Foo["hello"] = 42] = "hello"; -})(Foo || (Foo = {})); var x; var ref; ref = void 0, x = ref === void 0 ? 42 : ref; diff --git a/crates/swc/tests/fixture/ts-inline-enum/treatConstEnumAsEnum-2/output/index.ts b/crates/swc/tests/fixture/ts-inline-enum/treatConstEnumAsEnum-2/output/index.ts index 94e0d2630e064..c25bdc6b6c9fe 100644 --- a/crates/swc/tests/fixture/ts-inline-enum/treatConstEnumAsEnum-2/output/index.ts +++ b/crates/swc/tests/fixture/ts-inline-enum/treatConstEnumAsEnum-2/output/index.ts @@ -7,12 +7,6 @@ var Foo2; Foo2["hello"] = "42"; })(Foo2 || (Foo2 = {})); var Bar; -(function(Bar) { - Bar[Bar["hello"] = 42] = "hello"; -})(Bar || (Bar = {})); var Bar2; -(function(Bar2) { - Bar2["hello"] = "42"; -})(Bar2 || (Bar2 = {})); -console.log(Foo.hello, Foo2.hello); +console.log(42, "42"); console.log(42, "42"); diff --git a/crates/swc/tests/fixture/ts-inline-enum/treatConstEnumAsEnum/output/index.ts b/crates/swc/tests/fixture/ts-inline-enum/treatConstEnumAsEnum/output/index.ts index cea9922cd91bd..c25bdc6b6c9fe 100644 --- a/crates/swc/tests/fixture/ts-inline-enum/treatConstEnumAsEnum/output/index.ts +++ b/crates/swc/tests/fixture/ts-inline-enum/treatConstEnumAsEnum/output/index.ts @@ -7,12 +7,6 @@ var Foo2; Foo2["hello"] = "42"; })(Foo2 || (Foo2 = {})); var Bar; -(function(Bar) { - Bar[Bar["hello"] = 42] = "hello"; -})(Bar || (Bar = {})); var Bar2; -(function(Bar2) { - Bar2["hello"] = "42"; -})(Bar2 || (Bar2 = {})); -console.log(Foo.hello, Foo2.hello); -console.log(Bar.hello, Bar2.hello); +console.log(42, "42"); +console.log(42, "42"); diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.1.normal.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.1.normal.js index 599ad20191192..d0336b94f646e 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.1.normal.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.1.normal.js @@ -24,9 +24,18 @@ var clodule3 = function clodule3() { _class_call_check(this, clodule3); }; (function(clodule3) { - var y = clodule3.y = { + var y = { id: T }; + Object.defineProperty(clodule3, "y", { + enumerable: true, + get: function get() { + return y; + }, + set: function set(v) { + y = v; + } + }); })(clodule3 || (clodule3 = {})); var clodule4 = function clodule4() { "use strict"; diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.2.minified.js index a1a00a40cec64..46b6f9f2419cf 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.2.minified.js @@ -1,7 +1,7 @@ //// [ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts] // all expected to be errors import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var clodule1 = function clodule1() { +var clodule3, y, clodule1 = function clodule1() { _class_call_check(this, clodule1); }; clodule1 || (clodule1 = {}); @@ -9,12 +9,20 @@ var clodule2 = function clodule2() { _class_call_check(this, clodule2); }; clodule2 || (clodule2 = {}); -var clodule3 = function clodule3() { +var clodule31 = function clodule3() { _class_call_check(this, clodule3); }; -(clodule3 || (clodule3 = {})).y = { +clodule3 = clodule31 || (clodule31 = {}), y = { id: T -}; +}, Object.defineProperty(clodule3, "y", { + enumerable: !0, + get: function() { + return y; + }, + set: function(v) { + y = v; + } +}); var clodule4 = function clodule4() { _class_call_check(this, clodule4); }; diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.1.normal.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.1.normal.js index 3327efb7c642a..7e85bd6d5b08f 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.1.normal.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.1.normal.js @@ -10,9 +10,9 @@ var clodule = /*#__PURE__*/ function() { }; return clodule; }(); -(function(clodule1) { +(function(clodule) { var fn = function fn(x, y) { return clodule.sfn("a"); }; - clodule1.fn = fn; + clodule.fn = fn; })(clodule || (clodule = {})); diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.2.minified.js index 491426573d1bf..d4389a540799b 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.2.minified.js @@ -1,6 +1,6 @@ //// [ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var clodule = function() { +var clodule, clodule1 = function() { function clodule() { _class_call_check(this, clodule); } @@ -8,6 +8,6 @@ var clodule = function() { return 42; }, clodule; }(); -(clodule || (clodule = {})).fn = function(x, y) { +(clodule = clodule1 || (clodule1 = {})).fn = function(x, y) { return clodule.sfn("a"); }; diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.1.normal.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.1.normal.js index bffa50d53248a..b506243eff017 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.1.normal.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.1.normal.js @@ -43,9 +43,10 @@ var A; }(); A.Point = Point; (function(Point) { - function Origin() { + var Origin = function Origin() { return ""; } //expected duplicate identifier error + ; Point.Origin = Origin; })(Point = A.Point || (A.Point = {})); })(A || (A = {})); diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.1.normal.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.1.normal.js index b14e185c06094..edbb44ec1fe01 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.1.normal.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.1.normal.js @@ -40,8 +40,9 @@ var A; }(); A.Point = Point; (function(Point) { - function Origin() { + var Origin = function Origin() { return ""; } // not an error since not exported + ; })(Point = A.Point || (A.Point = {})); })(A || (A = {})); diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.1.normal.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.1.normal.js index 0157aeabd38c2..1f2c9cb6876a5 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.1.normal.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.1.normal.js @@ -13,7 +13,16 @@ var Point = function Point(x, y) { }; })(); (function(Point) { - var Origin = Point.Origin = ""; + var Origin = ""; //expected duplicate identifier error + Object.defineProperty(Point, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); })(Point || (Point = {})); var A; (function(A) { @@ -31,6 +40,15 @@ var A; })(); A.Point = Point; (function(Point) { - var Origin = Point.Origin = ""; + var Origin = ""; //expected duplicate identifier error + Object.defineProperty(Point, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); })(Point = A.Point || (A.Point = {})); })(A || (A = {})); diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.2.minified.js index e4c948b4f7b1f..fdd3710d39c40 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.2.minified.js @@ -1,14 +1,30 @@ //// [ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var A, Point, A1, Point1 = function Point(x, y) { +var Point, Origin, A, Point1, Point2, Origin1, A1, Point3 = function Point(x, y) { _class_call_check(this, Point), this.x = x, this.y = y; }; -Point1.Origin = { +Point3.Origin = { x: 0, y: 0 -}, (Point1 || (Point1 = {})).Origin = "", A = A1 || (A1 = {}), (Point = function Point(x, y) { +}, Point = Point3 || (Point3 = {}), Origin = "", Object.defineProperty(Point, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}), A = A1 || (A1 = {}), (Point1 = function Point(x, y) { _class_call_check(this, Point), this.x = x, this.y = y; }).Origin = { x: 0, y: 0 -}, A.Point = Point, (Point = A.Point || (A.Point = {})).Origin = ""; +}, A.Point = Point1, Point2 = Point1 = A.Point || (A.Point = {}), Origin1 = "", Object.defineProperty(Point2, "Origin", { + enumerable: !0, + get: function() { + return Origin1; + }, + set: function(v) { + Origin1 = v; + } +}); diff --git a/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRoot.1.normal.js b/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRoot.1.normal.js index 3e607d2b78bf4..e475b2350907c 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRoot.1.normal.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRoot.1.normal.js @@ -2,7 +2,6 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var X; (function(X) { - var Y; (function(Y) { var Point = function Point(x, y) { "use strict"; @@ -11,18 +10,26 @@ var X; this.y = y; }; Y.Point = Point; - })(Y = X.Y || (X.Y = {})); + })(X.Y || (X.Y = {})); })(X || (X = {})); //// [module.ts] var X; (function(X) { - var Y; (function(Y) { var Point; - (function(Point1) { - var Origin = Point1.Origin = new Point(0, 0); + (function(Point) { + var Origin = new Point(0, 0); + Object.defineProperty(Point, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); })(Point = Y.Point || (Y.Point = {})); - })(Y = X.Y || (X.Y = {})); + })(X.Y || (X.Y = {})); })(X || (X = {})); //// [test.ts] //var cl: { x: number; y: number; } @@ -34,8 +41,17 @@ var A = function A() { "use strict"; _class_call_check(this, A); }; -(function(A1) { - var Instance = A1.Instance = new A(); +(function(A) { + var Instance = new A(); + Object.defineProperty(A, "Instance", { + enumerable: true, + get: function get() { + return Instance; + }, + set: function set(v) { + Instance = v; + } + }); })(A || (A = {})); // ensure merging works as expected var a = A.Instance; diff --git a/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRoot.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRoot.2.minified.js index 601dd94f71e56..a15de2f188a64 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRoot.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRoot.2.minified.js @@ -5,15 +5,31 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; _class_call_check(this, Point), this.x = x, this.y = y; }; //// [module.ts] -var X, X1, Y, Point; -(Point = (Y = (X1 = X || (X = {})).Y || (X1.Y = {})).Point || (Y.Point = {})).Origin = new Point(0, 0); +var X, X1, Y, Point, Origin; +Origin = new (Point = (Y = (X1 = X || (X = {})).Y || (X1.Y = {})).Point || (Y.Point = {}))(0, 0), Object.defineProperty(Point, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}); //// [test.ts] //var cl: { x: number; y: number; } new X.Y.Point(1, 1), X.Y.Point.Origin; // error not expected here same as bug 83996 ? //// [simple.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var A = function A() { +var A, Instance, A1 = function A() { _class_call_check(this, A); }; -(A || (A = {})).Instance = new A(), A.Instance, new A(); +Instance = new (A = A1 || (A1 = {}))(), Object.defineProperty(A, "Instance", { + enumerable: !0, + get: function() { + return Instance; + }, + set: function(v) { + Instance = v; + } +}), A1.Instance, new A1(); diff --git a/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRootES6.1.normal.js b/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRootES6.1.normal.js index 90f4bea35b570..2d00e0c909773 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRootES6.1.normal.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRootES6.1.normal.js @@ -1,7 +1,6 @@ //// [class.ts] var X; (function(X) { - let Y; (function(Y) { class Point { constructor(x, y){ @@ -10,18 +9,26 @@ var X; } } Y.Point = Point; - })(Y = X.Y || (X.Y = {})); + })(X.Y || (X.Y = {})); })(X || (X = {})); //// [module.ts] var X; (function(X) { - let Y; (function(Y) { let Point; - (function(Point1) { - var Origin = Point1.Origin = new Point(0, 0); + (function(Point) { + var Origin = new Point(0, 0); + Object.defineProperty(Point, "Origin", { + enumerable: true, + get () { + return Origin; + }, + set (v) { + Origin = v; + } + }); })(Point = Y.Point || (Y.Point = {})); - })(Y = X.Y || (X.Y = {})); + })(X.Y || (X.Y = {})); })(X || (X = {})); //// [test.ts] //var cl: { x: number; y: number; } @@ -30,8 +37,17 @@ var cl = X.Y.Point.Origin; // error not expected here same as bug 83996 ? //// [simple.ts] class A { } -(function(A1) { - var Instance = A1.Instance = new A(); +(function(A) { + var Instance = new A(); + Object.defineProperty(A, "Instance", { + enumerable: true, + get () { + return Instance; + }, + set (v) { + Instance = v; + } + }); })(A || (A = {})); // ensure merging works as expected var a = A.Instance; diff --git a/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRootES6.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRootES6.2.minified.js index 20585d9db6534..dc7f25afe2558 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRootES6.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRootES6.2.minified.js @@ -6,14 +6,26 @@ var X, X1; } }; //// [module.ts] -var X, X1, Y; -let Point; -(Point = (Y = (X1 = X || (X = {})).Y || (X1.Y = {})).Point || (Y.Point = {})).Origin = new Point(0, 0); +var X, X1, Y, Point, Origin; +Origin = new (Point = (Y = (X1 = X || (X = {})).Y || (X1.Y = {})).Point || (Y.Point = {}))(0, 0), Object.defineProperty(Point, "Origin", { + enumerable: !0, + get: ()=>Origin, + set (v) { + Origin = v; + } +}); //// [test.ts] //var cl: { x: number; y: number; } new X.Y.Point(1, 1), X.Y.Point.Origin; // error not expected here same as bug 83996 ? //// [simple.ts] -class A { +var A, Instance; +class A1 { } -(A || (A = {})).Instance = new A(), A.Instance, new A(); +Instance = new (A = A1 || (A1 = {}))(), Object.defineProperty(A, "Instance", { + enumerable: !0, + get: ()=>Instance, + set (v) { + Instance = v; + } +}), A1.Instance, new A1(); diff --git a/crates/swc/tests/tsc-references/EnumAndModuleWithSameNameAndCommonRoot.1.normal.js b/crates/swc/tests/tsc-references/EnumAndModuleWithSameNameAndCommonRoot.1.normal.js index 8ffbb9b07f347..d77e4c2a822fc 100644 --- a/crates/swc/tests/tsc-references/EnumAndModuleWithSameNameAndCommonRoot.1.normal.js +++ b/crates/swc/tests/tsc-references/EnumAndModuleWithSameNameAndCommonRoot.1.normal.js @@ -15,6 +15,6 @@ var enumdule; enumdule.Point = Point; })(enumdule || (enumdule = {})); var x; -var x = enumdule.Red; +var x = 0; var y; var y = new enumdule.Point(0, 0); diff --git a/crates/swc/tests/tsc-references/EnumAndModuleWithSameNameAndCommonRoot.2.minified.js b/crates/swc/tests/tsc-references/EnumAndModuleWithSameNameAndCommonRoot.2.minified.js index b2c606ae0a076..aecb9f799e3b0 100644 --- a/crates/swc/tests/tsc-references/EnumAndModuleWithSameNameAndCommonRoot.2.minified.js +++ b/crates/swc/tests/tsc-references/EnumAndModuleWithSameNameAndCommonRoot.2.minified.js @@ -3,4 +3,4 @@ var enumdule, enumdule1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; (enumdule1 = enumdule || (enumdule = {}))[enumdule1.Red = 0] = "Red", enumdule1[enumdule1.Blue = 1] = "Blue", (enumdule || (enumdule = {})).Point = function Point(x, y) { _class_call_check(this, Point), this.x = x, this.y = y; -}, enumdule.Red, new enumdule.Point(0, 0); +}, new enumdule.Point(0, 0); diff --git a/crates/swc/tests/tsc-references/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.1.normal.js b/crates/swc/tests/tsc-references/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.1.normal.js index 96fcd9de053e5..621ced591ee5f 100644 --- a/crates/swc/tests/tsc-references/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.1.normal.js +++ b/crates/swc/tests/tsc-references/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.1.normal.js @@ -9,10 +9,19 @@ var A; _class_call_check(this, Point); }; A.Point = Point; - var Origin = A.Origin = { + var Origin = { x: 0, y: 0 }; + Object.defineProperty(A, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); var Point3d = /*#__PURE__*/ function(Point) { "use strict"; _inherits(Point3d, Point); @@ -24,11 +33,20 @@ var A; return Point3d; }(Point); A.Point3d = Point3d; - var Origin3d = A.Origin3d = { + var Origin3d = { x: 0, y: 0, z: 0 }; + Object.defineProperty(A, "Origin3d", { + enumerable: true, + get: function get() { + return Origin3d; + }, + set: function set(v) { + Origin3d = v; + } + }); var Line = function Line(start, end) { "use strict"; _class_call_check(this, Line); diff --git a/crates/swc/tests/tsc-references/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.2.minified.js b/crates/swc/tests/tsc-references/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.2.minified.js index d54f621888fe8..bb7ac7d8dae91 100644 --- a/crates/swc/tests/tsc-references/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.2.minified.js @@ -1,24 +1,40 @@ //// [ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.ts] -var A, A1, Point, Point3d; +var A, A1, Point, Origin, Point3d, Origin3d; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; A1 = A || (A = {}), Point = function Point() { _class_call_check(this, Point); -}, A1.Point = Point, A1.Origin = { +}, A1.Point = Point, Origin = { x: 0, y: 0 -}, Point3d = function(Point) { +}, Object.defineProperty(A1, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}), Point3d = function(Point) { _inherits(Point3d, Point); var _super = _create_super(Point3d); function Point3d() { return _class_call_check(this, Point3d), _super.apply(this, arguments); } return Point3d; -}(Point), A1.Point3d = Point3d, A1.Origin3d = { +}(Point), A1.Point3d = Point3d, Origin3d = { x: 0, y: 0, z: 0 -}, A1.Line = function Line(start, end) { +}, Object.defineProperty(A1, "Origin3d", { + enumerable: !0, + get: function() { + return Origin3d; + }, + set: function(v) { + Origin3d = v; + } +}), A1.Line = function Line(start, end) { _class_call_check(this, Line), this.start = start, this.end = end; }; diff --git a/crates/swc/tests/tsc-references/ExportClassWithInaccessibleTypeInTypeParameterConstraint.1.normal.js b/crates/swc/tests/tsc-references/ExportClassWithInaccessibleTypeInTypeParameterConstraint.1.normal.js index 2e8f50fdb2274..2f197bf666331 100644 --- a/crates/swc/tests/tsc-references/ExportClassWithInaccessibleTypeInTypeParameterConstraint.1.normal.js +++ b/crates/swc/tests/tsc-references/ExportClassWithInaccessibleTypeInTypeParameterConstraint.1.normal.js @@ -8,10 +8,19 @@ var A; "use strict"; _class_call_check(this, Point); }; - var Origin = A.Origin = { + var Origin = { x: 0, y: 0 }; + Object.defineProperty(A, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); var Point3d = /*#__PURE__*/ function(Point) { "use strict"; _inherits(Point3d, Point); @@ -23,11 +32,20 @@ var A; return Point3d; }(Point); A.Point3d = Point3d; - var Origin3d = A.Origin3d = { + var Origin3d = { x: 0, y: 0, z: 0 }; + Object.defineProperty(A, "Origin3d", { + enumerable: true, + get: function get() { + return Origin3d; + }, + set: function set(v) { + Origin3d = v; + } + }); var Line = /*#__PURE__*/ function() { "use strict"; function Line(start, end) { diff --git a/crates/swc/tests/tsc-references/ExportClassWithInaccessibleTypeInTypeParameterConstraint.2.minified.js b/crates/swc/tests/tsc-references/ExportClassWithInaccessibleTypeInTypeParameterConstraint.2.minified.js index 59a96bf54a1b9..a17ca29a7fca4 100644 --- a/crates/swc/tests/tsc-references/ExportClassWithInaccessibleTypeInTypeParameterConstraint.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportClassWithInaccessibleTypeInTypeParameterConstraint.2.minified.js @@ -1,12 +1,20 @@ //// [ExportClassWithInaccessibleTypeInTypeParameterConstraint.ts] -var A, A1, Point3d, Line; +var A, A1, Origin, Point3d, Origin3d, Line; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -(A1 = A || (A = {})).Origin = { +A1 = A || (A = {}), Origin = { x: 0, y: 0 -}, Point3d = function(Point) { +}, Object.defineProperty(A1, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}), Point3d = function(Point) { _inherits(Point3d, Point); var _super = _create_super(Point3d); function Point3d() { @@ -15,11 +23,19 @@ import { _ as _create_super } from "@swc/helpers/_/_create_super"; return Point3d; }(function Point() { _class_call_check(this, Point); -}), A1.Point3d = Point3d, A1.Origin3d = { +}), A1.Point3d = Point3d, Origin3d = { x: 0, y: 0, z: 0 -}, Line = function() { +}, Object.defineProperty(A1, "Origin3d", { + enumerable: !0, + get: function() { + return Origin3d; + }, + set: function(v) { + Origin3d = v; + } +}), Line = function() { function Line(start, end) { _class_call_check(this, Line), this.start = start, this.end = end; } diff --git a/crates/swc/tests/tsc-references/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.1.normal.js b/crates/swc/tests/tsc-references/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.1.normal.js index 30e5b3d8c5dfe..708f144f34951 100644 --- a/crates/swc/tests/tsc-references/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.1.normal.js +++ b/crates/swc/tests/tsc-references/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.1.normal.js @@ -1,13 +1,31 @@ //// [ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.ts] var A; (function(A) { - var Origin = A.Origin = { + var Origin = { x: 0, y: 0 }; - var Origin3d = A.Origin3d = { + Object.defineProperty(A, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); + var Origin3d = { x: 0, y: 0, z: 0 }; + Object.defineProperty(A, "Origin3d", { + enumerable: true, + get: function get() { + return Origin3d; + }, + set: function set(v) { + Origin3d = v; + } + }); })(A || (A = {})); diff --git a/crates/swc/tests/tsc-references/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.2.minified.js b/crates/swc/tests/tsc-references/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.2.minified.js index a05953f0aa3dc..35271e1e99523 100644 --- a/crates/swc/tests/tsc-references/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.2.minified.js @@ -1,10 +1,26 @@ //// [ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.ts] -var A, A1; -(A1 = A || (A = {})).Origin = { +var A, A1, Origin, Origin3d; +A1 = A || (A = {}), Origin = { x: 0, y: 0 -}, A1.Origin3d = { +}, Object.defineProperty(A1, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}), Origin3d = { x: 0, y: 0, z: 0 -}; +}, Object.defineProperty(A1, "Origin3d", { + enumerable: !0, + get: function() { + return Origin3d; + }, + set: function(v) { + Origin3d = v; + } +}); diff --git a/crates/swc/tests/tsc-references/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.1.normal.js b/crates/swc/tests/tsc-references/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.1.normal.js index 2ea00d535bcb2..e3b73b8c13293 100644 --- a/crates/swc/tests/tsc-references/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.1.normal.js +++ b/crates/swc/tests/tsc-references/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.1.normal.js @@ -1,13 +1,31 @@ //// [ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.ts] var A; (function(A) { - var Origin = A.Origin = { + var Origin = { x: 0, y: 0 }; - var Origin3d = A.Origin3d = { + Object.defineProperty(A, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); + var Origin3d = { x: 0, y: 0, z: 0 }; + Object.defineProperty(A, "Origin3d", { + enumerable: true, + get: function get() { + return Origin3d; + }, + set: function set(v) { + Origin3d = v; + } + }); })(A || (A = {})); diff --git a/crates/swc/tests/tsc-references/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.2.minified.js b/crates/swc/tests/tsc-references/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.2.minified.js index 5e95ec7acb693..aebe04a6abea1 100644 --- a/crates/swc/tests/tsc-references/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.2.minified.js @@ -1,10 +1,26 @@ //// [ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.ts] -var A, A1; -(A1 = A || (A = {})).Origin = { +var A, A1, Origin, Origin3d; +A1 = A || (A = {}), Origin = { x: 0, y: 0 -}, A1.Origin3d = { +}, Object.defineProperty(A1, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}), Origin3d = { x: 0, y: 0, z: 0 -}; +}, Object.defineProperty(A1, "Origin3d", { + enumerable: !0, + get: function() { + return Origin3d; + }, + set: function(v) { + Origin3d = v; + } +}); diff --git a/crates/swc/tests/tsc-references/ExportModuleWithAccessibleTypesOnItsExportedMembers.1.normal.js b/crates/swc/tests/tsc-references/ExportModuleWithAccessibleTypesOnItsExportedMembers.1.normal.js index ae565ca29f61d..d4ad741270133 100644 --- a/crates/swc/tests/tsc-references/ExportModuleWithAccessibleTypesOnItsExportedMembers.1.normal.js +++ b/crates/swc/tests/tsc-references/ExportModuleWithAccessibleTypesOnItsExportedMembers.1.normal.js @@ -11,7 +11,16 @@ var A; A.Point = Point; var B; (function(B) { - var Origin = B.Origin = new Point(0, 0); + var Origin = new Point(0, 0); + Object.defineProperty(B, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); var Line = /*#__PURE__*/ function() { "use strict"; function Line(start, end) { diff --git a/crates/swc/tests/tsc-references/ExportModuleWithAccessibleTypesOnItsExportedMembers.2.minified.js b/crates/swc/tests/tsc-references/ExportModuleWithAccessibleTypesOnItsExportedMembers.2.minified.js index c47fbbeeeb19f..e023edb9ead1d 100644 --- a/crates/swc/tests/tsc-references/ExportModuleWithAccessibleTypesOnItsExportedMembers.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportModuleWithAccessibleTypesOnItsExportedMembers.2.minified.js @@ -1,9 +1,17 @@ //// [ExportModuleWithAccessibleTypesOnItsExportedMembers.ts] -var A, A1, Point, B, Line; +var A, A1, Point, B, Origin, Line; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; A1 = A || (A = {}), Point = function Point(x, y) { _class_call_check(this, Point), this.x = x, this.y = y; -}, A1.Point = Point, (B = A1.B || (A1.B = {})).Origin = new Point(0, 0), Line = function() { +}, A1.Point = Point, B = A1.B || (A1.B = {}), Origin = new Point(0, 0), Object.defineProperty(B, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}), Line = function() { function Line(start, end) { _class_call_check(this, Line); } diff --git a/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.1.normal.js b/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.1.normal.js index 50ace62ba612a..09309c069ac7f 100644 --- a/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.1.normal.js +++ b/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.1.normal.js @@ -8,12 +8,30 @@ var A; this.x = x; this.y = y; }; - var Origin = A.Origin = { + var Origin = { x: 0, y: 0 }; - var Unity = A.Unity = { + Object.defineProperty(A, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); + var Unity = { start: new Point(0, 0), end: new Point(1, 0) }; + Object.defineProperty(A, "Unity", { + enumerable: true, + get: function get() { + return Unity; + }, + set: function set(v) { + Unity = v; + } + }); })(A || (A = {})); diff --git a/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.2.minified.js b/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.2.minified.js index c02904af1e033..8ce6b8b9f0a91 100644 --- a/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.2.minified.js @@ -1,12 +1,28 @@ //// [ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.ts] -var A, A1, Point; +var A, A1, Point, Origin, Unity; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; A1 = A || (A = {}), Point = function Point(x, y) { _class_call_check(this, Point), this.x = x, this.y = y; -}, A1.Origin = { +}, Origin = { x: 0, y: 0 -}, A1.Unity = { +}, Object.defineProperty(A1, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}), Unity = { start: new Point(0, 0), end: new Point(1, 0) -}; +}, Object.defineProperty(A1, "Unity", { + enumerable: !0, + get: function() { + return Unity; + }, + set: function(v) { + Unity = v; + } +}); diff --git a/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.1.normal.js b/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.1.normal.js index 734bd641cc185..5b2bc3574615c 100644 --- a/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.1.normal.js +++ b/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.1.normal.js @@ -8,5 +8,14 @@ var A; this.x = x; this.y = y; }; - var UnitSquare = A.UnitSquare = null; + var UnitSquare = null; + Object.defineProperty(A, "UnitSquare", { + enumerable: true, + get: function get() { + return UnitSquare; + }, + set: function set(v) { + UnitSquare = v; + } + }); })(A || (A = {})); diff --git a/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.2.minified.js b/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.2.minified.js index ced4f3dd2d0fc..cc02764e02135 100644 --- a/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.2.minified.js @@ -1,4 +1,12 @@ //// [ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.ts] -var A; +var A, A1, UnitSquare; import "@swc/helpers/_/_class_call_check"; -(A || (A = {})).UnitSquare = null; +A1 = A || (A = {}), UnitSquare = null, Object.defineProperty(A1, "UnitSquare", { + enumerable: !0, + get: function() { + return UnitSquare; + }, + set: function(v) { + UnitSquare = v; + } +}); diff --git a/crates/swc/tests/tsc-references/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.1.normal.js b/crates/swc/tests/tsc-references/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.1.normal.js index ffa8abf4ab5a7..b6b594a579ea2 100644 --- a/crates/swc/tests/tsc-references/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.1.normal.js +++ b/crates/swc/tests/tsc-references/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.1.normal.js @@ -7,6 +7,23 @@ var A; _class_call_check(this, B); }; var beez; - var beez2 = A.beez2 = new Array(); - A.beez = beez; + Object.defineProperty(A, "beez", { + enumerable: true, + get: function get() { + return beez; + }, + set: function set(v) { + beez = v; + } + }); + var beez2 = new Array(); + Object.defineProperty(A, "beez2", { + enumerable: true, + get: function get() { + return beez2; + }, + set: function set(v) { + beez2 = v; + } + }); })(A || (A = {})); diff --git a/crates/swc/tests/tsc-references/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.2.minified.js b/crates/swc/tests/tsc-references/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.2.minified.js index ce80ed46ad3de..71f3bdbc27841 100644 --- a/crates/swc/tests/tsc-references/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.2.minified.js @@ -1,4 +1,20 @@ //// [ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.ts] -var A, A1, beez; +var A, A1, beez, beez2; import "@swc/helpers/_/_class_call_check"; -(A1 = A || (A = {})).beez2 = [], A1.beez = beez; +Object.defineProperty(A1 = A || (A = {}), "beez", { + enumerable: !0, + get: function() { + return beez; + }, + set: function(v) { + beez = v; + } +}), beez2 = [], Object.defineProperty(A1, "beez2", { + enumerable: !0, + get: function() { + return beez2; + }, + set: function(v) { + beez2 = v; + } +}); diff --git a/crates/swc/tests/tsc-references/ExportVariableWithAccessibleTypeInTypeAnnotation.1.normal.js b/crates/swc/tests/tsc-references/ExportVariableWithAccessibleTypeInTypeAnnotation.1.normal.js index ae2f06e6b911d..43b19c78d961b 100644 --- a/crates/swc/tests/tsc-references/ExportVariableWithAccessibleTypeInTypeAnnotation.1.normal.js +++ b/crates/swc/tests/tsc-references/ExportVariableWithAccessibleTypeInTypeAnnotation.1.normal.js @@ -1,8 +1,17 @@ //// [ExportVariableWithAccessibleTypeInTypeAnnotation.ts] var A; (function(A) { - var Origin = A.Origin = { + var Origin = { x: 0, y: 0 }; + Object.defineProperty(A, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); })(A || (A = {})); diff --git a/crates/swc/tests/tsc-references/ExportVariableWithAccessibleTypeInTypeAnnotation.2.minified.js b/crates/swc/tests/tsc-references/ExportVariableWithAccessibleTypeInTypeAnnotation.2.minified.js index ee06c32ca683f..d0a62cf213365 100644 --- a/crates/swc/tests/tsc-references/ExportVariableWithAccessibleTypeInTypeAnnotation.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportVariableWithAccessibleTypeInTypeAnnotation.2.minified.js @@ -1,6 +1,14 @@ //// [ExportVariableWithAccessibleTypeInTypeAnnotation.ts] -var A; -(A || (A = {})).Origin = { +var A, A1, Origin; +A1 = A || (A = {}), Origin = { x: 0, y: 0 -}; +}, Object.defineProperty(A1, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}); diff --git a/crates/swc/tests/tsc-references/ExportVariableWithInaccessibleTypeInTypeAnnotation.1.normal.js b/crates/swc/tests/tsc-references/ExportVariableWithInaccessibleTypeInTypeAnnotation.1.normal.js index c13f614454ab7..b195550967ff0 100644 --- a/crates/swc/tests/tsc-references/ExportVariableWithInaccessibleTypeInTypeAnnotation.1.normal.js +++ b/crates/swc/tests/tsc-references/ExportVariableWithInaccessibleTypeInTypeAnnotation.1.normal.js @@ -1,13 +1,31 @@ //// [ExportVariableWithInaccessibleTypeInTypeAnnotation.ts] var A; (function(A) { - var Origin = A.Origin = { + var Origin = { x: 0, y: 0 }; - var Origin3d = A.Origin3d = { + Object.defineProperty(A, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); + var Origin3d = { x: 0, y: 0, z: 0 }; + Object.defineProperty(A, "Origin3d", { + enumerable: true, + get: function get() { + return Origin3d; + }, + set: function set(v) { + Origin3d = v; + } + }); })(A || (A = {})); diff --git a/crates/swc/tests/tsc-references/ExportVariableWithInaccessibleTypeInTypeAnnotation.2.minified.js b/crates/swc/tests/tsc-references/ExportVariableWithInaccessibleTypeInTypeAnnotation.2.minified.js index d4edf5ae2b280..ccfaf2db4385e 100644 --- a/crates/swc/tests/tsc-references/ExportVariableWithInaccessibleTypeInTypeAnnotation.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportVariableWithInaccessibleTypeInTypeAnnotation.2.minified.js @@ -1,10 +1,26 @@ //// [ExportVariableWithInaccessibleTypeInTypeAnnotation.ts] -var A, A1; -(A1 = A || (A = {})).Origin = { +var A, A1, Origin, Origin3d; +A1 = A || (A = {}), Origin = { x: 0, y: 0 -}, A1.Origin3d = { +}, Object.defineProperty(A1, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}), Origin3d = { x: 0, y: 0, z: 0 -}; +}, Object.defineProperty(A1, "Origin3d", { + enumerable: !0, + get: function() { + return Origin3d; + }, + set: function(v) { + Origin3d = v; + } +}); diff --git a/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndCommonRoot.1.normal.js b/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndCommonRoot.1.normal.js index 7143d1d21553a..25b754a11b278 100644 --- a/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndCommonRoot.1.normal.js +++ b/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndCommonRoot.1.normal.js @@ -14,10 +14,19 @@ var A; (function(A) { var Point; (function(Point) { - var Origin = Point.Origin = { + var Origin = { x: 0, y: 0 }; + Object.defineProperty(Point, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); })(Point = A.Point || (A.Point = {})); })(A || (A = {})); //// [test.ts] @@ -37,10 +46,19 @@ var B; }; B.Point = Point; (function(Point) { - var Origin = Point.Origin = { + var Origin = { x: 0, y: 0 }; + Object.defineProperty(Point, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); })(Point = B.Point || (B.Point = {})); })(B || (B = {})); var fn; diff --git a/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndCommonRoot.2.minified.js b/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndCommonRoot.2.minified.js index 887b1260c6c05..1e96c351d3101 100644 --- a/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndCommonRoot.2.minified.js +++ b/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndCommonRoot.2.minified.js @@ -7,22 +7,38 @@ var A; }; }; //// [module.ts] -var A, A1; -((A1 = A || (A = {})).Point || (A1.Point = {})).Origin = { +var A, A1, Point, Origin; +Point = (A1 = A || (A = {})).Point || (A1.Point = {}), Origin = { x: 0, y: 0 -}; +}, Object.defineProperty(Point, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}); //// [test.ts] A.Point, A.Point(), A.Point.Origin; // not expected to be an error. //// [simple.ts] -var B, B1, Point; +var B, B1, Point, Point1, Origin; Point = function() { return { x: 0, y: 0 }; -}, (B1 = B || (B = {})).Point = Point, (Point = B1.Point || (B1.Point = {})).Origin = { +}, (B1 = B || (B = {})).Point = Point, Point1 = Point = B1.Point || (B1.Point = {}), Origin = { x: 0, y: 0 -}, B.Point, B.Point(), B.Point.Origin; +}, Object.defineProperty(Point1, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}), B.Point, B.Point(), B.Point.Origin; diff --git a/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndDifferentCommonRoot.1.normal.js b/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndDifferentCommonRoot.1.normal.js index 32c3461ce4549..1368226a54f1d 100644 --- a/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndDifferentCommonRoot.1.normal.js +++ b/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndDifferentCommonRoot.1.normal.js @@ -14,10 +14,19 @@ var B; (function(B) { var Point; (function(Point) { - var Origin = Point.Origin = { + var Origin = { x: 0, y: 0 }; + Object.defineProperty(Point, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); })(Point = B.Point || (B.Point = {})); })(B || (B = {})); //// [test.ts] diff --git a/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndDifferentCommonRoot.2.minified.js b/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndDifferentCommonRoot.2.minified.js index a8159472db87d..5f2606526e80f 100644 --- a/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndDifferentCommonRoot.2.minified.js +++ b/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndDifferentCommonRoot.2.minified.js @@ -7,10 +7,18 @@ var A; }; }; //// [module.ts] -var B, B1; -((B1 = B || (B = {})).Point || (B1.Point = {})).Origin = { +var B, B1, Point, Origin; +Point = (B1 = B || (B = {})).Point || (B1.Point = {}), Origin = { x: 0, y: 0 -}; +}, Object.defineProperty(Point, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}); //// [test.ts] A.Point, B.Point.Origin; diff --git a/crates/swc/tests/tsc-references/ModuleAndClassWithSameNameAndCommonRoot.1.normal.js b/crates/swc/tests/tsc-references/ModuleAndClassWithSameNameAndCommonRoot.1.normal.js index 07a64bbeea3ed..c79ed4ea29196 100644 --- a/crates/swc/tests/tsc-references/ModuleAndClassWithSameNameAndCommonRoot.1.normal.js +++ b/crates/swc/tests/tsc-references/ModuleAndClassWithSameNameAndCommonRoot.1.normal.js @@ -1,19 +1,26 @@ //// [module.ts] var X; (function(X) { - var Y; (function(Y) { var Point; - (function(Point1) { - var Origin = Point1.Origin = new Point(0, 0); + (function(Point) { + var Origin = new Point(0, 0); + Object.defineProperty(Point, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); })(Point = Y.Point || (Y.Point = {})); - })(Y = X.Y || (X.Y = {})); + })(X.Y || (X.Y = {})); })(X || (X = {})); //// [classPoint.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var X; (function(X) { - var Y; (function(Y) { var Point = function Point(x, y) { "use strict"; @@ -22,12 +29,22 @@ var X; this.y = y; }; Y.Point = Point; - })(Y = X.Y || (X.Y = {})); + })(X.Y || (X.Y = {})); })(X || (X = {})); //// [simple.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(function(A1) { - var Instance = A1.Instance = new A(); +var A; +(function(A) { + var Instance = new A(); + Object.defineProperty(A, "Instance", { + enumerable: true, + get: function get() { + return Instance; + }, + set: function set(v) { + Instance = v; + } + }); })(A || (A = {})); // duplicate identifier var A = function A() { diff --git a/crates/swc/tests/tsc-references/ModuleAndClassWithSameNameAndCommonRoot.2.minified.js b/crates/swc/tests/tsc-references/ModuleAndClassWithSameNameAndCommonRoot.2.minified.js index ea92a3f1142eb..71a76728db236 100644 --- a/crates/swc/tests/tsc-references/ModuleAndClassWithSameNameAndCommonRoot.2.minified.js +++ b/crates/swc/tests/tsc-references/ModuleAndClassWithSameNameAndCommonRoot.2.minified.js @@ -1,6 +1,14 @@ //// [module.ts] -var X, X1, Y, Point; -(Point = (Y = (X1 = X || (X = {})).Y || (X1.Y = {})).Point || (Y.Point = {})).Origin = new Point(0, 0); +var X, X1, Y, Point, Origin; +Origin = new (Point = (Y = (X1 = X || (X = {})).Y || (X1.Y = {})).Point || (Y.Point = {}))(0, 0), Object.defineProperty(Point, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}); //// [classPoint.ts] var X, X1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; @@ -9,8 +17,16 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; }; //// [simple.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(A || (A = {})).Instance = new A(); +Instance = new (A = A1 || (A1 = {}))(), Object.defineProperty(A, "Instance", { + enumerable: !0, + get: function() { + return Instance; + }, + set: function(v) { + Instance = v; + } +}); // duplicate identifier -var A = function A() { +var A, Instance, A1 = function A() { _class_call_check(this, A); }; diff --git a/crates/swc/tests/tsc-references/ModuleAndEnumWithSameNameAndCommonRoot.1.normal.js b/crates/swc/tests/tsc-references/ModuleAndEnumWithSameNameAndCommonRoot.1.normal.js index 57d96cf93bd10..380826b8c0e73 100644 --- a/crates/swc/tests/tsc-references/ModuleAndEnumWithSameNameAndCommonRoot.1.normal.js +++ b/crates/swc/tests/tsc-references/ModuleAndEnumWithSameNameAndCommonRoot.1.normal.js @@ -15,6 +15,6 @@ var enumdule; enumdule[enumdule["Blue"] = 1] = "Blue"; })(enumdule || (enumdule = {})); var x; -var x = enumdule.Red; +var x = 0; var y; var y = new enumdule.Point(0, 0); diff --git a/crates/swc/tests/tsc-references/ModuleAndEnumWithSameNameAndCommonRoot.2.minified.js b/crates/swc/tests/tsc-references/ModuleAndEnumWithSameNameAndCommonRoot.2.minified.js index 0ef361d19e67f..7a8496adc0495 100644 --- a/crates/swc/tests/tsc-references/ModuleAndEnumWithSameNameAndCommonRoot.2.minified.js +++ b/crates/swc/tests/tsc-references/ModuleAndEnumWithSameNameAndCommonRoot.2.minified.js @@ -3,4 +3,4 @@ var enumdule, enumdule1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; (enumdule || (enumdule = {})).Point = function Point(x, y) { _class_call_check(this, Point), this.x = x, this.y = y; -}, (enumdule1 = enumdule || (enumdule = {}))[enumdule1.Red = 0] = "Red", enumdule1[enumdule1.Blue = 1] = "Blue", enumdule.Red, new enumdule.Point(0, 0); +}, (enumdule1 = enumdule || (enumdule = {}))[enumdule1.Red = 0] = "Red", enumdule1[enumdule1.Blue = 1] = "Blue", new enumdule.Point(0, 0); diff --git a/crates/swc/tests/tsc-references/ModuleAndFunctionWithSameNameAndCommonRoot.1.normal.js b/crates/swc/tests/tsc-references/ModuleAndFunctionWithSameNameAndCommonRoot.1.normal.js index 64cda8adfd2cf..126d604771d88 100644 --- a/crates/swc/tests/tsc-references/ModuleAndFunctionWithSameNameAndCommonRoot.1.normal.js +++ b/crates/swc/tests/tsc-references/ModuleAndFunctionWithSameNameAndCommonRoot.1.normal.js @@ -3,10 +3,19 @@ var A; (function(A) { var Point; (function(Point) { - var Origin = Point.Origin = { + var Origin = { x: 0, y: 0 }; + Object.defineProperty(Point, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); })(Point = A.Point || (A.Point = {})); })(A || (A = {})); //// [function.ts] @@ -29,11 +38,21 @@ var B; y: 0 }; }; + var Point; (function(Point) { - var Origin = Point.Origin = { + var Origin = { x: 0, y: 0 }; + Object.defineProperty(Point, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); })(Point = B.Point || (B.Point = {})); B.Point = Point; })(B || (B = {})); diff --git a/crates/swc/tests/tsc-references/ModuleAndFunctionWithSameNameAndCommonRoot.2.minified.js b/crates/swc/tests/tsc-references/ModuleAndFunctionWithSameNameAndCommonRoot.2.minified.js index 58e881c4a1d21..71565f5d00b04 100644 --- a/crates/swc/tests/tsc-references/ModuleAndFunctionWithSameNameAndCommonRoot.2.minified.js +++ b/crates/swc/tests/tsc-references/ModuleAndFunctionWithSameNameAndCommonRoot.2.minified.js @@ -1,9 +1,17 @@ //// [module.ts] -var A, A1; -((A1 = A || (A = {})).Point || (A1.Point = {})).Origin = { +var A, A1, Point, Origin; +Point = (A1 = A || (A = {})).Point || (A1.Point = {}), Origin = { x: 0, y: 0 -}; +}, Object.defineProperty(Point, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}); //// [function.ts] var A; (A || (A = {})).Point = function() { @@ -13,13 +21,21 @@ var A; }; }; //// [simple.ts] -var B, B1, Point; +var B, B1, Point, Point1, Origin; Point = function() { return { x: 0, y: 0 }; -}, (Point = (B1 = B || (B = {})).Point || (B1.Point = {})).Origin = { +}, Point1 = Point = (B1 = B || (B = {})).Point || (B1.Point = {}), Origin = { x: 0, y: 0 -}, B1.Point = Point; +}, Object.defineProperty(Point1, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}), B1.Point = Point; diff --git a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedClasses.1.normal.js b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedClasses.1.normal.js index 6d07283688bad..f09cf6c6b2059 100644 --- a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedClasses.1.normal.js +++ b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedClasses.1.normal.js @@ -2,11 +2,11 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var A; (function(A) { - var _$A = function A() { + var A1 = function A() { "use strict"; _class_call_check(this, A); }; - A.A = _$A; + A.A = A1; var AG = function AG() { "use strict"; _class_call_check(this, AG); diff --git a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedImportAlias.1.normal.js b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedImportAlias.1.normal.js index 4e93792114600..1366fbb4d7e60 100644 --- a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedImportAlias.1.normal.js +++ b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedImportAlias.1.normal.js @@ -12,17 +12,34 @@ var B; })(B || (B = {})); var Geometry; (function(Geometry) { - var Points = A; - Geometry.Points = Points; + var Points = Geometry.Points = A; var Lines = B; - var Origin = Geometry.Origin = { + var Origin = { x: 0, y: 0 }; - var Unit = Geometry.Unit = new Lines.Line(Origin, { + Object.defineProperty(Geometry, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); + var Unit = new Lines.Line(Origin, { x: 1, y: 0 }); + Object.defineProperty(Geometry, "Unit", { + enumerable: true, + get: function get() { + return Unit; + }, + set: function set(v) { + Unit = v; + } + }); })(Geometry || (Geometry = {})); // expected to work since all are exported var p; diff --git a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedImportAlias.2.minified.js b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedImportAlias.2.minified.js index c8f78d8675388..1d688751e948e 100644 --- a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedImportAlias.2.minified.js +++ b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedImportAlias.2.minified.js @@ -1,12 +1,28 @@ //// [ModuleWithExportedAndNonExportedImportAlias.ts] -var B, Geometry, Geometry1, Points, Lines, Origin; +var B, Geometry, Geometry1, Lines, Origin, Unit; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; (B || (B = {})).Line = function Line(start, end) { _class_call_check(this, Line), this.start = start, this.end = end; -}, Geometry1 = Geometry || (Geometry = {}), Points = A, Geometry1.Points = Points, Lines = B, Origin = Geometry1.Origin = { +}, (Geometry1 = Geometry || (Geometry = {})).Points = A, Lines = B, Origin = { x: 0, y: 0 -}, Geometry1.Unit = new Lines.Line(Origin, { +}, Object.defineProperty(Geometry1, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}), Unit = new Lines.Line(Origin, { x: 1, y: 0 +}), Object.defineProperty(Geometry1, "Unit", { + enumerable: !0, + get: function() { + return Unit; + }, + set: function(v) { + Unit = v; + } }), Geometry.Origin, Geometry.Unit, Geometry.Lines.Line; diff --git a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedVariables.1.normal.js b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedVariables.1.normal.js index d4a16b80aa35d..8997264282556 100644 --- a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedVariables.1.normal.js +++ b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedVariables.1.normal.js @@ -1,7 +1,16 @@ //// [ModuleWithExportedAndNonExportedVariables.ts] var A; (function(A) { - var x = A.x = "hello world"; + var x = "hello world"; + Object.defineProperty(A, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); var y = 12; })(A || (A = {})); var x; diff --git a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedVariables.2.minified.js b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedVariables.2.minified.js index 49a4c717e3185..ec860d8b6f139 100644 --- a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedVariables.2.minified.js +++ b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedVariables.2.minified.js @@ -1,3 +1,11 @@ //// [ModuleWithExportedAndNonExportedVariables.ts] -var A; -(A || (A = {})).x = "hello world", A.x, A.y; +var A, A1, x; +A1 = A || (A = {}), x = "hello world", Object.defineProperty(A1, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}), A.x, A.y; diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName.1.normal.js b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName.1.normal.js index 2514e54c411eb..10a58c8fe0259 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName.1.normal.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName.1.normal.js @@ -29,17 +29,15 @@ var p; var p; var X; (function(X) { - var Y; (function(Y) { - var Z; (function(Z) { var Line = function Line() { "use strict"; _class_call_check(this, Line); }; Z.Line = Line; - })(Z = Y.Z || (Y.Z = {})); - })(Y = X.Y || (X.Y = {})); + })(Y.Z || (Y.Z = {})); + })(X.Y || (X.Y = {})); })(X || (X = {})); (function(X) { var Y; diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.1.normal.js b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.1.normal.js index 2032b0f1e10bd..03522adbbc279 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.1.normal.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.1.normal.js @@ -3,18 +3,27 @@ var A; (function(A) { var Utils; (function(Utils) { - function mirror(p) { + var mirror = function mirror(p) { return { x: p.y, y: p.x }; - } + }; Utils.mirror = mirror; })(Utils = A.Utils || (A.Utils = {})); - var Origin = A.Origin = { + var Origin = { x: 0, y: 0 }; + Object.defineProperty(A, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); })(A || (A = {})); //// [part2.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.2.minified.js b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.2.minified.js index b33996d1ac946..76539ccd93dbf 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.2.minified.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.2.minified.js @@ -1,14 +1,22 @@ //// [part1.ts] -var A, A1; +var A, A1, Origin; ((A1 = A || (A = {})).Utils || (A1.Utils = {})).mirror = function(p) { return { x: p.y, y: p.x }; -}, A1.Origin = { +}, Origin = { x: 0, y: 0 -}; +}, Object.defineProperty(A1, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}); //// [part2.ts] var A, A1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.1.normal.js b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.1.normal.js index 9bcdf5ad7ffa8..526414611bf0d 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.1.normal.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.1.normal.js @@ -17,17 +17,15 @@ var A; })(A || (A = {})); var X; (function(X) { - var Y; (function(Y) { - var Z; (function(Z) { var Line = function Line() { "use strict"; _class_call_check(this, Line); }; Z.Line = Line; - })(Z = Y.Z || (Y.Z = {})); - })(Y = X.Y || (X.Y = {})); + })(Y.Z || (Y.Z = {})); + })(X.Y || (X.Y = {})); })(X || (X = {})); (function(X) { var Y; diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.1.normal.js b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.1.normal.js index aaaae6725ec0c..724748260db47 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.1.normal.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.1.normal.js @@ -3,27 +3,45 @@ export var A; (function(A) { var Utils; (function(Utils) { - function mirror(p) { + var mirror = function mirror(p) { return { x: p.y, y: p.x }; - } + }; Utils.mirror = mirror; })(Utils = A.Utils || (A.Utils = {})); - var Origin = A.Origin = { + var Origin = { x: 0, y: 0 }; + Object.defineProperty(A, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); })(A || (A = {})); //// [part2.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; export var A; (function(A) { - var Origin = A.Origin = { + var Origin = { x: 0, y: 0 }; + Object.defineProperty(A, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); var Utils; (function(Utils) { var Plane = function Plane(tl, br) { diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.2.minified.js b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.2.minified.js index f9ce03b67751d..0e5e33ce27f16 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.2.minified.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.2.minified.js @@ -1,5 +1,5 @@ //// [part1.ts] -var A; +var A, Origin; var A1; export { A1 as A }; ((A = A1 || (A1 = {})).Utils || (A.Utils = {})).mirror = function(p) { @@ -7,18 +7,34 @@ export { A1 as A }; x: p.y, y: p.x }; -}, A.Origin = { +}, Origin = { x: 0, y: 0 -}; +}, Object.defineProperty(A, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}); //// [part2.ts] -var A; +var A, Origin; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var A1; export { A1 as A }; -(A = A1 || (A1 = {})).Origin = { +A = A1 || (A1 = {}), Origin = { x: 0, y: 0 -}, (A.Utils || (A.Utils = {})).Plane = function Plane(tl, br) { +}, Object.defineProperty(A, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}), (A.Utils || (A.Utils = {})).Plane = function Plane(tl, br) { _class_call_check(this, Plane), this.tl = tl, this.br = br; }; diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.1.normal.js b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.1.normal.js index 6423aa9b3f9e8..63bee12f32144 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.1.normal.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.1.normal.js @@ -2,17 +2,32 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var A; (function(A) { - var B; (function(B) { var x; - B.x = x; - })(B = A.B || (A.B = {})); + Object.defineProperty(B, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); + })(A.B || (A.B = {})); })(A || (A = {})); (function(A) { var B; (function(B) { var x; - B.x = x; + Object.defineProperty(B, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(B || (B = {})); })(A || (A = {})); // ensure the right var decl is exported @@ -20,17 +35,15 @@ var x; var x = A.B.x; var X; (function(X) { - var Y; (function(Y) { - var Z; (function(Z) { var Line = function Line() { "use strict"; _class_call_check(this, Line); }; Z.Line = Line; - })(Z = Y.Z || (Y.Z = {})); - })(Y = X.Y || (X.Y = {})); + })(Y.Z || (Y.Z = {})); + })(X.Y || (X.Y = {})); })(X || (X = {})); (function(X) { var Y; diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.2.minified.js b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.2.minified.js index 94fda1145bca9..19a3e91c58f2a 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.2.minified.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.2.minified.js @@ -1,7 +1,23 @@ //// [TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.ts] var A, X, A1, x, B, x1, X1, Y, X2, Z; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -((A1 = A || (A = {})).B || (A1.B = {})).x = x, A || (A = {}), (B || (B = {})).x = x1, A.B.x, ((Y = (X1 = X || (X = {})).Y || (X1.Y = {})).Z || (Y.Z = {})).Line = function Line() { +Object.defineProperty((A1 = A || (A = {})).B || (A1.B = {}), "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}), A || (A = {}), Object.defineProperty(B || (B = {}), "x", { + enumerable: !0, + get: function() { + return x1; + }, + set: function(v) { + x1 = v; + } +}), A.B.x, ((Y = (X1 = X || (X = {})).Y || (X1.Y = {})).Z || (Y.Z = {})).Line = function Line() { _class_call_check(this, Line); }, (X2 = X || (X = {})).Y || (X2.Y = {}), (Z || (Z = {})).Line = function Line() { _class_call_check(this, Line); diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndDifferentCommonRoot.1.normal.js b/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndDifferentCommonRoot.1.normal.js index e1a0a2749eea5..866b09cfd7cfb 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndDifferentCommonRoot.1.normal.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndDifferentCommonRoot.1.normal.js @@ -5,12 +5,12 @@ var Root; (function(A) { var Utils; (function(Utils) { - function mirror(p) { + var mirror = function mirror(p) { return { x: p.y, y: p.x }; - } + }; Utils.mirror = mirror; })(Utils = A.Utils || (A.Utils = {})); })(A = Root.A || (Root.A = {})); @@ -21,10 +21,19 @@ var otherRoot; (function(otherRoot) { var A; (function(A) { - var Origin = A.Origin = { + var Origin = { x: 0, y: 0 }; + Object.defineProperty(A, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); var Utils; (function(Utils) { var Plane = function Plane(tl, br) { diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndDifferentCommonRoot.2.minified.js b/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndDifferentCommonRoot.2.minified.js index c049162e2b3d5..80204ca335b70 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndDifferentCommonRoot.2.minified.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndDifferentCommonRoot.2.minified.js @@ -7,11 +7,19 @@ var Root, Root1, A; }; }; //// [part2.ts] -var otherRoot, otherRoot1, A; +var otherRoot, otherRoot1, A, Origin; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(A = (otherRoot1 = otherRoot || (otherRoot = {})).A || (otherRoot1.A = {})).Origin = { +A = (otherRoot1 = otherRoot || (otherRoot = {})).A || (otherRoot1.A = {}), Origin = { x: 0, y: 0 -}, (A.Utils || (A.Utils = {})).Plane = function Plane(tl, br) { +}, Object.defineProperty(A, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}), (A.Utils || (A.Utils = {})).Plane = function Plane(tl, br) { _class_call_check(this, Plane), this.tl = tl, this.br = br; }; diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndSameCommonRoot.1.normal.js b/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndSameCommonRoot.1.normal.js index 398c63a03d6b8..a85ea60332961 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndSameCommonRoot.1.normal.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndSameCommonRoot.1.normal.js @@ -3,12 +3,12 @@ var A; (function(A) { var Utils; (function(Utils) { - function mirror(p) { + var mirror = function mirror(p) { return { x: p.y, y: p.x }; - } + }; Utils.mirror = mirror; })(Utils = A.Utils || (A.Utils = {})); })(A || (A = {})); @@ -16,10 +16,19 @@ var A; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var A; (function(A) { - var Origin = A.Origin = { + var Origin = { x: 0, y: 0 }; + Object.defineProperty(A, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); var Utils; (function(Utils) { var Plane = function Plane(tl, br) { diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndSameCommonRoot.2.minified.js b/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndSameCommonRoot.2.minified.js index 1095748df5d3c..62f1cad2fef2d 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndSameCommonRoot.2.minified.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndSameCommonRoot.2.minified.js @@ -7,12 +7,20 @@ var A, A1; }; }; //// [part2.ts] -var A, A1; +var A, A1, Origin; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(A1 = A || (A = {})).Origin = { +A1 = A || (A = {}), Origin = { x: 0, y: 0 -}, (A1.Utils || (A1.Utils = {})).Plane = function Plane(tl, br) { +}, Object.defineProperty(A1, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}), (A1.Utils || (A1.Utils = {})).Plane = function Plane(tl, br) { _class_call_check(this, Plane), this.tl = tl, this.br = br; }; //// [part3.ts] diff --git a/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType.1.normal.js b/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType.1.normal.js index d8a70a2bf3997..807a829dcc986 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType.1.normal.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType.1.normal.js @@ -18,7 +18,15 @@ var E; var M; (function(M) { var a; - M.a = a; + Object.defineProperty(M, "a", { + enumerable: true, + get: function get() { + return a; + }, + set: function set(v) { + a = v; + } + }); })(M || (M = {})); var a; var b; @@ -42,7 +50,7 @@ var r11 = a + foo(); var r12 = a + C; var r13 = a + new C(); var r14 = a + E; -var r15 = a + E.a; +var r15 = a + 0; var r16 = a + M; var r17 = a + ""; var r18 = a + 123; diff --git a/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType.2.minified.js b/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType.2.minified.js index ea119e87116b1..93b2770a690a4 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType.2.minified.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType.2.minified.js @@ -6,4 +6,12 @@ var E, a, E1, M, C = function() { } return C.foo = function() {}, C; }(); -(E = E1 || (E1 = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", (M || (M = {})).a = a, new C(), E1.a; +(E = E1 || (E1 = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", Object.defineProperty(M || (M = {}), "a", { + enumerable: !0, + get: function() { + return a; + }, + set: function(v) { + a = v; + } +}), new C(); diff --git a/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands.1.normal.js b/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands.1.normal.js index badf396e49e9f..55c8845e7041b 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands.1.normal.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands.1.normal.js @@ -18,7 +18,15 @@ var E; var M; (function(M) { var a; - M.a = a; + Object.defineProperty(M, "a", { + enumerable: true, + get: function get() { + return a; + }, + set: function set(v) { + a = v; + } + }); })(M || (M = {})); var a; var b; @@ -45,6 +53,6 @@ var r14 = b + d; var r15 = b + foo; var r16 = b + foo(); var r17 = b + C; -var r18 = E.a + new C(); -var r19 = E.a + C.foo(); -var r20 = E.a + M; +var r18 = 0 + new C(); +var r19 = 0 + C.foo(); +var r20 = 0 + M; diff --git a/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands.2.minified.js b/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands.2.minified.js index b9d3efb647f2b..58444fd81a8d7 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands.2.minified.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands.2.minified.js @@ -6,4 +6,12 @@ var E, a, E1, M, C = function() { } return C.foo = function() {}, C; }(); -(E = E1 || (E1 = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", (M || (M = {})).a = a, E1.a, new C(), E1.a, C.foo(), E1.a; +(E = E1 || (E1 = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", Object.defineProperty(M || (M = {}), "a", { + enumerable: !0, + get: function() { + return a; + }, + set: function(v) { + a = v; + } +}), new C(), C.foo(); diff --git a/crates/swc/tests/tsc-references/additionOperatorWithNullValueAndValidOperator.1.normal.js b/crates/swc/tests/tsc-references/additionOperatorWithNullValueAndValidOperator.1.normal.js index 230db082fc95e..9e312abf9115f 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithNullValueAndValidOperator.1.normal.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithNullValueAndValidOperator.1.normal.js @@ -17,13 +17,13 @@ var r2 = a + null; var r3 = null + b; var r4 = null + 1; var r5 = null + c; -var r6 = null + E.a; -var r7 = null + E["a"]; +var r6 = null + 0; +var r7 = null + 0; var r8 = b + null; var r9 = 1 + null; var r10 = c + null; -var r11 = E.a + null; -var r12 = E["a"] + null; +var r11 = 0 + null; +var r12 = 0 + null; // null + string var r13 = null + d; var r14 = null + ""; diff --git a/crates/swc/tests/tsc-references/additionOperatorWithNullValueAndValidOperator.2.minified.js b/crates/swc/tests/tsc-references/additionOperatorWithNullValueAndValidOperator.2.minified.js index ec2dce0a43ffa..8f2e61bd99542 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithNullValueAndValidOperator.2.minified.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithNullValueAndValidOperator.2.minified.js @@ -1,4 +1,4 @@ //// [additionOperatorWithNullValueAndValidOperator.ts] // If one operand is the null or undefined value, it is treated as having the type of the other operand. var E, E1; -(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E1[E1.c = 2] = "c", E.a, E.a, E.a, E.a; +(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E1[E1.c = 2] = "c"; diff --git a/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum.1.normal.js b/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum.1.normal.js index 9c972017f28f7..b3b3c7ac7dd32 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum.1.normal.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum.1.normal.js @@ -17,10 +17,10 @@ var r2 = a + b; var r3 = b + a; var r4 = b + b; var r5 = 0 + a; -var r6 = E.a + 0; -var r7 = E.a + E.b; -var r8 = E["a"] + E["b"]; -var r9 = E["a"] + F["c"]; +var r6 = 0 + 0; +var r7 = 0 + 1; +var r8 = 0 + 1; +var r9 = 0 + 0; var r10 = a + c; var r11 = c + a; var r12 = b + c; diff --git a/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum.2.minified.js b/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum.2.minified.js index cb788d95f012e..4ae8f17e89efe 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum.2.minified.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum.2.minified.js @@ -1,3 +1,3 @@ //// [additionOperatorWithNumberAndEnum.ts] var E, F, E1, F1; -(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", (F1 = F || (F = {}))[F1.c = 0] = "c", F1[F1.d = 1] = "d", E.a, E.a, E.b, E.a, E.b, E.a, F.c; +(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", (F1 = F || (F = {}))[F1.c = 0] = "c", F1[F1.d = 1] = "d"; diff --git a/crates/swc/tests/tsc-references/additionOperatorWithStringAndEveryType.1.normal.js b/crates/swc/tests/tsc-references/additionOperatorWithStringAndEveryType.1.normal.js index 815e8cb35fd3d..af565770a7178 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithStringAndEveryType.1.normal.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithStringAndEveryType.1.normal.js @@ -32,7 +32,7 @@ var r13 = f + x; var r14 = g + x; // other cases var r15 = x + E; -var r16 = x + E.a; +var r16 = x + 0; var r17 = x + ""; var r18 = x + 0; var r19 = x + { diff --git a/crates/swc/tests/tsc-references/additionOperatorWithStringAndEveryType.2.minified.js b/crates/swc/tests/tsc-references/additionOperatorWithStringAndEveryType.2.minified.js index 3628972cc09db..489e001a73fa9 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithStringAndEveryType.2.minified.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithStringAndEveryType.2.minified.js @@ -1,3 +1,3 @@ //// [additionOperatorWithStringAndEveryType.ts] var E, E1; -(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E1[E1.c = 2] = "c", E.a; +(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E1[E1.c = 2] = "c"; diff --git a/crates/swc/tests/tsc-references/additionOperatorWithUndefinedValueAndValidOperator.1.normal.js b/crates/swc/tests/tsc-references/additionOperatorWithUndefinedValueAndValidOperator.1.normal.js index 0a4e187a95707..d3cd3221e8143 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithUndefinedValueAndValidOperator.1.normal.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithUndefinedValueAndValidOperator.1.normal.js @@ -17,13 +17,13 @@ var r2 = a + undefined; var r3 = undefined + b; var r4 = undefined + 1; var r5 = undefined + c; -var r6 = undefined + E.a; -var r7 = undefined + E["a"]; +var r6 = undefined + 0; +var r7 = undefined + 0; var r8 = b + undefined; var r9 = 1 + undefined; var r10 = c + undefined; -var r11 = E.a + undefined; -var r12 = E["a"] + undefined; +var r11 = 0 + undefined; +var r12 = 0 + undefined; // undefined + string var r13 = undefined + d; var r14 = undefined + ""; diff --git a/crates/swc/tests/tsc-references/additionOperatorWithUndefinedValueAndValidOperator.2.minified.js b/crates/swc/tests/tsc-references/additionOperatorWithUndefinedValueAndValidOperator.2.minified.js index e79b8f51961e3..73d77d3cb887f 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithUndefinedValueAndValidOperator.2.minified.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithUndefinedValueAndValidOperator.2.minified.js @@ -1,4 +1,4 @@ //// [additionOperatorWithUndefinedValueAndValidOperator.ts] // If one operand is the null or undefined value, it is treated as having the type of the other operand. var E, E1; -(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E1[E1.c = 2] = "c", E.a, E.a, E.a, E.a; +(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E1[E1.c = 2] = "c"; diff --git a/crates/swc/tests/tsc-references/ambientDeclarations.1.normal.js b/crates/swc/tests/tsc-references/ambientDeclarations.1.normal.js index 4300cd6f6a716..a5ee7ff03c865 100644 --- a/crates/swc/tests/tsc-references/ambientDeclarations.1.normal.js +++ b/crates/swc/tests/tsc-references/ambientDeclarations.1.normal.js @@ -1,26 +1,5 @@ //// [ambientDeclarations.ts] // Ambient variable without type annotation -var // Ambient enum -E1; -(function(E1) { - E1[E1["x"] = 0] = "x"; - E1[E1["y"] = 1] = "y"; - E1[E1["z"] = 2] = "z"; -})(E1 || (E1 = {})); -var // Ambient enum with integer literal initializer -E2; -(function(E2) { - E2[E2["q"] = 0] = "q"; - E2[E2["a"] = 1] = "a"; - E2[E2["b"] = 2] = "b"; - E2[E2["c"] = 2] = "c"; - E2[E2["d"] = 3] = "d"; -})(E2 || (E2 = {})); -var // Ambient enum members are always exported with or without export keyword -E3; -(function(E3) { - E3[E3["A"] = 0] = "A"; -})(E3 || (E3 = {})); var x = E3.B; // Ambient module members are always exported with or without export keyword var p = M1.x; diff --git a/crates/swc/tests/tsc-references/ambientDeclarations.2.minified.js b/crates/swc/tests/tsc-references/ambientDeclarations.2.minified.js index c094137d4eb06..55a7bd1f6fcb5 100644 --- a/crates/swc/tests/tsc-references/ambientDeclarations.2.minified.js +++ b/crates/swc/tests/tsc-references/ambientDeclarations.2.minified.js @@ -1,7 +1,3 @@ //// [ambientDeclarations.ts] // Ambient variable without type annotation -var // Ambient enum -E1, // Ambient enum with integer literal initializer -E2, // Ambient enum members are always exported with or without export keyword -E3, E11, E21, E31; -(E11 = E1 || (E1 = {}))[E11.x = 0] = "x", E11[E11.y = 1] = "y", E11[E11.z = 2] = "z", (E21 = E2 || (E2 = {}))[E21.q = 0] = "q", E21[E21.a = 1] = "a", E21[E21.b = 2] = "b", E21[E21.c = 2] = "c", E21[E21.d = 3] = "d", (E31 = E3 || (E3 = {}))[E31.A = 0] = "A", E3.B, M1.x, M1.fn(); +E3.B, M1.x, M1.fn(); diff --git a/crates/swc/tests/tsc-references/ambientDeclarationsExternal.1.normal.js b/crates/swc/tests/tsc-references/ambientDeclarationsExternal.1.normal.js index fa1ae4c8db85d..9ec29fadda0c8 100644 --- a/crates/swc/tests/tsc-references/ambientDeclarationsExternal.1.normal.js +++ b/crates/swc/tests/tsc-references/ambientDeclarationsExternal.1.normal.js @@ -5,16 +5,6 @@ //// [consumer.ts] //! //! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. -//! ,-[1:1] -//! 1 | /// -//! 2 | import imp1 = require('equ'); -//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -//! 3 | -//! 4 | -//! 5 | // Ambient external module members are always exported with or without export keyword when module lacks export assignment -//! `---- -//! -//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. //! ,-[3:1] //! 3 | //! 4 | diff --git a/crates/swc/tests/tsc-references/ambientDeclarationsExternal.2.minified.js b/crates/swc/tests/tsc-references/ambientDeclarationsExternal.2.minified.js index fa1ae4c8db85d..9ec29fadda0c8 100644 --- a/crates/swc/tests/tsc-references/ambientDeclarationsExternal.2.minified.js +++ b/crates/swc/tests/tsc-references/ambientDeclarationsExternal.2.minified.js @@ -5,16 +5,6 @@ //// [consumer.ts] //! //! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. -//! ,-[1:1] -//! 1 | /// -//! 2 | import imp1 = require('equ'); -//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -//! 3 | -//! 4 | -//! 5 | // Ambient external module members are always exported with or without export keyword when module lacks export assignment -//! `---- -//! -//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. //! ,-[3:1] //! 3 | //! 4 | diff --git a/crates/swc/tests/tsc-references/ambientDeclarationsPatterns_merging2.1.normal.js b/crates/swc/tests/tsc-references/ambientDeclarationsPatterns_merging2.1.normal.js index 4705cba3b1c08..f020eba1405bb 100644 --- a/crates/swc/tests/tsc-references/ambientDeclarationsPatterns_merging2.1.normal.js +++ b/crates/swc/tests/tsc-references/ambientDeclarationsPatterns_merging2.1.normal.js @@ -2,4 +2,4 @@ //// [testA.ts] export { }; //// [testB.ts] -export { }; +export { }; // Error diff --git a/crates/swc/tests/tsc-references/ambientEnumDeclaration1.1.normal.js b/crates/swc/tests/tsc-references/ambientEnumDeclaration1.1.normal.js index d6bb8eb803b49..256c33b7294fd 100644 --- a/crates/swc/tests/tsc-references/ambientEnumDeclaration1.1.normal.js +++ b/crates/swc/tests/tsc-references/ambientEnumDeclaration1.1.normal.js @@ -1,10 +1,2 @@ //// [ambientEnumDeclaration1.ts] // In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions. -var E; -(function(E) { - E[E["a"] = 10] = "a"; - E[E["b"] = 11] = "b"; - E[E["c"] = 11] = "c"; - E[E["d"] = 12] = "d"; - E[E["e"] = 655360] = "e"; -})(E || (E = {})); diff --git a/crates/swc/tests/tsc-references/ambientEnumDeclaration1.2.minified.js b/crates/swc/tests/tsc-references/ambientEnumDeclaration1.2.minified.js index 9f0e613046952..256c33b7294fd 100644 --- a/crates/swc/tests/tsc-references/ambientEnumDeclaration1.2.minified.js +++ b/crates/swc/tests/tsc-references/ambientEnumDeclaration1.2.minified.js @@ -1,4 +1,2 @@ //// [ambientEnumDeclaration1.ts] // In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions. -var E, E1; -(E1 = E || (E = {}))[E1.a = 10] = "a", E1[E1.b = 11] = "b", E1[E1.c = 11] = "c", E1[E1.d = 12] = "d", E1[E1.e = 655360] = "e"; diff --git a/crates/swc/tests/tsc-references/ambientEnumDeclaration2.1.normal.js b/crates/swc/tests/tsc-references/ambientEnumDeclaration2.1.normal.js index 49726d741d03e..85e3b38c6dc3e 100644 --- a/crates/swc/tests/tsc-references/ambientEnumDeclaration2.1.normal.js +++ b/crates/swc/tests/tsc-references/ambientEnumDeclaration2.1.normal.js @@ -1,13 +1,3 @@ //// [ambientEnumDeclaration2.ts] // In ambient enum declarations that specify no const modifier, enum member declarations // that omit a value are considered computed members (as opposed to having auto- incremented values assigned). -var E; -(function(E) { - E[E["a"] = 0] = "a"; - E[E["b"] = 1] = "b"; -})(E || (E = {})); -var E1; -(function(E1) { - E1[E1["a"] = 0] = "a"; - E1[E1["b"] = 1] = "b"; -})(E1 || (E1 = {})); diff --git a/crates/swc/tests/tsc-references/ambientEnumDeclaration2.2.minified.js b/crates/swc/tests/tsc-references/ambientEnumDeclaration2.2.minified.js index b68425370e3e8..85e3b38c6dc3e 100644 --- a/crates/swc/tests/tsc-references/ambientEnumDeclaration2.2.minified.js +++ b/crates/swc/tests/tsc-references/ambientEnumDeclaration2.2.minified.js @@ -1,5 +1,3 @@ //// [ambientEnumDeclaration2.ts] // In ambient enum declarations that specify no const modifier, enum member declarations // that omit a value are considered computed members (as opposed to having auto- incremented values assigned). -var E, E1, E2, E11; -(E2 = E || (E = {}))[E2.a = 0] = "a", E2[E2.b = 1] = "b", (E11 = E1 || (E1 = {}))[E11.a = 0] = "a", E11[E11.b = 1] = "b"; diff --git a/crates/swc/tests/tsc-references/ambientInsideNonAmbient.1.normal.js b/crates/swc/tests/tsc-references/ambientInsideNonAmbient.1.normal.js index d6e683b239d91..17fc7da7e6cbc 100644 --- a/crates/swc/tests/tsc-references/ambientInsideNonAmbient.1.normal.js +++ b/crates/swc/tests/tsc-references/ambientInsideNonAmbient.1.normal.js @@ -1,6 +1,5 @@ //// [ambientInsideNonAmbient.ts] +var M; +(function(M) {})(M || (M = {})); var M2; -(function(M2) { - var E; - (function(E) {})(E || (E = {})); -})(M2 || (M2 = {})); +(function(M2) {})(M2 || (M2 = {})); diff --git a/crates/swc/tests/tsc-references/ambientInsideNonAmbient.2.minified.js b/crates/swc/tests/tsc-references/ambientInsideNonAmbient.2.minified.js index 327c9105a1c5e..b133fdd22be32 100644 --- a/crates/swc/tests/tsc-references/ambientInsideNonAmbient.2.minified.js +++ b/crates/swc/tests/tsc-references/ambientInsideNonAmbient.2.minified.js @@ -1,3 +1,3 @@ //// [ambientInsideNonAmbient.ts] -var M2, E; -M2 || (M2 = {}), E || (E = {}); +var M, M2; +M || (M = {}), M2 || (M2 = {}); diff --git a/crates/swc/tests/tsc-references/anyAssignabilityInInheritance.1.normal.js b/crates/swc/tests/tsc-references/anyAssignabilityInInheritance.1.normal.js index 74f190e953822..3dfabf9edf661 100644 --- a/crates/swc/tests/tsc-references/anyAssignabilityInInheritance.1.normal.js +++ b/crates/swc/tests/tsc-references/anyAssignabilityInInheritance.1.normal.js @@ -29,7 +29,16 @@ var E; var r3 = foo3(a); // any function f() {} (function(f) { - var bar = f.bar = 1; + var bar = 1; + Object.defineProperty(f, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(f || (f = {})); var r3 = foo3(a); // any var CC = function CC() { @@ -37,7 +46,16 @@ var CC = function CC() { _class_call_check(this, CC); }; (function(CC) { - var bar = CC.bar = 1; + var bar = 1; + Object.defineProperty(CC, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(CC || (CC = {})); var r3 = foo3(a); // any var r3 = foo3(a); // any diff --git a/crates/swc/tests/tsc-references/anyAssignabilityInInheritance.2.minified.js b/crates/swc/tests/tsc-references/anyAssignabilityInInheritance.2.minified.js index b3b08fa9e1253..0102c6a00644e 100644 --- a/crates/swc/tests/tsc-references/anyAssignabilityInInheritance.2.minified.js +++ b/crates/swc/tests/tsc-references/anyAssignabilityInInheritance.2.minified.js @@ -2,9 +2,25 @@ // any is not a subtype of any other types, errors expected on all the below derived classes unless otherwise noted import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; function f() {} -foo2(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), (E = E1 || (E1 = {}))[E.A = 0] = "A", foo3(a), (f || (f = {})).bar = 1, foo3(a); -var E, a, E1, CC = function CC() { +foo2(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), foo3(a), (E = E1 || (E1 = {}))[E.A = 0] = "A", foo3(a), f1 = f || (f = {}), bar1 = 1, Object.defineProperty(f1, "bar", { + enumerable: !0, + get: function() { + return bar1; + }, + set: function(v) { + bar1 = v; + } +}), foo3(a); +var CC, bar, E, f1, bar1, a, E1, CC1 = function CC() { _class_call_check(this, CC); }; -(CC || (CC = {})).bar = 1, foo3(a), foo3(a), foo3(a); +CC = CC1 || (CC1 = {}), bar = 1, Object.defineProperty(CC, "bar", { + enumerable: !0, + get: function() { + return bar; + }, + set: function(v) { + bar = v; + } +}), foo3(a), foo3(a), foo3(a); // any diff --git a/crates/swc/tests/tsc-references/anyAssignableToEveryType2.1.normal.js b/crates/swc/tests/tsc-references/anyAssignableToEveryType2.1.normal.js index 81c27947866c6..9fdd41012e623 100644 --- a/crates/swc/tests/tsc-references/anyAssignableToEveryType2.1.normal.js +++ b/crates/swc/tests/tsc-references/anyAssignableToEveryType2.1.normal.js @@ -15,12 +15,30 @@ var E; })(E || (E = {})); function f() {} (function(f) { - var bar = f.bar = 1; + var bar = 1; + Object.defineProperty(f, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(f || (f = {})); var c = function c() { "use strict"; _class_call_check(this, c); }; (function(c) { - var bar = c.bar = 1; + var bar = 1; + Object.defineProperty(c, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(c || (c = {})); diff --git a/crates/swc/tests/tsc-references/anyAssignableToEveryType2.2.minified.js b/crates/swc/tests/tsc-references/anyAssignableToEveryType2.2.minified.js index 4b2028134e307..50519c225539b 100644 --- a/crates/swc/tests/tsc-references/anyAssignableToEveryType2.2.minified.js +++ b/crates/swc/tests/tsc-references/anyAssignableToEveryType2.2.minified.js @@ -2,8 +2,24 @@ // any is not a subtype of any other types, but is assignable, all the below should work import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; function f() {} -(E = E1 || (E1 = {}))[E.A = 0] = "A", (f || (f = {})).bar = 1; -var E, E1, c = function c() { +(E = E1 || (E1 = {}))[E.A = 0] = "A", f1 = f || (f = {}), bar1 = 1, Object.defineProperty(f1, "bar", { + enumerable: !0, + get: function() { + return bar1; + }, + set: function(v) { + bar1 = v; + } +}); +var c, bar, E, f1, bar1, E1, c1 = function c() { _class_call_check(this, c); }; -(c || (c = {})).bar = 1; +c = c1 || (c1 = {}), bar = 1, Object.defineProperty(c, "bar", { + enumerable: !0, + get: function() { + return bar; + }, + set: function(v) { + bar = v; + } +}); diff --git a/crates/swc/tests/tsc-references/arithmeticOperatorWithEnum.1.normal.js b/crates/swc/tests/tsc-references/arithmeticOperatorWithEnum.1.normal.js index 03ae1397f40d9..07a3c8bc5ecfb 100644 --- a/crates/swc/tests/tsc-references/arithmeticOperatorWithEnum.1.normal.js +++ b/crates/swc/tests/tsc-references/arithmeticOperatorWithEnum.1.normal.js @@ -14,127 +14,127 @@ var ra2 = c * b; var ra3 = c * c; var ra4 = a * c; var ra5 = b * c; -var ra6 = E.a * a; -var ra7 = E.a * b; -var ra8 = E.a * E.b; -var ra9 = E.a * 1; -var ra10 = a * E.b; -var ra11 = b * E.b; -var ra12 = 1 * E.b; +var ra6 = 0 * a; +var ra7 = 0 * b; +var ra8 = 0 * 1; +var ra9 = 0 * 1; +var ra10 = a * 1; +var ra11 = b * 1; +var ra12 = 1 * 1; // operator / var rb1 = c / a; var rb2 = c / b; var rb3 = c / c; var rb4 = a / c; var rb5 = b / c; -var rb6 = E.a / a; -var rb7 = E.a / b; -var rb8 = E.a / E.b; -var rb9 = E.a / 1; -var rb10 = a / E.b; -var rb11 = b / E.b; -var rb12 = 1 / E.b; +var rb6 = 0 / a; +var rb7 = 0 / b; +var rb8 = 0 / 1; +var rb9 = 0 / 1; +var rb10 = a / 1; +var rb11 = b / 1; +var rb12 = 1 / 1; // operator % var rc1 = c % a; var rc2 = c % b; var rc3 = c % c; var rc4 = a % c; var rc5 = b % c; -var rc6 = E.a % a; -var rc7 = E.a % b; -var rc8 = E.a % E.b; -var rc9 = E.a % 1; -var rc10 = a % E.b; -var rc11 = b % E.b; -var rc12 = 1 % E.b; +var rc6 = 0 % a; +var rc7 = 0 % b; +var rc8 = 0 % 1; +var rc9 = 0 % 1; +var rc10 = a % 1; +var rc11 = b % 1; +var rc12 = 1 % 1; // operator - var rd1 = c - a; var rd2 = c - b; var rd3 = c - c; var rd4 = a - c; var rd5 = b - c; -var rd6 = E.a - a; -var rd7 = E.a - b; -var rd8 = E.a - E.b; -var rd9 = E.a - 1; -var rd10 = a - E.b; -var rd11 = b - E.b; -var rd12 = 1 - E.b; +var rd6 = 0 - a; +var rd7 = 0 - b; +var rd8 = 0 - 1; +var rd9 = 0 - 1; +var rd10 = a - 1; +var rd11 = b - 1; +var rd12 = 1 - 1; // operator << var re1 = c << a; var re2 = c << b; var re3 = c << c; var re4 = a << c; var re5 = b << c; -var re6 = E.a << a; -var re7 = E.a << b; -var re8 = E.a << E.b; -var re9 = E.a << 1; -var re10 = a << E.b; -var re11 = b << E.b; -var re12 = 1 << E.b; +var re6 = 0 << a; +var re7 = 0 << b; +var re8 = 0 << 1; +var re9 = 0 << 1; +var re10 = a << 1; +var re11 = b << 1; +var re12 = 1 << 1; // operator >> var rf1 = c >> a; var rf2 = c >> b; var rf3 = c >> c; var rf4 = a >> c; var rf5 = b >> c; -var rf6 = E.a >> a; -var rf7 = E.a >> b; -var rf8 = E.a >> E.b; -var rf9 = E.a >> 1; -var rf10 = a >> E.b; -var rf11 = b >> E.b; -var rf12 = 1 >> E.b; +var rf6 = 0 >> a; +var rf7 = 0 >> b; +var rf8 = 0 >> 1; +var rf9 = 0 >> 1; +var rf10 = a >> 1; +var rf11 = b >> 1; +var rf12 = 1 >> 1; // operator >>> var rg1 = c >>> a; var rg2 = c >>> b; var rg3 = c >>> c; var rg4 = a >>> c; var rg5 = b >>> c; -var rg6 = E.a >>> a; -var rg7 = E.a >>> b; -var rg8 = E.a >>> E.b; -var rg9 = E.a >>> 1; -var rg10 = a >>> E.b; -var rg11 = b >>> E.b; -var rg12 = 1 >>> E.b; +var rg6 = 0 >>> a; +var rg7 = 0 >>> b; +var rg8 = 0 >>> 1; +var rg9 = 0 >>> 1; +var rg10 = a >>> 1; +var rg11 = b >>> 1; +var rg12 = 1 >>> 1; // operator & var rh1 = c & a; var rh2 = c & b; var rh3 = c & c; var rh4 = a & c; var rh5 = b & c; -var rh6 = E.a & a; -var rh7 = E.a & b; -var rh8 = E.a & E.b; -var rh9 = E.a & 1; -var rh10 = a & E.b; -var rh11 = b & E.b; -var rh12 = 1 & E.b; +var rh6 = 0 & a; +var rh7 = 0 & b; +var rh8 = 0 & 1; +var rh9 = 0 & 1; +var rh10 = a & 1; +var rh11 = b & 1; +var rh12 = 1 & 1; // operator ^ var ri1 = c ^ a; var ri2 = c ^ b; var ri3 = c ^ c; var ri4 = a ^ c; var ri5 = b ^ c; -var ri6 = E.a ^ a; -var ri7 = E.a ^ b; -var ri8 = E.a ^ E.b; -var ri9 = E.a ^ 1; -var ri10 = a ^ E.b; -var ri11 = b ^ E.b; -var ri12 = 1 ^ E.b; +var ri6 = 0 ^ a; +var ri7 = 0 ^ b; +var ri8 = 0 ^ 1; +var ri9 = 0 ^ 1; +var ri10 = a ^ 1; +var ri11 = b ^ 1; +var ri12 = 1 ^ 1; // operator | var rj1 = c | a; var rj2 = c | b; var rj3 = c | c; var rj4 = a | c; var rj5 = b | c; -var rj6 = E.a | a; -var rj7 = E.a | b; -var rj8 = E.a | E.b; -var rj9 = E.a | 1; -var rj10 = a | E.b; -var rj11 = b | E.b; -var rj12 = 1 | E.b; +var rj6 = 0 | a; +var rj7 = 0 | b; +var rj8 = 0 | 1; +var rj9 = 0 | 1; +var rj10 = a | 1; +var rj11 = b | 1; +var rj12 = 1 | 1; diff --git a/crates/swc/tests/tsc-references/arithmeticOperatorWithEnum.2.minified.js b/crates/swc/tests/tsc-references/arithmeticOperatorWithEnum.2.minified.js index b38f3b5a0edc1..7eac3ef2eaabe 100644 --- a/crates/swc/tests/tsc-references/arithmeticOperatorWithEnum.2.minified.js +++ b/crates/swc/tests/tsc-references/arithmeticOperatorWithEnum.2.minified.js @@ -1,4 +1,4 @@ //// [arithmeticOperatorWithEnum.ts] // operands of an enum type are treated as having the primitive type Number. var E, E1; -(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b; +(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b"; diff --git a/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion.1.normal.js b/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion.1.normal.js index 15a9189a51e21..2c9155bc19aea 100644 --- a/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion.1.normal.js +++ b/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion.1.normal.js @@ -19,127 +19,127 @@ var ra2 = c * b; var ra3 = c * c; var ra4 = a * c; var ra5 = b * c; -var ra6 = E.a * a; -var ra7 = E.a * b; -var ra8 = E.a * E.b; -var ra9 = E.a * 1; -var ra10 = a * E.b; -var ra11 = b * E.b; -var ra12 = 1 * E.b; +var ra6 = 0 * a; +var ra7 = 0 * b; +var ra8 = 0 * 1; +var ra9 = 0 * 1; +var ra10 = a * 1; +var ra11 = b * 1; +var ra12 = 1 * 1; // operator / var rb1 = c / a; var rb2 = c / b; var rb3 = c / c; var rb4 = a / c; var rb5 = b / c; -var rb6 = E.a / a; -var rb7 = E.a / b; -var rb8 = E.a / E.b; -var rb9 = E.a / 1; -var rb10 = a / E.b; -var rb11 = b / E.b; -var rb12 = 1 / E.b; +var rb6 = 0 / a; +var rb7 = 0 / b; +var rb8 = 0 / 1; +var rb9 = 0 / 1; +var rb10 = a / 1; +var rb11 = b / 1; +var rb12 = 1 / 1; // operator % var rc1 = c % a; var rc2 = c % b; var rc3 = c % c; var rc4 = a % c; var rc5 = b % c; -var rc6 = E.a % a; -var rc7 = E.a % b; -var rc8 = E.a % E.b; -var rc9 = E.a % 1; -var rc10 = a % E.b; -var rc11 = b % E.b; -var rc12 = 1 % E.b; +var rc6 = 0 % a; +var rc7 = 0 % b; +var rc8 = 0 % 1; +var rc9 = 0 % 1; +var rc10 = a % 1; +var rc11 = b % 1; +var rc12 = 1 % 1; // operator - var rd1 = c - a; var rd2 = c - b; var rd3 = c - c; var rd4 = a - c; var rd5 = b - c; -var rd6 = E.a - a; -var rd7 = E.a - b; -var rd8 = E.a - E.b; -var rd9 = E.a - 1; -var rd10 = a - E.b; -var rd11 = b - E.b; -var rd12 = 1 - E.b; +var rd6 = 0 - a; +var rd7 = 0 - b; +var rd8 = 0 - 1; +var rd9 = 0 - 1; +var rd10 = a - 1; +var rd11 = b - 1; +var rd12 = 1 - 1; // operator << var re1 = c << a; var re2 = c << b; var re3 = c << c; var re4 = a << c; var re5 = b << c; -var re6 = E.a << a; -var re7 = E.a << b; -var re8 = E.a << E.b; -var re9 = E.a << 1; -var re10 = a << E.b; -var re11 = b << E.b; -var re12 = 1 << E.b; +var re6 = 0 << a; +var re7 = 0 << b; +var re8 = 0 << 1; +var re9 = 0 << 1; +var re10 = a << 1; +var re11 = b << 1; +var re12 = 1 << 1; // operator >> var rf1 = c >> a; var rf2 = c >> b; var rf3 = c >> c; var rf4 = a >> c; var rf5 = b >> c; -var rf6 = E.a >> a; -var rf7 = E.a >> b; -var rf8 = E.a >> E.b; -var rf9 = E.a >> 1; -var rf10 = a >> E.b; -var rf11 = b >> E.b; -var rf12 = 1 >> E.b; +var rf6 = 0 >> a; +var rf7 = 0 >> b; +var rf8 = 0 >> 1; +var rf9 = 0 >> 1; +var rf10 = a >> 1; +var rf11 = b >> 1; +var rf12 = 1 >> 1; // operator >>> var rg1 = c >>> a; var rg2 = c >>> b; var rg3 = c >>> c; var rg4 = a >>> c; var rg5 = b >>> c; -var rg6 = E.a >>> a; -var rg7 = E.a >>> b; -var rg8 = E.a >>> E.b; -var rg9 = E.a >>> 1; -var rg10 = a >>> E.b; -var rg11 = b >>> E.b; -var rg12 = 1 >>> E.b; +var rg6 = 0 >>> a; +var rg7 = 0 >>> b; +var rg8 = 0 >>> 1; +var rg9 = 0 >>> 1; +var rg10 = a >>> 1; +var rg11 = b >>> 1; +var rg12 = 1 >>> 1; // operator & var rh1 = c & a; var rh2 = c & b; var rh3 = c & c; var rh4 = a & c; var rh5 = b & c; -var rh6 = E.a & a; -var rh7 = E.a & b; -var rh8 = E.a & E.b; -var rh9 = E.a & 1; -var rh10 = a & E.b; -var rh11 = b & E.b; -var rh12 = 1 & E.b; +var rh6 = 0 & a; +var rh7 = 0 & b; +var rh8 = 0 & 1; +var rh9 = 0 & 1; +var rh10 = a & 1; +var rh11 = b & 1; +var rh12 = 1 & 1; // operator ^ var ri1 = c ^ a; var ri2 = c ^ b; var ri3 = c ^ c; var ri4 = a ^ c; var ri5 = b ^ c; -var ri6 = E.a ^ a; -var ri7 = E.a ^ b; -var ri8 = E.a ^ E.b; -var ri9 = E.a ^ 1; -var ri10 = a ^ E.b; -var ri11 = b ^ E.b; -var ri12 = 1 ^ E.b; +var ri6 = 0 ^ a; +var ri7 = 0 ^ b; +var ri8 = 0 ^ 1; +var ri9 = 0 ^ 1; +var ri10 = a ^ 1; +var ri11 = b ^ 1; +var ri12 = 1 ^ 1; // operator | var rj1 = c | a; var rj2 = c | b; var rj3 = c | c; var rj4 = a | c; var rj5 = b | c; -var rj6 = E.a | a; -var rj7 = E.a | b; -var rj8 = E.a | E.b; -var rj9 = E.a | 1; -var rj10 = a | E.b; -var rj11 = b | E.b; -var rj12 = 1 | E.b; +var rj6 = 0 | a; +var rj7 = 0 | b; +var rj8 = 0 | 1; +var rj9 = 0 | 1; +var rj10 = a | 1; +var rj11 = b | 1; +var rj12 = 1 | 1; diff --git a/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion.2.minified.js b/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion.2.minified.js index 66e24c7b56de0..01f9830b373d6 100644 --- a/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion.2.minified.js +++ b/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion.2.minified.js @@ -1,4 +1,4 @@ //// [arithmeticOperatorWithEnumUnion.ts] // operands of an enum type are treated as having the primitive type Number. var E, F, E1, F1; -(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", (F1 = F || (F = {}))[F1.c = 0] = "c", F1[F1.d = 1] = "d", E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b; +(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", (F1 = F || (F = {}))[F1.c = 0] = "c", F1[F1.d = 1] = "d"; diff --git a/crates/swc/tests/tsc-references/arithmeticOperatorWithInvalidOperands.1.normal.js b/crates/swc/tests/tsc-references/arithmeticOperatorWithInvalidOperands.1.normal.js index d42de1a485263..8671166257670 100644 --- a/crates/swc/tests/tsc-references/arithmeticOperatorWithInvalidOperands.1.normal.js +++ b/crates/swc/tests/tsc-references/arithmeticOperatorWithInvalidOperands.1.normal.js @@ -51,18 +51,18 @@ var r1f3 = f * c; var r1f4 = f * d; var r1f5 = f * e; var r1f6 = f * f; -var r1g1 = E.a * a; //ok -var r1g2 = E.a * b; -var r1g3 = E.a * c; //ok -var r1g4 = E.a * d; -var r1g5 = E.a * e; -var r1g6 = E.a * f; -var r1h1 = a * E.b; //ok -var r1h2 = b * E.b; -var r1h3 = c * E.b; //ok -var r1h4 = d * E.b; -var r1h5 = e * E.b; -var r1h6 = f * E.b; +var r1g1 = 0 * a; //ok +var r1g2 = 0 * b; +var r1g3 = 0 * c; //ok +var r1g4 = 0 * d; +var r1g5 = 0 * e; +var r1g6 = 0 * f; +var r1h1 = a * 1; //ok +var r1h2 = b * 1; +var r1h3 = c * 1; //ok +var r1h4 = d * 1; +var r1h5 = e * 1; +var r1h6 = f * 1; // operator / var r2a1 = a / a; //ok var r2a2 = a / b; @@ -100,18 +100,18 @@ var r2f3 = f / c; var r2f4 = f / d; var r2f5 = f / e; var r2f6 = f / f; -var r2g1 = E.a / a; //ok -var r2g2 = E.a / b; -var r2g3 = E.a / c; //ok -var r2g4 = E.a / d; -var r2g5 = E.a / e; -var r2g6 = E.a / f; -var r2h1 = a / E.b; //ok -var r2h2 = b / E.b; -var r2h3 = c / E.b; //ok -var r2h4 = d / E.b; -var r2h5 = e / E.b; -var r2h6 = f / E.b; +var r2g1 = 0 / a; //ok +var r2g2 = 0 / b; +var r2g3 = 0 / c; //ok +var r2g4 = 0 / d; +var r2g5 = 0 / e; +var r2g6 = 0 / f; +var r2h1 = a / 1; //ok +var r2h2 = b / 1; +var r2h3 = c / 1; //ok +var r2h4 = d / 1; +var r2h5 = e / 1; +var r2h6 = f / 1; // operator % var r3a1 = a % a; //ok var r3a2 = a % b; @@ -149,18 +149,18 @@ var r3f3 = f % c; var r3f4 = f % d; var r3f5 = f % e; var r3f6 = f % f; -var r3g1 = E.a % a; //ok -var r3g2 = E.a % b; -var r3g3 = E.a % c; //ok -var r3g4 = E.a % d; -var r3g5 = E.a % e; -var r3g6 = E.a % f; -var r3h1 = a % E.b; //ok -var r3h2 = b % E.b; -var r3h3 = c % E.b; //ok -var r3h4 = d % E.b; -var r3h5 = e % E.b; -var r3h6 = f % E.b; +var r3g1 = 0 % a; //ok +var r3g2 = 0 % b; +var r3g3 = 0 % c; //ok +var r3g4 = 0 % d; +var r3g5 = 0 % e; +var r3g6 = 0 % f; +var r3h1 = a % 1; //ok +var r3h2 = b % 1; +var r3h3 = c % 1; //ok +var r3h4 = d % 1; +var r3h5 = e % 1; +var r3h6 = f % 1; // operator - var r4a1 = a - a; //ok var r4a2 = a - b; @@ -198,18 +198,18 @@ var r4f3 = f - c; var r4f4 = f - d; var r4f5 = f - e; var r4f6 = f - f; -var r4g1 = E.a - a; //ok -var r4g2 = E.a - b; -var r4g3 = E.a - c; //ok -var r4g4 = E.a - d; -var r4g5 = E.a - e; -var r4g6 = E.a - f; -var r4h1 = a - E.b; //ok -var r4h2 = b - E.b; -var r4h3 = c - E.b; //ok -var r4h4 = d - E.b; -var r4h5 = e - E.b; -var r4h6 = f - E.b; +var r4g1 = 0 - a; //ok +var r4g2 = 0 - b; +var r4g3 = 0 - c; //ok +var r4g4 = 0 - d; +var r4g5 = 0 - e; +var r4g6 = 0 - f; +var r4h1 = a - 1; //ok +var r4h2 = b - 1; +var r4h3 = c - 1; //ok +var r4h4 = d - 1; +var r4h5 = e - 1; +var r4h6 = f - 1; // operator << var r5a1 = a << a; //ok var r5a2 = a << b; @@ -247,18 +247,18 @@ var r5f3 = f << c; var r5f4 = f << d; var r5f5 = f << e; var r5f6 = f << f; -var r5g1 = E.a << a; //ok -var r5g2 = E.a << b; -var r5g3 = E.a << c; //ok -var r5g4 = E.a << d; -var r5g5 = E.a << e; -var r5g6 = E.a << f; -var r5h1 = a << E.b; //ok -var r5h2 = b << E.b; -var r5h3 = c << E.b; //ok -var r5h4 = d << E.b; -var r5h5 = e << E.b; -var r5h6 = f << E.b; +var r5g1 = 0 << a; //ok +var r5g2 = 0 << b; +var r5g3 = 0 << c; //ok +var r5g4 = 0 << d; +var r5g5 = 0 << e; +var r5g6 = 0 << f; +var r5h1 = a << 1; //ok +var r5h2 = b << 1; +var r5h3 = c << 1; //ok +var r5h4 = d << 1; +var r5h5 = e << 1; +var r5h6 = f << 1; // operator >> var r6a1 = a >> a; //ok var r6a2 = a >> b; @@ -296,18 +296,18 @@ var r6f3 = f >> c; var r6f4 = f >> d; var r6f5 = f >> e; var r6f6 = f >> f; -var r6g1 = E.a >> a; //ok -var r6g2 = E.a >> b; -var r6g3 = E.a >> c; //ok -var r6g4 = E.a >> d; -var r6g5 = E.a >> e; -var r6g6 = E.a >> f; -var r6h1 = a >> E.b; //ok -var r6h2 = b >> E.b; -var r6h3 = c >> E.b; //ok -var r6h4 = d >> E.b; -var r6h5 = e >> E.b; -var r6h6 = f >> E.b; +var r6g1 = 0 >> a; //ok +var r6g2 = 0 >> b; +var r6g3 = 0 >> c; //ok +var r6g4 = 0 >> d; +var r6g5 = 0 >> e; +var r6g6 = 0 >> f; +var r6h1 = a >> 1; //ok +var r6h2 = b >> 1; +var r6h3 = c >> 1; //ok +var r6h4 = d >> 1; +var r6h5 = e >> 1; +var r6h6 = f >> 1; // operator >>> var r7a1 = a >>> a; //ok var r7a2 = a >>> b; @@ -345,18 +345,18 @@ var r7f3 = f >>> c; var r7f4 = f >>> d; var r7f5 = f >>> e; var r7f6 = f >>> f; -var r7g1 = E.a >>> a; //ok -var r7g2 = E.a >>> b; -var r7g3 = E.a >>> c; //ok -var r7g4 = E.a >>> d; -var r7g5 = E.a >>> e; -var r7g6 = E.a >>> f; -var r7h1 = a >>> E.b; //ok -var r7h2 = b >>> E.b; -var r7h3 = c >>> E.b; //ok -var r7h4 = d >>> E.b; -var r7h5 = e >>> E.b; -var r7h6 = f >>> E.b; +var r7g1 = 0 >>> a; //ok +var r7g2 = 0 >>> b; +var r7g3 = 0 >>> c; //ok +var r7g4 = 0 >>> d; +var r7g5 = 0 >>> e; +var r7g6 = 0 >>> f; +var r7h1 = a >>> 1; //ok +var r7h2 = b >>> 1; +var r7h3 = c >>> 1; //ok +var r7h4 = d >>> 1; +var r7h5 = e >>> 1; +var r7h6 = f >>> 1; // operator & var r8a1 = a & a; //ok var r8a2 = a & b; @@ -394,18 +394,18 @@ var r8f3 = f & c; var r8f4 = f & d; var r8f5 = f & e; var r8f6 = f & f; -var r8g1 = E.a & a; //ok -var r8g2 = E.a & b; -var r8g3 = E.a & c; //ok -var r8g4 = E.a & d; -var r8g5 = E.a & e; -var r8g6 = E.a & f; -var r8h1 = a & E.b; //ok -var r8h2 = b & E.b; -var r8h3 = c & E.b; //ok -var r8h4 = d & E.b; -var r8h5 = e & E.b; -var r8h6 = f & E.b; +var r8g1 = 0 & a; //ok +var r8g2 = 0 & b; +var r8g3 = 0 & c; //ok +var r8g4 = 0 & d; +var r8g5 = 0 & e; +var r8g6 = 0 & f; +var r8h1 = a & 1; //ok +var r8h2 = b & 1; +var r8h3 = c & 1; //ok +var r8h4 = d & 1; +var r8h5 = e & 1; +var r8h6 = f & 1; // operator ^ var r9a1 = a ^ a; //ok var r9a2 = a ^ b; @@ -443,18 +443,18 @@ var r9f3 = f ^ c; var r9f4 = f ^ d; var r9f5 = f ^ e; var r9f6 = f ^ f; -var r9g1 = E.a ^ a; //ok -var r9g2 = E.a ^ b; -var r9g3 = E.a ^ c; //ok -var r9g4 = E.a ^ d; -var r9g5 = E.a ^ e; -var r9g6 = E.a ^ f; -var r9h1 = a ^ E.b; //ok -var r9h2 = b ^ E.b; -var r9h3 = c ^ E.b; //ok -var r9h4 = d ^ E.b; -var r9h5 = e ^ E.b; -var r9h6 = f ^ E.b; +var r9g1 = 0 ^ a; //ok +var r9g2 = 0 ^ b; +var r9g3 = 0 ^ c; //ok +var r9g4 = 0 ^ d; +var r9g5 = 0 ^ e; +var r9g6 = 0 ^ f; +var r9h1 = a ^ 1; //ok +var r9h2 = b ^ 1; +var r9h3 = c ^ 1; //ok +var r9h4 = d ^ 1; +var r9h5 = e ^ 1; +var r9h6 = f ^ 1; // operator | var r10a1 = a | a; //ok var r10a2 = a | b; @@ -492,15 +492,15 @@ var r10f3 = f | c; var r10f4 = f | d; var r10f5 = f | e; var r10f6 = f | f; -var r10g1 = E.a | a; //ok -var r10g2 = E.a | b; -var r10g3 = E.a | c; //ok -var r10g4 = E.a | d; -var r10g5 = E.a | e; -var r10g6 = E.a | f; -var r10h1 = a | E.b; //ok -var r10h2 = b | E.b; -var r10h3 = c | E.b; //ok -var r10h4 = d | E.b; -var r10h5 = e | E.b; -var r10h6 = f | E.b; +var r10g1 = 0 | a; //ok +var r10g2 = 0 | b; +var r10g3 = 0 | c; //ok +var r10g4 = 0 | d; +var r10g5 = 0 | e; +var r10g6 = 0 | f; +var r10h1 = a | 1; //ok +var r10h2 = b | 1; +var r10h3 = c | 1; //ok +var r10h4 = d | 1; +var r10h5 = e | 1; +var r10h6 = f | 1; diff --git a/crates/swc/tests/tsc-references/arithmeticOperatorWithInvalidOperands.2.minified.js b/crates/swc/tests/tsc-references/arithmeticOperatorWithInvalidOperands.2.minified.js index 288c2ba14cec7..ca2c46e3f484c 100644 --- a/crates/swc/tests/tsc-references/arithmeticOperatorWithInvalidOperands.2.minified.js +++ b/crates/swc/tests/tsc-references/arithmeticOperatorWithInvalidOperands.2.minified.js @@ -2,4 +2,4 @@ // these operators require their operands to be of type Any, the Number primitive type, or // an enum type var E, E1; -(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E1[E1.c = 2] = "c", E.a, E.a, E.a, E.a, E.a, E.a, E.b, E.b, E.b, E.b, E.b, E.b, E.a, E.a, E.a, E.a, E.a, E.a, E.b, E.b, E.b, E.b, E.b, E.b, E.a, E.a, E.a, E.a, E.a, E.a, E.b, E.b, E.b, E.b, E.b, E.b, E.a, E.a, E.a, E.a, E.a, E.a, E.b, E.b, E.b, E.b, E.b, E.b, E.a, E.a, E.a, E.a, E.a, E.a, E.b, E.b, E.b, E.b, E.b, E.b, E.a, E.a, E.a, E.a, E.a, E.a, E.b, E.b, E.b, E.b, E.b, E.b, E.a, E.a, E.a, E.a, E.a, E.a, E.b, E.b, E.b, E.b, E.b, E.b, E.a, E.a, E.a, E.a, E.a, E.a, E.b, E.b, E.b, E.b, E.b, E.b, E.a, E.a, E.a, E.a, E.a, E.a, E.b, E.b, E.b, E.b, E.b, E.b, E.a, E.a, E.a, E.a, E.a, E.a, E.b, E.b, E.b, E.b, E.b, E.b; +(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E1[E1.c = 2] = "c"; diff --git a/crates/swc/tests/tsc-references/arrayLiteralInference.1.normal.js b/crates/swc/tests/tsc-references/arrayLiteralInference.1.normal.js index 9fc6e709557ff..e020c6c4a4927 100644 --- a/crates/swc/tests/tsc-references/arrayLiteralInference.1.normal.js +++ b/crates/swc/tests/tsc-references/arrayLiteralInference.1.normal.js @@ -22,25 +22,25 @@ export var AppStyle; })(AppStyle || (AppStyle = {})); const appTypeStylesWithError = new Map([ [ - AppType.Standard, + "Standard", [ - AppStyle.Standard, - AppStyle.MiniApp + 2, + 3 ] ], [ - AppType.Relationship, + "Relationship", [ - AppStyle.Standard, - AppStyle.Tree, - AppStyle.TreeEntity + 2, + 0, + 1 ] ], [ - AppType.AdvancedList, + "AdvancedList", [ - AppStyle.Standard, - AppStyle.MiniApp + 2, + 3 ] ] ]); diff --git a/crates/swc/tests/tsc-references/arrayLiteralInference.2.minified.js b/crates/swc/tests/tsc-references/arrayLiteralInference.2.minified.js index 57ec03a7ed6e5..f0f0d7b14228e 100644 --- a/crates/swc/tests/tsc-references/arrayLiteralInference.2.minified.js +++ b/crates/swc/tests/tsc-references/arrayLiteralInference.2.minified.js @@ -6,7 +6,7 @@ export { AppType1 as AppType }; (AppType = AppType1 || (AppType1 = {})).HeaderDetail = "HeaderDetail", AppType.HeaderMultiDetail = "HeaderMultiDetail", AppType.AdvancedList = "AdvancedList", AppType.Standard = "Standard", AppType.Relationship = "Relationship", AppType.Report = "Report", AppType.Composite = "Composite", AppType.ListOnly = "ListOnly", AppType.ModuleSettings = "ModuleSettings"; var AppStyle1; export { AppStyle1 as AppStyle }; -(AppStyle = AppStyle1 || (AppStyle1 = {}))[AppStyle.Tree = 0] = "Tree", AppStyle[AppStyle.TreeEntity = 1] = "TreeEntity", AppStyle[AppStyle.Standard = 2] = "Standard", AppStyle[AppStyle.MiniApp = 3] = "MiniApp", AppStyle[AppStyle.PivotTable = 4] = "PivotTable", AppType1.Standard, AppStyle1.Standard, AppStyle1.MiniApp, AppType1.Relationship, AppStyle1.Standard, AppStyle1.Tree, AppStyle1.TreeEntity, AppType1.AdvancedList, AppStyle1.Standard, AppStyle1.MiniApp, foo({ +(AppStyle = AppStyle1 || (AppStyle1 = {}))[AppStyle.Tree = 0] = "Tree", AppStyle[AppStyle.TreeEntity = 1] = "TreeEntity", AppStyle[AppStyle.Standard = 2] = "Standard", AppStyle[AppStyle.MiniApp = 3] = "MiniApp", AppStyle[AppStyle.PivotTable = 4] = "PivotTable", foo({ x: !0 }, { x: !1 diff --git a/crates/swc/tests/tsc-references/asiPreventsParsingAsNamespace05.1.normal.js b/crates/swc/tests/tsc-references/asiPreventsParsingAsNamespace05.1.normal.js index 6056e384f6298..68e134b5c850a 100644 --- a/crates/swc/tests/tsc-references/asiPreventsParsingAsNamespace05.1.normal.js +++ b/crates/swc/tests/tsc-references/asiPreventsParsingAsNamespace05.1.normal.js @@ -2,8 +2,16 @@ var namespace = 10; var a; (function(a) { - var b; (function(b) { - var c = b.c = 20; - })(b = a.b || (a.b = {})); + var c = 20; + Object.defineProperty(b, "c", { + enumerable: true, + get: function get() { + return c; + }, + set: function set(v) { + c = v; + } + }); + })(a.b || (a.b = {})); })(a || (a = {})); diff --git a/crates/swc/tests/tsc-references/asiPreventsParsingAsNamespace05.2.minified.js b/crates/swc/tests/tsc-references/asiPreventsParsingAsNamespace05.2.minified.js index ccd6bbb0cfdfa..25a5247e4651c 100644 --- a/crates/swc/tests/tsc-references/asiPreventsParsingAsNamespace05.2.minified.js +++ b/crates/swc/tests/tsc-references/asiPreventsParsingAsNamespace05.2.minified.js @@ -1,3 +1,11 @@ //// [asiPreventsParsingAsNamespace05.ts] -var a, a1; -((a1 = a || (a = {})).b || (a1.b = {})).c = 20; +var a, a1, b, c; +b = (a1 = a || (a = {})).b || (a1.b = {}), c = 20, Object.defineProperty(b, "c", { + enumerable: !0, + get: function() { + return c; + }, + set: function(v) { + c = v; + } +}); diff --git a/crates/swc/tests/tsc-references/assignAnyToEveryType.1.normal.js b/crates/swc/tests/tsc-references/assignAnyToEveryType.1.normal.js index d918de3bc005a..b91e5d36e7823 100644 --- a/crates/swc/tests/tsc-references/assignAnyToEveryType.1.normal.js +++ b/crates/swc/tests/tsc-references/assignAnyToEveryType.1.normal.js @@ -15,7 +15,7 @@ var E; E[E["A"] = 0] = "A"; })(E || (E = {})); var g = x; -var g2 = E.A; +var g2 = 0; g2 = x; var C = function C() { "use strict"; @@ -27,7 +27,16 @@ var j = x; var j2 = x; var M; (function(M) { - var foo = M.foo = 1; + var foo = 1; + Object.defineProperty(M, "foo", { + enumerable: true, + get: function get() { + return foo; + }, + set: function set(v) { + foo = v; + } + }); })(M || (M = {})); M = x; function k(a) { diff --git a/crates/swc/tests/tsc-references/assignAnyToEveryType.2.minified.js b/crates/swc/tests/tsc-references/assignAnyToEveryType.2.minified.js index c6f30b420a585..6184611a258ae 100644 --- a/crates/swc/tests/tsc-references/assignAnyToEveryType.2.minified.js +++ b/crates/swc/tests/tsc-references/assignAnyToEveryType.2.minified.js @@ -1,5 +1,13 @@ //// [assignAnyToEveryType.ts] // all of these are valid -var E, M, E1; +var E, M, E1, M1, foo; import "@swc/helpers/_/_class_call_check"; -(E1 = E || (E = {}))[E1.A = 0] = "A", E.A, (M || (M = {})).foo = 1; +(E1 = E || (E = {}))[E1.A = 0] = "A", M1 = M || (M = {}), foo = 1, Object.defineProperty(M1, "foo", { + enumerable: !0, + get: function() { + return foo; + }, + set: function(v) { + foo = v; + } +}); diff --git a/crates/swc/tests/tsc-references/assignEveryTypeToAny.1.normal.js b/crates/swc/tests/tsc-references/assignEveryTypeToAny.1.normal.js index a6c0a2d75af26..95a7d6ebfe1e2 100644 --- a/crates/swc/tests/tsc-references/assignEveryTypeToAny.1.normal.js +++ b/crates/swc/tests/tsc-references/assignEveryTypeToAny.1.normal.js @@ -21,8 +21,8 @@ var E; (function(E) { E[E["A"] = 0] = "A"; })(E || (E = {})); -x = E.A; -var f = E.A; +x = 0; +var f = 0; x = f; var g; x = g; diff --git a/crates/swc/tests/tsc-references/assignEveryTypeToAny.2.minified.js b/crates/swc/tests/tsc-references/assignEveryTypeToAny.2.minified.js index 3bd3d568356d0..c6b6c40d6b8e8 100644 --- a/crates/swc/tests/tsc-references/assignEveryTypeToAny.2.minified.js +++ b/crates/swc/tests/tsc-references/assignEveryTypeToAny.2.minified.js @@ -2,4 +2,4 @@ // all of these are valid var E, E1; import "@swc/helpers/_/_class_call_check"; -(E1 = E || (E = {}))[E1.A = 0] = "A", E.A, E.A; +(E1 = E || (E = {}))[E1.A = 0] = "A"; diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion.1.normal.js b/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion.1.normal.js index a16ea56a65b2a..cbc1a4d2d63db 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion.1.normal.js @@ -7,37 +7,37 @@ var Example1; // S is assignable to T1 when S["done"] is false t = s; })(Example1 || (Example1 = {})); -// Dropping constituents of T var Example2; +// Dropping constituents of T (function(Example2) { // S is assignable to T0 when S["a"] is 0 // S is assignable to T2 when S["a"] is 2 t = s; })(Example2 || (Example2 = {})); -// Unmatched discriminants var Example3; +// Unmatched discriminants (function(Example3) { // S is assignable to T0 when S["a"] is 0 // S is *not* assignable to T1 when S["b"] is 4 // S is *not* assignable to T2 when S["a"] is 2 t = s; })(Example3 || (Example3 = {})); -// Unmatched non-discriminants var Example4; +// Unmatched non-discriminants (function(Example4) { // S is assignable to T0 when S["a"] is 0 // S is *not* assignable to T2 when S["a"] is 2 as S is missing "c" t = s; })(Example4 || (Example4 = {})); -// Maximum discriminant combinations var Example5; +// Maximum discriminant combinations (function(Example5) { // S *should* be assignable but the number of // combinations is too complex. t = s; })(Example5 || (Example5 = {})); -// https://github.com/Microsoft/TypeScript/issues/14865 var GH14865; +// https://github.com/Microsoft/TypeScript/issues/14865 (function(GH14865) { var a = { type: "A", @@ -48,8 +48,8 @@ var GH14865; b1.type; // "A" | "B" b1 = a; // should be assignable })(GH14865 || (GH14865 = {})); -// https://github.com/Microsoft/TypeScript/issues/30170 var GH30170; +// https://github.com/Microsoft/TypeScript/issues/30170 (function(GH30170) { var draw = function draw(val) {}; var drawWithColor = function drawWithColor(currentColor) { @@ -58,8 +58,8 @@ var GH30170; }); }; })(GH30170 || (GH30170 = {})); -// https://github.com/Microsoft/TypeScript/issues/12052 var GH12052; +// https://github.com/Microsoft/TypeScript/issues/12052 (function(GH12052) { var getAxisType = function getAxisType() { if (1 == 1) { @@ -76,8 +76,8 @@ var GH12052; }; good.type = getAxisType(); })(GH12052 || (GH12052 = {})); -// https://github.com/Microsoft/TypeScript/issues/18421 var GH18421; +// https://github.com/Microsoft/TypeScript/issues/18421 (function(GH18421) { var makeNewThing = function makeNewThing(thingType) { return { @@ -85,8 +85,8 @@ var GH18421; }; }; })(GH18421 || (GH18421 = {})); -// https://github.com/Microsoft/TypeScript/issues/15907 var GH15907; +// https://github.com/Microsoft/TypeScript/issues/15907 (function(GH15907) { var dispatchAction = function dispatchAction(action) {}; var active = true; @@ -94,8 +94,8 @@ var GH15907; type: active ? "disactivate" : "activate" }); })(GH15907 || (GH15907 = {})); -// https://github.com/Microsoft/TypeScript/issues/20889 var GH20889; +// https://github.com/Microsoft/TypeScript/issues/20889 (function(GH20889) { var foo = function foo(obj1) { var obj2 = { @@ -103,8 +103,8 @@ var GH20889; }; }; })(GH20889 || (GH20889 = {})); -// https://github.com/microsoft/TypeScript/issues/39357 var GH39357; +// https://github.com/microsoft/TypeScript/issues/39357 (function(GH39357) { var a = b === "a" || b === "b" ? [ b, diff --git a/crates/swc/tests/tsc-references/assignmentToParenthesizedIdentifiers.1.normal.js b/crates/swc/tests/tsc-references/assignmentToParenthesizedIdentifiers.1.normal.js index 045eff8525c07..403880c64d72b 100644 --- a/crates/swc/tests/tsc-references/assignmentToParenthesizedIdentifiers.1.normal.js +++ b/crates/swc/tests/tsc-references/assignmentToParenthesizedIdentifiers.1.normal.js @@ -8,7 +8,15 @@ x = ""; // Error var M; (function(M) { var y; - M.y = y; + Object.defineProperty(M, "y", { + enumerable: true, + get: function get() { + return y; + }, + set: function set(v) { + y = v; + } + }); })(M || (M = {})); M.y = 3; // OK M.y = 3; // OK @@ -27,7 +35,15 @@ var M2; var M3; (function(M3) { var x; - M3.x = x; + Object.defineProperty(M3, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(M3 = M2.M3 || (M2.M3 = {})); M3 = { x: 3 diff --git a/crates/swc/tests/tsc-references/assignmentToParenthesizedIdentifiers.2.minified.js b/crates/swc/tests/tsc-references/assignmentToParenthesizedIdentifiers.2.minified.js index 3df56a7d0ea60..0e97f7dec0f5c 100644 --- a/crates/swc/tests/tsc-references/assignmentToParenthesizedIdentifiers.2.minified.js +++ b/crates/swc/tests/tsc-references/assignmentToParenthesizedIdentifiers.2.minified.js @@ -1,11 +1,27 @@ //// [assignmentToParenthesizedIdentifiers.ts] var M, M2, E, y, M21, x, E1; import "@swc/helpers/_/_class_call_check"; -(M || (M = {})).y = y, M.y = 3, M.y = 3, M.y = 3, M.y = "", M.y = "", M.y = "", M = { +Object.defineProperty(M || (M = {}), "y", { + enumerable: !0, + get: function() { + return y; + }, + set: function(v) { + y = v; + } +}), M.y = 3, M.y = 3, M.y = 3, M.y = "", M.y = "", M.y = "", M = { y: 3 }, M = { y: 3 -}, ((M21 = M2 || (M2 = {})).M3 || (M21.M3 = {})).x = x, M2.M3 = { +}, Object.defineProperty((M21 = M2 || (M2 = {})).M3 || (M21.M3 = {}), "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}), M2.M3 = { x: 3 }, M2.M3 = { x: 3 diff --git a/crates/swc/tests/tsc-references/bestCommonTypeOfTuple.1.normal.js b/crates/swc/tests/tsc-references/bestCommonTypeOfTuple.1.normal.js index 8c0acc9556dc3..8c7e0d3001520 100644 --- a/crates/swc/tests/tsc-references/bestCommonTypeOfTuple.1.normal.js +++ b/crates/swc/tests/tsc-references/bestCommonTypeOfTuple.1.normal.js @@ -26,16 +26,16 @@ t1 = [ f2 ]; t2 = [ - E1.one, - E2.two + 0, + 0 ]; t3 = [ 5, undefined ]; t4 = [ - E1.one, - E2.two, + 0, + 0, 20 ]; var e1 = t1[2]; // {} diff --git a/crates/swc/tests/tsc-references/bestCommonTypeOfTuple.2.minified.js b/crates/swc/tests/tsc-references/bestCommonTypeOfTuple.2.minified.js index 104eb7a7be23c..7a637f9f203a2 100644 --- a/crates/swc/tests/tsc-references/bestCommonTypeOfTuple.2.minified.js +++ b/crates/swc/tests/tsc-references/bestCommonTypeOfTuple.2.minified.js @@ -1,11 +1,4 @@ //// [bestCommonTypeOfTuple.ts] -var E1, E2, t2, t4, E11, E21; -(E11 = E1 || (E1 = {}))[E11.one = 0] = "one", (E21 = E2 || (E2 = {}))[E21.two = 0] = "two", t2 = [ - E1.one, - E2.two -], t4 = [ - E1.one, - E2.two, - 20 -], t2[2], t4[3]; +var E1, E2, E11, E21; +(E11 = E1 || (E1 = {}))[E11.one = 0] = "one", (E21 = E2 || (E2 = {}))[E21.two = 0] = "two"; // number diff --git a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithBooleanType.1.normal.js b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithBooleanType.1.normal.js index a3fa02a551aec..ecb0956fb9ca2 100644 --- a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithBooleanType.1.normal.js +++ b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithBooleanType.1.normal.js @@ -18,7 +18,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // boolean type var diff --git a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithBooleanType.2.minified.js b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithBooleanType.2.minified.js index 1d7ef7e187a5c..0caed9b194b30 100644 --- a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithBooleanType.2.minified.js +++ b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithBooleanType.2.minified.js @@ -9,6 +9,14 @@ var n, M, A = function() { return !1; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithEnumType.1.normal.js b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithEnumType.1.normal.js index 6aca5a59419cb..6c0e7d17fb0c6 100644 --- a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithEnumType.1.normal.js +++ b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithEnumType.1.normal.js @@ -9,11 +9,11 @@ var ENUM1; // enum type var var ResultIsNumber1 = ~ENUM1; // enum type expressions -var ResultIsNumber2 = ~ENUM1["A"]; -var ResultIsNumber3 = ~(ENUM1.A + ENUM1["B"]); +var ResultIsNumber2 = ~0; +var ResultIsNumber3 = ~(0 + 1); // multiple ~ operators -var ResultIsNumber4 = ~~~(ENUM1["A"] + ENUM1.B); +var ResultIsNumber4 = ~~~(0 + 1); // miss assignment operators ~ENUM1; -~ENUM1["A"]; -~ENUM1.A, ~ENUM1["B"]; +~0; +~0, ~1; diff --git a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithEnumType.2.minified.js b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithEnumType.2.minified.js index c54af7528cdc2..b92a7bc30a894 100644 --- a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithEnumType.2.minified.js +++ b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithEnumType.2.minified.js @@ -1,4 +1,4 @@ //// [bitwiseNotOperatorWithEnumType.ts] // ~ operator on enum type var ENUM1, ENUM11; -(ENUM11 = ENUM1 || (ENUM1 = {}))[ENUM11.A = 0] = "A", ENUM11[ENUM11.B = 1] = "B", ENUM11[ENUM11[""] = 2] = "", ENUM1.A, ENUM1.A, ENUM1.B, ENUM1.A, ENUM1.B, ENUM1.A, ENUM1.A, ENUM1.B; +(ENUM11 = ENUM1 || (ENUM1 = {}))[ENUM11.A = 0] = "A", ENUM11[ENUM11.B = 1] = "B", ENUM11[ENUM11[""] = 2] = ""; diff --git a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithNumberType.1.normal.js b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithNumberType.1.normal.js index 01a8285a7b2ab..ddd8de00bf727 100644 --- a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithNumberType.1.normal.js +++ b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithNumberType.1.normal.js @@ -22,7 +22,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // number type var diff --git a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithNumberType.2.minified.js index da0b278ef6cf8..f93837da24e4c 100644 --- a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithNumberType.2.minified.js @@ -9,6 +9,14 @@ var M, n, A = function() { return 1; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n, objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithStringType.1.normal.js b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithStringType.1.normal.js index 553ced4e6eff1..091ce9f96264b 100644 --- a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithStringType.1.normal.js +++ b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithStringType.1.normal.js @@ -22,7 +22,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // string type var diff --git a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithStringType.2.minified.js b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithStringType.2.minified.js index 0305ece64b0fc..a2a328a6820dd 100644 --- a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithStringType.2.minified.js +++ b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithStringType.2.minified.js @@ -9,6 +9,14 @@ var STRING, M, n, A = function() { return ""; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); objA.a, M.n, A.foo(), STRING.charAt(0), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/bundlerSyntaxRestrictions.1.normal.js b/crates/swc/tests/tsc-references/bundlerSyntaxRestrictions.1.normal.js index 3b5bc4f68c84b..41742bb7e574e 100644 --- a/crates/swc/tests/tsc-references/bundlerSyntaxRestrictions.1.normal.js +++ b/crates/swc/tests/tsc-references/bundlerSyntaxRestrictions.1.normal.js @@ -8,15 +8,6 @@ var _ = require("./a"); // No resolution _.a; // any //// [/main.ts] //! -//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. -//! ,-[1:1] -//! 1 | import {} from "./a"; -//! 2 | import _ = require("./a"); // Error -//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^ -//! 3 | export = {}; // Error -//! 4 | export {}; -//! `---- -//! //! x Export assignment cannot be used when targeting ECMAScript modules. Consider using `export default` or another module format instead. //! ,-[1:1] //! 1 | import {} from "./a"; diff --git a/crates/swc/tests/tsc-references/bundlerSyntaxRestrictions.2.minified.js b/crates/swc/tests/tsc-references/bundlerSyntaxRestrictions.2.minified.js index 1fdc751167063..27c24bed970b8 100644 --- a/crates/swc/tests/tsc-references/bundlerSyntaxRestrictions.2.minified.js +++ b/crates/swc/tests/tsc-references/bundlerSyntaxRestrictions.2.minified.js @@ -7,15 +7,6 @@ import("./a"), require("./a").a; // any //// [/main.ts] //! -//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. -//! ,-[1:1] -//! 1 | import {} from "./a"; -//! 2 | import _ = require("./a"); // Error -//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^ -//! 3 | export = {}; // Error -//! 4 | export {}; -//! `---- -//! //! x Export assignment cannot be used when targeting ECMAScript modules. Consider using `export default` or another module format instead. //! ,-[1:1] //! 1 | import {} from "./a"; diff --git a/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference.1.normal.js b/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference.1.normal.js index a3b320bf8bf3d..601b06c31637a 100644 --- a/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference.1.normal.js +++ b/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference.1.normal.js @@ -62,7 +62,16 @@ function foo10(x) { var r10 = foo10(1); var M; (function(M) { - var x = M.x = 1; + var x = 1; + Object.defineProperty(M, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); var C = function C() { "use strict"; _class_call_check(this, C); @@ -82,7 +91,16 @@ function m1() { return 1; } (function(m1) { - var y = m1.y = 2; + var y = 2; + Object.defineProperty(m1, "y", { + enumerable: true, + get: function get() { + return y; + }, + set: function set(v) { + y = v; + } + }); })(m1 || (m1 = {})); function foo13() { return m1; @@ -93,7 +111,16 @@ var c1 = function c1(x) { _class_call_check(this, c1); }; (function(c1) { - var x = c1.x = 1; + var x = 1; + Object.defineProperty(c1, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(c1 || (c1 = {})); function foo14() { return c1; @@ -104,7 +131,16 @@ var e1; e1[e1["A"] = 0] = "A"; })(e1 || (e1 = {})); (function(e1) { - var y = e1.y = 1; + var y = 1; + Object.defineProperty(e1, "y", { + enumerable: true, + get: function get() { + return y; + }, + set: function set(v) { + y = v; + } + }); })(e1 || (e1 = {})); function foo15() { return e1; diff --git a/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference.2.minified.js b/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference.2.minified.js index ee01a86811bc0..a2abb3092a030 100644 --- a/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference.2.minified.js +++ b/crates/swc/tests/tsc-references/callSignatureWithoutReturnTypeAnnotationInference.2.minified.js @@ -8,10 +8,42 @@ function m1() { } !function foo3() { return foo3(); -}(), _type_of(1), (M = M1 || (M1 = {})).x = 1, M.C = function C() { +}(), _type_of(1), M = M1 || (M1 = {}), x1 = 1, Object.defineProperty(M, "x", { + enumerable: !0, + get: function() { + return x1; + }, + set: function(v) { + x1 = v; + } +}), M.C = function C() { _class_call_check(this, C); -}, (m1 || (m1 = {})).y = 2; -var e1, M, M1, e11, c1 = function c1(x) { +}, m11 = m1 || (m1 = {}), y1 = 2, Object.defineProperty(m11, "y", { + enumerable: !0, + get: function() { + return y1; + }, + set: function(v) { + y1 = v; + } +}); +var c1, x, e1, e11, y, M, x1, m11, y1, M1, e12, c11 = function c1(x) { _class_call_check(this, c1); }; -(c1 || (c1 = {})).x = 1, (e1 = e11 || (e11 = {}))[e1.A = 0] = "A", (e11 || (e11 = {})).y = 1; +c1 = c11 || (c11 = {}), x = 1, Object.defineProperty(c1, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}), (e1 = e12 || (e12 = {}))[e1.A = 0] = "A", e11 = e12 || (e12 = {}), y = 1, Object.defineProperty(e11, "y", { + enumerable: !0, + get: function() { + return y; + }, + set: function(v) { + y = v; + } +}); diff --git a/crates/swc/tests/tsc-references/castingTuple.1.normal.js b/crates/swc/tests/tsc-references/castingTuple.1.normal.js index 3249b19c52354..fb1c78321eceb 100644 --- a/crates/swc/tests/tsc-references/castingTuple.1.normal.js +++ b/crates/swc/tests/tsc-references/castingTuple.1.normal.js @@ -61,8 +61,8 @@ var classCDATuple = classCDTuple; var eleFromCDA1 = classCDATuple[2]; // A var eleFromCDA2 = classCDATuple[5]; // C | D | A var t10 = [ - E1.one, - E2.one + 0, + 0 ]; var t11 = t10; var array1 = emptyObjTuple; diff --git a/crates/swc/tests/tsc-references/castingTuple.2.minified.js b/crates/swc/tests/tsc-references/castingTuple.2.minified.js index eb1ddc8bf2ce4..784003d3fea09 100644 --- a/crates/swc/tests/tsc-references/castingTuple.2.minified.js +++ b/crates/swc/tests/tsc-references/castingTuple.2.minified.js @@ -12,4 +12,4 @@ var classCDTuple = [ new C(), new D() ]; -classCDTuple[2], classCDTuple[5], E1.one, E2.one, new C(), new C(), new D(), t4[2] = 10; +classCDTuple[2], classCDTuple[5], new C(), new C(), new D(), t4[2] = 10; diff --git a/crates/swc/tests/tsc-references/circularImportAlias.1.normal.js b/crates/swc/tests/tsc-references/circularImportAlias.1.normal.js index e9108f431713a..68a7daf8c3275 100644 --- a/crates/swc/tests/tsc-references/circularImportAlias.1.normal.js +++ b/crates/swc/tests/tsc-references/circularImportAlias.1.normal.js @@ -5,8 +5,7 @@ import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; var B; (function(B) { - var a = A; - B.a = a; + var a = B.a = A; var D = /*#__PURE__*/ function(_a_C) { "use strict"; _inherits(D, _a_C); @@ -26,8 +25,7 @@ var A; _class_call_check(this, C); }; A.C = C; - var b = B; - A.b = b; + var b = A.b = B; })(A || (A = {})); var c; var c = new B.a.C(); diff --git a/crates/swc/tests/tsc-references/circularImportAlias.2.minified.js b/crates/swc/tests/tsc-references/circularImportAlias.2.minified.js index 63fd1e7388934..283e930eaecc4 100644 --- a/crates/swc/tests/tsc-references/circularImportAlias.2.minified.js +++ b/crates/swc/tests/tsc-references/circularImportAlias.2.minified.js @@ -1,16 +1,16 @@ //// [circularImportAlias.ts] // expected no error -var B, A, B1, a, D, A1, b; +var B, A, B1, D, A1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -B1 = B || (B = {}), a = A, B1.a = a, D = function(_a_C) { +D = function(_a_C) { _inherits(D, _a_C); var _super = _create_super(D); function D() { return _class_call_check(this, D), _super.apply(this, arguments); } return D; -}(a.C), B1.D = D, (A1 = A || (A = {})).C = function C() { +}(((B1 = B || (B = {})).a = A).C), B1.D = D, (A1 = A || (A = {})).C = function C() { _class_call_check(this, C); -}, b = B, A1.b = b, new B.a.C(); +}, A1.b = B, new B.a.C(); diff --git a/crates/swc/tests/tsc-references/comparisonOperatorWithSubtypeEnumAndNumber.1.normal.js b/crates/swc/tests/tsc-references/comparisonOperatorWithSubtypeEnumAndNumber.1.normal.js index d043e24976995..dadbd751ffefb 100644 --- a/crates/swc/tests/tsc-references/comparisonOperatorWithSubtypeEnumAndNumber.1.normal.js +++ b/crates/swc/tests/tsc-references/comparisonOperatorWithSubtypeEnumAndNumber.1.normal.js @@ -10,56 +10,56 @@ var b; // operator < var ra1 = a < b; var ra2 = b < a; -var ra3 = E.a < b; -var ra4 = b < E.a; -var ra5 = E.a < 0; -var ra6 = 0 < E.a; +var ra3 = 0 < b; +var ra4 = b < 0; +var ra5 = 0 < 0; +var ra6 = 0 < 0; // operator > var rb1 = a > b; var rb2 = b > a; -var rb3 = E.a > b; -var rb4 = b > E.a; -var rb5 = E.a > 0; -var rb6 = 0 > E.a; +var rb3 = 0 > b; +var rb4 = b > 0; +var rb5 = 0 > 0; +var rb6 = 0 > 0; // operator <= var rc1 = a <= b; var rc2 = b <= a; -var rc3 = E.a <= b; -var rc4 = b <= E.a; -var rc5 = E.a <= 0; -var rc6 = 0 <= E.a; +var rc3 = 0 <= b; +var rc4 = b <= 0; +var rc5 = 0 <= 0; +var rc6 = 0 <= 0; // operator >= var rd1 = a >= b; var rd2 = b >= a; -var rd3 = E.a >= b; -var rd4 = b >= E.a; -var rd5 = E.a >= 0; -var rd6 = 0 >= E.a; +var rd3 = 0 >= b; +var rd4 = b >= 0; +var rd5 = 0 >= 0; +var rd6 = 0 >= 0; // operator == var re1 = a == b; var re2 = b == a; -var re3 = E.a == b; -var re4 = b == E.a; -var re5 = E.a == 0; -var re6 = 0 == E.a; +var re3 = 0 == b; +var re4 = b == 0; +var re5 = 0 == 0; +var re6 = 0 == 0; // operator != var rf1 = a != b; var rf2 = b != a; -var rf3 = E.a != b; -var rf4 = b != E.a; -var rf5 = E.a != 0; -var rf6 = 0 != E.a; +var rf3 = 0 != b; +var rf4 = b != 0; +var rf5 = 0 != 0; +var rf6 = 0 != 0; // operator === var rg1 = a === b; var rg2 = b === a; -var rg3 = E.a === b; -var rg4 = b === E.a; -var rg5 = E.a === 0; -var rg6 = 0 === E.a; +var rg3 = 0 === b; +var rg4 = b === 0; +var rg5 = 0 === 0; +var rg6 = 0 === 0; // operator !== var rh1 = a !== b; var rh2 = b !== a; -var rh3 = E.a !== b; -var rh4 = b !== E.a; -var rh5 = E.a !== 0; -var rh6 = 0 !== E.a; +var rh3 = 0 !== b; +var rh4 = b !== 0; +var rh5 = 0 !== 0; +var rh6 = 0 !== 0; diff --git a/crates/swc/tests/tsc-references/comparisonOperatorWithSubtypeEnumAndNumber.2.minified.js b/crates/swc/tests/tsc-references/comparisonOperatorWithSubtypeEnumAndNumber.2.minified.js index 549c683134731..7794dd7f9aecb 100644 --- a/crates/swc/tests/tsc-references/comparisonOperatorWithSubtypeEnumAndNumber.2.minified.js +++ b/crates/swc/tests/tsc-references/comparisonOperatorWithSubtypeEnumAndNumber.2.minified.js @@ -1,3 +1,3 @@ //// [comparisonOperatorWithSubtypeEnumAndNumber.ts] var E, E1; -(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E1[E1.c = 2] = "c", E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a; +(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E1[E1.c = 2] = "c"; diff --git a/crates/swc/tests/tsc-references/compoundAdditionAssignmentLHSCanBeAssigned.1.normal.js b/crates/swc/tests/tsc-references/compoundAdditionAssignmentLHSCanBeAssigned.1.normal.js index 0161be6583592..caa63baf87b5a 100644 --- a/crates/swc/tests/tsc-references/compoundAdditionAssignmentLHSCanBeAssigned.1.normal.js +++ b/crates/swc/tests/tsc-references/compoundAdditionAssignmentLHSCanBeAssigned.1.normal.js @@ -12,7 +12,7 @@ x1 += b; x1 += true; x1 += 0; x1 += ""; -x1 += E.a; +x1 += 0; x1 += {}; x1 += null; x1 += undefined; @@ -22,20 +22,20 @@ x2 += b; x2 += true; x2 += 0; x2 += ""; -x2 += E.a; +x2 += 0; x2 += {}; x2 += null; x2 += undefined; var x3; x3 += a; x3 += 0; -x3 += E.a; +x3 += 0; x3 += null; x3 += undefined; var x4; x4 += a; x4 += 0; -x4 += E.a; +x4 += 0; x4 += null; x4 += undefined; var x5; diff --git a/crates/swc/tests/tsc-references/compoundAdditionAssignmentLHSCanBeAssigned.2.minified.js b/crates/swc/tests/tsc-references/compoundAdditionAssignmentLHSCanBeAssigned.2.minified.js index b79634efafba0..b3fceee5d4035 100644 --- a/crates/swc/tests/tsc-references/compoundAdditionAssignmentLHSCanBeAssigned.2.minified.js +++ b/crates/swc/tests/tsc-references/compoundAdditionAssignmentLHSCanBeAssigned.2.minified.js @@ -1,3 +1,3 @@ //// [compoundAdditionAssignmentLHSCanBeAssigned.ts] var E, E1; -(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E.a, E.a, E.a, E.a; +(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b"; diff --git a/crates/swc/tests/tsc-references/compoundAdditionAssignmentWithInvalidOperands.1.normal.js b/crates/swc/tests/tsc-references/compoundAdditionAssignmentWithInvalidOperands.1.normal.js index 4f853320770d5..c8e014d9449bd 100644 --- a/crates/swc/tests/tsc-references/compoundAdditionAssignmentWithInvalidOperands.1.normal.js +++ b/crates/swc/tests/tsc-references/compoundAdditionAssignmentWithInvalidOperands.1.normal.js @@ -9,7 +9,7 @@ var x1; x1 += a; x1 += true; x1 += 0; -x1 += E.a; +x1 += 0; x1 += {}; x1 += null; x1 += undefined; @@ -17,7 +17,7 @@ var x2; x2 += a; x2 += true; x2 += 0; -x2 += E.a; +x2 += 0; x2 += {}; x2 += null; x2 += undefined; @@ -25,7 +25,7 @@ var x3; x3 += a; x3 += true; x3 += 0; -x3 += E.a; +x3 += 0; x3 += {}; x3 += null; x3 += undefined; diff --git a/crates/swc/tests/tsc-references/compoundAdditionAssignmentWithInvalidOperands.2.minified.js b/crates/swc/tests/tsc-references/compoundAdditionAssignmentWithInvalidOperands.2.minified.js index 03b0bb2afceb5..8cdd8fee4bd1a 100644 --- a/crates/swc/tests/tsc-references/compoundAdditionAssignmentWithInvalidOperands.2.minified.js +++ b/crates/swc/tests/tsc-references/compoundAdditionAssignmentWithInvalidOperands.2.minified.js @@ -1,3 +1,3 @@ //// [compoundAdditionAssignmentWithInvalidOperands.ts] var E, E1; -(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E.a, E.a, E.a; +(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b"; diff --git a/crates/swc/tests/tsc-references/computedPropertyNames47_ES5.1.normal.js b/crates/swc/tests/tsc-references/computedPropertyNames47_ES5.1.normal.js index 2b25533c109ea..4484500dc232b 100644 --- a/crates/swc/tests/tsc-references/computedPropertyNames47_ES5.1.normal.js +++ b/crates/swc/tests/tsc-references/computedPropertyNames47_ES5.1.normal.js @@ -8,4 +8,4 @@ var E2; (function(E2) { E2[E2["x"] = 0] = "x"; })(E2 || (E2 = {})); -var o = _define_property({}, E1.x || E2.x, 0); +var o = _define_property({}, 0 || 0, 0); diff --git a/crates/swc/tests/tsc-references/computedPropertyNames47_ES5.2.minified.js b/crates/swc/tests/tsc-references/computedPropertyNames47_ES5.2.minified.js index 820e9ccf83874..04fcbe64ec3f3 100644 --- a/crates/swc/tests/tsc-references/computedPropertyNames47_ES5.2.minified.js +++ b/crates/swc/tests/tsc-references/computedPropertyNames47_ES5.2.minified.js @@ -1,4 +1,4 @@ //// [computedPropertyNames47_ES5.ts] var E1, E2, E11, E21; import { _ as _define_property } from "@swc/helpers/_/_define_property"; -(E11 = E1 || (E1 = {}))[E11.x = 0] = "x", (E21 = E2 || (E2 = {}))[E21.x = 0] = "x", _define_property({}, E1.x || E2.x, 0); +(E11 = E1 || (E1 = {}))[E11.x = 0] = "x", (E21 = E2 || (E2 = {}))[E21.x = 0] = "x", _define_property({}, 0, 0); diff --git a/crates/swc/tests/tsc-references/computedPropertyNames47_ES6.1.normal.js b/crates/swc/tests/tsc-references/computedPropertyNames47_ES6.1.normal.js index 208363702e9af..fca8fbec8eecd 100644 --- a/crates/swc/tests/tsc-references/computedPropertyNames47_ES6.1.normal.js +++ b/crates/swc/tests/tsc-references/computedPropertyNames47_ES6.1.normal.js @@ -8,5 +8,5 @@ var E2; E2[E2["x"] = 0] = "x"; })(E2 || (E2 = {})); var o = { - [E1.x || E2.x]: 0 + [0 || 0]: 0 }; diff --git a/crates/swc/tests/tsc-references/computedPropertyNames47_ES6.2.minified.js b/crates/swc/tests/tsc-references/computedPropertyNames47_ES6.2.minified.js index f40d3065c47c1..21cd637813742 100644 --- a/crates/swc/tests/tsc-references/computedPropertyNames47_ES6.2.minified.js +++ b/crates/swc/tests/tsc-references/computedPropertyNames47_ES6.2.minified.js @@ -1,3 +1,3 @@ //// [computedPropertyNames47_ES6.ts] var E1, E2, E11, E21; -(E11 = E1 || (E1 = {}))[E11.x = 0] = "x", (E21 = E2 || (E2 = {}))[E21.x = 0] = "x", E1.x || E2.x; +(E11 = E1 || (E1 = {}))[E11.x = 0] = "x", (E21 = E2 || (E2 = {}))[E21.x = 0] = "x"; diff --git a/crates/swc/tests/tsc-references/computedPropertyNames48_ES5.1.normal.js b/crates/swc/tests/tsc-references/computedPropertyNames48_ES5.1.normal.js index 1bd79367c12e7..1931fad1460c3 100644 --- a/crates/swc/tests/tsc-references/computedPropertyNames48_ES5.1.normal.js +++ b/crates/swc/tests/tsc-references/computedPropertyNames48_ES5.1.normal.js @@ -6,5 +6,5 @@ var E; })(E || (E = {})); var a; extractIndexer(_define_property({}, a, "")); // Should return string -extractIndexer(_define_property({}, E.x, "")); // Should return string +extractIndexer(_define_property({}, 0, "")); // Should return string extractIndexer(_define_property({}, "" || 0, "")); // Should return any (widened form of undefined) diff --git a/crates/swc/tests/tsc-references/computedPropertyNames48_ES5.2.minified.js b/crates/swc/tests/tsc-references/computedPropertyNames48_ES5.2.minified.js index a49fa9ac9f793..a6763fe30ebac 100644 --- a/crates/swc/tests/tsc-references/computedPropertyNames48_ES5.2.minified.js +++ b/crates/swc/tests/tsc-references/computedPropertyNames48_ES5.2.minified.js @@ -1,5 +1,5 @@ //// [computedPropertyNames48_ES5.ts] var E, a, E1; import { _ as _define_property } from "@swc/helpers/_/_define_property"; -(E1 = E || (E = {}))[E1.x = 0] = "x", extractIndexer(_define_property({}, a, "")), extractIndexer(_define_property({}, E.x, "")), extractIndexer(_define_property({}, 0, "")); +(E1 = E || (E = {}))[E1.x = 0] = "x", extractIndexer(_define_property({}, a, "")), extractIndexer(_define_property({}, 0, "")), extractIndexer(_define_property({}, 0, "")); // Should return any (widened form of undefined) diff --git a/crates/swc/tests/tsc-references/computedPropertyNames48_ES6.1.normal.js b/crates/swc/tests/tsc-references/computedPropertyNames48_ES6.1.normal.js index bb20c717abeba..b10c6205bfaa4 100644 --- a/crates/swc/tests/tsc-references/computedPropertyNames48_ES6.1.normal.js +++ b/crates/swc/tests/tsc-references/computedPropertyNames48_ES6.1.normal.js @@ -8,7 +8,7 @@ extractIndexer({ [a]: "" }); // Should return string extractIndexer({ - [E.x]: "" + [0]: "" }); // Should return string extractIndexer({ ["" || 0]: "" diff --git a/crates/swc/tests/tsc-references/computedPropertyNames48_ES6.2.minified.js b/crates/swc/tests/tsc-references/computedPropertyNames48_ES6.2.minified.js index 7c59a52795dde..bd361e979f65f 100644 --- a/crates/swc/tests/tsc-references/computedPropertyNames48_ES6.2.minified.js +++ b/crates/swc/tests/tsc-references/computedPropertyNames48_ES6.2.minified.js @@ -3,7 +3,7 @@ var E, a, E1; (E1 = E || (E = {}))[E1.x = 0] = "x", extractIndexer({ [a]: "" }), extractIndexer({ - [E.x]: "" + 0: "" }), extractIndexer({ 0: "" }); diff --git a/crates/swc/tests/tsc-references/computedPropertyNames7_ES5.1.normal.js b/crates/swc/tests/tsc-references/computedPropertyNames7_ES5.1.normal.js index 5e9c207788f91..fb675d5d2a865 100644 --- a/crates/swc/tests/tsc-references/computedPropertyNames7_ES5.1.normal.js +++ b/crates/swc/tests/tsc-references/computedPropertyNames7_ES5.1.normal.js @@ -4,4 +4,4 @@ var E; (function(E) { E[E["member"] = 0] = "member"; })(E || (E = {})); -var v = _define_property({}, E.member, 0); +var v = _define_property({}, 0, 0); diff --git a/crates/swc/tests/tsc-references/computedPropertyNames7_ES5.2.minified.js b/crates/swc/tests/tsc-references/computedPropertyNames7_ES5.2.minified.js index afd86ec8dc0af..ad39adae63618 100644 --- a/crates/swc/tests/tsc-references/computedPropertyNames7_ES5.2.minified.js +++ b/crates/swc/tests/tsc-references/computedPropertyNames7_ES5.2.minified.js @@ -1,4 +1,4 @@ //// [computedPropertyNames7_ES5.ts] var E, E1; import { _ as _define_property } from "@swc/helpers/_/_define_property"; -(E1 = E || (E = {}))[E1.member = 0] = "member", _define_property({}, E.member, 0); +(E1 = E || (E = {}))[E1.member = 0] = "member", _define_property({}, 0, 0); diff --git a/crates/swc/tests/tsc-references/computedPropertyNames7_ES6.1.normal.js b/crates/swc/tests/tsc-references/computedPropertyNames7_ES6.1.normal.js index d1ee7e703eddc..23f5f85339b1c 100644 --- a/crates/swc/tests/tsc-references/computedPropertyNames7_ES6.1.normal.js +++ b/crates/swc/tests/tsc-references/computedPropertyNames7_ES6.1.normal.js @@ -4,5 +4,5 @@ var E; E[E["member"] = 0] = "member"; })(E || (E = {})); var v = { - [E.member]: 0 + [0]: 0 }; diff --git a/crates/swc/tests/tsc-references/computedPropertyNames7_ES6.2.minified.js b/crates/swc/tests/tsc-references/computedPropertyNames7_ES6.2.minified.js index ebfc185fd6dd6..05c4be82d83f1 100644 --- a/crates/swc/tests/tsc-references/computedPropertyNames7_ES6.2.minified.js +++ b/crates/swc/tests/tsc-references/computedPropertyNames7_ES6.2.minified.js @@ -1,3 +1,3 @@ //// [computedPropertyNames7_ES6.ts] var E, E1; -(E1 = E || (E = {}))[E1.member = 0] = "member", E.member; +(E1 = E || (E = {}))[E1.member = 0] = "member"; diff --git a/crates/swc/tests/tsc-references/constAssertionOnEnum.1.normal.js b/crates/swc/tests/tsc-references/constAssertionOnEnum.1.normal.js index efd621a3d471d..6cedbb2468b8e 100644 --- a/crates/swc/tests/tsc-references/constAssertionOnEnum.1.normal.js +++ b/crates/swc/tests/tsc-references/constAssertionOnEnum.1.normal.js @@ -13,14 +13,14 @@ var Bar; Bar[Bar["B"] = 1] = "B"; })(Bar || (Bar = {})); let foo = Foo.A; -let bar = Bar.A; +let bar = 0; //// [ns.ts] var ns; -(function(ns1) { +(function(ns) { let Foo; (function(Foo) { Foo[Foo["X"] = 0] = "X"; - })(Foo = ns1.Foo || (ns1.Foo = {})); + })(Foo = ns.Foo || (ns.Foo = {})); ns.Foo.X; })(ns || (ns = {})); //// [more.ts] diff --git a/crates/swc/tests/tsc-references/constAssertionOnEnum.2.minified.js b/crates/swc/tests/tsc-references/constAssertionOnEnum.2.minified.js index ed06affd361a2..ecedf37d5e129 100644 --- a/crates/swc/tests/tsc-references/constAssertionOnEnum.2.minified.js +++ b/crates/swc/tests/tsc-references/constAssertionOnEnum.2.minified.js @@ -7,10 +7,10 @@ export { Foo1 as Foo }; //// [test.ts] var Bar, Bar1; import { Foo } from './enum'; -(Bar1 = Bar || (Bar = {}))[Bar1.A = 0] = "A", Bar1[Bar1.B = 1] = "B", Foo.A, Bar.A; +(Bar1 = Bar || (Bar = {}))[Bar1.A = 0] = "A", Bar1[Bar1.B = 1] = "B", Foo.A; //// [ns.ts] var ns, ns1, Foo; -(Foo = (ns1 = ns || (ns = {})).Foo || (ns1.Foo = {}))[Foo.X = 0] = "X", ns.Foo.X; +(Foo = (ns1 = ns || (ns = {})).Foo || (ns1.Foo = {}))[Foo.X = 0] = "X", ns1.Foo.X; //// [more.ts] var Foo; var Foo1; diff --git a/crates/swc/tests/tsc-references/constEnum1.1.normal.js b/crates/swc/tests/tsc-references/constEnum1.1.normal.js index f756f999c3c06..0a10dc161230f 100644 --- a/crates/swc/tests/tsc-references/constEnum1.1.normal.js +++ b/crates/swc/tests/tsc-references/constEnum1.1.normal.js @@ -3,13 +3,3 @@ // In a constant enum declaration, all members must have constant values and // it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression. var E; -(function(E) { - E[E["a"] = 10] = "a"; - E[E["b"] = 10] = "b"; - E[E["c"] = 11] = "c"; - E[E["e"] = 12] = "e"; - E[E["d"] = -13] = "d"; - E[E["f"] = 20] = "f"; - E[E["g"] = 20] = "g"; - E[E["h"] = 10] = "h"; -})(E || (E = {})); diff --git a/crates/swc/tests/tsc-references/constEnum1.2.minified.js b/crates/swc/tests/tsc-references/constEnum1.2.minified.js index 8359a1a6361a5..55e66098a8d76 100644 --- a/crates/swc/tests/tsc-references/constEnum1.2.minified.js +++ b/crates/swc/tests/tsc-references/constEnum1.2.minified.js @@ -2,5 +2,3 @@ // An enum declaration that specifies a const modifier is a constant enum declaration. // In a constant enum declaration, all members must have constant values and // it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression. -var E, E1; -(E1 = E || (E = {}))[E1.a = 10] = "a", E1[E1.b = 10] = "b", E1[E1.c = 11] = "c", E1[E1.e = 12] = "e", E1[E1.d = -13] = "d", E1[E1.f = 20] = "f", E1[E1.g = 20] = "g", E1[E1.h = 10] = "h"; diff --git a/crates/swc/tests/tsc-references/constEnum2.1.normal.js b/crates/swc/tests/tsc-references/constEnum2.1.normal.js index 72e6c34f7d3cf..04c05c2c00f29 100644 --- a/crates/swc/tests/tsc-references/constEnum2.1.normal.js +++ b/crates/swc/tests/tsc-references/constEnum2.1.normal.js @@ -6,7 +6,6 @@ var CONST = 9000 % 2; var D; (function(D) { - D[D["d"] = 10] = "d"; D[D["e"] = 199 * Math.floor(Math.random() * 1000)] = "e"; D[D["f"] = 10 - 100 * Math.floor(Math.random() % 8)] = "f"; D[D["g"] = CONST] = "g"; diff --git a/crates/swc/tests/tsc-references/constEnum2.2.minified.js b/crates/swc/tests/tsc-references/constEnum2.2.minified.js index 38707158b1502..cad837c64f79d 100644 --- a/crates/swc/tests/tsc-references/constEnum2.2.minified.js +++ b/crates/swc/tests/tsc-references/constEnum2.2.minified.js @@ -4,4 +4,4 @@ // it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression. // Error : not a constant enum expression var D, D1; -(D1 = D || (D = {}))[D1.d = 10] = "d", D1[D1.e = 199 * Math.floor(1000 * Math.random())] = "e", D1[D1.f = 10 - 100 * Math.floor(Math.random() % 8)] = "f", D1[D1.g = 0] = "g"; +(D1 = D || (D = {}))[D1.e = 199 * Math.floor(1000 * Math.random())] = "e", D1[D1.f = 10 - 100 * Math.floor(Math.random() % 8)] = "f", D1[D1.g = 0] = "g"; diff --git a/crates/swc/tests/tsc-references/constEnum3.1.normal.js b/crates/swc/tests/tsc-references/constEnum3.1.normal.js index f4677fcef2683..d00b04299cbc3 100644 --- a/crates/swc/tests/tsc-references/constEnum3.1.normal.js +++ b/crates/swc/tests/tsc-references/constEnum3.1.normal.js @@ -1,9 +1,5 @@ //// [constEnum3.ts] var TestType; -(function(TestType) { - TestType[TestType["foo"] = 0] = "foo"; - TestType[TestType["bar"] = 1] = "bar"; -})(TestType || (TestType = {})); function f1(f) {} function f2(f) {} f1(0); diff --git a/crates/swc/tests/tsc-references/constEnum3.2.minified.js b/crates/swc/tests/tsc-references/constEnum3.2.minified.js index a45c4c2e72ed5..1e5484fb4523b 100644 --- a/crates/swc/tests/tsc-references/constEnum3.2.minified.js +++ b/crates/swc/tests/tsc-references/constEnum3.2.minified.js @@ -1,3 +1 @@ //// [constEnum3.ts] -var TestType, TestType1; -(TestType1 = TestType || (TestType = {}))[TestType1.foo = 0] = "foo", TestType1[TestType1.bar = 1] = "bar"; diff --git a/crates/swc/tests/tsc-references/constEnumPropertyAccess1.1.normal.js b/crates/swc/tests/tsc-references/constEnumPropertyAccess1.1.normal.js index f5cf058b06818..3a18f8637b060 100644 --- a/crates/swc/tests/tsc-references/constEnumPropertyAccess1.1.normal.js +++ b/crates/swc/tests/tsc-references/constEnumPropertyAccess1.1.normal.js @@ -3,12 +3,6 @@ // it is an error to reference a constant enum object in any other context // than a property access that selects one of the enum's members var G; -(function(G) { - G[G["A"] = 1] = "A"; - G[G["B"] = 2] = "B"; - G[G["C"] = 3] = "C"; - G[G["D"] = 2] = "D"; -})(G || (G = {})); var o = { 1: true }; diff --git a/crates/swc/tests/tsc-references/constEnumPropertyAccess1.2.minified.js b/crates/swc/tests/tsc-references/constEnumPropertyAccess1.2.minified.js index 89cec51fee1b0..8dc64da91e96c 100644 --- a/crates/swc/tests/tsc-references/constEnumPropertyAccess1.2.minified.js +++ b/crates/swc/tests/tsc-references/constEnumPropertyAccess1.2.minified.js @@ -2,5 +2,3 @@ // constant enum declarations are completely erased in the emitted JavaScript code. // it is an error to reference a constant enum object in any other context // than a property access that selects one of the enum's members -var G, G1; -(G = G1 || (G1 = {}))[G.A = 1] = "A", G[G.B = 2] = "B", G[G.C = 3] = "C", G[G.D = 2] = "D"; diff --git a/crates/swc/tests/tsc-references/constEnumPropertyAccess2.1.normal.js b/crates/swc/tests/tsc-references/constEnumPropertyAccess2.1.normal.js index 7defae1baa660..6d22c6b2bb4c4 100644 --- a/crates/swc/tests/tsc-references/constEnumPropertyAccess2.1.normal.js +++ b/crates/swc/tests/tsc-references/constEnumPropertyAccess2.1.normal.js @@ -3,12 +3,6 @@ // it is an error to reference a constant enum object in any other context // than a property access that selects one of the enum's members var G; -(function(G) { - G[G["A"] = 1] = "A"; - G[G["B"] = 2] = "B"; - G[G["C"] = 3] = "C"; - G[G["D"] = 2] = "D"; -})(G || (G = {})); // Error from referring constant enum in any other context than a property access var z = G; var z1 = G[1]; diff --git a/crates/swc/tests/tsc-references/constEnumPropertyAccess2.2.minified.js b/crates/swc/tests/tsc-references/constEnumPropertyAccess2.2.minified.js index 6f6664443254e..907c2c3eacd00 100644 --- a/crates/swc/tests/tsc-references/constEnumPropertyAccess2.2.minified.js +++ b/crates/swc/tests/tsc-references/constEnumPropertyAccess2.2.minified.js @@ -2,5 +2,5 @@ // constant enum declarations are completely erased in the emitted JavaScript code. // it is an error to reference a constant enum object in any other context // than a property access that selects one of the enum's members -var G, G1; -(G1 = G || (G = {}))[G1.A = 1] = "A", G1[G1.B = 2] = "B", G1[G1.C = 3] = "C", G1[G1.D = 2] = "D", G[1], G.B = 3; +var G; +G[1], G.B = 3; diff --git a/crates/swc/tests/tsc-references/constructSignaturesWithOverloads2.1.normal.js b/crates/swc/tests/tsc-references/constructSignaturesWithOverloads2.1.normal.js index 3584bf60ca3c4..8e1c2c87d1907 100644 --- a/crates/swc/tests/tsc-references/constructSignaturesWithOverloads2.1.normal.js +++ b/crates/swc/tests/tsc-references/constructSignaturesWithOverloads2.1.normal.js @@ -7,7 +7,16 @@ var C = function C(x) { _class_call_check(this, C); }; (function(C) { - var x = C.x = 1; + var x = 1; + Object.defineProperty(C, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(C || (C = {})); var r1 = new C(1, ""); var C2 = function C2(x) { @@ -15,7 +24,16 @@ var C2 = function C2(x) { _class_call_check(this, C2); }; (function(C2) { - var x = C2.x = 1; + var x = 1; + Object.defineProperty(C2, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(C2 || (C2 = {})); var r2 = new C2(1, ""); var i2; diff --git a/crates/swc/tests/tsc-references/constructSignaturesWithOverloads2.2.minified.js b/crates/swc/tests/tsc-references/constructSignaturesWithOverloads2.2.minified.js index 29f0c4b3fd530..1af559cb3db3b 100644 --- a/crates/swc/tests/tsc-references/constructSignaturesWithOverloads2.2.minified.js +++ b/crates/swc/tests/tsc-references/constructSignaturesWithOverloads2.2.minified.js @@ -2,11 +2,27 @@ // No errors expected for basic overloads of construct signatures with merged declarations // clodules import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var i2, C = function C(x) { +var C, x, C2, x1, i2, C1 = function C(x) { _class_call_check(this, C); }; -(C || (C = {})).x = 1, new C(1, ""); -var C2 = function C2(x) { +C = C1 || (C1 = {}), x = 1, Object.defineProperty(C, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}), new C1(1, ""); +var C21 = function C2(x) { _class_call_check(this, C2); }; -(C2 || (C2 = {})).x = 1, new C2(1, ""), new i2(1, ""), new i2(1, 1); +C2 = C21 || (C21 = {}), x1 = 1, Object.defineProperty(C2, "x", { + enumerable: !0, + get: function() { + return x1; + }, + set: function(v) { + x1 = v; + } +}), new C21(1, ""), new i2(1, ""), new i2(1, 1); diff --git a/crates/swc/tests/tsc-references/declarationEmitWorkWithInlineComments.1.normal.js b/crates/swc/tests/tsc-references/declarationEmitWorkWithInlineComments.1.normal.js index 144eac03eb344..a9b7110e17a07 100644 --- a/crates/swc/tests/tsc-references/declarationEmitWorkWithInlineComments.1.normal.js +++ b/crates/swc/tests/tsc-references/declarationEmitWorkWithInlineComments.1.normal.js @@ -1,6 +1,11 @@ //// [declarationEmitWorkWithInlineComments.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -export var Foo = function Foo(isInternal1, isInternal2, isInternal3, isInternal4, isInternal5, isInternal6 /* trailing */ , isInternal7, notInternal1, notInternal2, notInternal3) { +export var Foo = function Foo(/** @internal */ isInternal1, /** @internal */ isInternal2, /** @internal */ isInternal3, // @internal +isInternal4, // nothing +/** @internal */ isInternal5, /* @internal */ isInternal6 /* trailing */ , /* @internal */ isInternal7, /** @internal */ // not work +notInternal1, // @internal +/* not work */ notInternal2, /* not work */ // @internal +/* not work */ notInternal3) { "use strict"; _class_call_check(this, Foo); this.isInternal1 = isInternal1; @@ -14,12 +19,12 @@ export var Foo = function Foo(isInternal1, isInternal2, isInternal3, isInternal4 this.notInternal2 = notInternal2; this.notInternal3 = notInternal3; }; -export var Bar = function Bar(isInternal1) { +export var Bar = function Bar(/* @internal */ isInternal1) { "use strict"; _class_call_check(this, Bar); this.isInternal1 = isInternal1; }; -export var Baz = function Baz(isInternal) { +export var Baz = function Baz(/* @internal */ isInternal) { "use strict"; _class_call_check(this, Baz); this.isInternal = isInternal; diff --git a/crates/swc/tests/tsc-references/declarationEmitWorkWithInlineComments.2.minified.js b/crates/swc/tests/tsc-references/declarationEmitWorkWithInlineComments.2.minified.js index b7ac53f7e53d4..36b8c1df34acb 100644 --- a/crates/swc/tests/tsc-references/declarationEmitWorkWithInlineComments.2.minified.js +++ b/crates/swc/tests/tsc-references/declarationEmitWorkWithInlineComments.2.minified.js @@ -1,11 +1,16 @@ //// [declarationEmitWorkWithInlineComments.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -export var Foo = function Foo(isInternal1, isInternal2, isInternal3, isInternal4, isInternal5, isInternal6 /* trailing */ , isInternal7, notInternal1, notInternal2, notInternal3) { +export var Foo = function Foo(/** @internal */ isInternal1, /** @internal */ isInternal2, /** @internal */ isInternal3, // @internal +isInternal4, // nothing +/** @internal */ isInternal5, /* @internal */ isInternal6 /* trailing */ , /* @internal */ isInternal7, /** @internal */ // not work +notInternal1, // @internal +/* not work */ notInternal2, /* not work */ // @internal +/* not work */ notInternal3) { _class_call_check(this, Foo), this.isInternal1 = isInternal1, this.isInternal2 = isInternal2, this.isInternal3 = isInternal3, this.isInternal4 = isInternal4, this.isInternal5 = isInternal5, this.isInternal6 = isInternal6, this.isInternal7 = isInternal7, this.notInternal1 = notInternal1, this.notInternal2 = notInternal2, this.notInternal3 = notInternal3; }; -export var Bar = function Bar(isInternal1) { +export var Bar = function Bar(/* @internal */ isInternal1) { _class_call_check(this, Bar), this.isInternal1 = isInternal1; }; -export var Baz = function Baz(isInternal) { +export var Baz = function Baz(/* @internal */ isInternal) { _class_call_check(this, Baz), this.isInternal = isInternal; }; diff --git a/crates/swc/tests/tsc-references/declarationsAndAssignments.1.normal.js b/crates/swc/tests/tsc-references/declarationsAndAssignments.1.normal.js index 22ef702580efc..fe514b31922ad 100644 --- a/crates/swc/tests/tsc-references/declarationsAndAssignments.1.normal.js +++ b/crates/swc/tests/tsc-references/declarationsAndAssignments.1.normal.js @@ -202,7 +202,27 @@ f14([ ]); // Error, no x var M; (function(M) { - M.a = 1, M.b = 2; + var a = 1, b = 2; + Object.definePropertys(M, { + a: { + enumerable: true, + get: function get() { + return a; + }, + set: function set(v) { + a = v; + } + }, + b: { + enumerable: true, + get: function get() { + return b; + }, + set: function set(v) { + b = v; + } + } + }); })(M || (M = {})); function f15() { var a = "hello"; diff --git a/crates/swc/tests/tsc-references/declarationsAndAssignments.2.minified.js b/crates/swc/tests/tsc-references/declarationsAndAssignments.2.minified.js index 16ebbe31be5be..b005f9ea8642d 100644 --- a/crates/swc/tests/tsc-references/declarationsAndAssignments.2.minified.js +++ b/crates/swc/tests/tsc-references/declarationsAndAssignments.2.minified.js @@ -1,5 +1,5 @@ //// [declarationsAndAssignments.ts] -var M, M1; +var M, M1, a, b; import "@swc/helpers/_/_object_destructuring_empty"; import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array"; import "@swc/helpers/_/_to_array"; @@ -35,7 +35,26 @@ f14([ y: !1 } ] -]), (M1 = M || (M = {})).a = 1, M1.b = 2, f17({}), f17({ +]), M1 = M || (M = {}), a = 1, b = 2, Object.definePropertys(M1, { + a: { + enumerable: !0, + get: function() { + return a; + }, + set: function(v) { + a = v; + } + }, + b: { + enumerable: !0, + get: function() { + return b; + }, + set: function(v) { + b = v; + } + } +}), f17({}), f17({ a: "hello" }), f17({ c: !0 diff --git a/crates/swc/tests/tsc-references/decrementOperatorWithAnyOtherType.1.normal.js b/crates/swc/tests/tsc-references/decrementOperatorWithAnyOtherType.1.normal.js index dbf1237cfc929..998a90eaf114e 100644 --- a/crates/swc/tests/tsc-references/decrementOperatorWithAnyOtherType.1.normal.js +++ b/crates/swc/tests/tsc-references/decrementOperatorWithAnyOtherType.1.normal.js @@ -18,7 +18,15 @@ var A = function A() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // any type var diff --git a/crates/swc/tests/tsc-references/decrementOperatorWithAnyOtherType.2.minified.js b/crates/swc/tests/tsc-references/decrementOperatorWithAnyOtherType.2.minified.js index f63167cde1787..58809d64fe5ad 100644 --- a/crates/swc/tests/tsc-references/decrementOperatorWithAnyOtherType.2.minified.js +++ b/crates/swc/tests/tsc-references/decrementOperatorWithAnyOtherType.2.minified.js @@ -8,7 +8,15 @@ var n, ANY, ANY1, M, ANY2 = [ x: 1, y: null }; -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new function A() { _class_call_check(this, A); }(); diff --git a/crates/swc/tests/tsc-references/decrementOperatorWithNumberType.1.normal.js b/crates/swc/tests/tsc-references/decrementOperatorWithNumberType.1.normal.js index 68a9277063031..2da6b4c8a1da2 100644 --- a/crates/swc/tests/tsc-references/decrementOperatorWithNumberType.1.normal.js +++ b/crates/swc/tests/tsc-references/decrementOperatorWithNumberType.1.normal.js @@ -13,7 +13,15 @@ var A = function A() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // number type var diff --git a/crates/swc/tests/tsc-references/decrementOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/decrementOperatorWithNumberType.2.minified.js index 822147d81f7b5..c96a387f89303 100644 --- a/crates/swc/tests/tsc-references/decrementOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/decrementOperatorWithNumberType.2.minified.js @@ -5,7 +5,15 @@ var n, NUMBER, M, NUMBER1 = [ 1, 2 ]; -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new function A() { _class_call_check(this, A); }(); diff --git a/crates/swc/tests/tsc-references/defaultExportsCannotMerge01.1.normal.js b/crates/swc/tests/tsc-references/defaultExportsCannotMerge01.1.normal.js index d48bcb19bb1ea..1bb4e4b7ca5f0 100644 --- a/crates/swc/tests/tsc-references/defaultExportsCannotMerge01.1.normal.js +++ b/crates/swc/tests/tsc-references/defaultExportsCannotMerge01.1.normal.js @@ -5,27 +5,36 @@ Object.defineProperty(exports, "__esModule", { value: true }); -function _export(target, all) { - for(var name in all)Object.defineProperty(target, name, { - enumerable: true, - get: all[name] - }); -} -_export(exports, { - Decl: function() { - return Decl; - }, - default: function() { +Object.defineProperty(exports, "default", { + enumerable: true, + get: function() { return Decl; } }); function Decl() { return 0; } -var Decl; (function(Decl) { - var x = Decl.x = 10; - var y = Decl.y = 20; + var x = 10; + Object.defineProperty(Decl, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); + var y = 20; + Object.defineProperty(Decl, "y", { + enumerable: true, + get: function get() { + return y; + }, + set: function set(v) { + y = v; + } + }); })(Decl || (Decl = {})); //// [m2.ts] "use strict"; diff --git a/crates/swc/tests/tsc-references/defaultExportsCannotMerge01.2.minified.js b/crates/swc/tests/tsc-references/defaultExportsCannotMerge01.2.minified.js index 878039687cace..bcdefe0ddfdab 100644 --- a/crates/swc/tests/tsc-references/defaultExportsCannotMerge01.2.minified.js +++ b/crates/swc/tests/tsc-references/defaultExportsCannotMerge01.2.minified.js @@ -1,24 +1,33 @@ //// [defaultExportsCannotMerge01.ts] //// [m1.ts] -var Decl, Decl1; -function Decl() { +var Decl, x, y; +function Decl1() { return 0; } Object.defineProperty(exports, "__esModule", { value: !0 -}), function(target, all) { - for(var name in all)Object.defineProperty(target, name, { - enumerable: !0, - get: all[name] - }); -}(exports, { - Decl: function() { - return Decl; +}), Object.defineProperty(exports, "default", { + enumerable: !0, + get: function() { + return Decl1; + } +}), Decl = Decl1 || (Decl1 = {}), x = 10, Object.defineProperty(Decl, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}), y = 20, Object.defineProperty(Decl, "y", { + enumerable: !0, + get: function() { + return y; }, - default: function() { - return Decl; + set: function(v) { + y = v; } -}), (Decl1 = Decl || (Decl = {})).x = 10, Decl1.y = 20; +}); //// [m2.ts] Object.defineProperty(exports, "__esModule", { value: !0 diff --git a/crates/swc/tests/tsc-references/defaultExportsCannotMerge04.1.normal.js b/crates/swc/tests/tsc-references/defaultExportsCannotMerge04.1.normal.js index a7a8f256ffc0d..caf6119534236 100644 --- a/crates/swc/tests/tsc-references/defaultExportsCannotMerge04.1.normal.js +++ b/crates/swc/tests/tsc-references/defaultExportsCannotMerge04.1.normal.js @@ -10,8 +10,15 @@ Object.defineProperty(exports, "default", { } }); function Foo() {} -var Foo; (function(Foo) { var x; - Foo.x = x; + Object.defineProperty(Foo, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(Foo || (Foo = {})); diff --git a/crates/swc/tests/tsc-references/defaultExportsCannotMerge04.2.minified.js b/crates/swc/tests/tsc-references/defaultExportsCannotMerge04.2.minified.js index fb80f144e3df7..1cf1a5ce8b849 100644 --- a/crates/swc/tests/tsc-references/defaultExportsCannotMerge04.2.minified.js +++ b/crates/swc/tests/tsc-references/defaultExportsCannotMerge04.2.minified.js @@ -1,5 +1,5 @@ //// [defaultExportsCannotMerge04.ts] -var Foo, x; +var x; function Foo() {} Object.defineProperty(exports, "__esModule", { value: !0 @@ -8,4 +8,12 @@ Object.defineProperty(exports, "__esModule", { get: function() { return Foo; } -}), (Foo || (Foo = {})).x = x; +}), Object.defineProperty(Foo || (Foo = {}), "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}); diff --git a/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es2022).1.normal.js b/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es2022).1.normal.js index 37fc24e12afd1..32f87e1602e20 100644 --- a/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es2022).1.normal.js +++ b/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es2022).1.normal.js @@ -4,10 +4,10 @@ var K; K["a"] = "a"; K["b"] = "b"; })(K || (K = {})); -const { [K.a]: aVal, [K.b]: bVal } = (()=>{ +const { ["a"]: aVal, ["b"]: bVal } = (()=>{ return { - [K.a]: 1, - [K.b]: 1 + ["a"]: 1, + ["b"]: 1 }; })(); console.log(aVal, bVal); diff --git a/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es2022).2.minified.js b/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es2022).2.minified.js index 25b7b2196f528..70138587b5746 100644 --- a/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es2022).2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es2022).2.minified.js @@ -1,8 +1,8 @@ //// [destructuringObjectBindingPatternAndAssignment7.ts] var K, K1; (K1 = K || (K = {})).a = "a", K1.b = "b"; -const { [K.a]: aVal, [K.b]: bVal } = { - [K.a]: 1, - [K.b]: 1 +const { a: aVal, b: bVal } = { + a: 1, + b: 1 }; console.log(aVal, bVal); diff --git a/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es5).1.normal.js b/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es5).1.normal.js index b064661d9d6e0..5b60210c62108 100644 --- a/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es5).1.normal.js +++ b/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es5).1.normal.js @@ -7,6 +7,6 @@ var K; })(K || (K = {})); var _ref = function() { var _obj; - return _obj = {}, _define_property(_obj, K.a, 1), _define_property(_obj, K.b, 1), _obj; -}(), aVal = _ref[K.a], bVal = _ref[K.b]; + return _obj = {}, _define_property(_obj, "a", 1), _define_property(_obj, "b", 1), _obj; +}(), aVal = _ref["a"], bVal = _ref["b"]; console.log(aVal, bVal); diff --git a/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es5).2.minified.js b/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es5).2.minified.js index 7501017f19177..4e9eeb790eeef 100644 --- a/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es5).2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es5).2.minified.js @@ -1,5 +1,5 @@ //// [destructuringObjectBindingPatternAndAssignment7.ts] import { _ as _define_property } from "@swc/helpers/_/_define_property"; (K = K1 || (K1 = {})).a = "a", K.b = "b"; -var K, _obj, K1, _ref = (_define_property(_obj = {}, K1.a, 1), _define_property(_obj, K1.b, 1), _obj); -console.log(_ref[K1.a], _ref[K1.b]); +var K, _obj, K1, _ref = (_define_property(_obj = {}, "a", 1), _define_property(_obj, "b", 1), _obj); +console.log(_ref.a, _ref.b); diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5.1.normal.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5.1.normal.js index c82c286fe8277..39f58510e69a2 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5.1.normal.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5.1.normal.js @@ -72,10 +72,6 @@ var E; E[E["b"] = 1] = "b"; })(E || (E = {})); var E1; -(function(E1) { - E1[E1["a"] = 0] = "a"; - E1[E1["b"] = 1] = "b"; -})(E1 || (E1 = {})); function foo1(...a) {} -foo1(1, 2, 3, E.a); -foo1(1, 2, 3, 0, E.b); +foo1(1, 2, 3, 0); +foo1(1, 2, 3, 0, 1); diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5.2.minified.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5.2.minified.js index 9127934ef98f1..7494221155166 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5.2.minified.js @@ -3,7 +3,7 @@ // A type annotation for a rest parameter must denote an array type. // RestParameter: // ... Identifier TypeAnnotation(opt) -var E, E1, E2, E11, array = [ +var E, E1, array = [ 1, 2, 3 @@ -23,4 +23,4 @@ var E, E1, E2, E11, array = [ ]), function([a, b, c, ...x]) {}([ 1, 2 -]), (E = E2 || (E2 = {}))[E.a = 0] = "a", E[E.b = 1] = "b", (E1 = E11 || (E11 = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E2.a, E2.b; +]), (E = E1 || (E1 = {}))[E.a = 0] = "a", E[E.b = 1] = "b"; diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.1.normal.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.1.normal.js index 660260b139835..06ce927caf49c 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.1.normal.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.1.normal.js @@ -103,14 +103,10 @@ var E; E[E["b"] = 1] = "b"; })(E || (E = {})); var E1; -(function(E1) { - E1[E1["a"] = 0] = "a"; - E1[E1["b"] = 1] = "b"; -})(E1 || (E1 = {})); function foo1() { for(var _len = arguments.length, a = new Array(_len), _key = 0; _key < _len; _key++){ a[_key] = arguments[_key]; } } -foo1(1, 2, 3, E.a); -foo1(1, 2, 3, 0, E.b); +foo1(1, 2, 3, 0); +foo1(1, 2, 3, 0, 1); diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.2.minified.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.2.minified.js index 4a404b1a66ed1..e46921a94ad1b 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.2.minified.js @@ -10,7 +10,7 @@ function a10(param) { var _param = _to_array(param), _param_ = (_param[0], _param[1], _sliced_to_array(_param[2], 1)); _sliced_to_array(_param_[0], 1)[0], _param.slice(3); } -var _param, _param_, _param1, E, E1, E2, E11, array = [ +var _param, _param_, _param1, E, E1, array = [ 1, 2, 3 @@ -58,4 +58,4 @@ function foo1() { ]), (_param1 = _to_array([ 1, 2 -]))[0], _param1[1], _param1[2], _param1.slice(3), foo("hello", 1, 2), foo("hello", "world"), (E = E2 || (E2 = {}))[E.a = 0] = "a", E[E.b = 1] = "b", (E1 = E11 || (E11 = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", foo1(1, 2, 3, E2.a), foo1(1, 2, 3, 0, E2.b); +]))[0], _param1[1], _param1[2], _param1.slice(3), foo("hello", 1, 2), foo("hello", "world"), (E = E1 || (E1 = {}))[E.a = 0] = "a", E[E.b = 1] = "b", foo1(1, 2, 3, 0), foo1(1, 2, 3, 0, 1); diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6.1.normal.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6.1.normal.js index 452655617e743..c3cdc055e0ef5 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6.1.normal.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6.1.normal.js @@ -72,10 +72,6 @@ var E; E[E["b"] = 1] = "b"; })(E || (E = {})); var E1; -(function(E1) { - E1[E1["a"] = 0] = "a"; - E1[E1["b"] = 1] = "b"; -})(E1 || (E1 = {})); function foo1(...a) {} -foo1(1, 2, 3, E.a); -foo1(1, 2, 3, 0, E.b); +foo1(1, 2, 3, 0); +foo1(1, 2, 3, 0, 1); diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6.2.minified.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6.2.minified.js index 1d27826c131e5..4f4cfe9ba042b 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6.2.minified.js @@ -3,7 +3,7 @@ // A type annotation for a rest parameter must denote an array type. // RestParameter: // ... Identifier TypeAnnotation(opt) -var E, E1, E2, E11, array = [ +var E, E1, array = [ 1, 2, 3 @@ -23,4 +23,4 @@ var E, E1, E2, E11, array = [ ]), function([a, b, c, ...x]) {}([ 1, 2 -]), (E = E2 || (E2 = {}))[E.a = 0] = "a", E[E.b = 1] = "b", (E1 = E11 || (E11 = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E2.a, E2.b; +]), (E = E1 || (E1 = {}))[E.a = 0] = "a", E[E.b = 1] = "b"; diff --git a/crates/swc/tests/tsc-references/enumAssignability.1.normal.js b/crates/swc/tests/tsc-references/enumAssignability.1.normal.js index 7b96304aeacc7..4e8e3a040b9e0 100644 --- a/crates/swc/tests/tsc-references/enumAssignability.1.normal.js +++ b/crates/swc/tests/tsc-references/enumAssignability.1.normal.js @@ -9,8 +9,8 @@ var F; (function(F) { F[F["B"] = 0] = "B"; })(F || (F = {})); -var e = E.A; -var f = F.B; +var e = 0; +var f = 0; e = f; f = e; e = 1; // ok diff --git a/crates/swc/tests/tsc-references/enumAssignability.2.minified.js b/crates/swc/tests/tsc-references/enumAssignability.2.minified.js index 35a111a1fc6e3..34c9824b117b8 100644 --- a/crates/swc/tests/tsc-references/enumAssignability.2.minified.js +++ b/crates/swc/tests/tsc-references/enumAssignability.2.minified.js @@ -2,4 +2,4 @@ // enums assignable to number, any, Object, errors unless otherwise noted var E, F, E1, F1, Others; import "@swc/helpers/_/_class_call_check"; -(E = E1 || (E1 = {}))[E.A = 0] = "A", (F = F1 || (F1 = {}))[F.B = 0] = "B", E1.A, F1.B, Others || (Others = {}); +(E = E1 || (E1 = {}))[E.A = 0] = "A", (F = F1 || (F1 = {}))[F.B = 0] = "B", Others || (Others = {}); diff --git a/crates/swc/tests/tsc-references/enumAssignabilityInInheritance.1.normal.js b/crates/swc/tests/tsc-references/enumAssignabilityInInheritance.1.normal.js index 8189cb9646e44..ebb35d09e582b 100644 --- a/crates/swc/tests/tsc-references/enumAssignabilityInInheritance.1.normal.js +++ b/crates/swc/tests/tsc-references/enumAssignabilityInInheritance.1.normal.js @@ -5,45 +5,63 @@ var E; (function(E) { E[E["A"] = 0] = "A"; })(E || (E = {})); -var r = foo(E.A); // E +var r = foo(0); // E var r2 = foo(1); // number var r3 = foo(null); // any -var r4 = foo2(E.A); -var r4 = foo3(E.A); -var r4 = foo4(E.A); -var r4 = foo5(E.A); -var r4 = foo6(E.A); -var r4 = foo7(E.A); -var r4 = foo8(E.A); +var r4 = foo2(0); +var r4 = foo3(0); +var r4 = foo4(0); +var r4 = foo5(0); +var r4 = foo6(0); +var r4 = foo7(0); +var r4 = foo8(0); var A = function A() { "use strict"; _class_call_check(this, A); }; -var r4 = foo9(E.A); +var r4 = foo9(0); var A2 = function A2() { "use strict"; _class_call_check(this, A2); }; -var r4 = foo10(E.A); -var r4 = foo11(E.A); -var r4 = foo12(E.A); +var r4 = foo10(0); +var r4 = foo11(0); +var r4 = foo12(0); var E2; (function(E2) { E2[E2["A"] = 0] = "A"; })(E2 || (E2 = {})); -var r4 = foo13(E.A); +var r4 = foo13(0); function f() {} (function(f) { - var bar = f.bar = 1; + var bar = 1; + Object.defineProperty(f, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(f || (f = {})); -var r4 = foo14(E.A); +var r4 = foo14(0); var CC = function CC() { "use strict"; _class_call_check(this, CC); }; (function(CC) { - var bar = CC.bar = 1; + var bar = 1; + Object.defineProperty(CC, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(CC || (CC = {})); -var r4 = foo15(E.A); -var r4 = foo16(E.A); -var r4 = foo16(E.A); +var r4 = foo15(0); +var r4 = foo16(0); +var r4 = foo16(0); diff --git a/crates/swc/tests/tsc-references/enumAssignabilityInInheritance.2.minified.js b/crates/swc/tests/tsc-references/enumAssignabilityInInheritance.2.minified.js index bd32eaeb8a43d..1343961d14295 100644 --- a/crates/swc/tests/tsc-references/enumAssignabilityInInheritance.2.minified.js +++ b/crates/swc/tests/tsc-references/enumAssignabilityInInheritance.2.minified.js @@ -2,8 +2,24 @@ // enum is only a subtype of number, no types are subtypes of enum, all of these except the first are errors import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; function f() {} -(E = E1 || (E1 = {}))[E.A = 0] = "A", foo(E1.A), foo(1), foo(null), foo2(E1.A), foo3(E1.A), foo4(E1.A), foo5(E1.A), foo6(E1.A), foo7(E1.A), foo8(E1.A), foo9(E1.A), foo10(E1.A), foo11(E1.A), foo12(E1.A), (E2 = E21 || (E21 = {}))[E2.A = 0] = "A", foo13(E1.A), (f || (f = {})).bar = 1, foo14(E1.A); -var E, E2, E1, E21, CC = function CC() { +(E = E1 || (E1 = {}))[E.A = 0] = "A", foo(0), foo(1), foo(null), foo2(0), foo3(0), foo4(0), foo5(0), foo6(0), foo7(0), foo8(0), foo9(0), foo10(0), foo11(0), foo12(0), (E2 = E21 || (E21 = {}))[E2.A = 0] = "A", foo13(0), f1 = f || (f = {}), bar1 = 1, Object.defineProperty(f1, "bar", { + enumerable: !0, + get: function() { + return bar1; + }, + set: function(v) { + bar1 = v; + } +}), foo14(0); +var CC, bar, E, E2, f1, bar1, E1, E21, CC1 = function CC() { _class_call_check(this, CC); }; -(CC || (CC = {})).bar = 1, foo15(E1.A), foo16(E1.A), foo16(E1.A); +CC = CC1 || (CC1 = {}), bar = 1, Object.defineProperty(CC, "bar", { + enumerable: !0, + get: function() { + return bar; + }, + set: function(v) { + bar = v; + } +}), foo15(0), foo16(0), foo16(0); diff --git a/crates/swc/tests/tsc-references/enumBasics.1.normal.js b/crates/swc/tests/tsc-references/enumBasics.1.normal.js index de54681f20fe3..2354d01e692cd 100644 --- a/crates/swc/tests/tsc-references/enumBasics.1.normal.js +++ b/crates/swc/tests/tsc-references/enumBasics.1.normal.js @@ -7,7 +7,7 @@ var E1; E1[E1["C"] = 2] = "C"; })(E1 || (E1 = {})); // Enum type is a subtype of Number -var x = E1.A; +var x = 0; // Enum object type is anonymous with properties of the enum type and numeric indexer var e = E1; var e; @@ -15,54 +15,52 @@ var e; // Reverse mapping of enum returns string name of property var s = E1[e.A]; var s; -var // Enum with only constant members -E2; +var E2; +// Enum with only constant members (function(E2) { E2[E2["A"] = 1] = "A"; E2[E2["B"] = 2] = "B"; E2[E2["C"] = 3] = "C"; })(E2 || (E2 = {})); -var // Enum with only computed members -E3; +var E3; +// Enum with only computed members (function(E3) { E3[E3["X"] = "foo".length] = "X"; E3[E3["Y"] = 7] = "Y"; E3[E3["Z"] = +"foo"] = "Z"; })(E3 || (E3 = {})); -var // Enum with constant members followed by computed members -E4; +var E4; +// Enum with constant members followed by computed members (function(E4) { E4[E4["X"] = 0] = "X"; E4[E4["Y"] = 1] = "Y"; E4[E4["Z"] = "foo".length] = "Z"; })(E4 || (E4 = {})); -var // Enum with > 2 constant members with no initializer for first member, non zero initializer for second element -E5; +var E5; +// Enum with > 2 constant members with no initializer for first member, non zero initializer for second element (function(E5) { E5[E5["A"] = 0] = "A"; E5[E5["B"] = 3] = "B"; - E5[E5["C" // 4 - ] = 4] = "C"; + E5[E5["C"] = 4] = "C"; // 4 })(E5 || (E5 = {})); var E6; (function(E6) { E6[E6["A"] = 0] = "A"; E6[E6["B"] = 0] = "B"; - E6[E6["C" // 1 - ] = 1] = "C"; + E6[E6["C"] = 1] = "C"; // 1 })(E6 || (E6 = {})); -var // Enum with computed member initializer of type 'any' -E7; +var E7; +// Enum with computed member initializer of type 'any' (function(E7) { E7[E7["A"] = "foo"["foo"]] = "A"; })(E7 || (E7 = {})); -var // Enum with computed member initializer of type number -E8; +var E8; +// Enum with computed member initializer of type number (function(E8) { E8[E8["B"] = "foo"["foo"]] = "B"; })(E8 || (E8 = {})); -var //Enum with computed member intializer of same enum type -E9; +var E9; +//Enum with computed member intializer of same enum type (function(E9) { E9[E9["A"] = 0] = "A"; E9[E9["B"] = 0] = "B"; @@ -74,17 +72,17 @@ var doNotPropagate = [ E7.A, E4.Z, E3.X, - E3.Y, + 7, E3.Z ]; // Enum computed members are not propagated var doPropagate = [ - E9.A, - E9.B, - E6.B, - E6.C, - E6.A, - E5.A, - E5.B, - E5.C + 0, + 0, + 0, + 1, + 0, + 0, + 3, + 4 ]; diff --git a/crates/swc/tests/tsc-references/enumBasics.2.minified.js b/crates/swc/tests/tsc-references/enumBasics.2.minified.js index 5aa5e067a4a85..04e006791cc5d 100644 --- a/crates/swc/tests/tsc-references/enumBasics.2.minified.js +++ b/crates/swc/tests/tsc-references/enumBasics.2.minified.js @@ -1,15 +1,6 @@ //// [enumBasics.ts] // Enum without initializers have first member = 0 and successive members = N + 1 -(E1 = E11 || (E11 = {}))[E1.A = 0] = "A", E1[E1.B = 1] = "B", E1[E1.C = 2] = "C", E11.A; +(E1 = E11 || (E11 = {}))[E1.A = 0] = "A", E1[E1.B = 1] = "B", E1[E1.C = 2] = "C"; // Enum object type is anonymous with properties of the enum type and numeric indexer -var E2, E3, E4, E5, E6, E7, E8, E9, E1, E11, // Enum with only constant members -E21, // Enum with only computed members -E31, // Enum with constant members followed by computed members -E41, // Enum with > 2 constant members with no initializer for first member, non zero initializer for second element -E51, E61, // Enum with computed member initializer of type 'any' -E71, // Enum with computed member initializer of type number -E81, //Enum with computed member intializer of same enum type -E91, e = E11; -E11[e.A], (E2 = E21 || (E21 = {}))[E2.A = 1] = "A", E2[E2.B = 2] = "B", E2[E2.C = 3] = "C", (E3 = E31 || (E31 = {}))[E3.X = 3] = "X", E3[E3.Y = 7] = "Y", E3[E3.Z = NaN] = "Z", (E4 = E41 || (E41 = {}))[E4.X = 0] = "X", E4[E4.Y = 1] = "Y", E4[E4.Z = 3] = "Z", (E5 = E51 || (E51 = {}))[E5.A = 0] = "A", E5[E5.B = 3] = "B", E5[E5.C = 4 // 4 -] = "C", (E6 = E61 || (E61 = {}))[E6.A = 0] = "A", E6[E6.B = 0] = "B", E6[E6.C = 1 // 1 -] = "C", (E7 = E71 || (E71 = {}))[E7.A = "foo".foo] = "A", (E8 = E81 || (E81 = {}))[E8.B = "foo".foo] = "B", (E9 = E91 || (E91 = {}))[E9.A = 0] = "A", E9[E9.B = 0] = "B", E81.B, E71.A, E41.Z, E31.X, E31.Y, E31.Z, E91.A, E91.B, E61.B, E61.C, E61.A, E51.A, E51.B, E51.C; +var E2, E3, E4, E5, E6, E7, E8, E9, E1, E11, E21, E31, E41, E51, E61, E71, E81, E91, e = E11; +E11[e.A], (E2 = E21 || (E21 = {}))[E2.A = 1] = "A", E2[E2.B = 2] = "B", E2[E2.C = 3] = "C", (E3 = E31 || (E31 = {}))[E3.X = 3] = "X", E3[E3.Y = 7] = "Y", E3[E3.Z = NaN] = "Z", (E4 = E41 || (E41 = {}))[E4.X = 0] = "X", E4[E4.Y = 1] = "Y", E4[E4.Z = 3] = "Z", (E5 = E51 || (E51 = {}))[E5.A = 0] = "A", E5[E5.B = 3] = "B", E5[E5.C = 4] = "C", (E6 = E61 || (E61 = {}))[E6.A = 0] = "A", E6[E6.B = 0] = "B", E6[E6.C = 1] = "C", (E7 = E71 || (E71 = {}))[E7.A = "foo".foo] = "A", (E8 = E81 || (E81 = {}))[E8.B = "foo".foo] = "B", (E9 = E91 || (E91 = {}))[E9.A = 0] = "A", E9[E9.B = 0] = "B", E81.B, E71.A, E41.Z, E31.X, E31.Z; diff --git a/crates/swc/tests/tsc-references/enumClassification.1.normal.js b/crates/swc/tests/tsc-references/enumClassification.1.normal.js index 98678d742337e..a1be527f9f14e 100644 --- a/crates/swc/tests/tsc-references/enumClassification.1.normal.js +++ b/crates/swc/tests/tsc-references/enumClassification.1.normal.js @@ -51,8 +51,8 @@ var E08; E08["D"] = "hello"; E08[E08["E"] = 10] = "E"; })(E08 || (E08 = {})); -var // Examples of numeric enum types with only constant members -E10; +var E10; +// Examples of numeric enum types with only constant members (function(E10) {})(E10 || (E10 = {})); var E11; (function(E11) { @@ -66,8 +66,8 @@ var E12; E12[E12["B"] = 2] = "B"; E12[E12["C"] = 4] = "C"; })(E12 || (E12 = {})); -var // Examples of numeric enum types with constant and computed members -E20; +var E20; +// Examples of numeric enum types with constant and computed members (function(E20) { E20[E20["A"] = "foo".length] = "A"; E20[E20["B"] = E20.A + 1] = "B"; diff --git a/crates/swc/tests/tsc-references/enumClassification.2.minified.js b/crates/swc/tests/tsc-references/enumClassification.2.minified.js index 6600b60bd8997..883ddb0b57c2b 100644 --- a/crates/swc/tests/tsc-references/enumClassification.2.minified.js +++ b/crates/swc/tests/tsc-references/enumClassification.2.minified.js @@ -4,7 +4,5 @@ // the enum type is classified as a literal enum type. An enum type that doesn't adhere // to this pattern is classified as a numeric enum type. // Examples of literal enum types -var E01, E02, E03, E04, E05, E06, E07, E08, // Examples of numeric enum types with only constant members -E10, E11, E12, // Examples of numeric enum types with constant and computed members -E20, E011, E021, E041, E051, E061, E071, E081, E111, E121, E201; +var E01, E02, E03, E04, E05, E06, E07, E08, E10, E11, E12, E20, E011, E021, E041, E051, E061, E071, E081, E111, E121, E201; (E011 = E01 || (E01 = {}))[E011.A = 0] = "A", (E021 = E02 || (E02 = {}))[E021.A = 123] = "A", (E03 || (E03 = {})).A = "hello", (E041 = E04 || (E04 = {}))[E041.A = 0] = "A", E041[E041.B = 1] = "B", E041[E041.C = 2] = "C", (E051 = E05 || (E05 = {}))[E051.A = 0] = "A", E051[E051.B = 10] = "B", E051[E051.C = 11] = "C", (E061 = E06 || (E06 = {})).A = "one", E061.B = "two", E061.C = "three", (E071 = E07 || (E07 = {}))[E071.A = 0] = "A", E071[E071.B = 1] = "B", E071.C = "hi", E071[E071.D = 10] = "D", E071[E071.E = 11] = "E", E071.F = "bye", (E081 = E08 || (E08 = {}))[E081.A = 10] = "A", E081.B = "hello", E081[E081.C = 10] = "C", E081.D = "hello", E081[E081.E = 10] = "E", E10 || (E10 = {}), (E111 = E11 || (E11 = {}))[E111.A = 0] = "A", E111[E111.B = 1] = "B", E111[E111.C = 2] = "C", (E121 = E12 || (E12 = {}))[E121.A = 1] = "A", E121[E121.B = 2] = "B", E121[E121.C = 4] = "C", (E201 = E20 || (E20 = {}))[E201.A = 3] = "A", E201[E201.B = E201.A + 1] = "B", E201[E201.C = 123] = "C", E201[E201.D = 0.8414709848078965] = "D"; diff --git a/crates/swc/tests/tsc-references/enumConstantMemberWithString.1.normal.js b/crates/swc/tests/tsc-references/enumConstantMemberWithString.1.normal.js index af603ed76c679..54ac56786b823 100644 --- a/crates/swc/tests/tsc-references/enumConstantMemberWithString.1.normal.js +++ b/crates/swc/tests/tsc-references/enumConstantMemberWithString.1.normal.js @@ -27,8 +27,3 @@ var T5; (function(T5) { T5["a"] = "12"; })(T5 || (T5 = {})); -var T6; -(function(T6) { - T6["a"] = "1"; - T6["b"] = "12"; -})(T6 || (T6 = {})); diff --git a/crates/swc/tests/tsc-references/enumConstantMemberWithString.2.minified.js b/crates/swc/tests/tsc-references/enumConstantMemberWithString.2.minified.js index 8770fd3c3dcf0..da9113fe5296e 100644 --- a/crates/swc/tests/tsc-references/enumConstantMemberWithString.2.minified.js +++ b/crates/swc/tests/tsc-references/enumConstantMemberWithString.2.minified.js @@ -1,3 +1,3 @@ //// [enumConstantMemberWithString.ts] -var T1, T2, T3, T4, T5, T6, T11, T21, T31, T61; -(T11 = T1 || (T1 = {})).a = "1", T11.b = "12", T11.c = "123", T11[T11.d = "a" - "a"] = "d", T11.e = "a1", (T21 = T2 || (T2 = {})).a = "1", T21.b = "12", (T31 = T3 || (T3 = {})).a = "1", T31.b = "12", T31[T31.c = 1] = "c", T31[T31.d = 3] = "d", (T4 || (T4 = {})).a = "1", (T5 || (T5 = {})).a = "12", (T61 = T6 || (T6 = {})).a = "1", T61.b = "12"; +var T1, T2, T3, T4, T5, T11, T21, T31; +(T11 = T1 || (T1 = {})).a = "1", T11.b = "12", T11.c = "123", T11[T11.d = "a" - "a"] = "d", T11.e = "a1", (T21 = T2 || (T2 = {})).a = "1", T21.b = "12", (T31 = T3 || (T3 = {})).a = "1", T31.b = "12", T31[T31.c = 1] = "c", T31[T31.d = 3] = "d", (T4 || (T4 = {})).a = "1", (T5 || (T5 = {})).a = "12"; diff --git a/crates/swc/tests/tsc-references/enumConstantMemberWithStringEmitDeclaration.1.normal.js b/crates/swc/tests/tsc-references/enumConstantMemberWithStringEmitDeclaration.1.normal.js index 15175b0d842ce..5ab10491ec1d6 100644 --- a/crates/swc/tests/tsc-references/enumConstantMemberWithStringEmitDeclaration.1.normal.js +++ b/crates/swc/tests/tsc-references/enumConstantMemberWithStringEmitDeclaration.1.normal.js @@ -23,8 +23,3 @@ var T5; (function(T5) { T5["a"] = "12"; })(T5 || (T5 = {})); -var T6; -(function(T6) { - T6["a"] = "1"; - T6["b"] = "12"; -})(T6 || (T6 = {})); diff --git a/crates/swc/tests/tsc-references/enumConstantMemberWithStringEmitDeclaration.2.minified.js b/crates/swc/tests/tsc-references/enumConstantMemberWithStringEmitDeclaration.2.minified.js index 0861800f487aa..3faa6e625d4e0 100644 --- a/crates/swc/tests/tsc-references/enumConstantMemberWithStringEmitDeclaration.2.minified.js +++ b/crates/swc/tests/tsc-references/enumConstantMemberWithStringEmitDeclaration.2.minified.js @@ -1,3 +1,3 @@ //// [enumConstantMemberWithStringEmitDeclaration.ts] -var T1, T2, T3, T4, T5, T6, T11, T21, T31, T61; -(T11 = T1 || (T1 = {})).a = "1", T11.b = "12", T11.c = "123", (T21 = T2 || (T2 = {})).a = "1", T21.b = "12", (T31 = T3 || (T3 = {})).a = "1", T31.b = "12", (T4 || (T4 = {})).a = "1", (T5 || (T5 = {})).a = "12", (T61 = T6 || (T6 = {})).a = "1", T61.b = "12"; +var T1, T2, T3, T4, T5, T11, T21, T31; +(T11 = T1 || (T1 = {})).a = "1", T11.b = "12", T11.c = "123", (T21 = T2 || (T2 = {})).a = "1", T21.b = "12", (T31 = T3 || (T3 = {})).a = "1", T31.b = "12", (T4 || (T4 = {})).a = "1", (T5 || (T5 = {})).a = "12"; diff --git a/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiterals.1.normal.js b/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiterals.1.normal.js index e08a6e314e553..617a225040ea3 100644 --- a/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiterals.1.normal.js +++ b/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiterals.1.normal.js @@ -29,7 +29,7 @@ var T5; T5[T5["d"] = 1] = "d"; T5[T5["e"] = "1" - "1"] = "e"; T5["f"] = "11"; - T5[T5["g"] = "123"] = "g"; + T5["g"] = "123"; T5[T5["h"] = "1".length] = "h"; })(T5 || (T5 = {})); var T6; @@ -37,9 +37,3 @@ var T6; T6[T6["a"] = 1] = "a"; T6[T6["b"] = "12".length] = "b"; })(T6 || (T6 = {})); -var T7; -(function(T7) { - T7["a"] = "1"; - T7["b"] = "11"; - T7["c"] = "21"; -})(T7 || (T7 = {})); diff --git a/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiterals.2.minified.js b/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiterals.2.minified.js index 52ffc82ef1db1..a79a8f04e5798 100644 --- a/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiterals.2.minified.js +++ b/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiterals.2.minified.js @@ -1,3 +1,3 @@ //// [enumConstantMemberWithTemplateLiterals.ts] -var T1, T2, T3, T4, T5, T6, T7, T21, T41, T51, T61, T71; -(T1 || (T1 = {})).a = "1", (T21 = T2 || (T2 = {})).a = "1", T21.b = "2", T21[T21.c = 3] = "c", (T3 || (T3 = {})).a = "11", (T41 = T4 || (T4 = {})).a = "1", T41.b = "11", T41.c = "12", T41.d = "21", T41.e = "211", (T51 = T5 || (T5 = {})).a = "1", T51.b = "12", T51.c = "123", T51[T51.d = 1] = "d", T51[T51.e = "1" - "1"] = "e", T51.f = "11", T51[T51.g = "123"] = "g", T51[T51.h = 1] = "h", (T61 = T6 || (T6 = {}))[T61.a = 1] = "a", T61[T61.b = 2] = "b", (T71 = T7 || (T7 = {})).a = "1", T71.b = "11", T71.c = "21"; +var T1, T2, T3, T4, T5, T6, T21, T41, T51, T61; +(T1 || (T1 = {})).a = "1", (T21 = T2 || (T2 = {})).a = "1", T21.b = "2", T21[T21.c = 3] = "c", (T3 || (T3 = {})).a = "11", (T41 = T4 || (T4 = {})).a = "1", T41.b = "11", T41.c = "12", T41.d = "21", T41.e = "211", (T51 = T5 || (T5 = {})).a = "1", T51.b = "12", T51.c = "123", T51[T51.d = 1] = "d", T51[T51.e = "1" - "1"] = "e", T51.f = "11", T51.g = "123", T51[T51.h = 1] = "h", (T61 = T6 || (T6 = {}))[T61.a = 1] = "a", T61[T61.b = 2] = "b"; diff --git a/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiteralsEmitDeclaration.1.normal.js b/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiteralsEmitDeclaration.1.normal.js index 43c8742db6c97..e6c55239c8a7d 100644 --- a/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiteralsEmitDeclaration.1.normal.js +++ b/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiteralsEmitDeclaration.1.normal.js @@ -33,9 +33,3 @@ var T6; T6[T6["a"] = 1] = "a"; T6[T6["b"] = "12".length] = "b"; })(T6 || (T6 = {})); -var T7; -(function(T7) { - T7["a"] = "1"; - T7["b"] = "11"; - T7["c"] = "21"; -})(T7 || (T7 = {})); diff --git a/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiteralsEmitDeclaration.2.minified.js b/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiteralsEmitDeclaration.2.minified.js index 66694730c2389..01de87abdd5d4 100644 --- a/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiteralsEmitDeclaration.2.minified.js +++ b/crates/swc/tests/tsc-references/enumConstantMemberWithTemplateLiteralsEmitDeclaration.2.minified.js @@ -1,3 +1,3 @@ //// [enumConstantMemberWithTemplateLiteralsEmitDeclaration.ts] -var T1, T2, T3, T4, T5, T6, T7, T21, T41, T51, T61, T71; -(T1 || (T1 = {})).a = "1", (T21 = T2 || (T2 = {})).a = "1", T21.b = "2", T21[T21.c = 3] = "c", (T3 || (T3 = {})).a = "11", (T41 = T4 || (T4 = {})).a = "1", T41.b = "11", T41.c = "12", T41.d = "21", T41.e = "211", (T51 = T5 || (T5 = {})).a = "1", T51.b = "12", T51.c = "123", T51[T51.d = 1] = "d", (T61 = T6 || (T6 = {}))[T61.a = 1] = "a", T61[T61.b = 2] = "b", (T71 = T7 || (T7 = {})).a = "1", T71.b = "11", T71.c = "21"; +var T1, T2, T3, T4, T5, T6, T21, T41, T51, T61; +(T1 || (T1 = {})).a = "1", (T21 = T2 || (T2 = {})).a = "1", T21.b = "2", T21[T21.c = 3] = "c", (T3 || (T3 = {})).a = "11", (T41 = T4 || (T4 = {})).a = "1", T41.b = "11", T41.c = "12", T41.d = "21", T41.e = "211", (T51 = T5 || (T5 = {})).a = "1", T51.b = "12", T51.c = "123", T51[T51.d = 1] = "d", (T61 = T6 || (T6 = {}))[T61.a = 1] = "a", T61[T61.b = 2] = "b"; diff --git a/crates/swc/tests/tsc-references/enumExportMergingES6.1.normal.js b/crates/swc/tests/tsc-references/enumExportMergingES6.1.normal.js index 572694e55430c..ee18fb9de6759 100644 --- a/crates/swc/tests/tsc-references/enumExportMergingES6.1.normal.js +++ b/crates/swc/tests/tsc-references/enumExportMergingES6.1.normal.js @@ -7,5 +7,5 @@ export var Animals; Animals[Animals["Dog"] = 2] = "Dog"; })(Animals || (Animals = {})); (function(Animals) { - Animals[Animals["CatDog"] = Cat | Dog] = "CatDog"; + Animals[Animals["CatDog"] = 3] = "CatDog"; })(Animals || (Animals = {})); diff --git a/crates/swc/tests/tsc-references/enumExportMergingES6.2.minified.js b/crates/swc/tests/tsc-references/enumExportMergingES6.2.minified.js index 75a9cbaf14d04..48cd6fdf95e92 100644 --- a/crates/swc/tests/tsc-references/enumExportMergingES6.2.minified.js +++ b/crates/swc/tests/tsc-references/enumExportMergingES6.2.minified.js @@ -2,4 +2,4 @@ var Animals, Animals1, Animals2; var Animals3; export { Animals3 as Animals }; -(Animals = Animals3 || (Animals3 = {}))[Animals.Cat = 1] = "Cat", (Animals1 = Animals3 || (Animals3 = {}))[Animals1.Dog = 2] = "Dog", (Animals2 = Animals3 || (Animals3 = {}))[Animals2.CatDog = Cat | Dog] = "CatDog"; +(Animals = Animals3 || (Animals3 = {}))[Animals.Cat = 1] = "Cat", (Animals1 = Animals3 || (Animals3 = {}))[Animals1.Dog = 2] = "Dog", (Animals2 = Animals3 || (Animals3 = {}))[Animals2.CatDog = 3] = "CatDog"; diff --git a/crates/swc/tests/tsc-references/enumIsNotASubtypeOfAnythingButNumber.1.normal.js b/crates/swc/tests/tsc-references/enumIsNotASubtypeOfAnythingButNumber.1.normal.js index cbf234dbd8221..5a8dc1826c095 100644 --- a/crates/swc/tests/tsc-references/enumIsNotASubtypeOfAnythingButNumber.1.normal.js +++ b/crates/swc/tests/tsc-references/enumIsNotASubtypeOfAnythingButNumber.1.normal.js @@ -19,12 +19,30 @@ var E2; })(E2 || (E2 = {})); function f() {} (function(f) { - var bar = f.bar = 1; + var bar = 1; + Object.defineProperty(f, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(f || (f = {})); var c = function c() { "use strict"; _class_call_check(this, c); }; (function(c) { - var bar = c.bar = 1; + var bar = 1; + Object.defineProperty(c, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(c || (c = {})); diff --git a/crates/swc/tests/tsc-references/enumIsNotASubtypeOfAnythingButNumber.2.minified.js b/crates/swc/tests/tsc-references/enumIsNotASubtypeOfAnythingButNumber.2.minified.js index 5b2ad53053a0d..3d4da013d6497 100644 --- a/crates/swc/tests/tsc-references/enumIsNotASubtypeOfAnythingButNumber.2.minified.js +++ b/crates/swc/tests/tsc-references/enumIsNotASubtypeOfAnythingButNumber.2.minified.js @@ -2,8 +2,24 @@ // enums are only subtypes of number, any and no other types import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; function f() {} -(E = E1 || (E1 = {}))[E.A = 0] = "A", (E2 = E21 || (E21 = {}))[E2.A = 0] = "A", (f || (f = {})).bar = 1; -var E, E2, E1, E21, c = function c() { +(E = E1 || (E1 = {}))[E.A = 0] = "A", (E2 = E21 || (E21 = {}))[E2.A = 0] = "A", f1 = f || (f = {}), bar1 = 1, Object.defineProperty(f1, "bar", { + enumerable: !0, + get: function() { + return bar1; + }, + set: function(v) { + bar1 = v; + } +}); +var c, bar, E, E2, f1, bar1, E1, E21, c1 = function c() { _class_call_check(this, c); }; -(c || (c = {})).bar = 1; +c = c1 || (c1 = {}), bar = 1, Object.defineProperty(c, "bar", { + enumerable: !0, + get: function() { + return bar; + }, + set: function(v) { + bar = v; + } +}); diff --git a/crates/swc/tests/tsc-references/enumLiteralTypes1.1.normal.js b/crates/swc/tests/tsc-references/enumLiteralTypes1.1.normal.js index db20e68e2ef19..38d0fc858d428 100644 --- a/crates/swc/tests/tsc-references/enumLiteralTypes1.1.normal.js +++ b/crates/swc/tests/tsc-references/enumLiteralTypes1.1.normal.js @@ -1,10 +1,5 @@ //// [enumLiteralTypes1.ts] var Choice; -(function(Choice) { - Choice[Choice["Unknown"] = 0] = "Unknown"; - Choice[Choice["Yes"] = 1] = "Yes"; - Choice[Choice["No"] = 2] = "No"; -})(Choice || (Choice = {})); function f1() { var a; var a; diff --git a/crates/swc/tests/tsc-references/enumLiteralTypes1.2.minified.js b/crates/swc/tests/tsc-references/enumLiteralTypes1.2.minified.js index 681f8c6ace674..c246968d8d4e9 100644 --- a/crates/swc/tests/tsc-references/enumLiteralTypes1.2.minified.js +++ b/crates/swc/tests/tsc-references/enumLiteralTypes1.2.minified.js @@ -1,3 +1 @@ //// [enumLiteralTypes1.ts] -var Choice, Choice1; -(Choice1 = Choice || (Choice = {}))[Choice1.Unknown = 0] = "Unknown", Choice1[Choice1.Yes = 1] = "Yes", Choice1[Choice1.No = 2] = "No"; diff --git a/crates/swc/tests/tsc-references/enumLiteralTypes2.1.normal.js b/crates/swc/tests/tsc-references/enumLiteralTypes2.1.normal.js index fd03a48baf9b2..d8f691275bac6 100644 --- a/crates/swc/tests/tsc-references/enumLiteralTypes2.1.normal.js +++ b/crates/swc/tests/tsc-references/enumLiteralTypes2.1.normal.js @@ -1,10 +1,5 @@ //// [enumLiteralTypes2.ts] var Choice; -(function(Choice) { - Choice[Choice["Unknown"] = 0] = "Unknown"; - Choice[Choice["Yes"] = 1] = "Yes"; - Choice[Choice["No"] = 2] = "No"; -})(Choice || (Choice = {})); function f1() { var a; var a; diff --git a/crates/swc/tests/tsc-references/enumLiteralTypes2.2.minified.js b/crates/swc/tests/tsc-references/enumLiteralTypes2.2.minified.js index df389ab0d2b77..e777af65094d2 100644 --- a/crates/swc/tests/tsc-references/enumLiteralTypes2.2.minified.js +++ b/crates/swc/tests/tsc-references/enumLiteralTypes2.2.minified.js @@ -1,3 +1 @@ //// [enumLiteralTypes2.ts] -var Choice, Choice1; -(Choice1 = Choice || (Choice = {}))[Choice1.Unknown = 0] = "Unknown", Choice1[Choice1.Yes = 1] = "Yes", Choice1[Choice1.No = 2] = "No"; diff --git a/crates/swc/tests/tsc-references/enumLiteralTypes3.1.normal.js b/crates/swc/tests/tsc-references/enumLiteralTypes3.1.normal.js index 7e150e96fdbd1..c7606641f8403 100644 --- a/crates/swc/tests/tsc-references/enumLiteralTypes3.1.normal.js +++ b/crates/swc/tests/tsc-references/enumLiteralTypes3.1.normal.js @@ -1,10 +1,5 @@ //// [enumLiteralTypes3.ts] var Choice; -(function(Choice) { - Choice[Choice["Unknown"] = 0] = "Unknown"; - Choice[Choice["Yes"] = 1] = "Yes"; - Choice[Choice["No"] = 2] = "No"; -})(Choice || (Choice = {})); function f1(a, b, c, d) { a = a; a = b; diff --git a/crates/swc/tests/tsc-references/enumLiteralTypes3.2.minified.js b/crates/swc/tests/tsc-references/enumLiteralTypes3.2.minified.js index efea6c87b812a..30acba432428f 100644 --- a/crates/swc/tests/tsc-references/enumLiteralTypes3.2.minified.js +++ b/crates/swc/tests/tsc-references/enumLiteralTypes3.2.minified.js @@ -1,3 +1 @@ //// [enumLiteralTypes3.ts] -var Choice, Choice1; -(Choice1 = Choice || (Choice = {}))[Choice1.Unknown = 0] = "Unknown", Choice1[Choice1.Yes = 1] = "Yes", Choice1[Choice1.No = 2] = "No"; diff --git a/crates/swc/tests/tsc-references/enumMerging.1.normal.js b/crates/swc/tests/tsc-references/enumMerging.1.normal.js index 4a9350646aca9..5339ebd375e5e 100644 --- a/crates/swc/tests/tsc-references/enumMerging.1.normal.js +++ b/crates/swc/tests/tsc-references/enumMerging.1.normal.js @@ -26,16 +26,16 @@ var M1; EConst1[EConst1["F"] = 8] = "F"; })(EConst1 = M1.EConst1 || (M1.EConst1 = {})); var x = [ - EConst1.A, - EConst1.B, - EConst1.C, - EConst1.D, - EConst1.E, - EConst1.F + 3, + 2, + 1, + 7, + 9, + 8 ]; })(M1 || (M1 = {})); -// Enum with only computed members across 2 declarations with the same root module var M2; +// Enum with only computed members across 2 declarations with the same root module (function(M2) { var EComp2; (function(EComp2) { @@ -57,8 +57,8 @@ var M2; EComp2.F ]; })(M2 || (M2 = {})); -// Enum with initializer in only one of two declarations with constant members with the same root module var M3; +// Enum with initializer in only one of two declarations with constant members with the same root module (function(M3) { var EInit; (function(EInit) { @@ -71,8 +71,8 @@ var M3; EInit[EInit["E"] = 3] = "E"; })(EInit || (EInit = {})); })(M3 || (M3 = {})); -// Enums with same name but different root module var M4; +// Enums with same name but different root module (function(M4) { var Color; (function(Color) { @@ -92,7 +92,6 @@ var M5; })(M5 || (M5 = {})); var M6; (function(M6) { - var A; (function(A) { var Color; (function(Color) { @@ -100,7 +99,7 @@ var M6; Color[Color["Green"] = 1] = "Green"; Color[Color["Blue"] = 2] = "Blue"; })(Color = A.Color || (A.Color = {})); - })(A = M6.A || (M6.A = {})); + })(M6.A || (M6.A = {})); })(M6 || (M6 = {})); (function(M6) { var A; diff --git a/crates/swc/tests/tsc-references/enumMerging.2.minified.js b/crates/swc/tests/tsc-references/enumMerging.2.minified.js index ba9145868e646..ecf70a72ce896 100644 --- a/crates/swc/tests/tsc-references/enumMerging.2.minified.js +++ b/crates/swc/tests/tsc-references/enumMerging.2.minified.js @@ -1,5 +1,5 @@ //// [enumMerging.ts] // Enum with only constant members across 2 declarations with the same root module // Enum with initializer in all declarations with constant members with the same root module -var M1, M2, M3, M4, M5, M6, M11, EImpl1, EConst1, EImpl11, EImpl12, EConst11, EConst12, M21, EComp2, EComp21, EComp22, EInit, EInit1, EInit2, M41, Color, M51, Color1, M61, A, Color2, M62, A1, Color3, A2; -M11 = M1 || (M1 = {}), (EImpl11 = EImpl1 || (EImpl1 = {}))[EImpl11.A = 0] = "A", EImpl11[EImpl11.B = 1] = "B", EImpl11[EImpl11.C = 2] = "C", (EImpl12 = EImpl1 || (EImpl1 = {}))[EImpl12.D = 1] = "D", EImpl12[EImpl12.E = 2] = "E", EImpl12[EImpl12.F = 3] = "F", (EConst11 = EConst1 = M11.EConst1 || (M11.EConst1 = {}))[EConst11.A = 3] = "A", EConst11[EConst11.B = 2] = "B", EConst11[EConst11.C = 1] = "C", (EConst12 = EConst1 = M11.EConst1 || (M11.EConst1 = {}))[EConst12.D = 7] = "D", EConst12[EConst12.E = 9] = "E", EConst12[EConst12.F = 8] = "F", EConst1.A, EConst1.B, EConst1.C, EConst1.D, EConst1.E, EConst1.F, (EComp21 = EComp2 = (M21 = M2 || (M2 = {})).EComp2 || (M21.EComp2 = {}))[EComp21.A = 3] = "A", EComp21[EComp21.B = 3] = "B", EComp21[EComp21.C = 3] = "C", (EComp22 = EComp2 = M21.EComp2 || (M21.EComp2 = {}))[EComp22.D = 3] = "D", EComp22[EComp22.E = 3] = "E", EComp22[EComp22.F = 3] = "F", EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F, M3 || (M3 = {}), (EInit1 = EInit || (EInit = {}))[EInit1.A = 0] = "A", EInit1[EInit1.B = 1] = "B", (EInit2 = EInit || (EInit = {}))[EInit2.C = 1] = "C", EInit2[EInit2.D = 2] = "D", EInit2[EInit2.E = 3] = "E", (Color = (M41 = M4 || (M4 = {})).Color || (M41.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue", (Color1 = (M51 = M5 || (M5 = {})).Color || (M51.Color = {}))[Color1.Red = 0] = "Red", Color1[Color1.Green = 1] = "Green", Color1[Color1.Blue = 2] = "Blue", (Color2 = (A = (M61 = M6 || (M6 = {})).A || (M61.A = {})).Color || (A.Color = {}))[Color2.Red = 0] = "Red", Color2[Color2.Green = 1] = "Green", Color2[Color2.Blue = 2] = "Blue", (Color3 = (A1 = A2 = (M62 = M6 || (M6 = {})).A || (M62.A = {})).Color || (A1.Color = {}))[Color3.Yellow = 1] = "Yellow", A2.Color.Yellow, A2.Color.Red; +var M1, M2, M3, M4, M5, M6, M11, EImpl1, EImpl11, EImpl12, EConst1, EConst11, M21, EComp2, EComp21, EComp22, EInit, EInit1, EInit2, M41, Color, M51, Color1, M61, A, Color2, M62, A1, Color3, A2; +M11 = M1 || (M1 = {}), (EImpl11 = EImpl1 || (EImpl1 = {}))[EImpl11.A = 0] = "A", EImpl11[EImpl11.B = 1] = "B", EImpl11[EImpl11.C = 2] = "C", (EImpl12 = EImpl1 || (EImpl1 = {}))[EImpl12.D = 1] = "D", EImpl12[EImpl12.E = 2] = "E", EImpl12[EImpl12.F = 3] = "F", (EConst1 = M11.EConst1 || (M11.EConst1 = {}))[EConst1.A = 3] = "A", EConst1[EConst1.B = 2] = "B", EConst1[EConst1.C = 1] = "C", (EConst11 = M11.EConst1 || (M11.EConst1 = {}))[EConst11.D = 7] = "D", EConst11[EConst11.E = 9] = "E", EConst11[EConst11.F = 8] = "F", (EComp21 = EComp2 = (M21 = M2 || (M2 = {})).EComp2 || (M21.EComp2 = {}))[EComp21.A = 3] = "A", EComp21[EComp21.B = 3] = "B", EComp21[EComp21.C = 3] = "C", (EComp22 = EComp2 = M21.EComp2 || (M21.EComp2 = {}))[EComp22.D = 3] = "D", EComp22[EComp22.E = 3] = "E", EComp22[EComp22.F = 3] = "F", EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F, M3 || (M3 = {}), (EInit1 = EInit || (EInit = {}))[EInit1.A = 0] = "A", EInit1[EInit1.B = 1] = "B", (EInit2 = EInit || (EInit = {}))[EInit2.C = 1] = "C", EInit2[EInit2.D = 2] = "D", EInit2[EInit2.E = 3] = "E", (Color = (M41 = M4 || (M4 = {})).Color || (M41.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue", (Color1 = (M51 = M5 || (M5 = {})).Color || (M51.Color = {}))[Color1.Red = 0] = "Red", Color1[Color1.Green = 1] = "Green", Color1[Color1.Blue = 2] = "Blue", (Color2 = (A = (M61 = M6 || (M6 = {})).A || (M61.A = {})).Color || (A.Color = {}))[Color2.Red = 0] = "Red", Color2[Color2.Green = 1] = "Green", Color2[Color2.Blue = 2] = "Blue", (Color3 = (A1 = A2 = (M62 = M6 || (M6 = {})).A || (M62.A = {})).Color || (A1.Color = {}))[Color3.Yellow = 1] = "Yellow", A2.Color.Yellow, A2.Color.Red; diff --git a/crates/swc/tests/tsc-references/enumMergingErrors.1.normal.js b/crates/swc/tests/tsc-references/enumMergingErrors.1.normal.js index b5fa55f0f6595..b1db4f8dd36a6 100644 --- a/crates/swc/tests/tsc-references/enumMergingErrors.1.normal.js +++ b/crates/swc/tests/tsc-references/enumMergingErrors.1.normal.js @@ -43,8 +43,8 @@ var M; E3[E3["B"] = "foo".length] = "B"; })(E3 = M.E3 || (M.E3 = {})); })(M || (M = {})); -// Enum with no initializer in either declaration with constant members with the same root module var M1; +// Enum with no initializer in either declaration with constant members with the same root module (function(M1) { var E1; (function(E1) { @@ -63,8 +63,8 @@ var M1; E1[E1["C"] = 0] = "C"; })(E1 = M1.E1 || (M1.E1 = {})); })(M1 || (M1 = {})); -// Enum with initializer in only one of three declarations with constant members with the same root module var M2; +// Enum with initializer in only one of three declarations with constant members with the same root module (function(M2) { var E1; (function(E1) { diff --git a/crates/swc/tests/tsc-references/enums.1.normal.js b/crates/swc/tests/tsc-references/enums.1.normal.js index 1fdb0cc491b24..cd3b1119ad5f4 100644 --- a/crates/swc/tests/tsc-references/enums.1.normal.js +++ b/crates/swc/tests/tsc-references/enums.1.normal.js @@ -5,10 +5,6 @@ var SyntaxKind; SyntaxKind[SyntaxKind["ExportDeclaration"] = 1] = "ExportDeclaration"; })(SyntaxKind || (SyntaxKind = {})); var SymbolFlags; -(function(SymbolFlags) { - SymbolFlags["Type"] = "Type"; - SymbolFlags["Value"] = "Value"; -})(SymbolFlags || (SymbolFlags = {})); export { SymbolFlags }; //// [/b.ts] SyntaxKind.ImportClause; diff --git a/crates/swc/tests/tsc-references/enums.2.minified.js b/crates/swc/tests/tsc-references/enums.2.minified.js index e1549c0615041..74d1175477ea0 100644 --- a/crates/swc/tests/tsc-references/enums.2.minified.js +++ b/crates/swc/tests/tsc-references/enums.2.minified.js @@ -1,6 +1,6 @@ //// [/a.ts] -var SyntaxKind, SymbolFlags, SyntaxKind1, SymbolFlags1; -(SyntaxKind1 = SyntaxKind || (SyntaxKind = {}))[SyntaxKind1.ImportClause = 0] = "ImportClause", SyntaxKind1[SyntaxKind1.ExportDeclaration = 1] = "ExportDeclaration", (SymbolFlags1 = SymbolFlags || (SymbolFlags = {})).Type = "Type", SymbolFlags1.Value = "Value"; +var SyntaxKind, SymbolFlags, SyntaxKind1; +(SyntaxKind1 = SyntaxKind || (SyntaxKind = {}))[SyntaxKind1.ImportClause = 0] = "ImportClause", SyntaxKind1[SyntaxKind1.ExportDeclaration = 1] = "ExportDeclaration"; export { SymbolFlags }; //// [/b.ts] SyntaxKind.ImportClause, SymbolFlags.Type; diff --git a/crates/swc/tests/tsc-references/equalityWithEnumTypes.1.normal.js b/crates/swc/tests/tsc-references/equalityWithEnumTypes.1.normal.js index 2759ebd545bd8..61817baced749 100644 --- a/crates/swc/tests/tsc-references/equalityWithEnumTypes.1.normal.js +++ b/crates/swc/tests/tsc-references/equalityWithEnumTypes.1.normal.js @@ -5,8 +5,8 @@ var E1; E1[E1["a"] = 1] = "a"; E1[E1["b"] = 2] = "b"; })(E1 || (E1 = {})); -var // Numeric enum type -E2; +var E2; +// Numeric enum type (function(E2) { E2[E2["a"] = 1] = "a"; E2[E2["b"] = 2] = "b"; diff --git a/crates/swc/tests/tsc-references/equalityWithEnumTypes.2.minified.js b/crates/swc/tests/tsc-references/equalityWithEnumTypes.2.minified.js index 7670524d2807c..bfae7af178a66 100644 --- a/crates/swc/tests/tsc-references/equalityWithEnumTypes.2.minified.js +++ b/crates/swc/tests/tsc-references/equalityWithEnumTypes.2.minified.js @@ -1,5 +1,4 @@ //// [equalityWithEnumTypes.ts] // Literal enum type -var E1, // Numeric enum type -E2, E11, E21; +var E1, E2, E11, E21; (E11 = E1 || (E1 = {}))[E11.a = 1] = "a", E11[E11.b = 2] = "b", (E21 = E2 || (E2 = {}))[E21.a = 1] = "a", E21[E21.b = 2] = "b"; diff --git a/crates/swc/tests/tsc-references/es6modulekindWithES5Target10.1.normal.js b/crates/swc/tests/tsc-references/es6modulekindWithES5Target10.1.normal.js index 121551c299511..63db7842b1c0a 100644 --- a/crates/swc/tests/tsc-references/es6modulekindWithES5Target10.1.normal.js +++ b/crates/swc/tests/tsc-references/es6modulekindWithES5Target10.1.normal.js @@ -1,15 +1,5 @@ //// [es6modulekindWithES5Target10.ts] //! -//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. -//! ,-[1:1] -//! 1 | -//! 2 | import i = require("mod"); // Error; -//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^ -//! 3 | -//! 4 | -//! 5 | namespace N { -//! `---- -//! //! x Export assignment cannot be used when targeting ECMAScript modules. Consider using `export default` or another module format instead. //! ,-[4:1] //! 4 | diff --git a/crates/swc/tests/tsc-references/es6modulekindWithES5Target10.2.minified.js b/crates/swc/tests/tsc-references/es6modulekindWithES5Target10.2.minified.js index 121551c299511..63db7842b1c0a 100644 --- a/crates/swc/tests/tsc-references/es6modulekindWithES5Target10.2.minified.js +++ b/crates/swc/tests/tsc-references/es6modulekindWithES5Target10.2.minified.js @@ -1,15 +1,5 @@ //// [es6modulekindWithES5Target10.ts] //! -//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. -//! ,-[1:1] -//! 1 | -//! 2 | import i = require("mod"); // Error; -//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^ -//! 3 | -//! 4 | -//! 5 | namespace N { -//! `---- -//! //! x Export assignment cannot be used when targeting ECMAScript modules. Consider using `export default` or another module format instead. //! ,-[4:1] //! 4 | diff --git a/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target10.1.normal.js b/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target10.1.normal.js index 5f056487f5b75..401f1655f8cfb 100644 --- a/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target10.1.normal.js +++ b/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target10.1.normal.js @@ -1,15 +1,5 @@ //// [esnextmodulekindWithES5Target10.ts] //! -//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. -//! ,-[1:1] -//! 1 | -//! 2 | import i = require("mod"); // Error; -//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^ -//! 3 | -//! 4 | -//! 5 | namespace N { -//! `---- -//! //! x Export assignment cannot be used when targeting ECMAScript modules. Consider using `export default` or another module format instead. //! ,-[4:1] //! 4 | diff --git a/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target10.2.minified.js b/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target10.2.minified.js index 5f056487f5b75..401f1655f8cfb 100644 --- a/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target10.2.minified.js +++ b/crates/swc/tests/tsc-references/esnextmodulekindWithES5Target10.2.minified.js @@ -1,15 +1,5 @@ //// [esnextmodulekindWithES5Target10.ts] //! -//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. -//! ,-[1:1] -//! 1 | -//! 2 | import i = require("mod"); // Error; -//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^ -//! 3 | -//! 4 | -//! 5 | namespace N { -//! `---- -//! //! x Export assignment cannot be used when targeting ECMAScript modules. Consider using `export default` or another module format instead. //! ,-[4:1] //! 4 | diff --git a/crates/swc/tests/tsc-references/exhaustiveSwitchStatements1.1.normal.js b/crates/swc/tests/tsc-references/exhaustiveSwitchStatements1.1.normal.js index 64561f2a239f2..a3f9cc7368985 100644 --- a/crates/swc/tests/tsc-references/exhaustiveSwitchStatements1.1.normal.js +++ b/crates/swc/tests/tsc-references/exhaustiveSwitchStatements1.1.normal.js @@ -35,26 +35,26 @@ function f3(x) { throw new Error("Bad input"); } } -var // Repro from #11572 -E; +var E; +// Repro from #11572 (function(E) { E[E["A"] = 0] = "A"; E[E["B"] = 1] = "B"; })(E || (E = {})); function f(e) { switch(e){ - case E.A: + case 0: return 0; - case E.B: + case 1: return 1; } } function g(e) { if (!true) return -1; else switch(e){ - case E.A: + case 0: return 0; - case E.B: + case 1: return 1; } } @@ -92,8 +92,8 @@ function areaWrapped(s) { }(); return area; } -var // Repro from #13241 -MyEnum; +var MyEnum; +// Repro from #13241 (function(MyEnum) { MyEnum[MyEnum["A"] = 0] = "A"; MyEnum[MyEnum["B"] = 1] = "B"; @@ -101,10 +101,10 @@ MyEnum; function thisGivesError(e) { var s; switch(e){ - case MyEnum.A: + case 0: s = "it was A"; break; - case MyEnum.B: + case 1: s = "it was B"; break; } @@ -113,10 +113,10 @@ function thisGivesError(e) { function good1(e) { var s; switch(e){ - case MyEnum.A: + case 0: s = "it was A"; break; - case MyEnum.B: + case 1: s = "it was B"; break; default: @@ -127,14 +127,14 @@ function good1(e) { } function good2(e) { switch(e){ - case MyEnum.A: + case 0: return "it was A"; - case MyEnum.B: + case 1: return "it was B"; } } -var // Repro from #18362 -Level; +var Level; +// Repro from #18362 (function(Level) { Level[Level["One"] = 0] = "One"; Level[Level["Two"] = 1] = "Two"; @@ -142,11 +142,11 @@ Level; var doSomethingWithLevel = function(level) { var next; switch(level){ - case Level.One: - next = Level.Two; + case 0: + next = 1; break; - case Level.Two: - next = Level.One; + case 1: + next = 0; break; } return next; @@ -192,8 +192,8 @@ function test4(value) { } return x; } -var // Repro from #34661 -Animal; +var Animal; +// Repro from #34661 (function(Animal) { Animal[Animal["DOG"] = 0] = "DOG"; Animal[Animal["CAT"] = 1] = "CAT"; @@ -201,11 +201,11 @@ Animal; function expression() { var _zoo; var _zoo_animal; - switch((_zoo_animal = (_zoo = zoo) === null || _zoo === void 0 ? void 0 : _zoo.animal) !== null && _zoo_animal !== void 0 ? _zoo_animal : Animal.DOG){ - case Animal.DOG: - return Animal.DOG; - case Animal.CAT: - return Animal.CAT; + switch((_zoo_animal = (_zoo = zoo) === null || _zoo === void 0 ? void 0 : _zoo.animal) !== null && _zoo_animal !== void 0 ? _zoo_animal : 0){ + case 0: + return 0; + case 1: + return 1; } } // Repro from #34840 diff --git a/crates/swc/tests/tsc-references/exhaustiveSwitchStatements1.2.minified.js b/crates/swc/tests/tsc-references/exhaustiveSwitchStatements1.2.minified.js index 10f979bbbe481..b64d0c2ef2206 100644 --- a/crates/swc/tests/tsc-references/exhaustiveSwitchStatements1.2.minified.js +++ b/crates/swc/tests/tsc-references/exhaustiveSwitchStatements1.2.minified.js @@ -1,7 +1,3 @@ //// [exhaustiveSwitchStatements1.ts] -var // Repro from #11572 -E, // Repro from #13241 -MyEnum, // Repro from #18362 -Level, // Repro from #34661 -Animal, E1, MyEnum1, Level1, Animal1; +var E, MyEnum, Level, Animal, E1, MyEnum1, Level1, Animal1; (E1 = E || (E = {}))[E1.A = 0] = "A", E1[E1.B = 1] = "B", (MyEnum1 = MyEnum || (MyEnum = {}))[MyEnum1.A = 0] = "A", MyEnum1[MyEnum1.B = 1] = "B", (Level1 = Level || (Level = {}))[Level1.One = 0] = "One", Level1[Level1.Two = 1] = "Two", (Animal1 = Animal || (Animal = {}))[Animal1.DOG = 0] = "DOG", Animal1[Animal1.CAT = 1] = "CAT"; diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum.1.normal.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum.1.normal.js index 8f44259b06c86..c3827e401e4ba 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum.1.normal.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum.1.normal.js @@ -14,10 +14,10 @@ var r2 = Math.pow(c, b); var r3 = Math.pow(c, c); var r4 = Math.pow(a, c); var r5 = Math.pow(b, c); -var r6 = Math.pow(E.a, a); -var r7 = Math.pow(E.a, b); -var r8 = Math.pow(E.a, E.b); -var r9 = Math.pow(E.a, 1); -var r10 = Math.pow(a, E.b); -var r11 = Math.pow(b, E.b); -var r12 = Math.pow(1, E.b); +var r6 = Math.pow(0, a); +var r7 = Math.pow(0, b); +var r8 = Math.pow(0, 1); +var r9 = Math.pow(0, 1); +var r10 = Math.pow(a, 1); +var r11 = Math.pow(b, 1); +var r12 = Math.pow(1, 1); diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum.2.minified.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum.2.minified.js index 57357dec64bf1..4f97ebbc90e37 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum.2.minified.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum.2.minified.js @@ -1,4 +1,4 @@ //// [exponentiationOperatorWithEnum.ts] // operands of an enum type are treated as having the primitive type Number. var E, E1; -(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b; +(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b"; diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion.1.normal.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion.1.normal.js index d022489a5d1c1..f73c6930f54e7 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion.1.normal.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion.1.normal.js @@ -19,10 +19,10 @@ var r2 = Math.pow(c, b); var r3 = Math.pow(c, c); var r4 = Math.pow(a, c); var r5 = Math.pow(b, c); -var r6 = Math.pow(E.a, a); -var r7 = Math.pow(E.a, b); -var r8 = Math.pow(E.a, E.b); -var r9 = Math.pow(E.a, 1); -var r10 = Math.pow(a, E.b); -var r11 = Math.pow(b, E.b); -var r12 = Math.pow(1, E.b); +var r6 = Math.pow(0, a); +var r7 = Math.pow(0, b); +var r8 = Math.pow(0, 1); +var r9 = Math.pow(0, 1); +var r10 = Math.pow(a, 1); +var r11 = Math.pow(b, 1); +var r12 = Math.pow(1, 1); diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion.2.minified.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion.2.minified.js index 516b546291139..72a3dff04c5f3 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion.2.minified.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion.2.minified.js @@ -1,4 +1,4 @@ //// [exponentiationOperatorWithEnumUnion.ts] // operands of an enum type are treated as having the primitive type Number. var E, F, E1, F1; -(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", (F1 = F || (F = {}))[F1.c = 0] = "c", F1[F1.d = 1] = "d", E.a, E.a, E.a, E.b, E.a, E.b, E.b, E.b; +(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", (F1 = F || (F = {}))[F1.c = 0] = "c", F1[F1.d = 1] = "d"; diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands.1.normal.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands.1.normal.js index ebdaef42a9caa..453680ebcf447 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands.1.normal.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands.1.normal.js @@ -51,15 +51,15 @@ var r1f3 = Math.pow(f, c); var r1f4 = Math.pow(f, d); var r1f5 = Math.pow(f, e); var r1f6 = Math.pow(f, f); -var r1g1 = Math.pow(E.a, a); //ok -var r1g2 = Math.pow(E.a, b); -var r1g3 = Math.pow(E.a, c); //ok -var r1g4 = Math.pow(E.a, d); -var r1g5 = Math.pow(E.a, e); -var r1g6 = Math.pow(E.a, f); -var r1h1 = Math.pow(a, E.b); //ok -var r1h2 = Math.pow(b, E.b); -var r1h3 = Math.pow(c, E.b); //ok -var r1h4 = Math.pow(d, E.b); -var r1h5 = Math.pow(e, E.b); -var r1h6 = Math.pow(f, E.b); +var r1g1 = Math.pow(0, a); //ok +var r1g2 = Math.pow(0, b); +var r1g3 = Math.pow(0, c); //ok +var r1g4 = Math.pow(0, d); +var r1g5 = Math.pow(0, e); +var r1g6 = Math.pow(0, f); +var r1h1 = Math.pow(a, 1); //ok +var r1h2 = Math.pow(b, 1); +var r1h3 = Math.pow(c, 1); //ok +var r1h4 = Math.pow(d, 1); +var r1h5 = Math.pow(e, 1); +var r1h6 = Math.pow(f, 1); diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands.2.minified.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands.2.minified.js index 7e3d878f8a81a..f2cba40a48ca4 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands.2.minified.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands.2.minified.js @@ -2,4 +2,4 @@ // these operators require their operands to be of type Any, the Number primitive type, or // an enum type var E, E1; -(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E1[E1.c = 2] = "c", E.a, E.a, E.a, E.a, E.a, E.a, E.b, E.b, E.b, E.b, E.b, E.b; +(E1 = E || (E = {}))[E1.a = 0] = "a", E1[E1.b = 1] = "b", E1[E1.c = 2] = "c"; diff --git a/crates/swc/tests/tsc-references/exportAssignmentCircularModules.1.normal.js b/crates/swc/tests/tsc-references/exportAssignmentCircularModules.1.normal.js index f4235623b22a6..70c831b2c081c 100644 --- a/crates/swc/tests/tsc-references/exportAssignmentCircularModules.1.normal.js +++ b/crates/swc/tests/tsc-references/exportAssignmentCircularModules.1.normal.js @@ -6,7 +6,16 @@ define([ "use strict"; var Foo; (function(Foo) { - var x = Foo.x = _foo_1.x; + var x = _foo_1.x; + Object.defineProperty(Foo, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(Foo || (Foo = {})); return Foo; }); @@ -18,7 +27,16 @@ define([ "use strict"; var Foo; (function(Foo) { - var x = Foo.x = _foo_2.x; + var x = _foo_2.x; + Object.defineProperty(Foo, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(Foo || (Foo = {})); return Foo; }); @@ -30,7 +48,16 @@ define([ "use strict"; var Foo; (function(Foo) { - var x = Foo.x = _foo_0.x; + var x = _foo_0.x; + Object.defineProperty(Foo, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(Foo || (Foo = {})); return Foo; }); diff --git a/crates/swc/tests/tsc-references/exportAssignmentCircularModules.2.minified.js b/crates/swc/tests/tsc-references/exportAssignmentCircularModules.2.minified.js index e8dfa47d707cb..ee28f8dc393f8 100644 --- a/crates/swc/tests/tsc-references/exportAssignmentCircularModules.2.minified.js +++ b/crates/swc/tests/tsc-references/exportAssignmentCircularModules.2.minified.js @@ -3,22 +3,46 @@ define([ "require", "./foo_1" ], function(require, _foo_1) { - var Foo; - return (Foo || (Foo = {})).x = _foo_1.x, Foo; + var Foo, Foo1, x; + return Foo1 = Foo || (Foo = {}), x = _foo_1.x, Object.defineProperty(Foo1, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } + }), Foo; }); //// [foo_1.ts] define([ "require", "./foo_2" ], function(require, _foo_2) { - var Foo; - return (Foo || (Foo = {})).x = _foo_2.x, Foo; + var Foo, Foo1, x; + return Foo1 = Foo || (Foo = {}), x = _foo_2.x, Object.defineProperty(Foo1, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } + }), Foo; }); //// [foo_2.ts] define([ "require", "./foo_0" ], function(require, _foo_0) { - var Foo; - return (Foo || (Foo = {})).x = _foo_0.x, Foo; + var Foo, Foo1, x; + return Foo1 = Foo || (Foo = {}), x = _foo_0.x, Object.defineProperty(Foo1, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } + }), Foo; }); diff --git a/crates/swc/tests/tsc-references/exportAssignmentMergedInterface.1.normal.js b/crates/swc/tests/tsc-references/exportAssignmentMergedInterface.1.normal.js index 859bc8d3c6c69..2a1b45f54cd18 100644 --- a/crates/swc/tests/tsc-references/exportAssignmentMergedInterface.1.normal.js +++ b/crates/swc/tests/tsc-references/exportAssignmentMergedInterface.1.normal.js @@ -8,9 +8,8 @@ define([ //// [foo_1.ts] define([ "require", - "exports", - "./foo_0" -], function(require, exports, _foo_0) { + "exports" +], function(require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true diff --git a/crates/swc/tests/tsc-references/exportAssignmentMergedInterface.2.minified.js b/crates/swc/tests/tsc-references/exportAssignmentMergedInterface.2.minified.js index c17789bce975d..d1a767750f24d 100644 --- a/crates/swc/tests/tsc-references/exportAssignmentMergedInterface.2.minified.js +++ b/crates/swc/tests/tsc-references/exportAssignmentMergedInterface.2.minified.js @@ -7,9 +7,8 @@ define([ //// [foo_1.ts] define([ "require", - "exports", - "./foo_0" -], function(require, exports, _foo_0) { + "exports" +], function(require, exports) { var x; Object.defineProperty(exports, "__esModule", { value: !0 diff --git a/crates/swc/tests/tsc-references/exportAssignmentMergedModule.1.normal.js b/crates/swc/tests/tsc-references/exportAssignmentMergedModule.1.normal.js index 0ebf4525c66dd..0e9e52037b6b5 100644 --- a/crates/swc/tests/tsc-references/exportAssignmentMergedModule.1.normal.js +++ b/crates/swc/tests/tsc-references/exportAssignmentMergedModule.1.normal.js @@ -6,7 +6,16 @@ var Foo; return 5; }; Foo.a = a; - var b = Foo.b = true; + var b = true; + Object.defineProperty(Foo, "b", { + enumerable: true, + get: function get() { + return b; + }, + set: function set(v) { + b = v; + } + }); })(Foo || (Foo = {})); (function(Foo) { var c = function c(a) { @@ -15,7 +24,16 @@ var Foo; Foo.c = c; var Test; (function(Test) { - var answer = Test.answer = 42; + var answer = 42; + Object.defineProperty(Test, "answer", { + enumerable: true, + get: function get() { + return answer; + }, + set: function set(v) { + answer = v; + } + }); })(Test = Foo.Test || (Foo.Test = {})); })(Foo || (Foo = {})); module.exports = Foo; diff --git a/crates/swc/tests/tsc-references/exportAssignmentMergedModule.2.minified.js b/crates/swc/tests/tsc-references/exportAssignmentMergedModule.2.minified.js index 02eba927fbb59..1fa437ead7dd7 100644 --- a/crates/swc/tests/tsc-references/exportAssignmentMergedModule.2.minified.js +++ b/crates/swc/tests/tsc-references/exportAssignmentMergedModule.2.minified.js @@ -1,10 +1,26 @@ //// [foo_0.ts] -var Foo, Foo1, Foo2; +var Foo, Foo1, b, Foo2, Test, answer; (Foo1 = Foo || (Foo = {})).a = function() { return 5; -}, Foo1.b = !0, (Foo2 = Foo || (Foo = {})).c = function(a) { +}, b = !0, Object.defineProperty(Foo1, "b", { + enumerable: !0, + get: function() { + return b; + }, + set: function(v) { + b = v; + } +}), (Foo2 = Foo || (Foo = {})).c = function(a) { return a; -}, (Foo2.Test || (Foo2.Test = {})).answer = 42, module.exports = Foo; +}, Test = Foo2.Test || (Foo2.Test = {}), answer = 42, Object.defineProperty(Test, "answer", { + enumerable: !0, + get: function() { + return answer; + }, + set: function(v) { + answer = v; + } +}), module.exports = Foo; //// [foo_1.ts] Object.defineProperty(exports, "__esModule", { value: !0 diff --git a/crates/swc/tests/tsc-references/exportAssignmentTopLevelClodule.1.normal.js b/crates/swc/tests/tsc-references/exportAssignmentTopLevelClodule.1.normal.js index ad24871377781..62da09b4b28af 100644 --- a/crates/swc/tests/tsc-references/exportAssignmentTopLevelClodule.1.normal.js +++ b/crates/swc/tests/tsc-references/exportAssignmentTopLevelClodule.1.normal.js @@ -10,7 +10,16 @@ define([ this.test = "test"; }; (function(Foo) { - var answer = Foo.answer = 42; + var answer = 42; + Object.defineProperty(Foo, "answer", { + enumerable: true, + get: function get() { + return answer; + }, + set: function set(v) { + answer = v; + } + }); })(Foo || (Foo = {})); return Foo; }); diff --git a/crates/swc/tests/tsc-references/exportAssignmentTopLevelClodule.2.minified.js b/crates/swc/tests/tsc-references/exportAssignmentTopLevelClodule.2.minified.js index f50a028443701..87b36ea9d6b02 100644 --- a/crates/swc/tests/tsc-references/exportAssignmentTopLevelClodule.2.minified.js +++ b/crates/swc/tests/tsc-references/exportAssignmentTopLevelClodule.2.minified.js @@ -3,10 +3,18 @@ define([ "require", "@swc/helpers/_/_class_call_check" ], function(require, _class_call_check) { - var Foo = function Foo() { + var Foo, answer, Foo1 = function Foo() { _class_call_check._(this, Foo), this.test = "test"; }; - return (Foo || (Foo = {})).answer = 42, Foo; + return Foo = Foo1 || (Foo1 = {}), answer = 42, Object.defineProperty(Foo, "answer", { + enumerable: !0, + get: function() { + return answer; + }, + set: function(v) { + answer = v; + } + }), Foo1; }); //// [foo_1.ts] define([ diff --git a/crates/swc/tests/tsc-references/exportAssignmentTopLevelEnumdule.1.normal.js b/crates/swc/tests/tsc-references/exportAssignmentTopLevelEnumdule.1.normal.js index cf4ee0d183115..cd5203f84d251 100644 --- a/crates/swc/tests/tsc-references/exportAssignmentTopLevelEnumdule.1.normal.js +++ b/crates/swc/tests/tsc-references/exportAssignmentTopLevelEnumdule.1.normal.js @@ -10,7 +10,16 @@ define([ foo[foo["blue"] = 2] = "blue"; })(foo || (foo = {})); (function(foo) { - var answer = foo.answer = 42; + var answer = 42; + Object.defineProperty(foo, "answer", { + enumerable: true, + get: function get() { + return answer; + }, + set: function set(v) { + answer = v; + } + }); })(foo || (foo = {})); return foo; }); diff --git a/crates/swc/tests/tsc-references/exportAssignmentTopLevelEnumdule.2.minified.js b/crates/swc/tests/tsc-references/exportAssignmentTopLevelEnumdule.2.minified.js index 785376eb596f9..c4a8891950cd6 100644 --- a/crates/swc/tests/tsc-references/exportAssignmentTopLevelEnumdule.2.minified.js +++ b/crates/swc/tests/tsc-references/exportAssignmentTopLevelEnumdule.2.minified.js @@ -2,8 +2,16 @@ define([ "require" ], function(require) { - var foo, foo1; - return (foo1 = foo || (foo = {}))[foo1.red = 0] = "red", foo1[foo1.green = 1] = "green", foo1[foo1.blue = 2] = "blue", (foo || (foo = {})).answer = 42, foo; + var foo, foo1, foo2, answer; + return (foo1 = foo || (foo = {}))[foo1.red = 0] = "red", foo1[foo1.green = 1] = "green", foo1[foo1.blue = 2] = "blue", foo2 = foo || (foo = {}), answer = 42, Object.defineProperty(foo2, "answer", { + enumerable: !0, + get: function() { + return answer; + }, + set: function(v) { + answer = v; + } + }), foo; }); //// [foo_1.ts] define([ diff --git a/crates/swc/tests/tsc-references/exportAssignmentTopLevelFundule.1.normal.js b/crates/swc/tests/tsc-references/exportAssignmentTopLevelFundule.1.normal.js index 02fadc4c7865e..73e9d44d34fc4 100644 --- a/crates/swc/tests/tsc-references/exportAssignmentTopLevelFundule.1.normal.js +++ b/crates/swc/tests/tsc-references/exportAssignmentTopLevelFundule.1.normal.js @@ -7,7 +7,16 @@ define([ return "test"; } (function(foo) { - var answer = foo.answer = 42; + var answer = 42; + Object.defineProperty(foo, "answer", { + enumerable: true, + get: function get() { + return answer; + }, + set: function set(v) { + answer = v; + } + }); })(foo || (foo = {})); return foo; }); diff --git a/crates/swc/tests/tsc-references/exportAssignmentTopLevelFundule.2.minified.js b/crates/swc/tests/tsc-references/exportAssignmentTopLevelFundule.2.minified.js index 4d392f9526057..413050f6c52fb 100644 --- a/crates/swc/tests/tsc-references/exportAssignmentTopLevelFundule.2.minified.js +++ b/crates/swc/tests/tsc-references/exportAssignmentTopLevelFundule.2.minified.js @@ -2,10 +2,19 @@ define([ "require" ], function(require) { - function foo() { + var foo, answer; + function foo1() { return "test"; } - return (foo || (foo = {})).answer = 42, foo; + return foo = foo1 || (foo1 = {}), answer = 42, Object.defineProperty(foo, "answer", { + enumerable: !0, + get: function() { + return answer; + }, + set: function(v) { + answer = v; + } + }), foo1; }); //// [foo_1.ts] define([ diff --git a/crates/swc/tests/tsc-references/exportAssignmentTopLevelIdentifier.1.normal.js b/crates/swc/tests/tsc-references/exportAssignmentTopLevelIdentifier.1.normal.js index 294a7b10110eb..baabbb302f9f2 100644 --- a/crates/swc/tests/tsc-references/exportAssignmentTopLevelIdentifier.1.normal.js +++ b/crates/swc/tests/tsc-references/exportAssignmentTopLevelIdentifier.1.normal.js @@ -5,7 +5,16 @@ define([ "use strict"; var Foo; (function(Foo) { - var answer = Foo.answer = 42; + var answer = 42; + Object.defineProperty(Foo, "answer", { + enumerable: true, + get: function get() { + return answer; + }, + set: function set(v) { + answer = v; + } + }); })(Foo || (Foo = {})); return Foo; }); diff --git a/crates/swc/tests/tsc-references/exportAssignmentTopLevelIdentifier.2.minified.js b/crates/swc/tests/tsc-references/exportAssignmentTopLevelIdentifier.2.minified.js index d0e6841759d1e..cf45337f3a32c 100644 --- a/crates/swc/tests/tsc-references/exportAssignmentTopLevelIdentifier.2.minified.js +++ b/crates/swc/tests/tsc-references/exportAssignmentTopLevelIdentifier.2.minified.js @@ -2,8 +2,16 @@ define([ "require" ], function(require) { - var Foo; - return (Foo || (Foo = {})).answer = 42, Foo; + var Foo, Foo1, answer; + return Foo1 = Foo || (Foo = {}), answer = 42, Object.defineProperty(Foo1, "answer", { + enumerable: !0, + get: function() { + return answer; + }, + set: function(v) { + answer = v; + } + }), Foo; }); //// [foo_1.ts] define([ diff --git a/crates/swc/tests/tsc-references/exportCodeGen.1.normal.js b/crates/swc/tests/tsc-references/exportCodeGen.1.normal.js index 926bb81ee2c6c..e50c6ef1fb299 100644 --- a/crates/swc/tests/tsc-references/exportCodeGen.1.normal.js +++ b/crates/swc/tests/tsc-references/exportCodeGen.1.normal.js @@ -7,33 +7,42 @@ var A; var lt12 = function lt12() { return x < 12; }; - var x = A.x = 12; + var x = 12; + Object.defineProperty(A, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(A || (A = {})); -// should not fully qualify 'x' var B; +// should not fully qualify 'x' (function(B) { var lt12 = function lt12() { return x < 12; }; var x = 12; })(B || (B = {})); -// not copied, since not exported var C; +// not copied, since not exported (function(C) { var no = function no() { return false; }; })(C || (C = {})); -// copies, since exported var D; +// copies, since exported (function(D) { var yes = function yes() { return true; }; D.yes = yes; })(D || (D = {})); -// validate all exportable statements var E; +// validate all exportable statements (function(E) { var fn = function fn() {}; var Color; @@ -48,12 +57,21 @@ var E; E.C = C; var M; (function(M) { - var x = M.x = 42; + var x = 42; + Object.defineProperty(M, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(M = E.M || (E.M = {})); })(E || (E = {})); +var F; // validate all exportable statements, // which are not exported -var F; (function(F) { var fn = function fn() {}; var Color; diff --git a/crates/swc/tests/tsc-references/exportCodeGen.2.minified.js b/crates/swc/tests/tsc-references/exportCodeGen.2.minified.js index 61939e3e9a611..98d4b0e9d7a6e 100644 --- a/crates/swc/tests/tsc-references/exportCodeGen.2.minified.js +++ b/crates/swc/tests/tsc-references/exportCodeGen.2.minified.js @@ -1,10 +1,26 @@ //// [exportCodeGen.ts] // should replace all refs to 'x' in the body, // with fully qualified -var A, B, C, D, E, F, E1, Color, Color1, M, Color2; +var A, B, C, D, E, F, A1, x, E1, Color, M, x1, Color1, M1, Color2; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(A || (A = {})).x = 12, B || (B = {}), C || (C = {}), (D || (D = {})).yes = function() { +A1 = A || (A = {}), x = 12, Object.defineProperty(A1, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}), B || (B = {}), C || (C = {}), (D || (D = {})).yes = function() { return !0; }, (Color = (E1 = E || (E = {})).Color || (E1.Color = {}))[Color.Red = 0] = "Red", E1.fn = function() {}, E1.C = function C() { _class_call_check(this, C); -}, (E1.M || (E1.M = {})).x = 42, F || (F = {}), (Color2 = Color1 || (Color1 = {}))[Color2.Red = 0] = "Red", M || (M = {}); +}, M = E1.M || (E1.M = {}), x1 = 42, Object.defineProperty(M, "x", { + enumerable: !0, + get: function() { + return x1; + }, + set: function(v) { + x1 = v; + } +}), F || (F = {}), (Color2 = Color1 || (Color1 = {}))[Color2.Red = 0] = "Red", M1 || (M1 = {}); diff --git a/crates/swc/tests/tsc-references/exportImportAlias.1.normal.js b/crates/swc/tests/tsc-references/exportImportAlias.1.normal.js index f1cad7649dff0..99da5cdc5628f 100644 --- a/crates/swc/tests/tsc-references/exportImportAlias.1.normal.js +++ b/crates/swc/tests/tsc-references/exportImportAlias.1.normal.js @@ -3,7 +3,16 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var A; (function(A) { - var x = A.x = "hello world"; + var x = "hello world"; + Object.defineProperty(A, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); var Point = function Point(x, y) { "use strict"; _class_call_check(this, Point); @@ -14,8 +23,7 @@ var A; })(A || (A = {})); var C; (function(C) { - var a = A; - C.a = a; + var a = C.a = A; })(C || (C = {})); var a = C.a.x; var b = new C.a.Point(0, 0); @@ -39,9 +47,7 @@ var X; })(X || (X = {})); var Z; (function(Z) { - // 'y' should be a fundule here - var y = X.Y; - Z.y = y; + var y = Z.y = X.Y; })(Z || (Z = {})); var m = Z.y(); var n = new Z.y.Point(0, 0); @@ -54,13 +60,21 @@ var K; }; K.L = L; (function(L) { - var y = L.y = 12; + var y = 12; + Object.defineProperty(L, "y", { + enumerable: true, + get: function get() { + return y; + }, + set: function set(v) { + y = v; + } + }); })(L = K.L || (K.L = {})); })(K || (K = {})); var M; (function(M) { - var D = K.L; - M.D = D; + var D = M.D = K.L; })(M || (M = {})); var o; var o = new M.D("Hello"); diff --git a/crates/swc/tests/tsc-references/exportImportAlias.2.minified.js b/crates/swc/tests/tsc-references/exportImportAlias.2.minified.js index ca61538a0949a..04bd562118348 100644 --- a/crates/swc/tests/tsc-references/exportImportAlias.2.minified.js +++ b/crates/swc/tests/tsc-references/exportImportAlias.2.minified.js @@ -1,13 +1,29 @@ //// [exportImportAlias.ts] // expect no errors here -var A, C, X, Z, K, M, A1, C1, a, X1, Y, Z1, y, K1, L, M1, D; +var A, C, X, Z, K, M, A1, x, X1, Y, K1, L, L1, y; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(A1 = A || (A = {})).x = "hello world", A1.Point = function Point(x, y) { +A1 = A || (A = {}), x = "hello world", Object.defineProperty(A1, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}), A1.Point = function Point(x, y) { _class_call_check(this, Point), this.x = x, this.y = y; -}, C1 = C || (C = {}), a = A, C1.a = a, C.a.x, new C.a.Point(0, 0), Y = function() { +}, (C || (C = {})).a = A, C.a.x, new C.a.Point(0, 0), Y = function() { return 42; }, (X1 = X || (X = {})).Y = Y, (Y = X1.Y || (X1.Y = {})).Point = function Point(x, y) { _class_call_check(this, Point), this.x = x, this.y = y; -}, Z1 = Z || (Z = {}), y = X.Y, Z1.y = y, Z.y(), new Z.y.Point(0, 0), K1 = K || (K = {}), L = function L(name) { +}, (Z || (Z = {})).y = X.Y, Z.y(), new Z.y.Point(0, 0), K1 = K || (K = {}), L = function L(name) { _class_call_check(this, L), this.name = name; -}, K1.L = L, (L = K1.L || (K1.L = {})).y = 12, M1 = M || (M = {}), D = K.L, M1.D = D, new M.D("Hello"); +}, K1.L = L, L1 = L = K1.L || (K1.L = {}), y = 12, Object.defineProperty(L1, "y", { + enumerable: !0, + get: function() { + return y; + }, + set: function(v) { + y = v; + } +}), (M || (M = {})).D = K.L, new M.D("Hello"); diff --git a/crates/swc/tests/tsc-references/exportsAndImports1-amd.1.normal.js b/crates/swc/tests/tsc-references/exportsAndImports1-amd.1.normal.js index 91e18670222c7..35d4e6bf75c38 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports1-amd.1.normal.js +++ b/crates/swc/tests/tsc-references/exportsAndImports1-amd.1.normal.js @@ -56,15 +56,18 @@ define([ E[E["C"] = 2] = "C"; })(E || (E = {})); var D; - (function(D) { - D[D["A"] = 0] = "A"; - D[D["B"] = 1] = "B"; - D[D["C"] = 2] = "C"; - })(D || (D = {})); var M; (function(M) { var x; - M.x = x; + Object.defineProperty(M, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(M || (M = {})); var a = M.x; }); diff --git a/crates/swc/tests/tsc-references/exportsAndImports1-amd.2.minified.js b/crates/swc/tests/tsc-references/exportsAndImports1-amd.2.minified.js index 99ec9dc69d4e9..1a198028e734b 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports1-amd.2.minified.js +++ b/crates/swc/tests/tsc-references/exportsAndImports1-amd.2.minified.js @@ -29,7 +29,7 @@ define([ return E1; }, D: function() { - return D1; + return D; }, M: function() { return M; @@ -38,12 +38,20 @@ define([ return a; } }); - var E, D, x, E1, D1, M, v = 1; + var E, x, E1, D, M, v = 1; function f() {} var C = function C() { _class_call_check._(this, C); }; - (E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C", (D = D1 || (D1 = {}))[D.A = 0] = "A", D[D.B = 1] = "B", D[D.C = 2] = "C", (M || (M = {})).x = x; + (E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C", Object.defineProperty(M || (M = {}), "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } + }); var a = M.x; }); //// [t2.ts] diff --git a/crates/swc/tests/tsc-references/exportsAndImports1-es6.1.normal.js b/crates/swc/tests/tsc-references/exportsAndImports1-es6.1.normal.js index 0521ec4dca156..6ba70e236087b 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports1-es6.1.normal.js +++ b/crates/swc/tests/tsc-references/exportsAndImports1-es6.1.normal.js @@ -45,17 +45,20 @@ var E; E[E["C"] = 2] = "C"; })(E || (E = {})); var D; -(function(D) { - D[D["A"] = 0] = "A"; - D[D["B"] = 1] = "B"; - D[D["C"] = 2] = "C"; -})(D || (D = {})); var M; (function(M) { var x; - M.x = x; + Object.defineProperty(M, "x", { + enumerable: true, + get () { + return x; + }, + set (v) { + x = v; + } + }); })(M || (M = {})); -var a = M.x; +const a = M.x; //// [t2.ts] "use strict"; Object.defineProperty(exports, "__esModule", { diff --git a/crates/swc/tests/tsc-references/exportsAndImports1-es6.2.minified.js b/crates/swc/tests/tsc-references/exportsAndImports1-es6.2.minified.js index 9d0a64e5f0a72..0f7b3fd89e09e 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports1-es6.2.minified.js +++ b/crates/swc/tests/tsc-references/exportsAndImports1-es6.2.minified.js @@ -21,7 +21,7 @@ Object.defineProperty(exports, "__esModule", { return E1; }, D: function() { - return D1; + return D; }, M: function() { return M; @@ -30,12 +30,18 @@ Object.defineProperty(exports, "__esModule", { return a; } }); -var E, D, x, E1, D1, M, v = 1; +var E, x, E1, D, M, v = 1; function f() {} class C { } -(E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C", (D = D1 || (D1 = {}))[D.A = 0] = "A", D[D.B = 1] = "B", D[D.C = 2] = "C", (M || (M = {})).x = x; -var a = M.x; +(E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C", Object.defineProperty(M || (M = {}), "x", { + enumerable: !0, + get: ()=>x, + set (v) { + x = v; + } +}); +const a = M.x; //// [t2.ts] Object.defineProperty(exports, "__esModule", { value: !0 diff --git a/crates/swc/tests/tsc-references/exportsAndImports1.1.normal.js b/crates/swc/tests/tsc-references/exportsAndImports1.1.normal.js index 4046f8ebb7c6f..eefe8c5a14ab7 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports1.1.normal.js +++ b/crates/swc/tests/tsc-references/exportsAndImports1.1.normal.js @@ -48,15 +48,18 @@ var E; E[E["C"] = 2] = "C"; })(E || (E = {})); var D; -(function(D) { - D[D["A"] = 0] = "A"; - D[D["B"] = 1] = "B"; - D[D["C"] = 2] = "C"; -})(D || (D = {})); var M; (function(M) { var x; - M.x = x; + Object.defineProperty(M, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(M || (M = {})); var a = M.x; //// [t2.ts] diff --git a/crates/swc/tests/tsc-references/exportsAndImports1.2.minified.js b/crates/swc/tests/tsc-references/exportsAndImports1.2.minified.js index de6001f323a1f..e94e695bff807 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports1.2.minified.js +++ b/crates/swc/tests/tsc-references/exportsAndImports1.2.minified.js @@ -21,7 +21,7 @@ Object.defineProperty(exports, "__esModule", { return E1; }, D: function() { - return D1; + return D; }, M: function() { return M; @@ -30,12 +30,20 @@ Object.defineProperty(exports, "__esModule", { return a; } }); -var E, D, x, E1, D1, M, _class_call_check = require("@swc/helpers/_/_class_call_check"), v = 1; +var E, x, E1, D, M, _class_call_check = require("@swc/helpers/_/_class_call_check"), v = 1; function f() {} var C = function C() { _class_call_check._(this, C); }; -(E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C", (D = D1 || (D1 = {}))[D.A = 0] = "A", D[D.B = 1] = "B", D[D.C = 2] = "C", (M || (M = {})).x = x; +(E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C", Object.defineProperty(M || (M = {}), "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}); var a = M.x; //// [t2.ts] Object.defineProperty(exports, "__esModule", { diff --git a/crates/swc/tests/tsc-references/exportsAndImports3-amd.1.normal.js b/crates/swc/tests/tsc-references/exportsAndImports3-amd.1.normal.js index a284b7e6f061e..c0995de1872dd 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports3-amd.1.normal.js +++ b/crates/swc/tests/tsc-references/exportsAndImports3-amd.1.normal.js @@ -85,7 +85,15 @@ define([ var M; (function(M) { var x; - M.x = x; + Object.defineProperty(M, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(M || (M = {})); var a = M.x; }); diff --git a/crates/swc/tests/tsc-references/exportsAndImports3-amd.2.minified.js b/crates/swc/tests/tsc-references/exportsAndImports3-amd.2.minified.js index a3426ad09fac5..cd97026a0eba9 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports3-amd.2.minified.js +++ b/crates/swc/tests/tsc-references/exportsAndImports3-amd.2.minified.js @@ -64,7 +64,15 @@ define([ var C = function C() { _class_call_check._(this, C); }; - (E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C", (D = D1 || (D1 = {}))[D.A = 0] = "A", D[D.B = 1] = "B", D[D.C = 2] = "C", (M || (M = {})).x = x; + (E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C", (D = D1 || (D1 = {}))[D.A = 0] = "A", D[D.B = 1] = "B", D[D.C = 2] = "C", Object.defineProperty(M || (M = {}), "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } + }); var a = M.x; }); //// [t2.ts] diff --git a/crates/swc/tests/tsc-references/exportsAndImports3-es6.1.normal.js b/crates/swc/tests/tsc-references/exportsAndImports3-es6.1.normal.js index 1771fd85767a6..e7dd7b6158d7c 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports3-es6.1.normal.js +++ b/crates/swc/tests/tsc-references/exportsAndImports3-es6.1.normal.js @@ -74,9 +74,17 @@ var D; var M; (function(M) { var x; - M.x = x; + Object.defineProperty(M, "x", { + enumerable: true, + get () { + return x; + }, + set (v) { + x = v; + } + }); })(M || (M = {})); -var a = M.x; +const a = M.x; //// [t2.ts] "use strict"; Object.defineProperty(exports, "__esModule", { diff --git a/crates/swc/tests/tsc-references/exportsAndImports3-es6.2.minified.js b/crates/swc/tests/tsc-references/exportsAndImports3-es6.2.minified.js index 4ce07f11cbd38..0a9941c6a3e18 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports3-es6.2.minified.js +++ b/crates/swc/tests/tsc-references/exportsAndImports3-es6.2.minified.js @@ -55,8 +55,14 @@ var E, D, x, E1, D1, M, v = 1; function f() {} class C { } -(E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C", (D = D1 || (D1 = {}))[D.A = 0] = "A", D[D.B = 1] = "B", D[D.C = 2] = "C", (M || (M = {})).x = x; -var a = M.x; +(E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C", (D = D1 || (D1 = {}))[D.A = 0] = "A", D[D.B = 1] = "B", D[D.C = 2] = "C", Object.defineProperty(M || (M = {}), "x", { + enumerable: !0, + get: ()=>x, + set (v) { + x = v; + } +}); +const a = M.x; //// [t2.ts] Object.defineProperty(exports, "__esModule", { value: !0 diff --git a/crates/swc/tests/tsc-references/exportsAndImports3.1.normal.js b/crates/swc/tests/tsc-references/exportsAndImports3.1.normal.js index 1fd19e4d534d0..825d8509b8936 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports3.1.normal.js +++ b/crates/swc/tests/tsc-references/exportsAndImports3.1.normal.js @@ -77,7 +77,15 @@ var D; var M; (function(M) { var x; - M.x = x; + Object.defineProperty(M, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(M || (M = {})); var a = M.x; //// [t2.ts] diff --git a/crates/swc/tests/tsc-references/exportsAndImports3.2.minified.js b/crates/swc/tests/tsc-references/exportsAndImports3.2.minified.js index ce1ddf76f2caa..44dd4c6c781eb 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports3.2.minified.js +++ b/crates/swc/tests/tsc-references/exportsAndImports3.2.minified.js @@ -56,7 +56,15 @@ function f() {} var C = function C() { _class_call_check._(this, C); }; -(E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C", (D = D1 || (D1 = {}))[D.A = 0] = "A", D[D.B = 1] = "B", D[D.C = 2] = "C", (M || (M = {})).x = x; +(E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C", (D = D1 || (D1 = {}))[D.A = 0] = "A", D[D.B = 1] = "B", D[D.C = 2] = "C", Object.defineProperty(M || (M = {}), "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}); var a = M.x; //// [t2.ts] Object.defineProperty(exports, "__esModule", { diff --git a/crates/swc/tests/tsc-references/for-inStatements.1.normal.js b/crates/swc/tests/tsc-references/for-inStatements.1.normal.js index da56ddc2fdede..bb5750b6750b1 100644 --- a/crates/swc/tests/tsc-references/for-inStatements.1.normal.js +++ b/crates/swc/tests/tsc-references/for-inStatements.1.normal.js @@ -91,4 +91,4 @@ var Color; Color[Color["Blue"] = 1] = "Blue"; })(Color || (Color = {})); for(var x in Color){} -for(var x in Color.Blue){} +for(var x in 1){} diff --git a/crates/swc/tests/tsc-references/for-inStatements.2.minified.js b/crates/swc/tests/tsc-references/for-inStatements.2.minified.js index 52edb29162ddc..52082d1fd2367 100644 --- a/crates/swc/tests/tsc-references/for-inStatements.2.minified.js +++ b/crates/swc/tests/tsc-references/for-inStatements.2.minified.js @@ -38,4 +38,4 @@ for(var x in (M || (M = {})).X = function X() { }, M); for(var x in M.X); for(var x in (Color1 = Color || (Color = {}))[Color1.Red = 0] = "Red", Color1[Color1.Blue = 1] = "Blue", Color); -for(var x in Color.Blue); +for(var x in 1); diff --git a/crates/swc/tests/tsc-references/for-of47.1.normal.js b/crates/swc/tests/tsc-references/for-of47.1.normal.js index 333df09968f09..1cdee4d9be7a5 100644 --- a/crates/swc/tests/tsc-references/for-of47.1.normal.js +++ b/crates/swc/tests/tsc-references/for-of47.1.normal.js @@ -10,7 +10,7 @@ var E; (function(E) { E[E["x"] = 0] = "x"; })(E || (E = {})); -for ({ x, y: y = E.x } of array){ +for ({ x, y: y = 0 } of array){ x; y; } diff --git a/crates/swc/tests/tsc-references/for-of47.2.minified.js b/crates/swc/tests/tsc-references/for-of47.2.minified.js index 5495fd1543713..3e8b5bbe94a19 100644 --- a/crates/swc/tests/tsc-references/for-of47.2.minified.js +++ b/crates/swc/tests/tsc-references/for-of47.2.minified.js @@ -1,6 +1,6 @@ //// [for-of47.ts] var x, y, E, E1; -for ({ x, y: y = E.x } of ((E1 = E || (E = {}))[E1.x = 0] = "x", [ +for ({ x, y: y = 0 } of ((E1 = E || (E = {}))[E1.x = 0] = "x", [ { x: "", y: !0 diff --git a/crates/swc/tests/tsc-references/for-of48.1.normal.js b/crates/swc/tests/tsc-references/for-of48.1.normal.js index 13b9e6ff786a7..71b4be624bcd6 100644 --- a/crates/swc/tests/tsc-references/for-of48.1.normal.js +++ b/crates/swc/tests/tsc-references/for-of48.1.normal.js @@ -10,7 +10,7 @@ var E; (function(E) { E[E["x"] = 0] = "x"; })(E || (E = {})); -for ({ x, y = E.x } of array){ +for ({ x, y = 0 } of array){ x; y; } diff --git a/crates/swc/tests/tsc-references/for-of48.2.minified.js b/crates/swc/tests/tsc-references/for-of48.2.minified.js index e779e1a5cf2f2..29816636c65f5 100644 --- a/crates/swc/tests/tsc-references/for-of48.2.minified.js +++ b/crates/swc/tests/tsc-references/for-of48.2.minified.js @@ -1,6 +1,6 @@ //// [for-of48.ts] var x, y, E, E1; -for ({ x, y = E.x } of ((E1 = E || (E = {}))[E1.x = 0] = "x", [ +for ({ x, y = 0 } of ((E1 = E || (E = {}))[E1.x = 0] = "x", [ { x: "", y: !0 diff --git a/crates/swc/tests/tsc-references/generatedContextualTyping.1.normal.js b/crates/swc/tests/tsc-references/generatedContextualTyping.1.normal.js index ce377642b042f..5d20515ffbd57 100644 --- a/crates/swc/tests/tsc-references/generatedContextualTyping.1.normal.js +++ b/crates/swc/tests/tsc-references/generatedContextualTyping.1.normal.js @@ -1835,98 +1835,197 @@ var x192; })(x192 || (x192 = {})); var x193; (function(x193) { - var t = x193.t = function() { + var t = function() { return [ d1, d2 ]; }; + Object.defineProperty(x193, "t", { + enumerable: true, + get: function get() { + return t; + }, + set: function set(v) { + t = v; + } + }); })(x193 || (x193 = {})); var x194; (function(x194) { - var t = x194.t = function t() { + var t = function t() { return [ d1, d2 ]; }; + Object.defineProperty(x194, "t", { + enumerable: true, + get: function get() { + return t; + }, + set: function set(v) { + t = v; + } + }); })(x194 || (x194 = {})); var x195; (function(x195) { - var t = x195.t = function named() { + var t = function named() { return [ d1, d2 ]; }; + Object.defineProperty(x195, "t", { + enumerable: true, + get: function get() { + return t; + }, + set: function set(v) { + t = v; + } + }); })(x195 || (x195 = {})); var x196; (function(x196) { - var t = x196.t = function() { + var t = function() { return [ d1, d2 ]; }; + Object.defineProperty(x196, "t", { + enumerable: true, + get: function get() { + return t; + }, + set: function set(v) { + t = v; + } + }); })(x196 || (x196 = {})); var x197; (function(x197) { - var t = x197.t = function t() { + var t = function t() { return [ d1, d2 ]; }; + Object.defineProperty(x197, "t", { + enumerable: true, + get: function get() { + return t; + }, + set: function set(v) { + t = v; + } + }); })(x197 || (x197 = {})); var x198; (function(x198) { - var t = x198.t = function named() { + var t = function named() { return [ d1, d2 ]; }; + Object.defineProperty(x198, "t", { + enumerable: true, + get: function get() { + return t; + }, + set: function set(v) { + t = v; + } + }); })(x198 || (x198 = {})); var x199; (function(x199) { - var t = x199.t = [ + var t = [ d1, d2 ]; + Object.defineProperty(x199, "t", { + enumerable: true, + get: function get() { + return t; + }, + set: function set(v) { + t = v; + } + }); })(x199 || (x199 = {})); var x200; (function(x200) { - var t = x200.t = [ + var t = [ d1, d2 ]; + Object.defineProperty(x200, "t", { + enumerable: true, + get: function get() { + return t; + }, + set: function set(v) { + t = v; + } + }); })(x200 || (x200 = {})); var x201; (function(x201) { - var t = x201.t = [ + var t = [ d1, d2 ]; + Object.defineProperty(x201, "t", { + enumerable: true, + get: function get() { + return t; + }, + set: function set(v) { + t = v; + } + }); })(x201 || (x201 = {})); var x202; (function(x202) { - var t = x202.t = { + var t = { n: [ d1, d2 ] }; + Object.defineProperty(x202, "t", { + enumerable: true, + get: function get() { + return t; + }, + set: function set(v) { + t = v; + } + }); })(x202 || (x202 = {})); var x203; (function(x203) { - var t = x203.t = function(n) { + var t = function(n) { var n; return null; }; + Object.defineProperty(x203, "t", { + enumerable: true, + get: function get() { + return t; + }, + set: function set(v) { + t = v; + } + }); })(x203 || (x203 = {})); var x204; (function(x204) { - var t = x204.t = { + var t = { func: function(n) { return [ d1, @@ -1934,6 +2033,15 @@ var x204; ]; } }; + Object.defineProperty(x204, "t", { + enumerable: true, + get: function get() { + return t; + }, + set: function set(v) { + t = v; + } + }); })(x204 || (x204 = {})); var x206 = function x206() { return [ diff --git a/crates/swc/tests/tsc-references/generatedContextualTyping.2.minified.js b/crates/swc/tests/tsc-references/generatedContextualTyping.2.minified.js index 5066b1906118b..6b140a85e42d2 100644 --- a/crates/swc/tests/tsc-references/generatedContextualTyping.2.minified.js +++ b/crates/swc/tests/tsc-references/generatedContextualTyping.2.minified.js @@ -2,7 +2,7 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -var x181, x182, x183, x184, x185, x186, x187, x188, x189, x190, x191, x192, x193, x194, x195, x196, x197, x198, x199, x200, x201, x202, x203, x204, Base = function Base() { +var x193, t, x194, t1, x195, t2, x196, t3, x197, t4, x198, t5, x199, t6, x200, t7, x201, t8, x202, t9, x203, t10, x204, t11, x181, x182, x183, x184, x185, x186, x187, x188, x189, x190, x191, x192, x1931, x1941, x1951, x1961, x1971, x1981, x1991, x2001, x2011, x2021, x2031, x2041, Base = function Base() { _class_call_check(this, Base); }, Derived1 = function(Base) { _inherits(Derived1, Base); @@ -21,57 +21,153 @@ var x181, x182, x183, x184, x185, x186, x187, x188, x189, x190, x191, x192, x193 }(Base); new Base(); var d1 = new Derived1(), d2 = new Derived2(); -x181 || (x181 = {}), x182 || (x182 = {}), x183 || (x183 = {}), x184 || (x184 = {}), x185 || (x185 = {}), x186 || (x186 = {}), x187 || (x187 = {}), x188 || (x188 = {}), x189 || (x189 = {}), x190 || (x190 = {}), x191 || (x191 = {}), x192 || (x192 = {}), (x193 || (x193 = {})).t = function() { +x181 || (x181 = {}), x182 || (x182 = {}), x183 || (x183 = {}), x184 || (x184 = {}), x185 || (x185 = {}), x186 || (x186 = {}), x187 || (x187 = {}), x188 || (x188 = {}), x189 || (x189 = {}), x190 || (x190 = {}), x191 || (x191 = {}), x192 || (x192 = {}), x193 = x1931 || (x1931 = {}), t = function() { return [ d1, d2 ]; -}, (x194 || (x194 = {})).t = function() { +}, Object.defineProperty(x193, "t", { + enumerable: !0, + get: function() { + return t; + }, + set: function(v) { + t = v; + } +}), x194 = x1941 || (x1941 = {}), t1 = function() { return [ d1, d2 ]; -}, (x195 || (x195 = {})).t = function() { +}, Object.defineProperty(x194, "t", { + enumerable: !0, + get: function() { + return t1; + }, + set: function(v) { + t1 = v; + } +}), x195 = x1951 || (x1951 = {}), t2 = function() { return [ d1, d2 ]; -}, (x196 || (x196 = {})).t = function() { +}, Object.defineProperty(x195, "t", { + enumerable: !0, + get: function() { + return t2; + }, + set: function(v) { + t2 = v; + } +}), x196 = x1961 || (x1961 = {}), t3 = function() { return [ d1, d2 ]; -}, (x197 || (x197 = {})).t = function() { +}, Object.defineProperty(x196, "t", { + enumerable: !0, + get: function() { + return t3; + }, + set: function(v) { + t3 = v; + } +}), x197 = x1971 || (x1971 = {}), t4 = function() { return [ d1, d2 ]; -}, (x198 || (x198 = {})).t = function() { +}, Object.defineProperty(x197, "t", { + enumerable: !0, + get: function() { + return t4; + }, + set: function(v) { + t4 = v; + } +}), x198 = x1981 || (x1981 = {}), t5 = function() { return [ d1, d2 ]; -}, (x199 || (x199 = {})).t = [ +}, Object.defineProperty(x198, "t", { + enumerable: !0, + get: function() { + return t5; + }, + set: function(v) { + t5 = v; + } +}), x199 = x1991 || (x1991 = {}), t6 = [ d1, d2 -], (x200 || (x200 = {})).t = [ +], Object.defineProperty(x199, "t", { + enumerable: !0, + get: function() { + return t6; + }, + set: function(v) { + t6 = v; + } +}), x200 = x2001 || (x2001 = {}), t7 = [ d1, d2 -], (x201 || (x201 = {})).t = [ +], Object.defineProperty(x200, "t", { + enumerable: !0, + get: function() { + return t7; + }, + set: function(v) { + t7 = v; + } +}), x201 = x2011 || (x2011 = {}), t8 = [ d1, d2 -], (x202 || (x202 = {})).t = { +], Object.defineProperty(x201, "t", { + enumerable: !0, + get: function() { + return t8; + }, + set: function(v) { + t8 = v; + } +}), x202 = x2021 || (x2021 = {}), t9 = { n: [ d1, d2 ] -}, (x203 || (x203 = {})).t = function(n) { +}, Object.defineProperty(x202, "t", { + enumerable: !0, + get: function() { + return t9; + }, + set: function(v) { + t9 = v; + } +}), x203 = x2031 || (x2031 = {}), t10 = function(n) { return null; -}, (x204 || (x204 = {})).t = { +}, Object.defineProperty(x203, "t", { + enumerable: !0, + get: function() { + return t10; + }, + set: function(v) { + t10 = v; + } +}), x204 = x2041 || (x2041 = {}), t11 = { func: function(n) { return [ d1, d2 ]; } -}; +}, Object.defineProperty(x204, "t", { + enumerable: !0, + get: function() { + return t11; + }, + set: function(v) { + t11 = v; + } +}); diff --git a/crates/swc/tests/tsc-references/genericCallToOverloadedMethodWithOverloadedArguments.1.normal.js b/crates/swc/tests/tsc-references/genericCallToOverloadedMethodWithOverloadedArguments.1.normal.js index 2cb5469c97d93..7a652cc7aa569 100644 --- a/crates/swc/tests/tsc-references/genericCallToOverloadedMethodWithOverloadedArguments.1.normal.js +++ b/crates/swc/tests/tsc-references/genericCallToOverloadedMethodWithOverloadedArguments.1.normal.js @@ -4,32 +4,32 @@ var m1; var numPromise; var newPromise = numPromise.then(testFunction); })(m1 || (m1 = {})); -////////////////////////////////////// var m2; +////////////////////////////////////// (function(m2) { var numPromise; var newPromise = numPromise.then(testFunction); })(m2 || (m2 = {})); -////////////////////////////////////// var m3; +////////////////////////////////////// (function(m3) { var numPromise; var newPromise = numPromise.then(testFunction); })(m3 || (m3 = {})); -////////////////////////////////////// var m4; +////////////////////////////////////// (function(m4) { var numPromise; var newPromise = numPromise.then(testFunction); })(m4 || (m4 = {})); -////////////////////////////////////// var m5; +////////////////////////////////////// (function(m5) { var numPromise; var newPromise = numPromise.then(testFunction); })(m5 || (m5 = {})); -////////////////////////////////////// var m6; +////////////////////////////////////// (function(m6) { var numPromise; var newPromise = numPromise.then(testFunction); diff --git a/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2.1.normal.js b/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2.1.normal.js index ec7dc6c006020..6be119d513ef4 100644 --- a/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2.1.normal.js +++ b/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2.1.normal.js @@ -50,10 +50,10 @@ var onlyT; (function(F) { F[F["A"] = 0] = "A"; })(F || (F = {})); - var r7 = foo3(E.A, function(x) { - return E.A; + var r7 = foo3(0, function(x) { + return 0; }, function(x) { - return F.A; + return 0; }); // error })(onlyT || (onlyT = {})); var TU; @@ -104,9 +104,9 @@ var TU; (function(F) { F[F["A"] = 0] = "A"; })(F || (F = {})); - var r7 = foo3(E.A, function(x) { - return E.A; + var r7 = foo3(0, function(x) { + return 0; }, function(x) { - return F.A; + return 0; }); })(TU || (TU = {})); diff --git a/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2.2.minified.js index 1c30e0078213e..63c13b3ca67a8 100644 --- a/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2.2.minified.js @@ -2,4 +2,4 @@ // When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made, // the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them. var onlyT, TU, E, F, E1, F1, E2, F2, E3, F3; -onlyT || (onlyT = {}), (E1 = E || (E = {}))[E1.A = 0] = "A", (F1 = F || (F = {}))[F1.A = 0] = "A", E.A, TU || (TU = {}), (E3 = E2 || (E2 = {}))[E3.A = 0] = "A", (F3 = F2 || (F2 = {}))[F3.A = 0] = "A", E2.A; +onlyT || (onlyT = {}), (E1 = E || (E = {}))[E1.A = 0] = "A", (F1 = F || (F = {}))[F1.A = 0] = "A", TU || (TU = {}), (E3 = E2 || (E2 = {}))[E3.A = 0] = "A", (F3 = F2 || (F2 = {}))[F3.A = 0] = "A"; diff --git a/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments3.1.normal.js b/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments3.1.normal.js index 68770cc86e481..5ebad0d55807c 100644 --- a/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments3.1.normal.js +++ b/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments3.1.normal.js @@ -43,10 +43,10 @@ var F; (function(F) { F[F["A"] = 0] = "A"; })(F || (F = {})); -var r6 = foo(E.A, function(x) { - return E.A; +var r6 = foo(0, function(x) { + return 0; }, function(x) { - return F.A; + return 0; }); // number => number function foo2(x, a, b) { var r; diff --git a/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments3.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments3.2.minified.js index 341a56d0dbcf9..42bdfb7ed6c0a 100644 --- a/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments3.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments3.2.minified.js @@ -2,5 +2,5 @@ // When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made, // the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them. var E, F, E1, F1; -(E1 = E || (E = {}))[E1.A = 0] = "A", (F1 = F || (F = {}))[F1.A = 0] = "A", E.A; +(E1 = E || (E = {}))[E1.A = 0] = "A", (F1 = F || (F = {}))[F1.A = 0] = "A"; // error diff --git a/crates/swc/tests/tsc-references/globalThisAmbientModules.1.normal.js b/crates/swc/tests/tsc-references/globalThisAmbientModules.1.normal.js index 751243314d8b0..bfc8a0a2cc82d 100644 --- a/crates/swc/tests/tsc-references/globalThisAmbientModules.1.normal.js +++ b/crates/swc/tests/tsc-references/globalThisAmbientModules.1.normal.js @@ -1,6 +1,15 @@ //// [globalThisAmbientModules.ts] var valueModule; (function(valueModule) { - var val = valueModule.val = 1; + var val = 1; + Object.defineProperty(valueModule, "val", { + enumerable: true, + get: function get() { + return val; + }, + set: function set(v) { + val = v; + } + }); })(valueModule || (valueModule = {})); var bad1 = "ambientModule"; diff --git a/crates/swc/tests/tsc-references/globalThisAmbientModules.2.minified.js b/crates/swc/tests/tsc-references/globalThisAmbientModules.2.minified.js index 7895bcc8abe51..4dd7442246e0c 100644 --- a/crates/swc/tests/tsc-references/globalThisAmbientModules.2.minified.js +++ b/crates/swc/tests/tsc-references/globalThisAmbientModules.2.minified.js @@ -1,3 +1,11 @@ //// [globalThisAmbientModules.ts] -var valueModule; -(valueModule || (valueModule = {})).val = 1; +var valueModule, valueModule1, val; +valueModule1 = valueModule || (valueModule = {}), val = 1, Object.defineProperty(valueModule1, "val", { + enumerable: !0, + get: function() { + return val; + }, + set: function(v) { + val = v; + } +}); diff --git a/crates/swc/tests/tsc-references/implementingAnInterfaceExtendingClassWithPrivates2.1.normal.js b/crates/swc/tests/tsc-references/implementingAnInterfaceExtendingClassWithPrivates2.1.normal.js index 336f9d714396f..e6372c25b8b31 100644 --- a/crates/swc/tests/tsc-references/implementingAnInterfaceExtendingClassWithPrivates2.1.normal.js +++ b/crates/swc/tests/tsc-references/implementingAnInterfaceExtendingClassWithPrivates2.1.normal.js @@ -36,8 +36,8 @@ var Bar3 = /*#__PURE__*/ function(Foo) { } return Bar3; }(Foo); -// another level of indirection var M; +// another level of indirection (function(M) { var Foo = function Foo() { "use strict"; @@ -84,8 +84,8 @@ var M; return Bar3; }(Foo); })(M || (M = {})); -// two levels of privates var M2; +// two levels of privates (function(M2) { var Foo = function Foo() { "use strict"; diff --git a/crates/swc/tests/tsc-references/importImportOnlyModule.1.normal.js b/crates/swc/tests/tsc-references/importImportOnlyModule.1.normal.js index eff95e32065f5..604d348f6433e 100644 --- a/crates/swc/tests/tsc-references/importImportOnlyModule.1.normal.js +++ b/crates/swc/tests/tsc-references/importImportOnlyModule.1.normal.js @@ -26,9 +26,8 @@ define([ //// [foo_1.ts] define([ "require", - "exports", - "./foo_0" -], function(require, exports, _foo_0) { + "exports" +], function(require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true diff --git a/crates/swc/tests/tsc-references/importImportOnlyModule.2.minified.js b/crates/swc/tests/tsc-references/importImportOnlyModule.2.minified.js index 4f6b235d52e2b..b9299d974b172 100644 --- a/crates/swc/tests/tsc-references/importImportOnlyModule.2.minified.js +++ b/crates/swc/tests/tsc-references/importImportOnlyModule.2.minified.js @@ -20,9 +20,8 @@ define([ //// [foo_1.ts] define([ "require", - "exports", - "./foo_0" -], function(require, exports, _foo_0) { + "exports" +], function(require, exports) { Object.defineProperty(exports, "__esModule", { value: !0 }); diff --git a/crates/swc/tests/tsc-references/importNonExternalModule.1.normal.js b/crates/swc/tests/tsc-references/importNonExternalModule.1.normal.js index ec736189924f9..538233d6ecc98 100644 --- a/crates/swc/tests/tsc-references/importNonExternalModule.1.normal.js +++ b/crates/swc/tests/tsc-references/importNonExternalModule.1.normal.js @@ -5,7 +5,16 @@ define([ "use strict"; var foo; (function(foo) { - var answer = foo.answer = 42; + var answer = 42; + Object.defineProperty(foo, "answer", { + enumerable: true, + get: function get() { + return answer; + }, + set: function set(v) { + answer = v; + } + }); })(foo || (foo = {})); }); //// [foo_1.ts] diff --git a/crates/swc/tests/tsc-references/importNonExternalModule.2.minified.js b/crates/swc/tests/tsc-references/importNonExternalModule.2.minified.js index b9f0b096328b4..355b5b1f3bbb4 100644 --- a/crates/swc/tests/tsc-references/importNonExternalModule.2.minified.js +++ b/crates/swc/tests/tsc-references/importNonExternalModule.2.minified.js @@ -2,8 +2,16 @@ define([ "require" ], function(require) { - var foo; - (foo || (foo = {})).answer = 42; + var foo, foo1, answer; + foo1 = foo || (foo = {}), answer = 42, Object.defineProperty(foo1, "answer", { + enumerable: !0, + get: function() { + return answer; + }, + set: function(v) { + answer = v; + } + }); }); //// [foo_1.ts] define([ diff --git a/crates/swc/tests/tsc-references/importStatements.1.normal.js b/crates/swc/tests/tsc-references/importStatements.1.normal.js index cf96266af51af..73cc06f748167 100644 --- a/crates/swc/tests/tsc-references/importStatements.1.normal.js +++ b/crates/swc/tests/tsc-references/importStatements.1.normal.js @@ -9,10 +9,19 @@ var A; this.y = y; }; A.Point = Point; - var Origin = A.Origin = new Point(0, 0); + var Origin = new Point(0, 0); + Object.defineProperty(A, "Origin", { + enumerable: true, + get: function get() { + return Origin; + }, + set: function set(v) { + Origin = v; + } + }); })(A || (A = {})); -// no code gen expected var C; +// no code gen expected (function(C) { var m; var p; @@ -21,8 +30,8 @@ var C; y: 0 }; })(C || (C = {})); -// code gen expected var D; +// code gen expected (function(D) { var a = A; var p = new a.Point(1, 1); diff --git a/crates/swc/tests/tsc-references/importStatements.2.minified.js b/crates/swc/tests/tsc-references/importStatements.2.minified.js index 72fa124ea34be..09258c4c40b72 100644 --- a/crates/swc/tests/tsc-references/importStatements.2.minified.js +++ b/crates/swc/tests/tsc-references/importStatements.2.minified.js @@ -1,8 +1,16 @@ //// [importStatements.ts] -var A, C, D, E, A1, Point, E1, a; +var A, C, D, E, A1, Point, Origin, E1, a; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; A1 = A || (A = {}), Point = function Point(x, y) { _class_call_check(this, Point), this.x = x, this.y = y; -}, A1.Point = Point, A1.Origin = new Point(0, 0), C || (C = {}), D || (D = {}), new A.Point(1, 1), E1 = E || (E = {}), a = A, E1.xDist = function(x) { +}, A1.Point = Point, Origin = new Point(0, 0), Object.defineProperty(A1, "Origin", { + enumerable: !0, + get: function() { + return Origin; + }, + set: function(v) { + Origin = v; + } +}), C || (C = {}), D || (D = {}), new A.Point(1, 1), E1 = E || (E = {}), a = A, E1.xDist = function(x) { return a.Origin.x - x.x; }; diff --git a/crates/swc/tests/tsc-references/importStatementsInterfaces.1.normal.js b/crates/swc/tests/tsc-references/importStatementsInterfaces.1.normal.js index 7c8cc79db180e..e6e8b1326e2df 100644 --- a/crates/swc/tests/tsc-references/importStatementsInterfaces.1.normal.js +++ b/crates/swc/tests/tsc-references/importStatementsInterfaces.1.normal.js @@ -1,7 +1,8 @@ //// [importStatementsInterfaces.ts] -// no code gen expected var C; +// no code gen expected (function(C) { + var a = A; var m; var p; var p = { @@ -10,13 +11,13 @@ var C; z: 0 }; })(C || (C = {})); -// no code gen expected var D; +// no code gen expected (function(D) { var p; })(D || (D = {})); -// no code gen expected var E; +// no code gen expected (function(E) { var xDist = function xDist(x) { return 0 - x.x; diff --git a/crates/swc/tests/tsc-references/importStatementsInterfaces.2.minified.js b/crates/swc/tests/tsc-references/importStatementsInterfaces.2.minified.js index 4334d5daa9d86..e5f6534008e4d 100644 --- a/crates/swc/tests/tsc-references/importStatementsInterfaces.2.minified.js +++ b/crates/swc/tests/tsc-references/importStatementsInterfaces.2.minified.js @@ -1,5 +1,5 @@ //// [importStatementsInterfaces.ts] var C, D, E; -C || (C = {}), D || (D = {}), (E || (E = {})).xDist = function(x) { +C || (C = {}), A, D || (D = {}), (E || (E = {})).xDist = function(x) { return 0 - x.x; }; diff --git a/crates/swc/tests/tsc-references/importsNotUsedAsValues_error.1.normal.js b/crates/swc/tests/tsc-references/importsNotUsedAsValues_error.1.normal.js index 629cd1ca51155..9cb9012a09b82 100644 --- a/crates/swc/tests/tsc-references/importsNotUsedAsValues_error.1.normal.js +++ b/crates/swc/tests/tsc-references/importsNotUsedAsValues_error.1.normal.js @@ -19,12 +19,12 @@ export var C; var a; var b; console.log(a, b); -export { }; +export { }; // Error //// [/c.ts] var a; var b; console.log(a, b); -export { }; +export { }; // Error //// [/d.ts] import { A } from "./a"; var a = A; @@ -53,22 +53,11 @@ export { }; //! 3 | //! `---- //// [/i.ts] -//! -//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. -//! ,-[1:1] -//! 1 | import H = require('./h'); // Error -//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^ -//! 2 | let h: H = {}; -//! 3 | console.log(h); -//! `---- +var h = {}; +console.log(h); +export { }; // Error //// [/j.ts] -//! -//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. -//! ,-[1:1] -//! 1 | import H = require('./h'); // noUnusedLocals error only -//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^ -//! 2 | -//! `---- +export { }; // noUnusedLocals error only //// [/k.ts] //! //! x Export assignment cannot be used when targeting ECMAScript modules. Consider using `export default` or another module format instead. diff --git a/crates/swc/tests/tsc-references/importsNotUsedAsValues_error.2.minified.js b/crates/swc/tests/tsc-references/importsNotUsedAsValues_error.2.minified.js index e3592a8523dde..e1efdfce3d6d3 100644 --- a/crates/swc/tests/tsc-references/importsNotUsedAsValues_error.2.minified.js +++ b/crates/swc/tests/tsc-references/importsNotUsedAsValues_error.2.minified.js @@ -39,22 +39,11 @@ export { }; //! 3 | //! `---- //// [/i.ts] -//! -//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. -//! ,-[1:1] -//! 1 | import H = require('./h'); // Error -//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^ -//! 2 | let h: H = {}; -//! 3 | console.log(h); -//! `---- +console.log({}); +export { }; //// [/j.ts] -//! -//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. -//! ,-[1:1] -//! 1 | import H = require('./h'); // noUnusedLocals error only -//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^ -//! 2 | -//! `---- +export { }; + // noUnusedLocals error only //// [/k.ts] //! //! x Export assignment cannot be used when targeting ECMAScript modules. Consider using `export default` or another module format instead. diff --git a/crates/swc/tests/tsc-references/incrementOperatorWithAnyOtherType.1.normal.js b/crates/swc/tests/tsc-references/incrementOperatorWithAnyOtherType.1.normal.js index f0f431fec2f59..9256f0aa81200 100644 --- a/crates/swc/tests/tsc-references/incrementOperatorWithAnyOtherType.1.normal.js +++ b/crates/swc/tests/tsc-references/incrementOperatorWithAnyOtherType.1.normal.js @@ -18,7 +18,15 @@ var A = function A() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // any type var diff --git a/crates/swc/tests/tsc-references/incrementOperatorWithAnyOtherType.2.minified.js b/crates/swc/tests/tsc-references/incrementOperatorWithAnyOtherType.2.minified.js index f732c12da0074..ed4bf66512754 100644 --- a/crates/swc/tests/tsc-references/incrementOperatorWithAnyOtherType.2.minified.js +++ b/crates/swc/tests/tsc-references/incrementOperatorWithAnyOtherType.2.minified.js @@ -8,7 +8,15 @@ var n, ANY, ANY1, M, ANY2 = [ x: 1, y: null }; -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new function A() { _class_call_check(this, A); }(); diff --git a/crates/swc/tests/tsc-references/incrementOperatorWithNumberType.1.normal.js b/crates/swc/tests/tsc-references/incrementOperatorWithNumberType.1.normal.js index 71e0265c990ee..17ea254cebfa1 100644 --- a/crates/swc/tests/tsc-references/incrementOperatorWithNumberType.1.normal.js +++ b/crates/swc/tests/tsc-references/incrementOperatorWithNumberType.1.normal.js @@ -13,7 +13,15 @@ var A = function A() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // number type var diff --git a/crates/swc/tests/tsc-references/incrementOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/incrementOperatorWithNumberType.2.minified.js index a345a09a1838d..810aac06b0d42 100644 --- a/crates/swc/tests/tsc-references/incrementOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/incrementOperatorWithNumberType.2.minified.js @@ -5,7 +5,15 @@ var n, NUMBER, M, NUMBER1 = [ 1, 2 ]; -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new function A() { _class_call_check(this, A); }(); diff --git a/crates/swc/tests/tsc-references/instantiatedModule.1.normal.js b/crates/swc/tests/tsc-references/instantiatedModule.1.normal.js index f66f1aa39baf2..ac29226099917 100644 --- a/crates/swc/tests/tsc-references/instantiatedModule.1.normal.js +++ b/crates/swc/tests/tsc-references/instantiatedModule.1.normal.js @@ -3,7 +3,16 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var M; (function(M) { - var Point = M.Point = 1; + var Point = 1; + Object.defineProperty(M, "Point", { + enumerable: true, + get: function get() { + return Point; + }, + set: function set(v) { + Point = v; + } + }); })(M || (M = {})); // primary expression var m; @@ -13,9 +22,9 @@ var a1 = M.Point; var a1 = m.Point; var p1; var p1; +var M2; // making the point a class instead of an interface // makes this an instantiated mmodule -var M2; (function(M2) { var Point = /*#__PURE__*/ function() { "use strict"; diff --git a/crates/swc/tests/tsc-references/instantiatedModule.2.minified.js b/crates/swc/tests/tsc-references/instantiatedModule.2.minified.js index b220241cce07a..6aacca38618db 100644 --- a/crates/swc/tests/tsc-references/instantiatedModule.2.minified.js +++ b/crates/swc/tests/tsc-references/instantiatedModule.2.minified.js @@ -1,9 +1,17 @@ //// [instantiatedModule.ts] // adding the var makes this an instantiated module import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(M || (M = {})).Point = 1; -var M2, Point, M3, Color, M, M21, m2, a2, M31, m3, a3, m = M; -M.Point, m.Point, M2 = M21 || (M21 = {}), Point = function() { +M = M1 || (M1 = {}), Point1 = 1, Object.defineProperty(M, "Point", { + enumerable: !0, + get: function() { + return Point1; + }, + set: function(v) { + Point1 = v; + } +}); +var M2, Point, M3, Color, M, Point1, M1, M21, m2, a2, M31, m3, a3, m = M1; +M1.Point, m.Point, M2 = M21 || (M21 = {}), Point = function() { function Point() { _class_call_check(this, Point); } diff --git a/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersection.1.normal.js b/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersection.1.normal.js index f8c37a97329cd..187326acd7ab0 100644 --- a/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersection.1.normal.js +++ b/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersection.1.normal.js @@ -72,12 +72,6 @@ var C7 = /*#__PURE__*/ function(_Constructor) { } return C7; }(Constructor()); -var EX; -(function(EX) { - EX[EX["A"] = 0] = "A"; - EX[EX["B"] = 1] = "B"; - EX[EX["C"] = 2] = "C"; -})(EX || (EX = {})); var C20 = /*#__PURE__*/ function(_Constructor) { "use strict"; _inherits(C20, _Constructor); diff --git a/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersection.2.minified.js b/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersection.2.minified.js index 5d6b7048caf29..60786ebc45ad6 100644 --- a/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersection.2.minified.js +++ b/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersection.2.minified.js @@ -1,6 +1,5 @@ //// [interfaceExtendsObjectIntersection.ts] -var EX, EX1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -Constructor(), Constructor(), Constructor(), Constructor(), Constructor(), Constructor(), Constructor(), (EX1 = EX || (EX = {}))[EX1.A = 0] = "A", EX1[EX1.B = 1] = "B", EX1[EX1.C = 2] = "C", Constructor(), Constructor(), Constructor(), Constructor(); +Constructor(), Constructor(), Constructor(), Constructor(), Constructor(), Constructor(), Constructor(), Constructor(), Constructor(), Constructor(), Constructor(); diff --git a/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersectionErrors.1.normal.js b/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersectionErrors.1.normal.js index 6f71556e6b7f1..95f733f6861f0 100644 --- a/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersectionErrors.1.normal.js +++ b/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersectionErrors.1.normal.js @@ -52,9 +52,3 @@ var C5 = /*#__PURE__*/ function(_Constructor) { } return C5; }(Constructor()); -var EX; -(function(EX) { - EX[EX["A"] = 0] = "A"; - EX[EX["B"] = 1] = "B"; - EX[EX["C"] = 2] = "C"; -})(EX || (EX = {})); diff --git a/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersectionErrors.2.minified.js b/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersectionErrors.2.minified.js index 31d38693bf89c..4bb15f1b3e719 100644 --- a/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersectionErrors.2.minified.js +++ b/crates/swc/tests/tsc-references/interfaceExtendsObjectIntersectionErrors.2.minified.js @@ -1,6 +1,5 @@ //// [interfaceExtendsObjectIntersectionErrors.ts] -var EX, EX1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -Constructor(), Constructor(), Constructor(), Constructor(), Constructor(), (EX1 = EX || (EX = {}))[EX1.A = 0] = "A", EX1[EX1.B = 1] = "B", EX1[EX1.C = 2] = "C"; +Constructor(), Constructor(), Constructor(), Constructor(), Constructor(); diff --git a/crates/swc/tests/tsc-references/interfaceWithPropertyOfEveryType.1.normal.js b/crates/swc/tests/tsc-references/interfaceWithPropertyOfEveryType.1.normal.js index bd47145143c67..0f1b99819d361 100644 --- a/crates/swc/tests/tsc-references/interfaceWithPropertyOfEveryType.1.normal.js +++ b/crates/swc/tests/tsc-references/interfaceWithPropertyOfEveryType.1.normal.js @@ -7,7 +7,16 @@ var C = function C() { function f1() {} var M; (function(M) { - var y = M.y = 1; + var y = 1; + Object.defineProperty(M, "y", { + enumerable: true, + get: function get() { + return y; + }, + set: function set(v) { + y = v; + } + }); })(M || (M = {})); var E; (function(E) { @@ -34,5 +43,5 @@ var a = { l: f1, m: M, n: {}, - o: E.A + o: 0 }; diff --git a/crates/swc/tests/tsc-references/interfaceWithPropertyOfEveryType.2.minified.js b/crates/swc/tests/tsc-references/interfaceWithPropertyOfEveryType.2.minified.js index 08f066e328899..9ddd56d10b5fc 100644 --- a/crates/swc/tests/tsc-references/interfaceWithPropertyOfEveryType.2.minified.js +++ b/crates/swc/tests/tsc-references/interfaceWithPropertyOfEveryType.2.minified.js @@ -1,6 +1,14 @@ //// [interfaceWithPropertyOfEveryType.ts] -var M, E, E1; +var M, E, M1, y, E1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(M || (M = {})).y = 1, (E1 = E || (E = {}))[E1.A = 0] = "A", new function C() { +M1 = M || (M = {}), y = 1, Object.defineProperty(M1, "y", { + enumerable: !0, + get: function() { + return y; + }, + set: function(v) { + y = v; + } +}), (E1 = E || (E = {}))[E1.A = 0] = "A", new function C() { _class_call_check(this, C); -}(), E.A; +}(); diff --git a/crates/swc/tests/tsc-references/intersectionOfUnionOfUnitTypes.1.normal.js b/crates/swc/tests/tsc-references/intersectionOfUnionOfUnitTypes.1.normal.js index 195277e15158a..9a7092b9d7b19 100644 --- a/crates/swc/tests/tsc-references/intersectionOfUnionOfUnitTypes.1.normal.js +++ b/crates/swc/tests/tsc-references/intersectionOfUnionOfUnitTypes.1.normal.js @@ -1,14 +1,6 @@ //// [intersectionOfUnionOfUnitTypes.ts] // @strict var E; -(function(E) { - E[E["A"] = 0] = "A"; - E[E["B"] = 1] = "B"; - E[E["C"] = 2] = "C"; - E[E["D"] = 3] = "D"; - E[E["E"] = 4] = "E"; - E[E["F"] = 5] = "F"; -})(E || (E = {})); var x0; // 'a' | 'b' | 'c' var x1; // 'b' | 'c' var x2; // 'c' diff --git a/crates/swc/tests/tsc-references/intersectionOfUnionOfUnitTypes.2.minified.js b/crates/swc/tests/tsc-references/intersectionOfUnionOfUnitTypes.2.minified.js index 25202516cdfdf..7231612f21c20 100644 --- a/crates/swc/tests/tsc-references/intersectionOfUnionOfUnitTypes.2.minified.js +++ b/crates/swc/tests/tsc-references/intersectionOfUnionOfUnitTypes.2.minified.js @@ -1,5 +1,3 @@ //// [intersectionOfUnionOfUnitTypes.ts] // @strict -var E, E1; -(E1 = E || (E = {}))[E1.A = 0] = "A", E1[E1.B = 1] = "B", E1[E1.C = 2] = "C", E1[E1.D = 3] = "D", E1[E1.E = 4] = "E", E1[E1.F = 5] = "F"; // never diff --git a/crates/swc/tests/tsc-references/intersectionReduction.1.normal.js b/crates/swc/tests/tsc-references/intersectionReduction.1.normal.js index 25a4ac9475bf5..9f534d2dba821 100644 --- a/crates/swc/tests/tsc-references/intersectionReduction.1.normal.js +++ b/crates/swc/tests/tsc-references/intersectionReduction.1.normal.js @@ -15,9 +15,7 @@ var x2 = { x1[k] = "bar"; // Error x2[k] = "bar"; // Error var Tag1; -(function(Tag1) {})(Tag1 || (Tag1 = {})); var Tag2; -(function(Tag2) {})(Tag2 || (Tag2 = {})); s1 = s2; s2 = s1; t1 = t2; diff --git a/crates/swc/tests/tsc-references/intersectionReduction.2.minified.js b/crates/swc/tests/tsc-references/intersectionReduction.2.minified.js index 1844f7c8e057c..11ff2cc1b3bdc 100644 --- a/crates/swc/tests/tsc-references/intersectionReduction.2.minified.js +++ b/crates/swc/tests/tsc-references/intersectionReduction.2.minified.js @@ -1,10 +1,8 @@ //// [intersectionReduction.ts] -// Repro from #31663 -var Tag1, Tag2; ab.kind, x, f10(a1), f10(a2), ({ a: "foo", b: 42 })[k] = "bar", ({ a: "foo", b: !0 -})[k] = "bar", Tag1 || (Tag1 = {}), Tag2 || (Tag2 = {}), s2 = s1 = s2, t2 = t1 = t2, shouldBeB; +})[k] = "bar", s2 = s1 = s2, t2 = t1 = t2, shouldBeB; diff --git a/crates/swc/tests/tsc-references/intersectionReductionStrict.1.normal.js b/crates/swc/tests/tsc-references/intersectionReductionStrict.1.normal.js index 105053a6377d8..3bf7c326c4775 100644 --- a/crates/swc/tests/tsc-references/intersectionReductionStrict.1.normal.js +++ b/crates/swc/tests/tsc-references/intersectionReductionStrict.1.normal.js @@ -13,9 +13,7 @@ var x2 = { x1[k] = "bar"; // Error x2[k] = "bar"; // Error var Tag1; -(function(Tag1) {})(Tag1 || (Tag1 = {})); var Tag2; -(function(Tag2) {})(Tag2 || (Tag2 = {})); s1 = s2; s2 = s1; t1 = t2; diff --git a/crates/swc/tests/tsc-references/intersectionReductionStrict.2.minified.js b/crates/swc/tests/tsc-references/intersectionReductionStrict.2.minified.js index 43571f2e98a4d..2f62f1ee3b591 100644 --- a/crates/swc/tests/tsc-references/intersectionReductionStrict.2.minified.js +++ b/crates/swc/tests/tsc-references/intersectionReductionStrict.2.minified.js @@ -1,10 +1,8 @@ //// [intersectionReductionStrict.ts] -// Repro from #31663 -var Tag1, Tag2; ab.kind, x, ({ a: "foo", b: 42 })[k] = "bar", ({ a: "foo", b: !0 -})[k] = "bar", Tag1 || (Tag1 = {}), Tag2 || (Tag2 = {}), s2 = s1 = s2, t2 = t1 = t2; +})[k] = "bar", s2 = s1 = s2, t2 = t1 = t2; diff --git a/crates/swc/tests/tsc-references/invalidAssignmentsToVoid.1.normal.js b/crates/swc/tests/tsc-references/invalidAssignmentsToVoid.1.normal.js index db7cdbb3cf3fd..2fe62b5ce277d 100644 --- a/crates/swc/tests/tsc-references/invalidAssignmentsToVoid.1.normal.js +++ b/crates/swc/tests/tsc-references/invalidAssignmentsToVoid.1.normal.js @@ -16,7 +16,16 @@ var i; x = i; var M; (function(M) { - var x = M.x = 1; + var x = 1; + Object.defineProperty(M, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(M || (M = {})); x = M; function f(a) { diff --git a/crates/swc/tests/tsc-references/invalidAssignmentsToVoid.2.minified.js b/crates/swc/tests/tsc-references/invalidAssignmentsToVoid.2.minified.js index 7335125b9563e..d76494cacbaba 100644 --- a/crates/swc/tests/tsc-references/invalidAssignmentsToVoid.2.minified.js +++ b/crates/swc/tests/tsc-references/invalidAssignmentsToVoid.2.minified.js @@ -1,4 +1,12 @@ //// [invalidAssignmentsToVoid.ts] -var M; +var M, M1, x; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(M || (M = {})).x = 1; +M1 = M || (M = {}), x = 1, Object.defineProperty(M1, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}); diff --git a/crates/swc/tests/tsc-references/invalidBooleanAssignments.1.normal.js b/crates/swc/tests/tsc-references/invalidBooleanAssignments.1.normal.js index c45dcbe6724cb..fc6bbdf5d871a 100644 --- a/crates/swc/tests/tsc-references/invalidBooleanAssignments.1.normal.js +++ b/crates/swc/tests/tsc-references/invalidBooleanAssignments.1.normal.js @@ -20,7 +20,16 @@ var h = x; var h2 = x; // no error var M; (function(M) { - var a = M.a = 1; + var a = 1; + Object.defineProperty(M, "a", { + enumerable: true, + get: function get() { + return a; + }, + set: function set(v) { + a = v; + } + }); })(M || (M = {})); M = x; function i(a) { diff --git a/crates/swc/tests/tsc-references/invalidBooleanAssignments.2.minified.js b/crates/swc/tests/tsc-references/invalidBooleanAssignments.2.minified.js index 8068d7d74b21c..76515f566cd84 100644 --- a/crates/swc/tests/tsc-references/invalidBooleanAssignments.2.minified.js +++ b/crates/swc/tests/tsc-references/invalidBooleanAssignments.2.minified.js @@ -1,4 +1,12 @@ //// [invalidBooleanAssignments.ts] -var E, M, E1; +var E, M, E1, M1, a; import "@swc/helpers/_/_class_call_check"; -(E1 = E || (E = {}))[E1.A = 0] = "A", (M || (M = {})).a = 1; +(E1 = E || (E = {}))[E1.A = 0] = "A", M1 = M || (M = {}), a = 1, Object.defineProperty(M1, "a", { + enumerable: !0, + get: function() { + return a; + }, + set: function(v) { + a = v; + } +}); diff --git a/crates/swc/tests/tsc-references/invalidEnumAssignments.1.normal.js b/crates/swc/tests/tsc-references/invalidEnumAssignments.1.normal.js index 96b3c91855c7b..82355927bd047 100644 --- a/crates/swc/tests/tsc-references/invalidEnumAssignments.1.normal.js +++ b/crates/swc/tests/tsc-references/invalidEnumAssignments.1.normal.js @@ -11,8 +11,8 @@ var E2; })(E2 || (E2 = {})); var e; var e2; -e = E2.A; -e2 = E.A; +e = 0; +e2 = 0; e = null; e = {}; e = ""; diff --git a/crates/swc/tests/tsc-references/invalidEnumAssignments.2.minified.js b/crates/swc/tests/tsc-references/invalidEnumAssignments.2.minified.js index 0ad729ccba2cf..b609812f2af59 100644 --- a/crates/swc/tests/tsc-references/invalidEnumAssignments.2.minified.js +++ b/crates/swc/tests/tsc-references/invalidEnumAssignments.2.minified.js @@ -1,3 +1,3 @@ //// [invalidEnumAssignments.ts] var E, E2, E1, E21; -(E1 = E || (E = {}))[E1.A = 0] = "A", E1[E1.B = 1] = "B", (E21 = E2 || (E2 = {}))[E21.A = 0] = "A", E21[E21.B = 1] = "B", E2.A, E.A; +(E1 = E || (E = {}))[E1.A = 0] = "A", E1[E1.B = 1] = "B", (E21 = E2 || (E2 = {}))[E21.A = 0] = "A", E21[E21.B = 1] = "B"; diff --git a/crates/swc/tests/tsc-references/invalidNestedModules.1.normal.js b/crates/swc/tests/tsc-references/invalidNestedModules.1.normal.js index 4c0868328f0a6..bbf02b89c7816 100644 --- a/crates/swc/tests/tsc-references/invalidNestedModules.1.normal.js +++ b/crates/swc/tests/tsc-references/invalidNestedModules.1.normal.js @@ -2,17 +2,15 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var A; (function(A) { - var B; (function(B) { - var C; (function(C) { var Point = function Point() { "use strict"; _class_call_check(this, Point); }; C.Point = Point; - })(C = B.C || (B.C = {})); - })(B = A.B || (A.B = {})); + })(B.C || (B.C = {})); + })(A.B || (A.B = {})); })(A || (A = {})); (function(A) { var B; @@ -26,19 +24,26 @@ var A; })(A || (A = {})); var M2; (function(M2) { - var X; (function(X) { var Point = function Point() { "use strict"; _class_call_check(this, Point); }; X.Point = Point; - })(X = M2.X || (M2.X = {})); + })(M2.X || (M2.X = {})); })(M2 || (M2 = {})); (function(M2) { var X; (function(X) { - var Point; - X.Point = Point; + var Point; // Error + Object.defineProperty(X, "Point", { + enumerable: true, + get: function get() { + return Point; + }, + set: function set(v) { + Point = v; + } + }); })(X = M2.X || (M2.X = {})); })(M2 || (M2 = {})); diff --git a/crates/swc/tests/tsc-references/invalidNestedModules.2.minified.js b/crates/swc/tests/tsc-references/invalidNestedModules.2.minified.js index b2c02998be2c3..0904c1f4b49cf 100644 --- a/crates/swc/tests/tsc-references/invalidNestedModules.2.minified.js +++ b/crates/swc/tests/tsc-references/invalidNestedModules.2.minified.js @@ -7,4 +7,12 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; _class_call_check(this, C); }, ((M21 = M2 || (M2 = {})).X || (M21.X = {})).Point = function Point() { _class_call_check(this, Point); -}, ((M22 = M2 || (M2 = {})).X || (M22.X = {})).Point = Point; +}, Object.defineProperty((M22 = M2 || (M2 = {})).X || (M22.X = {}), "Point", { + enumerable: !0, + get: function() { + return Point; + }, + set: function(v) { + Point = v; + } +}); diff --git a/crates/swc/tests/tsc-references/invalidNumberAssignments.1.normal.js b/crates/swc/tests/tsc-references/invalidNumberAssignments.1.normal.js index 4b27f79f93361..d35e71de7d724 100644 --- a/crates/swc/tests/tsc-references/invalidNumberAssignments.1.normal.js +++ b/crates/swc/tests/tsc-references/invalidNumberAssignments.1.normal.js @@ -15,7 +15,16 @@ var g = 1; var g2 = 1; var M; (function(M) { - var x = M.x = 1; + var x = 1; + Object.defineProperty(M, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(M || (M = {})); M = x; function i(a) { diff --git a/crates/swc/tests/tsc-references/invalidNumberAssignments.2.minified.js b/crates/swc/tests/tsc-references/invalidNumberAssignments.2.minified.js index 7f7e5f5b7e6dc..d2663cef358b2 100644 --- a/crates/swc/tests/tsc-references/invalidNumberAssignments.2.minified.js +++ b/crates/swc/tests/tsc-references/invalidNumberAssignments.2.minified.js @@ -1,4 +1,12 @@ //// [invalidNumberAssignments.ts] -var M; +var M, M1, x; import "@swc/helpers/_/_class_call_check"; -(M || (M = {})).x = 1; +M1 = M || (M = {}), x = 1, Object.defineProperty(M1, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}); diff --git a/crates/swc/tests/tsc-references/invalidStringAssignments.1.normal.js b/crates/swc/tests/tsc-references/invalidStringAssignments.1.normal.js index b43141ee22d9e..b175aba3702a2 100644 --- a/crates/swc/tests/tsc-references/invalidStringAssignments.1.normal.js +++ b/crates/swc/tests/tsc-references/invalidStringAssignments.1.normal.js @@ -15,7 +15,16 @@ var g = 1; var g2 = 1; var M; (function(M) { - var x = M.x = 1; + var x = 1; + Object.defineProperty(M, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(M || (M = {})); M = x; function i(a) { diff --git a/crates/swc/tests/tsc-references/invalidStringAssignments.2.minified.js b/crates/swc/tests/tsc-references/invalidStringAssignments.2.minified.js index 2c37840dfc8c3..485b6940f89bf 100644 --- a/crates/swc/tests/tsc-references/invalidStringAssignments.2.minified.js +++ b/crates/swc/tests/tsc-references/invalidStringAssignments.2.minified.js @@ -1,4 +1,12 @@ //// [invalidStringAssignments.ts] -var M, E, E1; +var M, E, M1, x, E1; import "@swc/helpers/_/_class_call_check"; -(M || (M = {})).x = 1, M = "", (E1 = E || (E = {}))[E1.A = 0] = "A"; +M1 = M || (M = {}), x = 1, Object.defineProperty(M1, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}), M = "", (E1 = E || (E = {}))[E1.A = 0] = "A"; diff --git a/crates/swc/tests/tsc-references/invalidUndefinedAssignments.1.normal.js b/crates/swc/tests/tsc-references/invalidUndefinedAssignments.1.normal.js index 322105ef0dc96..3084ea6a2a5f4 100644 --- a/crates/swc/tests/tsc-references/invalidUndefinedAssignments.1.normal.js +++ b/crates/swc/tests/tsc-references/invalidUndefinedAssignments.1.normal.js @@ -18,7 +18,16 @@ g = x; I = x; var M; (function(M) { - var x = M.x = 1; + var x = 1; + Object.defineProperty(M, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(M || (M = {})); M = x; function i(a) {} diff --git a/crates/swc/tests/tsc-references/invalidUndefinedAssignments.2.minified.js b/crates/swc/tests/tsc-references/invalidUndefinedAssignments.2.minified.js index 4d9a881b167cf..f3d176f7ad2a6 100644 --- a/crates/swc/tests/tsc-references/invalidUndefinedAssignments.2.minified.js +++ b/crates/swc/tests/tsc-references/invalidUndefinedAssignments.2.minified.js @@ -1,4 +1,12 @@ //// [invalidUndefinedAssignments.ts] -var x, E, M, E1; +var x, E, M, E1, M1, x1; import "@swc/helpers/_/_class_call_check"; -(E1 = E || (E = {}))[E1.A = 0] = "A", (E = x).A = x, I = x, (M || (M = {})).x = 1; +(E1 = E || (E = {}))[E1.A = 0] = "A", (E = x).A = x, I = x, M1 = M || (M = {}), x1 = 1, Object.defineProperty(M1, "x", { + enumerable: !0, + get: function() { + return x1; + }, + set: function(v) { + x1 = v; + } +}); diff --git a/crates/swc/tests/tsc-references/invalidUndefinedValues.1.normal.js b/crates/swc/tests/tsc-references/invalidUndefinedValues.1.normal.js index aa6dea3b5572c..e34b11769200b 100644 --- a/crates/swc/tests/tsc-references/invalidUndefinedValues.1.normal.js +++ b/crates/swc/tests/tsc-references/invalidUndefinedValues.1.normal.js @@ -18,7 +18,16 @@ var c; x = c; var M; (function(M) { - var x = M.x = 1; + var x = 1; + Object.defineProperty(M, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(M || (M = {})); x = M; x = { @@ -33,4 +42,4 @@ var E; E[E["A"] = 0] = "A"; })(E || (E = {})); x = E; -x = E.A; +x = 0; diff --git a/crates/swc/tests/tsc-references/invalidUndefinedValues.2.minified.js b/crates/swc/tests/tsc-references/invalidUndefinedValues.2.minified.js index c7598ba951935..d81304d369d55 100644 --- a/crates/swc/tests/tsc-references/invalidUndefinedValues.2.minified.js +++ b/crates/swc/tests/tsc-references/invalidUndefinedValues.2.minified.js @@ -1,4 +1,12 @@ //// [invalidUndefinedValues.ts] -var M, E, E1; +var M, E, M1, x, E1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(M || (M = {})).x = 1, (E1 = E || (E = {}))[E1.A = 0] = "A", E.A; +M1 = M || (M = {}), x = 1, Object.defineProperty(M1, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}), (E1 = E || (E = {}))[E1.A = 0] = "A"; diff --git a/crates/swc/tests/tsc-references/invalidVoidAssignments.1.normal.js b/crates/swc/tests/tsc-references/invalidVoidAssignments.1.normal.js index 79af5d8fc27bd..928a83f1d8b53 100644 --- a/crates/swc/tests/tsc-references/invalidVoidAssignments.1.normal.js +++ b/crates/swc/tests/tsc-references/invalidVoidAssignments.1.normal.js @@ -15,7 +15,16 @@ var g = 1; var g2 = 1; var M; (function(M) { - var x = M.x = 1; + var x = 1; + Object.defineProperty(M, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(M || (M = {})); M = x; function i(a) { @@ -27,7 +36,7 @@ var E; E[E["A"] = 0] = "A"; })(E || (E = {})); x = E; -x = E.A; +x = 0; x = { f: function f() {} }; diff --git a/crates/swc/tests/tsc-references/invalidVoidAssignments.2.minified.js b/crates/swc/tests/tsc-references/invalidVoidAssignments.2.minified.js index e1df8a69b9587..ed41cdf1fb7d3 100644 --- a/crates/swc/tests/tsc-references/invalidVoidAssignments.2.minified.js +++ b/crates/swc/tests/tsc-references/invalidVoidAssignments.2.minified.js @@ -1,4 +1,12 @@ //// [invalidVoidAssignments.ts] -var x, M, E, E1; +var x, M, E, M1, x1, E1; import "@swc/helpers/_/_class_call_check"; -(M || (M = {})).x = 1, M = x, (E1 = E || (E = {}))[E1.A = 0] = "A", x = E, x = E.A; +M1 = M || (M = {}), x1 = 1, Object.defineProperty(M1, "x", { + enumerable: !0, + get: function() { + return x1; + }, + set: function(v) { + x1 = v; + } +}), M = x, (E1 = E || (E = {}))[E1.A = 0] = "A"; diff --git a/crates/swc/tests/tsc-references/invalidVoidValues.1.normal.js b/crates/swc/tests/tsc-references/invalidVoidValues.1.normal.js index 53d7e8fa01e42..f4294f39b3f4f 100644 --- a/crates/swc/tests/tsc-references/invalidVoidValues.1.normal.js +++ b/crates/swc/tests/tsc-references/invalidVoidValues.1.normal.js @@ -9,7 +9,7 @@ var E; E[E["A"] = 0] = "A"; })(E || (E = {})); x = E; -x = E.A; +x = 0; var C = function C() { "use strict"; _class_call_check(this, C); @@ -23,7 +23,16 @@ x = { }; var M; (function(M) { - var x = M.x = 1; + var x = 1; + Object.defineProperty(M, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(M || (M = {})); x = M; function f(a) { diff --git a/crates/swc/tests/tsc-references/invalidVoidValues.2.minified.js b/crates/swc/tests/tsc-references/invalidVoidValues.2.minified.js index eaa88fbe04afb..d438c7c7c53f3 100644 --- a/crates/swc/tests/tsc-references/invalidVoidValues.2.minified.js +++ b/crates/swc/tests/tsc-references/invalidVoidValues.2.minified.js @@ -1,4 +1,12 @@ //// [invalidVoidValues.ts] -var E, M, E1; +var E, M, E1, M1, x; import "@swc/helpers/_/_class_call_check"; -(E1 = E || (E = {}))[E1.A = 0] = "A", E.A, (M || (M = {})).x = 1; +(E1 = E || (E = {}))[E1.A = 0] = "A", M1 = M || (M = {}), x = 1, Object.defineProperty(M1, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}); diff --git a/crates/swc/tests/tsc-references/jsDeclarationsTypeReferences4.1.normal.js b/crates/swc/tests/tsc-references/jsDeclarationsTypeReferences4.1.normal.js index ad51b30175591..10ced191f73da 100644 --- a/crates/swc/tests/tsc-references/jsDeclarationsTypeReferences4.1.normal.js +++ b/crates/swc/tests/tsc-references/jsDeclarationsTypeReferences4.1.normal.js @@ -1,13 +1,13 @@ //// [node_modules/@types/node/index.d.ts] //// [index.js] -/// -export var Something = 2; // to show conflict that can occur -// @ts-ignore -export var A; -(function(A) { - var B; - (function(B) { - var Something = require("fs").Something; - var thing = new Something(); - })(B = A.B || (A.B = {})); -})(A || (A = {})); +//! +//! x ESM-style module declarations are not permitted in a namespace. +//! ,-[7:1] +//! 7 | const Something = require("fs").Something; +//! 8 | const thing = new Something(); +//! 9 | // @ts-ignore +//! 10 | export { thing }; +//! : ^^^^^^^^^^^^^^^^^ +//! 11 | } +//! 12 | } +//! `---- diff --git a/crates/swc/tests/tsc-references/jsDeclarationsTypeReferences4.2.minified.js b/crates/swc/tests/tsc-references/jsDeclarationsTypeReferences4.2.minified.js index acb4545ff9ed4..10ced191f73da 100644 --- a/crates/swc/tests/tsc-references/jsDeclarationsTypeReferences4.2.minified.js +++ b/crates/swc/tests/tsc-references/jsDeclarationsTypeReferences4.2.minified.js @@ -1,9 +1,13 @@ //// [node_modules/@types/node/index.d.ts] //// [index.js] -/// -var A; -export var Something = 2; // to show conflict that can occur -var A1; -// @ts-ignore -export { A1 as A }; -(A = A1 || (A1 = {})).B || (A.B = {}), new (require("fs")).Something(); +//! +//! x ESM-style module declarations are not permitted in a namespace. +//! ,-[7:1] +//! 7 | const Something = require("fs").Something; +//! 8 | const thing = new Something(); +//! 9 | // @ts-ignore +//! 10 | export { thing }; +//! : ^^^^^^^^^^^^^^^^^ +//! 11 | } +//! 12 | } +//! `---- diff --git a/crates/swc/tests/tsc-references/keyofAndIndexedAccess.1.normal.js b/crates/swc/tests/tsc-references/keyofAndIndexedAccess.1.normal.js index 203050717d4d6..78f21fcc86360 100644 --- a/crates/swc/tests/tsc-references/keyofAndIndexedAccess.1.normal.js +++ b/crates/swc/tests/tsc-references/keyofAndIndexedAccess.1.normal.js @@ -25,11 +25,6 @@ var Options = function Options() { _class_call_check(this, Options); }; var E; -(function(E) { - E[E["A"] = 0] = "A"; - E[E["B"] = 1] = "B"; - E[E["C"] = 2] = "C"; -})(E || (E = {})); function getProperty(obj, key) { return obj[key]; } diff --git a/crates/swc/tests/tsc-references/keyofAndIndexedAccess.2.minified.js b/crates/swc/tests/tsc-references/keyofAndIndexedAccess.2.minified.js index 7b835e951dbca..54f3632516f5a 100644 --- a/crates/swc/tests/tsc-references/keyofAndIndexedAccess.2.minified.js +++ b/crates/swc/tests/tsc-references/keyofAndIndexedAccess.2.minified.js @@ -1,9 +1,9 @@ //// [keyofAndIndexedAccess.ts] -var E, Flag, E1, Flag1; +var Flag, Flag1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -(E1 = E || (E = {}))[E1.A = 0] = "A", E1[E1.B = 1] = "B", E1[E1.C = 2] = "C", one(function() {}) // inferred as {}, expected +one(function() {}) // inferred as {}, expected , on({ test: function() {} }), on({ diff --git a/crates/swc/tests/tsc-references/literalTypeWidening.1.normal.js b/crates/swc/tests/tsc-references/literalTypeWidening.1.normal.js index 32d18e47e5d68..c95ccebfb0037 100644 --- a/crates/swc/tests/tsc-references/literalTypeWidening.1.normal.js +++ b/crates/swc/tests/tsc-references/literalTypeWidening.1.normal.js @@ -120,5 +120,5 @@ var E; E[E["A"] = 0] = "A"; E[E["B"] = 1] = "B"; })(E || (E = {})); -var a = f(E.A); +var a = f(0); var b = a; diff --git a/crates/swc/tests/tsc-references/literalTypeWidening.2.minified.js b/crates/swc/tests/tsc-references/literalTypeWidening.2.minified.js index c1dd1d0d1e9e9..63c6c73db273f 100644 --- a/crates/swc/tests/tsc-references/literalTypeWidening.2.minified.js +++ b/crates/swc/tests/tsc-references/literalTypeWidening.2.minified.js @@ -19,4 +19,4 @@ langCodes.map(function(code) { return { code: code }; -}), (E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", f(E1.A); +}), (E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", f(0); diff --git a/crates/swc/tests/tsc-references/literalTypes2.1.normal.js b/crates/swc/tests/tsc-references/literalTypes2.1.normal.js index 7f07e7aa534a4..ee36f1ba75a4a 100644 --- a/crates/swc/tests/tsc-references/literalTypes2.1.normal.js +++ b/crates/swc/tests/tsc-references/literalTypes2.1.normal.js @@ -8,7 +8,7 @@ var E; })(E || (E = {})); var cond; function f1() { - var p1 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1, p2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "abc", p3 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true, p4 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : E.A; + var p1 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1, p2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "abc", p3 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true, p4 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0; var v1 = 1; var v2 = -123; var v3 = 3 + 4; @@ -16,7 +16,7 @@ function f1() { var v5 = ""; var v6 = "abc" + "def"; var v7 = true; - var v8 = E.A; + var v8 = 0; var x1 = 1; var x2 = -123; var x3 = 3 + 4; @@ -24,7 +24,7 @@ function f1() { var x5 = ""; var x6 = "abc" + "def"; var x7 = true; - var x8 = E.A; + var x8 = 0; var c1 = 1; var c2 = -123; var c3 = 3 + 4; @@ -32,25 +32,25 @@ function f1() { var c5 = ""; var c6 = "abc" + "def"; var c7 = true; - var c8 = E.A; + var c8 = 0; } function f2() { - var p1 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1, p2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "abc", p3 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true, p4 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : E.A; + var p1 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1, p2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "abc", p3 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true, p4 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0; var v1 = 1; var v2 = -123; var v3 = "abc"; var v4 = true; - var v5 = E.A; + var v5 = 0; var x1 = 1; var x2 = -123; var x3 = "abc"; var x4 = true; - var x5 = E.A; + var x5 = 0; } function f3() { var c1 = cond ? 1 : 2; var c2 = cond ? 1 : "two"; - var c3 = cond ? E.A : cond ? true : 123; + var c3 = cond ? 0 : cond ? true : 123; var c4 = cond ? "abc" : null; var c5 = cond ? 456 : undefined; var c6 = { @@ -80,7 +80,7 @@ var C1 = function C1() { this.x5 = ""; this.x6 = "abc" + "def"; this.x7 = true; - this.x8 = E.A; + this.x8 = 0; this.c1 = 1; this.c2 = -123; this.c3 = 3 + 4; @@ -88,7 +88,7 @@ var C1 = function C1() { this.c5 = ""; this.c6 = "abc" + "def"; this.c7 = true; - this.c8 = E.A; + this.c8 = 0; }; function f4() { var c1 = { @@ -184,7 +184,7 @@ function f20() { return true; }; var f4 = function() { - return E.C; + return 2; }; var f5 = function() { return "foo"; diff --git a/crates/swc/tests/tsc-references/localTypes1.1.normal.js b/crates/swc/tests/tsc-references/localTypes1.1.normal.js index a7a446fc25b98..090278fbef449 100644 --- a/crates/swc/tests/tsc-references/localTypes1.1.normal.js +++ b/crates/swc/tests/tsc-references/localTypes1.1.normal.js @@ -17,7 +17,7 @@ function f1() { var a = [ new C() ]; - a[0].x = E.B; + a[0].x = 1; return a; } function f2() { @@ -35,7 +35,7 @@ function f2() { var a = [ new C() ]; - a[0].x = E.B; + a[0].x = 1; return a; }; return g(); @@ -56,7 +56,7 @@ function f3(b) { var a = [ new C() ]; - a[0].x = E.B; + a[0].x = 1; return a; } else { var A = function A() { @@ -66,7 +66,7 @@ function f3(b) { var c = [ new A() ]; - c[0].x = E.B; + c[0].x = 1; return c; } } diff --git a/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType.1.normal.js b/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType.1.normal.js index 9c6caa92fa763..880aaad4b3f7b 100644 --- a/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType.1.normal.js +++ b/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType.1.normal.js @@ -30,7 +30,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // any type var diff --git a/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType.2.minified.js b/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType.2.minified.js index be08d75c9f0fd..dbec991c446e9 100644 --- a/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType.2.minified.js +++ b/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType.2.minified.js @@ -10,6 +10,14 @@ var n, M, obj1 = { } return A.foo = function() {}, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); obj1.x, obj1.y, objA.a, M.n, A.foo(), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/logicalNotOperatorWithBooleanType.1.normal.js b/crates/swc/tests/tsc-references/logicalNotOperatorWithBooleanType.1.normal.js index 9fe02e3da45bf..43858cc063cd2 100644 --- a/crates/swc/tests/tsc-references/logicalNotOperatorWithBooleanType.1.normal.js +++ b/crates/swc/tests/tsc-references/logicalNotOperatorWithBooleanType.1.normal.js @@ -18,7 +18,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // boolean type var diff --git a/crates/swc/tests/tsc-references/logicalNotOperatorWithBooleanType.2.minified.js b/crates/swc/tests/tsc-references/logicalNotOperatorWithBooleanType.2.minified.js index 89920d30acc69..1aad80e004d85 100644 --- a/crates/swc/tests/tsc-references/logicalNotOperatorWithBooleanType.2.minified.js +++ b/crates/swc/tests/tsc-references/logicalNotOperatorWithBooleanType.2.minified.js @@ -9,6 +9,14 @@ var n, M, A = function() { return !1; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/logicalNotOperatorWithEnumType.1.normal.js b/crates/swc/tests/tsc-references/logicalNotOperatorWithEnumType.1.normal.js index f7210745cc293..48ed0aed58a74 100644 --- a/crates/swc/tests/tsc-references/logicalNotOperatorWithEnumType.1.normal.js +++ b/crates/swc/tests/tsc-references/logicalNotOperatorWithEnumType.1.normal.js @@ -11,13 +11,13 @@ var ENUM1; // enum type var var ResultIsBoolean1 = !ENUM; // enum type expressions -var ResultIsBoolean2 = !ENUM["B"]; -var ResultIsBoolean3 = !(ENUM.B + ENUM["C"]); +var ResultIsBoolean2 = !1; +var ResultIsBoolean3 = !(1 + 2); // multiple ! operators var ResultIsBoolean4 = !!ENUM; -var ResultIsBoolean5 = !!!(ENUM["B"] + ENUM.C); +var ResultIsBoolean5 = !!!(1 + 2); // miss assignment operators !ENUM; !ENUM1; -!ENUM.B; +!1; !ENUM, ENUM1; diff --git a/crates/swc/tests/tsc-references/logicalNotOperatorWithEnumType.2.minified.js b/crates/swc/tests/tsc-references/logicalNotOperatorWithEnumType.2.minified.js index 36eb01fd3ad80..57c1b7d885b83 100644 --- a/crates/swc/tests/tsc-references/logicalNotOperatorWithEnumType.2.minified.js +++ b/crates/swc/tests/tsc-references/logicalNotOperatorWithEnumType.2.minified.js @@ -1,4 +1,4 @@ //// [logicalNotOperatorWithEnumType.ts] // ! operator on enum type var ENUM, ENUM1, ENUM2; -(ENUM2 = ENUM || (ENUM = {}))[ENUM2.A = 0] = "A", ENUM2[ENUM2.B = 1] = "B", ENUM2[ENUM2.C = 2] = "C", ENUM1 || (ENUM1 = {}), ENUM.B, ENUM.B, ENUM.C, ENUM.B, ENUM.C, ENUM.B; +(ENUM2 = ENUM || (ENUM = {}))[ENUM2.A = 0] = "A", ENUM2[ENUM2.B = 1] = "B", ENUM2[ENUM2.C = 2] = "C", ENUM1 || (ENUM1 = {}); diff --git a/crates/swc/tests/tsc-references/logicalNotOperatorWithNumberType.1.normal.js b/crates/swc/tests/tsc-references/logicalNotOperatorWithNumberType.1.normal.js index bd1273c6ba92f..4ab7689b31eeb 100644 --- a/crates/swc/tests/tsc-references/logicalNotOperatorWithNumberType.1.normal.js +++ b/crates/swc/tests/tsc-references/logicalNotOperatorWithNumberType.1.normal.js @@ -22,7 +22,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // number type var diff --git a/crates/swc/tests/tsc-references/logicalNotOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/logicalNotOperatorWithNumberType.2.minified.js index cb28443674938..7b4751dd7eac7 100644 --- a/crates/swc/tests/tsc-references/logicalNotOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/logicalNotOperatorWithNumberType.2.minified.js @@ -9,6 +9,14 @@ var M, n, A = function() { return 1; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n, objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/logicalNotOperatorWithStringType.1.normal.js b/crates/swc/tests/tsc-references/logicalNotOperatorWithStringType.1.normal.js index 15589bceaa61b..1ee641adfc7b0 100644 --- a/crates/swc/tests/tsc-references/logicalNotOperatorWithStringType.1.normal.js +++ b/crates/swc/tests/tsc-references/logicalNotOperatorWithStringType.1.normal.js @@ -22,7 +22,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // string type var diff --git a/crates/swc/tests/tsc-references/logicalNotOperatorWithStringType.2.minified.js b/crates/swc/tests/tsc-references/logicalNotOperatorWithStringType.2.minified.js index 73b34fe2b71d9..d762a5cb03521 100644 --- a/crates/swc/tests/tsc-references/logicalNotOperatorWithStringType.2.minified.js +++ b/crates/swc/tests/tsc-references/logicalNotOperatorWithStringType.2.minified.js @@ -9,6 +9,14 @@ var STRING, M, n, A = function() { return ""; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); objA.a, M.n, A.foo(), STRING.charAt(0), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/mappedTypeOverlappingStringEnumKeys.1.normal.js b/crates/swc/tests/tsc-references/mappedTypeOverlappingStringEnumKeys.1.normal.js index a1742d7bea212..64d0a81f37d8f 100644 --- a/crates/swc/tests/tsc-references/mappedTypeOverlappingStringEnumKeys.1.normal.js +++ b/crates/swc/tests/tsc-references/mappedTypeOverlappingStringEnumKeys.1.normal.js @@ -12,11 +12,11 @@ var AlienAnimalTypes; var catMap = { cat: [ { - type: TerrestrialAnimalTypes.CAT, + type: "cat", address: "" }, { - type: AlienAnimalTypes.CAT, + type: "cat", planet: "" } ], diff --git a/crates/swc/tests/tsc-references/mappedTypeOverlappingStringEnumKeys.2.minified.js b/crates/swc/tests/tsc-references/mappedTypeOverlappingStringEnumKeys.2.minified.js index f213c018a7c05..22fda9d50a8af 100644 --- a/crates/swc/tests/tsc-references/mappedTypeOverlappingStringEnumKeys.2.minified.js +++ b/crates/swc/tests/tsc-references/mappedTypeOverlappingStringEnumKeys.2.minified.js @@ -1,4 +1,4 @@ //// [mappedTypeOverlappingStringEnumKeys.ts] // #37859 var TerrestrialAnimalTypes, AlienAnimalTypes, TerrestrialAnimalTypes1; -(TerrestrialAnimalTypes1 = TerrestrialAnimalTypes || (TerrestrialAnimalTypes = {})).CAT = "cat", TerrestrialAnimalTypes1.DOG = "dog", (AlienAnimalTypes || (AlienAnimalTypes = {})).CAT = "cat", TerrestrialAnimalTypes.CAT, AlienAnimalTypes.CAT; +(TerrestrialAnimalTypes1 = TerrestrialAnimalTypes || (TerrestrialAnimalTypes = {})).CAT = "cat", TerrestrialAnimalTypes1.DOG = "dog", (AlienAnimalTypes || (AlienAnimalTypes = {})).CAT = "cat"; diff --git a/crates/swc/tests/tsc-references/mergeThreeInterfaces.1.normal.js b/crates/swc/tests/tsc-references/mergeThreeInterfaces.1.normal.js index fd0c85321786b..baef7e50fb285 100644 --- a/crates/swc/tests/tsc-references/mergeThreeInterfaces.1.normal.js +++ b/crates/swc/tests/tsc-references/mergeThreeInterfaces.1.normal.js @@ -9,8 +9,8 @@ var b; var r4 = b.foo; var r5 = b.bar; var r6 = b.baz; -// basic non-generic and generic case inside a module var M; +// basic non-generic and generic case inside a module (function(M) { var a; var r1 = a.foo; diff --git a/crates/swc/tests/tsc-references/mergeThreeInterfaces2.1.normal.js b/crates/swc/tests/tsc-references/mergeThreeInterfaces2.1.normal.js index 528342291b615..ebfd40ea67b05 100644 --- a/crates/swc/tests/tsc-references/mergeThreeInterfaces2.1.normal.js +++ b/crates/swc/tests/tsc-references/mergeThreeInterfaces2.1.normal.js @@ -13,6 +13,7 @@ var M2; var r2 = a.bar; var r3 = a.baz; })(M2 || (M2 = {})); +// same as above but with an additional level of nesting and third module declaration (function(M2) { var M3; (function(M3) { diff --git a/crates/swc/tests/tsc-references/mergeTwoInterfaces.1.normal.js b/crates/swc/tests/tsc-references/mergeTwoInterfaces.1.normal.js index 5902aac575daa..d5912f8fd92a6 100644 --- a/crates/swc/tests/tsc-references/mergeTwoInterfaces.1.normal.js +++ b/crates/swc/tests/tsc-references/mergeTwoInterfaces.1.normal.js @@ -7,8 +7,8 @@ var r2 = a.bar; var b; var r3 = b.foo; var r4 = b.bar; -// basic non-generic and generic case inside a module var M; +// basic non-generic and generic case inside a module (function(M) { var a; var r1 = a.foo; diff --git a/crates/swc/tests/tsc-references/mergeTwoInterfaces2.1.normal.js b/crates/swc/tests/tsc-references/mergeTwoInterfaces2.1.normal.js index f3257d22c997f..91be54f2b89b0 100644 --- a/crates/swc/tests/tsc-references/mergeTwoInterfaces2.1.normal.js +++ b/crates/swc/tests/tsc-references/mergeTwoInterfaces2.1.normal.js @@ -12,6 +12,7 @@ var M2; var r1 = a.foo; var r2 = a.bar; })(M2 || (M2 = {})); +// same as above but with an additional level of nesting (function(M2) { var M3; (function(M3) { diff --git a/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases.1.normal.js b/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases.1.normal.js index 200e5cd115cdc..d5b37135cb3b1 100644 --- a/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases.1.normal.js +++ b/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases.1.normal.js @@ -16,8 +16,8 @@ var D = function D() { }; var a; var r = a.a; -// generic interfaces in a module var M; +// generic interfaces in a module (function(M) { var C = function C() { "use strict"; diff --git a/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases2.1.normal.js b/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases2.1.normal.js index 540a463176535..82e5f2d325c69 100644 --- a/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases2.1.normal.js +++ b/crates/swc/tests/tsc-references/mergedInterfacesWithMultipleBases2.1.normal.js @@ -24,8 +24,8 @@ var D = function D() { }; var a; var r = a.a; -// generic interfaces in a module var M; +// generic interfaces in a module (function(M) { var C = function C() { "use strict"; diff --git a/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension2.1.normal.js b/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension2.1.normal.js index 0bce8e5a1f799..8fa5ea889a795 100644 --- a/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension2.1.normal.js +++ b/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension2.1.normal.js @@ -1,7 +1,4 @@ //// [moduleResolutionWithoutExtension2.ts] //// [/src/buzz.mts] // Extensionless relative path cjs import in an ES module -import { createRequire as _createRequire } from "module"; -var __require = _createRequire(import.meta.url); -var foo = __require("./foo") // should error, should not ask for extension -; +export { }; // should error, should not ask for extension diff --git a/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension2.2.minified.js b/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension2.2.minified.js index a5b53dbacfbdf..da0e0139833a3 100644 --- a/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension2.2.minified.js +++ b/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension2.2.minified.js @@ -1,6 +1,5 @@ //// [moduleResolutionWithoutExtension2.ts] //// [/src/buzz.mts] // Extensionless relative path cjs import in an ES module -import { createRequire as _createRequire } from "module"; -_createRequire(import.meta.url)("./foo") // should error, should not ask for extension -; +export { }; + // should error, should not ask for extension diff --git a/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension7.1.normal.js b/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension7.1.normal.js index f26d8cb51d985..d7b22959ea874 100644 --- a/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension7.1.normal.js +++ b/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension7.1.normal.js @@ -1,7 +1,4 @@ //// [moduleResolutionWithoutExtension7.ts] //// [/src/bar.cts] // Extensionless relative path cjs import in a cjs module -import { createRequire as _createRequire } from "module"; -var __require = _createRequire(import.meta.url); -var foo = __require("./foo") // should error, should not ask for extension -; +export { }; // should error, should not ask for extension diff --git a/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension7.2.minified.js b/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension7.2.minified.js index 53a72e2dae077..d74f49c365f0f 100644 --- a/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension7.2.minified.js +++ b/crates/swc/tests/tsc-references/moduleResolutionWithoutExtension7.2.minified.js @@ -1,6 +1,5 @@ //// [moduleResolutionWithoutExtension7.ts] //// [/src/bar.cts] // Extensionless relative path cjs import in a cjs module -import { createRequire as _createRequire } from "module"; -_createRequire(import.meta.url)("./foo") // should error, should not ask for extension -; +export { }; + // should error, should not ask for extension diff --git a/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind.1.normal.js b/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind.1.normal.js index b430921ce83d7..37a37543df874 100644 --- a/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind.1.normal.js +++ b/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind.1.normal.js @@ -107,15 +107,51 @@ var Y; Color[Color["Blue"] = 0] = "Blue"; Color[Color["Red"] = 1] = "Red"; })(Color = Y.Color || (Y.Color = {})); - var x = Y.x = 12; + var x = 12; + Object.defineProperty(Y, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); Y.F = F; - var array = Y.array = null; - var fn = Y.fn = function(s) { + var array = null; + Object.defineProperty(Y, "array", { + enumerable: true, + get: function get() { + return array; + }, + set: function set(v) { + array = v; + } + }); + var fn = function(s) { return "hello " + s; }; - var ol = Y.ol = { + Object.defineProperty(Y, "fn", { + enumerable: true, + get: function get() { + return fn; + }, + set: function set(v) { + fn = v; + } + }); + var ol = { s: "hello", id: 2, isvalid: true }; + Object.defineProperty(Y, "ol", { + enumerable: true, + get: function get() { + return ol; + }, + set: function set(v) { + ol = v; + } + }); })(Y || (Y = {})); diff --git a/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind.2.minified.js b/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind.2.minified.js index adf7ad67e3f98..f1e5f5f436b65 100644 --- a/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind.2.minified.js +++ b/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind.2.minified.js @@ -1,5 +1,5 @@ //// [moduleWithStatementsOfEveryKind.ts] -var A, Y, Module, Color, Color1, Y1, A1, AA, B, BB, Color2; +var A, Y, Module, Color, Color1, Y1, A1, AA, B, BB, Color2, x, array, fn, ol; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; @@ -21,12 +21,44 @@ A || (A = {}), Module || (Module = {}), (Color1 = Color || (Color = {}))[Color1. return _class_call_check(this, BB), _super.apply(this, arguments); } return BB; -}(A1), Y1.BB = BB, Y1.Module || (Y1.Module = {}), (Color2 = Y1.Color || (Y1.Color = {}))[Color2.Blue = 0] = "Blue", Color2[Color2.Red = 1] = "Red", Y1.x = 12, Y1.F = function(s) { +}(A1), Y1.BB = BB, Y1.Module || (Y1.Module = {}), (Color2 = Y1.Color || (Y1.Color = {}))[Color2.Blue = 0] = "Blue", Color2[Color2.Red = 1] = "Red", x = 12, Object.defineProperty(Y1, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}), Y1.F = function(s) { return 2; -}, Y1.array = null, Y1.fn = function(s) { +}, array = null, Object.defineProperty(Y1, "array", { + enumerable: !0, + get: function() { + return array; + }, + set: function(v) { + array = v; + } +}), fn = function(s) { return "hello " + s; -}, Y1.ol = { +}, Object.defineProperty(Y1, "fn", { + enumerable: !0, + get: function() { + return fn; + }, + set: function(v) { + fn = v; + } +}), ol = { s: "hello", id: 2, isvalid: !0 -}; +}, Object.defineProperty(Y1, "ol", { + enumerable: !0, + get: function() { + return ol; + }, + set: function(v) { + ol = v; + } +}); diff --git a/crates/swc/tests/tsc-references/nameCollision.1.normal.js b/crates/swc/tests/tsc-references/nameCollision.1.normal.js index 76316e0c9f910..c4c9fed0669f8 100644 --- a/crates/swc/tests/tsc-references/nameCollision.1.normal.js +++ b/crates/swc/tests/tsc-references/nameCollision.1.normal.js @@ -21,32 +21,40 @@ var B; })(B || (B = {})); var X; (function(X) { - var _$X = 13; + var X1 = 13; var Y; (function(Y) { - var _$Y = 13; + var Y1 = 13; var Z; (function(Z) { - var _$X = 12; - var _$Y = 12; + var X = 12; + var Y = 12; var Z1 = 12; })(Z = Y.Z || (Y.Z = {})); })(Y = X.Y || (X.Y = {})); })(X || (X = {})); var Y; (function(Y) { - var _$Y; (function(Y) { - var _$Y; - (function(_$Y) { - _$Y[_$Y["Red"] = 0] = "Red"; - _$Y[_$Y["Blue"] = 1] = "Blue"; - })(_$Y = Y.Y || (Y.Y = {})); - })(_$Y = Y.Y || (Y.Y = {})); + var Y; + (function(Y) { + Y[Y["Red"] = 0] = "Red"; + Y[Y["Blue"] = 1] = "Blue"; + })(Y = Y.Y || (Y.Y = {})); + })(Y.Y || (Y.Y = {})); })(Y || (Y = {})); +var D; // no collision, since interface doesn't // generate code. -var D; (function(D) { - var E = D.E = "hello"; + var E = "hello"; + Object.defineProperty(D, "E", { + enumerable: true, + get: function get() { + return E; + }, + set: function set(v) { + E = v; + } + }); })(D || (D = {})); diff --git a/crates/swc/tests/tsc-references/nameCollision.2.minified.js b/crates/swc/tests/tsc-references/nameCollision.2.minified.js index 76562a87ee5fc..ff81db1444068 100644 --- a/crates/swc/tests/tsc-references/nameCollision.2.minified.js +++ b/crates/swc/tests/tsc-references/nameCollision.2.minified.js @@ -1,4 +1,12 @@ //// [nameCollision.ts] -var A, B, X, Y, D, X1, Y1, Y2, Y3, _$Y; +var A, B, X, Y, D, X1, Y1, Y2, Y3, Y4, D1, E; import "@swc/helpers/_/_class_call_check"; -A || (A = {}), B || (B = {}), B || (B = {}), (Y1 = (X1 = X || (X = {})).Y || (X1.Y = {})).Z || (Y1.Z = {}), (_$Y = (Y3 = (Y2 = Y || (Y = {})).Y || (Y2.Y = {})).Y || (Y3.Y = {}))[_$Y.Red = 0] = "Red", _$Y[_$Y.Blue = 1] = "Blue", (D || (D = {})).E = "hello"; +A || (A = {}), B || (B = {}), B || (B = {}), (Y1 = (X1 = X || (X = {})).Y || (X1.Y = {})).Z || (Y1.Z = {}), (Y4 = Y3 = (Y3 = (Y2 = Y || (Y = {})).Y || (Y2.Y = {})).Y || (Y3.Y = {}))[Y4.Red = 0] = "Red", Y4[Y4.Blue = 1] = "Blue", D1 = D || (D = {}), E = "hello", Object.defineProperty(D1, "E", { + enumerable: !0, + get: function() { + return E; + }, + set: function(v) { + E = v; + } +}); diff --git a/crates/swc/tests/tsc-references/nameWithRelativePaths.1.normal.js b/crates/swc/tests/tsc-references/nameWithRelativePaths.1.normal.js index 47a24ae2678eb..ddb1a2c76d7c8 100644 --- a/crates/swc/tests/tsc-references/nameWithRelativePaths.1.normal.js +++ b/crates/swc/tests/tsc-references/nameWithRelativePaths.1.normal.js @@ -37,7 +37,16 @@ Object.defineProperty(exports, "M2", { }); var M2; (function(M2) { - var x = M2.x = true; + var x = true; + Object.defineProperty(M2, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(M2 || (M2 = {})); //// [test/foo_3.ts] "use strict"; diff --git a/crates/swc/tests/tsc-references/nameWithRelativePaths.2.minified.js b/crates/swc/tests/tsc-references/nameWithRelativePaths.2.minified.js index 4474895136200..feeaacd208724 100644 --- a/crates/swc/tests/tsc-references/nameWithRelativePaths.2.minified.js +++ b/crates/swc/tests/tsc-references/nameWithRelativePaths.2.minified.js @@ -21,7 +21,7 @@ Object.defineProperty(exports, "__esModule", { } }); //// [test/foo_2.ts] -var M2; +var M2, M21, x; Object.defineProperty(exports, "__esModule", { value: !0 }), Object.defineProperty(exports, "M2", { @@ -29,7 +29,15 @@ Object.defineProperty(exports, "__esModule", { get: function() { return M2; } -}), (M2 || (M2 = {})).x = !0; +}), M21 = M2 || (M2 = {}), x = !0, Object.defineProperty(M21, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}); //// [test/foo_3.ts] Object.defineProperty(exports, "__esModule", { value: !0 diff --git a/crates/swc/tests/tsc-references/negateOperatorWithBooleanType.1.normal.js b/crates/swc/tests/tsc-references/negateOperatorWithBooleanType.1.normal.js index 84eefa96994ff..e48fdd8c9422d 100644 --- a/crates/swc/tests/tsc-references/negateOperatorWithBooleanType.1.normal.js +++ b/crates/swc/tests/tsc-references/negateOperatorWithBooleanType.1.normal.js @@ -18,7 +18,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // boolean type var diff --git a/crates/swc/tests/tsc-references/negateOperatorWithBooleanType.2.minified.js b/crates/swc/tests/tsc-references/negateOperatorWithBooleanType.2.minified.js index 16238b4e44769..2cf0f54b954bb 100644 --- a/crates/swc/tests/tsc-references/negateOperatorWithBooleanType.2.minified.js +++ b/crates/swc/tests/tsc-references/negateOperatorWithBooleanType.2.minified.js @@ -9,6 +9,14 @@ var n, M, A = function() { return !1; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/negateOperatorWithEnumType.1.normal.js b/crates/swc/tests/tsc-references/negateOperatorWithEnumType.1.normal.js index eb5044f63d6f8..a2f831818a659 100644 --- a/crates/swc/tests/tsc-references/negateOperatorWithEnumType.1.normal.js +++ b/crates/swc/tests/tsc-references/negateOperatorWithEnumType.1.normal.js @@ -11,10 +11,10 @@ var ENUM1; // enum type var var ResultIsNumber1 = -ENUM; // expressions -var ResultIsNumber2 = -ENUM1["B"]; -var ResultIsNumber3 = -(ENUM1.B + ENUM1[""]); +var ResultIsNumber2 = -1; +var ResultIsNumber3 = -(1 + 2); // miss assignment operators -ENUM; -ENUM1; --ENUM1["B"]; +-1; -ENUM, ENUM1; diff --git a/crates/swc/tests/tsc-references/negateOperatorWithEnumType.2.minified.js b/crates/swc/tests/tsc-references/negateOperatorWithEnumType.2.minified.js index 6792b886adebc..dda3d12355f87 100644 --- a/crates/swc/tests/tsc-references/negateOperatorWithEnumType.2.minified.js +++ b/crates/swc/tests/tsc-references/negateOperatorWithEnumType.2.minified.js @@ -1,4 +1,4 @@ //// [negateOperatorWithEnumType.ts] // - operator on enum type var ENUM, ENUM1, ENUM11; -ENUM || (ENUM = {}), (ENUM11 = ENUM1 || (ENUM1 = {}))[ENUM11.A = 0] = "A", ENUM11[ENUM11.B = 1] = "B", ENUM11[ENUM11[""] = 2] = "", ENUM1.B, ENUM1.B, ENUM1[""], ENUM1.B; +ENUM || (ENUM = {}), (ENUM11 = ENUM1 || (ENUM1 = {}))[ENUM11.A = 0] = "A", ENUM11[ENUM11.B = 1] = "B", ENUM11[ENUM11[""] = 2] = ""; diff --git a/crates/swc/tests/tsc-references/negateOperatorWithNumberType.1.normal.js b/crates/swc/tests/tsc-references/negateOperatorWithNumberType.1.normal.js index bf338a8a29813..1574bc03a9bb7 100644 --- a/crates/swc/tests/tsc-references/negateOperatorWithNumberType.1.normal.js +++ b/crates/swc/tests/tsc-references/negateOperatorWithNumberType.1.normal.js @@ -22,7 +22,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // number type var diff --git a/crates/swc/tests/tsc-references/negateOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/negateOperatorWithNumberType.2.minified.js index 4dec79aa8ce75..9cf0a04fa9675 100644 --- a/crates/swc/tests/tsc-references/negateOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/negateOperatorWithNumberType.2.minified.js @@ -9,6 +9,14 @@ var M, n, A = function() { return 1; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n, objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/negateOperatorWithStringType.1.normal.js b/crates/swc/tests/tsc-references/negateOperatorWithStringType.1.normal.js index 352b2d254868b..31530d7b161ad 100644 --- a/crates/swc/tests/tsc-references/negateOperatorWithStringType.1.normal.js +++ b/crates/swc/tests/tsc-references/negateOperatorWithStringType.1.normal.js @@ -22,7 +22,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // string type var diff --git a/crates/swc/tests/tsc-references/negateOperatorWithStringType.2.minified.js b/crates/swc/tests/tsc-references/negateOperatorWithStringType.2.minified.js index a3580a8ffbf91..f09c8c156b736 100644 --- a/crates/swc/tests/tsc-references/negateOperatorWithStringType.2.minified.js +++ b/crates/swc/tests/tsc-references/negateOperatorWithStringType.2.minified.js @@ -9,6 +9,14 @@ var STRING, M, n, A = function() { return ""; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); objA.a, M.n, A.foo(), STRING.charAt(0), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/nestedModules.1.normal.js b/crates/swc/tests/tsc-references/nestedModules.1.normal.js index f2544d543dc0f..4467b8f28d379 100644 --- a/crates/swc/tests/tsc-references/nestedModules.1.normal.js +++ b/crates/swc/tests/tsc-references/nestedModules.1.normal.js @@ -14,7 +14,15 @@ var M2; var X; (function(X) { var Point; - X.Point = Point; + Object.defineProperty(X, "Point", { + enumerable: true, + get: function get() { + return Point; + }, + set: function set(v) { + Point = v; + } + }); })(X = M2.X || (M2.X = {})); })(M2 || (M2 = {})); var m = M2.X; diff --git a/crates/swc/tests/tsc-references/nestedModules.2.minified.js b/crates/swc/tests/tsc-references/nestedModules.2.minified.js index 878d91810297e..fdcf6a4d04223 100644 --- a/crates/swc/tests/tsc-references/nestedModules.2.minified.js +++ b/crates/swc/tests/tsc-references/nestedModules.2.minified.js @@ -1,3 +1,11 @@ //// [nestedModules.ts] var A, M2, Point, A1, M21; -(A = A1 || (A1 = {})).B || (A.B = {}), ((M2 = M21 || (M21 = {})).X || (M2.X = {})).Point = Point, M21.X.Point; +(A = A1 || (A1 = {})).B || (A.B = {}), Object.defineProperty((M2 = M21 || (M21 = {})).X || (M2.X = {}), "Point", { + enumerable: !0, + get: function() { + return Point; + }, + set: function(v) { + Point = v; + } +}), M21.X.Point; diff --git a/crates/swc/tests/tsc-references/noUncheckedIndexedAccess.1.normal.js b/crates/swc/tests/tsc-references/noUncheckedIndexedAccess.1.normal.js index 89789673fe32d..802673a6e5c33 100644 --- a/crates/swc/tests/tsc-references/noUncheckedIndexedAccess.1.normal.js +++ b/crates/swc/tests/tsc-references/noUncheckedIndexedAccess.1.normal.js @@ -24,12 +24,12 @@ var e4 = strMap[0]; var e5 = strMap[0]; var e6 = strMap[0]; var e7 = strMap["foo"]; -var e8 = strMap[NumericEnum1.A]; -var e9 = strMap[NumericEnum2.A]; -var e10 = strMap[StringEnum1.A]; -var e11 = strMap[StringEnum1.A]; -var e12 = strMap[NumericEnum1.A]; -var e13 = strMap[NumericEnum2.A]; +var e8 = strMap[0]; +var e9 = strMap[0]; +var e10 = strMap["Alpha"]; +var e11 = strMap["Alpha"]; +var e12 = strMap[0]; +var e13 = strMap[0]; var e14 = strMap[null]; // Should be OK var ok1 = strMap["foo"]; @@ -43,8 +43,8 @@ strMap[null] = undefined; var num_ok1 = numMap[0]; var num_ok2 = numMap[0]; var num_ok3 = numMap[0]; -var num_ok4 = numMap[NumericEnum1.A]; -var num_ok5 = numMap[NumericEnum2.A]; +var num_ok4 = numMap[0]; +var num_ok5 = numMap[0]; // Generics function generic1(arg) { // Should error diff --git a/crates/swc/tests/tsc-references/noUncheckedIndexedAccess.2.minified.js b/crates/swc/tests/tsc-references/noUncheckedIndexedAccess.2.minified.js index d9a5e70d1b55d..31f9fea9041a8 100644 --- a/crates/swc/tests/tsc-references/noUncheckedIndexedAccess.2.minified.js +++ b/crates/swc/tests/tsc-references/noUncheckedIndexedAccess.2.minified.js @@ -1,4 +1,4 @@ //// [noUncheckedIndexedAccess.ts] var NumericEnum1, NumericEnum2, StringEnum1, NumericEnum11, NumericEnum21, StringEnum11; -(NumericEnum1 = NumericEnum11 || (NumericEnum11 = {}))[NumericEnum1.A = 0] = "A", NumericEnum1[NumericEnum1.B = 1] = "B", NumericEnum1[NumericEnum1.C = 2] = "C", (NumericEnum2 = NumericEnum21 || (NumericEnum21 = {}))[NumericEnum2.A = 0] = "A", NumericEnum2[NumericEnum2.B = 1] = "B", NumericEnum2[NumericEnum2.C = 2] = "C", (StringEnum1 = StringEnum11 || (StringEnum11 = {})).A = "Alpha", StringEnum1.B = "Beta", strMap.foo, strMap.bar, strMap[0], strMap[0], strMap[0], strMap[0], strMap.foo, strMap[NumericEnum11.A], strMap[NumericEnum21.A], strMap[StringEnum11.A], strMap[StringEnum11.A], strMap[NumericEnum11.A], strMap[NumericEnum21.A], strMap[null], strMap.foo, strMap.bar, // Writes don't allow 'undefined'; all should be errors -strMap.baz = void 0, strMap.qua = void 0, strMap[0] = void 0, strMap[null] = void 0, numMap[0], numMap[0], numMap[0], numMap[NumericEnum11.A], numMap[NumericEnum21.A], obj1.x, obj1.y, obj1.y, obj1.z, strMapUnion.foo, symbolMap[s], symbolMap[s] = void 0, nonEmptyStringArray[0], nonEmptyStringArray[1]; +(NumericEnum1 = NumericEnum11 || (NumericEnum11 = {}))[NumericEnum1.A = 0] = "A", NumericEnum1[NumericEnum1.B = 1] = "B", NumericEnum1[NumericEnum1.C = 2] = "C", (NumericEnum2 = NumericEnum21 || (NumericEnum21 = {}))[NumericEnum2.A = 0] = "A", NumericEnum2[NumericEnum2.B = 1] = "B", NumericEnum2[NumericEnum2.C = 2] = "C", (StringEnum1 = StringEnum11 || (StringEnum11 = {})).A = "Alpha", StringEnum1.B = "Beta", strMap.foo, strMap.bar, strMap[0], strMap[0], strMap[0], strMap[0], strMap.foo, strMap[0], strMap[0], strMap.Alpha, strMap.Alpha, strMap[0], strMap[0], strMap[null], strMap.foo, strMap.bar, // Writes don't allow 'undefined'; all should be errors +strMap.baz = void 0, strMap.qua = void 0, strMap[0] = void 0, strMap[null] = void 0, numMap[0], numMap[0], numMap[0], numMap[0], numMap[0], obj1.x, obj1.y, obj1.y, obj1.z, strMapUnion.foo, symbolMap[s], symbolMap[s] = void 0, nonEmptyStringArray[0], nonEmptyStringArray[1]; diff --git a/crates/swc/tests/tsc-references/nonInstantiatedModule.1.normal.js b/crates/swc/tests/tsc-references/nonInstantiatedModule.1.normal.js index df662b1d61ddc..1b9de4c339671 100644 --- a/crates/swc/tests/tsc-references/nonInstantiatedModule.1.normal.js +++ b/crates/swc/tests/tsc-references/nonInstantiatedModule.1.normal.js @@ -2,7 +2,16 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var M; (function(M) { - var a = M.a = 1; + var a = 1; + Object.defineProperty(M, "a", { + enumerable: true, + get: function get() { + return a; + }, + set: function set(v) { + a = v; + } + }); })(M || (M = {})); // primary expression var m; @@ -15,12 +24,12 @@ var M2; (function(M2) { var Point; (function(Point) { - function Origin() { + var Origin = function Origin() { return { x: 0, y: 0 }; - } + }; Point.Origin = Origin; })(Point = M2.Point || (M2.Point = {})); })(M2 || (M2 = {})); diff --git a/crates/swc/tests/tsc-references/nonInstantiatedModule.2.minified.js b/crates/swc/tests/tsc-references/nonInstantiatedModule.2.minified.js index a23a3ea51c7dc..542cc2b30bc90 100644 --- a/crates/swc/tests/tsc-references/nonInstantiatedModule.2.minified.js +++ b/crates/swc/tests/tsc-references/nonInstantiatedModule.2.minified.js @@ -1,8 +1,16 @@ //// [nonInstantiatedModule.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(M || (M = {})).a = 1; -var M2, M, M21, M3, m = M; -M.a, m.a, ((M2 = M21 || (M21 = {})).Point || (M2.Point = {})).Origin = function() { +M = M1 || (M1 = {}), a = 1, Object.defineProperty(M, "a", { + enumerable: !0, + get: function() { + return a; + }, + set: function(v) { + a = v; + } +}); +var M2, M, a, M1, M21, M3, m = M1; +M1.a, m.a, ((M2 = M21 || (M21 = {})).Point || (M2.Point = {})).Origin = function() { return { x: 0, y: 0 diff --git a/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined.1.normal.js b/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined.1.normal.js index 1d1aca6a7a81b..9092f3925943b 100644 --- a/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined.1.normal.js +++ b/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined.1.normal.js @@ -53,11 +53,20 @@ var E; })(E || (E = {})); var r13 = true ? E : null; var r13 = true ? null : E; -var r14 = true ? E.A : null; -var r14 = true ? null : E.A; +var r14 = true ? 0 : null; +var r14 = true ? null : 0; function f() {} (function(f) { - var bar = f.bar = 1; + var bar = 1; + Object.defineProperty(f, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(f || (f = {})); var af; var r15 = true ? af : null; @@ -67,7 +76,16 @@ var c = function c() { _class_call_check(this, c); }; (function(c) { - var bar = c.bar = 1; + var bar = 1; + Object.defineProperty(c, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(c || (c = {})); var ac; var r16 = true ? ac : null; diff --git a/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined.2.minified.js b/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined.2.minified.js index 295a6b334a800..48933a7088fa2 100644 --- a/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined.2.minified.js +++ b/crates/swc/tests/tsc-references/nullIsSubtypeOfEverythingButUndefined.2.minified.js @@ -2,8 +2,24 @@ // null is a subtype of any other types except undefined import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; function f() {} -(E = E1 || (E1 = {}))[E.A = 0] = "A", E1.A, (f || (f = {})).bar = 1; -var E, E1, c = function c() { +(E = E1 || (E1 = {}))[E.A = 0] = "A", f1 = f || (f = {}), bar1 = 1, Object.defineProperty(f1, "bar", { + enumerable: !0, + get: function() { + return bar1; + }, + set: function(v) { + bar1 = v; + } +}); +var c, bar, E, f1, bar1, E1, c1 = function c() { _class_call_check(this, c); }; -(c || (c = {})).bar = 1; +c = c1 || (c1 = {}), bar = 1, Object.defineProperty(c, "bar", { + enumerable: !0, + get: function() { + return bar; + }, + set: function(v) { + bar = v; + } +}); diff --git a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule.1.normal.js b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule.1.normal.js index 080b9d177e87a..16195174739a6 100644 --- a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule.1.normal.js +++ b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule.1.normal.js @@ -3,7 +3,15 @@ var m; (function(m) { var x1; - m.x = x1; + Object.defineProperty(m, "x", { + enumerable: true, + get: function get() { + return x1; + }, + set: function set(v) { + x1 = v; + } + }); })(m || (m = {})); (function(m) { var z = x; diff --git a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule.2.minified.js b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule.2.minified.js index c2d7a6948c138..4dc0cae5a859d 100644 --- a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule.2.minified.js +++ b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule.2.minified.js @@ -1,4 +1,12 @@ //// [objectLiteralShorthandPropertiesWithModule.ts] // module export var m, x1; -(m || (m = {})).x = x1, m || (m = {}), x, x, x; +Object.defineProperty(m || (m = {}), "x", { + enumerable: !0, + get: function() { + return x1; + }, + set: function(v) { + x1 = v; + } +}), m || (m = {}), x, x, x; diff --git a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6.1.normal.js b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6.1.normal.js index 157a52af5712a..a7b492bf3cf7b 100644 --- a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6.1.normal.js +++ b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6.1.normal.js @@ -2,7 +2,15 @@ var m; (function(m) { var x1; - m.x = x1; + Object.defineProperty(m, "x", { + enumerable: true, + get () { + return x1; + }, + set (v) { + x1 = v; + } + }); })(m || (m = {})); (function(m) { var z = x; diff --git a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6.2.minified.js b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6.2.minified.js index adbdcd21a0ebb..3c64a811fdc4e 100644 --- a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6.2.minified.js +++ b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6.2.minified.js @@ -1,3 +1,9 @@ //// [objectLiteralShorthandPropertiesWithModuleES6.ts] var m, x1; -(m || (m = {})).x = x1, m || (m = {}), x, x, x; +Object.defineProperty(m || (m = {}), "x", { + enumerable: !0, + get: ()=>x1, + set (v) { + x1 = v; + } +}), m || (m = {}), x, x, x; diff --git a/crates/swc/tests/tsc-references/objectTypesIdentity2.1.normal.js b/crates/swc/tests/tsc-references/objectTypesIdentity2.1.normal.js index d273b45aa9e29..794fb6c051142 100644 --- a/crates/swc/tests/tsc-references/objectTypesIdentity2.1.normal.js +++ b/crates/swc/tests/tsc-references/objectTypesIdentity2.1.normal.js @@ -19,7 +19,7 @@ var E; E[E["A"] = 0] = "A"; })(E || (E = {})); var b = { - foo: E.A + foo: 0 }; function foo5(x) {} function foo5b(x) {} diff --git a/crates/swc/tests/tsc-references/objectTypesIdentity2.2.minified.js b/crates/swc/tests/tsc-references/objectTypesIdentity2.2.minified.js index e423f2408b6cd..e69728e8421b8 100644 --- a/crates/swc/tests/tsc-references/objectTypesIdentity2.2.minified.js +++ b/crates/swc/tests/tsc-references/objectTypesIdentity2.2.minified.js @@ -2,4 +2,4 @@ // object types are identical structurally var E, E1; import "@swc/helpers/_/_class_call_check"; -(E1 = E || (E = {}))[E1.A = 0] = "A", E.A; +(E1 = E || (E = {}))[E1.A = 0] = "A"; diff --git a/crates/swc/tests/tsc-references/parserEnumDeclaration2.d.1.normal.js b/crates/swc/tests/tsc-references/parserEnumDeclaration2.d.1.normal.js index b28e838514f9b..f5a67a774c2c0 100644 --- a/crates/swc/tests/tsc-references/parserEnumDeclaration2.d.1.normal.js +++ b/crates/swc/tests/tsc-references/parserEnumDeclaration2.d.1.normal.js @@ -1,3 +1 @@ //// [parserEnumDeclaration2.d.ts] -var E; -(function(E) {})(E || (E = {})); diff --git a/crates/swc/tests/tsc-references/parserEnumDeclaration2.d.2.minified.js b/crates/swc/tests/tsc-references/parserEnumDeclaration2.d.2.minified.js index 2cf91bf602eb4..f5a67a774c2c0 100644 --- a/crates/swc/tests/tsc-references/parserEnumDeclaration2.d.2.minified.js +++ b/crates/swc/tests/tsc-references/parserEnumDeclaration2.d.2.minified.js @@ -1,3 +1 @@ //// [parserEnumDeclaration2.d.ts] -var E; -E || (E = {}); diff --git a/crates/swc/tests/tsc-references/parserEnumDeclaration3.1.normal.js b/crates/swc/tests/tsc-references/parserEnumDeclaration3.1.normal.js index cf81e6b57f996..b80933a5365ea 100644 --- a/crates/swc/tests/tsc-references/parserEnumDeclaration3.1.normal.js +++ b/crates/swc/tests/tsc-references/parserEnumDeclaration3.1.normal.js @@ -1,5 +1 @@ //// [parserEnumDeclaration3.ts] -var E; -(function(E) { - E[E["A"] = 1] = "A"; -})(E || (E = {})); diff --git a/crates/swc/tests/tsc-references/parserEnumDeclaration3.2.minified.js b/crates/swc/tests/tsc-references/parserEnumDeclaration3.2.minified.js index 292fd80521dfe..b80933a5365ea 100644 --- a/crates/swc/tests/tsc-references/parserEnumDeclaration3.2.minified.js +++ b/crates/swc/tests/tsc-references/parserEnumDeclaration3.2.minified.js @@ -1,3 +1 @@ //// [parserEnumDeclaration3.ts] -var E, E1; -(E1 = E || (E = {}))[E1.A = 1] = "A"; diff --git a/crates/swc/tests/tsc-references/parserErrorRecovery_IncompleteMemberVariable1.1.normal.js b/crates/swc/tests/tsc-references/parserErrorRecovery_IncompleteMemberVariable1.1.normal.js index 8577b5c795e96..e4c0c9ed8a5cb 100644 --- a/crates/swc/tests/tsc-references/parserErrorRecovery_IncompleteMemberVariable1.1.normal.js +++ b/crates/swc/tests/tsc-references/parserErrorRecovery_IncompleteMemberVariable1.1.normal.js @@ -1,8 +1,8 @@ //// [parserErrorRecovery_IncompleteMemberVariable1.ts] // Interface import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -// Module var Shapes; +// Module (function(Shapes) { var Point = /*#__PURE__*/ function() { "use strict"; diff --git a/crates/swc/tests/tsc-references/parserModule1.1.normal.js b/crates/swc/tests/tsc-references/parserModule1.1.normal.js index 3740fbc761022..5138d62abea07 100644 --- a/crates/swc/tests/tsc-references/parserModule1.1.normal.js +++ b/crates/swc/tests/tsc-references/parserModule1.1.normal.js @@ -18,9 +18,36 @@ export var CompilerDiagnostics; } } }; - var debug = CompilerDiagnostics.debug = false; - var diagnosticWriter = CompilerDiagnostics.diagnosticWriter = null; - var analysisPass = CompilerDiagnostics.analysisPass = 0; + var debug = false; + Object.defineProperty(CompilerDiagnostics, "debug", { + enumerable: true, + get: function get() { + return debug; + }, + set: function set(v) { + debug = v; + } + }); + var diagnosticWriter = null; + Object.defineProperty(CompilerDiagnostics, "diagnosticWriter", { + enumerable: true, + get: function get() { + return diagnosticWriter; + }, + set: function set(v) { + diagnosticWriter = v; + } + }); + var analysisPass = 0; + Object.defineProperty(CompilerDiagnostics, "analysisPass", { + enumerable: true, + get: function get() { + return analysisPass; + }, + set: function set(v) { + analysisPass = v; + } + }); CompilerDiagnostics.Alert = Alert; CompilerDiagnostics.debugPrint = debugPrint; CompilerDiagnostics.assert = assert; diff --git a/crates/swc/tests/tsc-references/parserModule1.2.minified.js b/crates/swc/tests/tsc-references/parserModule1.2.minified.js index ef04af8eb13af..db57c36038a86 100644 --- a/crates/swc/tests/tsc-references/parserModule1.2.minified.js +++ b/crates/swc/tests/tsc-references/parserModule1.2.minified.js @@ -1,10 +1,34 @@ //// [parserModule1.ts] -var CompilerDiagnostics, Alert, debug, diagnosticWriter; +var CompilerDiagnostics, Alert, debug, diagnosticWriter, analysisPass; var CompilerDiagnostics1; export { CompilerDiagnostics1 as CompilerDiagnostics }; CompilerDiagnostics = CompilerDiagnostics1 || (CompilerDiagnostics1 = {}), Alert = function(output) { diagnosticWriter && diagnosticWriter.Alert(output); -}, debug = CompilerDiagnostics.debug = !1, diagnosticWriter = CompilerDiagnostics.diagnosticWriter = null, CompilerDiagnostics.analysisPass = 0, CompilerDiagnostics.Alert = Alert, CompilerDiagnostics.debugPrint = function(s) { +}, debug = !1, Object.defineProperty(CompilerDiagnostics, "debug", { + enumerable: !0, + get: function() { + return debug; + }, + set: function(v) { + debug = v; + } +}), diagnosticWriter = null, Object.defineProperty(CompilerDiagnostics, "diagnosticWriter", { + enumerable: !0, + get: function() { + return diagnosticWriter; + }, + set: function(v) { + diagnosticWriter = v; + } +}), analysisPass = 0, Object.defineProperty(CompilerDiagnostics, "analysisPass", { + enumerable: !0, + get: function() { + return analysisPass; + }, + set: function(v) { + analysisPass = v; + } +}), CompilerDiagnostics.Alert = Alert, CompilerDiagnostics.debugPrint = function(s) { debug && Alert(s); }, CompilerDiagnostics.assert = function(condition, s) { debug && !condition && Alert(s); diff --git a/crates/swc/tests/tsc-references/parserRealSource1.1.normal.js b/crates/swc/tests/tsc-references/parserRealSource1.1.normal.js index 66a8ae90ad6a7..a903ddc0c42af 100644 --- a/crates/swc/tests/tsc-references/parserRealSource1.1.normal.js +++ b/crates/swc/tests/tsc-references/parserRealSource1.1.normal.js @@ -59,28 +59,55 @@ var TypeScript; }; var CompilerDiagnostics; (function(CompilerDiagnostics) { - var debug = CompilerDiagnostics.debug = false; - var diagnosticWriter = CompilerDiagnostics.diagnosticWriter = null; - var analysisPass = CompilerDiagnostics.analysisPass = 0; - function Alert(output) { + var Alert = function Alert(output) { if (diagnosticWriter) { diagnosticWriter.Alert(output); } - } - CompilerDiagnostics.Alert = Alert; - function debugPrint(s) { + }; + var debugPrint = function debugPrint(s) { if (debug) { Alert(s); } - } - CompilerDiagnostics.debugPrint = debugPrint; - function assert(condition, s) { + }; + var assert = function assert(condition, s) { if (debug) { if (!condition) { Alert(s); } } - } + }; + var debug = false; + Object.defineProperty(CompilerDiagnostics, "debug", { + enumerable: true, + get: function get() { + return debug; + }, + set: function set(v) { + debug = v; + } + }); + var diagnosticWriter = null; + Object.defineProperty(CompilerDiagnostics, "diagnosticWriter", { + enumerable: true, + get: function get() { + return diagnosticWriter; + }, + set: function set(v) { + diagnosticWriter = v; + } + }); + var analysisPass = 0; + Object.defineProperty(CompilerDiagnostics, "analysisPass", { + enumerable: true, + get: function get() { + return analysisPass; + }, + set: function set(v) { + analysisPass = v; + } + }); + CompilerDiagnostics.Alert = Alert; + CompilerDiagnostics.debugPrint = debugPrint; CompilerDiagnostics.assert = assert; })(CompilerDiagnostics = TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); var NullLogger = /*#__PURE__*/ function() { diff --git a/crates/swc/tests/tsc-references/parserRealSource1.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource1.2.minified.js index 33e1d166c4cb1..76e36f86e9c33 100644 --- a/crates/swc/tests/tsc-references/parserRealSource1.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource1.2.minified.js @@ -2,19 +2,39 @@ // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. /// -var TypeScript, TypeScript1, NullLogger, LoggerAdapter, BufferedLogger; +var TypeScript, TypeScript1, CompilerDiagnostics, Alert, debug, diagnosticWriter, analysisPass, NullLogger, LoggerAdapter, BufferedLogger; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(CompilerDiagnostics) { - var debug = CompilerDiagnostics.debug = !1, diagnosticWriter = CompilerDiagnostics.diagnosticWriter = null; - function Alert(output) { - diagnosticWriter && diagnosticWriter.Alert(output); +CompilerDiagnostics = (TypeScript1 = TypeScript || (TypeScript = {})).CompilerDiagnostics || (TypeScript1.CompilerDiagnostics = {}), Alert = function(output) { + diagnosticWriter && diagnosticWriter.Alert(output); +}, debug = !1, Object.defineProperty(CompilerDiagnostics, "debug", { + enumerable: !0, + get: function() { + return debug; + }, + set: function(v) { + debug = v; } - CompilerDiagnostics.analysisPass = 0, CompilerDiagnostics.Alert = Alert, CompilerDiagnostics.debugPrint = function(s) { - debug && Alert(s); - }, CompilerDiagnostics.assert = function(condition, s) { - debug && !condition && Alert(s); - }; -}((TypeScript1 = TypeScript || (TypeScript = {})).CompilerDiagnostics || (TypeScript1.CompilerDiagnostics = {})), NullLogger = function() { +}), diagnosticWriter = null, Object.defineProperty(CompilerDiagnostics, "diagnosticWriter", { + enumerable: !0, + get: function() { + return diagnosticWriter; + }, + set: function(v) { + diagnosticWriter = v; + } +}), analysisPass = 0, Object.defineProperty(CompilerDiagnostics, "analysisPass", { + enumerable: !0, + get: function() { + return analysisPass; + }, + set: function(v) { + analysisPass = v; + } +}), CompilerDiagnostics.Alert = Alert, CompilerDiagnostics.debugPrint = function(s) { + debug && Alert(s); +}, CompilerDiagnostics.assert = function(condition, s) { + debug && !condition && Alert(s); +}, NullLogger = function() { function NullLogger() { _class_call_check(this, NullLogger); } diff --git a/crates/swc/tests/tsc-references/parserRealSource12.1.normal.js b/crates/swc/tests/tsc-references/parserRealSource12.1.normal.js index a90e9701d835b..b736b924043bc 100644 --- a/crates/swc/tests/tsc-references/parserRealSource12.1.normal.js +++ b/crates/swc/tests/tsc-references/parserRealSource12.1.normal.js @@ -209,11 +209,10 @@ var TypeScript; TypeScript.getAstWalkerFactory = getAstWalkerFactory; var ChildrenWalkers; (function(ChildrenWalkers) { - function walkNone(preAst, parent, walker) { + var walkNone = function walkNone(preAst, parent, walker) { // Nothing to do - } - ChildrenWalkers.walkNone = walkNone; - function walkListChildren(preAst, parent, walker) { + }; + var walkListChildren = function walkListChildren(preAst, parent, walker) { var len = preAst.members.length; if (walker.options.reverseSiblings) { for(var i = len - 1; i >= 0; i--){ @@ -228,18 +227,16 @@ var TypeScript; } } } - } - ChildrenWalkers.walkListChildren = walkListChildren; - function walkUnaryExpressionChildren(preAst, parent, walker) { + }; + var walkUnaryExpressionChildren = function walkUnaryExpressionChildren(preAst, parent, walker) { if (preAst.castTerm) { preAst.castTerm = walker.walk(preAst.castTerm, preAst); } if (preAst.operand) { preAst.operand = walker.walk(preAst.operand, preAst); } - } - ChildrenWalkers.walkUnaryExpressionChildren = walkUnaryExpressionChildren; - function walkBinaryExpressionChildren(preAst, parent, walker) { + }; + var walkBinaryExpressionChildren = function walkBinaryExpressionChildren(preAst, parent, walker) { if (walker.options.reverseSiblings) { if (preAst.operand2) { preAst.operand2 = walker.walk(preAst.operand2, preAst); @@ -255,15 +252,13 @@ var TypeScript; preAst.operand2 = walker.walk(preAst.operand2, preAst); } } - } - ChildrenWalkers.walkBinaryExpressionChildren = walkBinaryExpressionChildren; - function walkTypeReferenceChildren(preAst, parent, walker) { + }; + var walkTypeReferenceChildren = function walkTypeReferenceChildren(preAst, parent, walker) { if (preAst.term) { preAst.term = walker.walk(preAst.term, preAst); } - } - ChildrenWalkers.walkTypeReferenceChildren = walkTypeReferenceChildren; - function walkCallExpressionChildren(preAst, parent, walker) { + }; + var walkCallExpressionChildren = function walkCallExpressionChildren(preAst, parent, walker) { if (!walker.options.reverseSiblings) { preAst.target = walker.walk(preAst.target, preAst); } @@ -273,9 +268,8 @@ var TypeScript; if (walker.options.reverseSiblings && walker.options.goNextSibling) { preAst.target = walker.walk(preAst.target, preAst); } - } - ChildrenWalkers.walkCallExpressionChildren = walkCallExpressionChildren; - function walkTrinaryExpressionChildren(preAst, parent, walker) { + }; + var walkTrinaryExpressionChildren = function walkTrinaryExpressionChildren(preAst, parent, walker) { if (preAst.operand1) { preAst.operand1 = walker.walk(preAst.operand1, preAst); } @@ -285,9 +279,8 @@ var TypeScript; if (preAst.operand3 && walker.options.goNextSibling) { preAst.operand3 = walker.walk(preAst.operand3, preAst); } - } - ChildrenWalkers.walkTrinaryExpressionChildren = walkTrinaryExpressionChildren; - function walkFuncDeclChildren(preAst, parent, walker) { + }; + var walkFuncDeclChildren = function walkFuncDeclChildren(preAst, parent, walker) { if (preAst.name) { preAst.name = walker.walk(preAst.name, preAst); } @@ -300,9 +293,8 @@ var TypeScript; if (preAst.bod && preAst.bod.members.length > 0 && walker.options.goNextSibling) { preAst.bod = walker.walk(preAst.bod, preAst); } - } - ChildrenWalkers.walkFuncDeclChildren = walkFuncDeclChildren; - function walkBoundDeclChildren(preAst, parent, walker) { + }; + var walkBoundDeclChildren = function walkBoundDeclChildren(preAst, parent, walker) { if (preAst.id) { preAst.id = walker.walk(preAst.id, preAst); } @@ -312,15 +304,13 @@ var TypeScript; if (preAst.typeExpr && walker.options.goNextSibling) { preAst.typeExpr = walker.walk(preAst.typeExpr, preAst); } - } - ChildrenWalkers.walkBoundDeclChildren = walkBoundDeclChildren; - function walkReturnStatementChildren(preAst, parent, walker) { + }; + var walkReturnStatementChildren = function walkReturnStatementChildren(preAst, parent, walker) { if (preAst.returnExpression) { preAst.returnExpression = walker.walk(preAst.returnExpression, preAst); } - } - ChildrenWalkers.walkReturnStatementChildren = walkReturnStatementChildren; - function walkForStatementChildren(preAst, parent, walker) { + }; + var walkForStatementChildren = function walkForStatementChildren(preAst, parent, walker) { if (preAst.init) { preAst.init = walker.walk(preAst.init, preAst); } @@ -333,9 +323,8 @@ var TypeScript; if (preAst.body && walker.options.goNextSibling) { preAst.body = walker.walk(preAst.body, preAst); } - } - ChildrenWalkers.walkForStatementChildren = walkForStatementChildren; - function walkForInStatementChildren(preAst, parent, walker) { + }; + var walkForInStatementChildren = function walkForInStatementChildren(preAst, parent, walker) { preAst.lval = walker.walk(preAst.lval, preAst); if (walker.options.goNextSibling) { preAst.obj = walker.walk(preAst.obj, preAst); @@ -343,9 +332,8 @@ var TypeScript; if (preAst.body && walker.options.goNextSibling) { preAst.body = walker.walk(preAst.body, preAst); } - } - ChildrenWalkers.walkForInStatementChildren = walkForInStatementChildren; - function walkIfStatementChildren(preAst, parent, walker) { + }; + var walkIfStatementChildren = function walkIfStatementChildren(preAst, parent, walker) { preAst.cond = walker.walk(preAst.cond, preAst); if (preAst.thenBod && walker.options.goNextSibling) { preAst.thenBod = walker.walk(preAst.thenBod, preAst); @@ -353,97 +341,84 @@ var TypeScript; if (preAst.elseBod && walker.options.goNextSibling) { preAst.elseBod = walker.walk(preAst.elseBod, preAst); } - } - ChildrenWalkers.walkIfStatementChildren = walkIfStatementChildren; - function walkWhileStatementChildren(preAst, parent, walker) { + }; + var walkWhileStatementChildren = function walkWhileStatementChildren(preAst, parent, walker) { preAst.cond = walker.walk(preAst.cond, preAst); if (preAst.body && walker.options.goNextSibling) { preAst.body = walker.walk(preAst.body, preAst); } - } - ChildrenWalkers.walkWhileStatementChildren = walkWhileStatementChildren; - function walkDoWhileStatementChildren(preAst, parent, walker) { + }; + var walkDoWhileStatementChildren = function walkDoWhileStatementChildren(preAst, parent, walker) { preAst.cond = walker.walk(preAst.cond, preAst); if (preAst.body && walker.options.goNextSibling) { preAst.body = walker.walk(preAst.body, preAst); } - } - ChildrenWalkers.walkDoWhileStatementChildren = walkDoWhileStatementChildren; - function walkBlockChildren(preAst, parent, walker) { + }; + var walkBlockChildren = function walkBlockChildren(preAst, parent, walker) { if (preAst.statements) { preAst.statements = walker.walk(preAst.statements, preAst); } - } - ChildrenWalkers.walkBlockChildren = walkBlockChildren; - function walkCaseStatementChildren(preAst, parent, walker) { + }; + var walkCaseStatementChildren = function walkCaseStatementChildren(preAst, parent, walker) { if (preAst.expr) { preAst.expr = walker.walk(preAst.expr, preAst); } if (preAst.body && walker.options.goNextSibling) { preAst.body = walker.walk(preAst.body, preAst); } - } - ChildrenWalkers.walkCaseStatementChildren = walkCaseStatementChildren; - function walkSwitchStatementChildren(preAst, parent, walker) { + }; + var walkSwitchStatementChildren = function walkSwitchStatementChildren(preAst, parent, walker) { if (preAst.val) { preAst.val = walker.walk(preAst.val, preAst); } if (preAst.caseList && walker.options.goNextSibling) { preAst.caseList = walker.walk(preAst.caseList, preAst); } - } - ChildrenWalkers.walkSwitchStatementChildren = walkSwitchStatementChildren; - function walkTryChildren(preAst, parent, walker) { + }; + var walkTryChildren = function walkTryChildren(preAst, parent, walker) { if (preAst.body) { preAst.body = walker.walk(preAst.body, preAst); } - } - ChildrenWalkers.walkTryChildren = walkTryChildren; - function walkTryCatchChildren(preAst, parent, walker) { + }; + var walkTryCatchChildren = function walkTryCatchChildren(preAst, parent, walker) { if (preAst.tryNode) { preAst.tryNode = walker.walk(preAst.tryNode, preAst); } if (preAst.catchNode && walker.options.goNextSibling) { preAst.catchNode = walker.walk(preAst.catchNode, preAst); } - } - ChildrenWalkers.walkTryCatchChildren = walkTryCatchChildren; - function walkTryFinallyChildren(preAst, parent, walker) { + }; + var walkTryFinallyChildren = function walkTryFinallyChildren(preAst, parent, walker) { if (preAst.tryNode) { preAst.tryNode = walker.walk(preAst.tryNode, preAst); } if (preAst.finallyNode && walker.options.goNextSibling) { preAst.finallyNode = walker.walk(preAst.finallyNode, preAst); } - } - ChildrenWalkers.walkTryFinallyChildren = walkTryFinallyChildren; - function walkFinallyChildren(preAst, parent, walker) { + }; + var walkFinallyChildren = function walkFinallyChildren(preAst, parent, walker) { if (preAst.body) { preAst.body = walker.walk(preAst.body, preAst); } - } - ChildrenWalkers.walkFinallyChildren = walkFinallyChildren; - function walkCatchChildren(preAst, parent, walker) { + }; + var walkCatchChildren = function walkCatchChildren(preAst, parent, walker) { if (preAst.param) { preAst.param = walker.walk(preAst.param, preAst); } if (preAst.body && walker.options.goNextSibling) { preAst.body = walker.walk(preAst.body, preAst); } - } - ChildrenWalkers.walkCatchChildren = walkCatchChildren; - function walkRecordChildren(preAst, parent, walker) { + }; + var walkRecordChildren = function walkRecordChildren(preAst, parent, walker) { preAst.name = walker.walk(preAst.name, preAst); if (walker.options.goNextSibling && preAst.members) { preAst.members = walker.walk(preAst.members, preAst); } - } - ChildrenWalkers.walkRecordChildren = walkRecordChildren; - function walkNamedTypeChildren(preAst, parent, walker) { + }; + var walkNamedTypeChildren = function walkNamedTypeChildren(preAst, parent, walker) { walkRecordChildren(preAst, parent, walker); - } - ChildrenWalkers.walkNamedTypeChildren = walkNamedTypeChildren; - function walkClassDeclChildren(preAst, parent, walker) { + }; + var walkClassDeclChildren = function walkClassDeclChildren(preAst, parent, walker) { walkNamedTypeChildren(preAst, parent, walker); if (walker.options.goNextSibling && preAst.extendsList) { preAst.extendsList = walker.walk(preAst.extendsList, preAst); @@ -451,15 +426,13 @@ var TypeScript; if (walker.options.goNextSibling && preAst.implementsList) { preAst.implementsList = walker.walk(preAst.implementsList, preAst); } - } - ChildrenWalkers.walkClassDeclChildren = walkClassDeclChildren; - function walkScriptChildren(preAst, parent, walker) { + }; + var walkScriptChildren = function walkScriptChildren(preAst, parent, walker) { if (preAst.bod) { preAst.bod = walker.walk(preAst.bod, preAst); } - } - ChildrenWalkers.walkScriptChildren = walkScriptChildren; - function walkTypeDeclChildren(preAst, parent, walker) { + }; + var walkTypeDeclChildren = function walkTypeDeclChildren(preAst, parent, walker) { walkNamedTypeChildren(preAst, parent, walker); // walked arguments as part of members if (walker.options.goNextSibling && preAst.extendsList) { @@ -468,40 +441,67 @@ var TypeScript; if (walker.options.goNextSibling && preAst.implementsList) { preAst.implementsList = walker.walk(preAst.implementsList, preAst); } - } - ChildrenWalkers.walkTypeDeclChildren = walkTypeDeclChildren; - function walkModuleDeclChildren(preAst, parent, walker) { + }; + var walkModuleDeclChildren = function walkModuleDeclChildren(preAst, parent, walker) { walkRecordChildren(preAst, parent, walker); - } - ChildrenWalkers.walkModuleDeclChildren = walkModuleDeclChildren; - function walkImportDeclChildren(preAst, parent, walker) { + }; + var walkImportDeclChildren = function walkImportDeclChildren(preAst, parent, walker) { if (preAst.id) { preAst.id = walker.walk(preAst.id, preAst); } if (preAst.alias) { preAst.alias = walker.walk(preAst.alias, preAst); } - } - ChildrenWalkers.walkImportDeclChildren = walkImportDeclChildren; - function walkWithStatementChildren(preAst, parent, walker) { + }; + var walkWithStatementChildren = function walkWithStatementChildren(preAst, parent, walker) { if (preAst.expr) { preAst.expr = walker.walk(preAst.expr, preAst); } if (preAst.body && walker.options.goNextSibling) { preAst.body = walker.walk(preAst.body, preAst); } - } - ChildrenWalkers.walkWithStatementChildren = walkWithStatementChildren; - function walkLabelChildren(preAst, parent, walker) { + }; + var walkLabelChildren = function walkLabelChildren(preAst, parent, walker) { //TODO: Walk "id"? - } - ChildrenWalkers.walkLabelChildren = walkLabelChildren; - function walkLabeledStatementChildren(preAst, parent, walker) { + }; + var walkLabeledStatementChildren = function walkLabeledStatementChildren(preAst, parent, walker) { preAst.labels = walker.walk(preAst.labels, preAst); if (walker.options.goNextSibling) { preAst.stmt = walker.walk(preAst.stmt, preAst); } - } + }; + ChildrenWalkers.walkNone = walkNone; + ChildrenWalkers.walkListChildren = walkListChildren; + ChildrenWalkers.walkUnaryExpressionChildren = walkUnaryExpressionChildren; + ChildrenWalkers.walkBinaryExpressionChildren = walkBinaryExpressionChildren; + ChildrenWalkers.walkTypeReferenceChildren = walkTypeReferenceChildren; + ChildrenWalkers.walkCallExpressionChildren = walkCallExpressionChildren; + ChildrenWalkers.walkTrinaryExpressionChildren = walkTrinaryExpressionChildren; + ChildrenWalkers.walkFuncDeclChildren = walkFuncDeclChildren; + ChildrenWalkers.walkBoundDeclChildren = walkBoundDeclChildren; + ChildrenWalkers.walkReturnStatementChildren = walkReturnStatementChildren; + ChildrenWalkers.walkForStatementChildren = walkForStatementChildren; + ChildrenWalkers.walkForInStatementChildren = walkForInStatementChildren; + ChildrenWalkers.walkIfStatementChildren = walkIfStatementChildren; + ChildrenWalkers.walkWhileStatementChildren = walkWhileStatementChildren; + ChildrenWalkers.walkDoWhileStatementChildren = walkDoWhileStatementChildren; + ChildrenWalkers.walkBlockChildren = walkBlockChildren; + ChildrenWalkers.walkCaseStatementChildren = walkCaseStatementChildren; + ChildrenWalkers.walkSwitchStatementChildren = walkSwitchStatementChildren; + ChildrenWalkers.walkTryChildren = walkTryChildren; + ChildrenWalkers.walkTryCatchChildren = walkTryCatchChildren; + ChildrenWalkers.walkTryFinallyChildren = walkTryFinallyChildren; + ChildrenWalkers.walkFinallyChildren = walkFinallyChildren; + ChildrenWalkers.walkCatchChildren = walkCatchChildren; + ChildrenWalkers.walkRecordChildren = walkRecordChildren; + ChildrenWalkers.walkNamedTypeChildren = walkNamedTypeChildren; + ChildrenWalkers.walkClassDeclChildren = walkClassDeclChildren; + ChildrenWalkers.walkScriptChildren = walkScriptChildren; + ChildrenWalkers.walkTypeDeclChildren = walkTypeDeclChildren; + ChildrenWalkers.walkModuleDeclChildren = walkModuleDeclChildren; + ChildrenWalkers.walkImportDeclChildren = walkImportDeclChildren; + ChildrenWalkers.walkWithStatementChildren = walkWithStatementChildren; + ChildrenWalkers.walkLabelChildren = walkLabelChildren; ChildrenWalkers.walkLabeledStatementChildren = walkLabeledStatementChildren; })(ChildrenWalkers || (ChildrenWalkers = {})); })(TypeScript || (TypeScript = {})); diff --git a/crates/swc/tests/tsc-references/parserRealSource12.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource12.2.minified.js index 8a9041b83791d..809e1472bda37 100644 --- a/crates/swc/tests/tsc-references/parserRealSource12.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource12.2.minified.js @@ -2,7 +2,7 @@ // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. /// -var TypeScript, TypeScript1, globalAstWalkerFactory, ChildrenWalkers, AstWalkOptions, AstWalker, AstWalkerFactory; +var TypeScript, TypeScript1, globalAstWalkerFactory, ChildrenWalkers, AstWalkOptions, AstWalker, AstWalkerFactory, ChildrenWalkers1, walkRecordChildren, walkNamedTypeChildren; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; TypeScript1 = TypeScript || (TypeScript = {}), AstWalkOptions = function() { function AstWalkOptions() { @@ -46,75 +46,72 @@ TypeScript1 = TypeScript || (TypeScript = {}), AstWalkOptions = function() { }, AstWalkerFactory; }(), TypeScript1.AstWalkerFactory = AstWalkerFactory, TypeScript1.getAstWalkerFactory = function() { return globalAstWalkerFactory || (globalAstWalkerFactory = new AstWalkerFactory()), globalAstWalkerFactory; -}, function(ChildrenWalkers) { - function walkRecordChildren(preAst, parent, walker) { - preAst.name = walker.walk(preAst.name, preAst), walker.options.goNextSibling && preAst.members && (preAst.members = walker.walk(preAst.members, preAst)); - } - ChildrenWalkers.walkNone = function(preAst, parent, walker) { - // Nothing to do - }, ChildrenWalkers.walkListChildren = function(preAst, parent, walker) { - var len = preAst.members.length; - if (walker.options.reverseSiblings) for(var i = len - 1; i >= 0; i--)walker.options.goNextSibling && (preAst.members[i] = walker.walk(preAst.members[i], preAst)); - else for(var i = 0; i < len; i++)walker.options.goNextSibling && (preAst.members[i] = walker.walk(preAst.members[i], preAst)); - }, ChildrenWalkers.walkUnaryExpressionChildren = function(preAst, parent, walker) { - preAst.castTerm && (preAst.castTerm = walker.walk(preAst.castTerm, preAst)), preAst.operand && (preAst.operand = walker.walk(preAst.operand, preAst)); - }, ChildrenWalkers.walkBinaryExpressionChildren = function(preAst, parent, walker) { - walker.options.reverseSiblings ? (preAst.operand2 && (preAst.operand2 = walker.walk(preAst.operand2, preAst)), preAst.operand1 && walker.options.goNextSibling && (preAst.operand1 = walker.walk(preAst.operand1, preAst))) : (preAst.operand1 && (preAst.operand1 = walker.walk(preAst.operand1, preAst)), preAst.operand2 && walker.options.goNextSibling && (preAst.operand2 = walker.walk(preAst.operand2, preAst))); - }, ChildrenWalkers.walkTypeReferenceChildren = function(preAst, parent, walker) { - preAst.term && (preAst.term = walker.walk(preAst.term, preAst)); - }, ChildrenWalkers.walkCallExpressionChildren = function(preAst, parent, walker) { - walker.options.reverseSiblings || (preAst.target = walker.walk(preAst.target, preAst)), preAst.arguments && walker.options.goNextSibling && (preAst.arguments = walker.walk(preAst.arguments, preAst)), walker.options.reverseSiblings && walker.options.goNextSibling && (preAst.target = walker.walk(preAst.target, preAst)); - }, ChildrenWalkers.walkTrinaryExpressionChildren = function(preAst, parent, walker) { - preAst.operand1 && (preAst.operand1 = walker.walk(preAst.operand1, preAst)), preAst.operand2 && walker.options.goNextSibling && (preAst.operand2 = walker.walk(preAst.operand2, preAst)), preAst.operand3 && walker.options.goNextSibling && (preAst.operand3 = walker.walk(preAst.operand3, preAst)); - }, ChildrenWalkers.walkFuncDeclChildren = function(preAst, parent, walker) { - preAst.name && (preAst.name = walker.walk(preAst.name, preAst)), preAst.arguments && preAst.arguments.members.length > 0 && walker.options.goNextSibling && (preAst.arguments = walker.walk(preAst.arguments, preAst)), preAst.returnTypeAnnotation && walker.options.goNextSibling && (preAst.returnTypeAnnotation = walker.walk(preAst.returnTypeAnnotation, preAst)), preAst.bod && preAst.bod.members.length > 0 && walker.options.goNextSibling && (preAst.bod = walker.walk(preAst.bod, preAst)); - }, ChildrenWalkers.walkBoundDeclChildren = function(preAst, parent, walker) { - preAst.id && (preAst.id = walker.walk(preAst.id, preAst)), preAst.init && (preAst.init = walker.walk(preAst.init, preAst)), preAst.typeExpr && walker.options.goNextSibling && (preAst.typeExpr = walker.walk(preAst.typeExpr, preAst)); - }, ChildrenWalkers.walkReturnStatementChildren = function(preAst, parent, walker) { - preAst.returnExpression && (preAst.returnExpression = walker.walk(preAst.returnExpression, preAst)); - }, ChildrenWalkers.walkForStatementChildren = function(preAst, parent, walker) { - preAst.init && (preAst.init = walker.walk(preAst.init, preAst)), preAst.cond && walker.options.goNextSibling && (preAst.cond = walker.walk(preAst.cond, preAst)), preAst.incr && walker.options.goNextSibling && (preAst.incr = walker.walk(preAst.incr, preAst)), preAst.body && walker.options.goNextSibling && (preAst.body = walker.walk(preAst.body, preAst)); - }, ChildrenWalkers.walkForInStatementChildren = function(preAst, parent, walker) { - preAst.lval = walker.walk(preAst.lval, preAst), walker.options.goNextSibling && (preAst.obj = walker.walk(preAst.obj, preAst)), preAst.body && walker.options.goNextSibling && (preAst.body = walker.walk(preAst.body, preAst)); - }, ChildrenWalkers.walkIfStatementChildren = function(preAst, parent, walker) { - preAst.cond = walker.walk(preAst.cond, preAst), preAst.thenBod && walker.options.goNextSibling && (preAst.thenBod = walker.walk(preAst.thenBod, preAst)), preAst.elseBod && walker.options.goNextSibling && (preAst.elseBod = walker.walk(preAst.elseBod, preAst)); - }, ChildrenWalkers.walkWhileStatementChildren = function(preAst, parent, walker) { - preAst.cond = walker.walk(preAst.cond, preAst), preAst.body && walker.options.goNextSibling && (preAst.body = walker.walk(preAst.body, preAst)); - }, ChildrenWalkers.walkDoWhileStatementChildren = function(preAst, parent, walker) { - preAst.cond = walker.walk(preAst.cond, preAst), preAst.body && walker.options.goNextSibling && (preAst.body = walker.walk(preAst.body, preAst)); - }, ChildrenWalkers.walkBlockChildren = function(preAst, parent, walker) { - preAst.statements && (preAst.statements = walker.walk(preAst.statements, preAst)); - }, ChildrenWalkers.walkCaseStatementChildren = function(preAst, parent, walker) { - preAst.expr && (preAst.expr = walker.walk(preAst.expr, preAst)), preAst.body && walker.options.goNextSibling && (preAst.body = walker.walk(preAst.body, preAst)); - }, ChildrenWalkers.walkSwitchStatementChildren = function(preAst, parent, walker) { - preAst.val && (preAst.val = walker.walk(preAst.val, preAst)), preAst.caseList && walker.options.goNextSibling && (preAst.caseList = walker.walk(preAst.caseList, preAst)); - }, ChildrenWalkers.walkTryChildren = function(preAst, parent, walker) { - preAst.body && (preAst.body = walker.walk(preAst.body, preAst)); - }, ChildrenWalkers.walkTryCatchChildren = function(preAst, parent, walker) { - preAst.tryNode && (preAst.tryNode = walker.walk(preAst.tryNode, preAst)), preAst.catchNode && walker.options.goNextSibling && (preAst.catchNode = walker.walk(preAst.catchNode, preAst)); - }, ChildrenWalkers.walkTryFinallyChildren = function(preAst, parent, walker) { - preAst.tryNode && (preAst.tryNode = walker.walk(preAst.tryNode, preAst)), preAst.finallyNode && walker.options.goNextSibling && (preAst.finallyNode = walker.walk(preAst.finallyNode, preAst)); - }, ChildrenWalkers.walkFinallyChildren = function(preAst, parent, walker) { - preAst.body && (preAst.body = walker.walk(preAst.body, preAst)); - }, ChildrenWalkers.walkCatchChildren = function(preAst, parent, walker) { - preAst.param && (preAst.param = walker.walk(preAst.param, preAst)), preAst.body && walker.options.goNextSibling && (preAst.body = walker.walk(preAst.body, preAst)); - }, ChildrenWalkers.walkRecordChildren = walkRecordChildren, ChildrenWalkers.walkNamedTypeChildren = function(preAst, parent, walker) { - walkRecordChildren(preAst, parent, walker); - }, ChildrenWalkers.walkClassDeclChildren = function(preAst, parent, walker) { - walkRecordChildren(preAst, parent, walker), walker.options.goNextSibling && preAst.extendsList && (preAst.extendsList = walker.walk(preAst.extendsList, preAst)), walker.options.goNextSibling && preAst.implementsList && (preAst.implementsList = walker.walk(preAst.implementsList, preAst)); - }, ChildrenWalkers.walkScriptChildren = function(preAst, parent, walker) { - preAst.bod && (preAst.bod = walker.walk(preAst.bod, preAst)); - }, ChildrenWalkers.walkTypeDeclChildren = function(preAst, parent, walker) { - walkRecordChildren(preAst, parent, walker), walker.options.goNextSibling && preAst.extendsList && (preAst.extendsList = walker.walk(preAst.extendsList, preAst)), walker.options.goNextSibling && preAst.implementsList && (preAst.implementsList = walker.walk(preAst.implementsList, preAst)); - }, ChildrenWalkers.walkModuleDeclChildren = function(preAst, parent, walker) { - walkRecordChildren(preAst, parent, walker); - }, ChildrenWalkers.walkImportDeclChildren = function(preAst, parent, walker) { - preAst.id && (preAst.id = walker.walk(preAst.id, preAst)), preAst.alias && (preAst.alias = walker.walk(preAst.alias, preAst)); - }, ChildrenWalkers.walkWithStatementChildren = function(preAst, parent, walker) { - preAst.expr && (preAst.expr = walker.walk(preAst.expr, preAst)), preAst.body && walker.options.goNextSibling && (preAst.body = walker.walk(preAst.body, preAst)); - }, ChildrenWalkers.walkLabelChildren = function(preAst, parent, walker) { - //TODO: Walk "id"? - }, ChildrenWalkers.walkLabeledStatementChildren = function(preAst, parent, walker) { - preAst.labels = walker.walk(preAst.labels, preAst), walker.options.goNextSibling && (preAst.stmt = walker.walk(preAst.stmt, preAst)); - }; -}(ChildrenWalkers || (ChildrenWalkers = {})); +}, ChildrenWalkers1 = ChildrenWalkers || (ChildrenWalkers = {}), walkRecordChildren = function(preAst, parent, walker) { + preAst.name = walker.walk(preAst.name, preAst), walker.options.goNextSibling && preAst.members && (preAst.members = walker.walk(preAst.members, preAst)); +}, walkNamedTypeChildren = function(preAst, parent, walker) { + walkRecordChildren(preAst, parent, walker); +}, ChildrenWalkers1.walkNone = function(preAst, parent, walker) { +// Nothing to do +}, ChildrenWalkers1.walkListChildren = function(preAst, parent, walker) { + var len = preAst.members.length; + if (walker.options.reverseSiblings) for(var i = len - 1; i >= 0; i--)walker.options.goNextSibling && (preAst.members[i] = walker.walk(preAst.members[i], preAst)); + else for(var i = 0; i < len; i++)walker.options.goNextSibling && (preAst.members[i] = walker.walk(preAst.members[i], preAst)); +}, ChildrenWalkers1.walkUnaryExpressionChildren = function(preAst, parent, walker) { + preAst.castTerm && (preAst.castTerm = walker.walk(preAst.castTerm, preAst)), preAst.operand && (preAst.operand = walker.walk(preAst.operand, preAst)); +}, ChildrenWalkers1.walkBinaryExpressionChildren = function(preAst, parent, walker) { + walker.options.reverseSiblings ? (preAst.operand2 && (preAst.operand2 = walker.walk(preAst.operand2, preAst)), preAst.operand1 && walker.options.goNextSibling && (preAst.operand1 = walker.walk(preAst.operand1, preAst))) : (preAst.operand1 && (preAst.operand1 = walker.walk(preAst.operand1, preAst)), preAst.operand2 && walker.options.goNextSibling && (preAst.operand2 = walker.walk(preAst.operand2, preAst))); +}, ChildrenWalkers1.walkTypeReferenceChildren = function(preAst, parent, walker) { + preAst.term && (preAst.term = walker.walk(preAst.term, preAst)); +}, ChildrenWalkers1.walkCallExpressionChildren = function(preAst, parent, walker) { + walker.options.reverseSiblings || (preAst.target = walker.walk(preAst.target, preAst)), preAst.arguments && walker.options.goNextSibling && (preAst.arguments = walker.walk(preAst.arguments, preAst)), walker.options.reverseSiblings && walker.options.goNextSibling && (preAst.target = walker.walk(preAst.target, preAst)); +}, ChildrenWalkers1.walkTrinaryExpressionChildren = function(preAst, parent, walker) { + preAst.operand1 && (preAst.operand1 = walker.walk(preAst.operand1, preAst)), preAst.operand2 && walker.options.goNextSibling && (preAst.operand2 = walker.walk(preAst.operand2, preAst)), preAst.operand3 && walker.options.goNextSibling && (preAst.operand3 = walker.walk(preAst.operand3, preAst)); +}, ChildrenWalkers1.walkFuncDeclChildren = function(preAst, parent, walker) { + preAst.name && (preAst.name = walker.walk(preAst.name, preAst)), preAst.arguments && preAst.arguments.members.length > 0 && walker.options.goNextSibling && (preAst.arguments = walker.walk(preAst.arguments, preAst)), preAst.returnTypeAnnotation && walker.options.goNextSibling && (preAst.returnTypeAnnotation = walker.walk(preAst.returnTypeAnnotation, preAst)), preAst.bod && preAst.bod.members.length > 0 && walker.options.goNextSibling && (preAst.bod = walker.walk(preAst.bod, preAst)); +}, ChildrenWalkers1.walkBoundDeclChildren = function(preAst, parent, walker) { + preAst.id && (preAst.id = walker.walk(preAst.id, preAst)), preAst.init && (preAst.init = walker.walk(preAst.init, preAst)), preAst.typeExpr && walker.options.goNextSibling && (preAst.typeExpr = walker.walk(preAst.typeExpr, preAst)); +}, ChildrenWalkers1.walkReturnStatementChildren = function(preAst, parent, walker) { + preAst.returnExpression && (preAst.returnExpression = walker.walk(preAst.returnExpression, preAst)); +}, ChildrenWalkers1.walkForStatementChildren = function(preAst, parent, walker) { + preAst.init && (preAst.init = walker.walk(preAst.init, preAst)), preAst.cond && walker.options.goNextSibling && (preAst.cond = walker.walk(preAst.cond, preAst)), preAst.incr && walker.options.goNextSibling && (preAst.incr = walker.walk(preAst.incr, preAst)), preAst.body && walker.options.goNextSibling && (preAst.body = walker.walk(preAst.body, preAst)); +}, ChildrenWalkers1.walkForInStatementChildren = function(preAst, parent, walker) { + preAst.lval = walker.walk(preAst.lval, preAst), walker.options.goNextSibling && (preAst.obj = walker.walk(preAst.obj, preAst)), preAst.body && walker.options.goNextSibling && (preAst.body = walker.walk(preAst.body, preAst)); +}, ChildrenWalkers1.walkIfStatementChildren = function(preAst, parent, walker) { + preAst.cond = walker.walk(preAst.cond, preAst), preAst.thenBod && walker.options.goNextSibling && (preAst.thenBod = walker.walk(preAst.thenBod, preAst)), preAst.elseBod && walker.options.goNextSibling && (preAst.elseBod = walker.walk(preAst.elseBod, preAst)); +}, ChildrenWalkers1.walkWhileStatementChildren = function(preAst, parent, walker) { + preAst.cond = walker.walk(preAst.cond, preAst), preAst.body && walker.options.goNextSibling && (preAst.body = walker.walk(preAst.body, preAst)); +}, ChildrenWalkers1.walkDoWhileStatementChildren = function(preAst, parent, walker) { + preAst.cond = walker.walk(preAst.cond, preAst), preAst.body && walker.options.goNextSibling && (preAst.body = walker.walk(preAst.body, preAst)); +}, ChildrenWalkers1.walkBlockChildren = function(preAst, parent, walker) { + preAst.statements && (preAst.statements = walker.walk(preAst.statements, preAst)); +}, ChildrenWalkers1.walkCaseStatementChildren = function(preAst, parent, walker) { + preAst.expr && (preAst.expr = walker.walk(preAst.expr, preAst)), preAst.body && walker.options.goNextSibling && (preAst.body = walker.walk(preAst.body, preAst)); +}, ChildrenWalkers1.walkSwitchStatementChildren = function(preAst, parent, walker) { + preAst.val && (preAst.val = walker.walk(preAst.val, preAst)), preAst.caseList && walker.options.goNextSibling && (preAst.caseList = walker.walk(preAst.caseList, preAst)); +}, ChildrenWalkers1.walkTryChildren = function(preAst, parent, walker) { + preAst.body && (preAst.body = walker.walk(preAst.body, preAst)); +}, ChildrenWalkers1.walkTryCatchChildren = function(preAst, parent, walker) { + preAst.tryNode && (preAst.tryNode = walker.walk(preAst.tryNode, preAst)), preAst.catchNode && walker.options.goNextSibling && (preAst.catchNode = walker.walk(preAst.catchNode, preAst)); +}, ChildrenWalkers1.walkTryFinallyChildren = function(preAst, parent, walker) { + preAst.tryNode && (preAst.tryNode = walker.walk(preAst.tryNode, preAst)), preAst.finallyNode && walker.options.goNextSibling && (preAst.finallyNode = walker.walk(preAst.finallyNode, preAst)); +}, ChildrenWalkers1.walkFinallyChildren = function(preAst, parent, walker) { + preAst.body && (preAst.body = walker.walk(preAst.body, preAst)); +}, ChildrenWalkers1.walkCatchChildren = function(preAst, parent, walker) { + preAst.param && (preAst.param = walker.walk(preAst.param, preAst)), preAst.body && walker.options.goNextSibling && (preAst.body = walker.walk(preAst.body, preAst)); +}, ChildrenWalkers1.walkRecordChildren = walkRecordChildren, ChildrenWalkers1.walkNamedTypeChildren = walkNamedTypeChildren, ChildrenWalkers1.walkClassDeclChildren = function(preAst, parent, walker) { + walkNamedTypeChildren(preAst, parent, walker), walker.options.goNextSibling && preAst.extendsList && (preAst.extendsList = walker.walk(preAst.extendsList, preAst)), walker.options.goNextSibling && preAst.implementsList && (preAst.implementsList = walker.walk(preAst.implementsList, preAst)); +}, ChildrenWalkers1.walkScriptChildren = function(preAst, parent, walker) { + preAst.bod && (preAst.bod = walker.walk(preAst.bod, preAst)); +}, ChildrenWalkers1.walkTypeDeclChildren = function(preAst, parent, walker) { + walkNamedTypeChildren(preAst, parent, walker), walker.options.goNextSibling && preAst.extendsList && (preAst.extendsList = walker.walk(preAst.extendsList, preAst)), walker.options.goNextSibling && preAst.implementsList && (preAst.implementsList = walker.walk(preAst.implementsList, preAst)); +}, ChildrenWalkers1.walkModuleDeclChildren = function(preAst, parent, walker) { + walkRecordChildren(preAst, parent, walker); +}, ChildrenWalkers1.walkImportDeclChildren = function(preAst, parent, walker) { + preAst.id && (preAst.id = walker.walk(preAst.id, preAst)), preAst.alias && (preAst.alias = walker.walk(preAst.alias, preAst)); +}, ChildrenWalkers1.walkWithStatementChildren = function(preAst, parent, walker) { + preAst.expr && (preAst.expr = walker.walk(preAst.expr, preAst)), preAst.body && walker.options.goNextSibling && (preAst.body = walker.walk(preAst.body, preAst)); +}, ChildrenWalkers1.walkLabelChildren = function(preAst, parent, walker) { +//TODO: Walk "id"? +}, ChildrenWalkers1.walkLabeledStatementChildren = function(preAst, parent, walker) { + preAst.labels = walker.walk(preAst.labels, preAst), walker.options.goNextSibling && (preAst.stmt = walker.walk(preAst.stmt, preAst)); +}; diff --git a/crates/swc/tests/tsc-references/parserRealSource13.1.normal.js b/crates/swc/tests/tsc-references/parserRealSource13.1.normal.js index 0eafe15490f51..bb1b798fa813f 100644 --- a/crates/swc/tests/tsc-references/parserRealSource13.1.normal.js +++ b/crates/swc/tests/tsc-references/parserRealSource13.1.normal.js @@ -3,8 +3,7 @@ // See LICENSE.txt in the project root for complete license information. /// var TypeScript; -(function(TypeScript1) { - var AstWalkerWithDetailCallback; +(function(TypeScript) { (function(AstWalkerWithDetailCallback) { function walk(script, callback) { var pre = function(cur, parent) { @@ -31,5 +30,5 @@ var TypeScript; } return true; } - })(AstWalkerWithDetailCallback = TypeScript1.AstWalkerWithDetailCallback || (TypeScript1.AstWalkerWithDetailCallback = {})); + })(TypeScript.AstWalkerWithDetailCallback || (TypeScript.AstWalkerWithDetailCallback = {})); })(TypeScript || (TypeScript = {})); diff --git a/crates/swc/tests/tsc-references/parserRealSource13.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource13.2.minified.js index 98256200627c6..c70aa22fd4e69 100644 --- a/crates/swc/tests/tsc-references/parserRealSource13.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource13.2.minified.js @@ -10,7 +10,7 @@ var TypeScript, TypeScript1; return callback[callbackString] ? callback[callbackString](pre, ast) : !callback.DefaultCallback || callback.DefaultCallback(pre, ast); } AstWalkerWithDetailCallback.walk = function(script, callback) { - var walker = TypeScript.getAstWalkerFactory().getWalker(function(cur, parent) { + var walker = TypeScript1.getAstWalkerFactory().getWalker(function(cur, parent) { return walker.options.goChildren = AstWalkerCallback(!0, cur, callback), cur; }, function(cur, parent) { return AstWalkerCallback(!1, cur, callback), cur; diff --git a/crates/swc/tests/tsc-references/parserRealSource14.1.normal.js b/crates/swc/tests/tsc-references/parserRealSource14.1.normal.js index 506b68c722cea..5649d1b830c59 100644 --- a/crates/swc/tests/tsc-references/parserRealSource14.1.normal.js +++ b/crates/swc/tests/tsc-references/parserRealSource14.1.normal.js @@ -4,7 +4,7 @@ /// import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var TypeScript; -(function(TypeScript1) { +(function(TypeScript) { var lastOf = function lastOf(items) { return items === null || items.length === 0 ? null : items[items.length - 1]; }; @@ -20,7 +20,7 @@ var TypeScript; return true; }; var getAstPathToPosition = function getAstPathToPosition(script, pos) { - var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : GetAstPathOptions.Default; + var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0; var lookInComments = function(comments) { if (comments && comments.length > 0) { for(var i = 0; i < comments.length; i++){ @@ -44,7 +44,7 @@ var TypeScript; // bar // 0123 // If "position == 3", the caret is at the "right" of the "r" character, which should be considered valid - var inclusive = hasFlag(options, GetAstPathOptions.EdgeInclusive) || cur.nodeType === TypeScript.NodeType.Name || pos === script.limChar; // Special "EOF" case + var inclusive = hasFlag(options, 1) || cur.nodeType === TypeScript.NodeType.Name || pos === script.limChar; // Special "EOF" case var minChar = cur.minChar; var limChar = cur.limChar + (inclusive ? 1 : 0); if (pos >= minChar && pos < limChar) { @@ -64,7 +64,7 @@ var TypeScript; if (pos >= minChar) { lookInComments(cur.postComments); } - if (!hasFlag(options, GetAstPathOptions.DontPruneSearchBasedOnPosition)) { + if (!hasFlag(options, 2)) { // Don't go further down the tree if pos is outside of [minChar, limChar] walker.options.goChildren = minChar <= pos && pos <= limChar; } @@ -108,9 +108,9 @@ var TypeScript; var path = new AstPath(); TypeScript.getAstWalkerFactory().walk(ast, pre, post, null, path); }; - TypeScript1.lastOf = lastOf; - TypeScript1.max = max; - TypeScript1.min = min; + TypeScript.lastOf = lastOf; + TypeScript.max = max; + TypeScript.min = min; var AstPath = /*#__PURE__*/ function() { "use strict"; function AstPath() { @@ -330,28 +330,21 @@ var TypeScript; }; return AstPath; }(); - TypeScript1.AstPath = AstPath; - TypeScript1.isValidAstNode = isValidAstNode; + TypeScript.AstPath = AstPath; + TypeScript.isValidAstNode = isValidAstNode; var AstPathContext = function AstPathContext() { "use strict"; _class_call_check(this, AstPathContext); this.path = new TypeScript.AstPath(); }; - TypeScript1.AstPathContext = AstPathContext; + TypeScript.AstPathContext = AstPathContext; var GetAstPathOptions; (function(GetAstPathOptions) { GetAstPathOptions[GetAstPathOptions["Default"] = 0] = "Default"; GetAstPathOptions[GetAstPathOptions["EdgeInclusive"] = 1] = "EdgeInclusive"; - GetAstPathOptions[GetAstPathOptions[//We need this options dealing with an AST coming from an incomplete AST. For example: - // class foo { // r - // If we ask for the AST at the position after the "r" character, we won't see we are - // inside a comment, because the "class" AST node has a limChar corresponding to the position of - // the "{" character, meaning we don't traverse the tree down to the stmt list of the class, meaning - // we don't find the "precomment" attached to the errorneous empty stmt. - //TODO: It would be nice to be able to get rid of this. - "DontPruneSearchBasedOnPosition"] = 2] = "DontPruneSearchBasedOnPosition"; - })(GetAstPathOptions = TypeScript1.GetAstPathOptions || (TypeScript1.GetAstPathOptions = {})); - TypeScript1.getAstPathToPosition = getAstPathToPosition; - TypeScript1.getTokenizationOffset = getTokenizationOffset; - TypeScript1.walkAST = walkAST; + GetAstPathOptions[GetAstPathOptions["DontPruneSearchBasedOnPosition"] = 2] = "DontPruneSearchBasedOnPosition"; + })(GetAstPathOptions = TypeScript.GetAstPathOptions || (TypeScript.GetAstPathOptions = {})); + TypeScript.getAstPathToPosition = getAstPathToPosition; + TypeScript.getTokenizationOffset = getTokenizationOffset; + TypeScript.walkAST = walkAST; })(TypeScript || (TypeScript = {})); diff --git a/crates/swc/tests/tsc-references/parserRealSource14.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource14.2.minified.js index 63535caf1f805..49169e9581965 100644 --- a/crates/swc/tests/tsc-references/parserRealSource14.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource14.2.minified.js @@ -2,7 +2,7 @@ // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. /// -var TypeScript, TypeScript1, GetAstPathOptions, lastOf, max, isValidAstNode, AstPath, AstPathContext, GetAstPathOptions1; +var TypeScript, TypeScript1, lastOf, max, isValidAstNode, AstPath, AstPathContext, GetAstPathOptions; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; TypeScript1 = TypeScript || (TypeScript = {}), lastOf = function(items) { return null === items || 0 === items.length ? null : items[items.length - 1]; @@ -36,7 +36,7 @@ TypeScript1 = TypeScript || (TypeScript = {}), lastOf = function(items) { if (this.top == this.ast.length - 1) throw Error("Invalid call to 'down'"); this.top++; }, _proto.nodeType = function() { - return null == this.ast() ? TypeScript.NodeType.None : this.ast().nodeType; + return null == this.ast() ? TypeScript1.NodeType.None : this.ast().nodeType; }, _proto.ast = function() { return AstPath.reverseIndexOf(this.asts, this.asts.length - (this.top + 1)); }, _proto.parent = function() { @@ -46,129 +46,122 @@ TypeScript1 = TypeScript || (TypeScript = {}), lastOf = function(items) { }, _proto.get = function(index) { return this.asts[index]; }, _proto.isNameOfClass = function() { - return null !== this.ast() && null !== this.parent() && this.ast().nodeType === TypeScript.NodeType.Name && this.parent().nodeType === TypeScript.NodeType.ClassDeclaration && this.parent().name === this.ast(); + return null !== this.ast() && null !== this.parent() && this.ast().nodeType === TypeScript1.NodeType.Name && this.parent().nodeType === TypeScript1.NodeType.ClassDeclaration && this.parent().name === this.ast(); }, _proto.isNameOfInterface = function() { - return null !== this.ast() && null !== this.parent() && this.ast().nodeType === TypeScript.NodeType.Name && this.parent().nodeType === TypeScript.NodeType.InterfaceDeclaration && this.parent().name === this.ast(); + return null !== this.ast() && null !== this.parent() && this.ast().nodeType === TypeScript1.NodeType.Name && this.parent().nodeType === TypeScript1.NodeType.InterfaceDeclaration && this.parent().name === this.ast(); }, _proto.isNameOfArgument = function() { - return null !== this.ast() && null !== this.parent() && this.ast().nodeType === TypeScript.NodeType.Name && this.parent().nodeType === TypeScript.NodeType.ArgDecl && this.parent().id === this.ast(); + return null !== this.ast() && null !== this.parent() && this.ast().nodeType === TypeScript1.NodeType.Name && this.parent().nodeType === TypeScript1.NodeType.ArgDecl && this.parent().id === this.ast(); }, _proto.isNameOfVariable = function() { - return null !== this.ast() && null !== this.parent() && this.ast().nodeType === TypeScript.NodeType.Name && this.parent().nodeType === TypeScript.NodeType.VarDecl && this.parent().id === this.ast(); + return null !== this.ast() && null !== this.parent() && this.ast().nodeType === TypeScript1.NodeType.Name && this.parent().nodeType === TypeScript1.NodeType.VarDecl && this.parent().id === this.ast(); }, _proto.isNameOfModule = function() { - return null !== this.ast() && null !== this.parent() && this.ast().nodeType === TypeScript.NodeType.Name && this.parent().nodeType === TypeScript.NodeType.ModuleDeclaration && this.parent().name === this.ast(); + return null !== this.ast() && null !== this.parent() && this.ast().nodeType === TypeScript1.NodeType.Name && this.parent().nodeType === TypeScript1.NodeType.ModuleDeclaration && this.parent().name === this.ast(); }, _proto.isNameOfFunction = function() { - return null !== this.ast() && null !== this.parent() && this.ast().nodeType === TypeScript.NodeType.Name && this.parent().nodeType === TypeScript.NodeType.FuncDecl && this.parent().name === this.ast(); + return null !== this.ast() && null !== this.parent() && this.ast().nodeType === TypeScript1.NodeType.Name && this.parent().nodeType === TypeScript1.NodeType.FuncDecl && this.parent().name === this.ast(); }, _proto.isChildOfScript = function() { var ast = lastOf(this.asts); - return this.count() >= 3 && this.asts[this.top] === ast && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript.NodeType.Script; + return this.count() >= 3 && this.asts[this.top] === ast && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript1.NodeType.Script; }, _proto.isChildOfModule = function() { var ast = lastOf(this.asts); - return this.count() >= 3 && this.asts[this.top] === ast && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript.NodeType.ModuleDeclaration; + return this.count() >= 3 && this.asts[this.top] === ast && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript1.NodeType.ModuleDeclaration; }, _proto.isChildOfClass = function() { var ast = lastOf(this.asts); - return this.count() >= 3 && this.asts[this.top] === ast && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript.NodeType.ClassDeclaration; + return this.count() >= 3 && this.asts[this.top] === ast && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript1.NodeType.ClassDeclaration; }, _proto.isArgumentOfClassConstructor = function() { var ast = lastOf(this.asts); - return this.count() >= 5 && this.asts[this.top] === ast && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript.NodeType.FuncDecl && this.asts[this.top - 3].nodeType === TypeScript.NodeType.List && this.asts[this.top - 4].nodeType === TypeScript.NodeType.ClassDeclaration && this.asts[this.top - 2].isConstructor && this.asts[this.top - 2].arguments === this.asts[this.top - 1] && this.asts[this.top - 4].constructorDecl === this.asts[this.top - 2]; + return this.count() >= 5 && this.asts[this.top] === ast && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript1.NodeType.FuncDecl && this.asts[this.top - 3].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 4].nodeType === TypeScript1.NodeType.ClassDeclaration && this.asts[this.top - 2].isConstructor && this.asts[this.top - 2].arguments === this.asts[this.top - 1] && this.asts[this.top - 4].constructorDecl === this.asts[this.top - 2]; }, _proto.isChildOfInterface = function() { var ast = lastOf(this.asts); - return this.count() >= 3 && this.asts[this.top] === ast && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript.NodeType.InterfaceDeclaration; + return this.count() >= 3 && this.asts[this.top] === ast && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript1.NodeType.InterfaceDeclaration; }, _proto.isTopLevelImplicitModule = function() { - return this.count() >= 1 && this.asts[this.top].nodeType === TypeScript.NodeType.ModuleDeclaration && TypeScript.hasFlag(this.asts[this.top].modFlags, TypeScript.ModuleFlags.IsWholeFile); + return this.count() >= 1 && this.asts[this.top].nodeType === TypeScript1.NodeType.ModuleDeclaration && TypeScript1.hasFlag(this.asts[this.top].modFlags, TypeScript1.ModuleFlags.IsWholeFile); }, _proto.isBodyOfTopLevelImplicitModule = function() { - return this.count() >= 2 && this.asts[this.top - 0].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].nodeType === TypeScript.NodeType.ModuleDeclaration && this.asts[this.top - 1].members == this.asts[this.top - 0] && TypeScript.hasFlag(this.asts[this.top - 1].modFlags, TypeScript.ModuleFlags.IsWholeFile); + return this.count() >= 2 && this.asts[this.top - 0].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.ModuleDeclaration && this.asts[this.top - 1].members == this.asts[this.top - 0] && TypeScript1.hasFlag(this.asts[this.top - 1].modFlags, TypeScript1.ModuleFlags.IsWholeFile); }, _proto.isBodyOfScript = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Script && this.asts[this.top - 1].bod == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.Script && this.asts[this.top - 1].bod == this.asts[this.top - 0]; }, _proto.isBodyOfSwitch = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Switch && this.asts[this.top - 1].caseList == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.Switch && this.asts[this.top - 1].caseList == this.asts[this.top - 0]; }, _proto.isBodyOfModule = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.ModuleDeclaration && this.asts[this.top - 1].members == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.ModuleDeclaration && this.asts[this.top - 1].members == this.asts[this.top - 0]; }, _proto.isBodyOfClass = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.ClassDeclaration && this.asts[this.top - 1].members == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.ClassDeclaration && this.asts[this.top - 1].members == this.asts[this.top - 0]; }, _proto.isBodyOfFunction = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.FuncDecl && this.asts[this.top - 1].bod == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.FuncDecl && this.asts[this.top - 1].bod == this.asts[this.top - 0]; }, _proto.isBodyOfInterface = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.InterfaceDeclaration && this.asts[this.top - 1].members == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.InterfaceDeclaration && this.asts[this.top - 1].members == this.asts[this.top - 0]; }, _proto.isBodyOfBlock = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Block && this.asts[this.top - 1].statements == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.Block && this.asts[this.top - 1].statements == this.asts[this.top - 0]; }, _proto.isBodyOfFor = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.For && this.asts[this.top - 1].body == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.For && this.asts[this.top - 1].body == this.asts[this.top - 0]; }, _proto.isBodyOfCase = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Case && this.asts[this.top - 1].body == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.Case && this.asts[this.top - 1].body == this.asts[this.top - 0]; }, _proto.isBodyOfTry = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Try && this.asts[this.top - 1].body == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.Try && this.asts[this.top - 1].body == this.asts[this.top - 0]; }, _proto.isBodyOfCatch = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Catch && this.asts[this.top - 1].body == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.Catch && this.asts[this.top - 1].body == this.asts[this.top - 0]; }, _proto.isBodyOfDoWhile = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.DoWhile && this.asts[this.top - 1].body == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.DoWhile && this.asts[this.top - 1].body == this.asts[this.top - 0]; }, _proto.isBodyOfWhile = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.While && this.asts[this.top - 1].body == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.While && this.asts[this.top - 1].body == this.asts[this.top - 0]; }, _proto.isBodyOfForIn = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.ForIn && this.asts[this.top - 1].body == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.ForIn && this.asts[this.top - 1].body == this.asts[this.top - 0]; }, _proto.isBodyOfWith = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.With && this.asts[this.top - 1].body == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.With && this.asts[this.top - 1].body == this.asts[this.top - 0]; }, _proto.isBodyOfFinally = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Finally && this.asts[this.top - 1].body == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.Finally && this.asts[this.top - 1].body == this.asts[this.top - 0]; }, _proto.isCaseOfSwitch = function() { - return this.count() >= 3 && this.asts[this.top - 2].nodeType === TypeScript.NodeType.Switch && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].caseList == this.asts[this.top - 1]; + return this.count() >= 3 && this.asts[this.top - 2].nodeType === TypeScript1.NodeType.Switch && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 2].caseList == this.asts[this.top - 1]; }, _proto.isDefaultCaseOfSwitch = function() { - return this.count() >= 3 && this.asts[this.top - 2].nodeType === TypeScript.NodeType.Switch && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].caseList == this.asts[this.top - 1] && this.asts[this.top - 2].defaultCase == this.asts[this.top - 0]; + return this.count() >= 3 && this.asts[this.top - 2].nodeType === TypeScript1.NodeType.Switch && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 2].caseList == this.asts[this.top - 1] && this.asts[this.top - 2].defaultCase == this.asts[this.top - 0]; }, _proto.isListOfObjectLit = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.ObjectLit && this.asts[this.top - 0].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].operand == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.ObjectLit && this.asts[this.top - 0].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 1].operand == this.asts[this.top - 0]; }, _proto.isBodyOfObjectLit = function() { return this.isListOfObjectLit(); }, _proto.isEmptyListOfObjectLit = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.ObjectLit && this.asts[this.top - 0].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].operand == this.asts[this.top - 0] && 0 == this.asts[this.top - 0].members.length; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.ObjectLit && this.asts[this.top - 0].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 1].operand == this.asts[this.top - 0] && 0 == this.asts[this.top - 0].members.length; }, _proto.isMemberOfObjectLit = function() { - return this.count() >= 3 && this.asts[this.top - 2].nodeType === TypeScript.NodeType.ObjectLit && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 0].nodeType === TypeScript.NodeType.Member && this.asts[this.top - 2].operand == this.asts[this.top - 1]; + return this.count() >= 3 && this.asts[this.top - 2].nodeType === TypeScript1.NodeType.ObjectLit && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 0].nodeType === TypeScript1.NodeType.Member && this.asts[this.top - 2].operand == this.asts[this.top - 1]; }, _proto.isNameOfMemberOfObjectLit = function() { - return this.count() >= 4 && this.asts[this.top - 3].nodeType === TypeScript.NodeType.ObjectLit && this.asts[this.top - 2].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Member && this.asts[this.top - 0].nodeType === TypeScript.NodeType.Name && this.asts[this.top - 3].operand == this.asts[this.top - 2]; + return this.count() >= 4 && this.asts[this.top - 3].nodeType === TypeScript1.NodeType.ObjectLit && this.asts[this.top - 2].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.Member && this.asts[this.top - 0].nodeType === TypeScript1.NodeType.Name && this.asts[this.top - 3].operand == this.asts[this.top - 2]; }, _proto.isListOfArrayLit = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.ArrayLit && this.asts[this.top - 0].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].operand == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.ArrayLit && this.asts[this.top - 0].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 1].operand == this.asts[this.top - 0]; }, _proto.isTargetOfMember = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Member && this.asts[this.top - 1].operand1 === this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.Member && this.asts[this.top - 1].operand1 === this.asts[this.top - 0]; }, _proto.isMemberOfMember = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Member && this.asts[this.top - 1].operand2 === this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.Member && this.asts[this.top - 1].operand2 === this.asts[this.top - 0]; }, _proto.isItemOfList = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.List; //(this.asts[this.top - 1]).operand2 === this.asts[this.top - 0]; }, _proto.isThenOfIf = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.If && this.asts[this.top - 1].thenBod == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.If && this.asts[this.top - 1].thenBod == this.asts[this.top - 0]; }, _proto.isElseOfIf = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.If && this.asts[this.top - 1].elseBod == this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.If && this.asts[this.top - 1].elseBod == this.asts[this.top - 0]; }, _proto.isBodyOfDefaultCase = function() { return this.isBodyOfCase(); }, _proto.isSingleStatementList = function() { - return this.count() >= 1 && this.asts[this.top].nodeType === TypeScript.NodeType.List && 1 === this.asts[this.top].members.length; + return this.count() >= 1 && this.asts[this.top].nodeType === TypeScript1.NodeType.List && 1 === this.asts[this.top].members.length; }, _proto.isArgumentListOfFunction = function() { - return this.count() >= 2 && this.asts[this.top - 0].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].nodeType === TypeScript.NodeType.FuncDecl && this.asts[this.top - 1].arguments === this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 0].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.FuncDecl && this.asts[this.top - 1].arguments === this.asts[this.top - 0]; }, _proto.isArgumentOfFunction = function() { - return this.count() >= 3 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript.NodeType.FuncDecl && this.asts[this.top - 2].arguments === this.asts[this.top - 1]; + return this.count() >= 3 && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript1.NodeType.FuncDecl && this.asts[this.top - 2].arguments === this.asts[this.top - 1]; }, _proto.isArgumentListOfCall = function() { - return this.count() >= 2 && this.asts[this.top - 0].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Call && this.asts[this.top - 1].arguments === this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 0].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.Call && this.asts[this.top - 1].arguments === this.asts[this.top - 0]; }, _proto.isArgumentListOfNew = function() { - return this.count() >= 2 && this.asts[this.top - 0].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].nodeType === TypeScript.NodeType.New && this.asts[this.top - 1].arguments === this.asts[this.top - 0]; + return this.count() >= 2 && this.asts[this.top - 0].nodeType === TypeScript1.NodeType.List && this.asts[this.top - 1].nodeType === TypeScript1.NodeType.New && this.asts[this.top - 1].arguments === this.asts[this.top - 0]; }, _proto.isSynthesizedBlock = function() { - return this.count() >= 1 && this.asts[this.top - 0].nodeType === TypeScript.NodeType.Block && !1 === this.asts[this.top - 0].isStatementBlock; + return this.count() >= 1 && this.asts[this.top - 0].nodeType === TypeScript1.NodeType.Block && !1 === this.asts[this.top - 0].isStatementBlock; }, AstPath.reverseIndexOf = function(items, index) { return null === items || items.length <= index ? null : items[items.length - index - 1]; }, AstPath; }(), TypeScript1.AstPath = AstPath, TypeScript1.isValidAstNode = isValidAstNode, AstPathContext = function AstPathContext() { - _class_call_check(this, AstPathContext), this.path = new TypeScript.AstPath(); -}, TypeScript1.AstPathContext = AstPathContext, (GetAstPathOptions1 = GetAstPathOptions = TypeScript1.GetAstPathOptions || (TypeScript1.GetAstPathOptions = {}))[GetAstPathOptions1.Default = 0] = "Default", GetAstPathOptions1[GetAstPathOptions1.EdgeInclusive = 1] = "EdgeInclusive", GetAstPathOptions1[GetAstPathOptions1.//We need this options dealing with an AST coming from an incomplete AST. For example: -// class foo { // r -// If we ask for the AST at the position after the "r" character, we won't see we are -// inside a comment, because the "class" AST node has a limChar corresponding to the position of -// the "{" character, meaning we don't traverse the tree down to the stmt list of the class, meaning -// we don't find the "precomment" attached to the errorneous empty stmt. -//TODO: It would be nice to be able to get rid of this. -DontPruneSearchBasedOnPosition = 2] = "DontPruneSearchBasedOnPosition", TypeScript1.getAstPathToPosition = function(script, pos) { - var options = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : GetAstPathOptions.Default, lookInComments = function(comments) { + _class_call_check(this, AstPathContext), this.path = new TypeScript1.AstPath(); +}, TypeScript1.AstPathContext = AstPathContext, (GetAstPathOptions = TypeScript1.GetAstPathOptions || (TypeScript1.GetAstPathOptions = {}))[GetAstPathOptions.Default = 0] = "Default", GetAstPathOptions[GetAstPathOptions.EdgeInclusive = 1] = "EdgeInclusive", GetAstPathOptions[GetAstPathOptions.DontPruneSearchBasedOnPosition = 2] = "DontPruneSearchBasedOnPosition", TypeScript1.getAstPathToPosition = function(script, pos) { + var options = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 0, lookInComments = function(comments) { if (comments && comments.length > 0) for(var i = 0; i < comments.length; i++){ var minChar = comments[i].minChar, limChar = comments[i].limChar; !comments[i].isBlockComment && limChar++, pos >= minChar && pos < limChar && ctx.path.push(comments[i]); } }, ctx = new AstPathContext(); - return TypeScript.getAstWalkerFactory().walk(script, function(cur, parent, walker) { + return TypeScript1.getAstWalkerFactory().walk(script, function(cur, parent, walker) { if (isValidAstNode(cur)) { // Add "cur" to the stack if it contains our position // For "identifier" nodes, we need a special case: A position equal to "limChar" is @@ -177,26 +170,26 @@ DontPruneSearchBasedOnPosition = 2] = "DontPruneSearchBasedOnPosition", TypeScri // bar // 0123 // If "position == 3", the caret is at the "right" of the "r" character, which should be considered valid - var inclusive = hasFlag(options, GetAstPathOptions.EdgeInclusive) || cur.nodeType === TypeScript.NodeType.Name || pos === script.limChar, minChar = cur.minChar, limChar = cur.limChar + (inclusive ? 1 : 0); // Special "EOF" case + var inclusive = hasFlag(options, 1) || cur.nodeType === TypeScript1.NodeType.Name || pos === script.limChar, minChar = cur.minChar, limChar = cur.limChar + (inclusive ? 1 : 0); // Special "EOF" case if (pos >= minChar && pos < limChar) { // TODO: Since AST is sometimes not correct wrt to position, only add "cur" if it's better // than top of the stack. var previous = ctx.path.ast(); (null == previous || cur.minChar >= previous.minChar && cur.limChar <= previous.limChar) && ctx.path.push(cur); } - pos < limChar && lookInComments(cur.preComments), pos >= minChar && lookInComments(cur.postComments), hasFlag(options, GetAstPathOptions.DontPruneSearchBasedOnPosition) || // Don't go further down the tree if pos is outside of [minChar, limChar] + pos < limChar && lookInComments(cur.preComments), pos >= minChar && lookInComments(cur.postComments), hasFlag(options, 2) || // Don't go further down the tree if pos is outside of [minChar, limChar] (walker.options.goChildren = minChar <= pos && pos <= limChar); } return cur; }, null, null, ctx), ctx.path; }, TypeScript1.getTokenizationOffset = function(script, position) { var bestOffset = 0; - return TypeScript.getAstWalkerFactory().walk(script, function(cur, parent, walker) { - return TypeScript.isValidAstNode(cur) && (cur.minChar <= position && (bestOffset = max(bestOffset, cur.minChar)), (cur.minChar > position || cur.limChar < bestOffset) && (walker.options.goChildren = !1)), cur; + return TypeScript1.getAstWalkerFactory().walk(script, function(cur, parent, walker) { + return TypeScript1.isValidAstNode(cur) && (cur.minChar <= position && (bestOffset = max(bestOffset, cur.minChar)), (cur.minChar > position || cur.limChar < bestOffset) && (walker.options.goChildren = !1)), cur; }), bestOffset; }, TypeScript1.walkAST = function(ast, callback) { var path = new AstPath(); - TypeScript.getAstWalkerFactory().walk(ast, function(cur, parent, walker) { + TypeScript1.getAstWalkerFactory().walk(ast, function(cur, parent, walker) { var path = walker.state; return path.push(cur), callback(path, walker), cur; }, function(cur, parent, walker) { diff --git a/crates/swc/tests/tsc-references/parserRealSource2.1.normal.js b/crates/swc/tests/tsc-references/parserRealSource2.1.normal.js index b7c99b7cd93a6..8d68d34143835 100644 --- a/crates/swc/tests/tsc-references/parserRealSource2.1.normal.js +++ b/crates/swc/tests/tsc-references/parserRealSource2.1.normal.js @@ -35,9 +35,7 @@ var TypeScript; ErrorRecoverySet[ErrorRecoverySet["SColon"] = 2] = "SColon"; ErrorRecoverySet[ErrorRecoverySet["Asg"] = 4] = "Asg"; ErrorRecoverySet[ErrorRecoverySet["BinOp"] = 8] = "BinOp"; - ErrorRecoverySet[ErrorRecoverySet[// AsgMod, AsgAdd, AsgSub, AsgLsh, AsgRsh, AsgRs2, AsgAnd, AsgXor, AsgOr, QMark, Mult, Div, - // Pct, GT, LT, And, Xor, Or - "RBrack"] = 16] = "RBrack"; + ErrorRecoverySet[ErrorRecoverySet["RBrack"] = 16] = "RBrack"; ErrorRecoverySet[ErrorRecoverySet["RCurly"] = 32] = "RCurly"; ErrorRecoverySet[ErrorRecoverySet["RParen"] = 64] = "RParen"; ErrorRecoverySet[ErrorRecoverySet["Dot"] = 128] = "Dot"; @@ -63,8 +61,7 @@ var TypeScript; ErrorRecoverySet[ErrorRecoverySet["RLit"] = 134217728] = "RLit"; ErrorRecoverySet[ErrorRecoverySet["Func"] = 268435456] = "Func"; ErrorRecoverySet[ErrorRecoverySet["EOF"] = 536870912] = "EOF"; - ErrorRecoverySet[ErrorRecoverySet[// REVIEW: Name this something clearer. - "TypeScriptS"] = 1073741824] = "TypeScriptS"; + ErrorRecoverySet[ErrorRecoverySet["TypeScriptS"] = 1073741824] = "TypeScriptS"; ErrorRecoverySet[ErrorRecoverySet["ExprStart"] = 520158210] = "ExprStart"; ErrorRecoverySet[ErrorRecoverySet["StmtStart"] = 1608580098] = "StmtStart"; ErrorRecoverySet[ErrorRecoverySet["Postfix"] = 49280] = "Postfix"; @@ -106,10 +103,7 @@ var TypeScript; ASTFlags[ASTFlags["PossibleOptionalParameter"] = 256] = "PossibleOptionalParameter"; ASTFlags[ASTFlags["ClassBaseConstructorCall"] = 512] = "ClassBaseConstructorCall"; ASTFlags[ASTFlags["OptionalName"] = 1024] = "OptionalName"; - ASTFlags[ASTFlags[// REVIEW: This flag is to mark lambda nodes to note that the LParen of an expression has already been matched in the lambda header. - // The flag is used to communicate this piece of information to the calling parseTerm, which intern will remove it. - // Once we have a better way to associate information with nodes, this flag should not be used. - "SkipNextRParen"] = 2048] = "SkipNextRParen"; + ASTFlags[ASTFlags["SkipNextRParen"] = 2048] = "SkipNextRParen"; })(ASTFlags = TypeScript.ASTFlags || (TypeScript.ASTFlags = {})); var DeclFlags; (function(DeclFlags) { @@ -252,8 +246,35 @@ var TypeScript; ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 1] = "Asynchronous"; ModuleGenTarget[ModuleGenTarget["Local"] = 2] = "Local"; })(ModuleGenTarget = TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); - var codeGenTarget = TypeScript.codeGenTarget = CodeGenTarget.ES3; - var moduleGenTarget = TypeScript.moduleGenTarget = ModuleGenTarget.Synchronous; - var optimizeModuleCodeGen = TypeScript.optimizeModuleCodeGen = true; + var codeGenTarget = 0; + Object.defineProperty(TypeScript, "codeGenTarget", { + enumerable: true, + get: function get() { + return codeGenTarget; + }, + set: function set(v) { + codeGenTarget = v; + } + }); + var moduleGenTarget = 0; + Object.defineProperty(TypeScript, "moduleGenTarget", { + enumerable: true, + get: function get() { + return moduleGenTarget; + }, + set: function set(v) { + moduleGenTarget = v; + } + }); + var optimizeModuleCodeGen = true; + Object.defineProperty(TypeScript, "optimizeModuleCodeGen", { + enumerable: true, + get: function get() { + return optimizeModuleCodeGen; + }, + set: function set(v) { + optimizeModuleCodeGen = v; + } + }); TypeScript.flagsToString = flagsToString; })(TypeScript || (TypeScript = {})); diff --git a/crates/swc/tests/tsc-references/parserRealSource2.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource2.2.minified.js index 0f6c4927d809c..370789fb99bdb 100644 --- a/crates/swc/tests/tsc-references/parserRealSource2.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource2.2.minified.js @@ -2,18 +2,36 @@ // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. /// -var TypeScript, TypeScript1, CodeGenTarget, ModuleGenTarget, ErrorRecoverySet, AllowedElements, Modifiers, ASTFlags, DeclFlags, ModuleFlags, SymbolFlags, VarFlags, FncFlags, SignatureFlags, TypeFlags, TypeRelationshipFlags, CodeGenTarget1, ModuleGenTarget1; +var TypeScript, TypeScript1, ErrorRecoverySet, AllowedElements, Modifiers, ASTFlags, DeclFlags, ModuleFlags, SymbolFlags, VarFlags, FncFlags, SignatureFlags, TypeFlags, TypeRelationshipFlags, CodeGenTarget, ModuleGenTarget, codeGenTarget, moduleGenTarget, optimizeModuleCodeGen; (TypeScript1 = TypeScript || (TypeScript = {})).hasFlag = function(val, flag) { return (val & flag) != 0; -}, (ErrorRecoverySet = TypeScript1.ErrorRecoverySet || (TypeScript1.ErrorRecoverySet = {}))[ErrorRecoverySet.None = 0] = "None", ErrorRecoverySet[ErrorRecoverySet.Comma = 1] = "Comma", ErrorRecoverySet[ErrorRecoverySet.SColon = 2] = "SColon", ErrorRecoverySet[ErrorRecoverySet.Asg = 4] = "Asg", ErrorRecoverySet[ErrorRecoverySet.BinOp = 8] = "BinOp", ErrorRecoverySet[ErrorRecoverySet.// AsgMod, AsgAdd, AsgSub, AsgLsh, AsgRsh, AsgRs2, AsgAnd, AsgXor, AsgOr, QMark, Mult, Div, -// Pct, GT, LT, And, Xor, Or -RBrack = 16] = "RBrack", ErrorRecoverySet[ErrorRecoverySet.RCurly = 32] = "RCurly", ErrorRecoverySet[ErrorRecoverySet.RParen = 64] = "RParen", ErrorRecoverySet[ErrorRecoverySet.Dot = 128] = "Dot", ErrorRecoverySet[ErrorRecoverySet.Colon = 256] = "Colon", ErrorRecoverySet[ErrorRecoverySet.PrimType = 512] = "PrimType", ErrorRecoverySet[ErrorRecoverySet.AddOp = 1024] = "AddOp", ErrorRecoverySet[ErrorRecoverySet.LCurly = 2048] = "LCurly", ErrorRecoverySet[ErrorRecoverySet.PreOp = 4096] = "PreOp", ErrorRecoverySet[ErrorRecoverySet.RegExp = 8192] = "RegExp", ErrorRecoverySet[ErrorRecoverySet.LParen = 16384] = "LParen", ErrorRecoverySet[ErrorRecoverySet.LBrack = 32768] = "LBrack", ErrorRecoverySet[ErrorRecoverySet.Scope = 65536] = "Scope", ErrorRecoverySet[ErrorRecoverySet.In = 131072] = "In", ErrorRecoverySet[ErrorRecoverySet.SCase = 262144] = "SCase", ErrorRecoverySet[ErrorRecoverySet.Else = 524288] = "Else", ErrorRecoverySet[ErrorRecoverySet.Catch = 1048576] = "Catch", ErrorRecoverySet[ErrorRecoverySet.Var = 2097152] = "Var", ErrorRecoverySet[ErrorRecoverySet.Stmt = 4194304] = "Stmt", ErrorRecoverySet[ErrorRecoverySet.While = 8388608] = "While", ErrorRecoverySet[ErrorRecoverySet.ID = 16777216] = "ID", ErrorRecoverySet[ErrorRecoverySet.Prefix = 33554432] = "Prefix", ErrorRecoverySet[ErrorRecoverySet.Literal = 67108864] = "Literal", ErrorRecoverySet[ErrorRecoverySet.RLit = 134217728] = "RLit", ErrorRecoverySet[ErrorRecoverySet.Func = 268435456] = "Func", ErrorRecoverySet[ErrorRecoverySet.EOF = 536870912] = "EOF", ErrorRecoverySet[ErrorRecoverySet.// REVIEW: Name this something clearer. -TypeScriptS = 1073741824] = "TypeScriptS", ErrorRecoverySet[ErrorRecoverySet.ExprStart = 520158210] = "ExprStart", ErrorRecoverySet[ErrorRecoverySet.StmtStart = 1608580098] = "StmtStart", ErrorRecoverySet[ErrorRecoverySet.Postfix = 49280] = "Postfix", (AllowedElements = TypeScript1.AllowedElements || (TypeScript1.AllowedElements = {}))[AllowedElements.None = 0] = "None", AllowedElements[AllowedElements.ModuleDeclarations = 4] = "ModuleDeclarations", AllowedElements[AllowedElements.ClassDeclarations = 8] = "ClassDeclarations", AllowedElements[AllowedElements.InterfaceDeclarations = 16] = "InterfaceDeclarations", AllowedElements[AllowedElements.AmbientDeclarations = 1024] = "AmbientDeclarations", AllowedElements[AllowedElements.Properties = 2048] = "Properties", AllowedElements[AllowedElements.Global = 1052] = "Global", AllowedElements[AllowedElements.QuickParse = 3100] = "QuickParse", (Modifiers = TypeScript1.Modifiers || (TypeScript1.Modifiers = {}))[Modifiers.None = 0] = "None", Modifiers[Modifiers.Private = 1] = "Private", Modifiers[Modifiers.Public = 2] = "Public", Modifiers[Modifiers.Readonly = 4] = "Readonly", Modifiers[Modifiers.Ambient = 8] = "Ambient", Modifiers[Modifiers.Exported = 16] = "Exported", Modifiers[Modifiers.Getter = 32] = "Getter", Modifiers[Modifiers.Setter = 64] = "Setter", Modifiers[Modifiers.Static = 128] = "Static", (ASTFlags = TypeScript1.ASTFlags || (TypeScript1.ASTFlags = {}))[ASTFlags.None = 0] = "None", ASTFlags[ASTFlags.ExplicitSemicolon = 1] = "ExplicitSemicolon", ASTFlags[ASTFlags.AutomaticSemicolon = 2] = "AutomaticSemicolon", ASTFlags[ASTFlags.Writeable = 4] = "Writeable", ASTFlags[ASTFlags.Error = 8] = "Error", ASTFlags[ASTFlags.DotLHSPartial = 16] = "DotLHSPartial", ASTFlags[ASTFlags.DotLHS = 32] = "DotLHS", ASTFlags[ASTFlags.IsStatement = 64] = "IsStatement", ASTFlags[ASTFlags.StrictMode = 128] = "StrictMode", ASTFlags[ASTFlags.PossibleOptionalParameter = 256] = "PossibleOptionalParameter", ASTFlags[ASTFlags.ClassBaseConstructorCall = 512] = "ClassBaseConstructorCall", ASTFlags[ASTFlags.OptionalName = 1024] = "OptionalName", ASTFlags[ASTFlags.// REVIEW: This flag is to mark lambda nodes to note that the LParen of an expression has already been matched in the lambda header. -// The flag is used to communicate this piece of information to the calling parseTerm, which intern will remove it. -// Once we have a better way to associate information with nodes, this flag should not be used. -SkipNextRParen = 2048] = "SkipNextRParen", (DeclFlags = TypeScript1.DeclFlags || (TypeScript1.DeclFlags = {}))[DeclFlags.None = 0] = "None", DeclFlags[DeclFlags.Exported = 1] = "Exported", DeclFlags[DeclFlags.Private = 2] = "Private", DeclFlags[DeclFlags.Public = 4] = "Public", DeclFlags[DeclFlags.Ambient = 8] = "Ambient", DeclFlags[DeclFlags.Static = 16] = "Static", DeclFlags[DeclFlags.LocalStatic = 32] = "LocalStatic", DeclFlags[DeclFlags.GetAccessor = 64] = "GetAccessor", DeclFlags[DeclFlags.SetAccessor = 128] = "SetAccessor", (ModuleFlags = TypeScript1.ModuleFlags || (TypeScript1.ModuleFlags = {}))[ModuleFlags.None = 0] = "None", ModuleFlags[ModuleFlags.Exported = 1] = "Exported", ModuleFlags[ModuleFlags.Private = 2] = "Private", ModuleFlags[ModuleFlags.Public = 4] = "Public", ModuleFlags[ModuleFlags.Ambient = 8] = "Ambient", ModuleFlags[ModuleFlags.Static = 16] = "Static", ModuleFlags[ModuleFlags.LocalStatic = 32] = "LocalStatic", ModuleFlags[ModuleFlags.GetAccessor = 64] = "GetAccessor", ModuleFlags[ModuleFlags.SetAccessor = 128] = "SetAccessor", ModuleFlags[ModuleFlags.IsEnum = 256] = "IsEnum", ModuleFlags[ModuleFlags.ShouldEmitModuleDecl = 512] = "ShouldEmitModuleDecl", ModuleFlags[ModuleFlags.IsWholeFile = 1024] = "IsWholeFile", ModuleFlags[ModuleFlags.IsDynamic = 2048] = "IsDynamic", ModuleFlags[ModuleFlags.MustCaptureThis = 4096] = "MustCaptureThis", (SymbolFlags = TypeScript1.SymbolFlags || (TypeScript1.SymbolFlags = {}))[SymbolFlags.None = 0] = "None", SymbolFlags[SymbolFlags.Exported = 1] = "Exported", SymbolFlags[SymbolFlags.Private = 2] = "Private", SymbolFlags[SymbolFlags.Public = 4] = "Public", SymbolFlags[SymbolFlags.Ambient = 8] = "Ambient", SymbolFlags[SymbolFlags.Static = 16] = "Static", SymbolFlags[SymbolFlags.LocalStatic = 32] = "LocalStatic", SymbolFlags[SymbolFlags.GetAccessor = 64] = "GetAccessor", SymbolFlags[SymbolFlags.SetAccessor = 128] = "SetAccessor", SymbolFlags[SymbolFlags.Property = 256] = "Property", SymbolFlags[SymbolFlags.Readonly = 512] = "Readonly", SymbolFlags[SymbolFlags.ModuleMember = 1024] = "ModuleMember", SymbolFlags[SymbolFlags.InterfaceMember = 2048] = "InterfaceMember", SymbolFlags[SymbolFlags.ClassMember = 4096] = "ClassMember", SymbolFlags[SymbolFlags.BuiltIn = 8192] = "BuiltIn", SymbolFlags[SymbolFlags.TypeSetDuringScopeAssignment = 16384] = "TypeSetDuringScopeAssignment", SymbolFlags[SymbolFlags.Constant = 32768] = "Constant", SymbolFlags[SymbolFlags.Optional = 65536] = "Optional", SymbolFlags[SymbolFlags.RecursivelyReferenced = 131072] = "RecursivelyReferenced", SymbolFlags[SymbolFlags.Bound = 262144] = "Bound", SymbolFlags[SymbolFlags.CompilerGenerated = 524288] = "CompilerGenerated", (VarFlags = TypeScript1.VarFlags || (TypeScript1.VarFlags = {}))[VarFlags.None = 0] = "None", VarFlags[VarFlags.Exported = 1] = "Exported", VarFlags[VarFlags.Private = 2] = "Private", VarFlags[VarFlags.Public = 4] = "Public", VarFlags[VarFlags.Ambient = 8] = "Ambient", VarFlags[VarFlags.Static = 16] = "Static", VarFlags[VarFlags.LocalStatic = 32] = "LocalStatic", VarFlags[VarFlags.GetAccessor = 64] = "GetAccessor", VarFlags[VarFlags.SetAccessor = 128] = "SetAccessor", VarFlags[VarFlags.AutoInit = 256] = "AutoInit", VarFlags[VarFlags.Property = 512] = "Property", VarFlags[VarFlags.Readonly = 1024] = "Readonly", VarFlags[VarFlags.Class = 2048] = "Class", VarFlags[VarFlags.ClassProperty = 4096] = "ClassProperty", VarFlags[VarFlags.ClassBodyProperty = 8192] = "ClassBodyProperty", VarFlags[VarFlags.ClassConstructorProperty = 16384] = "ClassConstructorProperty", VarFlags[VarFlags.ClassSuperMustBeFirstCallInConstructor = 32768] = "ClassSuperMustBeFirstCallInConstructor", VarFlags[VarFlags.Constant = 65536] = "Constant", VarFlags[VarFlags.MustCaptureThis = 131072] = "MustCaptureThis", (FncFlags = TypeScript1.FncFlags || (TypeScript1.FncFlags = {}))[FncFlags.None = 0] = "None", FncFlags[FncFlags.Exported = 1] = "Exported", FncFlags[FncFlags.Private = 2] = "Private", FncFlags[FncFlags.Public = 4] = "Public", FncFlags[FncFlags.Ambient = 8] = "Ambient", FncFlags[FncFlags.Static = 16] = "Static", FncFlags[FncFlags.LocalStatic = 32] = "LocalStatic", FncFlags[FncFlags.GetAccessor = 64] = "GetAccessor", FncFlags[FncFlags.SetAccessor = 128] = "SetAccessor", FncFlags[FncFlags.Definition = 256] = "Definition", FncFlags[FncFlags.Signature = 512] = "Signature", FncFlags[FncFlags.Method = 1024] = "Method", FncFlags[FncFlags.HasReturnExpression = 2048] = "HasReturnExpression", FncFlags[FncFlags.CallMember = 4096] = "CallMember", FncFlags[FncFlags.ConstructMember = 8192] = "ConstructMember", FncFlags[FncFlags.HasSelfReference = 16384] = "HasSelfReference", FncFlags[FncFlags.IsFatArrowFunction = 32768] = "IsFatArrowFunction", FncFlags[FncFlags.IndexerMember = 65536] = "IndexerMember", FncFlags[FncFlags.IsFunctionExpression = 131072] = "IsFunctionExpression", FncFlags[FncFlags.ClassMethod = 262144] = "ClassMethod", FncFlags[FncFlags.ClassPropertyMethodExported = 524288] = "ClassPropertyMethodExported", (SignatureFlags = TypeScript1.SignatureFlags || (TypeScript1.SignatureFlags = {}))[SignatureFlags.None = 0] = "None", SignatureFlags[SignatureFlags.IsIndexer = 1] = "IsIndexer", SignatureFlags[SignatureFlags.IsStringIndexer = 2] = "IsStringIndexer", SignatureFlags[SignatureFlags.IsNumberIndexer = 4] = "IsNumberIndexer", TypeScript1.ToDeclFlags = function(fncOrVarOrSymbolOrModuleFlags) { +}, (ErrorRecoverySet = TypeScript1.ErrorRecoverySet || (TypeScript1.ErrorRecoverySet = {}))[ErrorRecoverySet.None = 0] = "None", ErrorRecoverySet[ErrorRecoverySet.Comma = 1] = "Comma", ErrorRecoverySet[ErrorRecoverySet.SColon = 2] = "SColon", ErrorRecoverySet[ErrorRecoverySet.Asg = 4] = "Asg", ErrorRecoverySet[ErrorRecoverySet.BinOp = 8] = "BinOp", ErrorRecoverySet[ErrorRecoverySet.RBrack = 16] = "RBrack", ErrorRecoverySet[ErrorRecoverySet.RCurly = 32] = "RCurly", ErrorRecoverySet[ErrorRecoverySet.RParen = 64] = "RParen", ErrorRecoverySet[ErrorRecoverySet.Dot = 128] = "Dot", ErrorRecoverySet[ErrorRecoverySet.Colon = 256] = "Colon", ErrorRecoverySet[ErrorRecoverySet.PrimType = 512] = "PrimType", ErrorRecoverySet[ErrorRecoverySet.AddOp = 1024] = "AddOp", ErrorRecoverySet[ErrorRecoverySet.LCurly = 2048] = "LCurly", ErrorRecoverySet[ErrorRecoverySet.PreOp = 4096] = "PreOp", ErrorRecoverySet[ErrorRecoverySet.RegExp = 8192] = "RegExp", ErrorRecoverySet[ErrorRecoverySet.LParen = 16384] = "LParen", ErrorRecoverySet[ErrorRecoverySet.LBrack = 32768] = "LBrack", ErrorRecoverySet[ErrorRecoverySet.Scope = 65536] = "Scope", ErrorRecoverySet[ErrorRecoverySet.In = 131072] = "In", ErrorRecoverySet[ErrorRecoverySet.SCase = 262144] = "SCase", ErrorRecoverySet[ErrorRecoverySet.Else = 524288] = "Else", ErrorRecoverySet[ErrorRecoverySet.Catch = 1048576] = "Catch", ErrorRecoverySet[ErrorRecoverySet.Var = 2097152] = "Var", ErrorRecoverySet[ErrorRecoverySet.Stmt = 4194304] = "Stmt", ErrorRecoverySet[ErrorRecoverySet.While = 8388608] = "While", ErrorRecoverySet[ErrorRecoverySet.ID = 16777216] = "ID", ErrorRecoverySet[ErrorRecoverySet.Prefix = 33554432] = "Prefix", ErrorRecoverySet[ErrorRecoverySet.Literal = 67108864] = "Literal", ErrorRecoverySet[ErrorRecoverySet.RLit = 134217728] = "RLit", ErrorRecoverySet[ErrorRecoverySet.Func = 268435456] = "Func", ErrorRecoverySet[ErrorRecoverySet.EOF = 536870912] = "EOF", ErrorRecoverySet[ErrorRecoverySet.TypeScriptS = 1073741824] = "TypeScriptS", ErrorRecoverySet[ErrorRecoverySet.ExprStart = 520158210] = "ExprStart", ErrorRecoverySet[ErrorRecoverySet.StmtStart = 1608580098] = "StmtStart", ErrorRecoverySet[ErrorRecoverySet.Postfix = 49280] = "Postfix", (AllowedElements = TypeScript1.AllowedElements || (TypeScript1.AllowedElements = {}))[AllowedElements.None = 0] = "None", AllowedElements[AllowedElements.ModuleDeclarations = 4] = "ModuleDeclarations", AllowedElements[AllowedElements.ClassDeclarations = 8] = "ClassDeclarations", AllowedElements[AllowedElements.InterfaceDeclarations = 16] = "InterfaceDeclarations", AllowedElements[AllowedElements.AmbientDeclarations = 1024] = "AmbientDeclarations", AllowedElements[AllowedElements.Properties = 2048] = "Properties", AllowedElements[AllowedElements.Global = 1052] = "Global", AllowedElements[AllowedElements.QuickParse = 3100] = "QuickParse", (Modifiers = TypeScript1.Modifiers || (TypeScript1.Modifiers = {}))[Modifiers.None = 0] = "None", Modifiers[Modifiers.Private = 1] = "Private", Modifiers[Modifiers.Public = 2] = "Public", Modifiers[Modifiers.Readonly = 4] = "Readonly", Modifiers[Modifiers.Ambient = 8] = "Ambient", Modifiers[Modifiers.Exported = 16] = "Exported", Modifiers[Modifiers.Getter = 32] = "Getter", Modifiers[Modifiers.Setter = 64] = "Setter", Modifiers[Modifiers.Static = 128] = "Static", (ASTFlags = TypeScript1.ASTFlags || (TypeScript1.ASTFlags = {}))[ASTFlags.None = 0] = "None", ASTFlags[ASTFlags.ExplicitSemicolon = 1] = "ExplicitSemicolon", ASTFlags[ASTFlags.AutomaticSemicolon = 2] = "AutomaticSemicolon", ASTFlags[ASTFlags.Writeable = 4] = "Writeable", ASTFlags[ASTFlags.Error = 8] = "Error", ASTFlags[ASTFlags.DotLHSPartial = 16] = "DotLHSPartial", ASTFlags[ASTFlags.DotLHS = 32] = "DotLHS", ASTFlags[ASTFlags.IsStatement = 64] = "IsStatement", ASTFlags[ASTFlags.StrictMode = 128] = "StrictMode", ASTFlags[ASTFlags.PossibleOptionalParameter = 256] = "PossibleOptionalParameter", ASTFlags[ASTFlags.ClassBaseConstructorCall = 512] = "ClassBaseConstructorCall", ASTFlags[ASTFlags.OptionalName = 1024] = "OptionalName", ASTFlags[ASTFlags.SkipNextRParen = 2048] = "SkipNextRParen", (DeclFlags = TypeScript1.DeclFlags || (TypeScript1.DeclFlags = {}))[DeclFlags.None = 0] = "None", DeclFlags[DeclFlags.Exported = 1] = "Exported", DeclFlags[DeclFlags.Private = 2] = "Private", DeclFlags[DeclFlags.Public = 4] = "Public", DeclFlags[DeclFlags.Ambient = 8] = "Ambient", DeclFlags[DeclFlags.Static = 16] = "Static", DeclFlags[DeclFlags.LocalStatic = 32] = "LocalStatic", DeclFlags[DeclFlags.GetAccessor = 64] = "GetAccessor", DeclFlags[DeclFlags.SetAccessor = 128] = "SetAccessor", (ModuleFlags = TypeScript1.ModuleFlags || (TypeScript1.ModuleFlags = {}))[ModuleFlags.None = 0] = "None", ModuleFlags[ModuleFlags.Exported = 1] = "Exported", ModuleFlags[ModuleFlags.Private = 2] = "Private", ModuleFlags[ModuleFlags.Public = 4] = "Public", ModuleFlags[ModuleFlags.Ambient = 8] = "Ambient", ModuleFlags[ModuleFlags.Static = 16] = "Static", ModuleFlags[ModuleFlags.LocalStatic = 32] = "LocalStatic", ModuleFlags[ModuleFlags.GetAccessor = 64] = "GetAccessor", ModuleFlags[ModuleFlags.SetAccessor = 128] = "SetAccessor", ModuleFlags[ModuleFlags.IsEnum = 256] = "IsEnum", ModuleFlags[ModuleFlags.ShouldEmitModuleDecl = 512] = "ShouldEmitModuleDecl", ModuleFlags[ModuleFlags.IsWholeFile = 1024] = "IsWholeFile", ModuleFlags[ModuleFlags.IsDynamic = 2048] = "IsDynamic", ModuleFlags[ModuleFlags.MustCaptureThis = 4096] = "MustCaptureThis", (SymbolFlags = TypeScript1.SymbolFlags || (TypeScript1.SymbolFlags = {}))[SymbolFlags.None = 0] = "None", SymbolFlags[SymbolFlags.Exported = 1] = "Exported", SymbolFlags[SymbolFlags.Private = 2] = "Private", SymbolFlags[SymbolFlags.Public = 4] = "Public", SymbolFlags[SymbolFlags.Ambient = 8] = "Ambient", SymbolFlags[SymbolFlags.Static = 16] = "Static", SymbolFlags[SymbolFlags.LocalStatic = 32] = "LocalStatic", SymbolFlags[SymbolFlags.GetAccessor = 64] = "GetAccessor", SymbolFlags[SymbolFlags.SetAccessor = 128] = "SetAccessor", SymbolFlags[SymbolFlags.Property = 256] = "Property", SymbolFlags[SymbolFlags.Readonly = 512] = "Readonly", SymbolFlags[SymbolFlags.ModuleMember = 1024] = "ModuleMember", SymbolFlags[SymbolFlags.InterfaceMember = 2048] = "InterfaceMember", SymbolFlags[SymbolFlags.ClassMember = 4096] = "ClassMember", SymbolFlags[SymbolFlags.BuiltIn = 8192] = "BuiltIn", SymbolFlags[SymbolFlags.TypeSetDuringScopeAssignment = 16384] = "TypeSetDuringScopeAssignment", SymbolFlags[SymbolFlags.Constant = 32768] = "Constant", SymbolFlags[SymbolFlags.Optional = 65536] = "Optional", SymbolFlags[SymbolFlags.RecursivelyReferenced = 131072] = "RecursivelyReferenced", SymbolFlags[SymbolFlags.Bound = 262144] = "Bound", SymbolFlags[SymbolFlags.CompilerGenerated = 524288] = "CompilerGenerated", (VarFlags = TypeScript1.VarFlags || (TypeScript1.VarFlags = {}))[VarFlags.None = 0] = "None", VarFlags[VarFlags.Exported = 1] = "Exported", VarFlags[VarFlags.Private = 2] = "Private", VarFlags[VarFlags.Public = 4] = "Public", VarFlags[VarFlags.Ambient = 8] = "Ambient", VarFlags[VarFlags.Static = 16] = "Static", VarFlags[VarFlags.LocalStatic = 32] = "LocalStatic", VarFlags[VarFlags.GetAccessor = 64] = "GetAccessor", VarFlags[VarFlags.SetAccessor = 128] = "SetAccessor", VarFlags[VarFlags.AutoInit = 256] = "AutoInit", VarFlags[VarFlags.Property = 512] = "Property", VarFlags[VarFlags.Readonly = 1024] = "Readonly", VarFlags[VarFlags.Class = 2048] = "Class", VarFlags[VarFlags.ClassProperty = 4096] = "ClassProperty", VarFlags[VarFlags.ClassBodyProperty = 8192] = "ClassBodyProperty", VarFlags[VarFlags.ClassConstructorProperty = 16384] = "ClassConstructorProperty", VarFlags[VarFlags.ClassSuperMustBeFirstCallInConstructor = 32768] = "ClassSuperMustBeFirstCallInConstructor", VarFlags[VarFlags.Constant = 65536] = "Constant", VarFlags[VarFlags.MustCaptureThis = 131072] = "MustCaptureThis", (FncFlags = TypeScript1.FncFlags || (TypeScript1.FncFlags = {}))[FncFlags.None = 0] = "None", FncFlags[FncFlags.Exported = 1] = "Exported", FncFlags[FncFlags.Private = 2] = "Private", FncFlags[FncFlags.Public = 4] = "Public", FncFlags[FncFlags.Ambient = 8] = "Ambient", FncFlags[FncFlags.Static = 16] = "Static", FncFlags[FncFlags.LocalStatic = 32] = "LocalStatic", FncFlags[FncFlags.GetAccessor = 64] = "GetAccessor", FncFlags[FncFlags.SetAccessor = 128] = "SetAccessor", FncFlags[FncFlags.Definition = 256] = "Definition", FncFlags[FncFlags.Signature = 512] = "Signature", FncFlags[FncFlags.Method = 1024] = "Method", FncFlags[FncFlags.HasReturnExpression = 2048] = "HasReturnExpression", FncFlags[FncFlags.CallMember = 4096] = "CallMember", FncFlags[FncFlags.ConstructMember = 8192] = "ConstructMember", FncFlags[FncFlags.HasSelfReference = 16384] = "HasSelfReference", FncFlags[FncFlags.IsFatArrowFunction = 32768] = "IsFatArrowFunction", FncFlags[FncFlags.IndexerMember = 65536] = "IndexerMember", FncFlags[FncFlags.IsFunctionExpression = 131072] = "IsFunctionExpression", FncFlags[FncFlags.ClassMethod = 262144] = "ClassMethod", FncFlags[FncFlags.ClassPropertyMethodExported = 524288] = "ClassPropertyMethodExported", (SignatureFlags = TypeScript1.SignatureFlags || (TypeScript1.SignatureFlags = {}))[SignatureFlags.None = 0] = "None", SignatureFlags[SignatureFlags.IsIndexer = 1] = "IsIndexer", SignatureFlags[SignatureFlags.IsStringIndexer = 2] = "IsStringIndexer", SignatureFlags[SignatureFlags.IsNumberIndexer = 4] = "IsNumberIndexer", TypeScript1.ToDeclFlags = function(fncOrVarOrSymbolOrModuleFlags) { return fncOrVarOrSymbolOrModuleFlags; -}, (TypeFlags = TypeScript1.TypeFlags || (TypeScript1.TypeFlags = {}))[TypeFlags.None = 0] = "None", TypeFlags[TypeFlags.HasImplementation = 1] = "HasImplementation", TypeFlags[TypeFlags.HasSelfReference = 2] = "HasSelfReference", TypeFlags[TypeFlags.MergeResult = 4] = "MergeResult", TypeFlags[TypeFlags.IsEnum = 8] = "IsEnum", TypeFlags[TypeFlags.BuildingName = 16] = "BuildingName", TypeFlags[TypeFlags.HasBaseType = 32] = "HasBaseType", TypeFlags[TypeFlags.HasBaseTypeOfObject = 64] = "HasBaseTypeOfObject", TypeFlags[TypeFlags.IsClass = 128] = "IsClass", (TypeRelationshipFlags = TypeScript1.TypeRelationshipFlags || (TypeScript1.TypeRelationshipFlags = {}))[TypeRelationshipFlags.SuccessfulComparison = 0] = "SuccessfulComparison", TypeRelationshipFlags[TypeRelationshipFlags.SourceIsNullTargetIsVoidOrUndefined = 1] = "SourceIsNullTargetIsVoidOrUndefined", TypeRelationshipFlags[TypeRelationshipFlags.RequiredPropertyIsMissing = 2] = "RequiredPropertyIsMissing", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleSignatures = 4] = "IncompatibleSignatures", TypeRelationshipFlags[TypeRelationshipFlags.SourceSignatureHasTooManyParameters = 3] = "SourceSignatureHasTooManyParameters", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleReturnTypes = 16] = "IncompatibleReturnTypes", TypeRelationshipFlags[TypeRelationshipFlags.IncompatiblePropertyTypes = 32] = "IncompatiblePropertyTypes", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleParameterTypes = 64] = "IncompatibleParameterTypes", (CodeGenTarget1 = CodeGenTarget = TypeScript1.CodeGenTarget || (TypeScript1.CodeGenTarget = {}))[CodeGenTarget1.ES3 = 0] = "ES3", CodeGenTarget1[CodeGenTarget1.ES5 = 1] = "ES5", (ModuleGenTarget1 = ModuleGenTarget = TypeScript1.ModuleGenTarget || (TypeScript1.ModuleGenTarget = {}))[ModuleGenTarget1.Synchronous = 0] = "Synchronous", ModuleGenTarget1[ModuleGenTarget1.Asynchronous = 1] = "Asynchronous", ModuleGenTarget1[ModuleGenTarget1.Local = 2] = "Local", TypeScript1.codeGenTarget = CodeGenTarget.ES3, TypeScript1.moduleGenTarget = ModuleGenTarget.Synchronous, TypeScript1.optimizeModuleCodeGen = !0, TypeScript1.flagsToString = function(e, flags) { +}, (TypeFlags = TypeScript1.TypeFlags || (TypeScript1.TypeFlags = {}))[TypeFlags.None = 0] = "None", TypeFlags[TypeFlags.HasImplementation = 1] = "HasImplementation", TypeFlags[TypeFlags.HasSelfReference = 2] = "HasSelfReference", TypeFlags[TypeFlags.MergeResult = 4] = "MergeResult", TypeFlags[TypeFlags.IsEnum = 8] = "IsEnum", TypeFlags[TypeFlags.BuildingName = 16] = "BuildingName", TypeFlags[TypeFlags.HasBaseType = 32] = "HasBaseType", TypeFlags[TypeFlags.HasBaseTypeOfObject = 64] = "HasBaseTypeOfObject", TypeFlags[TypeFlags.IsClass = 128] = "IsClass", (TypeRelationshipFlags = TypeScript1.TypeRelationshipFlags || (TypeScript1.TypeRelationshipFlags = {}))[TypeRelationshipFlags.SuccessfulComparison = 0] = "SuccessfulComparison", TypeRelationshipFlags[TypeRelationshipFlags.SourceIsNullTargetIsVoidOrUndefined = 1] = "SourceIsNullTargetIsVoidOrUndefined", TypeRelationshipFlags[TypeRelationshipFlags.RequiredPropertyIsMissing = 2] = "RequiredPropertyIsMissing", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleSignatures = 4] = "IncompatibleSignatures", TypeRelationshipFlags[TypeRelationshipFlags.SourceSignatureHasTooManyParameters = 3] = "SourceSignatureHasTooManyParameters", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleReturnTypes = 16] = "IncompatibleReturnTypes", TypeRelationshipFlags[TypeRelationshipFlags.IncompatiblePropertyTypes = 32] = "IncompatiblePropertyTypes", TypeRelationshipFlags[TypeRelationshipFlags.IncompatibleParameterTypes = 64] = "IncompatibleParameterTypes", (CodeGenTarget = TypeScript1.CodeGenTarget || (TypeScript1.CodeGenTarget = {}))[CodeGenTarget.ES3 = 0] = "ES3", CodeGenTarget[CodeGenTarget.ES5 = 1] = "ES5", (ModuleGenTarget = TypeScript1.ModuleGenTarget || (TypeScript1.ModuleGenTarget = {}))[ModuleGenTarget.Synchronous = 0] = "Synchronous", ModuleGenTarget[ModuleGenTarget.Asynchronous = 1] = "Asynchronous", ModuleGenTarget[ModuleGenTarget.Local = 2] = "Local", codeGenTarget = 0, Object.defineProperty(TypeScript1, "codeGenTarget", { + enumerable: !0, + get: function() { + return codeGenTarget; + }, + set: function(v) { + codeGenTarget = v; + } +}), moduleGenTarget = 0, Object.defineProperty(TypeScript1, "moduleGenTarget", { + enumerable: !0, + get: function() { + return moduleGenTarget; + }, + set: function(v) { + moduleGenTarget = v; + } +}), optimizeModuleCodeGen = !0, Object.defineProperty(TypeScript1, "optimizeModuleCodeGen", { + enumerable: !0, + get: function() { + return optimizeModuleCodeGen; + }, + set: function(v) { + optimizeModuleCodeGen = v; + } +}), TypeScript1.flagsToString = function(e, flags) { for(var builder = "", i = 1; i < -2147483648; i <<= 1)if ((flags & i) != 0) { for(var k in e)if (e[k] == i) { builder.length > 0 && (builder += "|"), builder += k; diff --git a/crates/swc/tests/tsc-references/parserRealSource6.1.normal.js b/crates/swc/tests/tsc-references/parserRealSource6.1.normal.js index cbeb58477e487..0fbd6e39ff731 100644 --- a/crates/swc/tests/tsc-references/parserRealSource6.1.normal.js +++ b/crates/swc/tests/tsc-references/parserRealSource6.1.normal.js @@ -4,7 +4,7 @@ /// import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var TypeScript; -(function(TypeScript1) { +(function(TypeScript) { var preFindMemberScope = function preFindMemberScope(ast, parent, walker) { var memScope = walker.state; if (hasFlag(ast.flags, memScope.matchFlag) && (memScope.pos < 0 || memScope.pos == ast.limChar)) { @@ -122,7 +122,7 @@ var TypeScript; this.checker = checker; this.script = null; }; - TypeScript1.TypeCollectionContext = TypeCollectionContext; + TypeScript.TypeCollectionContext = TypeCollectionContext; var MemberScopeContext = function MemberScopeContext(flow, pos, matchFlag) { "use strict"; _class_call_check(this, MemberScopeContext); @@ -133,7 +133,7 @@ var TypeScript; this.ast = null; this.options = new AstWalkOptions(); }; - TypeScript1.MemberScopeContext = MemberScopeContext; + TypeScript.MemberScopeContext = MemberScopeContext; var EnclosingScopeContext = /*#__PURE__*/ function() { "use strict"; function EnclosingScopeContext(logger, script, text, pos, isMemberCompletion) { @@ -183,10 +183,10 @@ var TypeScript; }; return EnclosingScopeContext; }(); - TypeScript1.EnclosingScopeContext = EnclosingScopeContext; - TypeScript1.preFindMemberScope = preFindMemberScope; - TypeScript1.pushTypeCollectionScope = pushTypeCollectionScope; - TypeScript1.popTypeCollectionScope = popTypeCollectionScope; - TypeScript1.preFindEnclosingScope = preFindEnclosingScope; - TypeScript1.findEnclosingScopeAt = findEnclosingScopeAt; + TypeScript.EnclosingScopeContext = EnclosingScopeContext; + TypeScript.preFindMemberScope = preFindMemberScope; + TypeScript.pushTypeCollectionScope = pushTypeCollectionScope; + TypeScript.popTypeCollectionScope = popTypeCollectionScope; + TypeScript.preFindEnclosingScope = preFindEnclosingScope; + TypeScript.findEnclosingScopeAt = findEnclosingScopeAt; })(TypeScript || (TypeScript = {})); diff --git a/crates/swc/tests/tsc-references/parserRealSource6.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource6.2.minified.js index f4c32cdf0856d..da96b21747ae7 100644 --- a/crates/swc/tests/tsc-references/parserRealSource6.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource6.2.minified.js @@ -68,7 +68,7 @@ TypeScript1 = TypeScript || (TypeScript = {}), preFindEnclosingScope = function( }, _proto.getScriptFragment = function() { if (null == this.scriptFragment) { var ast = this.getScriptFragmentStartAST(), minChar = ast.minChar, limChar = this.isMemberCompletion ? this.pos : this.pos + 1; - this.scriptFragment = TypeScript.quickParse(this.logger, ast, this.text, minChar, limChar, null).Script; + this.scriptFragment = TypeScript1.quickParse(this.logger, ast, this.text, minChar, limChar, null).Script; } return this.scriptFragment; }, EnclosingScopeContext; @@ -82,5 +82,5 @@ TypeScript1 = TypeScript || (TypeScript = {}), preFindEnclosingScope = function( context.scopeChain = context.scopeChain.previous; }, TypeScript1.preFindEnclosingScope = preFindEnclosingScope, TypeScript1.findEnclosingScopeAt = function(logger, script, text, pos, isMemberCompletion) { var context = new EnclosingScopeContext(logger, script, text, pos, isMemberCompletion); - return (TypeScript.getAstWalkerFactory().walk(script, preFindEnclosingScope, null, null, context), null === context.scopeStartAST) ? null : context; + return (TypeScript1.getAstWalkerFactory().walk(script, preFindEnclosingScope, null, null, context), null === context.scopeStartAST) ? null : context; }; diff --git a/crates/swc/tests/tsc-references/parserRealSource8.1.normal.js b/crates/swc/tests/tsc-references/parserRealSource8.1.normal.js index 0634bfd83bc30..1e4698a5213da 100644 --- a/crates/swc/tests/tsc-references/parserRealSource8.1.normal.js +++ b/crates/swc/tests/tsc-references/parserRealSource8.1.normal.js @@ -4,7 +4,7 @@ /// import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; var TypeScript; -(function(TypeScript1) { +(function(TypeScript) { var pushAssignScope = function pushAssignScope(scope, context, type, classType, fnc) { var chain = new ScopeChain(null, context.scopeChain, scope); chain.thisType = type; @@ -333,11 +333,11 @@ var TypeScript; this.typeFlow = typeFlow; this.modDeclChain = modDeclChain; }; - TypeScript1.AssignScopeContext = AssignScopeContext; - TypeScript1.pushAssignScope = pushAssignScope; - TypeScript1.popAssignScope = popAssignScope; - TypeScript1.instanceCompare = instanceCompare; - TypeScript1.instanceFilterStop = instanceFilterStop; + TypeScript.AssignScopeContext = AssignScopeContext; + TypeScript.pushAssignScope = pushAssignScope; + TypeScript.popAssignScope = popAssignScope; + TypeScript.instanceCompare = instanceCompare; + TypeScript.instanceFilterStop = instanceFilterStop; var ScopeSearchFilter = /*#__PURE__*/ function() { "use strict"; function ScopeSearchFilter(select, stop) { @@ -360,14 +360,23 @@ var TypeScript; }; return ScopeSearchFilter; }(); - TypeScript1.ScopeSearchFilter = ScopeSearchFilter; - var instanceFilter = TypeScript1.instanceFilter = new ScopeSearchFilter(instanceCompare, instanceFilterStop); - TypeScript1.preAssignModuleScopes = preAssignModuleScopes; - TypeScript1.preAssignClassScopes = preAssignClassScopes; - TypeScript1.preAssignInterfaceScopes = preAssignInterfaceScopes; - TypeScript1.preAssignWithScopes = preAssignWithScopes; - TypeScript1.preAssignFuncDeclScopes = preAssignFuncDeclScopes; - TypeScript1.preAssignCatchScopes = preAssignCatchScopes; - TypeScript1.preAssignScopes = preAssignScopes; - TypeScript1.postAssignScopes = postAssignScopes; + TypeScript.ScopeSearchFilter = ScopeSearchFilter; + var instanceFilter = new ScopeSearchFilter(instanceCompare, instanceFilterStop); + Object.defineProperty(TypeScript, "instanceFilter", { + enumerable: true, + get: function get() { + return instanceFilter; + }, + set: function set(v) { + instanceFilter = v; + } + }); + TypeScript.preAssignModuleScopes = preAssignModuleScopes; + TypeScript.preAssignClassScopes = preAssignClassScopes; + TypeScript.preAssignInterfaceScopes = preAssignInterfaceScopes; + TypeScript.preAssignWithScopes = preAssignWithScopes; + TypeScript.preAssignFuncDeclScopes = preAssignFuncDeclScopes; + TypeScript.preAssignCatchScopes = preAssignCatchScopes; + TypeScript.preAssignScopes = preAssignScopes; + TypeScript.postAssignScopes = postAssignScopes; })(TypeScript || (TypeScript = {})); diff --git a/crates/swc/tests/tsc-references/parserRealSource8.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource8.2.minified.js index 8ac36abf07ec2..57c951d55178c 100644 --- a/crates/swc/tests/tsc-references/parserRealSource8.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource8.2.minified.js @@ -2,7 +2,7 @@ // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. /// -var TypeScript, TypeScript1, pushAssignScope, popAssignScope, instanceCompare, instanceFilterStop, preAssignModuleScopes, preAssignClassScopes, preAssignInterfaceScopes, preAssignWithScopes, preAssignFuncDeclScopes, preAssignCatchScopes, ScopeSearchFilter; +var TypeScript, TypeScript1, pushAssignScope, popAssignScope, instanceCompare, instanceFilterStop, preAssignModuleScopes, preAssignClassScopes, preAssignInterfaceScopes, preAssignWithScopes, preAssignFuncDeclScopes, preAssignCatchScopes, ScopeSearchFilter, instanceFilter; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; TypeScript1 = TypeScript || (TypeScript = {}), pushAssignScope = function(scope, context, type, classType, fnc) { var chain = new ScopeChain(null, context.scopeChain, scope); @@ -35,7 +35,7 @@ TypeScript1 = TypeScript || (TypeScript = {}), pushAssignScope = function(scope, }, preAssignWithScopes = function(ast, context) { var withType = ast.type, members = new ScopedMembers(new DualStringHashTable(new StringHashTable(), new StringHashTable())), ambientMembers = new ScopedMembers(new DualStringHashTable(new StringHashTable(), new StringHashTable())), withType = new Type(), withSymbol = new WithSymbol(ast.minChar, context.typeFlow.checker.locationInfo.unitIndex, withType); withType.members = members, withType.ambientMembers = ambientMembers, withType.symbol = withSymbol, withType.setHasImplementation(), ast.type = withType; - var withScope = new TypeScript.SymbolScopeBuilder(withType.members, withType.ambientMembers, null, null, context.scopeChain.scope, withType.symbol); + var withScope = new TypeScript1.SymbolScopeBuilder(withType.members, withType.ambientMembers, null, null, context.scopeChain.scope, withType.symbol); pushAssignScope(withScope, context, null, null, null), withType.containedScope = withScope; }, preAssignFuncDeclScopes = function(ast, context) { var container = null, localContainer = null; @@ -105,7 +105,15 @@ TypeScript1 = TypeScript || (TypeScript = {}), pushAssignScope = function(scope, }, _proto.update = function(b) { return this.result = this.select(this.result, b), !!this.result && this.stop(this.result); }, ScopeSearchFilter; -}(), TypeScript1.ScopeSearchFilter = ScopeSearchFilter, TypeScript1.instanceFilter = new ScopeSearchFilter(instanceCompare, instanceFilterStop), TypeScript1.preAssignModuleScopes = preAssignModuleScopes, TypeScript1.preAssignClassScopes = preAssignClassScopes, TypeScript1.preAssignInterfaceScopes = preAssignInterfaceScopes, TypeScript1.preAssignWithScopes = preAssignWithScopes, TypeScript1.preAssignFuncDeclScopes = preAssignFuncDeclScopes, TypeScript1.preAssignCatchScopes = preAssignCatchScopes, TypeScript1.preAssignScopes = function(ast, parent, walker) { +}(), TypeScript1.ScopeSearchFilter = ScopeSearchFilter, instanceFilter = new ScopeSearchFilter(instanceCompare, instanceFilterStop), Object.defineProperty(TypeScript1, "instanceFilter", { + enumerable: !0, + get: function() { + return instanceFilter; + }, + set: function(v) { + instanceFilter = v; + } +}), TypeScript1.preAssignModuleScopes = preAssignModuleScopes, TypeScript1.preAssignClassScopes = preAssignClassScopes, TypeScript1.preAssignInterfaceScopes = preAssignInterfaceScopes, TypeScript1.preAssignWithScopes = preAssignWithScopes, TypeScript1.preAssignFuncDeclScopes = preAssignFuncDeclScopes, TypeScript1.preAssignCatchScopes = preAssignCatchScopes, TypeScript1.preAssignScopes = function(ast, parent, walker) { var context = walker.state, go = !0; return ast && (ast.nodeType == NodeType.List ? ast.enclosingScope = context.scopeChain.scope : ast.nodeType == NodeType.ModuleDeclaration ? preAssignModuleScopes(ast, context) : ast.nodeType == NodeType.ClassDeclaration ? preAssignClassScopes(ast, context) : ast.nodeType == NodeType.InterfaceDeclaration ? preAssignInterfaceScopes(ast, context) : ast.nodeType == NodeType.With ? preAssignWithScopes(ast, context) : ast.nodeType == NodeType.FuncDecl ? preAssignFuncDeclScopes(ast, context) : ast.nodeType == NodeType.Catch ? preAssignCatchScopes(ast, context) : ast.nodeType == NodeType.TypeRef && (go = !1)), walker.options.goChildren = go, ast; }, TypeScript1.postAssignScopes = function(ast, parent, walker) { diff --git a/crates/swc/tests/tsc-references/parserSuperExpression1.1.normal.js b/crates/swc/tests/tsc-references/parserSuperExpression1.1.normal.js index 08fea883cd7da..b44b484e70b1e 100644 --- a/crates/swc/tests/tsc-references/parserSuperExpression1.1.normal.js +++ b/crates/swc/tests/tsc-references/parserSuperExpression1.1.normal.js @@ -15,7 +15,6 @@ var C = /*#__PURE__*/ function() { }(); var M1; (function(M1) { - var M2; (function(M2) { var C = /*#__PURE__*/ function() { "use strict"; @@ -28,5 +27,5 @@ var M1; }; return C; }(); - })(M2 = M1.M2 || (M1.M2 = {})); + })(M1.M2 || (M1.M2 = {})); })(M1 || (M1 = {})); diff --git a/crates/swc/tests/tsc-references/parserSuperExpression4.1.normal.js b/crates/swc/tests/tsc-references/parserSuperExpression4.1.normal.js index ac551899e4e78..79751b10bf9e9 100644 --- a/crates/swc/tests/tsc-references/parserSuperExpression4.1.normal.js +++ b/crates/swc/tests/tsc-references/parserSuperExpression4.1.normal.js @@ -15,7 +15,6 @@ var C = /*#__PURE__*/ function() { }(); var M1; (function(M1) { - var M2; (function(M2) { var C = /*#__PURE__*/ function() { "use strict"; @@ -28,5 +27,5 @@ var M1; }; return C; }(); - })(M2 = M1.M2 || (M1.M2 = {})); + })(M1.M2 || (M1.M2 = {})); })(M1 || (M1 = {})); diff --git a/crates/swc/tests/tsc-references/plusOperatorWithBooleanType.1.normal.js b/crates/swc/tests/tsc-references/plusOperatorWithBooleanType.1.normal.js index a9924ee9a639b..beea3466423db 100644 --- a/crates/swc/tests/tsc-references/plusOperatorWithBooleanType.1.normal.js +++ b/crates/swc/tests/tsc-references/plusOperatorWithBooleanType.1.normal.js @@ -18,7 +18,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // boolean type var diff --git a/crates/swc/tests/tsc-references/plusOperatorWithBooleanType.2.minified.js b/crates/swc/tests/tsc-references/plusOperatorWithBooleanType.2.minified.js index 509e4f1e2e8bf..d55fb907dd289 100644 --- a/crates/swc/tests/tsc-references/plusOperatorWithBooleanType.2.minified.js +++ b/crates/swc/tests/tsc-references/plusOperatorWithBooleanType.2.minified.js @@ -9,6 +9,14 @@ var n, M, A = function() { return !1; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/plusOperatorWithEnumType.1.normal.js b/crates/swc/tests/tsc-references/plusOperatorWithEnumType.1.normal.js index ec1eea1c7cc6d..46ec23feb0e26 100644 --- a/crates/swc/tests/tsc-references/plusOperatorWithEnumType.1.normal.js +++ b/crates/swc/tests/tsc-references/plusOperatorWithEnumType.1.normal.js @@ -12,10 +12,10 @@ var ENUM1; var ResultIsNumber1 = +ENUM; var ResultIsNumber2 = +ENUM1; // enum type expressions -var ResultIsNumber3 = +ENUM1["A"]; -var ResultIsNumber4 = +(ENUM[0] + ENUM1["B"]); +var ResultIsNumber3 = +0; +var ResultIsNumber4 = +(ENUM[0] + 1); // miss assignment operators +ENUM; +ENUM1; -+ENUM1.B; ++1; +ENUM, ENUM1; diff --git a/crates/swc/tests/tsc-references/plusOperatorWithEnumType.2.minified.js b/crates/swc/tests/tsc-references/plusOperatorWithEnumType.2.minified.js index 1304aedaab286..d48d3e24eccd6 100644 --- a/crates/swc/tests/tsc-references/plusOperatorWithEnumType.2.minified.js +++ b/crates/swc/tests/tsc-references/plusOperatorWithEnumType.2.minified.js @@ -1,4 +1,4 @@ //// [plusOperatorWithEnumType.ts] // + operator on enum type var ENUM, ENUM1, ENUM11; -ENUM || (ENUM = {}), (ENUM11 = ENUM1 || (ENUM1 = {}))[ENUM11.A = 0] = "A", ENUM11[ENUM11.B = 1] = "B", ENUM11[ENUM11[""] = 2] = "", ENUM1.A, ENUM[0], ENUM1.B, ENUM1.B; +ENUM || (ENUM = {}), (ENUM11 = ENUM1 || (ENUM1 = {}))[ENUM11.A = 0] = "A", ENUM11[ENUM11.B = 1] = "B", ENUM11[ENUM11[""] = 2] = "", ENUM[0]; diff --git a/crates/swc/tests/tsc-references/plusOperatorWithNumberType.1.normal.js b/crates/swc/tests/tsc-references/plusOperatorWithNumberType.1.normal.js index bafe933b3643b..a16efc9c45834 100644 --- a/crates/swc/tests/tsc-references/plusOperatorWithNumberType.1.normal.js +++ b/crates/swc/tests/tsc-references/plusOperatorWithNumberType.1.normal.js @@ -22,7 +22,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // number type var diff --git a/crates/swc/tests/tsc-references/plusOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/plusOperatorWithNumberType.2.minified.js index 618ca990212d4..c152d37508e4e 100644 --- a/crates/swc/tests/tsc-references/plusOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/plusOperatorWithNumberType.2.minified.js @@ -9,6 +9,14 @@ var M, n, A = function() { return 1; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n, objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/plusOperatorWithStringType.1.normal.js b/crates/swc/tests/tsc-references/plusOperatorWithStringType.1.normal.js index 59a53afdce8cf..a973358963409 100644 --- a/crates/swc/tests/tsc-references/plusOperatorWithStringType.1.normal.js +++ b/crates/swc/tests/tsc-references/plusOperatorWithStringType.1.normal.js @@ -22,7 +22,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // string type var diff --git a/crates/swc/tests/tsc-references/plusOperatorWithStringType.2.minified.js b/crates/swc/tests/tsc-references/plusOperatorWithStringType.2.minified.js index aa522bb16d586..c9442610b4f18 100644 --- a/crates/swc/tests/tsc-references/plusOperatorWithStringType.2.minified.js +++ b/crates/swc/tests/tsc-references/plusOperatorWithStringType.2.minified.js @@ -9,6 +9,14 @@ var STRING, M, n, A = function() { return ""; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); objA.a, M.n, A.foo(), STRING.charAt(0), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/preserveValueImports.1.normal.js b/crates/swc/tests/tsc-references/preserveValueImports.1.normal.js index faa946696b094..cc7ebb0f66954 100644 --- a/crates/swc/tests/tsc-references/preserveValueImports.1.normal.js +++ b/crates/swc/tests/tsc-references/preserveValueImports.1.normal.js @@ -20,14 +20,6 @@ export { }; //! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. //! ,-[1:1] //! 1 | import D = require("./d"); -//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^ -//! 2 | import DD = require("./d"); -//! 3 | DD; -//! `---- -//! -//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. -//! ,-[1:1] -//! 1 | import D = require("./d"); //! 2 | import DD = require("./d"); //! : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ //! 3 | DD; diff --git a/crates/swc/tests/tsc-references/preserveValueImports.2.minified.js b/crates/swc/tests/tsc-references/preserveValueImports.2.minified.js index 5eb2fb7169cbf..11e1aac970ee5 100644 --- a/crates/swc/tests/tsc-references/preserveValueImports.2.minified.js +++ b/crates/swc/tests/tsc-references/preserveValueImports.2.minified.js @@ -20,14 +20,6 @@ export { }; //! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. //! ,-[1:1] //! 1 | import D = require("./d"); -//! : ^^^^^^^^^^^^^^^^^^^^^^^^^^ -//! 2 | import DD = require("./d"); -//! 3 | DD; -//! `---- -//! -//! x Import assignment cannot be used when targeting ECMAScript modules. Consider using `import * as ns from "mod"`, `import {a} from "mod"`, `import d from "mod"`, or another module format instead. -//! ,-[1:1] -//! 1 | import D = require("./d"); //! 2 | import DD = require("./d"); //! : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ //! 3 | DD; diff --git a/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule.1.normal.js b/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule.1.normal.js index 06e8d0c8c2fad..13d68b0f6ccff 100644 --- a/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule.1.normal.js +++ b/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule.1.normal.js @@ -5,6 +5,15 @@ var C = function C() { "use strict"; _class_call_check(this, C); }; -(function(C1) { - var y = C1.y = C.bar; +(function(C) { + var y = C.bar; // error + Object.defineProperty(C, "y", { + enumerable: true, + get: function get() { + return y; + }, + set: function set(v) { + y = v; + } + }); })(C || (C = {})); diff --git a/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule.2.minified.js b/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule.2.minified.js index eab25c9580f59..0971dcd93dd1b 100644 --- a/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule.2.minified.js +++ b/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule.2.minified.js @@ -1,7 +1,15 @@ //// [privateStaticNotAccessibleInClodule.ts] // Any attempt to access a private property member outside the class body that contains its declaration results in a compile-time error. import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var C = function C() { +var C, y, C1 = function C() { _class_call_check(this, C); }; -(C || (C = {})).y = C.bar; +y = (C = C1 || (C1 = {})).bar, Object.defineProperty(C, "y", { + enumerable: !0, + get: function() { + return y; + }, + set: function(v) { + y = v; + } +}); diff --git a/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule2.1.normal.js b/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule2.1.normal.js index 8310233efe87c..ad0895323c0ab 100644 --- a/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule2.1.normal.js +++ b/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule2.1.normal.js @@ -17,6 +17,15 @@ var D = /*#__PURE__*/ function(C) { } return D; }(C); -(function(D1) { - var y = D1.y = D.bar; +(function(D) { + var y = D.bar; // error + Object.defineProperty(D, "y", { + enumerable: true, + get: function get() { + return y; + }, + set: function set(v) { + y = v; + } + }); })(D || (D = {})); diff --git a/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule2.2.minified.js b/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule2.2.minified.js index 0416bbbb24e27..1036414db85dd 100644 --- a/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule2.2.minified.js +++ b/crates/swc/tests/tsc-references/privateStaticNotAccessibleInClodule2.2.minified.js @@ -3,7 +3,7 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -var D = function(C) { +var D, y, D1 = function(C) { _inherits(D, C); var _super = _create_super(D); function D() { @@ -13,4 +13,12 @@ var D = function(C) { }(function C() { _class_call_check(this, C); }); -(D || (D = {})).y = D.bar; +y = (D = D1 || (D1 = {})).bar, Object.defineProperty(D, "y", { + enumerable: !0, + get: function() { + return y; + }, + set: function(v) { + y = v; + } +}); diff --git a/crates/swc/tests/tsc-references/propertyAccess.1.normal.js b/crates/swc/tests/tsc-references/propertyAccess.1.normal.js index 9ae4d7bc8e19c..1b7f4bf1d3f09 100644 --- a/crates/swc/tests/tsc-references/propertyAccess.1.normal.js +++ b/crates/swc/tests/tsc-references/propertyAccess.1.normal.js @@ -28,8 +28,8 @@ var numIndex = { "three": "three" }; var strIndex = { - "N": Compass.North, - "E": Compass.East + "N": 0, + "E": 2 }; var bothIndex; function noIndex() {} @@ -75,7 +75,7 @@ var gg; var hh = numIndex[3.0]; var hh; // Bracket notation property access using enum value on type with numeric index signature -var ii = numIndex[Compass.South]; +var ii = numIndex[1]; var ii; // Bracket notation property access using value of type 'any' on type with numeric index signature var jj = numIndex[anyVar]; @@ -94,7 +94,7 @@ var mm2; var nn = strIndex[10]; var nn; // Bracket notation property access using enum value on type with string index signature and no numeric index signature -var oo = strIndex[Compass.East]; +var oo = strIndex[2]; var oo; // Bracket notation property access using value of type 'any' on type with string index signature and no numeric index signature var pp = strIndex[null]; @@ -106,7 +106,7 @@ var qq; var rr = noIndex["zzzz"]; var rr; // Bracket notation property access using enum value on type with no index signatures -var ss = noIndex[Compass.South]; +var ss = noIndex[1]; var ss; // Bracket notation property access using value of type 'any' on type with no index signatures var tt = noIndex[null]; @@ -117,7 +117,7 @@ var uu = noIndex[someObject]; // Error var vv = noIndex[32]; var vv; // Bracket notation property access using enum value on type with numeric index signature and string index signature -var ww = bothIndex[Compass.East]; +var ww = bothIndex[2]; var ww; // Bracket notation property access using value of type 'any' on type with numeric index signature and string index signature var xx = bothIndex[null]; diff --git a/crates/swc/tests/tsc-references/propertyAccess.2.minified.js b/crates/swc/tests/tsc-references/propertyAccess.2.minified.js index 8526f62580fa7..fe3cd757db6d1 100644 --- a/crates/swc/tests/tsc-references/propertyAccess.2.minified.js +++ b/crates/swc/tests/tsc-references/propertyAccess.2.minified.js @@ -7,8 +7,8 @@ var Compass, bothIndex, stringOrNumber, someObject, Compass1, numIndex = { 3: "three", three: "three" }, strIndex = { - N: Compass.North, - E: Compass.East + N: 0, + E: 2 }; function noIndex() {} var obj = { @@ -26,4 +26,4 @@ var obj = { }, anyVar = {}; // Assign to a property access obj.y = 4, // Property access on value of type 'any' -anyVar.x = anyVar.y = obj.x = anyVar.z, obj.x, obj.hasOwnProperty, obj.qqq, obj["literal property"], obj["wa wa wa wa wa"], obj["10"], obj["1"], numIndex[3.0], numIndex[Compass.South], numIndex[anyVar], numIndex.what, numIndex[someObject], strIndex.N, strIndex.zzz, strIndex[10], strIndex[Compass.East], strIndex[null], noIndex[123], noIndex[Compass.South], noIndex[null], noIndex[someObject], noIndex[32], bothIndex[Compass.East], bothIndex[null], bothIndex.foo, bothIndex["1.0"], bothIndex[someObject], numIndex[stringOrNumber], strIndex[stringOrNumber], bothIndex[stringOrNumber]; +anyVar.x = anyVar.y = obj.x = anyVar.z, obj.x, obj.hasOwnProperty, obj.qqq, obj["literal property"], obj["wa wa wa wa wa"], obj["10"], obj["1"], numIndex[3.0], numIndex[1], numIndex[anyVar], numIndex.what, numIndex[someObject], strIndex.N, strIndex.zzz, strIndex[10], strIndex[2], strIndex[null], noIndex[123], noIndex[1], noIndex[null], noIndex[someObject], noIndex[32], bothIndex[2], bothIndex[null], bothIndex.foo, bothIndex["1.0"], bothIndex[someObject], numIndex[stringOrNumber], strIndex[stringOrNumber], bothIndex[stringOrNumber]; diff --git a/crates/swc/tests/tsc-references/propertyNamesOfReservedWords.1.normal.js b/crates/swc/tests/tsc-references/propertyNamesOfReservedWords.1.normal.js index b5bb241e4fcaa..b06323329ff54 100644 --- a/crates/swc/tests/tsc-references/propertyNamesOfReservedWords.1.normal.js +++ b/crates/swc/tests/tsc-references/propertyNamesOfReservedWords.1.normal.js @@ -79,5 +79,5 @@ var E; E[E["while"] = 61] = "while"; E[E["with"] = 62] = "with"; })(E || (E = {})); -var r7 = E.abstract; -var r8 = E.as; +var r7 = 0; +var r8 = 1; diff --git a/crates/swc/tests/tsc-references/propertyNamesOfReservedWords.2.minified.js b/crates/swc/tests/tsc-references/propertyNamesOfReservedWords.2.minified.js index e380b22b84692..803a54ea32eed 100644 --- a/crates/swc/tests/tsc-references/propertyNamesOfReservedWords.2.minified.js +++ b/crates/swc/tests/tsc-references/propertyNamesOfReservedWords.2.minified.js @@ -1,4 +1,4 @@ //// [propertyNamesOfReservedWords.ts] var c, i, a, E, E1; import "@swc/helpers/_/_class_call_check"; -c.abstract, c.as, i.abstract, i.as, a.abstract, a.as, (E1 = E || (E = {}))[E1.abstract = 0] = "abstract", E1[E1.as = 1] = "as", E1[E1.boolean = 2] = "boolean", E1[E1.break = 3] = "break", E1[E1.byte = 4] = "byte", E1[E1.case = 5] = "case", E1[E1.catch = 6] = "catch", E1[E1.char = 7] = "char", E1[E1.class = 8] = "class", E1[E1.continue = 9] = "continue", E1[E1.const = 10] = "const", E1[E1.debugger = 11] = "debugger", E1[E1.default = 12] = "default", E1[E1.delete = 13] = "delete", E1[E1.do = 14] = "do", E1[E1.double = 15] = "double", E1[E1.else = 16] = "else", E1[E1.enum = 17] = "enum", E1[E1.export = 18] = "export", E1[E1.extends = 19] = "extends", E1[E1.false = 20] = "false", E1[E1.final = 21] = "final", E1[E1.finally = 22] = "finally", E1[E1.float = 23] = "float", E1[E1.for = 24] = "for", E1[E1.function = 25] = "function", E1[E1.goto = 26] = "goto", E1[E1.if = 27] = "if", E1[E1.implements = 28] = "implements", E1[E1.import = 29] = "import", E1[E1.in = 30] = "in", E1[E1.instanceof = 31] = "instanceof", E1[E1.int = 32] = "int", E1[E1.interface = 33] = "interface", E1[E1.is = 34] = "is", E1[E1.long = 35] = "long", E1[E1.namespace = 36] = "namespace", E1[E1.native = 37] = "native", E1[E1.new = 38] = "new", E1[E1.null = 39] = "null", E1[E1.package = 40] = "package", E1[E1.private = 41] = "private", E1[E1.protected = 42] = "protected", E1[E1.public = 43] = "public", E1[E1.return = 44] = "return", E1[E1.short = 45] = "short", E1[E1.static = 46] = "static", E1[E1.super = 47] = "super", E1[E1.switch = 48] = "switch", E1[E1.synchronized = 49] = "synchronized", E1[E1.this = 50] = "this", E1[E1.throw = 51] = "throw", E1[E1.throws = 52] = "throws", E1[E1.transient = 53] = "transient", E1[E1.true = 54] = "true", E1[E1.try = 55] = "try", E1[E1.typeof = 56] = "typeof", E1[E1.use = 57] = "use", E1[E1.var = 58] = "var", E1[E1.void = 59] = "void", E1[E1.volatile = 60] = "volatile", E1[E1.while = 61] = "while", E1[E1.with = 62] = "with", E.abstract, E.as; +c.abstract, c.as, i.abstract, i.as, a.abstract, a.as, (E1 = E || (E = {}))[E1.abstract = 0] = "abstract", E1[E1.as = 1] = "as", E1[E1.boolean = 2] = "boolean", E1[E1.break = 3] = "break", E1[E1.byte = 4] = "byte", E1[E1.case = 5] = "case", E1[E1.catch = 6] = "catch", E1[E1.char = 7] = "char", E1[E1.class = 8] = "class", E1[E1.continue = 9] = "continue", E1[E1.const = 10] = "const", E1[E1.debugger = 11] = "debugger", E1[E1.default = 12] = "default", E1[E1.delete = 13] = "delete", E1[E1.do = 14] = "do", E1[E1.double = 15] = "double", E1[E1.else = 16] = "else", E1[E1.enum = 17] = "enum", E1[E1.export = 18] = "export", E1[E1.extends = 19] = "extends", E1[E1.false = 20] = "false", E1[E1.final = 21] = "final", E1[E1.finally = 22] = "finally", E1[E1.float = 23] = "float", E1[E1.for = 24] = "for", E1[E1.function = 25] = "function", E1[E1.goto = 26] = "goto", E1[E1.if = 27] = "if", E1[E1.implements = 28] = "implements", E1[E1.import = 29] = "import", E1[E1.in = 30] = "in", E1[E1.instanceof = 31] = "instanceof", E1[E1.int = 32] = "int", E1[E1.interface = 33] = "interface", E1[E1.is = 34] = "is", E1[E1.long = 35] = "long", E1[E1.namespace = 36] = "namespace", E1[E1.native = 37] = "native", E1[E1.new = 38] = "new", E1[E1.null = 39] = "null", E1[E1.package = 40] = "package", E1[E1.private = 41] = "private", E1[E1.protected = 42] = "protected", E1[E1.public = 43] = "public", E1[E1.return = 44] = "return", E1[E1.short = 45] = "short", E1[E1.static = 46] = "static", E1[E1.super = 47] = "super", E1[E1.switch = 48] = "switch", E1[E1.synchronized = 49] = "synchronized", E1[E1.this = 50] = "this", E1[E1.throw = 51] = "throw", E1[E1.throws = 52] = "throws", E1[E1.transient = 53] = "transient", E1[E1.true = 54] = "true", E1[E1.try = 55] = "try", E1[E1.typeof = 56] = "typeof", E1[E1.use = 57] = "use", E1[E1.var = 58] = "var", E1[E1.void = 59] = "void", E1[E1.volatile = 60] = "volatile", E1[E1.while = 61] = "while", E1[E1.with = 62] = "with"; diff --git a/crates/swc/tests/tsc-references/protectedStaticNotAccessibleInClodule.1.normal.js b/crates/swc/tests/tsc-references/protectedStaticNotAccessibleInClodule.1.normal.js index 9b700a4b6ae6f..cf4fb6723f2c4 100644 --- a/crates/swc/tests/tsc-references/protectedStaticNotAccessibleInClodule.1.normal.js +++ b/crates/swc/tests/tsc-references/protectedStaticNotAccessibleInClodule.1.normal.js @@ -5,7 +5,25 @@ var C = function C() { "use strict"; _class_call_check(this, C); }; -(function(C1) { - var f = C1.f = C.foo; - var b = C1.b = C.bar; +(function(C) { + var f = C.foo; // OK + Object.defineProperty(C, "f", { + enumerable: true, + get: function get() { + return f; + }, + set: function set(v) { + f = v; + } + }); + var b = C.bar; // error + Object.defineProperty(C, "b", { + enumerable: true, + get: function get() { + return b; + }, + set: function set(v) { + b = v; + } + }); })(C || (C = {})); diff --git a/crates/swc/tests/tsc-references/protectedStaticNotAccessibleInClodule.2.minified.js b/crates/swc/tests/tsc-references/protectedStaticNotAccessibleInClodule.2.minified.js index 5bd035138b6f8..2e4ba9760764b 100644 --- a/crates/swc/tests/tsc-references/protectedStaticNotAccessibleInClodule.2.minified.js +++ b/crates/swc/tests/tsc-references/protectedStaticNotAccessibleInClodule.2.minified.js @@ -1,7 +1,23 @@ //// [protectedStaticNotAccessibleInClodule.ts] // Any attempt to access a private property member outside the class body that contains its declaration results in a compile-time error. import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var C1, C = function C() { +var C, f, b, C1 = function C() { _class_call_check(this, C); }; -(C1 = C || (C = {})).f = C.foo, C1.b = C.bar; +f = (C = C1 || (C1 = {})).foo, Object.defineProperty(C, "f", { + enumerable: !0, + get: function() { + return f; + }, + set: function(v) { + f = v; + } +}), b = C.bar, Object.defineProperty(C, "b", { + enumerable: !0, + get: function() { + return b; + }, + set: function(v) { + b = v; + } +}); diff --git a/crates/swc/tests/tsc-references/scopeResolutionIdentifiers.1.normal.js b/crates/swc/tests/tsc-references/scopeResolutionIdentifiers.1.normal.js index f8c9e573fa214..a33346b8bb414 100644 --- a/crates/swc/tests/tsc-references/scopeResolutionIdentifiers.1.normal.js +++ b/crates/swc/tests/tsc-references/scopeResolutionIdentifiers.1.normal.js @@ -5,9 +5,17 @@ var s; var M1; (function(M1) { var s; + Object.defineProperty(M1, "s", { + enumerable: true, + get: function get() { + return s; + }, + set: function set(v) { + s = v; + } + }); var n = s; var n; - M1.s = s; })(M1 || (M1 = {})); var M2; (function(M2) { diff --git a/crates/swc/tests/tsc-references/scopeResolutionIdentifiers.2.minified.js b/crates/swc/tests/tsc-references/scopeResolutionIdentifiers.2.minified.js index d6e8190cd022d..e420c4552c0e5 100644 --- a/crates/swc/tests/tsc-references/scopeResolutionIdentifiers.2.minified.js +++ b/crates/swc/tests/tsc-references/scopeResolutionIdentifiers.2.minified.js @@ -2,4 +2,12 @@ // EveryType used in a nested scope of a different EveryType with the same name, type of the identifier is the one defined in the inner scope var M1, M2, M3, s, M4; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -(M1 || (M1 = {})).s = s, M2 || (M2 = {}), M3 || (M3 = {}), M4 || (M4 = {}); +Object.defineProperty(M1 || (M1 = {}), "s", { + enumerable: !0, + get: function() { + return s; + }, + set: function(v) { + s = v; + } +}), M2 || (M2 = {}), M3 || (M3 = {}), M4 || (M4 = {}); diff --git a/crates/swc/tests/tsc-references/staticPropertyNotInClassType.1.normal.js b/crates/swc/tests/tsc-references/staticPropertyNotInClassType.1.normal.js index c65de83b49f18..9fd5f25f88820 100644 --- a/crates/swc/tests/tsc-references/staticPropertyNotInClassType.1.normal.js +++ b/crates/swc/tests/tsc-references/staticPropertyNotInClassType.1.normal.js @@ -26,7 +26,16 @@ var NonGeneric; return C; }(); (function(C) { - var bar = C.bar = ""; + var bar = ""; // not reflected in class type + Object.defineProperty(C, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(C || (C = {})); var c = new C(1, 2); var r = c.fn(); @@ -59,7 +68,16 @@ var Generic; return C; }(); (function(C) { - var bar = C.bar = ""; + var bar = ""; // not reflected in class type + Object.defineProperty(C, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(C || (C = {})); var c = new C(1, ""); var r = c.fn(); diff --git a/crates/swc/tests/tsc-references/staticPropertyNotInClassType.2.minified.js b/crates/swc/tests/tsc-references/staticPropertyNotInClassType.2.minified.js index 41d71ae1ff139..4717764aca642 100644 --- a/crates/swc/tests/tsc-references/staticPropertyNotInClassType.2.minified.js +++ b/crates/swc/tests/tsc-references/staticPropertyNotInClassType.2.minified.js @@ -1,8 +1,8 @@ //// [staticPropertyNotInClassType.ts] -var NonGeneric, Generic, C, c, C1, c1; +var NonGeneric, Generic, C, C1, bar, c, C2, C3, bar1, c1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _create_class } from "@swc/helpers/_/_create_class"; -NonGeneric || (NonGeneric = {}), ((C = function() { +NonGeneric || (NonGeneric = {}), C1 = (C = function() { function C(a, b) { _class_call_check(this, C), this.a = a, this.b = b; } @@ -17,7 +17,15 @@ NonGeneric || (NonGeneric = {}), ((C = function() { set: function(v) {} } ]), C; -}()) || (C = {})).bar = "", (c = new C(1, 2)).fn(), c.foo, c.bar, c.x, Generic || (Generic = {}), ((C1 = function() { +}()) || (C = {}), bar = "", Object.defineProperty(C1, "bar", { + enumerable: !0, + get: function() { + return bar; + }, + set: function(v) { + bar = v; + } +}), (c = new C(1, 2)).fn(), c.foo, c.bar, c.x, Generic || (Generic = {}), C3 = (C2 = function() { function C(a, b) { _class_call_check(this, C), this.a = a, this.b = b; } @@ -32,4 +40,12 @@ NonGeneric || (NonGeneric = {}), ((C = function() { set: function(v) {} } ]), C; -}()) || (C1 = {})).bar = "", (c1 = new C1(1, "")).fn(), c1.foo, c1.bar, c1.x; +}()) || (C2 = {}), bar1 = "", Object.defineProperty(C3, "bar", { + enumerable: !0, + get: function() { + return bar1; + }, + set: function(v) { + bar1 = v; + } +}), (c1 = new C2(1, "")).fn(), c1.foo, c1.bar, c1.x; diff --git a/crates/swc/tests/tsc-references/strictPropertyInitialization.1.normal.js b/crates/swc/tests/tsc-references/strictPropertyInitialization.1.normal.js index fdd4db080873c..18f54caba6f64 100644 --- a/crates/swc/tests/tsc-references/strictPropertyInitialization.1.normal.js +++ b/crates/swc/tests/tsc-references/strictPropertyInitialization.1.normal.js @@ -143,12 +143,8 @@ var E; E["A"] = "A"; E["B"] = "B"; })(E || (E = {})); -let prop; class C13 { constructor(){ - this[E.A] = 1; + this["A"] = 1; } } -(()=>{ - prop = E.A; -})(); diff --git a/crates/swc/tests/tsc-references/strictPropertyInitialization.2.minified.js b/crates/swc/tests/tsc-references/strictPropertyInitialization.2.minified.js index 620e62b703a18..6c2e508eeb9b6 100644 --- a/crates/swc/tests/tsc-references/strictPropertyInitialization.2.minified.js +++ b/crates/swc/tests/tsc-references/strictPropertyInitialization.2.minified.js @@ -4,4 +4,4 @@ var E, E1; import "@swc/helpers/_/_class_private_field_get"; import "@swc/helpers/_/_class_private_field_init"; import "@swc/helpers/_/_class_private_field_set"; -Symbol(), (E1 = E || (E = {})).A = "A", E1.B = "B", E.A; +Symbol(), (E1 = E || (E = {})).A = "A", E1.B = "B"; diff --git a/crates/swc/tests/tsc-references/stringEnumLiteralTypes1.1.normal.js b/crates/swc/tests/tsc-references/stringEnumLiteralTypes1.1.normal.js index fb22154ad9687..e60bb4cf67137 100644 --- a/crates/swc/tests/tsc-references/stringEnumLiteralTypes1.1.normal.js +++ b/crates/swc/tests/tsc-references/stringEnumLiteralTypes1.1.normal.js @@ -1,10 +1,5 @@ //// [stringEnumLiteralTypes1.ts] var Choice; -(function(Choice) { - Choice["Unknown"] = ""; - Choice["Yes"] = "yes"; - Choice["No"] = "no"; -})(Choice || (Choice = {})); function f1() { var a; var a; diff --git a/crates/swc/tests/tsc-references/stringEnumLiteralTypes1.2.minified.js b/crates/swc/tests/tsc-references/stringEnumLiteralTypes1.2.minified.js index 511d418716d4f..aaf6377a3a1d7 100644 --- a/crates/swc/tests/tsc-references/stringEnumLiteralTypes1.2.minified.js +++ b/crates/swc/tests/tsc-references/stringEnumLiteralTypes1.2.minified.js @@ -1,3 +1 @@ //// [stringEnumLiteralTypes1.ts] -var Choice, Choice1; -(Choice1 = Choice || (Choice = {})).Unknown = "", Choice1.Yes = "yes", Choice1.No = "no"; diff --git a/crates/swc/tests/tsc-references/stringEnumLiteralTypes2.1.normal.js b/crates/swc/tests/tsc-references/stringEnumLiteralTypes2.1.normal.js index ee8f96230fdb8..0f406b5f46b9d 100644 --- a/crates/swc/tests/tsc-references/stringEnumLiteralTypes2.1.normal.js +++ b/crates/swc/tests/tsc-references/stringEnumLiteralTypes2.1.normal.js @@ -1,10 +1,5 @@ //// [stringEnumLiteralTypes2.ts] var Choice; -(function(Choice) { - Choice["Unknown"] = ""; - Choice["Yes"] = "yes"; - Choice["No"] = "no"; -})(Choice || (Choice = {})); function f1() { var a; var a; diff --git a/crates/swc/tests/tsc-references/stringEnumLiteralTypes2.2.minified.js b/crates/swc/tests/tsc-references/stringEnumLiteralTypes2.2.minified.js index 6739079656774..4599ba9ab402f 100644 --- a/crates/swc/tests/tsc-references/stringEnumLiteralTypes2.2.minified.js +++ b/crates/swc/tests/tsc-references/stringEnumLiteralTypes2.2.minified.js @@ -1,3 +1 @@ //// [stringEnumLiteralTypes2.ts] -var Choice, Choice1; -(Choice1 = Choice || (Choice = {})).Unknown = "", Choice1.Yes = "yes", Choice1.No = "no"; diff --git a/crates/swc/tests/tsc-references/stringEnumLiteralTypes3.1.normal.js b/crates/swc/tests/tsc-references/stringEnumLiteralTypes3.1.normal.js index 9a85ca58c8c48..022614e085c1a 100644 --- a/crates/swc/tests/tsc-references/stringEnumLiteralTypes3.1.normal.js +++ b/crates/swc/tests/tsc-references/stringEnumLiteralTypes3.1.normal.js @@ -1,10 +1,5 @@ //// [stringEnumLiteralTypes3.ts] var Choice; -(function(Choice) { - Choice["Unknown"] = ""; - Choice["Yes"] = "yes"; - Choice["No"] = "no"; -})(Choice || (Choice = {})); function f1(a, b, c, d) { a = a; a = b; diff --git a/crates/swc/tests/tsc-references/stringEnumLiteralTypes3.2.minified.js b/crates/swc/tests/tsc-references/stringEnumLiteralTypes3.2.minified.js index fcee833764c8a..a1a630d3d1148 100644 --- a/crates/swc/tests/tsc-references/stringEnumLiteralTypes3.2.minified.js +++ b/crates/swc/tests/tsc-references/stringEnumLiteralTypes3.2.minified.js @@ -1,3 +1 @@ //// [stringEnumLiteralTypes3.ts] -var Choice, Choice1; -(Choice1 = Choice || (Choice = {})).Unknown = "", Choice1.Yes = "yes", Choice1.No = "no"; diff --git a/crates/swc/tests/tsc-references/subtypesOfAny.1.normal.js b/crates/swc/tests/tsc-references/subtypesOfAny.1.normal.js index 699463936b7f1..635b823091ba5 100644 --- a/crates/swc/tests/tsc-references/subtypesOfAny.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypesOfAny.1.normal.js @@ -15,12 +15,30 @@ var E; })(E || (E = {})); function f() {} (function(f) { - var bar = f.bar = 1; + var bar = 1; + Object.defineProperty(f, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(f || (f = {})); var c = function c() { "use strict"; _class_call_check(this, c); }; (function(c) { - var bar = c.bar = 1; + var bar = 1; + Object.defineProperty(c, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(c || (c = {})); diff --git a/crates/swc/tests/tsc-references/subtypesOfAny.2.minified.js b/crates/swc/tests/tsc-references/subtypesOfAny.2.minified.js index 40c1a2e9f4b51..61749c5c22572 100644 --- a/crates/swc/tests/tsc-references/subtypesOfAny.2.minified.js +++ b/crates/swc/tests/tsc-references/subtypesOfAny.2.minified.js @@ -2,8 +2,24 @@ // every type is a subtype of any, no errors expected import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; function f() {} -(E = E1 || (E1 = {}))[E.A = 0] = "A", (f || (f = {})).bar = 1; -var E, E1, c = function c() { +(E = E1 || (E1 = {}))[E.A = 0] = "A", f1 = f || (f = {}), bar1 = 1, Object.defineProperty(f1, "bar", { + enumerable: !0, + get: function() { + return bar1; + }, + set: function(v) { + bar1 = v; + } +}); +var c, bar, E, f1, bar1, E1, c1 = function c() { _class_call_check(this, c); }; -(c || (c = {})).bar = 1; +c = c1 || (c1 = {}), bar = 1, Object.defineProperty(c, "bar", { + enumerable: !0, + get: function() { + return bar; + }, + set: function(v) { + bar = v; + } +}); diff --git a/crates/swc/tests/tsc-references/subtypesOfTypeParameter.1.normal.js b/crates/swc/tests/tsc-references/subtypesOfTypeParameter.1.normal.js index 49e16d9063cf5..837d5d2aa5ceb 100644 --- a/crates/swc/tests/tsc-references/subtypesOfTypeParameter.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypesOfTypeParameter.1.normal.js @@ -35,14 +35,32 @@ var E; })(E || (E = {})); function f() {} (function(f) { - var bar = f.bar = 1; + var bar = 1; + Object.defineProperty(f, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(f || (f = {})); var c = function c() { "use strict"; _class_call_check(this, c); }; (function(c) { - var bar = c.bar = 1; + var bar = 1; + Object.defineProperty(c, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(c || (c = {})); // errors throughout function f2(x, y) { @@ -94,8 +112,8 @@ function f2(x, y) { var r12 = true ? x : c2; var r13 = true ? E : x; var r13 = true ? x : E; - var r14 = true ? E.A : x; - var r14 = true ? x : E.A; + var r14 = true ? 0 : x; + var r14 = true ? x : 0; var af; var r15 = true ? af : x; var r15 = true ? x : af; diff --git a/crates/swc/tests/tsc-references/subtypesOfTypeParameter.2.minified.js b/crates/swc/tests/tsc-references/subtypesOfTypeParameter.2.minified.js index 44156cb275c4f..ac9507012e6a2 100644 --- a/crates/swc/tests/tsc-references/subtypesOfTypeParameter.2.minified.js +++ b/crates/swc/tests/tsc-references/subtypesOfTypeParameter.2.minified.js @@ -4,8 +4,24 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; function f() {} -(E1 = E || (E = {}))[E1.A = 0] = "A", (f || (f = {})).bar = 1; -var E, E1, c = function c() { +(E1 = E || (E = {}))[E1.A = 0] = "A", f1 = f || (f = {}), bar = 1, Object.defineProperty(f1, "bar", { + enumerable: !0, + get: function() { + return bar; + }, + set: function(v) { + bar = v; + } +}); +var E, E1, f1, bar, c, bar1, c1 = function c() { _class_call_check(this, c); }; -(c || (c = {})).bar = 1; +c = c1 || (c1 = {}), bar1 = 1, Object.defineProperty(c, "bar", { + enumerable: !0, + get: function() { + return bar1; + }, + set: function(v) { + bar1 = v; + } +}); diff --git a/crates/swc/tests/tsc-references/subtypesOfTypeParameterWithConstraints2.1.normal.js b/crates/swc/tests/tsc-references/subtypesOfTypeParameterWithConstraints2.1.normal.js index b6004c804af7f..4da18fc4c235f 100644 --- a/crates/swc/tests/tsc-references/subtypesOfTypeParameterWithConstraints2.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypesOfTypeParameterWithConstraints2.1.normal.js @@ -41,14 +41,32 @@ var E; })(E || (E = {})); function f() {} (function(f) { - var bar = f.bar = 1; + var bar = 1; + Object.defineProperty(f, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(f || (f = {})); var c = function c() { "use strict"; _class_call_check(this, c); }; (function(c) { - var bar = c.bar = 1; + var bar = 1; + Object.defineProperty(c, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(c || (c = {})); function f4(x) { var r0 = true ? x : null; // ok @@ -115,8 +133,8 @@ function f15(x) { function f16(x) { var r13 = true ? E : x; // ok var r13 = true ? x : E; // ok - var r14 = true ? E.A : x; // ok - var r14 = true ? x : E.A; // ok + var r14 = true ? 0 : x; // ok + var r14 = true ? x : 0; // ok } function f17(x) { var af; diff --git a/crates/swc/tests/tsc-references/subtypesOfTypeParameterWithConstraints2.2.minified.js b/crates/swc/tests/tsc-references/subtypesOfTypeParameterWithConstraints2.2.minified.js index 54b14df978385..19a34d865bbfe 100644 --- a/crates/swc/tests/tsc-references/subtypesOfTypeParameterWithConstraints2.2.minified.js +++ b/crates/swc/tests/tsc-references/subtypesOfTypeParameterWithConstraints2.2.minified.js @@ -2,8 +2,24 @@ // checking whether other types are subtypes of type parameters with constraints import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; function f() {} -(E = E1 || (E1 = {}))[E.A = 0] = "A", (f || (f = {})).bar = 1; -var E, E1, c = function c() { +(E = E1 || (E1 = {}))[E.A = 0] = "A", f1 = f || (f = {}), bar1 = 1, Object.defineProperty(f1, "bar", { + enumerable: !0, + get: function() { + return bar1; + }, + set: function(v) { + bar1 = v; + } +}); +var c, bar, E, f1, bar1, E1, c1 = function c() { _class_call_check(this, c); }; -(c || (c = {})).bar = 1; +c = c1 || (c1 = {}), bar = 1, Object.defineProperty(c, "bar", { + enumerable: !0, + get: function() { + return bar; + }, + set: function(v) { + bar = v; + } +}); diff --git a/crates/swc/tests/tsc-references/subtypesOfUnion.1.normal.js b/crates/swc/tests/tsc-references/subtypesOfUnion.1.normal.js index 095efa7444e9f..d7b8fa82acab3 100644 --- a/crates/swc/tests/tsc-references/subtypesOfUnion.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypesOfUnion.1.normal.js @@ -15,12 +15,30 @@ var A2 = function A2() { }; function f() {} (function(f) { - var bar = f.bar = 1; + var bar = 1; + Object.defineProperty(f, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(f || (f = {})); var c = function c() { "use strict"; _class_call_check(this, c); }; (function(c) { - var bar = c.bar = 1; + var bar = 1; + Object.defineProperty(c, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(c || (c = {})); diff --git a/crates/swc/tests/tsc-references/subtypesOfUnion.2.minified.js b/crates/swc/tests/tsc-references/subtypesOfUnion.2.minified.js index bf95162d54262..a4f8f871025b3 100644 --- a/crates/swc/tests/tsc-references/subtypesOfUnion.2.minified.js +++ b/crates/swc/tests/tsc-references/subtypesOfUnion.2.minified.js @@ -1,8 +1,24 @@ //// [subtypesOfUnion.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; function f() {} -(E = E1 || (E1 = {}))[E.e1 = 0] = "e1", E[E.e2 = 1] = "e2", (f || (f = {})).bar = 1; -var E, E1, c = function c() { +(E = E1 || (E1 = {}))[E.e1 = 0] = "e1", E[E.e2 = 1] = "e2", f1 = f || (f = {}), bar1 = 1, Object.defineProperty(f1, "bar", { + enumerable: !0, + get: function() { + return bar1; + }, + set: function(v) { + bar1 = v; + } +}); +var c, bar, E, f1, bar1, E1, c1 = function c() { _class_call_check(this, c); }; -(c || (c = {})).bar = 1; +c = c1 || (c1 = {}), bar = 1, Object.defineProperty(c, "bar", { + enumerable: !0, + get: function() { + return bar; + }, + set: function(v) { + bar = v; + } +}); diff --git a/crates/swc/tests/tsc-references/subtypingWithObjectMembers5.1.normal.js b/crates/swc/tests/tsc-references/subtypingWithObjectMembers5.1.normal.js index 007ffa90b2e69..72fb32b50cd5d 100644 --- a/crates/swc/tests/tsc-references/subtypingWithObjectMembers5.1.normal.js +++ b/crates/swc/tests/tsc-references/subtypingWithObjectMembers5.1.normal.js @@ -1,8 +1,8 @@ //// [subtypingWithObjectMembers5.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; +var NotOptional; // N and M have the same name, same accessibility, same optionality, and N is a subtype of M // foo properties are valid, bar properties cause errors in the derived class declarations -var NotOptional; (function(NotOptional) { var B = function B() { "use strict"; @@ -17,8 +17,8 @@ var NotOptional; _class_call_check(this, B3); }; })(NotOptional || (NotOptional = {})); -// same cases as above but with optional var Optional; +// same cases as above but with optional (function(Optional) { var B = function B() { "use strict"; diff --git a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2015).1.normal.js b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2015).1.normal.js index ee0ce84b115c1..a5a95bcca5de6 100644 --- a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2015).1.normal.js +++ b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2015).1.normal.js @@ -39,15 +39,12 @@ class C extends B { _get(_get_prototype_of(C), "w", C).call(C); })(), (()=>{ - let Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + let Reflect; + (function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) _get(_get_prototype_of(C), "w", C).call(C); })(), (()=>{ - let Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + let Reflect; _get(_get_prototype_of(C), "w", C).call(C); })(), (()=>{ @@ -93,15 +90,12 @@ class C extends B { _get(_get_prototype_of(C), "w", C).call(C); })(); (()=>{ - let Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + let Reflect; + (function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) _get(_get_prototype_of(C), "w", C).call(C); })(); (()=>{ - let Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + let Reflect; _get(_get_prototype_of(C), "w", C).call(C); })(); (()=>{ @@ -253,9 +247,8 @@ export { }; //// [enumInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; +(function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) class C extends B { } (()=>{ @@ -265,9 +258,8 @@ export { }; //// [enumInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; +(function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) class C extends B { } (()=>{ @@ -277,9 +269,7 @@ export { }; //// [constEnumInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; class C extends B { } (()=>{ @@ -289,9 +279,7 @@ export { }; //// [constEnumInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; class C extends B { } (()=>{ @@ -306,7 +294,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [namespaceImportInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -315,7 +303,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -324,7 +312,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -333,7 +321,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportOfInterfaceInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -342,7 +330,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfInterfaceInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -351,7 +339,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfUninstantiatedNamespaceInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -360,7 +348,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfUninstantiatedNamespaceInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -369,7 +357,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfConstEnumInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -378,7 +366,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportOfConstEnumInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -387,7 +375,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [typeOnlyNamedImportInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -396,7 +384,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // no collision //// [typeOnlyNamedImportInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -405,7 +393,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // no collision //// [defaultImportInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -414,7 +402,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [defaultImportInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -423,7 +411,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [typeOnlyDefaultImportInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -432,7 +420,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // no collision //// [typeOnlyDefaultImportInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -441,7 +429,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // no collision //// [typeInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; diff --git a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2015).2.minified.js b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2015).2.minified.js index 69f1ed1a8739d..bae5010fde618 100644 --- a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2015).2.minified.js +++ b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2015).2.minified.js @@ -7,11 +7,7 @@ Baz || (Baz = {}); export default class { } //// [locals.ts] -let Reflect// collision (es2015-es2021 only) -, Reflect1// collision (es2015-es2021 only) -, Reflect2// collision (es2015-es2021 only) -, Reflect3// collision (es2015-es2021 only) -; +let Reflect, Reflect1; import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; class C extends B { @@ -33,7 +29,7 @@ C._ = [ void _get(_get_prototype_of(C), "w", C).call(C), void _get(_get_prototype_of(C), "w", C).call(C), void (Reflect || (Reflect = {}), _get(_get_prototype_of(C), "w", C).call(C)), - void (Reflect1 || (Reflect1 = {}), _get(_get_prototype_of(C), "w", C).call(C)), + void _get(_get_prototype_of(C), "w", C).call(C), void _get(_get_prototype_of(C), "w", C).call(C), void _get(_get_prototype_of(C), "w", C).call(C), void _get(_get_prototype_of(C), "w", C).call(C), @@ -48,7 +44,7 @@ C._ = [ null ]; // collision (es2015-es2021 only) _get(_get_prototype_of(C), "w", C).call(C); -})(), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), Reflect2 || (Reflect2 = {}), _get(_get_prototype_of(C), "w", C).call(C), Reflect3 || (Reflect3 = {}), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C); +})(), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), Reflect1 || (Reflect1 = {}), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C); //// [varInContainingScopeStaticField1.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -134,38 +130,30 @@ class C extends B { } _get(_get_prototype_of(C), "w", C).call(C); //// [enumInContainingScopeStaticField.ts] -var Reflect// collision (es2015-es2021 only) -; +var Reflect; import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -Reflect || (Reflect = {}); +Reflect || (Reflect = {}); // collision (es2015-es2021 only) class C extends B { } C._ = _get(_get_prototype_of(C), "w", C).call(C); //// [enumInContainingScopeStaticBlock.ts] -var Reflect// collision (es2015-es2021 only) -; +var Reflect; import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -Reflect || (Reflect = {}); +Reflect || (Reflect = {}); // collision (es2015-es2021 only) class C extends B { } _get(_get_prototype_of(C), "w", C).call(C); //// [constEnumInContainingScopeStaticField.ts] -var Reflect// collision (es2015-es2021 only) -; import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -Reflect || (Reflect = {}); class C extends B { } C._ = _get(_get_prototype_of(C), "w", C).call(C); //// [constEnumInContainingScopeStaticBlock.ts] -var Reflect// collision (es2015-es2021 only) -; import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -Reflect || (Reflect = {}); class C extends B { } _get(_get_prototype_of(C), "w", C).call(C); diff --git a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2021).1.normal.js b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2021).1.normal.js index ee0ce84b115c1..a5a95bcca5de6 100644 --- a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2021).1.normal.js +++ b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2021).1.normal.js @@ -39,15 +39,12 @@ class C extends B { _get(_get_prototype_of(C), "w", C).call(C); })(), (()=>{ - let Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + let Reflect; + (function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) _get(_get_prototype_of(C), "w", C).call(C); })(), (()=>{ - let Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + let Reflect; _get(_get_prototype_of(C), "w", C).call(C); })(), (()=>{ @@ -93,15 +90,12 @@ class C extends B { _get(_get_prototype_of(C), "w", C).call(C); })(); (()=>{ - let Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + let Reflect; + (function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) _get(_get_prototype_of(C), "w", C).call(C); })(); (()=>{ - let Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + let Reflect; _get(_get_prototype_of(C), "w", C).call(C); })(); (()=>{ @@ -253,9 +247,8 @@ export { }; //// [enumInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; +(function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) class C extends B { } (()=>{ @@ -265,9 +258,8 @@ export { }; //// [enumInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; +(function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) class C extends B { } (()=>{ @@ -277,9 +269,7 @@ export { }; //// [constEnumInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; class C extends B { } (()=>{ @@ -289,9 +279,7 @@ export { }; //// [constEnumInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; class C extends B { } (()=>{ @@ -306,7 +294,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [namespaceImportInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -315,7 +303,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -324,7 +312,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -333,7 +321,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportOfInterfaceInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -342,7 +330,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfInterfaceInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -351,7 +339,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfUninstantiatedNamespaceInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -360,7 +348,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfUninstantiatedNamespaceInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -369,7 +357,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfConstEnumInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -378,7 +366,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportOfConstEnumInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -387,7 +375,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [typeOnlyNamedImportInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -396,7 +384,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // no collision //// [typeOnlyNamedImportInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -405,7 +393,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // no collision //// [defaultImportInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -414,7 +402,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [defaultImportInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -423,7 +411,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [typeOnlyDefaultImportInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -432,7 +420,7 @@ class C extends B { (()=>{ C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // no collision //// [typeOnlyDefaultImportInContainingScopeStaticBlock.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -441,7 +429,7 @@ class C extends B { (()=>{ _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // no collision //// [typeInContainingScopeStaticField.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; diff --git a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2021).2.minified.js b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2021).2.minified.js index 69f1ed1a8739d..bae5010fde618 100644 --- a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2021).2.minified.js +++ b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2021).2.minified.js @@ -7,11 +7,7 @@ Baz || (Baz = {}); export default class { } //// [locals.ts] -let Reflect// collision (es2015-es2021 only) -, Reflect1// collision (es2015-es2021 only) -, Reflect2// collision (es2015-es2021 only) -, Reflect3// collision (es2015-es2021 only) -; +let Reflect, Reflect1; import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; class C extends B { @@ -33,7 +29,7 @@ C._ = [ void _get(_get_prototype_of(C), "w", C).call(C), void _get(_get_prototype_of(C), "w", C).call(C), void (Reflect || (Reflect = {}), _get(_get_prototype_of(C), "w", C).call(C)), - void (Reflect1 || (Reflect1 = {}), _get(_get_prototype_of(C), "w", C).call(C)), + void _get(_get_prototype_of(C), "w", C).call(C), void _get(_get_prototype_of(C), "w", C).call(C), void _get(_get_prototype_of(C), "w", C).call(C), void _get(_get_prototype_of(C), "w", C).call(C), @@ -48,7 +44,7 @@ C._ = [ null ]; // collision (es2015-es2021 only) _get(_get_prototype_of(C), "w", C).call(C); -})(), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), Reflect2 || (Reflect2 = {}), _get(_get_prototype_of(C), "w", C).call(C), Reflect3 || (Reflect3 = {}), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C); +})(), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), Reflect1 || (Reflect1 = {}), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C); //// [varInContainingScopeStaticField1.ts] import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -134,38 +130,30 @@ class C extends B { } _get(_get_prototype_of(C), "w", C).call(C); //// [enumInContainingScopeStaticField.ts] -var Reflect// collision (es2015-es2021 only) -; +var Reflect; import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -Reflect || (Reflect = {}); +Reflect || (Reflect = {}); // collision (es2015-es2021 only) class C extends B { } C._ = _get(_get_prototype_of(C), "w", C).call(C); //// [enumInContainingScopeStaticBlock.ts] -var Reflect// collision (es2015-es2021 only) -; +var Reflect; import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -Reflect || (Reflect = {}); +Reflect || (Reflect = {}); // collision (es2015-es2021 only) class C extends B { } _get(_get_prototype_of(C), "w", C).call(C); //// [constEnumInContainingScopeStaticField.ts] -var Reflect// collision (es2015-es2021 only) -; import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -Reflect || (Reflect = {}); class C extends B { } C._ = _get(_get_prototype_of(C), "w", C).call(C); //// [constEnumInContainingScopeStaticBlock.ts] -var Reflect// collision (es2015-es2021 only) -; import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; -Reflect || (Reflect = {}); class C extends B { } _get(_get_prototype_of(C), "w", C).call(C); diff --git a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2022).1.normal.js b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2022).1.normal.js index c3f46bc40d644..0303766a77900 100644 --- a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2022).1.normal.js +++ b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2022).1.normal.js @@ -36,15 +36,12 @@ class C extends B { super.w(); })(), (()=>{ - let Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + let Reflect; + (function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) super.w(); })(), (()=>{ - let Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + let Reflect; super.w(); })(), (()=>{ @@ -90,15 +87,12 @@ class C extends B { super.w(); } static{ - let Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + let Reflect; + (function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) super.w(); } static{ - let Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + let Reflect; super.w(); } static{ @@ -225,9 +219,8 @@ class C extends B { } export { }; //// [enumInContainingScopeStaticField.ts] -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; +(function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) class C extends B { static{ this._ = super.w(); @@ -235,9 +228,8 @@ class C extends B { } export { }; //// [enumInContainingScopeStaticBlock.ts] -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; +(function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) class C extends B { static{ super.w(); @@ -245,9 +237,7 @@ class C extends B { } export { }; //// [constEnumInContainingScopeStaticField.ts] -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; class C extends B { static{ this._ = super.w(); @@ -255,9 +245,7 @@ class C extends B { } export { }; //// [constEnumInContainingScopeStaticBlock.ts] -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; class C extends B { static{ super.w(); @@ -270,112 +258,112 @@ class C extends B { this._ = super.w(); } } -export { }; +export { }; // collision (es2015-es2021 only) //// [namespaceImportInContainingScopeStaticBlock.ts] class C extends B { static{ super.w(); } } -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportInContainingScopeStaticField.ts] class C extends B { static{ this._ = super.w(); } } -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportInContainingScopeStaticBlock.ts] class C extends B { static{ super.w(); } } -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportOfInterfaceInContainingScopeStaticField.ts] class C extends B { static{ this._ = super.w(); } } -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfInterfaceInContainingScopeStaticBlock.ts] class C extends B { static{ super.w(); } } -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfUninstantiatedNamespaceInContainingScopeStaticField.ts] class C extends B { static{ this._ = super.w(); } } -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfUninstantiatedNamespaceInContainingScopeStaticBlock.ts] class C extends B { static{ super.w(); } } -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfConstEnumInContainingScopeStaticField.ts] class C extends B { static{ this._ = super.w(); } } -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportOfConstEnumInContainingScopeStaticBlock.ts] class C extends B { static{ super.w(); } } -export { }; +export { }; // collision (es2015-es2021 only) //// [typeOnlyNamedImportInContainingScopeStaticField.ts] class C extends B { static{ this._ = super.w(); } } -export { }; +export { }; // no collision //// [typeOnlyNamedImportInContainingScopeStaticBlock.ts] class C extends B { static{ super.w(); } } -export { }; +export { }; // no collision //// [defaultImportInContainingScopeStaticField.ts] class C extends B { static{ this._ = super.w(); } } -export { }; +export { }; // collision (es2015-es2021 only) //// [defaultImportInContainingScopeStaticBlock.ts] class C extends B { static{ super.w(); } } -export { }; +export { }; // collision (es2015-es2021 only) //// [typeOnlyDefaultImportInContainingScopeStaticField.ts] class C extends B { static{ this._ = super.w(); } } -export { }; +export { }; // no collision //// [typeOnlyDefaultImportInContainingScopeStaticBlock.ts] class C extends B { static{ super.w(); } } -export { }; +export { }; // no collision //// [typeInContainingScopeStaticField.ts] class C extends B { static{ diff --git a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2022).2.minified.js b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2022).2.minified.js index c10861faeefdd..3c152100fb54a 100644 --- a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2022).2.minified.js +++ b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2022).2.minified.js @@ -9,9 +9,7 @@ export default class { //// [locals.ts] class C extends B { static{ - let Reflect// collision (es2015-es2021 only) - , Reflect1// collision (es2015-es2021 only) - ; + let Reflect; this._ = [ void super.w(), (()=>{ @@ -29,7 +27,7 @@ class C extends B { void super.w(), void super.w(), void (Reflect || (Reflect = {}), super.w()), - void (Reflect1 || (Reflect1 = {}), super.w()), + void super.w(), void super.w(), void super.w(), void super.w(), @@ -58,14 +56,11 @@ class C extends B { super.w(); } static{ - let Reflect// collision (es2015-es2021 only) - ; + let Reflect; Reflect || (Reflect = {}), super.w(); } static{ - let Reflect// collision (es2015-es2021 only) - ; - Reflect || (Reflect = {}), super.w(); + super.w(); } static{ super.w(); @@ -178,9 +173,8 @@ class C extends B { } export { }; //// [enumInContainingScopeStaticField.ts] -var Reflect// collision (es2015-es2021 only) -; -Reflect || (Reflect = {}); +var Reflect; +Reflect || (Reflect = {}); // collision (es2015-es2021 only) class C extends B { static{ this._ = super.w(); @@ -188,9 +182,8 @@ class C extends B { } export { }; //// [enumInContainingScopeStaticBlock.ts] -var Reflect// collision (es2015-es2021 only) -; -Reflect || (Reflect = {}); +var Reflect; +Reflect || (Reflect = {}); // collision (es2015-es2021 only) class C extends B { static{ super.w(); @@ -198,9 +191,6 @@ class C extends B { } export { }; //// [constEnumInContainingScopeStaticField.ts] -var Reflect// collision (es2015-es2021 only) -; -Reflect || (Reflect = {}); class C extends B { static{ this._ = super.w(); @@ -208,9 +198,6 @@ class C extends B { } export { }; //// [constEnumInContainingScopeStaticBlock.ts] -var Reflect// collision (es2015-es2021 only) -; -Reflect || (Reflect = {}); class C extends B { static{ super.w(); diff --git a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es5).1.normal.js b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es5).1.normal.js index 4ec85f8e7dc8b..0ff4f8aae25c8 100644 --- a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es5).1.normal.js +++ b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es5).1.normal.js @@ -57,15 +57,12 @@ var C = /*#__PURE__*/ function(B1) { _get(_get_prototype_of(C), "w", C).call(C); }(), function() { - var Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + var Reflect; + (function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) _get(_get_prototype_of(C), "w", C).call(C); }(), function() { - var Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + var Reflect; _get(_get_prototype_of(C), "w", C).call(C); }(), function() { @@ -115,15 +112,12 @@ var C = /*#__PURE__*/ function(B1) { _get(_get_prototype_of(C), "w", C).call(C); })(); (function() { - var Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + var Reflect; + (function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) _get(_get_prototype_of(C), "w", C).call(C); })(); (function() { - var Reflect// collision (es2015-es2021 only) - ; - (function(Reflect) {})(Reflect || (Reflect = {})); + var Reflect; _get(_get_prototype_of(C), "w", C).call(C); })(); (function() { @@ -414,9 +408,8 @@ import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; +(function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) var C = /*#__PURE__*/ function(B1) { "use strict"; _inherits(C, B1); @@ -437,9 +430,8 @@ import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; +(function(Reflect) {})(Reflect || (Reflect = {})); // collision (es2015-es2021 only) var C = /*#__PURE__*/ function(B1) { "use strict"; _inherits(C, B1); @@ -460,9 +452,7 @@ import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; var C = /*#__PURE__*/ function(B1) { "use strict"; _inherits(C, B1); @@ -483,9 +473,7 @@ import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -var Reflect// collision (es2015-es2021 only) -; -(function(Reflect) {})(Reflect || (Reflect = {})); +var Reflect; var C = /*#__PURE__*/ function(B1) { "use strict"; _inherits(C, B1); @@ -519,7 +507,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [namespaceImportInContainingScopeStaticBlock.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -539,7 +527,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportInContainingScopeStaticField.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -559,7 +547,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportInContainingScopeStaticBlock.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -579,7 +567,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportOfInterfaceInContainingScopeStaticField.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -599,7 +587,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfInterfaceInContainingScopeStaticBlock.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -619,7 +607,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfUninstantiatedNamespaceInContainingScopeStaticField.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -639,7 +627,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfUninstantiatedNamespaceInContainingScopeStaticBlock.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -659,7 +647,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only, not a type-only import) //// [namedImportOfConstEnumInContainingScopeStaticField.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -679,7 +667,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [namedImportOfConstEnumInContainingScopeStaticBlock.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -699,7 +687,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [typeOnlyNamedImportInContainingScopeStaticField.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -719,7 +707,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // no collision //// [typeOnlyNamedImportInContainingScopeStaticBlock.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -739,7 +727,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // no collision //// [defaultImportInContainingScopeStaticField.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -759,7 +747,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [defaultImportInContainingScopeStaticBlock.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -779,7 +767,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // collision (es2015-es2021 only) //// [typeOnlyDefaultImportInContainingScopeStaticField.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -799,7 +787,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { C._ = _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // no collision //// [typeOnlyDefaultImportInContainingScopeStaticBlock.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -819,7 +807,7 @@ var C = /*#__PURE__*/ function(B1) { (function() { _get(_get_prototype_of(C), "w", C).call(C); })(); -export { }; +export { }; // no collision //// [typeInContainingScopeStaticField.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; diff --git a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es5).2.minified.js b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es5).2.minified.js index 1131de20133b4..ed1fb24a98989 100644 --- a/crates/swc/tests/tsc-references/superInStaticMembers1(target=es5).2.minified.js +++ b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es5).2.minified.js @@ -16,11 +16,7 @@ import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -var Reflect// collision (es2015-es2021 only) -, Reflect1// collision (es2015-es2021 only) -, Reflect2// collision (es2015-es2021 only) -, Reflect3// collision (es2015-es2021 only) -, C = function(B1) { +var Reflect, Reflect1, C = function(B1) { _inherits(C, B1); var _super = _create_super(C); function C() { @@ -35,12 +31,12 @@ C._ = [ void _get(_get_prototype_of(C), "w", C).call(C), void _get(_get_prototype_of(C), "w", C).call(C), void (Reflect || (Reflect = {}), _get(_get_prototype_of(C), "w", C).call(C)), - void (Reflect1 || (Reflect1 = {}), _get(_get_prototype_of(C), "w", C).call(C)), + void _get(_get_prototype_of(C), "w", C).call(C), void _get(_get_prototype_of(C), "w", C).call(C), void _get(_get_prototype_of(C), "w", C).call(C), void _get(_get_prototype_of(C), "w", C).call(C), void _get(_get_prototype_of(C), "w", C).call(C) -], _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), Reflect2 || (Reflect2 = {}), _get(_get_prototype_of(C), "w", C).call(C), Reflect3 || (Reflect3 = {}), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C); +], _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), Reflect1 || (Reflect1 = {}), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C), _get(_get_prototype_of(C), "w", C).call(C); //// [varInContainingScopeStaticField1.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -227,9 +223,8 @@ import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -Reflect || (Reflect = {}); -var Reflect// collision (es2015-es2021 only) -, C = function(B1) { +Reflect || (Reflect = {}); // collision (es2015-es2021 only) +var Reflect, C = function(B1) { _inherits(C, B1); var _super = _create_super(C); function C() { @@ -244,9 +239,8 @@ import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -Reflect || (Reflect = {}); -var Reflect// collision (es2015-es2021 only) -, C = function(B1) { +Reflect || (Reflect = {}); // collision (es2015-es2021 only) +var Reflect, C = function(B1) { _inherits(C, B1); var _super = _create_super(C); function C() { @@ -261,9 +255,7 @@ import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -Reflect || (Reflect = {}); -var Reflect// collision (es2015-es2021 only) -, C = function(B1) { +var C = function(B1) { _inherits(C, B1); var _super = _create_super(C); function C() { @@ -278,9 +270,7 @@ import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -Reflect || (Reflect = {}); -var Reflect// collision (es2015-es2021 only) -, C = function(B1) { +var C = function(B1) { _inherits(C, B1); var _super = _create_super(C); function C() { diff --git a/crates/swc/tests/tsc-references/symbolProperty49.1.normal.js b/crates/swc/tests/tsc-references/symbolProperty49.1.normal.js index 51acd15c3555a..70eec020b6fd3 100644 --- a/crates/swc/tests/tsc-references/symbolProperty49.1.normal.js +++ b/crates/swc/tests/tsc-references/symbolProperty49.1.normal.js @@ -2,8 +2,16 @@ var M; (function(M) { var Symbol; + Object.defineProperty(M, "Symbol", { + enumerable: true, + get () { + return Symbol; + }, + set (v) { + Symbol = v; + } + }); class C { [Symbol.iterator]() {} } - M.Symbol = Symbol; })(M || (M = {})); diff --git a/crates/swc/tests/tsc-references/symbolProperty49.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty49.2.minified.js index 1c75b68312b9c..22b25882a0c7c 100644 --- a/crates/swc/tests/tsc-references/symbolProperty49.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty49.2.minified.js @@ -1,3 +1,9 @@ //// [symbolProperty49.ts] -var M, M1, Symbol; -M1 = M || (M = {}), Symbol.iterator, M1.Symbol = Symbol; +var M, Symbol; +Object.defineProperty(M || (M = {}), "Symbol", { + enumerable: !0, + get: ()=>Symbol, + set (v) { + Symbol = v; + } +}), Symbol.iterator; diff --git a/crates/swc/tests/tsc-references/templateLiteralTypes4.1.normal.js b/crates/swc/tests/tsc-references/templateLiteralTypes4.1.normal.js index e64cf4f1992ab..4255c64f99c81 100644 --- a/crates/swc/tests/tsc-references/templateLiteralTypes4.1.normal.js +++ b/crates/swc/tests/tsc-references/templateLiteralTypes4.1.normal.js @@ -1,25 +1,8 @@ //// [templateLiteralTypes4.ts] // infer from number -var // infer from literal enums -StringLiteralEnum; -(function(StringLiteralEnum) { - StringLiteralEnum["Zero"] = "0"; - StringLiteralEnum["True"] = "true"; - StringLiteralEnum["False"] = "false"; - StringLiteralEnum["Undefined"] = "undefined"; - StringLiteralEnum["Null"] = "null"; -})(StringLiteralEnum || (StringLiteralEnum = {})); +var StringLiteralEnum; var NumberLiteralEnum; -(function(NumberLiteralEnum) { - NumberLiteralEnum[NumberLiteralEnum["Zero"] = 0] = "Zero"; - NumberLiteralEnum[NumberLiteralEnum["One"] = 1] = "One"; -})(NumberLiteralEnum || (NumberLiteralEnum = {})); -var // infer from non-literal enums -NonLiteralEnum; -(function(NonLiteralEnum) { - NonLiteralEnum[NonLiteralEnum["Zero"] = 0] = "Zero"; - NonLiteralEnum[NonLiteralEnum["One"] = 1] = "One"; -})(NonLiteralEnum || (NonLiteralEnum = {})); +var NonLiteralEnum; p.getIndex(0); // ok, 0 is a valid index p.getIndex(1); // ok, 1 is a valid index p.getIndex(2); // error, 2 is not a valid index diff --git a/crates/swc/tests/tsc-references/templateLiteralTypes4.2.minified.js b/crates/swc/tests/tsc-references/templateLiteralTypes4.2.minified.js index 67dca2741f89a..cec3b1f083a82 100644 --- a/crates/swc/tests/tsc-references/templateLiteralTypes4.2.minified.js +++ b/crates/swc/tests/tsc-references/templateLiteralTypes4.2.minified.js @@ -1,7 +1,4 @@ //// [templateLiteralTypes4.ts] // infer from number -var // infer from literal enums -StringLiteralEnum, NumberLiteralEnum, // infer from non-literal enums -NonLiteralEnum, StringLiteralEnum1, NumberLiteralEnum1, NonLiteralEnum1; -(StringLiteralEnum1 = StringLiteralEnum || (StringLiteralEnum = {})).Zero = "0", StringLiteralEnum1.True = "true", StringLiteralEnum1.False = "false", StringLiteralEnum1.Undefined = "undefined", StringLiteralEnum1.Null = "null", (NumberLiteralEnum1 = NumberLiteralEnum || (NumberLiteralEnum = {}))[NumberLiteralEnum1.Zero = 0] = "Zero", NumberLiteralEnum1[NumberLiteralEnum1.One = 1] = "One", (NonLiteralEnum1 = NonLiteralEnum || (NonLiteralEnum = {}))[NonLiteralEnum1.Zero = 0] = "Zero", NonLiteralEnum1[NonLiteralEnum1.One = 1] = "One", p.getIndex(0), p.getIndex(1), p.getIndex(2), p.setIndex(0, 0), p.setIndex(1, 0), p.setIndex(2, 3), f1("**123**"), f2("**123**"), f3("**123**"), f4("**true**"), f4("**false**"); +p.getIndex(0), p.getIndex(1), p.getIndex(2), p.setIndex(0, 0), p.setIndex(1, 0), p.setIndex(2, 3), f1("**123**"), f2("**123**"), f3("**123**"), f4("**true**"), f4("**false**"); // false | "false" diff --git a/crates/swc/tests/tsc-references/thisTypeErrors.1.normal.js b/crates/swc/tests/tsc-references/thisTypeErrors.1.normal.js index df3c2c4ae3054..23176765f6bb6 100644 --- a/crates/swc/tests/tsc-references/thisTypeErrors.1.normal.js +++ b/crates/swc/tests/tsc-references/thisTypeErrors.1.normal.js @@ -27,8 +27,25 @@ var C2 = /*#__PURE__*/ function() { var N1; (function(N1) { var x; - var y = N1.y = this; - N1.x = x; + Object.defineProperty(N1, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); + var y = this; + Object.defineProperty(N1, "y", { + enumerable: true, + get: function get() { + return y; + }, + set: function set(v) { + y = v; + } + }); })(N1 || (N1 = {})); var C3 = /*#__PURE__*/ function() { "use strict"; diff --git a/crates/swc/tests/tsc-references/thisTypeErrors.2.minified.js b/crates/swc/tests/tsc-references/thisTypeErrors.2.minified.js index 603a79780df25..994988c961314 100644 --- a/crates/swc/tests/tsc-references/thisTypeErrors.2.minified.js +++ b/crates/swc/tests/tsc-references/thisTypeErrors.2.minified.js @@ -7,6 +7,23 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; } return C2.foo = function(x) {}, C2; })().y = void 0, function(N1) { - var x; - N1.y = this, N1.x = x; + Object.defineProperty(N1, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } + }); + var x, y = this; + Object.defineProperty(N1, "y", { + enumerable: !0, + get: function() { + return y; + }, + set: function(v) { + y = v; + } + }); }(N1 || (N1 = {})); diff --git a/crates/swc/tests/tsc-references/tsxElementResolution17.1.normal.js b/crates/swc/tests/tsc-references/tsxElementResolution17.1.normal.js index 40d008b8068d7..fc9aad8cb8212 100644 --- a/crates/swc/tests/tsc-references/tsxElementResolution17.1.normal.js +++ b/crates/swc/tests/tsc-references/tsxElementResolution17.1.normal.js @@ -16,9 +16,8 @@ define([ define([ "require", "exports", - "elements1", - "elements2" -], function(require, exports, _elements1, _elements2) { + "elements1" +], function(require, exports, _elements1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true diff --git a/crates/swc/tests/tsc-references/tsxElementResolution17.2.minified.js b/crates/swc/tests/tsc-references/tsxElementResolution17.2.minified.js index 1f9c68bd569ee..8e61007f3e81e 100644 --- a/crates/swc/tests/tsc-references/tsxElementResolution17.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxElementResolution17.2.minified.js @@ -12,9 +12,8 @@ define([ define([ "require", "exports", - "elements1", - "elements2" -], function(require, exports, _elements1, _elements2) { + "elements1" +], function(require, exports, _elements1) { Object.defineProperty(exports, "__esModule", { value: !0 }), _elements1.MyElement; diff --git a/crates/swc/tests/tsc-references/tsxElementResolution7.1.normal.js b/crates/swc/tests/tsc-references/tsxElementResolution7.1.normal.js index 32ac6a0d048a8..4abf926c8c14e 100644 --- a/crates/swc/tests/tsc-references/tsxElementResolution7.1.normal.js +++ b/crates/swc/tests/tsc-references/tsxElementResolution7.1.normal.js @@ -2,7 +2,15 @@ var my; (function(my) { var div; - my.div = div; + Object.defineProperty(my, "div", { + enumerable: true, + get: function get() { + return div; + }, + set: function set(v) { + div = v; + } + }); })(my || (my = {})); // OK /*#__PURE__*/ React.createElement(my.div, { diff --git a/crates/swc/tests/tsc-references/tsxElementResolution7.2.minified.js b/crates/swc/tests/tsc-references/tsxElementResolution7.2.minified.js index cb53020c9670f..5668ff3c3f53c 100644 --- a/crates/swc/tests/tsc-references/tsxElementResolution7.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxElementResolution7.2.minified.js @@ -1,3 +1,11 @@ //// [file.tsx] var my, q, div, mine; -(my || (my = {})).div = div, my.div, my.other, q || (q = {}), (mine = my).div, mine.non; +Object.defineProperty(my || (my = {}), "div", { + enumerable: !0, + get: function() { + return div; + }, + set: function(v) { + div = v; + } +}), my.div, my.other, q || (q = {}), (mine = my).div, mine.non; diff --git a/crates/swc/tests/tsc-references/tsxEmit3.1.normal.js b/crates/swc/tests/tsc-references/tsxEmit3.1.normal.js index bc65d2df71a06..aa46ddd87b018 100644 --- a/crates/swc/tests/tsc-references/tsxEmit3.1.normal.js +++ b/crates/swc/tests/tsc-references/tsxEmit3.1.normal.js @@ -14,6 +14,8 @@ var M; _class_call_check(this, Bar1); }; S1.Bar = Bar1; + // Emit Foo + // Foo, ; })(S1 = M.S || (M.S = {})); })(M || (M = {})); (function(M) { diff --git a/crates/swc/tests/tsc-references/tsxPreserveEmit1.1.normal.js b/crates/swc/tests/tsc-references/tsxPreserveEmit1.1.normal.js index d60e0ca50241c..40c5075a183d7 100644 --- a/crates/swc/tests/tsc-references/tsxPreserveEmit1.1.normal.js +++ b/crates/swc/tests/tsc-references/tsxPreserveEmit1.1.normal.js @@ -27,7 +27,15 @@ define([ var M; (function(M) { var X1; - M.X = X1; + Object.defineProperty(M, "X", { + enumerable: true, + get: function get() { + return X1; + }, + set: function set(v) { + X1 = v; + } + }); })(M || (M = {})); (function(M) { // Should emit 'M.X' in both opening and closing tags diff --git a/crates/swc/tests/tsc-references/tsxPreserveEmit1.2.minified.js b/crates/swc/tests/tsc-references/tsxPreserveEmit1.2.minified.js index 9de18b70b2476..9ffe6c184c143 100644 --- a/crates/swc/tests/tsc-references/tsxPreserveEmit1.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxPreserveEmit1.2.minified.js @@ -17,5 +17,13 @@ define([ var M, X1; Object.defineProperty(exports, "__esModule", { value: !0 - }), _reactrouter.Route, (M || (M = {})).X = X1, M || (M = {}), X; + }), _reactrouter.Route, Object.defineProperty(M || (M = {}), "X", { + enumerable: !0, + get: function() { + return X1; + }, + set: function(v) { + X1 = v; + } + }), M || (M = {}), X; }); diff --git a/crates/swc/tests/tsc-references/tsxReactEmit6.1.normal.js b/crates/swc/tests/tsc-references/tsxReactEmit6.1.normal.js index 2927797e83cc6..f0febabcd2b3d 100644 --- a/crates/swc/tests/tsc-references/tsxReactEmit6.1.normal.js +++ b/crates/swc/tests/tsc-references/tsxReactEmit6.1.normal.js @@ -12,7 +12,15 @@ var _object_spread_props = require("@swc/helpers/_/_object_spread_props"); var M; (function(M) { var React1; - M.React = React1; + Object.defineProperty(M, "React", { + enumerable: true, + get: function get() { + return React1; + }, + set: function set(v) { + React1 = v; + } + }); })(M || (M = {})); (function(M) { // Should emit M.React.createElement diff --git a/crates/swc/tests/tsc-references/tsxReactEmit6.2.minified.js b/crates/swc/tests/tsc-references/tsxReactEmit6.2.minified.js index a4c4ec2d3f781..109ee3290f2dd 100644 --- a/crates/swc/tests/tsc-references/tsxReactEmit6.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxReactEmit6.2.minified.js @@ -5,7 +5,15 @@ Object.defineProperty(exports, "__esModule", { value: !0 }); var React1, foo, M, _object_spread = require("@swc/helpers/_/_object_spread"), _object_spread_props = require("@swc/helpers/_/_object_spread_props"); -(M || (M = {})).React = React1, M || (M = {}), _object_spread_props._(_object_spread._({ +Object.defineProperty(M || (M = {}), "React", { + enumerable: !0, + get: function() { + return React1; + }, + set: function(v) { + React1 = v; + } +}), M || (M = {}), _object_spread_props._(_object_spread._({ x: "" }, foo), { y: "" diff --git a/crates/swc/tests/tsc-references/typeAliases.1.normal.js b/crates/swc/tests/tsc-references/typeAliases.1.normal.js index 096b07f785b3e..0b9f75482788e 100644 --- a/crates/swc/tests/tsc-references/typeAliases.1.normal.js +++ b/crates/swc/tests/tsc-references/typeAliases.1.normal.js @@ -36,7 +36,7 @@ var E; (function(E) { E[E["x"] = 10] = "x"; })(E || (E = {})); -f15(E.x).toLowerCase(); +f15(10).toLowerCase(); var x; f16(x); var y = [ diff --git a/crates/swc/tests/tsc-references/typeAliases.2.minified.js b/crates/swc/tests/tsc-references/typeAliases.2.minified.js index b07f65407f7ed..f49357379ab4b 100644 --- a/crates/swc/tests/tsc-references/typeAliases.2.minified.js +++ b/crates/swc/tests/tsc-references/typeAliases.2.minified.js @@ -2,7 +2,7 @@ // Writing a reference to a type alias has exactly the same effect as writing the aliased type itself. var E, x13_1, x13_2, E1, x; import "@swc/helpers/_/_class_call_check"; -foo13(x13_1, x13_2), foo13(x13_2, x13_1), (E = E1 || (E1 = {}))[E.x = 10] = "x", f15(E1.x).toLowerCase(), f16(x), [ +foo13(x13_1, x13_2), foo13(x13_2, x13_1), (E = E1 || (E1 = {}))[E.x = 10] = "x", f15(10).toLowerCase(), f16(x), [ "1", !1 ][0].toLowerCase(); diff --git a/crates/swc/tests/tsc-references/typeArgumentInferenceWithObjectLiteral.1.normal.js b/crates/swc/tests/tsc-references/typeArgumentInferenceWithObjectLiteral.1.normal.js index 3a1a92fb3faf5..8aa1b0b1ece6a 100644 --- a/crates/swc/tests/tsc-references/typeArgumentInferenceWithObjectLiteral.1.normal.js +++ b/crates/swc/tests/tsc-references/typeArgumentInferenceWithObjectLiteral.1.normal.js @@ -42,13 +42,13 @@ var v1 = f1({ r: function() { return 0; } -}, E1.X); +}, 0); var v1 = f1({ w: function(x) { return x; }, r: function() { - return E1.X; + return 0; } }, 0); var v2; @@ -57,14 +57,14 @@ var v2 = f1({ return x; }, r: function() { - return E1.X; + return 0; } -}, E1.X); +}, 0); var v3 = f1({ w: function(x) { return x; }, r: function() { - return E1.X; + return 0; } -}, E2.X); // Error +}, 0); // Error diff --git a/crates/swc/tests/tsc-references/typeArgumentInferenceWithObjectLiteral.2.minified.js b/crates/swc/tests/tsc-references/typeArgumentInferenceWithObjectLiteral.2.minified.js index d5a768de15852..f061c786c7806 100644 --- a/crates/swc/tests/tsc-references/typeArgumentInferenceWithObjectLiteral.2.minified.js +++ b/crates/swc/tests/tsc-references/typeArgumentInferenceWithObjectLiteral.2.minified.js @@ -14,26 +14,26 @@ var E1, E2, E11, E21; r: function() { return 0; } -}, E1.X), f1({ +}, 0), f1({ w: function(x) { return x; }, r: function() { - return E1.X; + return 0; } }, 0), f1({ w: function(x) { return x; }, r: function() { - return E1.X; + return 0; } -}, E1.X), f1({ +}, 0), f1({ w: function(x) { return x; }, r: function() { - return E1.X; + return 0; } -}, E2.X); +}, 0); // Error diff --git a/crates/swc/tests/tsc-references/typeArgumentsWithStringLiteralTypes01.1.normal.js b/crates/swc/tests/tsc-references/typeArgumentsWithStringLiteralTypes01.1.normal.js index d19286e137d32..98a8db31ed3ee 100644 --- a/crates/swc/tests/tsc-references/typeArgumentsWithStringLiteralTypes01.1.normal.js +++ b/crates/swc/tests/tsc-references/typeArgumentsWithStringLiteralTypes01.1.normal.js @@ -13,11 +13,56 @@ function fun3() { } var n1; (function(n1) { - var a = n1.a = fun1("Hello", "World"); - var b = n1.b = fun1("Hello", "Hello"); - var c = n1.c = fun2("Hello", "World"); - var d = n1.d = fun2("Hello", "Hello"); - var e = n1.e = fun3("Hello", "Hello", "World", "Foo"); + var a = fun1("Hello", "World"); + Object.defineProperty(n1, "a", { + enumerable: true, + get: function get() { + return a; + }, + set: function set(v) { + a = v; + } + }); + var b = fun1("Hello", "Hello"); + Object.defineProperty(n1, "b", { + enumerable: true, + get: function get() { + return b; + }, + set: function set(v) { + b = v; + } + }); + var c = fun2("Hello", "World"); + Object.defineProperty(n1, "c", { + enumerable: true, + get: function get() { + return c; + }, + set: function set(v) { + c = v; + } + }); + var d = fun2("Hello", "Hello"); + Object.defineProperty(n1, "d", { + enumerable: true, + get: function get() { + return d; + }, + set: function set(v) { + d = v; + } + }); + var e = fun3("Hello", "Hello", "World", "Foo"); + Object.defineProperty(n1, "e", { + enumerable: true, + get: function get() { + return e; + }, + set: function set(v) { + e = v; + } + }); // Should be valid a = takeReturnString(a); b = takeReturnString(b); @@ -39,11 +84,56 @@ var n1; })(n1 || (n1 = {})); var n2; (function(n2) { - var a = n2.a = fun1("Hello", "Hello"); - var b = n2.b = fun1("Hello", "World"); - var c = n2.c = fun2("Hello", "Hello"); - var d = n2.d = fun2("Hello", "World"); - var e = n2.e = fun3("Hello", "World"); + var a = fun1("Hello", "Hello"); + Object.defineProperty(n2, "a", { + enumerable: true, + get: function get() { + return a; + }, + set: function set(v) { + a = v; + } + }); + var b = fun1("Hello", "World"); + Object.defineProperty(n2, "b", { + enumerable: true, + get: function get() { + return b; + }, + set: function set(v) { + b = v; + } + }); + var c = fun2("Hello", "Hello"); + Object.defineProperty(n2, "c", { + enumerable: true, + get: function get() { + return c; + }, + set: function set(v) { + c = v; + } + }); + var d = fun2("Hello", "World"); + Object.defineProperty(n2, "d", { + enumerable: true, + get: function get() { + return d; + }, + set: function set(v) { + d = v; + } + }); + var e = fun3("Hello", "World"); + Object.defineProperty(n2, "e", { + enumerable: true, + get: function get() { + return e; + }, + set: function set(v) { + e = v; + } + }); // Assignment from the returned value should cause an error. a = takeReturnString(a); b = takeReturnString(b); @@ -65,11 +155,56 @@ var n2; })(n2 || (n2 = {})); var n3; (function(n3) { - var a = n3.a = fun2("Hello", "World"); - var b = n3.b = fun2("World", "Hello"); - var c = n3.c = fun2("Hello", "Hello"); - var d = n3.d = fun2("World", "World"); - var e = n3.e = fun3("Hello", "World"); + var a = fun2("Hello", "World"); + Object.defineProperty(n3, "a", { + enumerable: true, + get: function get() { + return a; + }, + set: function set(v) { + a = v; + } + }); + var b = fun2("World", "Hello"); + Object.defineProperty(n3, "b", { + enumerable: true, + get: function get() { + return b; + }, + set: function set(v) { + b = v; + } + }); + var c = fun2("Hello", "Hello"); + Object.defineProperty(n3, "c", { + enumerable: true, + get: function get() { + return c; + }, + set: function set(v) { + c = v; + } + }); + var d = fun2("World", "World"); + Object.defineProperty(n3, "d", { + enumerable: true, + get: function get() { + return d; + }, + set: function set(v) { + d = v; + } + }); + var e = fun3("Hello", "World"); + Object.defineProperty(n3, "e", { + enumerable: true, + get: function get() { + return e; + }, + set: function set(v) { + e = v; + } + }); // Assignment from the returned value should cause an error. a = takeReturnString(a); b = takeReturnString(b); diff --git a/crates/swc/tests/tsc-references/typeArgumentsWithStringLiteralTypes01.2.minified.js b/crates/swc/tests/tsc-references/typeArgumentsWithStringLiteralTypes01.2.minified.js index d8f0104156b9f..bbcd5ff9a7b39 100644 --- a/crates/swc/tests/tsc-references/typeArgumentsWithStringLiteralTypes01.2.minified.js +++ b/crates/swc/tests/tsc-references/typeArgumentsWithStringLiteralTypes01.2.minified.js @@ -10,13 +10,133 @@ function fun3() { for(var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++)args[_key] = arguments[_key]; return args[+randBool()]; } -a = (n11 = n1 || (n1 = {})).a = fun1("Hello", "World"), b = n11.b = fun1("Hello", "Hello"), c = n11.c = fun2("Hello", "World"), d = n11.d = fun2("Hello", "Hello"), e = n11.e = fun3("Hello", "Hello", "World", "Foo"), // Should be valid +n11 = n1 || (n1 = {}), a = fun1("Hello", "World"), Object.defineProperty(n11, "a", { + enumerable: !0, + get: function() { + return a; + }, + set: function(v) { + a = v; + } +}), b = fun1("Hello", "Hello"), Object.defineProperty(n11, "b", { + enumerable: !0, + get: function() { + return b; + }, + set: function(v) { + b = v; + } +}), c = fun2("Hello", "World"), Object.defineProperty(n11, "c", { + enumerable: !0, + get: function() { + return c; + }, + set: function(v) { + c = v; + } +}), d = fun2("Hello", "Hello"), Object.defineProperty(n11, "d", { + enumerable: !0, + get: function() { + return d; + }, + set: function(v) { + d = v; + } +}), e = fun3("Hello", "Hello", "World", "Foo"), Object.defineProperty(n11, "e", { + enumerable: !0, + get: function() { + return e; + }, + set: function(v) { + e = v; + } +}), // Should be valid a = takeReturnString(a), b = takeReturnString(b), c = takeReturnString(c), d = takeReturnString(d), e = takeReturnString(e), // Passing these as arguments should cause an error. a = takeReturnHello(a), b = takeReturnHello(b), c = takeReturnHello(c), d = takeReturnHello(d), e = takeReturnHello(e), // Passing these as arguments should cause an error. -a = takeReturnHelloWorld(a), b = takeReturnHelloWorld(b), c = takeReturnHelloWorld(c), d = takeReturnHelloWorld(d), takeReturnHelloWorld(e), a1 = (n21 = n2 || (n2 = {})).a = fun1("Hello", "Hello"), b1 = n21.b = fun1("Hello", "World"), c1 = n21.c = fun2("Hello", "Hello"), d1 = n21.d = fun2("Hello", "World"), e1 = n21.e = fun3("Hello", "World"), // Assignment from the returned value should cause an error. +a = takeReturnHelloWorld(a), b = takeReturnHelloWorld(b), c = takeReturnHelloWorld(c), d = takeReturnHelloWorld(d), e = takeReturnHelloWorld(e), n21 = n2 || (n2 = {}), a1 = fun1("Hello", "Hello"), Object.defineProperty(n21, "a", { + enumerable: !0, + get: function() { + return a1; + }, + set: function(v) { + a1 = v; + } +}), b1 = fun1("Hello", "World"), Object.defineProperty(n21, "b", { + enumerable: !0, + get: function() { + return b1; + }, + set: function(v) { + b1 = v; + } +}), c1 = fun2("Hello", "Hello"), Object.defineProperty(n21, "c", { + enumerable: !0, + get: function() { + return c1; + }, + set: function(v) { + c1 = v; + } +}), d1 = fun2("Hello", "World"), Object.defineProperty(n21, "d", { + enumerable: !0, + get: function() { + return d1; + }, + set: function(v) { + d1 = v; + } +}), e1 = fun3("Hello", "World"), Object.defineProperty(n21, "e", { + enumerable: !0, + get: function() { + return e1; + }, + set: function(v) { + e1 = v; + } +}), // Assignment from the returned value should cause an error. a1 = takeReturnString(a1), b1 = takeReturnString(b1), c1 = takeReturnString(c1), d1 = takeReturnString(d1), e1 = takeReturnString(e1), // Should be valid a1 = takeReturnHello(a1), b1 = takeReturnHello(b1), c1 = takeReturnHello(c1), d1 = takeReturnHello(d1), e1 = takeReturnHello(e1), // Assignment from the returned value should cause an error. -a1 = takeReturnHelloWorld(a1), b1 = takeReturnHelloWorld(b1), c1 = takeReturnHelloWorld(c1), d1 = takeReturnHelloWorld(d1), takeReturnHelloWorld(e1), a2 = (n31 = n3 || (n3 = {})).a = fun2("Hello", "World"), b2 = n31.b = fun2("World", "Hello"), c2 = n31.c = fun2("Hello", "Hello"), d2 = n31.d = fun2("World", "World"), e2 = n31.e = fun3("Hello", "World"), // Assignment from the returned value should cause an error. +a1 = takeReturnHelloWorld(a1), b1 = takeReturnHelloWorld(b1), c1 = takeReturnHelloWorld(c1), d1 = takeReturnHelloWorld(d1), e1 = takeReturnHelloWorld(e1), n31 = n3 || (n3 = {}), a2 = fun2("Hello", "World"), Object.defineProperty(n31, "a", { + enumerable: !0, + get: function() { + return a2; + }, + set: function(v) { + a2 = v; + } +}), b2 = fun2("World", "Hello"), Object.defineProperty(n31, "b", { + enumerable: !0, + get: function() { + return b2; + }, + set: function(v) { + b2 = v; + } +}), c2 = fun2("Hello", "Hello"), Object.defineProperty(n31, "c", { + enumerable: !0, + get: function() { + return c2; + }, + set: function(v) { + c2 = v; + } +}), d2 = fun2("World", "World"), Object.defineProperty(n31, "d", { + enumerable: !0, + get: function() { + return d2; + }, + set: function(v) { + d2 = v; + } +}), e2 = fun3("Hello", "World"), Object.defineProperty(n31, "e", { + enumerable: !0, + get: function() { + return e2; + }, + set: function(v) { + e2 = v; + } +}), // Assignment from the returned value should cause an error. a2 = takeReturnString(a2), b2 = takeReturnString(b2), c2 = takeReturnString(c2), d2 = takeReturnString(d2), e2 = takeReturnString(e2), // Passing these as arguments should cause an error. a2 = takeReturnHello(a2), b2 = takeReturnHello(b2), c2 = takeReturnHello(c2), d2 = takeReturnHello(d2), e2 = takeReturnHello(e2), // Both should be valid. -a2 = takeReturnHelloWorld(a2), b2 = takeReturnHelloWorld(b2), c2 = takeReturnHelloWorld(c2), d2 = takeReturnHelloWorld(d2), takeReturnHelloWorld(e2); +a2 = takeReturnHelloWorld(a2), b2 = takeReturnHelloWorld(b2), c2 = takeReturnHelloWorld(c2), d2 = takeReturnHelloWorld(d2), e2 = takeReturnHelloWorld(e2); diff --git a/crates/swc/tests/tsc-references/typeFromPropertyAssignment29.1.normal.js b/crates/swc/tests/tsc-references/typeFromPropertyAssignment29.1.normal.js index 9c43f8f8f15fa..51abf7d170561 100644 --- a/crates/swc/tests/tsc-references/typeFromPropertyAssignment29.1.normal.js +++ b/crates/swc/tests/tsc-references/typeFromPropertyAssignment29.1.normal.js @@ -41,10 +41,28 @@ function ExpandoMerge(n) { } ExpandoMerge.p1 = 111; (function(ExpandoMerge) { - var p2 = ExpandoMerge.p2 = 222; + var p2 = 222; + Object.defineProperty(ExpandoMerge, "p2", { + enumerable: true, + get: function get() { + return p2; + }, + set: function set(v) { + p2 = v; + } + }); })(ExpandoMerge || (ExpandoMerge = {})); (function(ExpandoMerge) { - var p3 = ExpandoMerge.p3 = 333; + var p3 = 333; + Object.defineProperty(ExpandoMerge, "p3", { + enumerable: true, + get: function get() { + return p3; + }, + set: function set(v) { + p3 = v; + } + }); })(ExpandoMerge || (ExpandoMerge = {})); var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge(1); var Ns; diff --git a/crates/swc/tests/tsc-references/typeFromPropertyAssignment29.2.minified.js b/crates/swc/tests/tsc-references/typeFromPropertyAssignment29.2.minified.js index 4ab9a8e3779ef..5b2296d3969a1 100644 --- a/crates/swc/tests/tsc-references/typeFromPropertyAssignment29.2.minified.js +++ b/crates/swc/tests/tsc-references/typeFromPropertyAssignment29.2.minified.js @@ -6,7 +6,7 @@ function ExpandoDecl(n) { ExpandoDecl.prop = 2, ExpandoDecl.m = function(n) { return n + 1; }, ExpandoDecl.prop, ExpandoDecl.m(12), ExpandoDecl(101).length; -var Ns, ExpandoNamespace, Ns1, ExpandoExpr = function(n) { +var ExpandoMerge, p2, ExpandoMerge1, p3, Ns, ExpandoNamespace, Ns1, ExpandoExpr = function(n) { return n.toString(); }; ExpandoExpr.prop = { @@ -19,12 +19,28 @@ ExpandoExpr.prop = { var ExpandoArrow = function(n) { return n.toString(); }; -function ExpandoMerge(n) { +function ExpandoMerge2(n) { return 100 * n; } ExpandoArrow.prop = 2, ExpandoArrow.m = function(n) { return n + 1; -}, ExpandoMerge.p1 = 111, (ExpandoMerge || (ExpandoMerge = {})).p2 = 222, (ExpandoMerge || (ExpandoMerge = {})).p3 = 333, ExpandoMerge.p1, ExpandoMerge.p2, ExpandoMerge.p3, ExpandoMerge(1), Ns = Ns1 || (Ns1 = {}), (ExpandoNamespace = function() {}).p6 = 42, Ns.foo = function() { +}, ExpandoMerge2.p1 = 111, ExpandoMerge = ExpandoMerge2 || (ExpandoMerge2 = {}), p2 = 222, Object.defineProperty(ExpandoMerge, "p2", { + enumerable: !0, + get: function() { + return p2; + }, + set: function(v) { + p2 = v; + } +}), ExpandoMerge1 = ExpandoMerge2 || (ExpandoMerge2 = {}), p3 = 333, Object.defineProperty(ExpandoMerge1, "p3", { + enumerable: !0, + get: function() { + return p3; + }, + set: function(v) { + p3 = v; + } +}), ExpandoMerge2.p1, ExpandoMerge2.p2, ExpandoMerge2.p3, ExpandoMerge2(1), Ns = Ns1 || (Ns1 = {}), (ExpandoNamespace = function() {}).p6 = 42, Ns.foo = function() { return ExpandoNamespace; }; // Should not work in Typescript -- must be const diff --git a/crates/swc/tests/tsc-references/typeFromPropertyAssignment31.1.normal.js b/crates/swc/tests/tsc-references/typeFromPropertyAssignment31.1.normal.js index 13c9d1e64ad42..9fc6964c44243 100644 --- a/crates/swc/tests/tsc-references/typeFromPropertyAssignment31.1.normal.js +++ b/crates/swc/tests/tsc-references/typeFromPropertyAssignment31.1.normal.js @@ -7,19 +7,91 @@ ExpandoMerge.m = function(n) { return n + 1; }; (function(ExpandoMerge) { - var p2 = ExpandoMerge.p2 = 222; + var p2 = 222; + Object.defineProperty(ExpandoMerge, "p2", { + enumerable: true, + get: function get() { + return p2; + }, + set: function set(v) { + p2 = v; + } + }); })(ExpandoMerge || (ExpandoMerge = {})); ExpandoMerge.p4 = 44444; // ok ExpandoMerge.p6 = 66666; // ok ExpandoMerge.p8 = false; // type error (function(ExpandoMerge) { - var p3 = ExpandoMerge.p3 = 333; - var p4 = ExpandoMerge.p4 = 4; - var p5 = ExpandoMerge.p5 = 5; - var p6 = ExpandoMerge.p6 = 6; - var p7 = ExpandoMerge.p7 = 7; - var p8 = ExpandoMerge.p8 = 6; - var p9 = ExpandoMerge.p9 = 7; + var p3 = 333; + Object.defineProperty(ExpandoMerge, "p3", { + enumerable: true, + get: function get() { + return p3; + }, + set: function set(v) { + p3 = v; + } + }); + var p4 = 4; + Object.defineProperty(ExpandoMerge, "p4", { + enumerable: true, + get: function get() { + return p4; + }, + set: function set(v) { + p4 = v; + } + }); + var p5 = 5; + Object.defineProperty(ExpandoMerge, "p5", { + enumerable: true, + get: function get() { + return p5; + }, + set: function set(v) { + p5 = v; + } + }); + var p6 = 6; + Object.defineProperty(ExpandoMerge, "p6", { + enumerable: true, + get: function get() { + return p6; + }, + set: function set(v) { + p6 = v; + } + }); + var p7 = 7; + Object.defineProperty(ExpandoMerge, "p7", { + enumerable: true, + get: function get() { + return p7; + }, + set: function set(v) { + p7 = v; + } + }); + var p8 = 6; + Object.defineProperty(ExpandoMerge, "p8", { + enumerable: true, + get: function get() { + return p8; + }, + set: function set(v) { + p8 = v; + } + }); + var p9 = 7; + Object.defineProperty(ExpandoMerge, "p9", { + enumerable: true, + get: function get() { + return p9; + }, + set: function set(v) { + p9 = v; + } + }); })(ExpandoMerge || (ExpandoMerge = {})); ExpandoMerge.p5 = 555555; // ok ExpandoMerge.p7 = 777777; // ok diff --git a/crates/swc/tests/tsc-references/typeFromPropertyAssignment31.2.minified.js b/crates/swc/tests/tsc-references/typeFromPropertyAssignment31.2.minified.js index 7fde49ff705e8..a7aa4bfd4bdeb 100644 --- a/crates/swc/tests/tsc-references/typeFromPropertyAssignment31.2.minified.js +++ b/crates/swc/tests/tsc-references/typeFromPropertyAssignment31.2.minified.js @@ -1,8 +1,72 @@ //// [typeFromPropertyAssignment31.ts] -var ExpandoMerge; -function ExpandoMerge1(n) { +var ExpandoMerge, p2, ExpandoMerge1, p3, p4, p5, p6, p7, p8, p9; +function ExpandoMerge2(n) { return n; } -ExpandoMerge1.p1 = 111, ExpandoMerge1.m = function(n) { +ExpandoMerge2.p1 = 111, ExpandoMerge2.m = function(n) { return n + 1; -}, (ExpandoMerge1 || (ExpandoMerge1 = {})).p2 = 222, ExpandoMerge1.p4 = 44444, ExpandoMerge1.p6 = 66666, ExpandoMerge1.p8 = !1, (ExpandoMerge = ExpandoMerge1 || (ExpandoMerge1 = {})).p3 = 333, ExpandoMerge.p4 = 4, ExpandoMerge.p5 = 5, ExpandoMerge.p6 = 6, ExpandoMerge.p7 = 7, ExpandoMerge.p8 = 6, ExpandoMerge.p9 = 7, ExpandoMerge1.p5 = 555555, ExpandoMerge1.p7 = 777777, ExpandoMerge1.p9 = !1, ExpandoMerge1.p1, ExpandoMerge1.p2, ExpandoMerge1.p3, ExpandoMerge1.p4, ExpandoMerge1.p5, ExpandoMerge1.p6, ExpandoMerge1.p7, ExpandoMerge1.p8, ExpandoMerge1.p9, ExpandoMerge1.m(12), ExpandoMerge1(1001); +}, ExpandoMerge = ExpandoMerge2 || (ExpandoMerge2 = {}), p2 = 222, Object.defineProperty(ExpandoMerge, "p2", { + enumerable: !0, + get: function() { + return p2; + }, + set: function(v) { + p2 = v; + } +}), ExpandoMerge2.p4 = 44444, ExpandoMerge2.p6 = 66666, ExpandoMerge2.p8 = !1, ExpandoMerge1 = ExpandoMerge2 || (ExpandoMerge2 = {}), p3 = 333, Object.defineProperty(ExpandoMerge1, "p3", { + enumerable: !0, + get: function() { + return p3; + }, + set: function(v) { + p3 = v; + } +}), p4 = 4, Object.defineProperty(ExpandoMerge1, "p4", { + enumerable: !0, + get: function() { + return p4; + }, + set: function(v) { + p4 = v; + } +}), p5 = 5, Object.defineProperty(ExpandoMerge1, "p5", { + enumerable: !0, + get: function() { + return p5; + }, + set: function(v) { + p5 = v; + } +}), p6 = 6, Object.defineProperty(ExpandoMerge1, "p6", { + enumerable: !0, + get: function() { + return p6; + }, + set: function(v) { + p6 = v; + } +}), p7 = 7, Object.defineProperty(ExpandoMerge1, "p7", { + enumerable: !0, + get: function() { + return p7; + }, + set: function(v) { + p7 = v; + } +}), p8 = 6, Object.defineProperty(ExpandoMerge1, "p8", { + enumerable: !0, + get: function() { + return p8; + }, + set: function(v) { + p8 = v; + } +}), p9 = 7, Object.defineProperty(ExpandoMerge1, "p9", { + enumerable: !0, + get: function() { + return p9; + }, + set: function(v) { + p9 = v; + } +}), ExpandoMerge2.p5 = 555555, ExpandoMerge2.p7 = 777777, ExpandoMerge2.p9 = !1, ExpandoMerge2.p1, ExpandoMerge2.p2, ExpandoMerge2.p3, ExpandoMerge2.p4, ExpandoMerge2.p5, ExpandoMerge2.p6, ExpandoMerge2.p7, ExpandoMerge2.p8, ExpandoMerge2.p9, ExpandoMerge2.m(12), ExpandoMerge2(1001); diff --git a/crates/swc/tests/tsc-references/typeFromPropertyAssignment32.1.normal.js b/crates/swc/tests/tsc-references/typeFromPropertyAssignment32.1.normal.js index d5bc5e7c66e94..18be74e92f4e9 100644 --- a/crates/swc/tests/tsc-references/typeFromPropertyAssignment32.1.normal.js +++ b/crates/swc/tests/tsc-references/typeFromPropertyAssignment32.1.normal.js @@ -16,14 +16,86 @@ var n = ExpandoMerge.p1 + ExpandoMerge.p2 + ExpandoMerge.p3 + ExpandoMerge.p4 + //// [ns.ts] var ExpandoMerge; (function(ExpandoMerge) { - var p3 = ExpandoMerge.p3 = 333; - var p4 = ExpandoMerge.p4 = 4; - var p5 = ExpandoMerge.p5 = 5; - var p6 = ExpandoMerge.p6 = 6; - var p7 = ExpandoMerge.p7 = 7; - var p8 = ExpandoMerge.p8 = 6; - var p9 = ExpandoMerge.p9 = 7; + var p3 = 333; + Object.defineProperty(ExpandoMerge, "p3", { + enumerable: true, + get: function get() { + return p3; + }, + set: function set(v) { + p3 = v; + } + }); + var p4 = 4; + Object.defineProperty(ExpandoMerge, "p4", { + enumerable: true, + get: function get() { + return p4; + }, + set: function set(v) { + p4 = v; + } + }); + var p5 = 5; + Object.defineProperty(ExpandoMerge, "p5", { + enumerable: true, + get: function get() { + return p5; + }, + set: function set(v) { + p5 = v; + } + }); + var p6 = 6; + Object.defineProperty(ExpandoMerge, "p6", { + enumerable: true, + get: function get() { + return p6; + }, + set: function set(v) { + p6 = v; + } + }); + var p7 = 7; + Object.defineProperty(ExpandoMerge, "p7", { + enumerable: true, + get: function get() { + return p7; + }, + set: function set(v) { + p7 = v; + } + }); + var p8 = 6; + Object.defineProperty(ExpandoMerge, "p8", { + enumerable: true, + get: function get() { + return p8; + }, + set: function set(v) { + p8 = v; + } + }); + var p9 = 7; + Object.defineProperty(ExpandoMerge, "p9", { + enumerable: true, + get: function get() { + return p9; + }, + set: function set(v) { + p9 = v; + } + }); })(ExpandoMerge || (ExpandoMerge = {})); (function(ExpandoMerge) { - var p2 = ExpandoMerge.p2 = 222; + var p2 = 222; + Object.defineProperty(ExpandoMerge, "p2", { + enumerable: true, + get: function get() { + return p2; + }, + set: function set(v) { + p2 = v; + } + }); })(ExpandoMerge || (ExpandoMerge = {})); diff --git a/crates/swc/tests/tsc-references/typeFromPropertyAssignment32.2.minified.js b/crates/swc/tests/tsc-references/typeFromPropertyAssignment32.2.minified.js index d39c4c582628b..4bb716138b8d4 100644 --- a/crates/swc/tests/tsc-references/typeFromPropertyAssignment32.2.minified.js +++ b/crates/swc/tests/tsc-references/typeFromPropertyAssignment32.2.minified.js @@ -6,5 +6,69 @@ ExpandoMerge.p1 = 111, ExpandoMerge.m = function(n) { return n + 1; }, ExpandoMerge.p4 = 44444, ExpandoMerge.p5 = 555555, ExpandoMerge.p6 = 66666, ExpandoMerge.p7 = 777777, ExpandoMerge.p8 = !1, ExpandoMerge.p9 = !1, ExpandoMerge.p1, ExpandoMerge.p2, ExpandoMerge.p3, ExpandoMerge.p4, ExpandoMerge.p5, ExpandoMerge.p6, ExpandoMerge.p7, ExpandoMerge.p8, ExpandoMerge.p9, ExpandoMerge.m(12); //// [ns.ts] -var ExpandoMerge, ExpandoMerge1; -(ExpandoMerge1 = ExpandoMerge || (ExpandoMerge = {})).p3 = 333, ExpandoMerge1.p4 = 4, ExpandoMerge1.p5 = 5, ExpandoMerge1.p6 = 6, ExpandoMerge1.p7 = 7, ExpandoMerge1.p8 = 6, ExpandoMerge1.p9 = 7, (ExpandoMerge || (ExpandoMerge = {})).p2 = 222; +var ExpandoMerge, ExpandoMerge1, p3, p4, p5, p6, p7, p8, p9, ExpandoMerge2, p2; +ExpandoMerge1 = ExpandoMerge || (ExpandoMerge = {}), p3 = 333, Object.defineProperty(ExpandoMerge1, "p3", { + enumerable: !0, + get: function() { + return p3; + }, + set: function(v) { + p3 = v; + } +}), p4 = 4, Object.defineProperty(ExpandoMerge1, "p4", { + enumerable: !0, + get: function() { + return p4; + }, + set: function(v) { + p4 = v; + } +}), p5 = 5, Object.defineProperty(ExpandoMerge1, "p5", { + enumerable: !0, + get: function() { + return p5; + }, + set: function(v) { + p5 = v; + } +}), p6 = 6, Object.defineProperty(ExpandoMerge1, "p6", { + enumerable: !0, + get: function() { + return p6; + }, + set: function(v) { + p6 = v; + } +}), p7 = 7, Object.defineProperty(ExpandoMerge1, "p7", { + enumerable: !0, + get: function() { + return p7; + }, + set: function(v) { + p7 = v; + } +}), p8 = 6, Object.defineProperty(ExpandoMerge1, "p8", { + enumerable: !0, + get: function() { + return p8; + }, + set: function(v) { + p8 = v; + } +}), p9 = 7, Object.defineProperty(ExpandoMerge1, "p9", { + enumerable: !0, + get: function() { + return p9; + }, + set: function(v) { + p9 = v; + } +}), ExpandoMerge2 = ExpandoMerge || (ExpandoMerge = {}), p2 = 222, Object.defineProperty(ExpandoMerge2, "p2", { + enumerable: !0, + get: function() { + return p2; + }, + set: function(v) { + p2 = v; + } +}); diff --git a/crates/swc/tests/tsc-references/typeFromPropertyAssignment33.1.normal.js b/crates/swc/tests/tsc-references/typeFromPropertyAssignment33.1.normal.js index 0b9d185d995ff..1cdd92a309028 100644 --- a/crates/swc/tests/tsc-references/typeFromPropertyAssignment33.1.normal.js +++ b/crates/swc/tests/tsc-references/typeFromPropertyAssignment33.1.normal.js @@ -1,16 +1,88 @@ //// [ns.ts] var ExpandoMerge; (function(ExpandoMerge) { - var p3 = ExpandoMerge.p3 = 333; - var p4 = ExpandoMerge.p4 = 4; - var p5 = ExpandoMerge.p5 = 5; - var p6 = ExpandoMerge.p6 = 6; - var p7 = ExpandoMerge.p7 = 7; - var p8 = ExpandoMerge.p8 = 6; - var p9 = ExpandoMerge.p9 = 7; + var p3 = 333; + Object.defineProperty(ExpandoMerge, "p3", { + enumerable: true, + get: function get() { + return p3; + }, + set: function set(v) { + p3 = v; + } + }); + var p4 = 4; + Object.defineProperty(ExpandoMerge, "p4", { + enumerable: true, + get: function get() { + return p4; + }, + set: function set(v) { + p4 = v; + } + }); + var p5 = 5; + Object.defineProperty(ExpandoMerge, "p5", { + enumerable: true, + get: function get() { + return p5; + }, + set: function set(v) { + p5 = v; + } + }); + var p6 = 6; + Object.defineProperty(ExpandoMerge, "p6", { + enumerable: true, + get: function get() { + return p6; + }, + set: function set(v) { + p6 = v; + } + }); + var p7 = 7; + Object.defineProperty(ExpandoMerge, "p7", { + enumerable: true, + get: function get() { + return p7; + }, + set: function set(v) { + p7 = v; + } + }); + var p8 = 6; + Object.defineProperty(ExpandoMerge, "p8", { + enumerable: true, + get: function get() { + return p8; + }, + set: function set(v) { + p8 = v; + } + }); + var p9 = 7; + Object.defineProperty(ExpandoMerge, "p9", { + enumerable: true, + get: function get() { + return p9; + }, + set: function set(v) { + p9 = v; + } + }); })(ExpandoMerge || (ExpandoMerge = {})); (function(ExpandoMerge) { - var p2 = ExpandoMerge.p2 = 222; + var p2 = 222; + Object.defineProperty(ExpandoMerge, "p2", { + enumerable: true, + get: function get() { + return p2; + }, + set: function set(v) { + p2 = v; + } + }); })(ExpandoMerge || (ExpandoMerge = {})); //// [expando.ts] function ExpandoMerge(n) { diff --git a/crates/swc/tests/tsc-references/typeFromPropertyAssignment33.2.minified.js b/crates/swc/tests/tsc-references/typeFromPropertyAssignment33.2.minified.js index fae5f37c0119f..f7d6361fa0e54 100644 --- a/crates/swc/tests/tsc-references/typeFromPropertyAssignment33.2.minified.js +++ b/crates/swc/tests/tsc-references/typeFromPropertyAssignment33.2.minified.js @@ -1,6 +1,70 @@ //// [ns.ts] -var ExpandoMerge, ExpandoMerge1; -(ExpandoMerge1 = ExpandoMerge || (ExpandoMerge = {})).p3 = 333, ExpandoMerge1.p4 = 4, ExpandoMerge1.p5 = 5, ExpandoMerge1.p6 = 6, ExpandoMerge1.p7 = 7, ExpandoMerge1.p8 = 6, ExpandoMerge1.p9 = 7, (ExpandoMerge || (ExpandoMerge = {})).p2 = 222; +var ExpandoMerge, ExpandoMerge1, p3, p4, p5, p6, p7, p8, p9, ExpandoMerge2, p2; +ExpandoMerge1 = ExpandoMerge || (ExpandoMerge = {}), p3 = 333, Object.defineProperty(ExpandoMerge1, "p3", { + enumerable: !0, + get: function() { + return p3; + }, + set: function(v) { + p3 = v; + } +}), p4 = 4, Object.defineProperty(ExpandoMerge1, "p4", { + enumerable: !0, + get: function() { + return p4; + }, + set: function(v) { + p4 = v; + } +}), p5 = 5, Object.defineProperty(ExpandoMerge1, "p5", { + enumerable: !0, + get: function() { + return p5; + }, + set: function(v) { + p5 = v; + } +}), p6 = 6, Object.defineProperty(ExpandoMerge1, "p6", { + enumerable: !0, + get: function() { + return p6; + }, + set: function(v) { + p6 = v; + } +}), p7 = 7, Object.defineProperty(ExpandoMerge1, "p7", { + enumerable: !0, + get: function() { + return p7; + }, + set: function(v) { + p7 = v; + } +}), p8 = 6, Object.defineProperty(ExpandoMerge1, "p8", { + enumerable: !0, + get: function() { + return p8; + }, + set: function(v) { + p8 = v; + } +}), p9 = 7, Object.defineProperty(ExpandoMerge1, "p9", { + enumerable: !0, + get: function() { + return p9; + }, + set: function(v) { + p9 = v; + } +}), ExpandoMerge2 = ExpandoMerge || (ExpandoMerge = {}), p2 = 222, Object.defineProperty(ExpandoMerge2, "p2", { + enumerable: !0, + get: function() { + return p2; + }, + set: function(v) { + p2 = v; + } +}); //// [expando.ts] function ExpandoMerge(n) { return n; diff --git a/crates/swc/tests/tsc-references/typeGuardNarrowsPrimitiveIntersection.1.normal.js b/crates/swc/tests/tsc-references/typeGuardNarrowsPrimitiveIntersection.1.normal.js index 2530fa2264545..1adde60fd32c7 100644 --- a/crates/swc/tests/tsc-references/typeGuardNarrowsPrimitiveIntersection.1.normal.js +++ b/crates/swc/tests/tsc-references/typeGuardNarrowsPrimitiveIntersection.1.normal.js @@ -6,7 +6,6 @@ if (isNonBlank(value)) { doThat(value); } var Tag2; -(function(Tag2) {})(Tag2 || (Tag2 = {})); if (isNonBlank2(value)) { doThis2(value); } else { diff --git a/crates/swc/tests/tsc-references/typeGuardNarrowsPrimitiveIntersection.2.minified.js b/crates/swc/tests/tsc-references/typeGuardNarrowsPrimitiveIntersection.2.minified.js index 028997851e049..826abd3c7a2de 100644 --- a/crates/swc/tests/tsc-references/typeGuardNarrowsPrimitiveIntersection.2.minified.js +++ b/crates/swc/tests/tsc-references/typeGuardNarrowsPrimitiveIntersection.2.minified.js @@ -1,3 +1,3 @@ //// [typeGuardNarrowsPrimitiveIntersection.ts] -var value, Tag2; -isNonBlank(value) ? doThis(value) : doThat(value), Tag2 || (Tag2 = {}), isNonBlank2(value) ? doThis2(value) : doThat2(value); +var value; +isNonBlank(value) ? doThis(value) : doThat(value), isNonBlank2(value) ? doThis2(value) : doThat2(value); diff --git a/crates/swc/tests/tsc-references/typeGuardsInFunctionAndModuleBlock.1.normal.js b/crates/swc/tests/tsc-references/typeGuardsInFunctionAndModuleBlock.1.normal.js index 6856527e5cf24..0a6fc4f140572 100644 --- a/crates/swc/tests/tsc-references/typeGuardsInFunctionAndModuleBlock.1.normal.js +++ b/crates/swc/tests/tsc-references/typeGuardsInFunctionAndModuleBlock.1.normal.js @@ -58,7 +58,6 @@ var m1; var x; var m2; (function(m2) { - var m3; (function(m3) { var b = x; // new scope - number | boolean | string var y; @@ -69,6 +68,6 @@ var m1; y = typeof x === "boolean" ? x.toString() // boolean : x.toString(); // number } - })(m3 = m2.m3 || (m2.m3 = {})); + })(m2.m3 || (m2.m3 = {})); })(m2 || (m2 = {})); })(m1 || (m1 = {})); diff --git a/crates/swc/tests/tsc-references/typeGuardsInModule.1.normal.js b/crates/swc/tests/tsc-references/typeGuardsInModule.1.normal.js index aee5d26a832fa..8673a1a1eca22 100644 --- a/crates/swc/tests/tsc-references/typeGuardsInModule.1.normal.js +++ b/crates/swc/tests/tsc-references/typeGuardsInModule.1.normal.js @@ -5,8 +5,8 @@ var num; var strOrNum; var var1; -// Inside module var m1; +// Inside module (function(m1) { // global vars in function declaration num = typeof var1 === "string" && var1.length; // string @@ -18,18 +18,35 @@ var m1; num = var2; // number } var var3; + Object.defineProperty(m1, "var3", { + enumerable: true, + get: function get() { + return var3; + }, + set: function set(v) { + var3 = v; + } + }); if (typeof var3 === "string") { strOrNum = var3; // string | number } else { strOrNum = var3; // string | number } - m1.var3 = var3; })(m1 || (m1 = {})); -// local module var m2; +// local module (function(m2) { var var2; var var3; + Object.defineProperty(m2, "var3", { + enumerable: true, + get: function get() { + return var3; + }, + set: function set(v) { + var3 = v; + } + }); var m3; (function(m3) { // global vars in function declaration @@ -46,19 +63,25 @@ var m2; num = var4; // number } var var5; + Object.defineProperty(m3, "var5", { + enumerable: true, + get: function get() { + return var5; + }, + set: function set(v) { + var5 = v; + } + }); if (typeof var5 === "string") { strOrNum = var5; // string | number } else { strOrNum = var5; // string | number } - m3.var5 = var5; })(m3 || (m3 = {})); - m2.var3 = var3; })(m2 || (m2 = {})); -// Dotted module var m3; +// Dotted module (function(m3) { - var m4; (function(m4) { // global vars in function declaration num = typeof var1 === "string" && var1.length; // string @@ -70,11 +93,19 @@ var m3; num = var2; // number } var var3; + Object.defineProperty(m4, "var3", { + enumerable: true, + get: function get() { + return var3; + }, + set: function set(v) { + var3 = v; + } + }); if (typeof var3 === "string") { strOrNum = var3; // string | number } else { strOrNum = var3; // string | number } - m4.var3 = var3; - })(m4 = m3.m4 || (m3.m4 = {})); + })(m3.m4 || (m3.m4 = {})); })(m3 || (m3 = {})); diff --git a/crates/swc/tests/tsc-references/typeGuardsInModule.2.minified.js b/crates/swc/tests/tsc-references/typeGuardsInModule.2.minified.js index 4d1ec3a185e63..419e4c7cbce9c 100644 --- a/crates/swc/tests/tsc-references/typeGuardsInModule.2.minified.js +++ b/crates/swc/tests/tsc-references/typeGuardsInModule.2.minified.js @@ -2,5 +2,37 @@ // Note that type guards affect types of variables and parameters only and // have no effect on members of objects such as properties. // variables in global -var var1, m1, m2, m3, m11, var2, var3, m21, var21, var31, m31, m32, var4, var5, m33, m4, var22, var32; -m11 = m1 || (m1 = {}), "string" == typeof var1 && var1.length, "string" == typeof var2 && var2.length, m11.var3 = var3, m21 = m2 || (m2 = {}), m32 = m31 || (m31 = {}), "string" == typeof var1 && var1.length, "string" == typeof var21 && var21.length, "string" == typeof var4 && var4.length, m32.var5 = var5, m21.var3 = var31, m4 = (m33 = m3 || (m3 = {})).m4 || (m33.m4 = {}), "string" == typeof var1 && var1.length, "string" == typeof var22 && var22.length, m4.var3 = var32; +var var1, m1, m2, m3, m11, var2, var3, var21, var31, m31, m32, var4, var5, m33, m4, var22, var32; +m11 = m1 || (m1 = {}), "string" == typeof var1 && var1.length, "string" == typeof var2 && var2.length, Object.defineProperty(m11, "var3", { + enumerable: !0, + get: function() { + return var3; + }, + set: function(v) { + var3 = v; + } +}), Object.defineProperty(m2 || (m2 = {}), "var3", { + enumerable: !0, + get: function() { + return var31; + }, + set: function(v) { + var31 = v; + } +}), m32 = m31 || (m31 = {}), "string" == typeof var1 && var1.length, "string" == typeof var21 && var21.length, "string" == typeof var4 && var4.length, Object.defineProperty(m32, "var5", { + enumerable: !0, + get: function() { + return var5; + }, + set: function(v) { + var5 = v; + } +}), m4 = (m33 = m3 || (m3 = {})).m4 || (m33.m4 = {}), "string" == typeof var1 && var1.length, "string" == typeof var22 && var22.length, Object.defineProperty(m4, "var3", { + enumerable: !0, + get: function() { + return var32; + }, + set: function(v) { + var32 = v; + } +}); diff --git a/crates/swc/tests/tsc-references/typeofANonExportedType.1.normal.js b/crates/swc/tests/tsc-references/typeofANonExportedType.1.normal.js index fff8b6ce8fca1..2e0fbd745b7fe 100644 --- a/crates/swc/tests/tsc-references/typeofANonExportedType.1.normal.js +++ b/crates/swc/tests/tsc-references/typeofANonExportedType.1.normal.js @@ -21,7 +21,16 @@ export var r5; export var r5; var M; (function(M) { - var _$foo = M.foo = ""; + var _$foo = ""; + Object.defineProperty(M, "foo", { + enumerable: true, + get: function get() { + return _$foo; + }, + set: function set(v) { + _$foo = v; + } + }); var C = function C() { "use strict"; _class_call_check(this, C); @@ -41,7 +50,16 @@ export var r11; export var r12; function foo() {} (function(foo) { - var y = foo.y = 1; + var y = 1; + Object.defineProperty(foo, "y", { + enumerable: true, + get: function get() { + return y; + }, + set: function set(v) { + y = v; + } + }); var C = function C() { "use strict"; _class_call_check(this, C); diff --git a/crates/swc/tests/tsc-references/typeofANonExportedType.2.minified.js b/crates/swc/tests/tsc-references/typeofANonExportedType.2.minified.js index cacd502bb48d5..4563725a6695f 100644 --- a/crates/swc/tests/tsc-references/typeofANonExportedType.2.minified.js +++ b/crates/swc/tests/tsc-references/typeofANonExportedType.2.minified.js @@ -1,5 +1,5 @@ //// [typeofANonExportedType.ts] -var M, E, M1, E1, foo; +var M, E, M1, _$foo, E1, foo, y; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; export var r1; export var r2; @@ -10,7 +10,15 @@ export var r4b; export var i; export var r5; export var r5; -(M1 = M || (M = {})).foo = "", M1.C = function C() { +M1 = M || (M = {}), _$foo = "", Object.defineProperty(M1, "foo", { + enumerable: !0, + get: function() { + return _$foo; + }, + set: function(v) { + _$foo = v; + } +}), M1.C = function C() { _class_call_check(this, C); }; export var r6; @@ -22,7 +30,15 @@ export var r10; export var r11; export var r12; function foo1() {} -(foo = foo1 || (foo1 = {})).y = 1, foo.C = function C() { +foo = foo1 || (foo1 = {}), y = 1, Object.defineProperty(foo, "y", { + enumerable: !0, + get: function() { + return y; + }, + set: function(v) { + y = v; + } +}), foo.C = function C() { _class_call_check(this, C); }; export var r13; diff --git a/crates/swc/tests/tsc-references/typeofOperatorWithAnyOtherType.1.normal.js b/crates/swc/tests/tsc-references/typeofOperatorWithAnyOtherType.1.normal.js index 5e810b0c44153..0c963acbacd37 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithAnyOtherType.1.normal.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithAnyOtherType.1.normal.js @@ -31,7 +31,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // any type var diff --git a/crates/swc/tests/tsc-references/typeofOperatorWithAnyOtherType.2.minified.js b/crates/swc/tests/tsc-references/typeofOperatorWithAnyOtherType.2.minified.js index 3736282be1ee4..509ee37c0baed 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithAnyOtherType.2.minified.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithAnyOtherType.2.minified.js @@ -16,7 +16,15 @@ var A = function() { } return A.foo = function() {}, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); void 0 === ANY1 || _type_of(ANY1), _type_of(ANY2), void 0 === A || _type_of(A), void 0 === M || _type_of(M), void 0 === obj || _type_of(obj), _type_of(obj1), _type_of(null), _type_of({}), _type_of(ANY2[0]), _type_of(objA.a), _type_of(obj1.x), _type_of(M.n), _type_of(foo()), _type_of(A.foo()), _type_of(ANY + ANY1), _type_of(NaN), _type_of(0), _type_of(NaN), _type_of(void 0 === ANY ? "undefined" : _type_of(ANY)), _type_of(_type_of(_type_of(ANY + ANY1))), // miss assignment operators void 0 === ANY || _type_of(ANY), void 0 === ANY1 || _type_of(ANY1), _type_of(ANY2[0]), void 0 === ANY || _type_of(ANY), _type_of(obj1), _type_of(obj1.x), _type_of(objA.a), _type_of(M.n), void 0 === ANY || _type_of(ANY), _type_of(ANY2), _type_of(foo), _type_of(objA.a), _type_of(A.foo), _type_of(M.n), _type_of(obj1.x); diff --git a/crates/swc/tests/tsc-references/typeofOperatorWithBooleanType.1.normal.js b/crates/swc/tests/tsc-references/typeofOperatorWithBooleanType.1.normal.js index 8c040840d3684..ed6fe6c058d08 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithBooleanType.1.normal.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithBooleanType.1.normal.js @@ -19,7 +19,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // boolean type var diff --git a/crates/swc/tests/tsc-references/typeofOperatorWithBooleanType.2.minified.js b/crates/swc/tests/tsc-references/typeofOperatorWithBooleanType.2.minified.js index ce78eb0040af8..f72fc298d2341 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithBooleanType.2.minified.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithBooleanType.2.minified.js @@ -13,7 +13,15 @@ var n, BOOLEAN, M, A = function() { return !1; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); void 0 === BOOLEAN || _type_of(BOOLEAN), _type_of(!0), _type_of({ x: !0, diff --git a/crates/swc/tests/tsc-references/typeofOperatorWithEnumType.1.normal.js b/crates/swc/tests/tsc-references/typeofOperatorWithEnumType.1.normal.js index ecf28656c26ff..63942a4ba1bca 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithEnumType.1.normal.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithEnumType.1.normal.js @@ -13,18 +13,18 @@ var ENUM1; var ResultIsString1 = typeof ENUM === "undefined" ? "undefined" : _type_of(ENUM); var ResultIsString2 = typeof ENUM1 === "undefined" ? "undefined" : _type_of(ENUM1); // enum type expressions -var ResultIsString3 = _type_of(ENUM1["A"]); -var ResultIsString4 = _type_of(ENUM[0] + ENUM1["B"]); +var ResultIsString3 = _type_of(0); +var ResultIsString4 = _type_of(ENUM[0] + 1); // multiple typeof operators var ResultIsString5 = _type_of(typeof ENUM === "undefined" ? "undefined" : _type_of(ENUM)); -var ResultIsString6 = _type_of(_type_of(_type_of(ENUM[0] + ENUM1.B))); +var ResultIsString6 = _type_of(_type_of(_type_of(ENUM[0] + 1))); // miss assignment operators typeof ENUM === "undefined" ? "undefined" : _type_of(ENUM); typeof ENUM1 === "undefined" ? "undefined" : _type_of(ENUM1); -_type_of(ENUM1["B"]); +_type_of(1); typeof ENUM === "undefined" ? "undefined" : _type_of(ENUM), ENUM1; -var // use typeof in type query -z; +var z; +// use typeof in type query (function(z) {})(z || (z = {})); z: typeof ENUM === "undefined" ? "undefined" : _type_of(ENUM); z: typeof ENUM1 === "undefined" ? "undefined" : _type_of(ENUM1); diff --git a/crates/swc/tests/tsc-references/typeofOperatorWithEnumType.2.minified.js b/crates/swc/tests/tsc-references/typeofOperatorWithEnumType.2.minified.js index 3b2a9a933aafc..12b4ea40967f6 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithEnumType.2.minified.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithEnumType.2.minified.js @@ -1,7 +1,6 @@ //// [typeofOperatorWithEnumType.ts] // typeof operator on enum type -var ENUM, ENUM1, // use typeof in type query -z, ENUM11; +var ENUM, ENUM1, z, ENUM11; import { _ as _type_of } from "@swc/helpers/_/_type_of"; -ENUM || (ENUM = {}), (ENUM11 = ENUM1 || (ENUM1 = {}))[ENUM11.A = 0] = "A", ENUM11[ENUM11.B = 1] = "B", ENUM11[ENUM11[""] = 2] = "", void 0 === ENUM || _type_of(ENUM), void 0 === ENUM1 || _type_of(ENUM1), _type_of(ENUM1.A), _type_of(ENUM[0] + ENUM1.B), _type_of(void 0 === ENUM ? "undefined" : _type_of(ENUM)), _type_of(_type_of(_type_of(ENUM[0] + ENUM1.B))), // miss assignment operators -void 0 === ENUM || _type_of(ENUM), void 0 === ENUM1 || _type_of(ENUM1), _type_of(ENUM1.B), void 0 === ENUM || _type_of(ENUM), z || (z = {}), void 0 === ENUM || _type_of(ENUM), void 0 === ENUM1 || _type_of(ENUM1); +ENUM || (ENUM = {}), (ENUM11 = ENUM1 || (ENUM1 = {}))[ENUM11.A = 0] = "A", ENUM11[ENUM11.B = 1] = "B", ENUM11[ENUM11[""] = 2] = "", void 0 === ENUM || _type_of(ENUM), void 0 === ENUM1 || _type_of(ENUM1), _type_of(0), _type_of(ENUM[0] + 1), _type_of(void 0 === ENUM ? "undefined" : _type_of(ENUM)), _type_of(_type_of(_type_of(ENUM[0] + 1))), // miss assignment operators +void 0 === ENUM || _type_of(ENUM), void 0 === ENUM1 || _type_of(ENUM1), _type_of(1), void 0 === ENUM || _type_of(ENUM), z || (z = {}), void 0 === ENUM || _type_of(ENUM), void 0 === ENUM1 || _type_of(ENUM1); diff --git a/crates/swc/tests/tsc-references/typeofOperatorWithNumberType.1.normal.js b/crates/swc/tests/tsc-references/typeofOperatorWithNumberType.1.normal.js index 612211362c209..bbfb9b9c3e08c 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithNumberType.1.normal.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithNumberType.1.normal.js @@ -23,7 +23,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // number type var diff --git a/crates/swc/tests/tsc-references/typeofOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/typeofOperatorWithNumberType.2.minified.js index 2ce974dcd8e21..2eb76160c88f8 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithNumberType.2.minified.js @@ -17,7 +17,15 @@ var A = function() { return 1; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); void 0 === NUMBER || _type_of(NUMBER), _type_of(NUMBER1), _type_of(1), _type_of({ x: 1, diff --git a/crates/swc/tests/tsc-references/typeofOperatorWithStringType.1.normal.js b/crates/swc/tests/tsc-references/typeofOperatorWithStringType.1.normal.js index 060ea56273b1e..27d4081e6d16e 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithStringType.1.normal.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithStringType.1.normal.js @@ -23,7 +23,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // string type var diff --git a/crates/swc/tests/tsc-references/typeofOperatorWithStringType.2.minified.js b/crates/swc/tests/tsc-references/typeofOperatorWithStringType.2.minified.js index 816a9277c2ab2..808c54caf98d7 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithStringType.2.minified.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithStringType.2.minified.js @@ -17,7 +17,15 @@ var A = function() { return ""; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); void 0 === STRING || _type_of(STRING), _type_of(STRING1), _type_of(""), _type_of({ x: "", diff --git a/crates/swc/tests/tsc-references/typeofThis.1.normal.js b/crates/swc/tests/tsc-references/typeofThis.1.normal.js index bbcd9b08d2a7e..bbff6cb458d1c 100644 --- a/crates/swc/tests/tsc-references/typeofThis.1.normal.js +++ b/crates/swc/tests/tsc-references/typeofThis.1.normal.js @@ -42,15 +42,33 @@ var Test5 = function Test5() { }; var Test6; (function(Test6) { - var f = Test6.f = function() { + var f = function() { var x = 1; }; + Object.defineProperty(Test6, "f", { + enumerable: true, + get: function get() { + return f; + }, + set: function set(v) { + f = v; + } + }); })(Test6 || (Test6 = {})); var Test7; (function(Test7) { - var f = Test7.f = function() { + var f = function() { var x = 1; }; + Object.defineProperty(Test7, "f", { + enumerable: true, + get: function get() { + return f; + }, + set: function set(v) { + f = v; + } + }); })(Test7 || (Test7 = {})); var Test8 = function() { var x = 1; diff --git a/crates/swc/tests/tsc-references/typeofThis.2.minified.js b/crates/swc/tests/tsc-references/typeofThis.2.minified.js index c365f6faa278f..6fa039d7dca0f 100644 --- a/crates/swc/tests/tsc-references/typeofThis.2.minified.js +++ b/crates/swc/tests/tsc-references/typeofThis.2.minified.js @@ -1,5 +1,21 @@ //// [typeofThis.ts] -var Test6, Test7; +var Test6, f, Test7, f1, Test61, Test71; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _instanceof } from "@swc/helpers/_/_instanceof"; -(Test6 || (Test6 = {})).f = function() {}, (Test7 || (Test7 = {})).f = function() {}; +Test6 = Test61 || (Test61 = {}), f = function() {}, Object.defineProperty(Test6, "f", { + enumerable: !0, + get: function() { + return f; + }, + set: function(v) { + f = v; + } +}), Test7 = Test71 || (Test71 = {}), f1 = function() {}, Object.defineProperty(Test7, "f", { + enumerable: !0, + get: function() { + return f1; + }, + set: function(v) { + f1 = v; + } +}); diff --git a/crates/swc/tests/tsc-references/undefinedIsSubtypeOfEverything.1.normal.js b/crates/swc/tests/tsc-references/undefinedIsSubtypeOfEverything.1.normal.js index eb2655c9a6851..7114645765754 100644 --- a/crates/swc/tests/tsc-references/undefinedIsSubtypeOfEverything.1.normal.js +++ b/crates/swc/tests/tsc-references/undefinedIsSubtypeOfEverything.1.normal.js @@ -173,7 +173,16 @@ var D11 = /*#__PURE__*/ function(Base) { }(Base); function f() {} (function(f) { - var bar = f.bar = 1; + var bar = 1; + Object.defineProperty(f, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(f || (f = {})); var D12 = /*#__PURE__*/ function(Base) { "use strict"; @@ -190,7 +199,16 @@ var c = function c() { _class_call_check(this, c); }; (function(c) { - var bar = c.bar = 1; + var bar = 1; + Object.defineProperty(c, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(c || (c = {})); var D13 = /*#__PURE__*/ function(Base) { "use strict"; diff --git a/crates/swc/tests/tsc-references/undefinedIsSubtypeOfEverything.2.minified.js b/crates/swc/tests/tsc-references/undefinedIsSubtypeOfEverything.2.minified.js index 953f79c1fba74..a0b1b25bb6b1c 100644 --- a/crates/swc/tests/tsc-references/undefinedIsSubtypeOfEverything.2.minified.js +++ b/crates/swc/tests/tsc-references/undefinedIsSubtypeOfEverything.2.minified.js @@ -4,8 +4,24 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; function f() {} -(E1 = E || (E = {}))[E1.A = 0] = "A", (f || (f = {})).bar = 1; -var E, E1, c = function c() { +(E1 = E || (E = {}))[E1.A = 0] = "A", f1 = f || (f = {}), bar = 1, Object.defineProperty(f1, "bar", { + enumerable: !0, + get: function() { + return bar; + }, + set: function(v) { + bar = v; + } +}); +var E, E1, f1, bar, c, bar1, c1 = function c() { _class_call_check(this, c); }; -(c || (c = {})).bar = 1; +c = c1 || (c1 = {}), bar1 = 1, Object.defineProperty(c, "bar", { + enumerable: !0, + get: function() { + return bar1; + }, + set: function(v) { + bar1 = v; + } +}); diff --git a/crates/swc/tests/tsc-references/unionSubtypeIfEveryConstituentTypeIsSubtype.1.normal.js b/crates/swc/tests/tsc-references/unionSubtypeIfEveryConstituentTypeIsSubtype.1.normal.js index 45b46755c5bb9..b50e091c64da1 100644 --- a/crates/swc/tests/tsc-references/unionSubtypeIfEveryConstituentTypeIsSubtype.1.normal.js +++ b/crates/swc/tests/tsc-references/unionSubtypeIfEveryConstituentTypeIsSubtype.1.normal.js @@ -19,12 +19,30 @@ var E2; })(E2 || (E2 = {})); function f() {} (function(f) { - var bar = f.bar = 1; + var bar = 1; + Object.defineProperty(f, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(f || (f = {})); var c = function c() { "use strict"; _class_call_check(this, c); }; (function(c) { - var bar = c.bar = 1; + var bar = 1; + Object.defineProperty(c, "bar", { + enumerable: true, + get: function get() { + return bar; + }, + set: function set(v) { + bar = v; + } + }); })(c || (c = {})); diff --git a/crates/swc/tests/tsc-references/unionSubtypeIfEveryConstituentTypeIsSubtype.2.minified.js b/crates/swc/tests/tsc-references/unionSubtypeIfEveryConstituentTypeIsSubtype.2.minified.js index 7d9661d8d94b1..762688a39dd4a 100644 --- a/crates/swc/tests/tsc-references/unionSubtypeIfEveryConstituentTypeIsSubtype.2.minified.js +++ b/crates/swc/tests/tsc-references/unionSubtypeIfEveryConstituentTypeIsSubtype.2.minified.js @@ -1,8 +1,24 @@ //// [unionSubtypeIfEveryConstituentTypeIsSubtype.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; function f() {} -(e = e1 || (e1 = {}))[e.e1 = 0] = "e1", e[e.e2 = 1] = "e2", (E2 = E21 || (E21 = {}))[E2.A = 0] = "A", (f || (f = {})).bar = 1; -var e, E2, e1, E21, c = function c() { +(e = e1 || (e1 = {}))[e.e1 = 0] = "e1", e[e.e2 = 1] = "e2", (E2 = E21 || (E21 = {}))[E2.A = 0] = "A", f1 = f || (f = {}), bar1 = 1, Object.defineProperty(f1, "bar", { + enumerable: !0, + get: function() { + return bar1; + }, + set: function(v) { + bar1 = v; + } +}); +var c, bar, e, E2, f1, bar1, e1, E21, c1 = function c() { _class_call_check(this, c); }; -(c || (c = {})).bar = 1; +c = c1 || (c1 = {}), bar = 1, Object.defineProperty(c, "bar", { + enumerable: !0, + get: function() { + return bar; + }, + set: function(v) { + bar = v; + } +}); diff --git a/crates/swc/tests/tsc-references/unknownType2.1.normal.js b/crates/swc/tests/tsc-references/unknownType2.1.normal.js index 49c73b6dac041..6940daefcd056 100644 --- a/crates/swc/tests/tsc-references/unknownType2.1.normal.js +++ b/crates/swc/tests/tsc-references/unknownType2.1.normal.js @@ -58,32 +58,32 @@ var StringEnum; if (u === NumberEnum || u === StringEnum) { var enumObj = u; } -if (u === NumberEnum.A) { +if (u === 0) { var a = u; } -if (u === StringEnum.B) { +if (u === "B") { var b = u; } function switchTestEnum(x) { switch(x){ - case StringEnum.A: + case "A": var a = x; break; - case StringEnum.B: + case "B": var b = x; break; - case StringEnum.C: + case "C": var c = x; break; } } function switchTestCollectEnum(x) { switch(x){ - case StringEnum.A: + case "A": var a = x; - case StringEnum.B: + case "B": var b = x; - case StringEnum.C: + case "C": var c = x; var all = x; return; @@ -168,14 +168,14 @@ function notNotEquals(u) { if (u !== NumberEnum) {} else { var o = u; } - if (u !== NumberEnum.A) {} else { + if (u !== 0) {} else { var a = u; } - if (u !== NumberEnum.A && u !== NumberEnum.B && u !== StringEnum.A) {} else { + if (u !== 0 && u !== 1 && u !== "A") {} else { var aOrB = u; } // equivalent to - if (!(u === NumberEnum.A || u === NumberEnum.B || u === StringEnum.A)) {} else { + if (!(u === 0 || u === 1 || u === "A")) {} else { var aOrB1 = u; } } diff --git a/crates/swc/tests/tsc-references/unknownType2.2.minified.js b/crates/swc/tests/tsc-references/unknownType2.2.minified.js index 10816bbe4a854..fee503939e9e8 100644 --- a/crates/swc/tests/tsc-references/unknownType2.2.minified.js +++ b/crates/swc/tests/tsc-references/unknownType2.2.minified.js @@ -1,3 +1,3 @@ //// [unknownType2.ts] var NumberEnum, StringEnum, NumberEnum1, StringEnum1, u = void 0; -5 === u && u.toString(10), symb, aString, aBoolean, aNumber, anObject, anObjectLiteral, aUnion, anIntersection, aFunction, (NumberEnum = NumberEnum1 || (NumberEnum1 = {}))[NumberEnum.A = 0] = "A", NumberEnum[NumberEnum.B = 1] = "B", NumberEnum[NumberEnum.C = 2] = "C", (StringEnum = StringEnum1 || (StringEnum1 = {})).A = "A", StringEnum.B = "B", StringEnum.C = "C", NumberEnum1.A, StringEnum1.B; +5 === u && u.toString(10), symb, aString, aBoolean, aNumber, anObject, anObjectLiteral, aUnion, anIntersection, aFunction, (NumberEnum = NumberEnum1 || (NumberEnum1 = {}))[NumberEnum.A = 0] = "A", NumberEnum[NumberEnum.B = 1] = "B", NumberEnum[NumberEnum.C = 2] = "C", (StringEnum = StringEnum1 || (StringEnum1 = {})).A = "A", StringEnum.B = "B", StringEnum.C = "C"; diff --git a/crates/swc/tests/tsc-references/validEnumAssignments.1.normal.js b/crates/swc/tests/tsc-references/validEnumAssignments.1.normal.js index 6dff8a87d1013..0fc3233477e75 100644 --- a/crates/swc/tests/tsc-references/validEnumAssignments.1.normal.js +++ b/crates/swc/tests/tsc-references/validEnumAssignments.1.normal.js @@ -8,13 +8,13 @@ var n; var a; var e; n = e; -n = E.A; +n = 0; a = n; a = e; -a = E.A; +a = 0; e = e; -e = E.A; -e = E.B; +e = 0; +e = 1; e = n; e = null; e = undefined; diff --git a/crates/swc/tests/tsc-references/validEnumAssignments.2.minified.js b/crates/swc/tests/tsc-references/validEnumAssignments.2.minified.js index 5c6a00bb8ecbe..49e6e4d2b1790 100644 --- a/crates/swc/tests/tsc-references/validEnumAssignments.2.minified.js +++ b/crates/swc/tests/tsc-references/validEnumAssignments.2.minified.js @@ -1,3 +1,3 @@ //// [validEnumAssignments.ts] var E, E1; -(E1 = E || (E = {}))[E1.A = 0] = "A", E1[E1.B = 1] = "B", E.A, E.A, E.A, E.B; +(E1 = E || (E = {}))[E1.A = 0] = "A", E1[E1.B = 1] = "B"; diff --git a/crates/swc/tests/tsc-references/validNullAssignments.1.normal.js b/crates/swc/tests/tsc-references/validNullAssignments.1.normal.js index 6c5d6f6f33721..b7a70c7400124 100644 --- a/crates/swc/tests/tsc-references/validNullAssignments.1.normal.js +++ b/crates/swc/tests/tsc-references/validNullAssignments.1.normal.js @@ -23,7 +23,16 @@ g = null; // ok I = null; // error var M; (function(M) { - var x = M.x = 1; + var x = 1; + Object.defineProperty(M, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); })(M || (M = {})); M = null; // error var h = null; diff --git a/crates/swc/tests/tsc-references/validNullAssignments.2.minified.js b/crates/swc/tests/tsc-references/validNullAssignments.2.minified.js index d9ee9b611be26..de29082d8ee75 100644 --- a/crates/swc/tests/tsc-references/validNullAssignments.2.minified.js +++ b/crates/swc/tests/tsc-references/validNullAssignments.2.minified.js @@ -1,5 +1,13 @@ //// [validNullAssignments.ts] -var E, M, E1; +var E, M, E1, M1, x; import "@swc/helpers/_/_class_call_check"; -(E1 = E || (E = {}))[E1.A = 0] = "A", E.A = null, I = null, (M || (M = {})).x = 1; +(E1 = E || (E = {}))[E1.A = 0] = "A", E.A = null, I = null, M1 = M || (M = {}), x = 1, Object.defineProperty(M1, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}); // error diff --git a/crates/swc/tests/tsc-references/validNumberAssignments.1.normal.js b/crates/swc/tests/tsc-references/validNumberAssignments.1.normal.js index ee30229b1e8a7..002ce29e0e5db 100644 --- a/crates/swc/tests/tsc-references/validNumberAssignments.1.normal.js +++ b/crates/swc/tests/tsc-references/validNumberAssignments.1.normal.js @@ -8,5 +8,5 @@ var E; E[E["A"] = 0] = "A"; })(E || (E = {})); var d = x; -var e = E.A; +var e = 0; e = x; diff --git a/crates/swc/tests/tsc-references/validNumberAssignments.2.minified.js b/crates/swc/tests/tsc-references/validNumberAssignments.2.minified.js index 3eeb2b1f71fba..42573de5501e3 100644 --- a/crates/swc/tests/tsc-references/validNumberAssignments.2.minified.js +++ b/crates/swc/tests/tsc-references/validNumberAssignments.2.minified.js @@ -1,3 +1,3 @@ //// [validNumberAssignments.ts] var E, E1; -(E1 = E || (E = {}))[E1.A = 0] = "A", E.A; +(E1 = E || (E = {}))[E1.A = 0] = "A"; diff --git a/crates/swc/tests/tsc-references/verbatimModuleSyntaxNoElisionCJS.1.normal.js b/crates/swc/tests/tsc-references/verbatimModuleSyntaxNoElisionCJS.1.normal.js index 6b168b8886928..0e795d0e9fb2a 100644 --- a/crates/swc/tests/tsc-references/verbatimModuleSyntaxNoElisionCJS.1.normal.js +++ b/crates/swc/tests/tsc-references/verbatimModuleSyntaxNoElisionCJS.1.normal.js @@ -8,17 +8,15 @@ module.exports = I; Object.defineProperty(exports, "__esModule", { value: true }); -const I = require("./a"); //// [/c.ts] "use strict"; var I; (function(I) { - var x = I.x = 1; + const x = I.x = 1; })(I || (I = {})); module.exports = I; //// [/d.ts] "use strict"; -const I = require("./c"); module.exports = J; //// [/e.d.ts] "use strict"; diff --git a/crates/swc/tests/tsc-references/verbatimModuleSyntaxNoElisionCJS.2.minified.js b/crates/swc/tests/tsc-references/verbatimModuleSyntaxNoElisionCJS.2.minified.js index 8068c394c0ccf..cdcabee170ddd 100644 --- a/crates/swc/tests/tsc-references/verbatimModuleSyntaxNoElisionCJS.2.minified.js +++ b/crates/swc/tests/tsc-references/verbatimModuleSyntaxNoElisionCJS.2.minified.js @@ -4,12 +4,12 @@ module.exports = I; //// [/b.ts] Object.defineProperty(exports, "__esModule", { value: !0 -}), require("./a"); +}); //// [/c.ts] var I; (I || (I = {})).x = 1, module.exports = I; //// [/d.ts] -require("./c"), module.exports = J; +module.exports = J; //// [/e.d.ts] module.exports = I; //// [/f.ts] diff --git a/crates/swc/tests/tsc-references/verbatimModuleSyntaxRestrictionsCJS.1.normal.js b/crates/swc/tests/tsc-references/verbatimModuleSyntaxRestrictionsCJS.1.normal.js index ec89fe335cecb..d176c6af020b8 100644 --- a/crates/swc/tests/tsc-references/verbatimModuleSyntaxRestrictionsCJS.1.normal.js +++ b/crates/swc/tests/tsc-references/verbatimModuleSyntaxRestrictionsCJS.1.normal.js @@ -38,7 +38,7 @@ Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard._(require("./ const x = 1; // error var Values; (function(Values) { - var x = Values.x = 1; + const x = Values.x = 1; })(Values || (Values = {})); // sketchy, but ok //// [/main2.ts] @@ -50,7 +50,7 @@ module.exports = { "use strict"; var ns; (function(ns) { - var x = ns.x = 1; + const x = ns.x = 1; })(ns || (ns = {})); module.exports = ns; //// [/main4.ts] diff --git a/crates/swc/tests/tsc-references/voidOperatorWithAnyOtherType.1.normal.js b/crates/swc/tests/tsc-references/voidOperatorWithAnyOtherType.1.normal.js index 7ad0b69e5d570..0f049e6809f65 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithAnyOtherType.1.normal.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithAnyOtherType.1.normal.js @@ -30,7 +30,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // any type var diff --git a/crates/swc/tests/tsc-references/voidOperatorWithAnyOtherType.2.minified.js b/crates/swc/tests/tsc-references/voidOperatorWithAnyOtherType.2.minified.js index eef4b29a9452b..1f8f66f5e9bf6 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithAnyOtherType.2.minified.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithAnyOtherType.2.minified.js @@ -10,6 +10,14 @@ var n, M, obj1 = { } return A.foo = function() {}, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); obj1.x, obj1.y, objA.a, M.n, A.foo(), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/voidOperatorWithBooleanType.1.normal.js b/crates/swc/tests/tsc-references/voidOperatorWithBooleanType.1.normal.js index 1f64345c422da..e3b20f5b16311 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithBooleanType.1.normal.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithBooleanType.1.normal.js @@ -18,7 +18,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // boolean type var diff --git a/crates/swc/tests/tsc-references/voidOperatorWithBooleanType.2.minified.js b/crates/swc/tests/tsc-references/voidOperatorWithBooleanType.2.minified.js index d00f0850c12f2..34af3c0acb26e 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithBooleanType.2.minified.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithBooleanType.2.minified.js @@ -9,6 +9,14 @@ var n, M, A = function() { return !1; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/voidOperatorWithEnumType.1.normal.js b/crates/swc/tests/tsc-references/voidOperatorWithEnumType.1.normal.js index c5b1eb65b76c6..94d5ff638066d 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithEnumType.1.normal.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithEnumType.1.normal.js @@ -12,13 +12,13 @@ var ENUM1; var ResultIsAny1 = void ENUM; var ResultIsAny2 = void ENUM1; // enum type expressions -var ResultIsAny3 = void ENUM1["A"]; -var ResultIsAny4 = void (ENUM[0] + ENUM1["B"]); +var ResultIsAny3 = void 0; +var ResultIsAny4 = void (ENUM[0] + 1); // multiple void operators var ResultIsAny5 = void void ENUM; -var ResultIsAny6 = void void void (ENUM[0] + ENUM1.B); +var ResultIsAny6 = void void void (ENUM[0] + 1); // miss assignment operators void ENUM; void ENUM1; -void ENUM1["B"]; +void 1; ENUM, ENUM1; diff --git a/crates/swc/tests/tsc-references/voidOperatorWithEnumType.2.minified.js b/crates/swc/tests/tsc-references/voidOperatorWithEnumType.2.minified.js index 298806da8ddf5..47ed0c3ae5c39 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithEnumType.2.minified.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithEnumType.2.minified.js @@ -1,4 +1,4 @@ //// [voidOperatorWithEnumType.ts] // void operator on enum type var ENUM, ENUM1, ENUM11; -ENUM || (ENUM = {}), (ENUM11 = ENUM1 || (ENUM1 = {}))[ENUM11.A = 0] = "A", ENUM11[ENUM11.B = 1] = "B", ENUM11[ENUM11[""] = 2] = "", ENUM1.A, ENUM[0], ENUM1.B, ENUM[0], ENUM1.B, ENUM1.B; +ENUM || (ENUM = {}), (ENUM11 = ENUM1 || (ENUM1 = {}))[ENUM11.A = 0] = "A", ENUM11[ENUM11.B = 1] = "B", ENUM11[ENUM11[""] = 2] = "", ENUM[0], ENUM[0]; diff --git a/crates/swc/tests/tsc-references/voidOperatorWithNumberType.1.normal.js b/crates/swc/tests/tsc-references/voidOperatorWithNumberType.1.normal.js index acbf44d7c83e3..d6a645cf2f0e8 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithNumberType.1.normal.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithNumberType.1.normal.js @@ -22,7 +22,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // number type var diff --git a/crates/swc/tests/tsc-references/voidOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/voidOperatorWithNumberType.2.minified.js index 4c65bdc21ba36..4c668829963fa 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithNumberType.2.minified.js @@ -9,6 +9,14 @@ var M, n, A = function() { return 1; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n, objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/voidOperatorWithStringType.1.normal.js b/crates/swc/tests/tsc-references/voidOperatorWithStringType.1.normal.js index 33a35cff5be12..39510bb1ca556 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithStringType.1.normal.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithStringType.1.normal.js @@ -22,7 +22,15 @@ var A = /*#__PURE__*/ function() { var M; (function(M) { var n; - M.n = n; + Object.defineProperty(M, "n", { + enumerable: true, + get: function get() { + return n; + }, + set: function set(v) { + n = v; + } + }); })(M || (M = {})); var objA = new A(); // string type var diff --git a/crates/swc/tests/tsc-references/voidOperatorWithStringType.2.minified.js b/crates/swc/tests/tsc-references/voidOperatorWithStringType.2.minified.js index 5f82e753c66f3..3ccb99242291b 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithStringType.2.minified.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithStringType.2.minified.js @@ -9,6 +9,14 @@ var STRING, M, n, A = function() { return ""; }, A; }(); -(M || (M = {})).n = n; +Object.defineProperty(M || (M = {}), "n", { + enumerable: !0, + get: function() { + return n; + }, + set: function(v) { + n = v; + } +}); var objA = new A(); objA.a, M.n, A.foo(), STRING.charAt(0), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/witness.1.normal.js b/crates/swc/tests/tsc-references/witness.1.normal.js index 3ef995267568f..4a55e06c5592d 100644 --- a/crates/swc/tests/tsc-references/witness.1.normal.js +++ b/crates/swc/tests/tsc-references/witness.1.normal.js @@ -108,10 +108,19 @@ var propAcc1 = { m: propAcc1.m }; var propAcc1; -// Property access of module member var M2; -(function(M21) { - var x = M21.x = M2.x; +// Property access of module member +(function(M2) { + var x = M2.x; + Object.defineProperty(M2, "x", { + enumerable: true, + get: function get() { + return x; + }, + set: function set(v) { + x = v; + } + }); var y = x; var y; })(M2 || (M2 = {})); diff --git a/crates/swc/tests/tsc-references/witness.2.minified.js b/crates/swc/tests/tsc-references/witness.2.minified.js index a63d46be85d97..b48ae89f3c4d6 100644 --- a/crates/swc/tests/tsc-references/witness.2.minified.js +++ b/crates/swc/tests/tsc-references/witness.2.minified.js @@ -13,10 +13,18 @@ function fnCall() { return new (void 0)(fn5); }(); // Property access -var propAcc1, M2, propAcc1 = { +var propAcc1, M2, M21, x, propAcc1 = { m: propAcc1.m }; -(M2 || (M2 = {})).x = M2.x, new // Property access of class instance type +x = (M21 = M2 || (M2 = {})).x, Object.defineProperty(M21, "x", { + enumerable: !0, + get: function() { + return x; + }, + set: function(v) { + x = v; + } +}), new // Property access of class instance type function C2() { _class_call_check(this, C2), this.n = this.n // n: any ; diff --git a/crates/swc_bundler/tests/common/mod.rs b/crates/swc_bundler/tests/common/mod.rs index 2bad2443867f3..5cf80d034eb7a 100644 --- a/crates/swc_bundler/tests/common/mod.rs +++ b/crates/swc_bundler/tests/common/mod.rs @@ -16,7 +16,7 @@ use swc_common::{ sync::Lrc, FileName, Mark, SourceMap, }; -use swc_ecma_ast::EsVersion; +use swc_ecma_ast::{EsVersion, Program}; use swc_ecma_parser::{parse_file_as_module, Syntax, TsConfig}; use swc_ecma_transforms_base::{ helpers::{inject_helpers, Helpers, HELPERS}, @@ -133,7 +133,7 @@ impl Load for Loader { }); let module = HELPERS.set(&Helpers::new(false), || { - module + Program::Module(module) .fold_with(&mut resolver(unresolved_mark, top_level_mark, false)) .fold_with(&mut decorators(decorators::Config { legacy: true, @@ -149,6 +149,8 @@ impl Load for Loader { unresolved_mark, )) .fold_with(&mut inject_helpers(unresolved_mark)) + .module() + .unwrap() }); Ok(ModuleData { diff --git a/crates/swc_bundler/tests/fixture/deno-9591/output/entry.inlined.ts b/crates/swc_bundler/tests/fixture/deno-9591/output/entry.inlined.ts index a75ca202d2e97..421ac5ed91ab1 100644 --- a/crates/swc_bundler/tests/fixture/deno-9591/output/entry.inlined.ts +++ b/crates/swc_bundler/tests/fixture/deno-9591/output/entry.inlined.ts @@ -1622,27 +1622,27 @@ var LogLevels; })(LogLevels || (LogLevels = {})); Object.keys(LogLevels).filter((key)=>isNaN(Number(key))); const byLevel = { - [String(LogLevels.NOTSET)]: "NOTSET", - [String(LogLevels.DEBUG)]: "DEBUG", - [String(LogLevels.INFO)]: "INFO", - [String(LogLevels.WARNING)]: "WARNING", - [String(LogLevels.ERROR)]: "ERROR", - [String(LogLevels.CRITICAL)]: "CRITICAL" + [String(0)]: "NOTSET", + [String(10)]: "DEBUG", + [String(20)]: "INFO", + [String(30)]: "WARNING", + [String(40)]: "ERROR", + [String(50)]: "CRITICAL" }; function getLevelByName(name) { switch(name){ case "NOTSET": - return LogLevels.NOTSET; + return 0; case "DEBUG": - return LogLevels.DEBUG; + return 10; case "INFO": - return LogLevels.INFO; + return 20; case "WARNING": - return LogLevels.WARNING; + return 30; case "ERROR": - return LogLevels.ERROR; + return 40; case "CRITICAL": - return LogLevels.CRITICAL; + return 50; default: throw new Error(`no log level found for "${name}"`); } @@ -2919,11 +2919,11 @@ function detect(content) { if (!d || d.length === 0) { return null; } - const crlf = d.filter((x)=>x === EOL.CRLF); + const crlf = d.filter((x)=>x === "\r\n"); if (crlf.length > 0) { - return EOL.CRLF; + return "\r\n"; } else { - return EOL.LF; + return "\n"; } } function format3(content, eol) { diff --git a/crates/swc_bundler/tests/fixture/deno-9591/output/entry.ts b/crates/swc_bundler/tests/fixture/deno-9591/output/entry.ts index e311cc0c6930c..1683f888da597 100644 --- a/crates/swc_bundler/tests/fixture/deno-9591/output/entry.ts +++ b/crates/swc_bundler/tests/fixture/deno-9591/output/entry.ts @@ -1632,27 +1632,27 @@ var LogLevels; })(LogLevels || (LogLevels = {})); Object.keys(LogLevels).filter((key)=>isNaN(Number(key))); const byLevel = { - [String(LogLevels.NOTSET)]: "NOTSET", - [String(LogLevels.DEBUG)]: "DEBUG", - [String(LogLevels.INFO)]: "INFO", - [String(LogLevels.WARNING)]: "WARNING", - [String(LogLevels.ERROR)]: "ERROR", - [String(LogLevels.CRITICAL)]: "CRITICAL" + [String(0)]: "NOTSET", + [String(10)]: "DEBUG", + [String(20)]: "INFO", + [String(30)]: "WARNING", + [String(40)]: "ERROR", + [String(50)]: "CRITICAL" }; function getLevelByName(name) { switch(name){ case "NOTSET": - return LogLevels.NOTSET; + return 0; case "DEBUG": - return LogLevels.DEBUG; + return 10; case "INFO": - return LogLevels.INFO; + return 20; case "WARNING": - return LogLevels.WARNING; + return 30; case "ERROR": - return LogLevels.ERROR; + return 40; case "CRITICAL": - return LogLevels.CRITICAL; + return 50; default: throw new Error(`no log level found for "${name}"`); } @@ -2929,11 +2929,11 @@ function detect(content) { if (!d || d.length === 0) { return null; } - const crlf = d.filter((x)=>x === EOL.CRLF); + const crlf = d.filter((x)=>x === "\r\n"); if (crlf.length > 0) { - return EOL.CRLF; + return "\r\n"; } else { - return EOL.LF; + return "\n"; } } function format3(content, eol) { diff --git a/crates/swc_ecma_transforms/tests/decorators.rs b/crates/swc_ecma_transforms/tests/decorators.rs index 61c78c9870233..12b53456f3c24 100644 --- a/crates/swc_ecma_transforms/tests/decorators.rs +++ b/crates/swc_ecma_transforms/tests/decorators.rs @@ -18,7 +18,7 @@ use swc_ecma_transforms_compat::{ use swc_ecma_transforms_module::common_js; use swc_ecma_transforms_proposal::{decorators, decorators::Config}; use swc_ecma_transforms_testing::{test, test_exec, test_fixture, Tester}; -use swc_ecma_transforms_typescript::strip; +use swc_ecma_transforms_typescript::{strip, typescript}; use swc_ecma_visit::Fold; fn ts() -> Syntax { @@ -61,8 +61,8 @@ fn simple_strip(t: &Tester, config: Config) -> impl Fold { chain!( decorators(config), resolver(unresolved_mark, top_level_mark, false), - strip::strip_with_config( - strip::Config { + typescript( + typescript::Config { no_empty_export: true, ..Default::default() }, diff --git a/crates/swc_ecma_transforms_optimization/tests/simplify_inlining.rs b/crates/swc_ecma_transforms_optimization/tests/simplify_inlining.rs index f9aceb1bf4e50..f1713e1543bb5 100644 --- a/crates/swc_ecma_transforms_optimization/tests/simplify_inlining.rs +++ b/crates/swc_ecma_transforms_optimization/tests/simplify_inlining.rs @@ -6,12 +6,12 @@ use swc_ecma_transforms_base::resolver; use swc_ecma_transforms_compat::es2022::class_properties; use swc_ecma_transforms_optimization::simplify::inlining::inlining; use swc_ecma_transforms_testing::test; -use swc_ecma_transforms_typescript::strip; +use swc_ecma_transforms_typescript::typescript; use swc_ecma_visit::Fold; fn simple_strip(top_level_mark: Mark) -> impl Fold { - strip::strip_with_config( - strip::Config { + typescript( + typescript::Config { no_empty_export: true, ..Default::default() }, diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/deno-12395/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/deno-12395/output.js index 7b499b50aa0fd..348254665b504 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/deno-12395/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/deno-12395/output.js @@ -1,3 +1,3 @@ import * as mongo from "https://deno.land/x/mongo@v0.27.0/mod.ts"; -var MongoClient = mongo.MongoClient; +const MongoClient = mongo.MongoClient; const mongoClient = new MongoClient(); diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/export-import/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/export-import/output.js index a731c4b372a1a..710869ac16239 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/export-import/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/export-import/output.js @@ -1 +1 @@ -export var A = B; +export const A = B; diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-1653/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-1653/output.js index 179d47da327d8..5af1a9fbc89c0 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-1653/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-1653/output.js @@ -2,13 +2,13 @@ var X; (function(X) { let Z; (function(Z) { - var foo = Z.foo = 0; + const foo = Z.foo = 0; })(Z = X.Z || (X.Z = {})); })(X || (X = {})); var Y; (function(Y) { let Z; (function(Z) { - var bar = Z.bar = 1; + const bar = Z.bar = 1; })(Z = Y.Z || (Y.Z = {})); })(Y || (Y = {})); diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2234/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2234/output.js index 69ef9cdfabee3..c794428f52bdf 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2234/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2234/output.js @@ -10,5 +10,5 @@ var Shapes; Polygons.Square = Square; })(Polygons = Shapes.Polygons || (Shapes.Polygons = {})); })(Shapes || (Shapes = {})); -var polygons = Shapes.Polygons; +const polygons = Shapes.Polygons; let sq = new polygons.Square(); diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2243/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2243/output.js index d619ec022759a..09bbd105722b1 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2243/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2243/output.js @@ -2,7 +2,7 @@ export function Colors(member) { return Colors.ValueFor(member); } (function(Colors) { - var ValueMap = Colors.ValueMap = { + const ValueMap = Colors.ValueMap = { Red: { value: 0.0, label: "Red" @@ -16,7 +16,7 @@ export function Colors(member) { label: "Green" } }; - var Values = Colors.Values = [ + const Values = Colors.Values = [ 0.0, 1.0, 2.0 diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2669/1/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2669/1/output.js index 0c61563c4cd8f..d0117e667e9e4 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2669/1/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2669/1/output.js @@ -1,5 +1,5 @@ export var TEST; (function(TEST) { - var VALUE = TEST.VALUE = "value"; + const VALUE = TEST.VALUE = "value"; })(TEST || (TEST = {})); export default TEST; diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2670/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2670/output.js index 47f83878a6df8..6fc5b10ef5a05 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2670/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-2670/output.js @@ -1,5 +1,5 @@ export var TEST; (function(TEST) { - var VAL1 = TEST.VAL1 = "value1"; - var VAL2 = TEST.VAL2 = `${VAL1}_value2`; + const VAL1 = TEST.VAL1 = "value1"; + const VAL2 = TEST.VAL2 = `${VAL1}_value2`; })(TEST || (TEST = {})); diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3001/1/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3001/1/output.js index c2feb8a605315..5cff9db4b2b23 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3001/1/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3001/1/output.js @@ -4,8 +4,7 @@ var Foo; Foo[Foo["a"] = 0] = "a"; Foo[Foo["b"] = 0] = "b"; Foo[Foo["c"] = 1] = "c"; - Foo[Foo["d"] = 1 + Foo.c * x] = "d"; + Foo[Foo["d"] = 1 + 1 * x] = "d"; Foo[Foo["e"] = 2 * Foo.d] = "e"; Foo[Foo["f"] = Foo.e * 10] = "f"; -})(Foo || (Foo = { -})); +})(Foo || (Foo = {})); diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3001/2/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3001/2/output.js index 57ec067166d24..5ab00bf45ad1b 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3001/2/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3001/2/output.js @@ -3,20 +3,19 @@ var Foo; (function(Foo) { Foo[Foo["a"] = 10] = "a"; Foo[Foo["b"] = 10] = "b"; - Foo[Foo["c"] = Foo.b + x] = "c"; + Foo[Foo["c"] = 10 + x] = "c"; Foo[Foo["d"] = Foo.c] = "d"; })(Foo || (Foo = {})); var Bar; (function(Bar) { Bar[Bar["a"] = 1] = "a"; - Bar[Bar["b"] = Foo.a] = "b"; - Bar[Bar["E"] = Bar.b] = "E"; + Bar[Bar["b"] = 10] = "b"; + Bar[Bar["E"] = 10] = "E"; Bar[Bar["F"] = Math.E] = "F"; })(Bar || (Bar = {})); var Baz; (function(Baz) { Baz[Baz["a"] = 0] = "a"; Baz[Baz["b"] = 1] = "b"; - Baz[Baz[// @ts-ignore - "x"] = Baz.a.toString()] = "x"; + Baz[Baz["x"] = 0..toString()] = "x"; })(Baz || (Baz = {})); diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/1/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/1/output.js index 0937bae4affa6..2772e29804580 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/1/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/1/output.js @@ -1,6 +1,6 @@ var Foo; (function(Foo) { - ({ a: Foo.a } = { + const { a } = { a: Foo.a } = { a: 1 - }); + }; })(Foo || (Foo = {})); diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/2/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/2/output.js index b286785c69bc6..81e6f5b3638ed 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/2/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/2/output.js @@ -1,7 +1,7 @@ var Bar; (function(Bar) { - ({ a: Bar.a , b: Bar.b } = { + const { a, b } = { a: Bar.a, b: Bar.b } = { a: 1, b: 2 - }); + }; })(Bar || (Bar = {})); diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/3/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/3/output.js index 713cab64fa647..17a0966a22927 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/3/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/3/output.js @@ -1,6 +1,6 @@ var Baz; (function(Baz) { - var baz = Baz.baz = { + const baz = Baz.baz = { a: 1, b: 2 }; diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/4/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/4/output.js index 19ac2b1d10beb..f04110dd81851 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/4/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3073/4/output.js @@ -2,20 +2,20 @@ var A; (function(A) { const a = 1; const b = 2; - ({ a: A.A } = { + const { a: A1 } = { a: A.A } = { a - }); - ({ b: A.B } = { + }; + const { b: B } = { b: A.B } = { b - }); + }; })(A || (A = {})); (function(A) { const c = 3; const d = 4; - ({ c: A.C } = { + const { c: C } = { c: A.C } = { c: c - }); - ({ d: A.D } = { + }; + const { d: D } = { d: A.D } = { d: d - }); + }; })(A || (A = {})); diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3158/1/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3158/1/output.js index 7b1d24b3b5475..d7c6e5c993a14 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3158/1/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3158/1/output.js @@ -1,7 +1,7 @@ var Foo; (function(Foo) { - var bar = Foo.bar = 42; - var foo = Foo.foo = function() { + const bar = Foo.bar = 42; + const foo = Foo.foo = function() { return 20; }; function xyz() { diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3158/2/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3158/2/output.js index 52ba2650e05f3..ab27eaa34d430 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3158/2/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3158/2/output.js @@ -4,7 +4,7 @@ var Test; return 10; } Test.abc = abc; - var foo = Test.foo = function() { + const foo = Test.foo = function() { return 20; }; function xyz() { diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3454/1/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3454/1/output.js index 5ed331103e372..9f18e6d27aa3f 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3454/1/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-3454/1/output.js @@ -1,10 +1,9 @@ export var a; (function(a) { - let b; (function(b) { let e; (function(e) { e["FOO"] = "BAR"; })(e = b.e || (b.e = {})); - })(b = a.b || (a.b = {})); + })(a.b || (a.b = {})); })(a || (a = {})); diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-4393/1/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-4393/1/output.js index 6efae1288496e..cf63cb61d429a 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-4393/1/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-4393/1/output.js @@ -1,5 +1,5 @@ var foo; (function(foo) { - var bar = foo.bar = 0; + const bar = foo.bar = 0; })(foo || (foo = {})); export { foo }; diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-4481/1/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-4481/1/output.js index 5b98deb0c51e4..9231d2a0dcf18 100644 --- a/crates/swc_ecma_transforms_typescript/tests/fixture/issue-4481/1/output.js +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/issue-4481/1/output.js @@ -1,10 +1,7 @@ import * as I from "./ABC"; export var IE; (function(IE) { - var A = I.A; - IE.A = A; - var C = I.C; - IE.C = C; - var D = I.D; - IE.D = D; + const A = IE.A = I.A; + const C = IE.C = I.C; + const D = IE.D = I.D; })(IE || (IE = {})); diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/1/input.ts b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/1/input.ts new file mode 100644 index 0000000000000..2a46ff99c21ed --- /dev/null +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/1/input.ts @@ -0,0 +1,23 @@ +namespace X1 { + console.log(1); +} + +export namespace X2 { + console.log(2); +} + +namespace X3 { + namespace X4 { + console.log(4); + } +} + +namespace X5 { + export namespace X6 { + console.log(6); + } +} + +namespace X7.X8 { + console.log(8); +} diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/1/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/1/output.js new file mode 100644 index 0000000000000..4583907a6fb51 --- /dev/null +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/1/output.js @@ -0,0 +1,28 @@ +var X1; +(function(X1) { + console.log(1); +})(X1 || (X1 = {})); +export var X2; +(function(X2) { + console.log(2); +})(X2 || (X2 = {})); +var X3; +(function(X3) { + let X4; + (function(X4) { + console.log(4); + })(X4 || (X4 = {})); +})(X3 || (X3 = {})); +var X5; +(function(X5) { + let X6; + (function(X6) { + console.log(6); + })(X6 = X5.X6 || (X5.X6 = {})); +})(X5 || (X5 = {})); +var X7; +(function(X7) { + (function(X8) { + console.log(8); + })(X7.X8 || (X7.X8 = {})); +})(X7 || (X7 = {})); diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/2/input.ts b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/2/input.ts new file mode 100644 index 0000000000000..240d59b176f46 --- /dev/null +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/2/input.ts @@ -0,0 +1,17 @@ +class X1 {} + +namespace X1 { + console.log(1); +} + +function X2() {} + +namespace X2 { + console.log(2); +} + +enum X3 {} + +namespace X3 { + console.log(3); +} diff --git a/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/2/output.js b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/2/output.js new file mode 100644 index 0000000000000..04ed1dc7e3435 --- /dev/null +++ b/crates/swc_ecma_transforms_typescript/tests/fixture/namespace/2/output.js @@ -0,0 +1,17 @@ +class X1 { +} +(function (X1) { + console.log(1); +})(X1 || (X1 = {})); + +function X2() { } +(function (X2) { + console.log(2); +})(X2 || (X2 = {})); + +var X3; +(function (X3) { +})(X3 || (X3 = {})); +(function (X3) { + console.log(3); +})(X3 || (X3 = {})); diff --git a/crates/swc_ecma_transforms_typescript/tests/strip.rs b/crates/swc_ecma_transforms_typescript/tests/strip.rs index 549a7ee9a6294..27f3c0617ee7c 100644 --- a/crates/swc_ecma_transforms_typescript/tests/strip.rs +++ b/crates/swc_ecma_transforms_typescript/tests/strip.rs @@ -12,7 +12,9 @@ use swc_ecma_transforms_compat::{ }; use swc_ecma_transforms_proposal::decorators; use swc_ecma_transforms_testing::{test, test_exec, test_fixture, Tester}; -use swc_ecma_transforms_typescript::{strip, strip::strip_with_config, TsImportExportAssignConfig}; +use swc_ecma_transforms_typescript::{ + typescript, ImportsNotUsedAsValues, TsImportExportAssignConfig, +}; use swc_ecma_visit::Fold; fn tr() -> impl Fold { @@ -20,14 +22,14 @@ fn tr() -> impl Fold { } fn tr_config( - config: Option, + config: Option, decorators_config: Option, use_define_for_class_fields: bool, ) -> impl Fold { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); let has_decorators = decorators_config.is_some(); - let config = config.unwrap_or_else(|| strip::Config { + let config = config.unwrap_or_else(|| typescript::Config { no_empty_export: true, ..Default::default() }); @@ -38,7 +40,7 @@ fn tr_config( has_decorators, ), resolver(unresolved_mark, top_level_mark, true), - strip_with_config(config, top_level_mark), + typescript(config, top_level_mark), Optional::new(class_fields_use_set(true), !use_define_for_class_fields), ) } @@ -261,9 +263,9 @@ test!( r#" var StateNum; (function (StateNum) { - StateNum["closed"] = 'cl0'; - StateNum["opened"] = 'op1'; - StateNum["mounted"] = 'mo2'; + StateNum["closed"] = "cl0"; + StateNum["opened"] = "op1"; + StateNum["mounted"] = "mo2"; })(StateNum || (StateNum = {})); "#, ok_if_code_eq @@ -3065,9 +3067,9 @@ test!( }), |_| { tr_config( - Some(strip::Config { + Some(typescript::Config { no_empty_export: true, - import_not_used_as_values: strip::ImportsNotUsedAsValues::Preserve, + import_not_used_as_values: ImportsNotUsedAsValues::Preserve, ..Default::default() }), None, @@ -3105,14 +3107,14 @@ test!( |_| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); - let config = strip::Config { + let config = typescript::Config { no_empty_export: true, ..Default::default() }; chain!( Optional::new(decorators(Default::default()), false,), resolver(unresolved_mark, top_level_mark, true), - strip_with_config(config, top_level_mark), + typescript(config, top_level_mark), async_to_generator::(Default::default(), None, unresolved_mark), ) }, @@ -3210,7 +3212,7 @@ test!( test!( Syntax::Typescript(Default::default()), |_| tr_config( - Some(strip::Config { + Some(typescript::Config { no_empty_export: true, ..Default::default() }), @@ -3350,13 +3352,13 @@ to!( throw new Error(); } util.assertNever = assertNever; - var arrayToEnum = util.arrayToEnum = (items)=>{ + const arrayToEnum = util.arrayToEnum = (items)=>{ }; - var getValidEnumValues = util.getValidEnumValues = (obj)=>{ + const getValidEnumValues = util.getValidEnumValues = (obj)=>{ }; - var getValues = util.getValues = (obj)=>{ + const getValues = util.getValues = (obj)=>{ }; - var objectValues = util.objectValues = (obj)=>{ + const objectValues = util.objectValues = (obj)=>{ }; })(util || (util = {})); " @@ -3374,7 +3376,7 @@ to!( export var util; (function (util) { const c = 3; - [util.a, util.b] = [1, 2, 3]; + const [a, b] = [util.a, util.b] = [1, 2, 3]; })(util || (util = {})); " ); @@ -3419,10 +3421,9 @@ to!( " var Test; (function (Test) { - let Inner; (function (Inner) { - var c = Inner.c = 3; - })(Inner = Test.Inner || (Test.Inner = {})); + const c = Inner.c = 3; + })(Test.Inner || (Test.Inner = {})); })(Test || (Test = {})); " ); @@ -3476,7 +3477,7 @@ to!( })(MyEnum = MyNamespace.MyEnum || (MyNamespace.MyEnum = {})); let MyInnerNamespace; (function (MyInnerNamespace) { - var Dec2 = MyInnerNamespace.Dec2 = 2; + const Dec2 = MyInnerNamespace.Dec2 = 2; })(MyInnerNamespace = MyNamespace.MyInnerNamespace || (MyNamespace.MyInnerNamespace = {})); })(MyNamespace || (MyNamespace = {})); (function (MyNamespace) { @@ -3510,10 +3511,9 @@ to!( })(A || (A = {})); var B; (function (B) { - var a = A; - B.a = a; + const a = B.a = A; console.log(a.Test); - var b = A; + const b = A; console.log(b.Test); })(B || (B = {})); "# @@ -3598,7 +3598,7 @@ to!( test_with_config!( issue_1472_1_define, - strip::Config { + typescript::Config { no_empty_export: true, ..Default::default() }, @@ -3625,7 +3625,7 @@ test_with_config!( test_with_config!( issue_1472_1_no_define, - strip::Config { + typescript::Config { no_empty_export: true, ..Default::default() }, @@ -3713,12 +3713,11 @@ to!( " export class A { } - (function(A1) { + (function(A) { class B extends A { } - A1.B = B; - })(A || (A = { - })); + A.B = B; + })(A || (A = {})); " ); @@ -3732,15 +3731,12 @@ to!( ", " export var A; - (function(A1) { + (function(A) { class B extends A { } - A1.B = B; - })(A || (A = { - })); - (function(A) { - })(A || (A = { - })); + A.B = B; + })(A || (A = {})); + (function(A) {})(A || (A = {})); " ); @@ -3945,18 +3941,19 @@ to!( " ); -to!( - import_shadow_hoist, - " - const Test = 2; - console.log(Test); - import { Test } from 'test'; - ", - " - const Test = 2; - console.log(Test); - " -); +// invalid test +// to!( +// import_shadow_hoist, +// " +// const Test = 2; +// console.log(Test); +// import { Test } from 'test'; +// ", +// " +// const Test = 2; +// console.log(Test); +// " +// ); to!( import_shadow_hoist_type, @@ -4223,7 +4220,7 @@ to!( ", " import * as mongo from 'https://deno.land/x/mongo@v0.27.0/mod.ts'; - var MongoClient = mongo.MongoClient; + const MongoClient = mongo.MongoClient; const mongoClient = new MongoClient(); " ); @@ -4236,13 +4233,14 @@ to!( const mongoClient: MongoClient = {}; ", " + import * as mongo from 'https://deno.land/x/mongo@v0.27.0/mod.ts'; const mongoClient = {}; " ); test_with_config!( deno_12532_declare_class_prop, - strip::Config { + typescript::Config { no_empty_export: true, ..Default::default() }, @@ -4295,11 +4293,11 @@ to!( Aqua = '#00ffff', Cyan = Aqua, }", - "var Color; + r##"var Color; (function (Color) { - Color[\"Aqua\"] = '#00ffff'; - Color[\"Cyan\"] = '#00ffff'; -})(Color || (Color = {}));" + Color["Aqua"] = "#00ffff"; + Color["Cyan"] = "#00ffff"; +})(Color || (Color = {}));"## ); to!( @@ -4414,18 +4412,18 @@ let b = class { } ", " -let _console_log; -let _console_log1 = console.log(123); +let _console_log = console.log(123); class A { constructor(a = 1){ this.a = a; - this[_console_log1] = 456; + this[_console_log] = 456; } } -let b = (_console_log = console.log(456), class { +let _console_log1; +let b = (_console_log1 = console.log(456), class { constructor(a = 1){ this.a = a; - this[_console_log] = 123; + this[_console_log1] = 123; } }); " @@ -4441,8 +4439,7 @@ test!( foo(); "#, r#" - const foo = require("foo"); - exports.foo = foo; + const foo = exports.foo = require("foo"); foo(); "# ); @@ -4450,7 +4447,7 @@ test!( test!( Syntax::Typescript(TsConfig::default()), |_| tr_config( - Some(strip::Config { + Some(typescript::Config { import_export_assign_config: TsImportExportAssignConfig::NodeNext, ..Default::default() }), @@ -4475,7 +4472,7 @@ test!( test!( Syntax::Typescript(TsConfig::default()), |_| tr_config( - Some(strip::Config { + Some(typescript::Config { import_export_assign_config: TsImportExportAssignConfig::NodeNext, ..Default::default() }), @@ -4491,8 +4488,7 @@ test!( r#" import { createRequire as _createRequire } from "module"; const __require = _createRequire(import.meta.url); - const foo = __require("foo"); - export { foo }; + export const foo = __require("foo"); foo(); "# diff --git a/crates/swc_ecma_transforms_typescript/tests/strip_correctness.rs b/crates/swc_ecma_transforms_typescript/tests/strip_correctness.rs index 21f42d1011378..3f8d808ad4de2 100644 --- a/crates/swc_ecma_transforms_typescript/tests/strip_correctness.rs +++ b/crates/swc_ecma_transforms_typescript/tests/strip_correctness.rs @@ -9,7 +9,7 @@ use swc_ecma_ast::*; use swc_ecma_codegen::{self, Emitter}; use swc_ecma_parser::{lexer::Lexer, EsConfig, Parser, Syntax, TsConfig}; use swc_ecma_transforms_base::{fixer::fixer, hygiene::hygiene, resolver}; -use swc_ecma_transforms_typescript::{strip, strip::strip_with_config}; +use swc_ecma_transforms_typescript::typescript; use swc_ecma_visit::{Fold, FoldWith}; #[testing::fixture("../swc_ecma_parser/tests/tsc/**/*.ts")] @@ -200,14 +200,15 @@ fn identity(entry: PathBuf) { }; // Parse source - let module = parser + let program = parser .parse_typescript_module() .map(|p| { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); - p.fold_with(&mut resolver(unresolved_mark, top_level_mark, true)) - .fold_with(&mut strip_with_config( - strip::Config { + Program::Module(p) + .fold_with(&mut resolver(unresolved_mark, top_level_mark, true)) + .fold_with(&mut typescript( + typescript::Config { no_empty_export: true, ..Default::default() }, @@ -221,7 +222,7 @@ fn identity(entry: PathBuf) { e.into_diagnostic(handler).emit(); })?; - emitter.emit_module(&module).unwrap(); + emitter.emit_program(&program).unwrap(); } let js_content = String::from_utf8_lossy(&wr.0.read().unwrap()).to_string();