From a09a57102e27fa410b8ecf94333b961b0a2fe5be Mon Sep 17 00:00:00 2001 From: austaras Date: Fri, 21 Jul 2023 16:19:01 +0800 Subject: [PATCH 1/3] refact(es/minifier): Respect `TopLevel` when invoke IIFE --- .../fixture/issues-2xxx/2679/output/index.js | 6 +- .../issues-3xxx/3126/1/output/index.js | 29 +- .../full/firebase/dist/1/output/index.js | 177 ++- .../src/compress/optimize/iife.rs | 4 +- .../src/compress/optimize/inline.rs | 1 + .../src/compress/optimize/mod.rs | 15 +- .../src/compress/optimize/ops.rs | 4 + .../fixture/issues/2011/actual/output.js | 47 +- .../fixture/issues/emotion/react/2/output.js | 11 +- .../fixture/issues/typescript/1/output.js | 1017 ++++++++--------- .../tests/fixture/pr/7688/input.js | 5 + .../tests/fixture/pr/7688/output.js | 3 + 12 files changed, 655 insertions(+), 664 deletions(-) create mode 100644 crates/swc_ecma_minifier/tests/fixture/pr/7688/input.js create mode 100644 crates/swc_ecma_minifier/tests/fixture/pr/7688/output.js diff --git a/crates/swc/tests/fixture/issues-2xxx/2679/output/index.js b/crates/swc/tests/fixture/issues-2xxx/2679/output/index.js index 59aac12faf39..737ba0491b39 100644 --- a/crates/swc/tests/fixture/issues-2xxx/2679/output/index.js +++ b/crates/swc/tests/fixture/issues-2xxx/2679/output/index.js @@ -1,4 +1,2 @@ -!function() { - var a = {}; - a.b = 1, a = null, window.test = a; -}(); +var a; +(a = {}).b = 1, a = null, window.test = a; diff --git a/crates/swc/tests/fixture/issues-3xxx/3126/1/output/index.js b/crates/swc/tests/fixture/issues-3xxx/3126/1/output/index.js index 88e961d8f6a2..29c2ecda249b 100644 --- a/crates/swc/tests/fixture/issues-3xxx/3126/1/output/index.js +++ b/crates/swc/tests/fixture/issues-3xxx/3126/1/output/index.js @@ -1,17 +1,14 @@ -!function() { - __webpack_require__.m = { - 746: function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__1) { - Object.prototype.hasOwnProperty; - } - }, __webpack_require__.O = function(result, chunkIds, fn, priority) { - for(var j = 0; j < chunkIds.length; j++)Object.keys(__webpack_require__.O).every(function(key) { - return __webpack_require__.O[key](chunkIds[j]); - }); - }; - var __webpack_exports__ = __webpack_require__.O(void 0, [ - 532 - ], function() { - return __webpack_require__(746); +var __webpack_exports__; +__webpack_require__.m = { + 746: function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__1) { + Object.prototype.hasOwnProperty; + } +}, __webpack_require__.O = function(result, chunkIds, fn, priority) { + for(var j = 0; j < chunkIds.length; j++)Object.keys(__webpack_require__.O).every(function(key) { + return __webpack_require__.O[key](chunkIds[j]); }); - __webpack_exports__ = __webpack_require__.O(__webpack_exports__); -}(); +}, __webpack_exports__ = __webpack_require__.O(void 0, [ + 532 +], function() { + return __webpack_require__(746); +}), __webpack_exports__ = __webpack_require__.O(__webpack_exports__); diff --git a/crates/swc/tests/vercel/full/firebase/dist/1/output/index.js b/crates/swc/tests/vercel/full/firebase/dist/1/output/index.js index 167d4ada9b50..baf30a2b0839 100644 --- a/crates/swc/tests/vercel/full/firebase/dist/1/output/index.js +++ b/crates/swc/tests/vercel/full/firebase/dist/1/output/index.js @@ -1,4 +1,4 @@ -var e, t = require("@firebase/util"), n = require("tslib"), r = require("@firebase/component"), i = require("@firebase/app"), a = require("@firebase/logger"), o = function(e) { +var e, t, n = require("@firebase/util"), r = require("tslib"), i = require("@firebase/component"), a = require("@firebase/app"), o = require("@firebase/logger"), p = function(e) { if (e && e.__esModule) return e; var t = Object.create(null); return e && Object.keys(e).forEach(function(n) { @@ -12,94 +12,91 @@ var e, t = require("@firebase/util"), n = require("tslib"), r = require("@fireba }); } }), t.default = e, Object.freeze(t); -}(i), p = function() { - var e = function(e, t) { - var n = this; - this._delegate = e, this.firebase = t, i._addComponent(e, new r.Component("app-compat", function() { - return n; - }, "PUBLIC")), this.container = e.container; +}(a), s = (Object.defineProperty((e = function(e, t) { + var n = this; + this._delegate = e, this.firebase = t, a._addComponent(e, new i.Component("app-compat", function() { + return n; + }, "PUBLIC")), this.container = e.container; +}).prototype, "automaticDataCollectionEnabled", { + get: function() { + return this._delegate.automaticDataCollectionEnabled; + }, + set: function(e) { + this._delegate.automaticDataCollectionEnabled = e; + }, + enumerable: !1, + configurable: !0 +}), Object.defineProperty(e.prototype, "name", { + get: function() { + return this._delegate.name; + }, + enumerable: !1, + configurable: !0 +}), Object.defineProperty(e.prototype, "options", { + get: function() { + return this._delegate.options; + }, + enumerable: !1, + configurable: !0 +}), e.prototype.delete = function() { + var e = this; + return new Promise(function(t) { + e._delegate.checkDestroyed(), t(); + }).then(function() { + return e.firebase.INTERNAL.removeApp(e.name), a.deleteApp(e._delegate); + }); +}, e.prototype._getService = function(e, t) { + void 0 === t && (t = a._DEFAULT_ENTRY_NAME), this._delegate.checkDestroyed(); + var n, r = this._delegate.container.getProvider(e); + return r.isInitialized() || (null === (n = r.getComponent()) || void 0 === n ? void 0 : n.instantiationMode) !== "EXPLICIT" || r.initialize(), r.getImmediate({ + identifier: t + }); +}, e.prototype._removeServiceInstance = function(e, t) { + void 0 === t && (t = a._DEFAULT_ENTRY_NAME), this._delegate.container.getProvider(e).clearInstance(t); +}, e.prototype._addComponent = function(e) { + a._addComponent(this._delegate, e); +}, e.prototype._addOrOverwriteComponent = function(e) { + a._addOrOverwriteComponent(this._delegate, e); +}, e.prototype.toJSON = function() { + return { + name: this.name, + automaticDataCollectionEnabled: this.automaticDataCollectionEnabled, + options: this.options }; - return Object.defineProperty(e.prototype, "automaticDataCollectionEnabled", { - get: function() { - return this._delegate.automaticDataCollectionEnabled; - }, - set: function(e) { - this._delegate.automaticDataCollectionEnabled = e; - }, - enumerable: !1, - configurable: !0 - }), Object.defineProperty(e.prototype, "name", { - get: function() { - return this._delegate.name; - }, - enumerable: !1, - configurable: !0 - }), Object.defineProperty(e.prototype, "options", { - get: function() { - return this._delegate.options; - }, - enumerable: !1, - configurable: !0 - }), e.prototype.delete = function() { - var e = this; - return new Promise(function(t) { - e._delegate.checkDestroyed(), t(); - }).then(function() { - return e.firebase.INTERNAL.removeApp(e.name), i.deleteApp(e._delegate); - }); - }, e.prototype._getService = function(e, t) { - void 0 === t && (t = i._DEFAULT_ENTRY_NAME), this._delegate.checkDestroyed(); - var n, r = this._delegate.container.getProvider(e); - return r.isInitialized() || (null === (n = r.getComponent()) || void 0 === n ? void 0 : n.instantiationMode) !== "EXPLICIT" || r.initialize(), r.getImmediate({ - identifier: t - }); - }, e.prototype._removeServiceInstance = function(e, t) { - void 0 === t && (t = i._DEFAULT_ENTRY_NAME), this._delegate.container.getProvider(e).clearInstance(t); - }, e.prototype._addComponent = function(e) { - i._addComponent(this._delegate, e); - }, e.prototype._addOrOverwriteComponent = function(e) { - i._addOrOverwriteComponent(this._delegate, e); - }, e.prototype.toJSON = function() { - return { - name: this.name, - automaticDataCollectionEnabled: this.automaticDataCollectionEnabled, - options: this.options - }; - }, e; -}(), s = ((e = {})["no-app"] = "No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()", e["invalid-app-argument"] = "firebase.{$appName}() takes either no argument or a Firebase App instance.", e), c = new t.ErrorFactory("app-compat", "Firebase", s), u = function e() { - var r, i, a, s = (r = function(e) { - if (e = e || o._DEFAULT_ENTRY_NAME, !t.contains(i, e)) throw c.create("no-app", { +}, e), c = ((t = {})["no-app"] = "No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()", t["invalid-app-argument"] = "firebase.{$appName}() takes either no argument or a Firebase App instance.", t), u = new n.ErrorFactory("app-compat", "Firebase", c), l = function e() { + var t, i, a, o = (t = function(e) { + if (e = e || p._DEFAULT_ENTRY_NAME, !n.contains(i, e)) throw u.create("no-app", { appName: e }); return i[e]; }, i = {}, (a = { __esModule: !0, - initializeApp: function(e, n) { - void 0 === n && (n = {}); - var r = o.initializeApp(e, n); - if (t.contains(i, r.name)) return i[r.name]; - var s = new p(r, a); - return i[r.name] = s, s; + initializeApp: function(e, t) { + void 0 === t && (t = {}); + var r = p.initializeApp(e, t); + if (n.contains(i, r.name)) return i[r.name]; + var o = new s(r, a); + return i[r.name] = o, o; }, - app: r, - registerVersion: o.registerVersion, - setLogLevel: o.setLogLevel, - onLog: o.onLog, + app: t, + registerVersion: p.registerVersion, + setLogLevel: p.setLogLevel, + onLog: p.onLog, apps: null, - SDK_VERSION: o.SDK_VERSION, + SDK_VERSION: p.SDK_VERSION, INTERNAL: { registerComponent: function(e) { - var n = e.name, i = n.replace("-compat", ""); - if (o._registerComponent(e) && "PUBLIC" === e.type) { - var s = function(e) { - if (void 0 === e && (e = r()), "function" != typeof e[i]) throw c.create("invalid-app-argument", { - appName: n + var r = e.name, i = r.replace("-compat", ""); + if (p._registerComponent(e) && "PUBLIC" === e.type) { + var o = function(e) { + if (void 0 === e && (e = t()), "function" != typeof e[i]) throw u.create("invalid-app-argument", { + appName: r }); return e[i](); }; - void 0 !== e.serviceProps && t.deepExtend(s, e.serviceProps), a[i] = s, p.prototype[i] = function() { - for(var t = [], r = 0; r < arguments.length; r++)t[r] = arguments[r]; - return this._getService.bind(this, n).apply(this, e.multipleInstances ? t : []); + void 0 !== e.serviceProps && n.deepExtend(o, e.serviceProps), a[i] = o, s.prototype[i] = function() { + for(var t = [], n = 0; n < arguments.length; n++)t[n] = arguments[n]; + return this._getService.bind(this, r).apply(this, e.multipleInstances ? t : []); }; } return "PUBLIC" === e.type ? a[i] : null; @@ -110,7 +107,7 @@ var e, t = require("@firebase/util"), n = require("tslib"), r = require("@fireba useAsService: function(e, t) { return "serverAuth" === t ? null : t; }, - modularAPIs: o + modularAPIs: p } }).default = a, Object.defineProperty(a, "apps", { get: function() { @@ -118,20 +115,20 @@ var e, t = require("@firebase/util"), n = require("tslib"), r = require("@fireba return i[e]; }); } - }), r.App = p, a); - return s.INTERNAL = n.__assign(n.__assign({}, s.INTERNAL), { + }), t.App = s, a); + return o.INTERNAL = r.__assign(r.__assign({}, o.INTERNAL), { createFirebaseNamespace: e, extendNamespace: function(e) { - t.deepExtend(s, e); + n.deepExtend(o, e); }, - createSubscribe: t.createSubscribe, - ErrorFactory: t.ErrorFactory, - deepExtend: t.deepExtend - }), s; -}(), l = new a.Logger("@firebase/app-compat"); -if (t.isBrowser() && void 0 !== self.firebase) { - l.warn("\n Warning: Firebase is already defined in the global scope. Please make sure\n Firebase library is only loaded once.\n "); - var d = self.firebase.SDK_VERSION; - d && d.indexOf("LITE") >= 0 && l.warn("\n Warning: You are trying to load Firebase while using Firebase Performance standalone script.\n You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.\n "); + createSubscribe: n.createSubscribe, + ErrorFactory: n.ErrorFactory, + deepExtend: n.deepExtend + }), o; +}(), d = new o.Logger("@firebase/app-compat"); +if (n.isBrowser() && void 0 !== self.firebase) { + d.warn("\n Warning: Firebase is already defined in the global scope. Please make sure\n Firebase library is only loaded once.\n "); + var f = self.firebase.SDK_VERSION; + f && f.indexOf("LITE") >= 0 && d.warn("\n Warning: You are trying to load Firebase while using Firebase Performance standalone script.\n You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.\n "); } -i.registerVersion("@firebase/app-compat", "0.1.5", void 0), module.exports = u; +a.registerVersion("@firebase/app-compat", "0.1.5", void 0), module.exports = l; diff --git a/crates/swc_ecma_minifier/src/compress/optimize/iife.rs b/crates/swc_ecma_minifier/src/compress/optimize/iife.rs index 75a35723f0a5..0a808a2cbce8 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/iife.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/iife.rs @@ -464,7 +464,7 @@ impl Optimizer<'_> { return; } - if self.ctx.in_top_level() && !self.ctx.in_call_arg && self.options.negate_iife { + if !self.may_add_ident() { match &*f.body { BlockStmtOrExpr::BlockStmt(body) => { let has_decl = @@ -583,7 +583,7 @@ impl Optimizer<'_> { Expr::Fn(f) => { trace_op!("iife: Expr::Fn(..)"); - if self.ctx.in_top_level() && !self.ctx.in_call_arg && self.options.negate_iife { + if !self.may_add_ident() { let body = f.function.body.as_ref().unwrap(); let has_decl = body.stmts.iter().any(|stmt| matches!(stmt, Stmt::Decl(..))); if has_decl { diff --git a/crates/swc_ecma_minifier/src/compress/optimize/inline.rs b/crates/swc_ecma_minifier/src/compress/optimize/inline.rs index 162f95ca5041..8dcca0954e7e 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/inline.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/inline.rs @@ -238,6 +238,7 @@ impl Optimizer<'_> { && !(usage.has_property_mutation || usage.executed_multiple_time || usage.used_as_arg && ref_count > 1) + && ref_count - 1 <= usage.callee_count } _ => false, } diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 8e12f45e2220..583394229f29 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -118,7 +118,6 @@ struct Ctx { /// `true` only for [Callee::Expr]. is_callee: bool, - in_call_arg: bool, var_kind: Option, @@ -644,17 +643,17 @@ impl Optimizer<'_> { } } - fn remove_invalid(&mut self, e: &mut Expr) { + fn remove_invalid_bin(&mut self, e: &mut Expr) { if let Expr::Bin(BinExpr { left, right, .. }) = e { - self.remove_invalid(left); - self.remove_invalid(right); + self.remove_invalid_bin(left); + self.remove_invalid_bin(right); if left.is_invalid() { *e = *right.take(); - self.remove_invalid(e); + self.remove_invalid_bin(e); } else if right.is_invalid() { *e = *left.take(); - self.remove_invalid(e); + self.remove_invalid_bin(e); } } } @@ -1615,7 +1614,6 @@ impl VisitMut for Optimizer<'_> { { let ctx = Ctx { - in_call_arg: true, is_this_aware_callee: false, is_lhs_of_assign: false, is_exact_lhs_of_assign: false, @@ -1796,7 +1794,7 @@ impl VisitMut for Optimizer<'_> { debug_assert_valid(e); } - self.remove_invalid(e); + self.remove_invalid_bin(e); if e.is_seq() { debug_assert_valid(e); @@ -2298,7 +2296,6 @@ impl VisitMut for Optimizer<'_> { { let ctx = Ctx { - in_call_arg: true, is_exact_lhs_of_assign: false, is_lhs_of_assign: false, ..self.ctx diff --git a/crates/swc_ecma_minifier/src/compress/optimize/ops.rs b/crates/swc_ecma_minifier/src/compress/optimize/ops.rs index 67f28a383da9..aa4133852ccf 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/ops.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/ops.rs @@ -30,6 +30,10 @@ impl Optimizer<'_> { e.op == op!("===") || e.op == op!("=="), )); e.right.take(); + + self.changed = true; + report_change!("Evaluate comparing to self"); + return; } _ => {} diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/2011/actual/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/2011/actual/output.js index e303d2648a62..7dd112b9b6a6 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/2011/actual/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/2011/actual/output.js @@ -1,3 +1,4 @@ +var ClassB, value; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) throw TypeError("Cannot call a class as a function"); } @@ -7,30 +8,26 @@ function _defineProperties(target, props) { descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor); } } -var ClassA = function ClassA() { +module.exports = (ClassB = function() { "use strict"; - _classCallCheck(this, ClassA); -}; -module.exports = function() { - var ClassB = function() { - "use strict"; - var protoProps, staticProps; - function ClassB() { - _classCallCheck(this, ClassB); - } - return protoProps = [ - { - key: "it", - value: function() { - this.bb = new ClassB.MyA(); - } + var protoProps, staticProps; + function ClassB() { + _classCallCheck(this, ClassB); + } + return protoProps = [ + { + key: "it", + value: function() { + this.bb = new ClassB.MyA(); } - ], _defineProperties(ClassB.prototype, protoProps), staticProps && _defineProperties(ClassB, staticProps), ClassB; - }(); - return "MyA" in ClassB ? Object.defineProperty(ClassB, "MyA", { - value: ClassA, - enumerable: !0, - configurable: !0, - writable: !0 - }) : ClassB.MyA = ClassA, ClassB; -}(); + } + ], _defineProperties(ClassB.prototype, protoProps), staticProps && _defineProperties(ClassB, staticProps), ClassB; +}(), value = function ClassA() { + "use strict"; + _classCallCheck(this, ClassA); +}, "MyA" in ClassB ? Object.defineProperty(ClassB, "MyA", { + value: value, + enumerable: !0, + configurable: !0, + writable: !0 +}) : ClassB.MyA = value, ClassB); diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/2/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/2/output.js index f7b022b9e1eb..afe5929aa650 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/2/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/2/output.js @@ -1,4 +1,4 @@ -var cursor, hyphenateRegex = /[A-Z]|^ms/g, animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g, unitless_browser_esm = { +var cache, cursor, hyphenateRegex = /[A-Z]|^ms/g, animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g, unitless_browser_esm = { animationIterationCount: 1, borderImageOutset: 1, borderImageSlice: 1, @@ -128,13 +128,8 @@ export function serializeStyles(args, registered, mergedProps) { function isProcessableValue(value) { return null != value && "boolean" != typeof value; } -var processStyleName = function(fn) { - var cache = Object.create(null); - return function(arg) { - return void 0 === cache[arg] && (cache[arg] = fn(arg)), cache[arg]; - }; -}(function(styleName) { - return isCustomProperty(styleName) ? styleName : styleName.replace(hyphenateRegex, "-$&").toLowerCase(); +var processStyleName = (cache = Object.create(null), function(arg) { + return void 0 === cache[arg] && (cache[arg] = isCustomProperty(arg) ? arg : arg.replace(hyphenateRegex, "-$&").toLowerCase()), cache[arg]; }), processStyleValue = function(key, value) { switch(key){ case "animation": diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/typescript/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/typescript/1/output.js index 4f43fd3bcc13..225688a1f604 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/typescript/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/typescript/1/output.js @@ -1,548 +1,545 @@ -var ts; -!function(ts) { - ts.transformModule = function(context) { - var currentSourceFile, currentModuleInfo, needUMDDynamicImportHelper, factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, compilerOptions = context.getCompilerOptions(), resolver = context.getEmitResolver(), host = context.getEmitHost(), languageVersion = ts.getEmitScriptTarget(compilerOptions), moduleKind = ts.getEmitModuleKind(compilerOptions), previousOnSubstituteNode = context.onSubstituteNode, previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = function(hint, node) { - return (node = previousOnSubstituteNode(hint, node)).id && noSubstitution[node.id] ? node : 1 === hint ? function(node) { - switch(node.kind){ - case 79: - return substituteExpressionIdentifier(node); - case 207: - return function(node) { - if (ts.isIdentifier(node.expression)) { - var expression = substituteExpressionIdentifier(node.expression); - if (noSubstitution[ts.getNodeId(expression)] = !0, !ts.isIdentifier(expression) && !(4096 & ts.getEmitFlags(node.expression))) return ts.addEmitFlags(factory.updateCallExpression(node, expression, void 0, node.arguments), 536870912); - } - return node; - }(node); - case 209: - return function(node) { - if (ts.isIdentifier(node.tag)) { - var tag = substituteExpressionIdentifier(node.tag); - if (noSubstitution[ts.getNodeId(tag)] = !0, !ts.isIdentifier(tag) && !(4096 & ts.getEmitFlags(node.tag))) return ts.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag, void 0, node.template), 536870912); - } - return node; - }(node); - case 220: - return function(node) { - if (ts.isAssignmentOperator(node.operatorToken.kind) && ts.isIdentifier(node.left) && !ts.isGeneratedIdentifier(node.left) && !ts.isLocalName(node.left) && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { - var exportedNames = getExports(node.left); - if (exportedNames) { - for(var expression = node, _i = 0; _i < exportedNames.length; _i++){ - var exportName = exportedNames[_i]; - noSubstitution[ts.getNodeId(expression)] = !0, expression = createExportExpression(exportName, expression, node); - } - return expression; +var ts, ts1, dynamicImportUMDHelper; +(ts1 = ts || (ts = {})).transformModule = function(context) { + var currentSourceFile, currentModuleInfo, needUMDDynamicImportHelper, factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, compilerOptions = context.getCompilerOptions(), resolver = context.getEmitResolver(), host = context.getEmitHost(), languageVersion = ts1.getEmitScriptTarget(compilerOptions), moduleKind = ts1.getEmitModuleKind(compilerOptions), previousOnSubstituteNode = context.onSubstituteNode, previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = function(hint, node) { + return (node = previousOnSubstituteNode(hint, node)).id && noSubstitution[node.id] ? node : 1 === hint ? function(node) { + switch(node.kind){ + case 79: + return substituteExpressionIdentifier(node); + case 207: + return function(node) { + if (ts1.isIdentifier(node.expression)) { + var expression = substituteExpressionIdentifier(node.expression); + if (noSubstitution[ts1.getNodeId(expression)] = !0, !ts1.isIdentifier(expression) && !(4096 & ts1.getEmitFlags(node.expression))) return ts1.addEmitFlags(factory.updateCallExpression(node, expression, void 0, node.arguments), 536870912); + } + return node; + }(node); + case 209: + return function(node) { + if (ts1.isIdentifier(node.tag)) { + var tag = substituteExpressionIdentifier(node.tag); + if (noSubstitution[ts1.getNodeId(tag)] = !0, !ts1.isIdentifier(tag) && !(4096 & ts1.getEmitFlags(node.tag))) return ts1.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag, void 0, node.template), 536870912); + } + return node; + }(node); + case 220: + return function(node) { + if (ts1.isAssignmentOperator(node.operatorToken.kind) && ts1.isIdentifier(node.left) && !ts1.isGeneratedIdentifier(node.left) && !ts1.isLocalName(node.left) && !ts1.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + for(var expression = node, _i = 0; _i < exportedNames.length; _i++){ + var exportName = exportedNames[_i]; + noSubstitution[ts1.getNodeId(expression)] = !0, expression = createExportExpression(exportName, expression, node); } + return expression; } - return node; - }(node); - } - return node; - }(node) : ts.isShorthandPropertyAssignment(node) ? function(node) { - var name = node.name, exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - if (node.objectAssignmentInitializer) { - var initializer = factory.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.setTextRange(factory.createPropertyAssignment(name, initializer), node); - } - return ts.setTextRange(factory.createPropertyAssignment(name, exportedOrImportedName), node); - } - return node; - }(node) : node; - }, context.onEmitNode = function(hint, node, emitCallback) { - 303 === node.kind ? (currentSourceFile = node, currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)], previousOnEmitNode(hint, node, emitCallback), currentSourceFile = void 0, currentModuleInfo = void 0) : previousOnEmitNode(hint, node, emitCallback); - }, context.enableSubstitution(207), context.enableSubstitution(209), context.enableSubstitution(79), context.enableSubstitution(220), context.enableSubstitution(295), context.enableEmitNotification(303); - var moduleInfoMap = [], deferredExports = [], noSubstitution = []; - return ts.chainBundle(context, function(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || 4194304 & node.transformFlags || ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions))) return node; - currentSourceFile = node, currentModuleInfo = ts.collectExternalModuleInfo(context, node, resolver, compilerOptions), moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo; - var updated = (function(moduleKind) { - switch(moduleKind){ - case ts.ModuleKind.AMD: - return transformAMDModule; - case ts.ModuleKind.UMD: - return transformUMDModule; - default: - return transformCommonJSModule; + } + return node; + }(node); + } + return node; + }(node) : ts1.isShorthandPropertyAssignment(node) ? function(node) { + var name = node.name, exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + if (node.objectAssignmentInitializer) { + var initializer = factory.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts1.setTextRange(factory.createPropertyAssignment(name, initializer), node); } - })(moduleKind)(node); - return currentSourceFile = void 0, currentModuleInfo = void 0, needUMDDynamicImportHelper = !1, updated; - }); - function shouldEmitUnderscoreUnderscoreESModule() { - return !!(!currentModuleInfo.exportEquals && ts.isExternalModule(currentSourceFile)); - } - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = [], ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || !compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile), statementOffset = factory.copyPrologue(node.statements, statements, ensureUseStrict && !ts.isJsonSourceFile(node), topLevelVisitor); - if (shouldEmitUnderscoreUnderscoreESModule() && ts.append(statements, createUnderscoreUnderscoreESModule()), ts.length(currentModuleInfo.exportedNames)) for(var i = 0; i < currentModuleInfo.exportedNames.length; i += 50)ts.append(statements, factory.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames.slice(i, i + 50), function(prev, nextId) { - return factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(ts.idText(nextId))), prev); - }, factory.createVoidZero()))); - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, ts.isStatement)), ts.addRange(statements, ts.visitNodes(node.statements, topLevelVisitor, ts.isStatement, statementOffset)), addExportEqualsIfNeeded(statements, !1), ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); - var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(statements), node.statements)); - return ts.addEmitHelpers(updated, context.readEmitHelpers()), updated; - } - function transformAMDModule(node) { - var define = factory.createIdentifier("define"), moduleName = ts.tryGetModuleNameFromFile(factory, node, host, compilerOptions), jsonSourceFile = ts.isJsonSourceFile(node) && node, _a = collectAsynchronousDependencies(node, !0), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames, updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray([ - factory.createExpressionStatement(factory.createCallExpression(define, void 0, __spreadArray(__spreadArray([], moduleName ? [ + return ts1.setTextRange(factory.createPropertyAssignment(name, exportedOrImportedName), node); + } + return node; + }(node) : node; + }, context.onEmitNode = function(hint, node, emitCallback) { + 303 === node.kind ? (currentSourceFile = node, currentModuleInfo = moduleInfoMap[ts1.getOriginalNodeId(currentSourceFile)], previousOnEmitNode(hint, node, emitCallback), currentSourceFile = void 0, currentModuleInfo = void 0) : previousOnEmitNode(hint, node, emitCallback); + }, context.enableSubstitution(207), context.enableSubstitution(209), context.enableSubstitution(79), context.enableSubstitution(220), context.enableSubstitution(295), context.enableEmitNotification(303); + var moduleInfoMap = [], deferredExports = [], noSubstitution = []; + return ts1.chainBundle(context, function(node) { + if (node.isDeclarationFile || !(ts1.isEffectiveExternalModule(node, compilerOptions) || 4194304 & node.transformFlags || ts1.isJsonSourceFile(node) && ts1.hasJsonModuleEmitEnabled(compilerOptions) && ts1.outFile(compilerOptions))) return node; + currentSourceFile = node, currentModuleInfo = ts1.collectExternalModuleInfo(context, node, resolver, compilerOptions), moduleInfoMap[ts1.getOriginalNodeId(node)] = currentModuleInfo; + var updated = (function(moduleKind) { + switch(moduleKind){ + case ts1.ModuleKind.AMD: + return transformAMDModule; + case ts1.ModuleKind.UMD: + return transformUMDModule; + default: + return transformCommonJSModule; + } + })(moduleKind)(node); + return currentSourceFile = void 0, currentModuleInfo = void 0, needUMDDynamicImportHelper = !1, updated; + }); + function shouldEmitUnderscoreUnderscoreESModule() { + return !!(!currentModuleInfo.exportEquals && ts1.isExternalModule(currentSourceFile)); + } + function transformCommonJSModule(node) { + startLexicalEnvironment(); + var statements = [], ensureUseStrict = ts1.getStrictOptionValue(compilerOptions, "alwaysStrict") || !compilerOptions.noImplicitUseStrict && ts1.isExternalModule(currentSourceFile), statementOffset = factory.copyPrologue(node.statements, statements, ensureUseStrict && !ts1.isJsonSourceFile(node), topLevelVisitor); + if (shouldEmitUnderscoreUnderscoreESModule() && ts1.append(statements, createUnderscoreUnderscoreESModule()), ts1.length(currentModuleInfo.exportedNames)) for(var i = 0; i < currentModuleInfo.exportedNames.length; i += 50)ts1.append(statements, factory.createExpressionStatement(ts1.reduceLeft(currentModuleInfo.exportedNames.slice(i, i + 50), function(prev, nextId) { + return factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(ts1.idText(nextId))), prev); + }, factory.createVoidZero()))); + ts1.append(statements, ts1.visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, ts1.isStatement)), ts1.addRange(statements, ts1.visitNodes(node.statements, topLevelVisitor, ts1.isStatement, statementOffset)), addExportEqualsIfNeeded(statements, !1), ts1.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); + var updated = factory.updateSourceFile(node, ts1.setTextRange(factory.createNodeArray(statements), node.statements)); + return ts1.addEmitHelpers(updated, context.readEmitHelpers()), updated; + } + function transformAMDModule(node) { + var define = factory.createIdentifier("define"), moduleName = ts1.tryGetModuleNameFromFile(factory, node, host, compilerOptions), jsonSourceFile = ts1.isJsonSourceFile(node) && node, _a = collectAsynchronousDependencies(node, !0), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames, updated = factory.updateSourceFile(node, ts1.setTextRange(factory.createNodeArray([ + factory.createExpressionStatement(factory.createCallExpression(define, void 0, __spreadArray(__spreadArray([], moduleName ? [ + moduleName + ] : [], !0), [ + factory.createArrayLiteralExpression(jsonSourceFile ? ts1.emptyArray : __spreadArray(__spreadArray([ + factory.createStringLiteral("require"), + factory.createStringLiteral("exports") + ], aliasedModuleNames, !0), unaliasedModuleNames, !0)), + jsonSourceFile ? jsonSourceFile.statements.length ? jsonSourceFile.statements[0].expression : factory.createObjectLiteralExpression() : factory.createFunctionExpression(void 0, void 0, void 0, void 0, __spreadArray([ + factory.createParameterDeclaration(void 0, void 0, void 0, "require"), + factory.createParameterDeclaration(void 0, void 0, void 0, "exports") + ], importAliasNames, !0), void 0, transformAsynchronousModuleBody(node)) + ], !1))) + ]), node.statements)); + return ts1.addEmitHelpers(updated, context.readEmitHelpers()), updated; + } + function transformUMDModule(node) { + var _a = collectAsynchronousDependencies(node, !1), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames, moduleName = ts1.tryGetModuleNameFromFile(factory, node, host, compilerOptions), umdHeader = factory.createFunctionExpression(void 0, void 0, void 0, void 0, [ + factory.createParameterDeclaration(void 0, void 0, void 0, "factory") + ], void 0, ts1.setTextRange(factory.createBlock([ + factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("module"), "object"), factory.createTypeCheck(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), "object")), factory.createBlock([ + factory.createVariableStatement(void 0, [ + factory.createVariableDeclaration("v", void 0, void 0, factory.createCallExpression(factory.createIdentifier("factory"), void 0, [ + factory.createIdentifier("require"), + factory.createIdentifier("exports") + ])) + ]), + ts1.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1) + ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([ + factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), void 0, __spreadArray(__spreadArray([], moduleName ? [ moduleName ] : [], !0), [ - factory.createArrayLiteralExpression(jsonSourceFile ? ts.emptyArray : __spreadArray(__spreadArray([ + factory.createArrayLiteralExpression(__spreadArray(__spreadArray([ factory.createStringLiteral("require"), factory.createStringLiteral("exports") ], aliasedModuleNames, !0), unaliasedModuleNames, !0)), - jsonSourceFile ? jsonSourceFile.statements.length ? jsonSourceFile.statements[0].expression : factory.createObjectLiteralExpression() : factory.createFunctionExpression(void 0, void 0, void 0, void 0, __spreadArray([ - factory.createParameterDeclaration(void 0, void 0, void 0, "require"), - factory.createParameterDeclaration(void 0, void 0, void 0, "exports") - ], importAliasNames, !0), void 0, transformAsynchronousModuleBody(node)) + factory.createIdentifier("factory") ], !1))) - ]), node.statements)); - return ts.addEmitHelpers(updated, context.readEmitHelpers()), updated; - } - function transformUMDModule(node) { - var _a = collectAsynchronousDependencies(node, !1), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames, moduleName = ts.tryGetModuleNameFromFile(factory, node, host, compilerOptions), umdHeader = factory.createFunctionExpression(void 0, void 0, void 0, void 0, [ - factory.createParameterDeclaration(void 0, void 0, void 0, "factory") - ], void 0, ts.setTextRange(factory.createBlock([ - factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("module"), "object"), factory.createTypeCheck(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), "object")), factory.createBlock([ - factory.createVariableStatement(void 0, [ - factory.createVariableDeclaration("v", void 0, void 0, factory.createCallExpression(factory.createIdentifier("factory"), void 0, [ - factory.createIdentifier("require"), - factory.createIdentifier("exports") - ])) - ]), - ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1) - ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([ - factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), void 0, __spreadArray(__spreadArray([], moduleName ? [ - moduleName - ] : [], !0), [ - factory.createArrayLiteralExpression(__spreadArray(__spreadArray([ - factory.createStringLiteral("require"), - factory.createStringLiteral("exports") - ], aliasedModuleNames, !0), unaliasedModuleNames, !0)), - factory.createIdentifier("factory") - ], !1))) - ]))) - ], !0), void 0)), updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray([ - factory.createExpressionStatement(factory.createCallExpression(umdHeader, void 0, [ - factory.createFunctionExpression(void 0, void 0, void 0, void 0, __spreadArray([ - factory.createParameterDeclaration(void 0, void 0, void 0, "require"), - factory.createParameterDeclaration(void 0, void 0, void 0, "exports") - ], importAliasNames, !0), void 0, transformAsynchronousModuleBody(node)) - ])) - ]), node.statements)); - return ts.addEmitHelpers(updated, context.readEmitHelpers()), updated; - } - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - for(var aliasedModuleNames = [], unaliasedModuleNames = [], importAliasNames = [], _i = 0, _a = node.amdDependencies; _i < _a.length; _i++){ - var amdDependency = _a[_i]; - amdDependency.name ? (aliasedModuleNames.push(factory.createStringLiteral(amdDependency.path)), importAliasNames.push(factory.createParameterDeclaration(void 0, void 0, void 0, amdDependency.name))) : unaliasedModuleNames.push(factory.createStringLiteral(amdDependency.path)); - } - for(var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++){ - var importNode = _c[_b], externalModuleName = ts.getExternalModuleNameLiteral(factory, importNode, currentSourceFile, host, resolver, compilerOptions), importAliasName = ts.getLocalNameForExternalImport(factory, importNode, currentSourceFile); - externalModuleName && (includeNonAmdDependencies && importAliasName ? (ts.setEmitFlags(importAliasName, 4), aliasedModuleNames.push(externalModuleName), importAliasNames.push(factory.createParameterDeclaration(void 0, void 0, void 0, importAliasName))) : unaliasedModuleNames.push(externalModuleName)); - } - return { - aliasedModuleNames: aliasedModuleNames, - unaliasedModuleNames: unaliasedModuleNames, - importAliasNames: importAliasNames - }; + ]))) + ], !0), void 0)), updated = factory.updateSourceFile(node, ts1.setTextRange(factory.createNodeArray([ + factory.createExpressionStatement(factory.createCallExpression(umdHeader, void 0, [ + factory.createFunctionExpression(void 0, void 0, void 0, void 0, __spreadArray([ + factory.createParameterDeclaration(void 0, void 0, void 0, "require"), + factory.createParameterDeclaration(void 0, void 0, void 0, "exports") + ], importAliasNames, !0), void 0, transformAsynchronousModuleBody(node)) + ])) + ]), node.statements)); + return ts1.addEmitHelpers(updated, context.readEmitHelpers()), updated; + } + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + for(var aliasedModuleNames = [], unaliasedModuleNames = [], importAliasNames = [], _i = 0, _a = node.amdDependencies; _i < _a.length; _i++){ + var amdDependency = _a[_i]; + amdDependency.name ? (aliasedModuleNames.push(factory.createStringLiteral(amdDependency.path)), importAliasNames.push(factory.createParameterDeclaration(void 0, void 0, void 0, amdDependency.name))) : unaliasedModuleNames.push(factory.createStringLiteral(amdDependency.path)); } - function getAMDImportExpressionForImport(node) { - if (!(ts.isImportEqualsDeclaration(node) || ts.isExportDeclaration(node)) && ts.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions)) { - var name = ts.getLocalNameForExternalImport(factory, node, currentSourceFile), expr = getHelperExpressionForImport(node, name); - if (expr !== name) return factory.createExpressionStatement(factory.createAssignment(name, expr)); - } + for(var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++){ + var importNode = _c[_b], externalModuleName = ts1.getExternalModuleNameLiteral(factory, importNode, currentSourceFile, host, resolver, compilerOptions), importAliasName = ts1.getLocalNameForExternalImport(factory, importNode, currentSourceFile); + externalModuleName && (includeNonAmdDependencies && importAliasName ? (ts1.setEmitFlags(importAliasName, 4), aliasedModuleNames.push(externalModuleName), importAliasNames.push(factory.createParameterDeclaration(void 0, void 0, void 0, importAliasName))) : unaliasedModuleNames.push(externalModuleName)); } - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = [], statementOffset = factory.copyPrologue(node.statements, statements, !compilerOptions.noImplicitUseStrict, topLevelVisitor); - shouldEmitUnderscoreUnderscoreESModule() && ts.append(statements, createUnderscoreUnderscoreESModule()), ts.length(currentModuleInfo.exportedNames) && ts.append(statements, factory.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames, function(prev, nextId) { - return factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(ts.idText(nextId))), prev); - }, factory.createVoidZero()))), ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, ts.isStatement)), moduleKind === ts.ModuleKind.AMD && ts.addRange(statements, ts.mapDefined(currentModuleInfo.externalImports, getAMDImportExpressionForImport)), ts.addRange(statements, ts.visitNodes(node.statements, topLevelVisitor, ts.isStatement, statementOffset)), addExportEqualsIfNeeded(statements, !0), ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); - var body = factory.createBlock(statements, !0); - return needUMDDynamicImportHelper && ts.addEmitHelper(body, dynamicImportUMDHelper), body; + return { + aliasedModuleNames: aliasedModuleNames, + unaliasedModuleNames: unaliasedModuleNames, + importAliasNames: importAliasNames + }; + } + function getAMDImportExpressionForImport(node) { + if (!(ts1.isImportEqualsDeclaration(node) || ts1.isExportDeclaration(node)) && ts1.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions)) { + var name = ts1.getLocalNameForExternalImport(factory, node, currentSourceFile), expr = getHelperExpressionForImport(node, name); + if (expr !== name) return factory.createExpressionStatement(factory.createAssignment(name, expr)); } - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (currentModuleInfo.exportEquals) { - var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, visitor); - if (expressionResult) { - if (emitAsReturn) { - var statement = factory.createReturnStatement(expressionResult); - ts.setTextRange(statement, currentModuleInfo.exportEquals), ts.setEmitFlags(statement, 1920), statements.push(statement); - } else { - var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult)); - ts.setTextRange(statement, currentModuleInfo.exportEquals), ts.setEmitFlags(statement, 1536), statements.push(statement); - } + } + function transformAsynchronousModuleBody(node) { + startLexicalEnvironment(); + var statements = [], statementOffset = factory.copyPrologue(node.statements, statements, !compilerOptions.noImplicitUseStrict, topLevelVisitor); + shouldEmitUnderscoreUnderscoreESModule() && ts1.append(statements, createUnderscoreUnderscoreESModule()), ts1.length(currentModuleInfo.exportedNames) && ts1.append(statements, factory.createExpressionStatement(ts1.reduceLeft(currentModuleInfo.exportedNames, function(prev, nextId) { + return factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(ts1.idText(nextId))), prev); + }, factory.createVoidZero()))), ts1.append(statements, ts1.visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, ts1.isStatement)), moduleKind === ts1.ModuleKind.AMD && ts1.addRange(statements, ts1.mapDefined(currentModuleInfo.externalImports, getAMDImportExpressionForImport)), ts1.addRange(statements, ts1.visitNodes(node.statements, topLevelVisitor, ts1.isStatement, statementOffset)), addExportEqualsIfNeeded(statements, !0), ts1.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); + var body = factory.createBlock(statements, !0); + return needUMDDynamicImportHelper && ts1.addEmitHelper(body, dynamicImportUMDHelper), body; + } + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (currentModuleInfo.exportEquals) { + var expressionResult = ts1.visitNode(currentModuleInfo.exportEquals.expression, visitor); + if (expressionResult) { + if (emitAsReturn) { + var statement = factory.createReturnStatement(expressionResult); + ts1.setTextRange(statement, currentModuleInfo.exportEquals), ts1.setEmitFlags(statement, 1920), statements.push(statement); + } else { + var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult)); + ts1.setTextRange(statement, currentModuleInfo.exportEquals), ts1.setEmitFlags(statement, 1536), statements.push(statement); } } } - function topLevelVisitor(node) { - switch(node.kind){ - case 265: - return function(node) { - var statements, namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) return ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createRequireCall(node)), node), node); - var variables = []; - namespaceDeclaration && !ts.isDefaultImport(node) ? variables.push(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), void 0, void 0, getHelperExpressionForImport(node, createRequireCall(node)))) : (variables.push(factory.createVariableDeclaration(factory.getGeneratedNameForNode(node), void 0, void 0, getHelperExpressionForImport(node, createRequireCall(node)))), namespaceDeclaration && ts.isDefaultImport(node) && variables.push(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), void 0, void 0, factory.getGeneratedNameForNode(node)))), statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(void 0, factory.createVariableDeclarationList(variables, languageVersion >= 2 ? 2 : 0)), node), node)); - } else namespaceDeclaration && ts.isDefaultImport(node) && (statements = ts.append(statements, factory.createVariableStatement(void 0, factory.createVariableDeclarationList([ - ts.setOriginalNode(ts.setTextRange(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), void 0, void 0, factory.getGeneratedNameForNode(node)), node), node) - ], languageVersion >= 2 ? 2 : 0)))); - if (hasAssociatedEndOfDeclarationMarker(node)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); - } else statements = appendExportsOfImportDeclaration(statements, node); - return ts.singleOrMany(statements); - }(node); - case 264: - return function(node) { - if (ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."), moduleKind !== ts.ModuleKind.AMD ? statements = ts.hasSyntacticModifier(node, 1) ? ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node)) : ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(void 0, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.cloneNode(node.name), void 0, void 0, createRequireCall(node)) - ], languageVersion >= 2 ? 2 : 0)), node), node)) : ts.hasSyntacticModifier(node, 1) && (statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node))), hasAssociatedEndOfDeclarationMarker(node)) { - var statements, id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); - } else statements = appendExportsOfImportEqualsDeclaration(statements, node); - return ts.singleOrMany(statements); - }(node); - case 271: - return function(node) { - if (node.moduleSpecifier) { - var innerExpr, generatedName = factory.getGeneratedNameForNode(node); - if (node.exportClause && ts.isNamedExports(node.exportClause)) { - var statements = []; - moduleKind !== ts.ModuleKind.AMD && statements.push(ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(void 0, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(generatedName, void 0, void 0, createRequireCall(node)) - ])), node), node)); - for(var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++){ - var specifier = _a[_i]; - if (0 === languageVersion) statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : void 0)), specifier), specifier)); - else { - var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) && !(67108864 & ts.getEmitFlags(node)) && "default" === ts.idText(specifier.propertyName || specifier.name), exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); - statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, void 0, !0)), specifier), specifier)); - } - } - return ts.singleOrMany(statements); - } - if (!node.exportClause) return ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createExportStarHelper(moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node), node); + } + function topLevelVisitor(node) { + switch(node.kind){ + case 265: + return function(node) { + var statements, namespaceDeclaration = ts1.getNamespaceDeclarationNode(node); + if (moduleKind !== ts1.ModuleKind.AMD) { + if (!node.importClause) return ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(createRequireCall(node)), node), node); + var variables = []; + namespaceDeclaration && !ts1.isDefaultImport(node) ? variables.push(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), void 0, void 0, getHelperExpressionForImport(node, createRequireCall(node)))) : (variables.push(factory.createVariableDeclaration(factory.getGeneratedNameForNode(node), void 0, void 0, getHelperExpressionForImport(node, createRequireCall(node)))), namespaceDeclaration && ts1.isDefaultImport(node) && variables.push(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), void 0, void 0, factory.getGeneratedNameForNode(node)))), statements = ts1.append(statements, ts1.setOriginalNode(ts1.setTextRange(factory.createVariableStatement(void 0, factory.createVariableDeclarationList(variables, languageVersion >= 2 ? 2 : 0)), node), node)); + } else namespaceDeclaration && ts1.isDefaultImport(node) && (statements = ts1.append(statements, factory.createVariableStatement(void 0, factory.createVariableDeclarationList([ + ts1.setOriginalNode(ts1.setTextRange(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), void 0, void 0, factory.getGeneratedNameForNode(node)), node), node) + ], languageVersion >= 2 ? 2 : 0)))); + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts1.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + } else statements = appendExportsOfImportDeclaration(statements, node); + return ts1.singleOrMany(statements); + }(node); + case 264: + return function(node) { + if (ts1.Debug.assert(ts1.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."), moduleKind !== ts1.ModuleKind.AMD ? statements = ts1.hasSyntacticModifier(node, 1) ? ts1.append(statements, ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node)) : ts1.append(statements, ts1.setOriginalNode(ts1.setTextRange(factory.createVariableStatement(void 0, factory.createVariableDeclarationList([ + factory.createVariableDeclaration(factory.cloneNode(node.name), void 0, void 0, createRequireCall(node)) + ], languageVersion >= 2 ? 2 : 0)), node), node)) : ts1.hasSyntacticModifier(node, 1) && (statements = ts1.append(statements, ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node))), hasAssociatedEndOfDeclarationMarker(node)) { + var statements, id = ts1.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } else statements = appendExportsOfImportEqualsDeclaration(statements, node); + return ts1.singleOrMany(statements); + }(node); + case 271: + return function(node) { + if (node.moduleSpecifier) { + var innerExpr, generatedName = factory.getGeneratedNameForNode(node); + if (node.exportClause && ts1.isNamedExports(node.exportClause)) { var statements = []; - return statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.cloneNode(node.exportClause.name), (innerExpr = moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : ts.isExportNamespaceAsDefaultDeclaration(node) ? generatedName : factory.createIdentifier(ts.idText(node.exportClause.name)), !ts.getESModuleInterop(compilerOptions) || 67108864 & ts.getEmitFlags(node) ? innerExpr : ts.getExportNeedsImportStarHelper(node) ? emitHelpers().createImportStarHelper(innerExpr) : innerExpr))), node), node)), ts.singleOrMany(statements); - } - }(node); - case 270: - return function(node) { - if (!node.isExportEquals) { - var statements, original = node.original; - if (original && hasAssociatedEndOfDeclarationMarker(original)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportStatement(deferredExports[id], factory.createIdentifier("default"), ts.visitNode(node.expression, visitor), node, !0); - } else statements = appendExportStatement(statements, factory.createIdentifier("default"), ts.visitNode(node.expression, visitor), node, !0); - return ts.singleOrMany(statements); - } - }(node); - case 236: - return function(node) { - if (ts.hasSyntacticModifier(node, 1)) { - for(var statements, variables, expressions, modifiers = void 0, removeCommentsOnExpressions = !1, _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++){ - var variable = _a[_i]; - if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) modifiers || (modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)), variables = ts.append(variables, variable); - else if (variable.initializer) { - if (!ts.isBindingPattern(variable.name) && (ts.isArrowFunction(variable.initializer) || ts.isFunctionExpression(variable.initializer) || ts.isClassExpression(variable.initializer))) { - var expression = factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), variable.name), variable.name), factory.createIdentifier(ts.getTextOfIdentifierOrLiteral(variable.name))), updatedVariable = factory.createVariableDeclaration(variable.name, variable.exclamationToken, variable.type, ts.visitNode(variable.initializer, visitor)); - variables = ts.append(variables, updatedVariable), expressions = ts.append(expressions, expression), removeCommentsOnExpressions = !0; - } else expressions = ts.append(expressions, ts.isBindingPattern(variable.name) ? ts.flattenDestructuringAssignment(ts.visitNode(variable, visitor), void 0, context, 0, !1, createAllExportExpressions) : factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), variable.name), variable.name), variable.initializer ? ts.visitNode(variable.initializer, visitor) : factory.createVoidZero())); + moduleKind !== ts1.ModuleKind.AMD && statements.push(ts1.setOriginalNode(ts1.setTextRange(factory.createVariableStatement(void 0, factory.createVariableDeclarationList([ + factory.createVariableDeclaration(generatedName, void 0, void 0, createRequireCall(node)) + ])), node), node)); + for(var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++){ + var specifier = _a[_i]; + if (0 === languageVersion) statements.push(ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : void 0)), specifier), specifier)); + else { + var exportNeedsImportDefault = !!ts1.getESModuleInterop(compilerOptions) && !(67108864 & ts1.getEmitFlags(node)) && "default" === ts1.idText(specifier.propertyName || specifier.name), exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); + statements.push(ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, void 0, !0)), specifier), specifier)); } } - if (variables && (statements = ts.append(statements, factory.updateVariableStatement(node, modifiers, factory.updateVariableDeclarationList(node.declarationList, variables)))), expressions) { - var statement = ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(expressions)), node), node); - removeCommentsOnExpressions && ts.removeAllComments(statement), statements = ts.append(statements, statement); - } - } else statements = ts.append(statements, ts.visitEachChild(node, visitor, context)); - if (hasAssociatedEndOfDeclarationMarker(node)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); - } else statements = appendExportsOfVariableStatement(statements, node); - return ts.singleOrMany(statements); - }(node); - case 255: - return function(node) { - var statements; - if (statements = ts.hasSyntacticModifier(node, 1) ? ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration(void 0, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, !0, !0), void 0, ts.visitNodes(node.parameters, visitor), void 0, ts.visitEachChild(node.body, visitor, context)), node), node)) : ts.append(statements, ts.visitEachChild(node, visitor, context)), hasAssociatedEndOfDeclarationMarker(node)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); - } else statements = appendExportsOfHoistedDeclaration(statements, node); - return ts.singleOrMany(statements); - }(node); - case 256: - return function(node) { - var statements; - if (statements = ts.hasSyntacticModifier(node, 1) ? ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration(void 0, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.getDeclarationName(node, !0, !0), void 0, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node)) : ts.append(statements, ts.visitEachChild(node, visitor, context)), hasAssociatedEndOfDeclarationMarker(node)) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); - } else statements = appendExportsOfHoistedDeclaration(statements, node); - return ts.singleOrMany(statements); - }(node); - case 350: - return function(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && 236 === node.original.kind) { - var id = ts.getOriginalNodeId(node); - deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); - } - return node; - }(node); - case 351: - var id, statements; - return (statements = deferredExports[id = ts.getOriginalNodeId(node)]) ? (delete deferredExports[id], ts.append(statements, node)) : node; - default: - return visitor(node); - } - } - function visitorWorker(node, valueIsDiscarded) { - if (!(71307264 & node.transformFlags)) return node; - switch(node.kind){ - case 241: - return factory.updateForStatement(node, ts.visitNode(node.initializer, discardedValueVisitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, discardedValueVisitor, ts.isExpression), ts.visitIterationBody(node.statement, visitor, context)); - case 237: - return factory.updateExpressionStatement(node, ts.visitNode(node.expression, discardedValueVisitor, ts.isExpression)); - case 211: - return factory.updateParenthesizedExpression(node, ts.visitNode(node.expression, valueIsDiscarded ? discardedValueVisitor : visitor, ts.isExpression)); - case 348: - return factory.updatePartiallyEmittedExpression(node, ts.visitNode(node.expression, valueIsDiscarded ? discardedValueVisitor : visitor, ts.isExpression)); - case 207: - if (ts.isImportCall(node) && void 0 === currentSourceFile.impliedNodeFormat) return function(node) { - var externalModuleName = ts.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions), firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor), argument = !externalModuleName || firstArgument && ts.isStringLiteral(firstArgument) && firstArgument.text === externalModuleName.text ? firstArgument : externalModuleName, containsLexicalThis = !!(8192 & node.transformFlags); - switch(compilerOptions.module){ - case ts.ModuleKind.AMD: - return createImportCallExpressionAMD(argument, containsLexicalThis); - case ts.ModuleKind.UMD: - return function(arg, containsLexicalThis) { - if (needUMDDynamicImportHelper = !0, ts.isSimpleCopiableExpression(arg)) { - var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536); - return factory.createConditionalExpression(factory.createIdentifier("__syncRequire"), void 0, createImportCallExpressionCommonJS(arg, containsLexicalThis), void 0, createImportCallExpressionAMD(argClone, containsLexicalThis)); - } - var temp = factory.createTempVariable(hoistVariableDeclaration); - return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(factory.createIdentifier("__syncRequire"), void 0, createImportCallExpressionCommonJS(temp, containsLexicalThis), void 0, createImportCallExpressionAMD(temp, containsLexicalThis))); - }(null != argument ? argument : factory.createVoidZero(), containsLexicalThis); - case ts.ModuleKind.CommonJS: - default: - return createImportCallExpressionCommonJS(argument, containsLexicalThis); + return ts1.singleOrMany(statements); } - }(node); - break; - case 220: - if (ts.isDestructuringAssignment(node)) return !function destructuringNeedsFlattening(node) { - if (ts.isObjectLiteralExpression(node)) for(var _i = 0, _a = node.properties; _i < _a.length; _i++){ - var elem = _a[_i]; - switch(elem.kind){ - case 294: - if (destructuringNeedsFlattening(elem.initializer)) return !0; - break; - case 295: - if (destructuringNeedsFlattening(elem.name)) return !0; - break; - case 296: - if (destructuringNeedsFlattening(elem.expression)) return !0; - break; - case 168: - case 171: - case 172: - return !1; - default: - ts.Debug.assertNever(elem, "Unhandled object member kind"); + if (!node.exportClause) return ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(emitHelpers().createExportStarHelper(moduleKind !== ts1.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node), node); + var statements = []; + return statements.push(ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(createExportExpression(factory.cloneNode(node.exportClause.name), (innerExpr = moduleKind !== ts1.ModuleKind.AMD ? createRequireCall(node) : ts1.isExportNamespaceAsDefaultDeclaration(node) ? generatedName : factory.createIdentifier(ts1.idText(node.exportClause.name)), !ts1.getESModuleInterop(compilerOptions) || 67108864 & ts1.getEmitFlags(node) ? innerExpr : ts1.getExportNeedsImportStarHelper(node) ? emitHelpers().createImportStarHelper(innerExpr) : innerExpr))), node), node)), ts1.singleOrMany(statements); + } + }(node); + case 270: + return function(node) { + if (!node.isExportEquals) { + var statements, original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + var id = ts1.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], factory.createIdentifier("default"), ts1.visitNode(node.expression, visitor), node, !0); + } else statements = appendExportStatement(statements, factory.createIdentifier("default"), ts1.visitNode(node.expression, visitor), node, !0); + return ts1.singleOrMany(statements); + } + }(node); + case 236: + return function(node) { + if (ts1.hasSyntacticModifier(node, 1)) { + for(var statements, variables, expressions, modifiers = void 0, removeCommentsOnExpressions = !1, _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++){ + var variable = _a[_i]; + if (ts1.isIdentifier(variable.name) && ts1.isLocalName(variable.name)) modifiers || (modifiers = ts1.visitNodes(node.modifiers, modifierVisitor, ts1.isModifier)), variables = ts1.append(variables, variable); + else if (variable.initializer) { + if (!ts1.isBindingPattern(variable.name) && (ts1.isArrowFunction(variable.initializer) || ts1.isFunctionExpression(variable.initializer) || ts1.isClassExpression(variable.initializer))) { + var expression = factory.createAssignment(ts1.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), variable.name), variable.name), factory.createIdentifier(ts1.getTextOfIdentifierOrLiteral(variable.name))), updatedVariable = factory.createVariableDeclaration(variable.name, variable.exclamationToken, variable.type, ts1.visitNode(variable.initializer, visitor)); + variables = ts1.append(variables, updatedVariable), expressions = ts1.append(expressions, expression), removeCommentsOnExpressions = !0; + } else expressions = ts1.append(expressions, ts1.isBindingPattern(variable.name) ? ts1.flattenDestructuringAssignment(ts1.visitNode(variable, visitor), void 0, context, 0, !1, createAllExportExpressions) : factory.createAssignment(ts1.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), variable.name), variable.name), variable.initializer ? ts1.visitNode(variable.initializer, visitor) : factory.createVoidZero())); } } - else if (ts.isArrayLiteralExpression(node)) for(var _b = 0, _c = node.elements; _b < _c.length; _b++){ - var elem = _c[_b]; - if (ts.isSpreadElement(elem)) { - if (destructuringNeedsFlattening(elem.expression)) return !0; - } else if (destructuringNeedsFlattening(elem)) return !0; + if (variables && (statements = ts1.append(statements, factory.updateVariableStatement(node, modifiers, factory.updateVariableDeclarationList(node.declarationList, variables)))), expressions) { + var statement = ts1.setOriginalNode(ts1.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(expressions)), node), node); + removeCommentsOnExpressions && ts1.removeAllComments(statement), statements = ts1.append(statements, statement); } - else if (ts.isIdentifier(node)) return ts.length(getExports(node)) > (ts.isExportName(node) ? 1 : 0); - return !1; - }(node.left) ? ts.visitEachChild(node, visitor, context) : ts.flattenDestructuringAssignment(node, visitor, context, 0, !valueIsDiscarded, createAllExportExpressions); - break; - case 218: - case 219: - return function(node, valueIsDiscarded) { - if ((45 === node.operator || 46 === node.operator) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { - var exportedNames = getExports(node.operand); - if (exportedNames) { - var temp = void 0, expression = ts.visitNode(node.operand, visitor, ts.isExpression); - ts.isPrefixUnaryExpression(node) ? expression = factory.updatePrefixUnaryExpression(node, expression) : (expression = factory.updatePostfixUnaryExpression(node, expression), valueIsDiscarded || (temp = factory.createTempVariable(hoistVariableDeclaration), expression = factory.createAssignment(temp, expression), ts.setTextRange(expression, node)), expression = factory.createComma(expression, factory.cloneNode(node.operand)), ts.setTextRange(expression, node)); - for(var _i = 0; _i < exportedNames.length; _i++){ - var exportName = exportedNames[_i]; - noSubstitution[ts.getNodeId(expression)] = !0, expression = createExportExpression(exportName, expression), ts.setTextRange(expression, node); + } else statements = ts1.append(statements, ts1.visitEachChild(node, visitor, context)); + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts1.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); + } else statements = appendExportsOfVariableStatement(statements, node); + return ts1.singleOrMany(statements); + }(node); + case 255: + return function(node) { + var statements; + if (statements = ts1.hasSyntacticModifier(node, 1) ? ts1.append(statements, ts1.setOriginalNode(ts1.setTextRange(factory.createFunctionDeclaration(void 0, ts1.visitNodes(node.modifiers, modifierVisitor, ts1.isModifier), node.asteriskToken, factory.getDeclarationName(node, !0, !0), void 0, ts1.visitNodes(node.parameters, visitor), void 0, ts1.visitEachChild(node.body, visitor, context)), node), node)) : ts1.append(statements, ts1.visitEachChild(node, visitor, context)), hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts1.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } else statements = appendExportsOfHoistedDeclaration(statements, node); + return ts1.singleOrMany(statements); + }(node); + case 256: + return function(node) { + var statements; + if (statements = ts1.hasSyntacticModifier(node, 1) ? ts1.append(statements, ts1.setOriginalNode(ts1.setTextRange(factory.createClassDeclaration(void 0, ts1.visitNodes(node.modifiers, modifierVisitor, ts1.isModifier), factory.getDeclarationName(node, !0, !0), void 0, ts1.visitNodes(node.heritageClauses, visitor), ts1.visitNodes(node.members, visitor)), node), node)) : ts1.append(statements, ts1.visitEachChild(node, visitor, context)), hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts1.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } else statements = appendExportsOfHoistedDeclaration(statements, node); + return ts1.singleOrMany(statements); + }(node); + case 350: + return function(node) { + if (hasAssociatedEndOfDeclarationMarker(node) && 236 === node.original.kind) { + var id = ts1.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); + } + return node; + }(node); + case 351: + var id, statements; + return (statements = deferredExports[id = ts1.getOriginalNodeId(node)]) ? (delete deferredExports[id], ts1.append(statements, node)) : node; + default: + return visitor(node); + } + } + function visitorWorker(node, valueIsDiscarded) { + if (!(71307264 & node.transformFlags)) return node; + switch(node.kind){ + case 241: + return factory.updateForStatement(node, ts1.visitNode(node.initializer, discardedValueVisitor, ts1.isForInitializer), ts1.visitNode(node.condition, visitor, ts1.isExpression), ts1.visitNode(node.incrementor, discardedValueVisitor, ts1.isExpression), ts1.visitIterationBody(node.statement, visitor, context)); + case 237: + return factory.updateExpressionStatement(node, ts1.visitNode(node.expression, discardedValueVisitor, ts1.isExpression)); + case 211: + return factory.updateParenthesizedExpression(node, ts1.visitNode(node.expression, valueIsDiscarded ? discardedValueVisitor : visitor, ts1.isExpression)); + case 348: + return factory.updatePartiallyEmittedExpression(node, ts1.visitNode(node.expression, valueIsDiscarded ? discardedValueVisitor : visitor, ts1.isExpression)); + case 207: + if (ts1.isImportCall(node) && void 0 === currentSourceFile.impliedNodeFormat) return function(node) { + var externalModuleName = ts1.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions), firstArgument = ts1.visitNode(ts1.firstOrUndefined(node.arguments), visitor), argument = !externalModuleName || firstArgument && ts1.isStringLiteral(firstArgument) && firstArgument.text === externalModuleName.text ? firstArgument : externalModuleName, containsLexicalThis = !!(8192 & node.transformFlags); + switch(compilerOptions.module){ + case ts1.ModuleKind.AMD: + return createImportCallExpressionAMD(argument, containsLexicalThis); + case ts1.ModuleKind.UMD: + return function(arg, containsLexicalThis) { + if (needUMDDynamicImportHelper = !0, ts1.isSimpleCopiableExpression(arg)) { + var argClone = ts1.isGeneratedIdentifier(arg) ? arg : ts1.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts1.setEmitFlags(ts1.setTextRange(factory.cloneNode(arg), arg), 1536); + return factory.createConditionalExpression(factory.createIdentifier("__syncRequire"), void 0, createImportCallExpressionCommonJS(arg, containsLexicalThis), void 0, createImportCallExpressionAMD(argClone, containsLexicalThis)); } - return temp && (noSubstitution[ts.getNodeId(expression)] = !0, expression = factory.createComma(expression, temp), ts.setTextRange(expression, node)), expression; + var temp = factory.createTempVariable(hoistVariableDeclaration); + return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(factory.createIdentifier("__syncRequire"), void 0, createImportCallExpressionCommonJS(temp, containsLexicalThis), void 0, createImportCallExpressionAMD(temp, containsLexicalThis))); + }(null != argument ? argument : factory.createVoidZero(), containsLexicalThis); + case ts1.ModuleKind.CommonJS: + default: + return createImportCallExpressionCommonJS(argument, containsLexicalThis); + } + }(node); + break; + case 220: + if (ts1.isDestructuringAssignment(node)) return !function destructuringNeedsFlattening(node) { + if (ts1.isObjectLiteralExpression(node)) for(var _i = 0, _a = node.properties; _i < _a.length; _i++){ + var elem = _a[_i]; + switch(elem.kind){ + case 294: + if (destructuringNeedsFlattening(elem.initializer)) return !0; + break; + case 295: + if (destructuringNeedsFlattening(elem.name)) return !0; + break; + case 296: + if (destructuringNeedsFlattening(elem.expression)) return !0; + break; + case 168: + case 171: + case 172: + return !1; + default: + ts1.Debug.assertNever(elem, "Unhandled object member kind"); + } + } + else if (ts1.isArrayLiteralExpression(node)) for(var _b = 0, _c = node.elements; _b < _c.length; _b++){ + var elem = _c[_b]; + if (ts1.isSpreadElement(elem)) { + if (destructuringNeedsFlattening(elem.expression)) return !0; + } else if (destructuringNeedsFlattening(elem)) return !0; + } + else if (ts1.isIdentifier(node)) return ts1.length(getExports(node)) > (ts1.isExportName(node) ? 1 : 0); + return !1; + }(node.left) ? ts1.visitEachChild(node, visitor, context) : ts1.flattenDestructuringAssignment(node, visitor, context, 0, !valueIsDiscarded, createAllExportExpressions); + break; + case 218: + case 219: + return function(node, valueIsDiscarded) { + if ((45 === node.operator || 46 === node.operator) && ts1.isIdentifier(node.operand) && !ts1.isGeneratedIdentifier(node.operand) && !ts1.isLocalName(node.operand) && !ts1.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var temp = void 0, expression = ts1.visitNode(node.operand, visitor, ts1.isExpression); + ts1.isPrefixUnaryExpression(node) ? expression = factory.updatePrefixUnaryExpression(node, expression) : (expression = factory.updatePostfixUnaryExpression(node, expression), valueIsDiscarded || (temp = factory.createTempVariable(hoistVariableDeclaration), expression = factory.createAssignment(temp, expression), ts1.setTextRange(expression, node)), expression = factory.createComma(expression, factory.cloneNode(node.operand)), ts1.setTextRange(expression, node)); + for(var _i = 0; _i < exportedNames.length; _i++){ + var exportName = exportedNames[_i]; + noSubstitution[ts1.getNodeId(expression)] = !0, expression = createExportExpression(exportName, expression), ts1.setTextRange(expression, node); } + return temp && (noSubstitution[ts1.getNodeId(expression)] = !0, expression = factory.createComma(expression, temp), ts1.setTextRange(expression, node)), expression; } - return ts.visitEachChild(node, visitor, context); - }(node, valueIsDiscarded); - } - return ts.visitEachChild(node, visitor, context); - } - function visitor(node) { - return visitorWorker(node, !1); - } - function discardedValueVisitor(node) { - return visitorWorker(node, !0); - } - function createImportCallExpressionAMD(arg, containsLexicalThis) { - var func, resolve = factory.createUniqueName("resolve"), reject = factory.createUniqueName("reject"), parameters = [ - factory.createParameterDeclaration(void 0, void 0, void 0, resolve), - factory.createParameterDeclaration(void 0, void 0, void 0, reject) - ], body = factory.createBlock([ - factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("require"), void 0, [ - factory.createArrayLiteralExpression([ - arg || factory.createOmittedExpression() - ]), - resolve, - reject - ])) - ]); - languageVersion >= 2 ? func = factory.createArrowFunction(void 0, void 0, parameters, void 0, void 0, body) : (func = factory.createFunctionExpression(void 0, void 0, void 0, void 0, parameters, void 0, body), containsLexicalThis && ts.setEmitFlags(func, 8)); - var promise = factory.createNewExpression(factory.createIdentifier("Promise"), void 0, [ - func - ]); - return ts.getESModuleInterop(compilerOptions) ? factory.createCallExpression(factory.createPropertyAccessExpression(promise, factory.createIdentifier("then")), void 0, [ - emitHelpers().createImportStarCallbackHelper() - ]) : promise; - } - function createImportCallExpressionCommonJS(arg, containsLexicalThis) { - var func, promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), void 0, []), requireCall = factory.createCallExpression(factory.createIdentifier("require"), void 0, arg ? [ - arg - ] : []); - return ts.getESModuleInterop(compilerOptions) && (requireCall = emitHelpers().createImportStarHelper(requireCall)), languageVersion >= 2 ? func = factory.createArrowFunction(void 0, void 0, [], void 0, void 0, requireCall) : (func = factory.createFunctionExpression(void 0, void 0, void 0, void 0, [], void 0, factory.createBlock([ - factory.createReturnStatement(requireCall) - ])), containsLexicalThis && ts.setEmitFlags(func, 8)), factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), void 0, [ - func - ]); - } - function getHelperExpressionForImport(node, innerExpr) { - return !ts.getESModuleInterop(compilerOptions) || 67108864 & ts.getEmitFlags(node) ? innerExpr : ts.getImportNeedsImportStarHelper(node) ? emitHelpers().createImportStarHelper(innerExpr) : ts.getImportNeedsImportDefaultHelper(node) ? emitHelpers().createImportDefaultHelper(innerExpr) : innerExpr; - } - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(factory, importNode, currentSourceFile, host, resolver, compilerOptions), args = []; - return moduleName && args.push(moduleName), factory.createCallExpression(factory.createIdentifier("require"), void 0, args); + } + return ts1.visitEachChild(node, visitor, context); + }(node, valueIsDiscarded); } - function createAllExportExpressions(name, value, location) { - var exportedNames = getExports(name); - if (exportedNames) { - for(var expression = ts.isExportName(name) ? value : factory.createAssignment(name, value), _i = 0; _i < exportedNames.length; _i++){ - var exportName = exportedNames[_i]; - ts.setEmitFlags(expression, 4), expression = createExportExpression(exportName, expression, location); - } - return expression; + return ts1.visitEachChild(node, visitor, context); + } + function visitor(node) { + return visitorWorker(node, !1); + } + function discardedValueVisitor(node) { + return visitorWorker(node, !0); + } + function createImportCallExpressionAMD(arg, containsLexicalThis) { + var func, resolve = factory.createUniqueName("resolve"), reject = factory.createUniqueName("reject"), parameters = [ + factory.createParameterDeclaration(void 0, void 0, void 0, resolve), + factory.createParameterDeclaration(void 0, void 0, void 0, reject) + ], body = factory.createBlock([ + factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("require"), void 0, [ + factory.createArrayLiteralExpression([ + arg || factory.createOmittedExpression() + ]), + resolve, + reject + ])) + ]); + languageVersion >= 2 ? func = factory.createArrowFunction(void 0, void 0, parameters, void 0, void 0, body) : (func = factory.createFunctionExpression(void 0, void 0, void 0, void 0, parameters, void 0, body), containsLexicalThis && ts1.setEmitFlags(func, 8)); + var promise = factory.createNewExpression(factory.createIdentifier("Promise"), void 0, [ + func + ]); + return ts1.getESModuleInterop(compilerOptions) ? factory.createCallExpression(factory.createPropertyAccessExpression(promise, factory.createIdentifier("then")), void 0, [ + emitHelpers().createImportStarCallbackHelper() + ]) : promise; + } + function createImportCallExpressionCommonJS(arg, containsLexicalThis) { + var func, promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), void 0, []), requireCall = factory.createCallExpression(factory.createIdentifier("require"), void 0, arg ? [ + arg + ] : []); + return ts1.getESModuleInterop(compilerOptions) && (requireCall = emitHelpers().createImportStarHelper(requireCall)), languageVersion >= 2 ? func = factory.createArrowFunction(void 0, void 0, [], void 0, void 0, requireCall) : (func = factory.createFunctionExpression(void 0, void 0, void 0, void 0, [], void 0, factory.createBlock([ + factory.createReturnStatement(requireCall) + ])), containsLexicalThis && ts1.setEmitFlags(func, 8)), factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), void 0, [ + func + ]); + } + function getHelperExpressionForImport(node, innerExpr) { + return !ts1.getESModuleInterop(compilerOptions) || 67108864 & ts1.getEmitFlags(node) ? innerExpr : ts1.getImportNeedsImportStarHelper(node) ? emitHelpers().createImportStarHelper(innerExpr) : ts1.getImportNeedsImportDefaultHelper(node) ? emitHelpers().createImportDefaultHelper(innerExpr) : innerExpr; + } + function createRequireCall(importNode) { + var moduleName = ts1.getExternalModuleNameLiteral(factory, importNode, currentSourceFile, host, resolver, compilerOptions), args = []; + return moduleName && args.push(moduleName), factory.createCallExpression(factory.createIdentifier("require"), void 0, args); + } + function createAllExportExpressions(name, value, location) { + var exportedNames = getExports(name); + if (exportedNames) { + for(var expression = ts1.isExportName(name) ? value : factory.createAssignment(name, value), _i = 0; _i < exportedNames.length; _i++){ + var exportName = exportedNames[_i]; + ts1.setEmitFlags(expression, 4), expression = createExportExpression(exportName, expression, location); } - return factory.createAssignment(name, value); + return expression; } - function hasAssociatedEndOfDeclarationMarker(node) { - return (4194304 & ts.getEmitFlags(node)) != 0; + return factory.createAssignment(name, value); + } + function hasAssociatedEndOfDeclarationMarker(node) { + return (4194304 & ts1.getEmitFlags(node)) != 0; + } + function appendExportsOfImportDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) return statements; + var importClause = decl.importClause; + if (!importClause) return statements; + importClause.name && (statements = appendExportsOfDeclaration(statements, importClause)); + var namedBindings = importClause.namedBindings; + if (namedBindings) switch(namedBindings.kind){ + case 267: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 268: + for(var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++)statements = appendExportsOfDeclaration(statements, _a[_i], !0); } - function appendExportsOfImportDeclaration(statements, decl) { + return statements; + } + function appendExportsOfImportEqualsDeclaration(statements, decl) { + return currentModuleInfo.exportEquals ? statements : appendExportsOfDeclaration(statements, decl); + } + function appendExportsOfVariableStatement(statements, node) { + if (currentModuleInfo.exportEquals) return statements; + for(var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++)statements = function appendExportsOfBindingElement(statements, decl) { if (currentModuleInfo.exportEquals) return statements; - var importClause = decl.importClause; - if (!importClause) return statements; - importClause.name && (statements = appendExportsOfDeclaration(statements, importClause)); - var namedBindings = importClause.namedBindings; - if (namedBindings) switch(namedBindings.kind){ - case 267: - statements = appendExportsOfDeclaration(statements, namedBindings); - break; - case 268: - for(var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++)statements = appendExportsOfDeclaration(statements, _a[_i], !0); + if (ts1.isBindingPattern(decl.name)) for(var _i = 0, _a = decl.name.elements; _i < _a.length; _i++){ + var element = _a[_i]; + ts1.isOmittedExpression(element) || (statements = appendExportsOfBindingElement(statements, element)); } + else ts1.isGeneratedIdentifier(decl.name) || (statements = appendExportsOfDeclaration(statements, decl)); return statements; + }(statements, _a[_i]); + return statements; + } + function appendExportsOfHoistedDeclaration(statements, decl) { + return currentModuleInfo.exportEquals || (ts1.hasSyntacticModifier(decl, 1) && (statements = appendExportStatement(statements, ts1.hasSyntacticModifier(decl, 512) ? factory.createIdentifier("default") : factory.getDeclarationName(decl), factory.getLocalName(decl), decl)), decl.name && (statements = appendExportsOfDeclaration(statements, decl))), statements; + } + function appendExportsOfDeclaration(statements, decl, liveBinding) { + var name = factory.getDeclarationName(decl), exportSpecifiers = currentModuleInfo.exportSpecifiers.get(ts1.idText(name)); + if (exportSpecifiers) for(var _i = 0; _i < exportSpecifiers.length; _i++){ + var exportSpecifier = exportSpecifiers[_i]; + statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name, void 0, liveBinding); } - function appendExportsOfImportEqualsDeclaration(statements, decl) { - return currentModuleInfo.exportEquals ? statements : appendExportsOfDeclaration(statements, decl); - } - function appendExportsOfVariableStatement(statements, node) { - if (currentModuleInfo.exportEquals) return statements; - for(var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++)statements = function appendExportsOfBindingElement(statements, decl) { - if (currentModuleInfo.exportEquals) return statements; - if (ts.isBindingPattern(decl.name)) for(var _i = 0, _a = decl.name.elements; _i < _a.length; _i++){ - var element = _a[_i]; - ts.isOmittedExpression(element) || (statements = appendExportsOfBindingElement(statements, element)); - } - else ts.isGeneratedIdentifier(decl.name) || (statements = appendExportsOfDeclaration(statements, decl)); - return statements; - }(statements, _a[_i]); - return statements; - } - function appendExportsOfHoistedDeclaration(statements, decl) { - return currentModuleInfo.exportEquals || (ts.hasSyntacticModifier(decl, 1) && (statements = appendExportStatement(statements, ts.hasSyntacticModifier(decl, 512) ? factory.createIdentifier("default") : factory.getDeclarationName(decl), factory.getLocalName(decl), decl)), decl.name && (statements = appendExportsOfDeclaration(statements, decl))), statements; - } - function appendExportsOfDeclaration(statements, decl, liveBinding) { - var name = factory.getDeclarationName(decl), exportSpecifiers = currentModuleInfo.exportSpecifiers.get(ts.idText(name)); - if (exportSpecifiers) for(var _i = 0; _i < exportSpecifiers.length; _i++){ - var exportSpecifier = exportSpecifiers[_i]; - statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name, void 0, liveBinding); - } - return statements; - } - function appendExportStatement(statements, exportName, expression, location, allowComments, liveBinding) { - var statement; - return statements = ts.append(statements, (statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(exportName, expression, void 0, liveBinding)), location), ts.startOnNewLine(statement), allowComments || ts.setEmitFlags(statement, 1536), statement)); - } - function createUnderscoreUnderscoreESModule() { - var statement; - return statement = 0 === languageVersion ? factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue())) : factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), void 0, [ - factory.createIdentifier("exports"), - factory.createStringLiteral("__esModule"), - factory.createObjectLiteralExpression([ - factory.createPropertyAssignment("value", factory.createTrue()) - ]) - ])), ts.setEmitFlags(statement, 1048576), statement; - } - function createExportExpression(name, value, location, liveBinding) { - return ts.setTextRange(liveBinding && 0 !== languageVersion ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), void 0, [ - factory.createIdentifier("exports"), - factory.createStringLiteralFromNode(name), - factory.createObjectLiteralExpression([ - factory.createPropertyAssignment("enumerable", factory.createTrue()), - factory.createPropertyAssignment("get", factory.createFunctionExpression(void 0, void 0, void 0, void 0, [], void 0, factory.createBlock([ - factory.createReturnStatement(value) - ]))) - ]) - ]) : factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(name)), value), location); - } - function modifierVisitor(node) { - switch(node.kind){ - case 93: - case 88: - return; - } - return node; + return statements; + } + function appendExportStatement(statements, exportName, expression, location, allowComments, liveBinding) { + var statement; + return statements = ts1.append(statements, (statement = ts1.setTextRange(factory.createExpressionStatement(createExportExpression(exportName, expression, void 0, liveBinding)), location), ts1.startOnNewLine(statement), allowComments || ts1.setEmitFlags(statement, 1536), statement)); + } + function createUnderscoreUnderscoreESModule() { + var statement; + return statement = 0 === languageVersion ? factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue())) : factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), void 0, [ + factory.createIdentifier("exports"), + factory.createStringLiteral("__esModule"), + factory.createObjectLiteralExpression([ + factory.createPropertyAssignment("value", factory.createTrue()) + ]) + ])), ts1.setEmitFlags(statement, 1048576), statement; + } + function createExportExpression(name, value, location, liveBinding) { + return ts1.setTextRange(liveBinding && 0 !== languageVersion ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), void 0, [ + factory.createIdentifier("exports"), + factory.createStringLiteralFromNode(name), + factory.createObjectLiteralExpression([ + factory.createPropertyAssignment("enumerable", factory.createTrue()), + factory.createPropertyAssignment("get", factory.createFunctionExpression(void 0, void 0, void 0, void 0, [], void 0, factory.createBlock([ + factory.createReturnStatement(value) + ]))) + ]) + ]) : factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(name)), value), location); + } + function modifierVisitor(node) { + switch(node.kind){ + case 93: + case 88: + return; } - function substituteExpressionIdentifier(node) { - var _a, _b; - if (4096 & ts.getEmitFlags(node)) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) return factory.createPropertyAccessExpression(externalHelpersModuleName, node); - } else if (!(ts.isGeneratedIdentifier(node) && !(64 & node.autoGenerateFlags)) && !ts.isLocalName(node)) { - var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && 303 === exportContainer.kind) return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), node); - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - if (ts.isImportClause(importDeclaration)) return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent), factory.createIdentifier("default")), node); - if (ts.isImportSpecifier(importDeclaration)) { - var name = importDeclaration.propertyName || importDeclaration.name; - return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode((null === (_b = null === (_a = importDeclaration.parent) || void 0 === _a ? void 0 : _a.parent) || void 0 === _b ? void 0 : _b.parent) || importDeclaration), factory.cloneNode(name)), node); - } + return node; + } + function substituteExpressionIdentifier(node) { + var _a, _b; + if (4096 & ts1.getEmitFlags(node)) { + var externalHelpersModuleName = ts1.getExternalHelpersModuleName(currentSourceFile); + if (externalHelpersModuleName) return factory.createPropertyAccessExpression(externalHelpersModuleName, node); + } else if (!(ts1.isGeneratedIdentifier(node) && !(64 & node.autoGenerateFlags)) && !ts1.isLocalName(node)) { + var exportContainer = resolver.getReferencedExportContainer(node, ts1.isExportName(node)); + if (exportContainer && 303 === exportContainer.kind) return ts1.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), node); + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts1.isImportClause(importDeclaration)) return ts1.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent), factory.createIdentifier("default")), node); + if (ts1.isImportSpecifier(importDeclaration)) { + var name = importDeclaration.propertyName || importDeclaration.name; + return ts1.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode((null === (_b = null === (_a = importDeclaration.parent) || void 0 === _a ? void 0 : _a.parent) || void 0 === _b ? void 0 : _b.parent) || importDeclaration), factory.cloneNode(name)), node); } } - return node; } - function getExports(name) { - if (!ts.isGeneratedIdentifier(name)) { - var valueDeclaration = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name); - if (valueDeclaration) return currentModuleInfo && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; - } + return node; + } + function getExports(name) { + if (!ts1.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) return currentModuleInfo && currentModuleInfo.exportedBindings[ts1.getOriginalNodeId(valueDeclaration)]; } - }; - var dynamicImportUMDHelper = { - name: "typescript:dynamicimport-sync-require", - scoped: !0, - text: "\n var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";" - }; -}(ts || (ts = {})); + } +}, dynamicImportUMDHelper = { + name: "typescript:dynamicimport-sync-require", + scoped: !0, + text: "\n var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";" +}; diff --git a/crates/swc_ecma_minifier/tests/fixture/pr/7688/input.js b/crates/swc_ecma_minifier/tests/fixture/pr/7688/input.js new file mode 100644 index 000000000000..d042f4cf0488 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/fixture/pr/7688/input.js @@ -0,0 +1,5 @@ +export function foo() { + const x = () => null; + const y = () => x; + console.log(y() === y()); +} \ No newline at end of file diff --git a/crates/swc_ecma_minifier/tests/fixture/pr/7688/output.js b/crates/swc_ecma_minifier/tests/fixture/pr/7688/output.js new file mode 100644 index 000000000000..4d9c4b5165cd --- /dev/null +++ b/crates/swc_ecma_minifier/tests/fixture/pr/7688/output.js @@ -0,0 +1,3 @@ +export function foo() { + console.log(!0); +} From 001abecd0dcd9c5b1ecbfef861066ce8f92d0017 Mon Sep 17 00:00:00 2001 From: austaras Date: Fri, 21 Jul 2023 16:20:57 +0800 Subject: [PATCH 2/3] update tsc tests --- ...portedFunctionThatShareAName.2.minified.js | 33 +- ...portedFunctionThatShareAName.2.minified.js | 27 +- ...AndExportedVarThatShareAName.2.minified.js | 19 +- ...NonExportedVarThatShareAName.2.minified.js | 19 +- ...uleWithSameNameAndCommonRoot.2.minified.js | 7 +- ...WithSameNameAndCommonRootES6.2.minified.js | 9 +- .../ES5SymbolProperty2.2.minified.js | 17 +- ...nterfaceWithInaccessibleType.2.minified.js | 21 +- ...ageListMemberTypeAnnotations.2.minified.js | 45 +- ...ypeInTypeParameterConstraint.2.minified.js | 56 +-- ...meterAndReturnTypeAnnotation.2.minified.js | 26 +- ...pesInParameterTypeAnnotation.2.minified.js | 21 +- ...eTypesInReturnTypeAnnotation.2.minified.js | 26 +- ...bleTypesOnItsExportedMembers.2.minified.js | 31 +- ...TypesInMemberTypeAnnotations.2.minified.js | 23 +- ...accessibleTypeAsTypeArgument.2.minified.js | 7 +- ...uleWithSameNameAndCommonRoot.2.minified.js | 17 +- ...assWithSameNameAndCommonRoot.2.minified.js | 7 +- ...ionWithSameNameAndCommonRoot.2.minified.js | 19 +- ...hExportedAndNonExportedEnums.2.minified.js | 7 +- ...tedAndNonExportedImportAlias.2.minified.js | 21 +- ...ExportedClassesOfTheSameName.2.minified.js | 14 +- ...ExportedClassesOfTheSameName.2.minified.js | 18 +- ...ExportedModulesOfTheSameName.2.minified.js | 24 +- ...meNameAndDifferentCommonRoot.2.minified.js | 32 +- ...nOperatorWithAnyAndEveryType.2.minified.js | 7 +- ...nOperatorWithInvalidOperands.2.minified.js | 7 +- .../ambientInsideNonAmbient.2.minified.js | 7 +- ...entCompatWithCallSignatures4.2.minified.js | 7 +- ...mpatWithConstructSignatures4.2.minified.js | 7 +- ...CompatWithDiscriminatedUnion.2.minified.js | 11 +- ...nmentCompatWithObjectMembers.2.minified.js | 8 +- ...mentCompatWithObjectMembers4.2.minified.js | 60 +-- ...thObjectMembersAccessibility.2.minified.js | 10 +- ...ntToParenthesizedIdentifiers.2.minified.js | 12 +- .../asyncAwaitNestedClasses_es5.2.minified.js | 65 ++- ...seNotOperatorWithBooleanType.2.minified.js | 7 +- ...iseNotOperatorWithNumberType.2.minified.js | 7 +- ...iseNotOperatorWithStringType.2.minified.js | 7 +- .../circularImportAlias.2.minified.js | 31 +- ...sAbstractImportInstantiation.2.minified.js | 11 +- .../classAbstractInAModule.2.minified.js | 27 +- ...lassExtendsItselfIndirectly2.2.minified.js | 85 ++-- .../classWithConstructors.2.minified.js | 62 +-- .../constAssertionOnEnum.2.minified.js | 7 +- ...structorHasPrototypeProperty.2.minified.js | 46 +- ...mentOperatorWithAnyOtherType.2.minified.js | 7 +- ...rementOperatorWithNumberType.2.minified.js | 7 +- .../defaultExportsCannotMerge04.2.minified.js | 7 +- ...BindingPatternAndAssignment3.2.minified.js | 18 +- ...rnAndAssignment6(target=es5).2.minified.js | 5 +- ...rnAndAssignment7(target=es5).2.minified.js | 5 +- ...rnAndAssignment8(target=es5).2.minified.js | 7 +- ...meterDeclaration3ES5iterable.2.minified.js | 16 +- ...uringWithLiteralInitializers.2.minified.js | 14 +- ...arationBindingPatterns01_ES5.2.minified.js | 6 +- ...indingPatterns01_ES5iterable.2.minified.js | 6 +- .../tsc-references/enumMerging.2.minified.js | 25 +- .../enumMergingErrors.2.minified.js | 31 +- .../exportCodeGen.2.minified.js | 14 +- .../exportImportAlias.2.minified.js | 31 +- .../exportsAndImports1-es6.2.minified.js | 7 +- .../exportsAndImports1.2.minified.js | 7 +- .../exportsAndImports3-es6.2.minified.js | 7 +- .../exportsAndImports3.2.minified.js | 7 +- ...thGenericSignatureArguments2.2.minified.js | 10 +- ...dedConstructorTypedArguments.2.minified.js | 26 +- ...edConstructorTypedArguments2.2.minified.js | 11 +- ...loadedFunctionTypedArguments.2.minified.js | 58 +-- ...oadedFunctionTypedArguments2.2.minified.js | 15 +- ...FunctionTypedMemberArguments.2.minified.js | 80 ++- ...ObjectTypeArgsAndConstraints.2.minified.js | 10 +- .../genericSetterInClassType.2.minified.js | 33 +- ...eExtendingClassWithPrivates2.2.minified.js | 7 +- ...ortCallExpressionAsyncES3CJS.2.minified.js | 18 + ...ortCallExpressionAsyncES5CJS.2.minified.js | 18 + ...ortCallExpressionAsyncES6CJS.2.minified.js | 4 + .../importStatements.2.minified.js | 18 +- ...mentOperatorWithAnyOtherType.2.minified.js | 7 +- ...rementOperatorWithNumberType.2.minified.js | 7 +- ...ertiesInheritedIntoClassType.2.minified.js | 94 ++-- .../instancePropertyInClassType.2.minified.js | 66 ++- .../instantiatedModule.2.minified.js | 38 +- .../intersectionTypeInference.2.minified.js | 9 +- .../invalidNestedModules.2.minified.js | 16 +- .../literalTypes2.2.minified.js | 10 +- ...lNotOperatorWithAnyOtherType.2.minified.js | 7 +- ...alNotOperatorWithBooleanType.2.minified.js | 7 +- ...calNotOperatorWithNumberType.2.minified.js | 7 +- ...calNotOperatorWithStringType.2.minified.js | 7 +- .../mergeThreeInterfaces.2.minified.js | 7 +- .../mergeThreeInterfaces2.2.minified.js | 19 +- .../mergeTwoInterfaces.2.minified.js | 7 +- .../mergeTwoInterfaces2.2.minified.js | 16 +- ...uleWithStatementsOfEveryKind.2.minified.js | 68 ++- .../nameCollision.2.minified.js | 10 +- ...egateOperatorWithBooleanType.2.minified.js | 7 +- ...negateOperatorWithNumberType.2.minified.js | 7 +- ...negateOperatorWithStringType.2.minified.js | 7 +- .../nestedModules.2.minified.js | 7 +- ...horthandPropertiesWithModule.2.minified.js | 7 +- ...thandPropertiesWithModuleES6.2.minified.js | 7 +- ...erInitializer(target=es2015).2.minified.js | 4 + ...Initializer.2(target=es2015).2.minified.js | 8 + ...ry_IncompleteMemberVariable1.2.minified.js | 21 +- .../parserModule1.2.minified.js | 21 +- .../parserRealSource1.2.minified.js | 218 ++++----- .../parserRealSource12.2.minified.js | 219 ++++----- .../parserRealSource14.2.minified.js | 367 +++++++------- .../parserRealSource2.2.minified.js | 29 +- .../parserRealSource3.2.minified.js | 7 +- .../parserRealSource5.2.minified.js | 61 ++- .../parserRealSource6.2.minified.js | 163 +++---- .../parserRealSource8.2.minified.js | 179 ++++--- .../parserindenter.2.minified.js | 461 +++++++++--------- .../plusOperatorWithBooleanType.2.minified.js | 7 +- .../plusOperatorWithNumberType.2.minified.js | 7 +- .../plusOperatorWithStringType.2.minified.js | 7 +- ...ieldsInEsNext(target=es2020).2.minified.js | 49 +- .../scopeResolutionIdentifiers.2.minified.js | 10 +- ...staticPropertyNotInClassType.2.minified.js | 70 ++- ...ypingWithConstructSignatures.2.minified.js | 7 +- ...pingWithConstructSignatures3.2.minified.js | 10 +- ...taticMembers1(target=es2015).2.minified.js | 19 +- ...taticMembers1(target=es2021).2.minified.js | 19 +- ...taticMembers1(target=es2022).2.minified.js | 11 +- ...InStaticMembers1(target=es5).2.minified.js | 77 ++- .../symbolDeclarationEmit12.2.minified.js | 18 +- .../symbolProperty49.2.minified.js | 7 +- ...taticMembers2(target=es2015).2.minified.js | 10 +- .../tsxElementResolution7.2.minified.js | 10 +- .../tsxReactEmit6.2.minified.js | 18 +- ...nterfacesDifferentRootModule.2.minified.js | 7 +- ...terfacesDifferentRootModule2.2.minified.js | 7 +- ...facesWithDifferingOverloads2.2.minified.js | 7 +- ...entsWithStringLiteralTypes01.2.minified.js | 13 +- ...typeFromPropertyAssignment29.2.minified.js | 11 +- ...typeFromPropertyAssignment36.2.minified.js | 7 +- ...ardsInFunctionAndModuleBlock.2.minified.js | 10 +- .../typeGuardsInModule.2.minified.js | 13 +- ...peofOperatorWithAnyOtherType.2.minified.js | 7 +- ...ypeofOperatorWithBooleanType.2.minified.js | 7 +- ...typeofOperatorWithNumberType.2.minified.js | 7 +- ...typeofOperatorWithStringType.2.minified.js | 7 +- ...voidOperatorWithAnyOtherType.2.minified.js | 7 +- .../voidOperatorWithBooleanType.2.minified.js | 7 +- .../voidOperatorWithNumberType.2.minified.js | 7 +- .../voidOperatorWithStringType.2.minified.js | 7 +- 148 files changed, 1813 insertions(+), 2448 deletions(-) diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.2.minified.js index a95c1c8ea561..9425592826c9 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.2.minified.js @@ -1,6 +1,6 @@ //// [ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var A, Point = function() { +var A, Point, A1, Point1 = function() { function Point(x, y) { _class_call_check(this, Point), this.x = x, this.y = y; } @@ -11,21 +11,18 @@ var A, Point = function() { }; }, Point; }(); -(Point || (Point = {})).Origin = function() { +(Point1 || (Point1 = {})).Origin = function() { return null; -}, function(A) { - var Point = function() { - function Point(x, y) { - _class_call_check(this, Point), this.x = x, this.y = y; - } - return Point.Origin = function() { - return { - x: 0, - y: 0 - }; - }, Point; - }(); - A.Point = Point, (Point = A.Point || (A.Point = {})).Origin = function() { - return ""; - }; -}(A || (A = {})); +}, A = A1 || (A1 = {}), Point = function() { + function Point(x, y) { + _class_call_check(this, Point), this.x = x, this.y = y; + } + return Point.Origin = function() { + return { + x: 0, + y: 0 + }; + }, Point; +}(), A.Point = Point, (Point = A.Point || (A.Point = {})).Origin = function() { + return ""; +}; diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.2.minified.js index a6b8701c2b0b..7f6480df768f 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.2.minified.js @@ -1,6 +1,6 @@ //// [ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var A, Point = function() { +var A, Point, A1, Point1 = function() { function Point(x, y) { _class_call_check(this, Point), this.x = x, this.y = y; } @@ -11,17 +11,14 @@ var A, Point = function() { }; }, Point; }(); -Point || (Point = {}), function(A) { - var Point = function() { - function Point(x, y) { - _class_call_check(this, Point), this.x = x, this.y = y; - } - return Point.Origin = function() { - return { - x: 0, - y: 0 - }; - }, Point; - }(); - A.Point = Point, A.Point || (A.Point = {}); -}(A || (A = {})); +Point1 || (Point1 = {}), A = A1 || (A1 = {}), Point = function() { + function Point(x, y) { + _class_call_check(this, Point), this.x = x, this.y = y; + } + return Point.Origin = function() { + return { + x: 0, + y: 0 + }; + }, Point; +}(), A.Point = Point, A.Point || (A.Point = {}); diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.2.minified.js index 2f61ed42cb86..e4c948b4f7b1 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.2.minified.js @@ -1,17 +1,14 @@ //// [ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var A, Point = function Point(x, y) { +var A, Point, A1, Point1 = function Point(x, y) { _class_call_check(this, Point), this.x = x, this.y = y; }; -Point.Origin = { +Point1.Origin = { x: 0, y: 0 -}, (Point || (Point = {})).Origin = "", function(A) { - var Point = function Point(x, y) { - _class_call_check(this, Point), this.x = x, this.y = y; - }; - Point.Origin = { - x: 0, - y: 0 - }, A.Point = Point, (Point = A.Point || (A.Point = {})).Origin = ""; -}(A || (A = {})); +}, (Point1 || (Point1 = {})).Origin = "", A = A1 || (A1 = {}), (Point = 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 = ""; diff --git a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.2.minified.js index 58c660277d3a..f75a3a100dd0 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.2.minified.js @@ -1,17 +1,14 @@ //// [ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var A, Point = function Point(x, y) { +var A, Point, A1, Point1 = function Point(x, y) { _class_call_check(this, Point), this.x = x, this.y = y; }; -Point.Origin = { +Point1.Origin = { x: 0, y: 0 -}, Point || (Point = {}), function(A) { - var Point = function Point(x, y) { - _class_call_check(this, Point), this.x = x, this.y = y; - }; - Point.Origin = { - x: 0, - y: 0 - }, A.Point = Point, Point = A.Point || (A.Point = {}); -}(A || (A = {})); +}, Point1 || (Point1 = {}), A = A1 || (A1 = {}), (Point = 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 = {}); diff --git a/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRoot.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRoot.2.minified.js index c592d20b863f..0ca4159e7118 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRoot.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRoot.2.minified.js @@ -5,11 +5,8 @@ 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; -!function(X) { - var Y, Point; - (Point = (Y = X.Y || (X.Y = {})).Point || (Y.Point = {})).Origin = new Point(0, 0); -}(X || (X = {})); +var X, X1, Y, Point; +(Point = (Y = (X1 = X || (X = {})).Y || (X1.Y = {})).Point || (Y.Point = {})).Origin = new Point(0, 0); //// [test.ts] new X.Y.Point(1, 1), X.Y.Point.Origin; //// [simple.ts] diff --git a/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRootES6.2.minified.js b/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRootES6.2.minified.js index ef21fb088440..9f98d09f6544 100644 --- a/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRootES6.2.minified.js +++ b/crates/swc/tests/tsc-references/ClassAndModuleWithSameNameAndCommonRootES6.2.minified.js @@ -6,12 +6,9 @@ var X, X1; } }; //// [module.ts] -var X; -!function(X) { - var Y; - let Point; - (Point = (Y = X.Y || (X.Y = {})).Point || (Y.Point = {})).Origin = new Point(0, 0); -}(X || (X = {})); +var X, X1, Y; +let Point; +(Point = (Y = (X1 = X || (X = {})).Y || (X1.Y = {})).Point || (Y.Point = {})).Origin = new Point(0, 0); //// [test.ts] new X.Y.Point(1, 1), X.Y.Point.Origin; //// [simple.ts] diff --git a/crates/swc/tests/tsc-references/ES5SymbolProperty2.2.minified.js b/crates/swc/tests/tsc-references/ES5SymbolProperty2.2.minified.js index 359cc28efe2f..4d46427c09d4 100644 --- a/crates/swc/tests/tsc-references/ES5SymbolProperty2.2.minified.js +++ b/crates/swc/tests/tsc-references/ES5SymbolProperty2.2.minified.js @@ -1,12 +1,9 @@ //// [ES5SymbolProperty2.ts] -var M; +var M, M1, _$Symbol, C; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(M) { - var _$Symbol, C = function() { - function C() { - _class_call_check(this, C); - } - return C.prototype[_$Symbol.iterator] = function() {}, C; - }(); - M.C = C, (new C)[_$Symbol.iterator]; -}(M || (M = {})), (new M.C)[Symbol.iterator]; +M1 = M || (M = {}), C = function() { + function C() { + _class_call_check(this, C); + } + return C.prototype[_$Symbol.iterator] = function() {}, C; +}(), M1.C = C, (new C)[_$Symbol.iterator], (new M.C)[Symbol.iterator]; diff --git a/crates/swc/tests/tsc-references/ExportClassWhichExtendsInterfaceWithInaccessibleType.2.minified.js b/crates/swc/tests/tsc-references/ExportClassWhichExtendsInterfaceWithInaccessibleType.2.minified.js index 60927e3a294f..a9786cf3c54a 100644 --- a/crates/swc/tests/tsc-references/ExportClassWhichExtendsInterfaceWithInaccessibleType.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportClassWhichExtendsInterfaceWithInaccessibleType.2.minified.js @@ -1,14 +1,11 @@ //// [ExportClassWhichExtendsInterfaceWithInaccessibleType.ts] -var A; +var A, A1, Point2d; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(A) { - var Point2d = function() { - function Point2d(x, y) { - _class_call_check(this, Point2d), this.x = x, this.y = y; - } - return Point2d.prototype.fromOrigin = function(p) { - return 1; - }, Point2d; - }(); - A.Point2d = Point2d; -}(A || (A = {})); +A1 = A || (A = {}), Point2d = function() { + function Point2d(x, y) { + _class_call_check(this, Point2d), this.x = x, this.y = y; + } + return Point2d.prototype.fromOrigin = function(p) { + return 1; + }, Point2d; +}(), A1.Point2d = Point2d; diff --git a/crates/swc/tests/tsc-references/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.2.minified.js b/crates/swc/tests/tsc-references/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.2.minified.js index b2bff60acf0b..d54f621888fe 100644 --- a/crates/swc/tests/tsc-references/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.2.minified.js @@ -1,29 +1,24 @@ //// [ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.ts] -var A; +var A, A1, Point, Point3d; 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(A) { - var Point = function Point() { - _class_call_check(this, Point); - }; - A.Point = Point, A.Origin = { - x: 0, - y: 0 - }; - var 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); - A.Point3d = Point3d, A.Origin3d = { - x: 0, - y: 0, - z: 0 - }, A.Line = function Line(start, end) { - _class_call_check(this, Line), this.start = start, this.end = end; - }; -}(A || (A = {})); +A1 = A || (A = {}), Point = function Point() { + _class_call_check(this, Point); +}, A1.Point = Point, A1.Origin = { + x: 0, + y: 0 +}, 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 = { + x: 0, + y: 0, + z: 0 +}, 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.2.minified.js b/crates/swc/tests/tsc-references/ExportClassWithInaccessibleTypeInTypeParameterConstraint.2.minified.js index 6689f69f3aa9..59a96bf54a1b 100644 --- a/crates/swc/tests/tsc-references/ExportClassWithInaccessibleTypeInTypeParameterConstraint.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportClassWithInaccessibleTypeInTypeParameterConstraint.2.minified.js @@ -1,35 +1,29 @@ //// [ExportClassWithInaccessibleTypeInTypeParameterConstraint.ts] -var A; +var A, A1, Point3d, 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"; -!function(A) { - A.Origin = { - x: 0, - y: 0 - }; - var 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; - }(function Point() { - _class_call_check(this, Point); - }); - A.Point3d = Point3d, A.Origin3d = { - x: 0, - y: 0, - z: 0 - }; - var Line = function() { - function Line(start, end) { - _class_call_check(this, Line), this.start = start, this.end = end; - } - return Line.fromorigin2d = function(p) { - return null; - }, Line; - }(); - A.Line = Line; -}(A || (A = {})); +(A1 = A || (A = {})).Origin = { + x: 0, + y: 0 +}, 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; +}(function Point() { + _class_call_check(this, Point); +}), A1.Point3d = Point3d, A1.Origin3d = { + x: 0, + y: 0, + z: 0 +}, Line = function() { + function Line(start, end) { + _class_call_check(this, Line), this.start = start, this.end = end; + } + return Line.fromorigin2d = function(p) { + return null; + }, Line; +}(), A1.Line = Line; diff --git a/crates/swc/tests/tsc-references/ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.2.minified.js b/crates/swc/tests/tsc-references/ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.2.minified.js index 2a86c27b0fcf..e9b8d5500fb4 100644 --- a/crates/swc/tests/tsc-references/ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.2.minified.js @@ -1,17 +1,13 @@ //// [ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.ts] -var A; +var A, A1, Line; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(A) { - A.Point = function Point() { - _class_call_check(this, Point); - }; - var Line = function Line(start, end) { - _class_call_check(this, Line), this.start = start, this.end = end; - }; - A.Line = Line, A.fromOrigin = function(p) { - return new Line({ - x: 0, - y: 0 - }, p); - }; -}(A || (A = {})); +(A1 = A || (A = {})).Point = function Point() { + _class_call_check(this, Point); +}, Line = function Line(start, end) { + _class_call_check(this, Line), this.start = start, this.end = end; +}, A1.Line = Line, A1.fromOrigin = function(p) { + return new Line({ + x: 0, + y: 0 + }, p); +}; diff --git a/crates/swc/tests/tsc-references/ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.2.minified.js b/crates/swc/tests/tsc-references/ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.2.minified.js index 85d3600a61b5..ef0abb9464e5 100644 --- a/crates/swc/tests/tsc-references/ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.2.minified.js @@ -1,14 +1,11 @@ //// [ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.ts] -var A; +var A, A1, Line; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(A) { - var Line = function Line(start, end) { - _class_call_check(this, Line), this.start = start, this.end = end; - }; - A.Line = Line, A.fromOrigin = function(p) { - return new Line({ - x: 0, - y: 0 - }, p); - }; -}(A || (A = {})); +A1 = A || (A = {}), Line = function Line(start, end) { + _class_call_check(this, Line), this.start = start, this.end = end; +}, A1.Line = Line, A1.fromOrigin = function(p) { + return new Line({ + x: 0, + y: 0 + }, p); +}; diff --git a/crates/swc/tests/tsc-references/ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.2.minified.js b/crates/swc/tests/tsc-references/ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.2.minified.js index 065998f6e755..0846aa5d4fa9 100644 --- a/crates/swc/tests/tsc-references/ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.2.minified.js @@ -1,17 +1,13 @@ //// [ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.ts] -var A; +var A, A1, Line; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(A) { - A.Point = function Point() { - _class_call_check(this, Point); - }; - var Line = function Line(start, end) { - _class_call_check(this, Line), this.start = start, this.end = end; - }; - A.fromOrigin = function(p) { - return new Line({ - x: 0, - y: 0 - }, p); - }; -}(A || (A = {})); +(A1 = A || (A = {})).Point = function Point() { + _class_call_check(this, Point); +}, Line = function Line(start, end) { + _class_call_check(this, Line), this.start = start, this.end = end; +}, A1.fromOrigin = function(p) { + return new Line({ + x: 0, + y: 0 + }, p); +}; diff --git a/crates/swc/tests/tsc-references/ExportModuleWithAccessibleTypesOnItsExportedMembers.2.minified.js b/crates/swc/tests/tsc-references/ExportModuleWithAccessibleTypesOnItsExportedMembers.2.minified.js index 7180151fe9d2..c47fbbeeeb19 100644 --- a/crates/swc/tests/tsc-references/ExportModuleWithAccessibleTypesOnItsExportedMembers.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportModuleWithAccessibleTypesOnItsExportedMembers.2.minified.js @@ -1,19 +1,16 @@ //// [ExportModuleWithAccessibleTypesOnItsExportedMembers.ts] -var A; +var A, A1, Point, B, Line; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(A) { - var B, Line, Point = function Point(x, y) { - _class_call_check(this, Point), this.x = x, this.y = y; - }; - A.Point = Point, (B = A.B || (A.B = {})).Origin = new Point(0, 0), Line = function() { - function Line(start, end) { - _class_call_check(this, Line); - } - return Line.fromOrigin = function(p) { - return new Line({ - x: 0, - y: 0 - }, p); - }, Line; - }(), B.Line = Line; -}(A || (A = {})); +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() { + function Line(start, end) { + _class_call_check(this, Line); + } + return Line.fromOrigin = function(p) { + return new Line({ + x: 0, + y: 0 + }, p); + }, Line; +}(), B.Line = Line; diff --git a/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.2.minified.js b/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.2.minified.js index 21552d992c3a..c02904af1e03 100644 --- a/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.2.minified.js @@ -1,15 +1,12 @@ //// [ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.ts] -var A; +var A, A1, Point; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(A) { - var Point = function Point(x, y) { - _class_call_check(this, Point), this.x = x, this.y = y; - }; - A.Origin = { - x: 0, - y: 0 - }, A.Unity = { - start: new Point(0, 0), - end: new Point(1, 0) - }; -}(A || (A = {})); +A1 = A || (A = {}), Point = function Point(x, y) { + _class_call_check(this, Point), this.x = x, this.y = y; +}, A1.Origin = { + x: 0, + y: 0 +}, A1.Unity = { + start: new Point(0, 0), + end: new Point(1, 0) +}; diff --git a/crates/swc/tests/tsc-references/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.2.minified.js b/crates/swc/tests/tsc-references/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.2.minified.js index c1e70f454ac5..ce80ed46ad3d 100644 --- a/crates/swc/tests/tsc-references/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.2.minified.js +++ b/crates/swc/tests/tsc-references/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.2.minified.js @@ -1,7 +1,4 @@ //// [ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.ts] -var A; +var A, A1, beez; import "@swc/helpers/_/_class_call_check"; -!function(A) { - var beez; - A.beez2 = [], A.beez = beez; -}(A || (A = {})); +(A1 = A || (A = {})).beez2 = [], A1.beez = beez; diff --git a/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndCommonRoot.2.minified.js b/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndCommonRoot.2.minified.js index 32286a71548b..96833687f068 100644 --- a/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndCommonRoot.2.minified.js +++ b/crates/swc/tests/tsc-references/FunctionAndModuleWithSameNameAndCommonRoot.2.minified.js @@ -15,16 +15,13 @@ var A, A1; //// [test.ts] A.Point, A.Point(), A.Point.Origin; //// [simple.ts] -var B; -!function(B) { - var Point = function() { - return { - x: 0, - y: 0 - }; - }; - B.Point = Point, (Point = B.Point || (B.Point = {})).Origin = { +var B, B1, Point; +Point = function() { + return { x: 0, y: 0 }; -}(B || (B = {})), B.Point, B.Point(), B.Point.Origin; +}, (B1 = B || (B = {})).Point = Point, (Point = B1.Point || (B1.Point = {})).Origin = { + x: 0, + y: 0 +}, B.Point, B.Point(), B.Point.Origin; diff --git a/crates/swc/tests/tsc-references/ModuleAndClassWithSameNameAndCommonRoot.2.minified.js b/crates/swc/tests/tsc-references/ModuleAndClassWithSameNameAndCommonRoot.2.minified.js index d009d02d2c24..f7ef97735344 100644 --- a/crates/swc/tests/tsc-references/ModuleAndClassWithSameNameAndCommonRoot.2.minified.js +++ b/crates/swc/tests/tsc-references/ModuleAndClassWithSameNameAndCommonRoot.2.minified.js @@ -1,9 +1,6 @@ //// [module.ts] -var X; -!function(X) { - var Y, Point; - (Point = (Y = X.Y || (X.Y = {})).Point || (Y.Point = {})).Origin = new Point(0, 0); -}(X || (X = {})); +var X, X1, Y, Point; +(Point = (Y = (X1 = X || (X = {})).Y || (X1.Y = {})).Point || (Y.Point = {})).Origin = new Point(0, 0); //// [classPoint.ts] var X, X1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; diff --git a/crates/swc/tests/tsc-references/ModuleAndFunctionWithSameNameAndCommonRoot.2.minified.js b/crates/swc/tests/tsc-references/ModuleAndFunctionWithSameNameAndCommonRoot.2.minified.js index f709b7f39c09..58e881c4a1d2 100644 --- a/crates/swc/tests/tsc-references/ModuleAndFunctionWithSameNameAndCommonRoot.2.minified.js +++ b/crates/swc/tests/tsc-references/ModuleAndFunctionWithSameNameAndCommonRoot.2.minified.js @@ -13,16 +13,13 @@ var A; }; }; //// [simple.ts] -var B; -!function(B) { - var Point = function() { - return { - x: 0, - y: 0 - }; - }; - (Point = B.Point || (B.Point = {})).Origin = { +var B, B1, Point; +Point = function() { + return { x: 0, y: 0 - }, B.Point = Point; -}(B || (B = {})); + }; +}, (Point = (B1 = B || (B = {})).Point || (B1.Point = {})).Origin = { + x: 0, + y: 0 +}, B1.Point = Point; diff --git a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedEnums.2.minified.js b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedEnums.2.minified.js index 0ac78452a0b4..fd9fe60bbfb1 100644 --- a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedEnums.2.minified.js +++ b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedEnums.2.minified.js @@ -1,6 +1,3 @@ //// [ModuleWithExportedAndNonExportedEnums.ts] -var A; -!function(A) { - var Day, Color, Day1; - (Color = A.Color || (A.Color = {}))[Color.Red = 0] = "Red", Color[Color.Blue = 1] = "Blue", (Day1 = Day || (Day = {}))[Day1.Monday = 0] = "Monday", Day1[Day1.Tuesday = 1] = "Tuesday"; -}(A || (A = {})), A.Color.Red, A.Day.Monday; +var A, A1, Day, Color, Day1; +(Color = (A1 = A || (A = {})).Color || (A1.Color = {}))[Color.Red = 0] = "Red", Color[Color.Blue = 1] = "Blue", (Day1 = Day || (Day = {}))[Day1.Monday = 0] = "Monday", Day1[Day1.Tuesday = 1] = "Tuesday", A.Color.Red, A.Day.Monday; diff --git a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedImportAlias.2.minified.js b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedImportAlias.2.minified.js index 987836efda18..c8f78d867538 100644 --- a/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedImportAlias.2.minified.js +++ b/crates/swc/tests/tsc-references/ModuleWithExportedAndNonExportedImportAlias.2.minified.js @@ -1,17 +1,12 @@ //// [ModuleWithExportedAndNonExportedImportAlias.ts] -var B, Geometry; +var B, Geometry, Geometry1, Points, Lines, Origin; 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; -}, function(Geometry) { - var Points = A; - Geometry.Points = Points; - var Lines = B, Origin = Geometry.Origin = { - x: 0, - y: 0 - }; - Geometry.Unit = new Lines.Line(Origin, { - x: 1, - y: 0 - }); -}(Geometry || (Geometry = {})), Geometry.Origin, Geometry.Unit, Geometry.Lines.Line; +}, Geometry1 = Geometry || (Geometry = {}), Points = A, Geometry1.Points = Points, Lines = B, Origin = Geometry1.Origin = { + x: 0, + y: 0 +}, Geometry1.Unit = new Lines.Line(Origin, { + x: 1, + y: 0 +}), Geometry.Origin, Geometry.Unit, Geometry.Lines.Line; diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName.2.minified.js b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName.2.minified.js index 8e31cbc23056..dd585078abd9 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName.2.minified.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName.2.minified.js @@ -1,14 +1,8 @@ //// [TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName.ts] -var A, X; +var A, X, X1, Y, X2, Y1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; (A || (A = {})).Point = function Point() { _class_call_check(this, Point); -}, A || (A = {}), function(X) { - var Y; - ((Y = X.Y || (X.Y = {})).Z || (Y.Z = {})).Line = function Line() { - _class_call_check(this, Line); - }; -}(X || (X = {})), function(X) { - var Y; - (Y = X.Y || (X.Y = {})).Z || (Y.Z = {}); -}(X || (X = {})); +}, A || (A = {}), ((Y = (X1 = X || (X = {})).Y || (X1.Y = {})).Z || (Y.Z = {})).Line = function Line() { + _class_call_check(this, Line); +}, (Y1 = (X2 = X || (X = {})).Y || (X2.Y = {})).Z || (Y1.Z = {}); diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.2.minified.js b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.2.minified.js index 3eeaec6e277f..026505170e33 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.2.minified.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.2.minified.js @@ -1,18 +1,12 @@ //// [TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts] -var A, X; +var A, X, X1, Y, X2, Y1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; (A || (A = {})).Point = function Point() { _class_call_check(this, Point); }, (A || (A = {})).Point = function Point() { _class_call_check(this, Point); -}, function(X) { - var Y; - ((Y = X.Y || (X.Y = {})).Z || (Y.Z = {})).Line = function Line() { - _class_call_check(this, Line); - }; -}(X || (X = {})), function(X) { - var Y; - ((Y = X.Y || (X.Y = {})).Z || (Y.Z = {})).Line = function Line() { - _class_call_check(this, Line); - }; -}(X || (X = {})); +}, ((Y = (X1 = X || (X = {})).Y || (X1.Y = {})).Z || (Y.Z = {})).Line = function Line() { + _class_call_check(this, Line); +}, ((Y1 = (X2 = X || (X = {})).Y || (X2.Y = {})).Z || (Y1.Z = {})).Line = function Line() { + _class_call_check(this, Line); +}; diff --git a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.2.minified.js b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.2.minified.js index 85a41d622c39..94fda1145bca 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.2.minified.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.2.minified.js @@ -1,20 +1,8 @@ //// [TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.ts] -var A, X; +var A, X, A1, x, B, x1, X1, Y, X2, Z; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(A) { - var x; - (A.B || (A.B = {})).x = x; -}(A || (A = {})), function(A) { - var B, x; - (B || (B = {})).x = x; -}(A || (A = {})), A.B.x, function(X) { - var Y; - ((Y = X.Y || (X.Y = {})).Z || (Y.Z = {})).Line = function Line() { - _class_call_check(this, Line); - }; -}(X || (X = {})), function(X) { - var Z; - X.Y || (X.Y = {}), (Z || (Z = {})).Line = function Line() { - _class_call_check(this, Line); - }; -}(X || (X = {})); +((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() { + _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.2.minified.js b/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndDifferentCommonRoot.2.minified.js index 3dfa6f08c535..c049162e2b3d 100644 --- a/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndDifferentCommonRoot.2.minified.js +++ b/crates/swc/tests/tsc-references/TwoInternalModulesWithTheSameNameAndDifferentCommonRoot.2.minified.js @@ -1,23 +1,17 @@ //// [part1.ts] -var Root; -!function(Root) { - var A; - ((A = Root.A || (Root.A = {})).Utils || (A.Utils = {})).mirror = function(p) { - return { - x: p.y, - y: p.x - }; +var Root, Root1, A; +((A = (Root1 = Root || (Root = {})).A || (Root1.A = {})).Utils || (A.Utils = {})).mirror = function(p) { + return { + x: p.y, + y: p.x }; -}(Root || (Root = {})); +}; //// [part2.ts] -var otherRoot; +var otherRoot, otherRoot1, A; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(otherRoot) { - var A; - (A = otherRoot.A || (otherRoot.A = {})).Origin = { - x: 0, - y: 0 - }, (A.Utils || (A.Utils = {})).Plane = function Plane(tl, br) { - _class_call_check(this, Plane), this.tl = tl, this.br = br; - }; -}(otherRoot || (otherRoot = {})); +(A = (otherRoot1 = otherRoot || (otherRoot = {})).A || (otherRoot1.A = {})).Origin = { + x: 0, + y: 0 +}, (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/additionOperatorWithAnyAndEveryType.2.minified.js b/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType.2.minified.js index fa9b882faf64..ea119e87116b 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType.2.minified.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType.2.minified.js @@ -1,12 +1,9 @@ //// [additionOperatorWithAnyAndEveryType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var E, E1, M, C = function() { +var E, a, E1, M, C = function() { function C() { _class_call_check(this, C); } return C.foo = function() {}, C; }(); -(E = E1 || (E1 = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", function(M) { - var a; - M.a = a; -}(M || (M = {})), new C(), E1.a; +(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; diff --git a/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands.2.minified.js b/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands.2.minified.js index 5e1125603170..b9d3efb647f2 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands.2.minified.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands.2.minified.js @@ -1,12 +1,9 @@ //// [additionOperatorWithInvalidOperands.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var E, E1, M, C = function() { +var E, a, E1, M, C = function() { function C() { _class_call_check(this, C); } return C.foo = function() {}, C; }(); -(E = E1 || (E1 = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", function(M) { - var a; - M.a = a; -}(M || (M = {})), 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", (M || (M = {})).a = a, E1.a, new C(), E1.a, C.foo(), E1.a; diff --git a/crates/swc/tests/tsc-references/ambientInsideNonAmbient.2.minified.js b/crates/swc/tests/tsc-references/ambientInsideNonAmbient.2.minified.js index 5b12fad9aea9..327c9105a1c5 100644 --- a/crates/swc/tests/tsc-references/ambientInsideNonAmbient.2.minified.js +++ b/crates/swc/tests/tsc-references/ambientInsideNonAmbient.2.minified.js @@ -1,6 +1,3 @@ //// [ambientInsideNonAmbient.ts] -var M2; -!function(M2) { - var E; - E || (E = {}); -}(M2 || (M2 = {})); +var M2, E; +M2 || (M2 = {}), E || (E = {}); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithCallSignatures4.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithCallSignatures4.2.minified.js index 9d78303913a2..de211216c678 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithCallSignatures4.2.minified.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithCallSignatures4.2.minified.js @@ -1,9 +1,6 @@ //// [assignmentCompatWithCallSignatures4.ts] -var Errors; +var Errors, WithNonGenericSignaturesInBaseType, WithGenericSignaturesInBaseType; 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(Errors) { - var WithNonGenericSignaturesInBaseType, WithGenericSignaturesInBaseType; - WithNonGenericSignaturesInBaseType || (WithNonGenericSignaturesInBaseType = {}), WithGenericSignaturesInBaseType || (WithGenericSignaturesInBaseType = {}); -}(Errors || (Errors = {})); +Errors || (Errors = {}), WithNonGenericSignaturesInBaseType || (WithNonGenericSignaturesInBaseType = {}), WithGenericSignaturesInBaseType || (WithGenericSignaturesInBaseType = {}); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignatures4.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignatures4.2.minified.js index 70784e528031..2b94e7e9abd9 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignatures4.2.minified.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithConstructSignatures4.2.minified.js @@ -1,9 +1,6 @@ //// [assignmentCompatWithConstructSignatures4.ts] -var Errors; +var Errors, WithNonGenericSignaturesInBaseType, WithGenericSignaturesInBaseType; 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(Errors) { - var WithNonGenericSignaturesInBaseType, WithGenericSignaturesInBaseType; - WithNonGenericSignaturesInBaseType || (WithNonGenericSignaturesInBaseType = {}), WithGenericSignaturesInBaseType || (WithGenericSignaturesInBaseType = {}); -}(Errors || (Errors = {})); +Errors || (Errors = {}), WithNonGenericSignaturesInBaseType || (WithNonGenericSignaturesInBaseType = {}), WithGenericSignaturesInBaseType || (WithGenericSignaturesInBaseType = {}); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion.2.minified.js index 858426dcaa90..06adee48ced0 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion.2.minified.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion.2.minified.js @@ -1,8 +1,5 @@ //// [assignmentCompatWithDiscriminatedUnion.ts] -var Example1, Example2, Example3, Example4, Example5, GH14865, GH30170, GH12052, GH18421, GH15907, GH20889, GH39357; -Example1 || (Example1 = {}), t = s, Example2 || (Example2 = {}), t = s, Example3 || (Example3 = {}), t = s, Example4 || (Example4 = {}), t = s, Example5 || (Example5 = {}), t = s, GH14865 || (GH14865 = {}), (void 0).type, GH30170 || (GH30170 = {}), function(GH12052) { - var getAxisType = function() { - return "categorical"; - }; - getAxisType(), getAxisType(); -}(GH12052 || (GH12052 = {})), GH18421 || (GH18421 = {}), GH15907 || (GH15907 = {}), GH20889 || (GH20889 = {}), GH39357 || (GH39357 = {}), ("a" === b || "b" === b) && b; +var Example1, Example2, Example3, Example4, Example5, GH14865, GH30170, GH12052, GH18421, GH15907, GH20889, GH39357, b1, getAxisType; +Example1 || (Example1 = {}), t = s, Example2 || (Example2 = {}), t = s, Example3 || (Example3 = {}), t = s, Example4 || (Example4 = {}), t = s, Example5 || (Example5 = {}), t = s, GH14865 || (GH14865 = {}), b1.type, GH30170 || (GH30170 = {}), GH12052 || (GH12052 = {}), (getAxisType = function() { + return "categorical"; +})(), getAxisType(), GH18421 || (GH18421 = {}), GH15907 || (GH15907 = {}), GH20889 || (GH20889 = {}), GH39357 || (GH39357 = {}), ("a" === b || "b" === b) && b; diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembers.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembers.2.minified.js index 5a2ef5cf7329..0e7aca62f320 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembers.2.minified.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembers.2.minified.js @@ -1,4 +1,8 @@ //// [assignmentCompatWithObjectMembers.ts] -var SimpleTypes, ObjectTypes; +var SimpleTypes, ObjectTypes, t2, b, a2, b2; import "@swc/helpers/_/_class_call_check"; -SimpleTypes || (SimpleTypes = {}), ObjectTypes || (ObjectTypes = {}); +SimpleTypes || (SimpleTypes = {}), ObjectTypes || (ObjectTypes = {}), a2 = { + foo: a2 +}, b2 = a2 = b2 = { + foo: b2 +}, a2 = b, a2 = t2; diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembers4.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembers4.2.minified.js index 3d62d1a0d55e..09c99aa56f68 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembers4.2.minified.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembers4.2.minified.js @@ -1,37 +1,31 @@ //// [assignmentCompatWithObjectMembers4.ts] -var OnlyDerived, WithBase; +var OnlyDerived, WithBase, Base, Derived, Derived2, Base1, Derived21; 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(OnlyDerived) { - var Base = function Base() { - _class_call_check(this, Base); - }, Derived = function(Base) { - _inherits(Derived, Base); - var _super = _create_super(Derived); - function Derived() { - return _class_call_check(this, Derived), _super.apply(this, arguments); - } - return Derived; - }(Base), Derived2 = function(Base) { - _inherits(Derived2, Base); - var _super = _create_super(Derived2); - function Derived2() { - return _class_call_check(this, Derived2), _super.apply(this, arguments); - } - return Derived2; - }(Base); - new Derived(), new Derived2(); -}(OnlyDerived || (OnlyDerived = {})), function(WithBase) { - var Base = function Base() { - _class_call_check(this, Base); - }, Derived2 = function(Base) { - _inherits(Derived2, Base); - var _super = _create_super(Derived2); - function Derived2() { - return _class_call_check(this, Derived2), _super.apply(this, arguments); - } - return Derived2; - }(Base); - new Base(), new Derived2(); -}(WithBase || (WithBase = {})); +OnlyDerived || (OnlyDerived = {}), Derived = function(Base) { + _inherits(Derived, Base); + var _super = _create_super(Derived); + function Derived() { + return _class_call_check(this, Derived), _super.apply(this, arguments); + } + return Derived; +}(Base = function Base() { + _class_call_check(this, Base); +}), Derived2 = function(Base) { + _inherits(Derived2, Base); + var _super = _create_super(Derived2); + function Derived2() { + return _class_call_check(this, Derived2), _super.apply(this, arguments); + } + return Derived2; +}(Base), new Derived(), new Derived2(), WithBase || (WithBase = {}), Derived21 = function(Base) { + _inherits(Derived2, Base); + var _super = _create_super(Derived2); + function Derived2() { + return _class_call_check(this, Derived2), _super.apply(this, arguments); + } + return Derived2; +}(Base1 = function Base() { + _class_call_check(this, Base); +}), new Base1(), new Derived21(); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembersAccessibility.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembersAccessibility.2.minified.js index 3bf9121d1fba..441212f679d6 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembersAccessibility.2.minified.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithObjectMembersAccessibility.2.minified.js @@ -1,10 +1,4 @@ //// [assignmentCompatWithObjectMembersAccessibility.ts] -var TargetIsPublic; +var TargetIsPublic, a, b, i, d, e, a1, b1, i1, d1, e1; import "@swc/helpers/_/_class_call_check"; -!function(TargetIsPublic) { - var a, b, i, d, e; - a = b, a = i, a = d, b = a = e, b = i, b = d, b = e, i = a, i = b, i = d, i = e, d = a, d = b, d = i, d = e, e = a, e = b, e = i, e = d; -}(TargetIsPublic || (TargetIsPublic = {})), function(TargetIsPublic) { - var a, b, i, d, e; - a = b, a = i, a = d, b = a = e, b = i, b = d, b = e, i = a, i = b, i = d, i = e, d = a, d = b, d = i, d = e, e = a, e = b, e = i, e = d; -}(TargetIsPublic || (TargetIsPublic = {})); +TargetIsPublic || (TargetIsPublic = {}), a = b, a = i, a = d, b = a = e, b = i, b = d, b = e, i = a, i = b, i = d, i = e, d = a, d = b, d = i, d = e, e = a, e = b, e = i, e = d, TargetIsPublic || (TargetIsPublic = {}), a1 = b1, a1 = i1, a1 = d1, b1 = a1 = e1, b1 = i1, b1 = d1, b1 = e1, i1 = a1, i1 = b1, i1 = d1, i1 = e1, d1 = a1, d1 = b1, d1 = i1, d1 = e1, e1 = a1, e1 = b1, e1 = i1, e1 = d1; diff --git a/crates/swc/tests/tsc-references/assignmentToParenthesizedIdentifiers.2.minified.js b/crates/swc/tests/tsc-references/assignmentToParenthesizedIdentifiers.2.minified.js index 3e4ecb324088..9c73601609d6 100644 --- a/crates/swc/tests/tsc-references/assignmentToParenthesizedIdentifiers.2.minified.js +++ b/crates/swc/tests/tsc-references/assignmentToParenthesizedIdentifiers.2.minified.js @@ -1,17 +1,11 @@ //// [assignmentToParenthesizedIdentifiers.ts] -var M, M2, E, E1; +var M, M2, E, y, M21, x, E1; import "@swc/helpers/_/_class_call_check"; -!function(M) { - var y; - M.y = y; -}(M || (M = {})), M.y = 3, M.y = 3, M.y = 3, M.y = "", M.y = "", M.y = "", M = { +(M || (M = {})).y = y, M.y = 3, M.y = 3, M.y = 3, M.y = "", M.y = "", M.y = "", M = { y: 3 }, M = { y: 3 -}, function(M2) { - var x; - (M2.M3 || (M2.M3 = {})).x = x; -}(M2 || (M2 = {})), M2.M3 = { +}, ((M21 = M2 || (M2 = {})).M3 || (M21.M3 = {})).x = x, M2.M3 = { x: 3 }, M2.M3 = { x: 3 diff --git a/crates/swc/tests/tsc-references/asyncAwaitNestedClasses_es5.2.minified.js b/crates/swc/tests/tsc-references/asyncAwaitNestedClasses_es5.2.minified.js index ccc162d2883f..f246b823fb76 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitNestedClasses_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/asyncAwaitNestedClasses_es5.2.minified.js @@ -2,40 +2,37 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator"; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; -var A = function A() { +var _B, A = function A() { _class_call_check(this, A); }; -!function() { - var _B; - A.B = ((_B = function() { - function B() { - _class_call_check(this, B); - } - return B.func2 = function() { - return new Promise(function(resolve) { - resolve(null); +A.B = ((_B = function() { + function B() { + _class_call_check(this, B); + } + return B.func2 = function() { + return new Promise(function(resolve) { + resolve(null); + }); + }, B; +}()).C = function() { + function C() { + _class_call_check(this, C); + } + return C.func = function() { + return _async_to_generator(function() { + return _ts_generator(this, function(_state) { + switch(_state.label){ + case 0: + return [ + 4, + _B.func2() + ]; + case 1: + return _state.sent(), [ + 2 + ]; + } }); - }, B; - }()).C = function() { - function C() { - _class_call_check(this, C); - } - return C.func = function() { - return _async_to_generator(function() { - return _ts_generator(this, function(_state) { - switch(_state.label){ - case 0: - return [ - 4, - _B.func2() - ]; - case 1: - return _state.sent(), [ - 2 - ]; - } - }); - })(); - }, C; - }(), _B); -}(), A.B.C.func(); + })(); + }, C; +}(), _B), A.B.C.func(); diff --git a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithBooleanType.2.minified.js b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithBooleanType.2.minified.js index 6d5a4d80b2e1..399af51763cc 100644 --- a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithBooleanType.2.minified.js +++ b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithBooleanType.2.minified.js @@ -1,6 +1,6 @@ //// [bitwiseNotOperatorWithBooleanType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var M, A = function() { +var n, M, A = function() { function A() { _class_call_check(this, A); } @@ -8,9 +8,6 @@ var M, A = function() { return !1; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithNumberType.2.minified.js index 8162e76ecc05..1acd7e57fc17 100644 --- a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithNumberType.2.minified.js @@ -1,6 +1,6 @@ //// [bitwiseNotOperatorWithNumberType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var M, A = function() { +var M, n, A = function() { function A() { _class_call_check(this, A); } @@ -8,9 +8,6 @@ var M, A = function() { return 1; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; 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.2.minified.js b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithStringType.2.minified.js index 5dde16389c5f..f14bdda2d7d7 100644 --- a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithStringType.2.minified.js +++ b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithStringType.2.minified.js @@ -1,6 +1,6 @@ //// [bitwiseNotOperatorWithStringType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var STRING, M, A = function() { +var STRING, M, n, A = function() { function A() { _class_call_check(this, A); } @@ -8,9 +8,6 @@ var STRING, M, A = function() { return ""; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; 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/circularImportAlias.2.minified.js b/crates/swc/tests/tsc-references/circularImportAlias.2.minified.js index b16069507633..57452af912d2 100644 --- a/crates/swc/tests/tsc-references/circularImportAlias.2.minified.js +++ b/crates/swc/tests/tsc-references/circularImportAlias.2.minified.js @@ -1,24 +1,15 @@ //// [circularImportAlias.ts] -var B, A; +var B, A, B1, a, D, A1, b; 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(B) { - var a = A; - B.a = a; - var 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); - B.D = D; -}(B || (B = {})), function(A) { - A.C = function C() { - _class_call_check(this, C); - }; - var b = B; - A.b = b; -}(A || (A = {})), new B.a.C(); +B1 = B || (B = {}), a = A, B1.a = a, 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() { + _class_call_check(this, C); +}, b = B, A1.b = b, new B.a.C(); diff --git a/crates/swc/tests/tsc-references/classAbstractImportInstantiation.2.minified.js b/crates/swc/tests/tsc-references/classAbstractImportInstantiation.2.minified.js index 24475b2c210b..2be563d02dc3 100644 --- a/crates/swc/tests/tsc-references/classAbstractImportInstantiation.2.minified.js +++ b/crates/swc/tests/tsc-references/classAbstractImportInstantiation.2.minified.js @@ -1,9 +1,6 @@ //// [classAbstractImportInstantiation.ts] -var M; +var M, A, M1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(M) { - var A = function A() { - _class_call_check(this, A); - }; - M.A = A, new A; -}(M || (M = {})), new M.A; +M = M1 || (M1 = {}), A = function A() { + _class_call_check(this, A); +}, M.A = A, new A, new M1.A; diff --git a/crates/swc/tests/tsc-references/classAbstractInAModule.2.minified.js b/crates/swc/tests/tsc-references/classAbstractInAModule.2.minified.js index d0d68800be71..b379811fea8a 100644 --- a/crates/swc/tests/tsc-references/classAbstractInAModule.2.minified.js +++ b/crates/swc/tests/tsc-references/classAbstractInAModule.2.minified.js @@ -1,20 +1,15 @@ //// [classAbstractInAModule.ts] -var M; +var M, M1, A, B; 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(M) { - var A = function A() { - _class_call_check(this, A); - }; - M.A = A; - var B = function(A) { - _inherits(B, A); - var _super = _create_super(B); - function B() { - return _class_call_check(this, B), _super.apply(this, arguments); - } - return B; - }(A); - M.B = B; -}(M || (M = {})), new M.A, new M.B; +M1 = M || (M = {}), A = function A() { + _class_call_check(this, A); +}, M1.A = A, B = function(A) { + _inherits(B, A); + var _super = _create_super(B); + function B() { + return _class_call_check(this, B), _super.apply(this, arguments); + } + return B; +}(A), M1.B = B, new M.A, new M.B; diff --git a/crates/swc/tests/tsc-references/classExtendsItselfIndirectly2.2.minified.js b/crates/swc/tests/tsc-references/classExtendsItselfIndirectly2.2.minified.js index 1352545e04e7..17695e5cc4ce 100644 --- a/crates/swc/tests/tsc-references/classExtendsItselfIndirectly2.2.minified.js +++ b/crates/swc/tests/tsc-references/classExtendsItselfIndirectly2.2.minified.js @@ -2,56 +2,47 @@ 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 M, N, O, C = function(_N_E) { +var M, D, N, E, P, Q, C2, P1, D2, Q1, E2, M1, N1, O, C = function(_N_E) { _inherits(C, _N_E); var _super = _create_super(C); function C() { return _class_call_check(this, C), _super.apply(this, arguments); } return C; -}(N.E); -!function(M) { - var D = function(C) { - _inherits(D, C); - var _super = _create_super(D); - function D() { - return _class_call_check(this, D), _super.apply(this, arguments); - } - return D; - }(C); - M.D = D; -}(M || (M = {})), function(N) { - var E = function(_M_D) { - _inherits(E, _M_D); - var _super = _create_super(E); - function E() { - return _class_call_check(this, E), _super.apply(this, arguments); - } - return E; - }(M.D); - N.E = E; -}(N || (N = {})), function(O) { - var P, D2, Q, E2, P1, Q1, C2 = function(_Q_E2) { - _inherits(C2, _Q_E2); - var _super = _create_super(C2); - function C2() { - return _class_call_check(this, C2), _super.apply(this, arguments); - } - return C2; - }(Q1.E2); - P = P1 || (P1 = {}), D2 = function(C2) { - _inherits(D2, C2); - var _super = _create_super(D2); - function D2() { - return _class_call_check(this, D2), _super.apply(this, arguments); - } - return D2; - }(C2), P.D2 = D2, Q = Q1 || (Q1 = {}), E2 = function(_P_D2) { - _inherits(E2, _P_D2); - var _super = _create_super(E2); - function E2() { - return _class_call_check(this, E2), _super.apply(this, arguments); - } - return E2; - }(P1.D2), Q.E2 = E2; -}(O || (O = {})); +}(N1.E); +M = M1 || (M1 = {}), D = function(C) { + _inherits(D, C); + var _super = _create_super(D); + function D() { + return _class_call_check(this, D), _super.apply(this, arguments); + } + return D; +}(C), M.D = D, N = N1 || (N1 = {}), E = function(_M_D) { + _inherits(E, _M_D); + var _super = _create_super(E); + function E() { + return _class_call_check(this, E), _super.apply(this, arguments); + } + return E; +}(M1.D), N.E = E, O || (O = {}), C2 = function(_Q_E2) { + _inherits(C2, _Q_E2); + var _super = _create_super(C2); + function C2() { + return _class_call_check(this, C2), _super.apply(this, arguments); + } + return C2; +}(Q.E2), P1 = P || (P = {}), D2 = function(C2) { + _inherits(D2, C2); + var _super = _create_super(D2); + function D2() { + return _class_call_check(this, D2), _super.apply(this, arguments); + } + return D2; +}(C2), P1.D2 = D2, Q1 = Q || (Q = {}), E2 = function(_P_D2) { + _inherits(E2, _P_D2); + var _super = _create_super(E2); + function E2() { + return _class_call_check(this, E2), _super.apply(this, arguments); + } + return E2; +}(P.D2), Q1.E2 = E2; diff --git a/crates/swc/tests/tsc-references/classWithConstructors.2.minified.js b/crates/swc/tests/tsc-references/classWithConstructors.2.minified.js index b50a71d710b1..8276a916a18c 100644 --- a/crates/swc/tests/tsc-references/classWithConstructors.2.minified.js +++ b/crates/swc/tests/tsc-references/classWithConstructors.2.minified.js @@ -1,42 +1,28 @@ //// [classWithConstructors.ts] -var NonGeneric, Generics; +var NonGeneric, Generics, C, C2, D, C1, C21, D1; 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(NonGeneric) { - var C = function C(x) { - _class_call_check(this, C); - }; - new C(), new C(""); - var C2 = function C2(x) { - _class_call_check(this, C2); - }; - new C2(), new C2(""), new C2(1); - var D = function(C2) { - _inherits(D, C2); - var _super = _create_super(D); - function D() { - return _class_call_check(this, D), _super.apply(this, arguments); - } - return D; - }(C2); - new D(), new D(1), new D(""); -}(NonGeneric || (NonGeneric = {})), function(Generics) { - var C = function C(x) { - _class_call_check(this, C); - }; - new C(), new C(""); - var C2 = function C2(x) { - _class_call_check(this, C2); - }; - new C2(), new C2(""), new C2(1, 2); - var D = function(C2) { - _inherits(D, C2); - var _super = _create_super(D); - function D() { - return _class_call_check(this, D), _super.apply(this, arguments); - } - return D; - }(C2); - new D(), new D(1), new D(""); -}(Generics || (Generics = {})); +NonGeneric || (NonGeneric = {}), new (C = function C(x) { + _class_call_check(this, C); +})(), new C(""), new (C2 = function C2(x) { + _class_call_check(this, C2); +})(), new C2(""), new C2(1), new (D = function(C2) { + _inherits(D, C2); + var _super = _create_super(D); + function D() { + return _class_call_check(this, D), _super.apply(this, arguments); + } + return D; +}(C2))(), new D(1), new D(""), Generics || (Generics = {}), new (C1 = function C(x) { + _class_call_check(this, C); +})(), new C1(""), new (C21 = function C2(x) { + _class_call_check(this, C2); +})(), new C21(""), new C21(1, 2), new (D1 = function(C2) { + _inherits(D, C2); + var _super = _create_super(D); + function D() { + return _class_call_check(this, D), _super.apply(this, arguments); + } + return D; +}(C21))(), new D1(1), new D1(""); diff --git a/crates/swc/tests/tsc-references/constAssertionOnEnum.2.minified.js b/crates/swc/tests/tsc-references/constAssertionOnEnum.2.minified.js index 9535e0577517..ed06affd361a 100644 --- a/crates/swc/tests/tsc-references/constAssertionOnEnum.2.minified.js +++ b/crates/swc/tests/tsc-references/constAssertionOnEnum.2.minified.js @@ -9,11 +9,8 @@ var Bar, Bar1; import { Foo } from './enum'; (Bar1 = Bar || (Bar = {}))[Bar1.A = 0] = "A", Bar1[Bar1.B = 1] = "B", Foo.A, Bar.A; //// [ns.ts] -var ns; -!function(ns1) { - var Foo; - (Foo = ns1.Foo || (ns1.Foo = {}))[Foo.X = 0] = "X", ns.Foo.X; -}(ns || (ns = {})); +var ns, ns1, Foo; +(Foo = (ns1 = ns || (ns = {})).Foo || (ns1.Foo = {}))[Foo.X = 0] = "X", ns.Foo.X; //// [more.ts] var Foo; var Foo1; diff --git a/crates/swc/tests/tsc-references/constructorHasPrototypeProperty.2.minified.js b/crates/swc/tests/tsc-references/constructorHasPrototypeProperty.2.minified.js index 5b381856eabc..e1775c24769c 100644 --- a/crates/swc/tests/tsc-references/constructorHasPrototypeProperty.2.minified.js +++ b/crates/swc/tests/tsc-references/constructorHasPrototypeProperty.2.minified.js @@ -1,30 +1,24 @@ //// [constructorHasPrototypeProperty.ts] -var NonGeneric, Generic; +var NonGeneric, Generic, C, D, C1, D1; 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(NonGeneric) { - var C = function C() { - _class_call_check(this, C); - }, D = function(C) { - _inherits(D, C); - var _super = _create_super(D); - function D() { - return _class_call_check(this, D), _super.apply(this, arguments); - } - return D; - }(C); - C.prototype.foo, D.prototype.bar; -}(NonGeneric || (NonGeneric = {})), function(Generic) { - var C = function C() { - _class_call_check(this, C); - }, D = function(C) { - _inherits(D, C); - var _super = _create_super(D); - function D() { - return _class_call_check(this, D), _super.apply(this, arguments); - } - return D; - }(C); - C.prototype.foo, D.prototype.baz; -}(Generic || (Generic = {})); +NonGeneric || (NonGeneric = {}), D = function(C) { + _inherits(D, C); + var _super = _create_super(D); + function D() { + return _class_call_check(this, D), _super.apply(this, arguments); + } + return D; +}(C = function C() { + _class_call_check(this, C); +}), C.prototype.foo, D.prototype.bar, Generic || (Generic = {}), D1 = function(C) { + _inherits(D, C); + var _super = _create_super(D); + function D() { + return _class_call_check(this, D), _super.apply(this, arguments); + } + return D; +}(C1 = function C() { + _class_call_check(this, C); +}), C1.prototype.foo, D1.prototype.baz; diff --git a/crates/swc/tests/tsc-references/decrementOperatorWithAnyOtherType.2.minified.js b/crates/swc/tests/tsc-references/decrementOperatorWithAnyOtherType.2.minified.js index c4f82329d2f8..d6cb5baf132a 100644 --- a/crates/swc/tests/tsc-references/decrementOperatorWithAnyOtherType.2.minified.js +++ b/crates/swc/tests/tsc-references/decrementOperatorWithAnyOtherType.2.minified.js @@ -1,16 +1,13 @@ //// [decrementOperatorWithAnyOtherType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var ANY, ANY1, M, ANY2 = [ +var n, ANY, ANY1, M, ANY2 = [ "", "" ], obj = { x: 1, y: null }; -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; var objA = new function A() { _class_call_check(this, A); }(); diff --git a/crates/swc/tests/tsc-references/decrementOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/decrementOperatorWithNumberType.2.minified.js index 5bcb2008b723..c9f7288c8cbe 100644 --- a/crates/swc/tests/tsc-references/decrementOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/decrementOperatorWithNumberType.2.minified.js @@ -1,13 +1,10 @@ //// [decrementOperatorWithNumberType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var NUMBER, M, NUMBER1 = [ +var n, NUMBER, M, NUMBER1 = [ 1, 2 ]; -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; var objA = new function A() { _class_call_check(this, A); }(); diff --git a/crates/swc/tests/tsc-references/defaultExportsCannotMerge04.2.minified.js b/crates/swc/tests/tsc-references/defaultExportsCannotMerge04.2.minified.js index 222c9280adc6..fb80f144e3df 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; +var Foo, x; function Foo() {} Object.defineProperty(exports, "__esModule", { value: !0 @@ -8,7 +8,4 @@ Object.defineProperty(exports, "__esModule", { get: function() { return Foo; } -}), function(Foo) { - var x; - Foo.x = x; -}(Foo || (Foo = {})); +}), (Foo || (Foo = {})).x = x; diff --git a/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment3.2.minified.js b/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment3.2.minified.js index da0f266432f8..837f5c729bbd 100644 --- a/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment3.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment3.2.minified.js @@ -1,18 +1,10 @@ //// [destructuringArrayBindingPatternAndAssignment3.ts] +var _param, _param1, _param2; import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array"; -!function(param) { - var _param = _sliced_to_array(param, 2); - _param[0], _param[1]; -}([ +(_param = _sliced_to_array([ 1 -]), function(param) { - var _param = _sliced_to_array(param, 3); - _param[0], _param[1], _param[2]; -}([ +], 2))[0], _param[1], (_param1 = _sliced_to_array([ 1 -]), function(param) { - var _param = _sliced_to_array(param, 4); - _param[0], _param[1], _param[2], _param[3]; -}([ +], 3))[0], _param1[1], _param1[2], (_param2 = _sliced_to_array([ 1 -]); +], 4))[0], _param2[1], _param2[2], _param2[3]; diff --git a/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment6(target=es5).2.minified.js b/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment6(target=es5).2.minified.js index 8ec6f94afb7b..47cf7e93c523 100644 --- a/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment6(target=es5).2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment6(target=es5).2.minified.js @@ -1,7 +1,4 @@ //// [destructuringObjectBindingPatternAndAssignment6.ts] import { _ as _define_property } from "@swc/helpers/_/_define_property"; -var _ref = function() { - var _obj; - return _define_property(_obj = {}, "a", 1), _define_property(_obj, "b", 1), _obj; -}(); +var _obj, _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/destructuringObjectBindingPatternAndAssignment7(target=es5).2.minified.js b/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment7(target=es5).2.minified.js index b2156a76d77f..7501017f1917 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,8 +1,5 @@ //// [destructuringObjectBindingPatternAndAssignment7.ts] import { _ as _define_property } from "@swc/helpers/_/_define_property"; (K = K1 || (K1 = {})).a = "a", K.b = "b"; -var K, K1, _ref = function() { - var _obj; - return _define_property(_obj = {}, K1.a, 1), _define_property(_obj, K1.b, 1), _obj; -}(); +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]); diff --git a/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment8(target=es5).2.minified.js b/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment8(target=es5).2.minified.js index 7409f51d0034..9e863e21a791 100644 --- a/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment8(target=es5).2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringObjectBindingPatternAndAssignment8(target=es5).2.minified.js @@ -1,10 +1,7 @@ //// [destructuringObjectBindingPatternAndAssignment8.ts] import { _ as _define_property } from "@swc/helpers/_/_define_property"; -var K = { +var _obj, K = { a: "a", b: "b" -}, _ref = function() { - var _obj; - return _define_property(_obj = {}, K.a, 1), _define_property(_obj, K.b, 1), _obj; -}(); +}, _ref = (_define_property(_obj = {}, K.a, 1), _define_property(_obj, K.b, 1), _obj); console.log(_ref[K.a], _ref[K.b]); diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.2.minified.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.2.minified.js index 1678a18f3851..647ec23dbc95 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable.2.minified.js @@ -6,7 +6,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 E, E1, E2, E11, array = [ +var _param, _param_, _param1, E, E1, E2, E11, array = [ 1, 2, 3 @@ -21,10 +21,7 @@ function foo1() { for(var _len = arguments.length, a = Array(_len), _key = 0; _key < _len; _key++)a[_key] = arguments[_key]; }(_to_consumable_array(array)), (function() { for(var _len = arguments.length, x = Array(_len), _key = 0; _key < _len; _key++)x[_key] = arguments[_key]; -}).apply(void 0, _to_consumable_array(array)), function(param) { - var _param = _sliced_to_array(param, 3), _param_ = (_param[0], _param[1], _sliced_to_array(_param[2], 1)); - _sliced_to_array(_param_[0], 1)[0]; -}([ +}).apply(void 0, _to_consumable_array(array)), (_param = _sliced_to_array([ 1, 2, [ @@ -34,7 +31,7 @@ function foo1() { ], !1, !0 -]), a10([ +], 3))[0], _param[1], _param_ = _sliced_to_array(_param[2], 1), _sliced_to_array(_param_[0], 1)[0], a10([ 1, 2, [ @@ -53,10 +50,7 @@ function foo1() { ]), a10([ 1, 2 -]), function(param) { - var _param = _to_array(param); - _param[0], _param[1], _param[2], _param.slice(3); -}([ +]), (_param1 = _to_array([ 1, 2 -]), 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 = 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); diff --git a/crates/swc/tests/tsc-references/destructuringWithLiteralInitializers.2.minified.js b/crates/swc/tests/tsc-references/destructuringWithLiteralInitializers.2.minified.js index df2f1350bff0..4598731f2488 100644 --- a/crates/swc/tests/tsc-references/destructuringWithLiteralInitializers.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringWithLiteralInitializers.2.minified.js @@ -1,5 +1,5 @@ //// [destructuringWithLiteralInitializers.ts] -var param, param1, param2, param3, param4, param5, param6; +var param, param1, param2, param3, param4, param5, param6, _param, _param1; import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array"; function f4() { var _ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : { @@ -86,19 +86,13 @@ function g5() { x: 1, y: 1 } -}), function(param) { - var _param = _sliced_to_array(param, 2); - _param[0], _param[1]; -}([ +}), (_param = _sliced_to_array([ 1, 1 -]), function(param) { - var _param = _sliced_to_array(param, 2); - _param[0], _param[1]; -}([ +], 2))[0], _param[1], (_param1 = _sliced_to_array([ 1, 1 -]), g3(), g3([ +], 2))[0], _param1[1], g3(), g3([ 1, 1 ]), g4(), g4([ diff --git a/crates/swc/tests/tsc-references/emptyVariableDeclarationBindingPatterns01_ES5.2.minified.js b/crates/swc/tests/tsc-references/emptyVariableDeclarationBindingPatterns01_ES5.2.minified.js index a6308466321a..f617027823c2 100644 --- a/crates/swc/tests/tsc-references/emptyVariableDeclarationBindingPatterns01_ES5.2.minified.js +++ b/crates/swc/tests/tsc-references/emptyVariableDeclarationBindingPatterns01_ES5.2.minified.js @@ -1,10 +1,8 @@ //// [emptyVariableDeclarationBindingPatterns01_ES5.ts] +var a; import { _ as _object_destructuring_empty } from "@swc/helpers/_/_object_destructuring_empty"; import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array"; -!function() { - var a; - _object_destructuring_empty(a), _object_destructuring_empty(a), _object_destructuring_empty(a), _sliced_to_array(a, 0), _sliced_to_array(a, 0), _sliced_to_array(a, 0), _object_destructuring_empty(a), _sliced_to_array(a, 0), _object_destructuring_empty(a), _sliced_to_array(a, 0), _object_destructuring_empty(a), _sliced_to_array(a, 0), _object_destructuring_empty(a.p1), _sliced_to_array(a.p2, 0), _object_destructuring_empty(a.p1), _sliced_to_array(a.p2, 0), _object_destructuring_empty(a.p1), _sliced_to_array(a.p2, 0), _object_destructuring_empty({}), _object_destructuring_empty({}); -}(), function() { +_object_destructuring_empty(a), _object_destructuring_empty(a), _object_destructuring_empty(a), _sliced_to_array(a, 0), _sliced_to_array(a, 0), _sliced_to_array(a, 0), _object_destructuring_empty(a), _sliced_to_array(a, 0), _object_destructuring_empty(a), _sliced_to_array(a, 0), _object_destructuring_empty(a), _sliced_to_array(a, 0), _object_destructuring_empty(a.p1), _sliced_to_array(a.p2, 0), _object_destructuring_empty(a.p1), _sliced_to_array(a.p2, 0), _object_destructuring_empty(a.p1), _sliced_to_array(a.p2, 0), _object_destructuring_empty({}), _object_destructuring_empty({}), function() { var ns = [], _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0; try { for(var _step, _iterator = ns[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)_object_destructuring_empty(_step.value); diff --git a/crates/swc/tests/tsc-references/emptyVariableDeclarationBindingPatterns01_ES5iterable.2.minified.js b/crates/swc/tests/tsc-references/emptyVariableDeclarationBindingPatterns01_ES5iterable.2.minified.js index 88fa3b669a2c..25e48fae0998 100644 --- a/crates/swc/tests/tsc-references/emptyVariableDeclarationBindingPatterns01_ES5iterable.2.minified.js +++ b/crates/swc/tests/tsc-references/emptyVariableDeclarationBindingPatterns01_ES5iterable.2.minified.js @@ -1,10 +1,8 @@ //// [emptyVariableDeclarationBindingPatterns01_ES5iterable.ts] +var a; import { _ as _object_destructuring_empty } from "@swc/helpers/_/_object_destructuring_empty"; import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array"; -!function() { - var a; - _object_destructuring_empty(a), _object_destructuring_empty(a), _object_destructuring_empty(a), _sliced_to_array(a, 0), _sliced_to_array(a, 0), _sliced_to_array(a, 0), _object_destructuring_empty(a), _sliced_to_array(a, 0), _object_destructuring_empty(a), _sliced_to_array(a, 0), _object_destructuring_empty(a), _sliced_to_array(a, 0), _object_destructuring_empty(a.p1), _sliced_to_array(a.p2, 0), _object_destructuring_empty(a.p1), _sliced_to_array(a.p2, 0), _object_destructuring_empty(a.p1), _sliced_to_array(a.p2, 0), _object_destructuring_empty({}), _object_destructuring_empty({}); -}(), function() { +_object_destructuring_empty(a), _object_destructuring_empty(a), _object_destructuring_empty(a), _sliced_to_array(a, 0), _sliced_to_array(a, 0), _sliced_to_array(a, 0), _object_destructuring_empty(a), _sliced_to_array(a, 0), _object_destructuring_empty(a), _sliced_to_array(a, 0), _object_destructuring_empty(a), _sliced_to_array(a, 0), _object_destructuring_empty(a.p1), _sliced_to_array(a.p2, 0), _object_destructuring_empty(a.p1), _sliced_to_array(a.p2, 0), _object_destructuring_empty(a.p1), _sliced_to_array(a.p2, 0), _object_destructuring_empty({}), _object_destructuring_empty({}), function() { var ns = [], _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0; try { for(var _step, _iterator = ns[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)_object_destructuring_empty(_step.value); diff --git a/crates/swc/tests/tsc-references/enumMerging.2.minified.js b/crates/swc/tests/tsc-references/enumMerging.2.minified.js index 38f8202271a4..0f8dc429401e 100644 --- a/crates/swc/tests/tsc-references/enumMerging.2.minified.js +++ b/crates/swc/tests/tsc-references/enumMerging.2.minified.js @@ -1,24 +1,3 @@ //// [enumMerging.ts] -var M1, M2, M3, M4, M5, M6; -!function(M1) { - var EImpl1, EConst1, EImpl11, EImpl12, EConst11, EConst12; - (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 = M1.EConst1 || (M1.EConst1 = {}))[EConst11.A = 3] = "A", EConst11[EConst11.B = 2] = "B", EConst11[EConst11.C = 1] = "C", (EConst12 = EConst1 = M1.EConst1 || (M1.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; -}(M1 || (M1 = {})), function(M2) { - var EComp2, EComp21, EComp22; - (EComp21 = EComp2 = M2.EComp2 || (M2.EComp2 = {}))[EComp21.A = 3] = "A", EComp21[EComp21.B = 3] = "B", EComp21[EComp21.C = 3] = "C", (EComp22 = EComp2 = M2.EComp2 || (M2.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; -}(M2 || (M2 = {})), function(M3) { - var EInit, EInit1, EInit2; - (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"; -}(M3 || (M3 = {})), function(M4) { - var Color; - (Color = M4.Color || (M4.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue"; -}(M4 || (M4 = {})), function(M5) { - var Color; - (Color = M5.Color || (M5.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue"; -}(M5 || (M5 = {})), function(M6) { - var A, Color; - (Color = (A = M6.A || (M6.A = {})).Color || (A.Color = {}))[Color.Red = 0] = "Red", Color[Color.Green = 1] = "Green", Color[Color.Blue = 2] = "Blue"; -}(M6 || (M6 = {})), function(M6) { - var A, Color, A1; - (Color = (A = A1 = M6.A || (M6.A = {})).Color || (A.Color = {}))[Color.Yellow = 1] = "Yellow", A1.Color.Yellow, A1.Color.Red; -}(M6 || (M6 = {})); +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; diff --git a/crates/swc/tests/tsc-references/enumMergingErrors.2.minified.js b/crates/swc/tests/tsc-references/enumMergingErrors.2.minified.js index 1f24086f9f19..46ddc84c87fb 100644 --- a/crates/swc/tests/tsc-references/enumMergingErrors.2.minified.js +++ b/crates/swc/tests/tsc-references/enumMergingErrors.2.minified.js @@ -1,30 +1,3 @@ //// [enumMergingErrors.ts] -var M, M1, M2; -!function(M) { - var E1, E2, E3; - (E1 = M.E1 || (M.E1 = {}))[E1.A = 0] = "A", (E2 = M.E2 || (M.E2 = {}))[E2.C = 0] = "C", (E3 = M.E3 || (M.E3 = {}))[E3.A = 0] = "A"; -}(M || (M = {})), function(M) { - var E1, E2, E3; - (E1 = M.E1 || (M.E1 = {}))[E1.B = 3] = "B", (E2 = M.E2 || (M.E2 = {}))[E2.B = 3] = "B", (E3 = M.E3 || (M.E3 = {}))[E3.C = 0] = "C"; -}(M || (M = {})), function(M) { - var E1, E2, E3; - (E1 = M.E1 || (M.E1 = {}))[E1.C = 0] = "C", (E2 = M.E2 || (M.E2 = {}))[E2.A = 0] = "A", (E3 = M.E3 || (M.E3 = {}))[E3.B = 3] = "B"; -}(M || (M = {})), function(M1) { - var E1; - (E1 = M1.E1 || (M1.E1 = {}))[E1.A = 0] = "A"; -}(M1 || (M1 = {})), function(M1) { - var E1; - (E1 = M1.E1 || (M1.E1 = {}))[E1.B = 0] = "B"; -}(M1 || (M1 = {})), function(M1) { - var E1; - (E1 = M1.E1 || (M1.E1 = {}))[E1.C = 0] = "C"; -}(M1 || (M1 = {})), function(M2) { - var E1; - (E1 = M2.E1 || (M2.E1 = {}))[E1.A = 0] = "A"; -}(M2 || (M2 = {})), function(M2) { - var E1; - (E1 = M2.E1 || (M2.E1 = {}))[E1.B = 0] = "B"; -}(M2 || (M2 = {})), function(M2) { - var E1; - (E1 = M2.E1 || (M2.E1 = {}))[E1.C = 0] = "C"; -}(M2 || (M2 = {})); +var M, M1, M2, M3, E1, E2, E3, M4, E11, E21, E31, M5, E12, E22, E32, M11, E13, M12, E14, M13, E15, M21, E16, M22, E17, M23, E18; +(E1 = (M3 = M || (M = {})).E1 || (M3.E1 = {}))[E1.A = 0] = "A", (E2 = M3.E2 || (M3.E2 = {}))[E2.C = 0] = "C", (E3 = M3.E3 || (M3.E3 = {}))[E3.A = 0] = "A", (E11 = (M4 = M || (M = {})).E1 || (M4.E1 = {}))[E11.B = 3] = "B", (E21 = M4.E2 || (M4.E2 = {}))[E21.B = 3] = "B", (E31 = M4.E3 || (M4.E3 = {}))[E31.C = 0] = "C", (E12 = (M5 = M || (M = {})).E1 || (M5.E1 = {}))[E12.C = 0] = "C", (E22 = M5.E2 || (M5.E2 = {}))[E22.A = 0] = "A", (E32 = M5.E3 || (M5.E3 = {}))[E32.B = 3] = "B", (E13 = (M11 = M1 || (M1 = {})).E1 || (M11.E1 = {}))[E13.A = 0] = "A", (E14 = (M12 = M1 || (M1 = {})).E1 || (M12.E1 = {}))[E14.B = 0] = "B", (E15 = (M13 = M1 || (M1 = {})).E1 || (M13.E1 = {}))[E15.C = 0] = "C", (E16 = (M21 = M2 || (M2 = {})).E1 || (M21.E1 = {}))[E16.A = 0] = "A", (E17 = (M22 = M2 || (M2 = {})).E1 || (M22.E1 = {}))[E17.B = 0] = "B", (E18 = (M23 = M2 || (M2 = {})).E1 || (M23.E1 = {}))[E18.C = 0] = "C"; diff --git a/crates/swc/tests/tsc-references/exportCodeGen.2.minified.js b/crates/swc/tests/tsc-references/exportCodeGen.2.minified.js index ed009aebd495..fe1dbb74193d 100644 --- a/crates/swc/tests/tsc-references/exportCodeGen.2.minified.js +++ b/crates/swc/tests/tsc-references/exportCodeGen.2.minified.js @@ -1,14 +1,8 @@ //// [exportCodeGen.ts] -var A, B, C, D, E, F; +var A, B, C, D, E, F, E1, Color, Color1, M, Color2; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; (A || (A = {})).x = 12, B || (B = {}), C || (C = {}), (D || (D = {})).yes = function() { return !0; -}, function(E) { - var Color; - (Color = E.Color || (E.Color = {}))[Color.Red = 0] = "Red", E.fn = function() {}, E.C = function C() { - _class_call_check(this, C); - }, (E.M || (E.M = {})).x = 42; -}(E || (E = {})), function(F) { - var Color, M, Color1; - (Color1 = Color || (Color = {}))[Color1.Red = 0] = "Red", M || (M = {}); -}(F || (F = {})); +}, (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 = {}); diff --git a/crates/swc/tests/tsc-references/exportImportAlias.2.minified.js b/crates/swc/tests/tsc-references/exportImportAlias.2.minified.js index fd35fd9330a0..c378fd8ff7d6 100644 --- a/crates/swc/tests/tsc-references/exportImportAlias.2.minified.js +++ b/crates/swc/tests/tsc-references/exportImportAlias.2.minified.js @@ -1,27 +1,12 @@ //// [exportImportAlias.ts] -var A, C, X, Z, K, M, A1; +var A, C, X, Z, K, M, A1, C1, a, X1, Y, Z1, y, K1, L, M1, D; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; (A1 = A || (A = {})).x = "hello world", A1.Point = function Point(x, y) { _class_call_check(this, Point), this.x = x, this.y = y; -}, function(C) { - var a = A; - C.a = a; -}(C || (C = {})), C.a.x, new C.a.Point(0, 0), function(X) { - var Y = function() { - return 42; - }; - X.Y = Y, (Y = X.Y || (X.Y = {})).Point = function Point(x, y) { - _class_call_check(this, Point), this.x = x, this.y = y; - }; -}(X || (X = {})), function(Z) { - var y = X.Y; - Z.y = y; -}(Z || (Z = {})), Z.y(), new Z.y.Point(0, 0), function(K) { - var L = function L(name) { - _class_call_check(this, L), this.name = name; - }; - K.L = L, (L = K.L || (K.L = {})).y = 12; -}(K || (K = {})), function(M) { - var D = K.L; - M.D = D; -}(M || (M = {})), new M.D("Hello"); +}, C1 = C || (C = {}), a = A, C1.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) { + _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"); 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 431de7c7656d..9d0a64e5f0a7 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports1-es6.2.minified.js +++ b/crates/swc/tests/tsc-references/exportsAndImports1-es6.2.minified.js @@ -30,14 +30,11 @@ Object.defineProperty(exports, "__esModule", { return a; } }); -var E, D, E1, D1, M, v = 1; +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", function(M) { - var x; - M.x = x; -}(M || (M = {})); +(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; //// [t2.ts] Object.defineProperty(exports, "__esModule", { diff --git a/crates/swc/tests/tsc-references/exportsAndImports1.2.minified.js b/crates/swc/tests/tsc-references/exportsAndImports1.2.minified.js index 8669647cdb1a..de6001f323a1 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports1.2.minified.js +++ b/crates/swc/tests/tsc-references/exportsAndImports1.2.minified.js @@ -30,15 +30,12 @@ Object.defineProperty(exports, "__esModule", { return a; } }); -var E, D, E1, D1, M, _class_call_check = require("@swc/helpers/_/_class_call_check"), v = 1; +var E, D, x, E1, D1, 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", function(M) { - var x; - M.x = x; -}(M || (M = {})); +(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; //// [t2.ts] 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 981289188d67..4ce07f11cbd3 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports3-es6.2.minified.js +++ b/crates/swc/tests/tsc-references/exportsAndImports3-es6.2.minified.js @@ -51,14 +51,11 @@ Object.defineProperty(exports, "__esModule", { return a; } }); -var E, D, E1, D1, M, v = 1; +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", function(M) { - var x; - M.x = x; -}(M || (M = {})); +(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; //// [t2.ts] Object.defineProperty(exports, "__esModule", { diff --git a/crates/swc/tests/tsc-references/exportsAndImports3.2.minified.js b/crates/swc/tests/tsc-references/exportsAndImports3.2.minified.js index 203efee66a58..ce1ddf76f2ca 100644 --- a/crates/swc/tests/tsc-references/exportsAndImports3.2.minified.js +++ b/crates/swc/tests/tsc-references/exportsAndImports3.2.minified.js @@ -51,15 +51,12 @@ Object.defineProperty(exports, "__esModule", { return a; } }); -var E, D, E1, D1, M, _class_call_check = require("@swc/helpers/_/_class_call_check"), v = 1; +var E, D, x, E1, D1, 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", function(M) { - var x; - M.x = x; -}(M || (M = {})); +(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; //// [t2.ts] Object.defineProperty(exports, "__esModule", { diff --git a/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2.2.minified.js index 08ecbe4c29f9..c749d23aaf54 100644 --- a/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithGenericSignatureArguments2.2.minified.js @@ -1,9 +1,3 @@ //// [genericCallWithGenericSignatureArguments2.ts] -var onlyT, TU; -!function(onlyT) { - var E, F, E1, F1; - (E1 = E || (E = {}))[E1.A = 0] = "A", (F1 = F || (F = {}))[F1.A = 0] = "A", E.A; -}(onlyT || (onlyT = {})), function(TU) { - var E, F, E1, F1; - (E1 = E || (E = {}))[E1.A = 0] = "A", (F1 = F || (F = {}))[F1.A = 0] = "A", E.A; -}(TU || (TU = {})); +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; diff --git a/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments.2.minified.js index f011a7abab1f..5cf3d7e50101 100644 --- a/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments.2.minified.js @@ -1,17 +1,11 @@ //// [genericCallWithOverloadedConstructorTypedArguments.ts] -var NonGenericParameter, GenericParameter; -!function(NonGenericParameter) { - var b, foo4 = function(cb) { - return new cb(null); - }; - foo4(void 0), foo4(b); -}(NonGenericParameter || (NonGenericParameter = {})), function(GenericParameter) { - var a, b, c, c2, foo5 = function(cb) { - return cb; - }, foo6 = function(cb) { - return cb; - }, foo7 = function(x, cb) { - return cb; - }; - foo5(a), foo5(b), foo6(a), foo6(b), foo7(1, b), foo7(1, c), foo7(1, c2); -}(GenericParameter || (GenericParameter = {})); +var NonGenericParameter, GenericParameter, b, foo4, a, b1, c, c2, foo5, foo6, foo7; +NonGenericParameter || (NonGenericParameter = {}), (foo4 = function(cb) { + return new cb(null); +})(void 0), foo4(b), GenericParameter || (GenericParameter = {}), foo5 = function(cb) { + return cb; +}, foo6 = function(cb) { + return cb; +}, foo7 = function(x, cb) { + return cb; +}, foo5(a), foo5(b1), foo6(a), foo6(b1), foo7(1, b1), foo7(1, c), foo7(1, c2); diff --git a/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments2.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments2.2.minified.js index 1427a5d37656..3f44e53dc6f3 100644 --- a/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments2.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments2.2.minified.js @@ -1,8 +1,5 @@ //// [genericCallWithOverloadedConstructorTypedArguments2.ts] -var NonGenericParameter, GenericParameter; -NonGenericParameter || (NonGenericParameter = {}), function(GenericParameter) { - var c, foo7 = function(x, cb) { - return cb; - }; - foo7(1, void 0), foo7(1, c); -}(GenericParameter || (GenericParameter = {})); +var NonGenericParameter, GenericParameter, a, c, foo7; +NonGenericParameter || (NonGenericParameter = {}), GenericParameter || (GenericParameter = {}), (foo7 = function(x, cb) { + return cb; +})(1, a), foo7(1, c); diff --git a/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments.2.minified.js index 3bd2aba0a3cc..a5f4ccf2449f 100644 --- a/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments.2.minified.js @@ -1,33 +1,27 @@ //// [genericCallWithOverloadedFunctionTypedArguments.ts] -var NonGenericParameter, GenericParameter; -!function(NonGenericParameter) { - var foo4 = function(cb) { - return cb; - }; - foo4(void 0), foo4(function(x) { - return x; - }), foo4(function(x) { - return x; - }); -}(NonGenericParameter || (NonGenericParameter = {})), function(GenericParameter) { - var a, foo5 = function(cb) { - return cb; - }, foo6 = function(cb) { - return cb; - }, foo7 = function(x, cb) { - return cb; - }; - foo5(function(x) { - return x; - }), foo5(a), foo6(function(x) { - return x; - }), foo6(function(x) { - return ""; - }), foo6(function(x, y) { - return ""; - }), foo7(1, function(x) { - return x; - }), foo7(1, function(x) { - return ""; - }), foo7(1, a); -}(GenericParameter || (GenericParameter = {})); +var NonGenericParameter, GenericParameter, foo4, a, foo5, foo6, foo7; +NonGenericParameter || (NonGenericParameter = {}), (foo4 = function(cb) { + return cb; +})(void 0), foo4(function(x) { + return x; +}), foo4(function(x) { + return x; +}), GenericParameter || (GenericParameter = {}), foo5 = function(cb) { + return cb; +}, foo6 = function(cb) { + return cb; +}, foo7 = function(x, cb) { + return cb; +}, foo5(function(x) { + return x; +}), foo5(a), foo6(function(x) { + return x; +}), foo6(function(x) { + return ""; +}), foo6(function(x, y) { + return ""; +}), foo7(1, function(x) { + return x; +}), foo7(1, function(x) { + return ""; +}), foo7(1, a); diff --git a/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments2.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments2.2.minified.js index 0cc23dbbdf00..651aee23fd31 100644 --- a/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments2.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments2.2.minified.js @@ -1,10 +1,7 @@ //// [genericCallWithOverloadedFunctionTypedArguments2.ts] -var NonGenericParameter, GenericParameter; -NonGenericParameter || (NonGenericParameter = {}), function(GenericParameter) { - var a, foo7 = function(x, cb) { - return cb; - }; - foo7(1, function(x) { - return x; - }), foo7(1, a); -}(GenericParameter || (GenericParameter = {})); +var NonGenericParameter, GenericParameter, a, foo7; +NonGenericParameter || (NonGenericParameter = {}), GenericParameter || (GenericParameter = {}), (foo7 = function(x, cb) { + return cb; +})(1, function(x) { + return x; +}), foo7(1, a); diff --git a/crates/swc/tests/tsc-references/genericClassWithFunctionTypedMemberArguments.2.minified.js b/crates/swc/tests/tsc-references/genericClassWithFunctionTypedMemberArguments.2.minified.js index e65e5bdcd088..9e7770394496 100644 --- a/crates/swc/tests/tsc-references/genericClassWithFunctionTypedMemberArguments.2.minified.js +++ b/crates/swc/tests/tsc-references/genericClassWithFunctionTypedMemberArguments.2.minified.js @@ -1,46 +1,38 @@ //// [genericClassWithFunctionTypedMemberArguments.ts] -var ImmediatelyFix, WithCandidates; +var ImmediatelyFix, WithCandidates, c, c2, c1, c21; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(ImmediatelyFix) { - var c = new (function() { - function C() { - _class_call_check(this, C); - } - return C.prototype.foo = function(x) { - return x(null); - }, C; - }())(); - c.foo(function(x) { - return ""; - }), c.foo(function(x) { - return ""; - }), c.foo(function(x) { - return ""; - }); - var c2 = new (function() { - function C2() { - _class_call_check(this, C2); - } - return C2.prototype.foo = function(x) { - return x(null); - }, C2; - }())(); - c2.foo(function(x) { - return 1; - }), c2.foo(function(x) { - return 1; - }); -}(ImmediatelyFix || (ImmediatelyFix = {})), function(WithCandidates) { - var c, c2; - c.foo2(1, function(a) { - return ""; - }), c.foo2(1, function(a) { - return ""; - }), c.foo2("", function(a) { - return 1; - }), c2.foo3(1, function(a) { - return ""; - }, ""), c2.foo3(1, function(a) { - return ""; - }, ""); -}(WithCandidates || (WithCandidates = {})); +ImmediatelyFix || (ImmediatelyFix = {}), (c = new (function() { + function C() { + _class_call_check(this, C); + } + return C.prototype.foo = function(x) { + return x(null); + }, C; +}())()).foo(function(x) { + return ""; +}), c.foo(function(x) { + return ""; +}), c.foo(function(x) { + return ""; +}), (c2 = new (function() { + function C2() { + _class_call_check(this, C2); + } + return C2.prototype.foo = function(x) { + return x(null); + }, C2; +}())()).foo(function(x) { + return 1; +}), c2.foo(function(x) { + return 1; +}), WithCandidates || (WithCandidates = {}), c1.foo2(1, function(a) { + return ""; +}), c1.foo2(1, function(a) { + return ""; +}), c1.foo2("", function(a) { + return 1; +}), c21.foo3(1, function(a) { + return ""; +}, ""), c21.foo3(1, function(a) { + return ""; +}, ""); diff --git a/crates/swc/tests/tsc-references/genericClassWithObjectTypeArgsAndConstraints.2.minified.js b/crates/swc/tests/tsc-references/genericClassWithObjectTypeArgsAndConstraints.2.minified.js index 99037539e7a6..711e7c4cdc37 100644 --- a/crates/swc/tests/tsc-references/genericClassWithObjectTypeArgsAndConstraints.2.minified.js +++ b/crates/swc/tests/tsc-references/genericClassWithObjectTypeArgsAndConstraints.2.minified.js @@ -1,12 +1,6 @@ //// [genericClassWithObjectTypeArgsAndConstraints.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var Class, Interface, X = function X() { +var g, g2, c1, d1, g1, g21, c11, d11, Class, Interface, X = function X() { _class_call_check(this, X); }; -!function(Class) { - var g, g2, c1 = new X(), d1 = new X(); - g.foo(c1, d1), g.foo(c1, c1), g2.foo2(c1, d1), g2.foo2(c1, c1); -}(Class || (Class = {})), function(Interface) { - var g, g2, c1 = new X(), d1 = new X(); - g.foo(c1, d1), g.foo(c1, c1), g2.foo2(c1, d1), g2.foo2(c1, c1); -}(Interface || (Interface = {})); +Class || (Class = {}), c1 = new X(), d1 = new X(), g.foo(c1, d1), g.foo(c1, c1), g2.foo2(c1, d1), g2.foo2(c1, c1), Interface || (Interface = {}), c11 = new X(), d11 = new X(), g1.foo(c11, d11), g1.foo(c11, c11), g21.foo2(c11, d11), g21.foo2(c11, c11); diff --git a/crates/swc/tests/tsc-references/genericSetterInClassType.2.minified.js b/crates/swc/tests/tsc-references/genericSetterInClassType.2.minified.js index 58e72cd9d1d8..5d864ecac501 100644 --- a/crates/swc/tests/tsc-references/genericSetterInClassType.2.minified.js +++ b/crates/swc/tests/tsc-references/genericSetterInClassType.2.minified.js @@ -1,19 +1,16 @@ //// [genericSetterInClassType.ts] -var Generic; -!function(Generic) { - var c = new class { - get y() { - return 1; - } - set y(v) {} - }(); - c.y = c.y, new class { - #value; - get value() { - return this.#value; - } - set value(value) { - this.#value = value; - } - }().value = 3; -}(Generic || (Generic = {})); +var Generic, c; +Generic || (Generic = {}), (c = new class { + get y() { + return 1; + } + set y(v) {} +}()).y = c.y, new class { + #value; + get value() { + return this.#value; + } + set value(value) { + this.#value = value; + } +}().value = 3; diff --git a/crates/swc/tests/tsc-references/implementingAnInterfaceExtendingClassWithPrivates2.2.minified.js b/crates/swc/tests/tsc-references/implementingAnInterfaceExtendingClassWithPrivates2.2.minified.js index 65a6a34700ee..3e0bd8a07bd1 100644 --- a/crates/swc/tests/tsc-references/implementingAnInterfaceExtendingClassWithPrivates2.2.minified.js +++ b/crates/swc/tests/tsc-references/implementingAnInterfaceExtendingClassWithPrivates2.2.minified.js @@ -1,9 +1,6 @@ //// [implementingAnInterfaceExtendingClassWithPrivates2.ts] -var M, M2; +var M, M2, b; 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"; -M || (M = {}), function(M2) { - var b; - b.z, b.x, b.y; -}(M2 || (M2 = {})); +M || (M = {}), M2 || (M2 = {}), b.z, b.x, b.y; diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3CJS.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3CJS.2.minified.js index d09e8890db93..7226641e2dd6 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES3CJS.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES3CJS.2.minified.js @@ -1,2 +1,20 @@ //// [test.ts] exports, exports; +var _async_to_generator = require("@swc/helpers/_/_async_to_generator"), _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard"), _ts_generator = require("@swc/helpers/_/_ts_generator"); +_async_to_generator._(function() { + return _ts_generator._(this, function(_state) { + switch(_state.label){ + case 0: + return [ + 4, + Promise.resolve().then(function() { + return _interop_require_wildcard._(require("./test")); + }) + ]; + case 1: + return _state.sent(), [ + 2 + ]; + } + }); +}); diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS.2.minified.js index d09e8890db93..7226641e2dd6 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES5CJS.2.minified.js @@ -1,2 +1,20 @@ //// [test.ts] exports, exports; +var _async_to_generator = require("@swc/helpers/_/_async_to_generator"), _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard"), _ts_generator = require("@swc/helpers/_/_ts_generator"); +_async_to_generator._(function() { + return _ts_generator._(this, function(_state) { + switch(_state.label){ + case 0: + return [ + 4, + Promise.resolve().then(function() { + return _interop_require_wildcard._(require("./test")); + }) + ]; + case 1: + return _state.sent(), [ + 2 + ]; + } + }); +}); diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS.2.minified.js index d09e8890db93..01ba4798f69c 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES6CJS.2.minified.js @@ -1,2 +1,6 @@ //// [test.ts] exports, exports; +const _async_to_generator = require("@swc/helpers/_/_async_to_generator"), _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard"); +_async_to_generator._(function*() { + yield Promise.resolve().then(()=>_interop_require_wildcard._(require("./test"))); +}); diff --git a/crates/swc/tests/tsc-references/importStatements.2.minified.js b/crates/swc/tests/tsc-references/importStatements.2.minified.js index a341e5ca7611..72fa124ea34b 100644 --- a/crates/swc/tests/tsc-references/importStatements.2.minified.js +++ b/crates/swc/tests/tsc-references/importStatements.2.minified.js @@ -1,14 +1,8 @@ //// [importStatements.ts] -var A, C, D, E; +var A, C, D, E, A1, Point, E1, a; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(A) { - var Point = function Point(x, y) { - _class_call_check(this, Point), this.x = x, this.y = y; - }; - A.Point = Point, A.Origin = new Point(0, 0); -}(A || (A = {})), C || (C = {}), D || (D = {}), new A.Point(1, 1), function(E) { - var a = A; - E.xDist = function(x) { - return a.Origin.x - x.x; - }; -}(E || (E = {})); +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) { + return a.Origin.x - x.x; +}; diff --git a/crates/swc/tests/tsc-references/incrementOperatorWithAnyOtherType.2.minified.js b/crates/swc/tests/tsc-references/incrementOperatorWithAnyOtherType.2.minified.js index 94b152e3aa33..7a65ace40973 100644 --- a/crates/swc/tests/tsc-references/incrementOperatorWithAnyOtherType.2.minified.js +++ b/crates/swc/tests/tsc-references/incrementOperatorWithAnyOtherType.2.minified.js @@ -1,16 +1,13 @@ //// [incrementOperatorWithAnyOtherType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var ANY, ANY1, M, ANY2 = [ +var n, ANY, ANY1, M, ANY2 = [ "", "" ], obj = { x: 1, y: null }; -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; var objA = new function A() { _class_call_check(this, A); }(); diff --git a/crates/swc/tests/tsc-references/incrementOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/incrementOperatorWithNumberType.2.minified.js index 404cae19328b..15e7362962de 100644 --- a/crates/swc/tests/tsc-references/incrementOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/incrementOperatorWithNumberType.2.minified.js @@ -1,13 +1,10 @@ //// [incrementOperatorWithNumberType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var NUMBER, M, NUMBER1 = [ +var n, NUMBER, M, NUMBER1 = [ 1, 2 ]; -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; var objA = new function A() { _class_call_check(this, A); }(); diff --git a/crates/swc/tests/tsc-references/instancePropertiesInheritedIntoClassType.2.minified.js b/crates/swc/tests/tsc-references/instancePropertiesInheritedIntoClassType.2.minified.js index d0fba4637028..da276db37b30 100644 --- a/crates/swc/tests/tsc-references/instancePropertiesInheritedIntoClassType.2.minified.js +++ b/crates/swc/tests/tsc-references/instancePropertiesInheritedIntoClassType.2.minified.js @@ -1,57 +1,51 @@ //// [instancePropertiesInheritedIntoClassType.ts] -var NonGeneric, Generic; +var NonGeneric, Generic, d, r, d1, r1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _create_class } from "@swc/helpers/_/_create_class"; import { _ as _inherits } from "@swc/helpers/_/_inherits"; import { _ as _create_super } from "@swc/helpers/_/_create_super"; -!function(NonGeneric) { - var d = new (function(C) { - _inherits(D, C); - var _super = _create_super(D); - function D() { - return _class_call_check(this, D), _super.apply(this, arguments); +NonGeneric || (NonGeneric = {}), (r = (d = new (function(C) { + _inherits(D, C); + var _super = _create_super(D); + function D() { + return _class_call_check(this, D), _super.apply(this, arguments); + } + return D; +}(function() { + function C(a, b) { + _class_call_check(this, C), this.a = a, this.b = b; + } + return C.prototype.fn = function() { + return this; + }, _create_class(C, [ + { + key: "y", + get: function() { + return 1; + }, + set: function(v) {} } - return D; - }(function() { - function C(a, b) { - _class_call_check(this, C), this.a = a, this.b = b; + ]), C; +}()))(1, 2)).fn()).x, r.y, r.y = 4, d.y(), Generic || (Generic = {}), (r1 = (d1 = new (function(C) { + _inherits(D, C); + var _super = _create_super(D); + function D() { + return _class_call_check(this, D), _super.apply(this, arguments); + } + return D; +}(function() { + function C(a, b) { + _class_call_check(this, C), this.a = a, this.b = b; + } + return C.prototype.fn = function() { + return this; + }, _create_class(C, [ + { + key: "y", + get: function() { + return null; + }, + set: function(v) {} } - return C.prototype.fn = function() { - return this; - }, _create_class(C, [ - { - key: "y", - get: function() { - return 1; - }, - set: function(v) {} - } - ]), C; - }()))(1, 2), r = d.fn(); - r.x, r.y, r.y = 4, d.y(); -}(NonGeneric || (NonGeneric = {})), function(Generic) { - var d = new (function(C) { - _inherits(D, C); - var _super = _create_super(D); - function D() { - return _class_call_check(this, D), _super.apply(this, arguments); - } - return D; - }(function() { - function C(a, b) { - _class_call_check(this, C), this.a = a, this.b = b; - } - return C.prototype.fn = function() { - return this; - }, _create_class(C, [ - { - key: "y", - get: function() { - return null; - }, - set: function(v) {} - } - ]), C; - }()))(1, ""), r = d.fn(); - r.x, r.y, r.y = "", d.y(); -}(Generic || (Generic = {})); + ]), C; +}()))(1, "")).fn()).x, r1.y, r1.y = "", d1.y(); diff --git a/crates/swc/tests/tsc-references/instancePropertyInClassType.2.minified.js b/crates/swc/tests/tsc-references/instancePropertyInClassType.2.minified.js index 62f90b845988..6604d3d061ae 100644 --- a/crates/swc/tests/tsc-references/instancePropertyInClassType.2.minified.js +++ b/crates/swc/tests/tsc-references/instancePropertyInClassType.2.minified.js @@ -1,41 +1,35 @@ //// [instancePropertyInClassType.ts] -var NonGeneric, Generic; +var NonGeneric, Generic, c, r, c1, r1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _create_class } from "@swc/helpers/_/_create_class"; -!function(NonGeneric) { - var c = new (function() { - function C(a, b) { - _class_call_check(this, C), this.a = a, this.b = b; +NonGeneric || (NonGeneric = {}), (r = (c = new (function() { + function C(a, b) { + _class_call_check(this, C), this.a = a, this.b = b; + } + return C.prototype.fn = function() { + return this; + }, _create_class(C, [ + { + key: "y", + get: function() { + return 1; + }, + set: function(v) {} } - return C.prototype.fn = function() { - return this; - }, _create_class(C, [ - { - key: "y", - get: function() { - return 1; - }, - set: function(v) {} - } - ]), C; - }())(1, 2), r = c.fn(); - r.x, r.y, r.y = 4, c.y(); -}(NonGeneric || (NonGeneric = {})), function(Generic) { - var c = new (function() { - function C(a, b) { - _class_call_check(this, C), this.a = a, this.b = b; + ]), C; +}())(1, 2)).fn()).x, r.y, r.y = 4, c.y(), Generic || (Generic = {}), (r1 = (c1 = new (function() { + function C(a, b) { + _class_call_check(this, C), this.a = a, this.b = b; + } + return C.prototype.fn = function() { + return this; + }, _create_class(C, [ + { + key: "y", + get: function() { + return null; + }, + set: function(v) {} } - return C.prototype.fn = function() { - return this; - }, _create_class(C, [ - { - key: "y", - get: function() { - return null; - }, - set: function(v) {} - } - ]), C; - }())(1, ""), r = c.fn(); - r.x, r.y, r.y = "", c.y(); -}(Generic || (Generic = {})); + ]), C; +}())(1, "")).fn()).x, r1.y, r1.y = "", c1.y(); diff --git a/crates/swc/tests/tsc-references/instantiatedModule.2.minified.js b/crates/swc/tests/tsc-references/instantiatedModule.2.minified.js index ac018c090470..e07a75222b94 100644 --- a/crates/swc/tests/tsc-references/instantiatedModule.2.minified.js +++ b/crates/swc/tests/tsc-references/instantiatedModule.2.minified.js @@ -1,25 +1,19 @@ //// [instantiatedModule.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; (M || (M = {})).Point = 1; -var M, M2, m2, a2, M3, m3, a3, m = M; -M.Point, m.Point, function(M2) { - var Point = function() { - function Point() { - _class_call_check(this, Point); - } - return Point.Origin = function() { - return { - x: 0, - y: 0 - }; - }, Point; - }(); - M2.Point = Point; -}(M2 || (M2 = {})); -var m2 = M2, a2 = (m2.Point, M2.Point); -a2.Origin(), new m2.Point(), new M2.Point(), function(M3) { - var Color; - (Color = M3.Color || (M3.Color = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red"; -}(M3 || (M3 = {})); -var m3 = M3, a3 = (m3.Color, M3.Color); -a3.Blue, M3.Color.Red, m3.Color.Blue; +var M2, Point, M3, Color, M, M21, m2, a2, M31, m3, a3, m = M; +M.Point, m.Point, M2 = M21 || (M21 = {}), Point = function() { + function Point() { + _class_call_check(this, Point); + } + return Point.Origin = function() { + return { + x: 0, + y: 0 + }; + }, Point; +}(), M2.Point = Point; +var m2 = M21, a2 = (m2.Point, M21.Point); +a2.Origin(), new m2.Point(), new M21.Point(), (Color = (M3 = M31 || (M31 = {})).Color || (M3.Color = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red"; +var m3 = M31, a3 = (m3.Color, M31.Color); +a3.Blue, M31.Color.Red, m3.Color.Blue; diff --git a/crates/swc/tests/tsc-references/intersectionTypeInference.2.minified.js b/crates/swc/tests/tsc-references/intersectionTypeInference.2.minified.js index d073701c9cda..5833010dd3a2 100644 --- a/crates/swc/tests/tsc-references/intersectionTypeInference.2.minified.js +++ b/crates/swc/tests/tsc-references/intersectionTypeInference.2.minified.js @@ -1,10 +1,7 @@ //// [intersectionTypeInference.ts] -var x = function(obj1, obj2) { - var result; - return obj1 = result, obj2 = result, result = obj1, result = obj2; -}({ +var obj1, obj2, result, x = (obj1 = { a: "hello" -}, { +}, obj2 = { b: 42 -}); +}, obj1 = result, obj2 = result, result = obj1, result = obj2); x.a, x.b; diff --git a/crates/swc/tests/tsc-references/invalidNestedModules.2.minified.js b/crates/swc/tests/tsc-references/invalidNestedModules.2.minified.js index 26bb85408332..b2c02998be2c 100644 --- a/crates/swc/tests/tsc-references/invalidNestedModules.2.minified.js +++ b/crates/swc/tests/tsc-references/invalidNestedModules.2.minified.js @@ -1,16 +1,10 @@ //// [invalidNestedModules.ts] -var A, M2, A1, M21; +var A, M2, A1, B, A2, M21, M22, Point; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(A) { - var B; - ((B = A.B || (A.B = {})).C || (B.C = {})).Point = function Point() { - _class_call_check(this, Point); - }; -}(A || (A = {})), ((A1 = A || (A = {})).B || (A1.B = {})).C = function C() { +((B = (A1 = A || (A = {})).B || (A1.B = {})).C || (B.C = {})).Point = function Point() { + _class_call_check(this, Point); +}, ((A2 = A || (A = {})).B || (A2.B = {})).C = function C() { _class_call_check(this, C); }, ((M21 = M2 || (M2 = {})).X || (M21.X = {})).Point = function Point() { _class_call_check(this, Point); -}, function(M2) { - var Point; - (M2.X || (M2.X = {})).Point = Point; -}(M2 || (M2 = {})); +}, ((M22 = M2 || (M2 = {})).X || (M22.X = {})).Point = Point; diff --git a/crates/swc/tests/tsc-references/literalTypes2.2.minified.js b/crates/swc/tests/tsc-references/literalTypes2.2.minified.js index 305bfd05bc4c..14b4941fcf53 100644 --- a/crates/swc/tests/tsc-references/literalTypes2.2.minified.js +++ b/crates/swc/tests/tsc-references/literalTypes2.2.minified.js @@ -1,7 +1,7 @@ //// [literalTypes2.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; (E = E1 || (E1 = {}))[E.A = 0] = "A", E[E.B = 1] = "B", E[E.C = 2] = "C"; -var E, E1, a = [ +var result, E, E1, a = [ 1, 2 ]; @@ -12,8 +12,8 @@ g1(1), g2(1, 1), g2(1, 2), g3(1, "two"), g4(1), g5(1, 2), g6([ return x; }), g8(1, function(x) { return x + 1; -}), function(a, x) { - a.slice().push(1); -}([ +}); +var aa = [ 0 -], 0); +]; +(result = aa.slice()).push(1), aa = result; diff --git a/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType.2.minified.js b/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType.2.minified.js index 0e07eab2316f..1ce052ea6cc1 100644 --- a/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType.2.minified.js +++ b/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType.2.minified.js @@ -1,14 +1,11 @@ //// [logicalNotOperatorWithAnyOtherType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var M, A = function() { +var n, M, A = function() { function A() { _class_call_check(this, A); } return A.foo = function() {}, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/logicalNotOperatorWithBooleanType.2.minified.js b/crates/swc/tests/tsc-references/logicalNotOperatorWithBooleanType.2.minified.js index 8a48edbcaedd..d77144644a6d 100644 --- a/crates/swc/tests/tsc-references/logicalNotOperatorWithBooleanType.2.minified.js +++ b/crates/swc/tests/tsc-references/logicalNotOperatorWithBooleanType.2.minified.js @@ -1,6 +1,6 @@ //// [logicalNotOperatorWithBooleanType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var M, A = function() { +var n, M, A = function() { function A() { _class_call_check(this, A); } @@ -8,9 +8,6 @@ var M, A = function() { return !1; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/logicalNotOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/logicalNotOperatorWithNumberType.2.minified.js index a1a83b88464d..3b59f6bb81bd 100644 --- a/crates/swc/tests/tsc-references/logicalNotOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/logicalNotOperatorWithNumberType.2.minified.js @@ -1,6 +1,6 @@ //// [logicalNotOperatorWithNumberType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var M, A = function() { +var M, n, A = function() { function A() { _class_call_check(this, A); } @@ -8,9 +8,6 @@ var M, A = function() { return 1; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; 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.2.minified.js b/crates/swc/tests/tsc-references/logicalNotOperatorWithStringType.2.minified.js index 8b8e44d64223..5e700e4b844e 100644 --- a/crates/swc/tests/tsc-references/logicalNotOperatorWithStringType.2.minified.js +++ b/crates/swc/tests/tsc-references/logicalNotOperatorWithStringType.2.minified.js @@ -1,6 +1,6 @@ //// [logicalNotOperatorWithStringType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var STRING, M, A = function() { +var STRING, M, n, A = function() { function A() { _class_call_check(this, A); } @@ -8,9 +8,6 @@ var STRING, M, A = function() { return ""; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; 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/mergeThreeInterfaces.2.minified.js b/crates/swc/tests/tsc-references/mergeThreeInterfaces.2.minified.js index 0b21256793f5..a9b533fceeae 100644 --- a/crates/swc/tests/tsc-references/mergeThreeInterfaces.2.minified.js +++ b/crates/swc/tests/tsc-references/mergeThreeInterfaces.2.minified.js @@ -1,6 +1,3 @@ //// [mergeThreeInterfaces.ts] -var a, b, M; -a.foo, a.bar, a.baz, b.foo, b.bar, b.baz, function(M) { - var a, b; - a.foo, a.bar, a.baz, b.foo, b.bar, b.baz; -}(M || (M = {})); +var a, b, M, a1, b1; +a.foo, a.bar, a.baz, b.foo, b.bar, b.baz, M || (M = {}), a1.foo, a1.bar, a1.baz, b1.foo, b1.bar, b1.baz; diff --git a/crates/swc/tests/tsc-references/mergeThreeInterfaces2.2.minified.js b/crates/swc/tests/tsc-references/mergeThreeInterfaces2.2.minified.js index 9965e243afb8..b96fcae1a12c 100644 --- a/crates/swc/tests/tsc-references/mergeThreeInterfaces2.2.minified.js +++ b/crates/swc/tests/tsc-references/mergeThreeInterfaces2.2.minified.js @@ -1,18 +1,3 @@ //// [mergeThreeInterfaces2.ts] -var M2; -!function(M2) { - var a; - a.foo, a.bar; -}(M2 || (M2 = {})), function(M2) { - var a; - a.foo, a.bar, a.baz; -}(M2 || (M2 = {})), function(M2) { - var a; - M2.M3 || (M2.M3 = {}), a.foo, a.bar; -}(M2 || (M2 = {})), function(M2) { - var a; - M2.M3 || (M2.M3 = {}), a.foo, a.bar, a.baz; -}(M2 || (M2 = {})), function(M2) { - var a; - M2.M3 || (M2.M3 = {}), a.foo, a.bar, a.baz; -}(M2 || (M2 = {})); +var M2, a, a1, M21, a2, M22, a3, M23, a4; +M2 || (M2 = {}), a.foo, a.bar, M2 || (M2 = {}), a1.foo, a1.bar, a1.baz, (M21 = M2 || (M2 = {})).M3 || (M21.M3 = {}), a2.foo, a2.bar, (M22 = M2 || (M2 = {})).M3 || (M22.M3 = {}), a3.foo, a3.bar, a3.baz, (M23 = M2 || (M2 = {})).M3 || (M23.M3 = {}), a4.foo, a4.bar, a4.baz; diff --git a/crates/swc/tests/tsc-references/mergeTwoInterfaces.2.minified.js b/crates/swc/tests/tsc-references/mergeTwoInterfaces.2.minified.js index 1823be123c13..469c3435c07f 100644 --- a/crates/swc/tests/tsc-references/mergeTwoInterfaces.2.minified.js +++ b/crates/swc/tests/tsc-references/mergeTwoInterfaces.2.minified.js @@ -1,6 +1,3 @@ //// [mergeTwoInterfaces.ts] -var a, b, M; -a.foo, a.bar, b.foo, b.bar, function(M) { - var a, b; - a.foo, a.bar, b.foo, b.bar; -}(M || (M = {})); +var a, b, M, a1, b1; +a.foo, a.bar, b.foo, b.bar, M || (M = {}), a1.foo, a1.bar, b1.foo, b1.bar; diff --git a/crates/swc/tests/tsc-references/mergeTwoInterfaces2.2.minified.js b/crates/swc/tests/tsc-references/mergeTwoInterfaces2.2.minified.js index 0a5f28e521c4..827f30d0e26a 100644 --- a/crates/swc/tests/tsc-references/mergeTwoInterfaces2.2.minified.js +++ b/crates/swc/tests/tsc-references/mergeTwoInterfaces2.2.minified.js @@ -1,15 +1,3 @@ //// [mergeTwoInterfaces2.ts] -var M2; -!function(M2) { - var a; - a.foo, a.bar; -}(M2 || (M2 = {})), function(M2) { - var a; - a.foo, a.bar; -}(M2 || (M2 = {})), function(M2) { - var a; - M2.M3 || (M2.M3 = {}), a.foo, a.bar; -}(M2 || (M2 = {})), function(M2) { - var a; - M2.M3 || (M2.M3 = {}), a.foo, a.bar; -}(M2 || (M2 = {})); +var M2, a, a1, M21, a2, M22, a3; +M2 || (M2 = {}), a.foo, a.bar, M2 || (M2 = {}), a1.foo, a1.bar, (M21 = M2 || (M2 = {})).M3 || (M21.M3 = {}), a2.foo, a2.bar, (M22 = M2 || (M2 = {})).M3 || (M22.M3 = {}), a3.foo, a3.bar; diff --git a/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind.2.minified.js b/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind.2.minified.js index c8f5404b652a..adf7ad67e3f9 100644 --- a/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind.2.minified.js +++ b/crates/swc/tests/tsc-references/moduleWithStatementsOfEveryKind.2.minified.js @@ -1,44 +1,32 @@ //// [moduleWithStatementsOfEveryKind.ts] -var A, Y; +var A, Y, Module, Color, Color1, Y1, A1, AA, B, BB, Color2; 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(A) { - var Module, Color, Color1; - Module || (Module = {}), (Color1 = Color || (Color = {}))[Color1.Blue = 0] = "Blue", Color1[Color1.Red = 1] = "Red"; -}(A || (A = {})), function(Y) { - var Color, A = function A() { - _class_call_check(this, A); - }; - Y.A = A; - var AA = function AA() { - _class_call_check(this, AA); - }; - Y.AA = AA; - var B = function(AA) { - _inherits(B, AA); - var _super = _create_super(B); - function B() { - return _class_call_check(this, B), _super.apply(this, arguments); - } - return B; - }(AA); - Y.B = B; - var BB = function(A) { - _inherits(BB, A); - var _super = _create_super(BB); - function BB() { - return _class_call_check(this, BB), _super.apply(this, arguments); - } - return BB; - }(A); - Y.BB = BB, Y.Module || (Y.Module = {}), (Color = Y.Color || (Y.Color = {}))[Color.Blue = 0] = "Blue", Color[Color.Red = 1] = "Red", Y.x = 12, Y.F = function(s) { - return 2; - }, Y.array = null, Y.fn = function(s) { - return "hello " + s; - }, Y.ol = { - s: "hello", - id: 2, - isvalid: !0 - }; -}(Y || (Y = {})); +A || (A = {}), Module || (Module = {}), (Color1 = Color || (Color = {}))[Color1.Blue = 0] = "Blue", Color1[Color1.Red = 1] = "Red", Y1 = Y || (Y = {}), A1 = function A() { + _class_call_check(this, A); +}, Y1.A = A1, AA = function AA() { + _class_call_check(this, AA); +}, Y1.AA = AA, B = function(AA) { + _inherits(B, AA); + var _super = _create_super(B); + function B() { + return _class_call_check(this, B), _super.apply(this, arguments); + } + return B; +}(AA), Y1.B = B, BB = function(A) { + _inherits(BB, A); + var _super = _create_super(BB); + function BB() { + 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) { + return 2; +}, Y1.array = null, Y1.fn = function(s) { + return "hello " + s; +}, Y1.ol = { + s: "hello", + id: 2, + isvalid: !0 +}; diff --git a/crates/swc/tests/tsc-references/nameCollision.2.minified.js b/crates/swc/tests/tsc-references/nameCollision.2.minified.js index de3fe8ee81f5..76562a87ee5f 100644 --- a/crates/swc/tests/tsc-references/nameCollision.2.minified.js +++ b/crates/swc/tests/tsc-references/nameCollision.2.minified.js @@ -1,10 +1,4 @@ //// [nameCollision.ts] -var A, B, X, Y, D; +var A, B, X, Y, D, X1, Y1, Y2, Y3, _$Y; import "@swc/helpers/_/_class_call_check"; -A || (A = {}), B || (B = {}), B || (B = {}), function(X) { - var Y; - (Y = X.Y || (X.Y = {})).Z || (Y.Z = {}); -}(X || (X = {})), function(Y) { - var Y1, _$Y; - (_$Y = (Y1 = Y.Y || (Y.Y = {})).Y || (Y1.Y = {}))[_$Y.Red = 0] = "Red", _$Y[_$Y.Blue = 1] = "Blue"; -}(Y || (Y = {})), (D || (D = {})).E = "hello"; +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"; diff --git a/crates/swc/tests/tsc-references/negateOperatorWithBooleanType.2.minified.js b/crates/swc/tests/tsc-references/negateOperatorWithBooleanType.2.minified.js index 777082684f46..1d9b5d55d0ac 100644 --- a/crates/swc/tests/tsc-references/negateOperatorWithBooleanType.2.minified.js +++ b/crates/swc/tests/tsc-references/negateOperatorWithBooleanType.2.minified.js @@ -1,6 +1,6 @@ //// [negateOperatorWithBooleanType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var M, A = function() { +var n, M, A = function() { function A() { _class_call_check(this, A); } @@ -8,9 +8,6 @@ var M, A = function() { return !1; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/negateOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/negateOperatorWithNumberType.2.minified.js index 14fab4aa565b..61224d6a3a20 100644 --- a/crates/swc/tests/tsc-references/negateOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/negateOperatorWithNumberType.2.minified.js @@ -1,6 +1,6 @@ //// [negateOperatorWithNumberType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var M, A = function() { +var M, n, A = function() { function A() { _class_call_check(this, A); } @@ -8,9 +8,6 @@ var M, A = function() { return 1; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; 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.2.minified.js b/crates/swc/tests/tsc-references/negateOperatorWithStringType.2.minified.js index 648476f7762d..5059d4e97e40 100644 --- a/crates/swc/tests/tsc-references/negateOperatorWithStringType.2.minified.js +++ b/crates/swc/tests/tsc-references/negateOperatorWithStringType.2.minified.js @@ -1,6 +1,6 @@ //// [negateOperatorWithStringType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var STRING, M, A = function() { +var STRING, M, n, A = function() { function A() { _class_call_check(this, A); } @@ -8,9 +8,6 @@ var STRING, M, A = function() { return ""; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; 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.2.minified.js b/crates/swc/tests/tsc-references/nestedModules.2.minified.js index d6e01bd9cd47..878d91810297 100644 --- a/crates/swc/tests/tsc-references/nestedModules.2.minified.js +++ b/crates/swc/tests/tsc-references/nestedModules.2.minified.js @@ -1,6 +1,3 @@ //// [nestedModules.ts] -var A, M2, A1; -(A1 = A || (A = {})).B || (A1.B = {}), function(M2) { - var Point; - (M2.X || (M2.X = {})).Point = Point; -}(M2 || (M2 = {})), M2.X.Point; +var A, M2, Point, A1, M21; +(A = A1 || (A1 = {})).B || (A.B = {}), ((M2 = M21 || (M21 = {})).X || (M2.X = {})).Point = Point, M21.X.Point; diff --git a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule.2.minified.js b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule.2.minified.js index 2c17d24ca9f4..e1c754ba3047 100644 --- a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule.2.minified.js +++ b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule.2.minified.js @@ -1,6 +1,3 @@ //// [objectLiteralShorthandPropertiesWithModule.ts] -var m; -!function(m) { - var x1; - m.x = x1; -}(m || (m = {})), m || (m = {}), x, x, x; +var m, x1; +(m || (m = {})).x = x1, m || (m = {}), x, x, x; diff --git a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6.2.minified.js b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6.2.minified.js index 0beebaf42ea1..adbdcd21a0eb 100644 --- a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6.2.minified.js +++ b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6.2.minified.js @@ -1,6 +1,3 @@ //// [objectLiteralShorthandPropertiesWithModuleES6.ts] -var m; -!function(m) { - var x1; - m.x = x1; -}(m || (m = {})), m || (m = {}), x, x, x; +var m, x1; +(m || (m = {})).x = x1, m || (m = {}), x, x, x; diff --git a/crates/swc/tests/tsc-references/optionalChainingInParameterInitializer(target=es2015).2.minified.js b/crates/swc/tests/tsc-references/optionalChainingInParameterInitializer(target=es2015).2.minified.js index aa27fc047ae7..15db854a51ee 100644 --- a/crates/swc/tests/tsc-references/optionalChainingInParameterInitializer(target=es2015).2.minified.js +++ b/crates/swc/tests/tsc-references/optionalChainingInParameterInitializer(target=es2015).2.minified.js @@ -1 +1,5 @@ //// [optionalChainingInParameterInitializer.ts] +const a = ()=>void 0; +((b = null === (_a = a()) || void 0 === _a ? void 0 : _a.d)=>{ + var _a; +})(); diff --git a/crates/swc/tests/tsc-references/optionalChainingInParameterInitializer.2(target=es2015).2.minified.js b/crates/swc/tests/tsc-references/optionalChainingInParameterInitializer.2(target=es2015).2.minified.js index c9920a3e5c12..68f467379994 100644 --- a/crates/swc/tests/tsc-references/optionalChainingInParameterInitializer.2(target=es2015).2.minified.js +++ b/crates/swc/tests/tsc-references/optionalChainingInParameterInitializer.2(target=es2015).2.minified.js @@ -1 +1,9 @@ //// [optionalChainingInParameterInitializer.2.ts] +const a = ()=>void 0; +((b = null === (_a = a()) || void 0 === _a ? void 0 : _a.d)=>{ + var _a; +})(); +const x = ""; +((b = null === (_a = a()) || void 0 === _a ? void 0 : _a.d, d = x)=>{ + var _a; +})(); diff --git a/crates/swc/tests/tsc-references/parserErrorRecovery_IncompleteMemberVariable1.2.minified.js b/crates/swc/tests/tsc-references/parserErrorRecovery_IncompleteMemberVariable1.2.minified.js index 2a3228cae446..5c331066f1ae 100644 --- a/crates/swc/tests/tsc-references/parserErrorRecovery_IncompleteMemberVariable1.2.minified.js +++ b/crates/swc/tests/tsc-references/parserErrorRecovery_IncompleteMemberVariable1.2.minified.js @@ -1,14 +1,11 @@ //// [parserErrorRecovery_IncompleteMemberVariable1.ts] -var Shapes; +var Shapes, Point, Shapes1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(Shapes) { - var Point = function() { - function Point(x, y) { - _class_call_check(this, Point), this.x = x, this.y = y; - } - return Point.prototype.getDist = function() { - return Math.sqrt(this.x * this.x + this.y * this.y); - }, Point; - }(); - Point.origin = new Point(0, 0), Shapes.Point = Point; -}(Shapes || (Shapes = {})), new Shapes.Point(3, 4).getDist(); +Shapes = Shapes1 || (Shapes1 = {}), (Point = function() { + function Point(x, y) { + _class_call_check(this, Point), this.x = x, this.y = y; + } + return Point.prototype.getDist = function() { + return Math.sqrt(this.x * this.x + this.y * this.y); + }, Point; +}()).origin = new Point(0, 0), Shapes.Point = Point, new Shapes1.Point(3, 4).getDist(); diff --git a/crates/swc/tests/tsc-references/parserModule1.2.minified.js b/crates/swc/tests/tsc-references/parserModule1.2.minified.js index 71c4755dd041..ef04af8eb13a 100644 --- a/crates/swc/tests/tsc-references/parserModule1.2.minified.js +++ b/crates/swc/tests/tsc-references/parserModule1.2.minified.js @@ -1,12 +1,11 @@ //// [parserModule1.ts] -export var CompilerDiagnostics; -!function(CompilerDiagnostics) { - var 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 && Alert(s); - }, CompilerDiagnostics.assert = function(condition, s) { - debug && !condition && Alert(s); - }; -}(CompilerDiagnostics || (CompilerDiagnostics = {})); +var CompilerDiagnostics, Alert, debug, diagnosticWriter; +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 && Alert(s); +}, CompilerDiagnostics.assert = function(condition, s) { + debug && !condition && Alert(s); +}; diff --git a/crates/swc/tests/tsc-references/parserRealSource1.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource1.2.minified.js index 9afcc88c85a0..f9013c031e78 100644 --- a/crates/swc/tests/tsc-references/parserRealSource1.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource1.2.minified.js @@ -1,117 +1,109 @@ //// [parserRealSource1.ts] -var TypeScript; +var TypeScript, TypeScript1, NullLogger, LoggerAdapter, BufferedLogger; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(TypeScript) { - !function(CompilerDiagnostics) { - var debug = CompilerDiagnostics.debug = !1, diagnosticWriter = CompilerDiagnostics.diagnosticWriter = null; - function Alert(output) { - diagnosticWriter && diagnosticWriter.Alert(output); - } - CompilerDiagnostics.analysisPass = 0, CompilerDiagnostics.Alert = Alert, CompilerDiagnostics.debugPrint = function(s) { - debug && Alert(s); - }, CompilerDiagnostics.assert = function(condition, s) { - debug && !condition && Alert(s); - }; - }(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); - var NullLogger = function() { - function NullLogger() { - _class_call_check(this, NullLogger); - } - var _proto = NullLogger.prototype; - return _proto.information = function() { - return !1; - }, _proto.debug = function() { - return !1; - }, _proto.warning = function() { - return !1; - }, _proto.error = function() { - return !1; - }, _proto.fatal = function() { - return !1; - }, _proto.log = function(s) {}, NullLogger; - }(); - TypeScript.NullLogger = NullLogger; - var LoggerAdapter = function() { - function LoggerAdapter(logger) { - _class_call_check(this, LoggerAdapter), this.logger = logger, this._information = this.logger.information(), this._debug = this.logger.debug(), this._warning = this.logger.warning(), this._error = this.logger.error(), this._fatal = this.logger.fatal(); - } - var _proto = LoggerAdapter.prototype; - return _proto.information = function() { - return this._information; - }, _proto.debug = function() { - return this._debug; - }, _proto.warning = function() { - return this._warning; - }, _proto.error = function() { - return this._error; - }, _proto.fatal = function() { - return this._fatal; - }, _proto.log = function(s) { - this.logger.log(s); - }, LoggerAdapter; - }(); - TypeScript.LoggerAdapter = LoggerAdapter; - var BufferedLogger = function() { - function BufferedLogger() { - _class_call_check(this, BufferedLogger), this.logContents = []; - } - var _proto = BufferedLogger.prototype; - return _proto.information = function() { - return !1; - }, _proto.debug = function() { - return !1; - }, _proto.warning = function() { - return !1; - }, _proto.error = function() { - return !1; - }, _proto.fatal = function() { - return !1; - }, _proto.log = function(s) { - this.logContents.push(s); - }, BufferedLogger; - }(); - TypeScript.BufferedLogger = BufferedLogger, TypeScript.timeFunction = function(logger, funcDescription, func) { - var start = +new Date(), result = func(), end = +new Date(); - return logger.log(funcDescription + " completed in " + (end - start) + " msec"), result; - }, TypeScript.stringToLiteral = function(value, length) { - var result = "", addChar = function(index) { - switch(value.charCodeAt(index)){ - case 0x09: - result += "\\t"; - break; - case 0x0a: - result += "\\n"; - break; - case 0x0b: - result += "\\v"; - break; - case 0x0c: - result += "\\f"; - break; - case 0x0d: - result += "\\r"; - break; - case 0x22: - result += '\\"'; - break; - case 0x27: - result += "\\'"; - break; - case 0x5c: - result += "\\"; - break; - default: - result += value.charAt(index); - } - }; - if (value.length > length) { - for(var mid = length >> 1, i = 0; i < mid; i++)addChar(i); - result += "(...)"; - for(var i = value.length - mid; i < value.length; i++)addChar(i); - } else { - length = value.length; - for(var i = 0; i < length; i++)addChar(i); +!function(CompilerDiagnostics) { + var debug = CompilerDiagnostics.debug = !1, diagnosticWriter = CompilerDiagnostics.diagnosticWriter = null; + function Alert(output) { + diagnosticWriter && diagnosticWriter.Alert(output); + } + 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() { + function NullLogger() { + _class_call_check(this, NullLogger); + } + var _proto = NullLogger.prototype; + return _proto.information = function() { + return !1; + }, _proto.debug = function() { + return !1; + }, _proto.warning = function() { + return !1; + }, _proto.error = function() { + return !1; + }, _proto.fatal = function() { + return !1; + }, _proto.log = function(s) {}, NullLogger; +}(), TypeScript1.NullLogger = NullLogger, LoggerAdapter = function() { + function LoggerAdapter(logger) { + _class_call_check(this, LoggerAdapter), this.logger = logger, this._information = this.logger.information(), this._debug = this.logger.debug(), this._warning = this.logger.warning(), this._error = this.logger.error(), this._fatal = this.logger.fatal(); + } + var _proto = LoggerAdapter.prototype; + return _proto.information = function() { + return this._information; + }, _proto.debug = function() { + return this._debug; + }, _proto.warning = function() { + return this._warning; + }, _proto.error = function() { + return this._error; + }, _proto.fatal = function() { + return this._fatal; + }, _proto.log = function(s) { + this.logger.log(s); + }, LoggerAdapter; +}(), TypeScript1.LoggerAdapter = LoggerAdapter, BufferedLogger = function() { + function BufferedLogger() { + _class_call_check(this, BufferedLogger), this.logContents = []; + } + var _proto = BufferedLogger.prototype; + return _proto.information = function() { + return !1; + }, _proto.debug = function() { + return !1; + }, _proto.warning = function() { + return !1; + }, _proto.error = function() { + return !1; + }, _proto.fatal = function() { + return !1; + }, _proto.log = function(s) { + this.logContents.push(s); + }, BufferedLogger; +}(), TypeScript1.BufferedLogger = BufferedLogger, TypeScript1.timeFunction = function(logger, funcDescription, func) { + var start = +new Date(), result = func(), end = +new Date(); + return logger.log(funcDescription + " completed in " + (end - start) + " msec"), result; +}, TypeScript1.stringToLiteral = function(value, length) { + var result = "", addChar = function(index) { + switch(value.charCodeAt(index)){ + case 0x09: + result += "\\t"; + break; + case 0x0a: + result += "\\n"; + break; + case 0x0b: + result += "\\v"; + break; + case 0x0c: + result += "\\f"; + break; + case 0x0d: + result += "\\r"; + break; + case 0x22: + result += '\\"'; + break; + case 0x27: + result += "\\'"; + break; + case 0x5c: + result += "\\"; + break; + default: + result += value.charAt(index); } - return result; }; -}(TypeScript || (TypeScript = {})); + if (value.length > length) { + for(var mid = length >> 1, i = 0; i < mid; i++)addChar(i); + result += "(...)"; + for(var i = value.length - mid; i < value.length; i++)addChar(i); + } else { + length = value.length; + for(var i = 0; i < length; i++)addChar(i); + } + return result; +}; diff --git a/crates/swc/tests/tsc-references/parserRealSource12.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource12.2.minified.js index 689905dab76d..c3d3cd347f40 100644 --- a/crates/swc/tests/tsc-references/parserRealSource12.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource12.2.minified.js @@ -1,114 +1,109 @@ //// [parserRealSource12.ts] -var TypeScript; +var TypeScript, TypeScript1, globalAstWalkerFactory, ChildrenWalkers, AstWalkOptions, AstWalker, AstWalkerFactory; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(TypeScript) { - var globalAstWalkerFactory, ChildrenWalkers, AstWalkOptions = function() { - function AstWalkOptions() { - _class_call_check(this, AstWalkOptions), this.goChildren = !0, this.goNextSibling = !0, this.reverseSiblings = !1; - } - return AstWalkOptions.prototype.stopWalk = function() { - var stop = !(arguments.length > 0) || void 0 === arguments[0] || arguments[0]; - this.goChildren = !stop, this.goNextSibling = !stop; - }, AstWalkOptions; - }(); - TypeScript.AstWalkOptions = AstWalkOptions; - var AstWalker = function() { - function AstWalker(childrenWalkers, pre, post, options, state) { - _class_call_check(this, AstWalker), this.childrenWalkers = childrenWalkers, this.pre = pre, this.post = post, this.options = options, this.state = state; - } - return AstWalker.prototype.walk = function(ast, parent) { - var preAst = this.pre(ast, parent, this); - if (void 0 === preAst && (preAst = ast), this.options.goChildren) { - var svGoSib = this.options.goNextSibling; - this.options.goNextSibling = !0, this.childrenWalkers[ast.nodeType](ast, parent, this), this.options.goNextSibling = svGoSib; - } else this.options.goChildren = !0; - if (!this.post) return preAst; - var postAst = this.post(preAst, parent, this); - return void 0 === postAst && (postAst = preAst), postAst; - }, AstWalker; - }(), AstWalkerFactory = function() { - function AstWalkerFactory() { - _class_call_check(this, AstWalkerFactory), this.childrenWalkers = [], this.initChildrenWalkers(); - } - var _proto = AstWalkerFactory.prototype; - return _proto.walk = function(ast, pre, post, options, state) { - return this.getWalker(pre, post, options, state).walk(ast, null); - }, _proto.getWalker = function(pre, post, options, state) { - return this.getSlowWalker(pre, post, options, state); - }, _proto.getSlowWalker = function(pre, post, options, state) { - return options || (options = new AstWalkOptions()), new AstWalker(this.childrenWalkers, pre, post, options, state); - }, _proto.initChildrenWalkers = function() { - for(var e in this.childrenWalkers[NodeType.None] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Empty] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.EmptyExpr] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.True] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.False] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.This] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Super] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.QString] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Regex] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Null] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.ArrayLit] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.ObjectLit] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.Void] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.Comma] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Pos] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.Neg] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.Delete] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.Await] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.In] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Dot] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.From] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Is] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.InstOf] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Typeof] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.NumberLit] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Name] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.TypeRef] = ChildrenWalkers.walkTypeReferenceChildren, this.childrenWalkers[NodeType.Index] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Call] = ChildrenWalkers.walkCallExpressionChildren, this.childrenWalkers[NodeType.New] = ChildrenWalkers.walkCallExpressionChildren, this.childrenWalkers[NodeType.Asg] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgAdd] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgSub] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgDiv] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgMul] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgMod] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgAnd] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgXor] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgOr] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgLsh] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgRsh] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgRs2] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.ConditionalExpression] = ChildrenWalkers.walkTrinaryExpressionChildren, this.childrenWalkers[NodeType.LogOr] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.LogAnd] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Or] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Xor] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.And] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Eq] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Ne] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Eqv] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.NEqv] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Lt] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Le] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Gt] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Ge] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Add] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Sub] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Mul] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Div] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Mod] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Lsh] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Rsh] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Rs2] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Not] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.LogNot] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.IncPre] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.DecPre] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.IncPost] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.DecPost] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.TypeAssertion] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.FuncDecl] = ChildrenWalkers.walkFuncDeclChildren, this.childrenWalkers[NodeType.Member] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.VarDecl] = ChildrenWalkers.walkBoundDeclChildren, this.childrenWalkers[NodeType.ArgDecl] = ChildrenWalkers.walkBoundDeclChildren, this.childrenWalkers[NodeType.Return] = ChildrenWalkers.walkReturnStatementChildren, this.childrenWalkers[NodeType.Break] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Continue] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Throw] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.For] = ChildrenWalkers.walkForStatementChildren, this.childrenWalkers[NodeType.ForIn] = ChildrenWalkers.walkForInStatementChildren, this.childrenWalkers[NodeType.If] = ChildrenWalkers.walkIfStatementChildren, this.childrenWalkers[NodeType.While] = ChildrenWalkers.walkWhileStatementChildren, this.childrenWalkers[NodeType.DoWhile] = ChildrenWalkers.walkDoWhileStatementChildren, this.childrenWalkers[NodeType.Block] = ChildrenWalkers.walkBlockChildren, this.childrenWalkers[NodeType.Case] = ChildrenWalkers.walkCaseStatementChildren, this.childrenWalkers[NodeType.Switch] = ChildrenWalkers.walkSwitchStatementChildren, this.childrenWalkers[NodeType.Try] = ChildrenWalkers.walkTryChildren, this.childrenWalkers[NodeType.TryCatch] = ChildrenWalkers.walkTryCatchChildren, this.childrenWalkers[NodeType.TryFinally] = ChildrenWalkers.walkTryFinallyChildren, this.childrenWalkers[NodeType.Finally] = ChildrenWalkers.walkFinallyChildren, this.childrenWalkers[NodeType.Catch] = ChildrenWalkers.walkCatchChildren, this.childrenWalkers[NodeType.List] = ChildrenWalkers.walkListChildren, this.childrenWalkers[NodeType.Script] = ChildrenWalkers.walkScriptChildren, this.childrenWalkers[NodeType.ClassDeclaration] = ChildrenWalkers.walkClassDeclChildren, this.childrenWalkers[NodeType.InterfaceDeclaration] = ChildrenWalkers.walkTypeDeclChildren, this.childrenWalkers[NodeType.ModuleDeclaration] = ChildrenWalkers.walkModuleDeclChildren, this.childrenWalkers[NodeType.ImportDeclaration] = ChildrenWalkers.walkImportDeclChildren, this.childrenWalkers[NodeType.With] = ChildrenWalkers.walkWithStatementChildren, this.childrenWalkers[NodeType.Label] = ChildrenWalkers.walkLabelChildren, this.childrenWalkers[NodeType.LabeledStatement] = ChildrenWalkers.walkLabeledStatementChildren, this.childrenWalkers[NodeType.EBStart] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.GotoEB] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.EndCode] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Error] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Comment] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Debugger] = ChildrenWalkers.walkNone, NodeType._map)if (void 0 === this.childrenWalkers[e]) throw Error("initWalkers function is not up to date with enum content!"); - }, AstWalkerFactory; - }(); - TypeScript.AstWalkerFactory = AstWalkerFactory, TypeScript.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) {}, 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) {}, 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 = {})); -}(TypeScript || (TypeScript = {})); +TypeScript1 = TypeScript || (TypeScript = {}), AstWalkOptions = function() { + function AstWalkOptions() { + _class_call_check(this, AstWalkOptions), this.goChildren = !0, this.goNextSibling = !0, this.reverseSiblings = !1; + } + return AstWalkOptions.prototype.stopWalk = function() { + var stop = !(arguments.length > 0) || void 0 === arguments[0] || arguments[0]; + this.goChildren = !stop, this.goNextSibling = !stop; + }, AstWalkOptions; +}(), TypeScript1.AstWalkOptions = AstWalkOptions, AstWalker = function() { + function AstWalker(childrenWalkers, pre, post, options, state) { + _class_call_check(this, AstWalker), this.childrenWalkers = childrenWalkers, this.pre = pre, this.post = post, this.options = options, this.state = state; + } + return AstWalker.prototype.walk = function(ast, parent) { + var preAst = this.pre(ast, parent, this); + if (void 0 === preAst && (preAst = ast), this.options.goChildren) { + var svGoSib = this.options.goNextSibling; + this.options.goNextSibling = !0, this.childrenWalkers[ast.nodeType](ast, parent, this), this.options.goNextSibling = svGoSib; + } else this.options.goChildren = !0; + if (!this.post) return preAst; + var postAst = this.post(preAst, parent, this); + return void 0 === postAst && (postAst = preAst), postAst; + }, AstWalker; +}(), AstWalkerFactory = function() { + function AstWalkerFactory() { + _class_call_check(this, AstWalkerFactory), this.childrenWalkers = [], this.initChildrenWalkers(); + } + var _proto = AstWalkerFactory.prototype; + return _proto.walk = function(ast, pre, post, options, state) { + return this.getWalker(pre, post, options, state).walk(ast, null); + }, _proto.getWalker = function(pre, post, options, state) { + return this.getSlowWalker(pre, post, options, state); + }, _proto.getSlowWalker = function(pre, post, options, state) { + return options || (options = new AstWalkOptions()), new AstWalker(this.childrenWalkers, pre, post, options, state); + }, _proto.initChildrenWalkers = function() { + for(var e in this.childrenWalkers[NodeType.None] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Empty] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.EmptyExpr] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.True] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.False] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.This] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Super] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.QString] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Regex] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Null] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.ArrayLit] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.ObjectLit] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.Void] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.Comma] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Pos] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.Neg] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.Delete] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.Await] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.In] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Dot] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.From] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Is] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.InstOf] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Typeof] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.NumberLit] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Name] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.TypeRef] = ChildrenWalkers.walkTypeReferenceChildren, this.childrenWalkers[NodeType.Index] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Call] = ChildrenWalkers.walkCallExpressionChildren, this.childrenWalkers[NodeType.New] = ChildrenWalkers.walkCallExpressionChildren, this.childrenWalkers[NodeType.Asg] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgAdd] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgSub] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgDiv] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgMul] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgMod] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgAnd] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgXor] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgOr] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgLsh] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgRsh] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.AsgRs2] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.ConditionalExpression] = ChildrenWalkers.walkTrinaryExpressionChildren, this.childrenWalkers[NodeType.LogOr] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.LogAnd] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Or] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Xor] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.And] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Eq] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Ne] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Eqv] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.NEqv] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Lt] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Le] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Gt] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Ge] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Add] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Sub] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Mul] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Div] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Mod] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Lsh] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Rsh] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Rs2] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.Not] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.LogNot] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.IncPre] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.DecPre] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.IncPost] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.DecPost] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.TypeAssertion] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.FuncDecl] = ChildrenWalkers.walkFuncDeclChildren, this.childrenWalkers[NodeType.Member] = ChildrenWalkers.walkBinaryExpressionChildren, this.childrenWalkers[NodeType.VarDecl] = ChildrenWalkers.walkBoundDeclChildren, this.childrenWalkers[NodeType.ArgDecl] = ChildrenWalkers.walkBoundDeclChildren, this.childrenWalkers[NodeType.Return] = ChildrenWalkers.walkReturnStatementChildren, this.childrenWalkers[NodeType.Break] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Continue] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Throw] = ChildrenWalkers.walkUnaryExpressionChildren, this.childrenWalkers[NodeType.For] = ChildrenWalkers.walkForStatementChildren, this.childrenWalkers[NodeType.ForIn] = ChildrenWalkers.walkForInStatementChildren, this.childrenWalkers[NodeType.If] = ChildrenWalkers.walkIfStatementChildren, this.childrenWalkers[NodeType.While] = ChildrenWalkers.walkWhileStatementChildren, this.childrenWalkers[NodeType.DoWhile] = ChildrenWalkers.walkDoWhileStatementChildren, this.childrenWalkers[NodeType.Block] = ChildrenWalkers.walkBlockChildren, this.childrenWalkers[NodeType.Case] = ChildrenWalkers.walkCaseStatementChildren, this.childrenWalkers[NodeType.Switch] = ChildrenWalkers.walkSwitchStatementChildren, this.childrenWalkers[NodeType.Try] = ChildrenWalkers.walkTryChildren, this.childrenWalkers[NodeType.TryCatch] = ChildrenWalkers.walkTryCatchChildren, this.childrenWalkers[NodeType.TryFinally] = ChildrenWalkers.walkTryFinallyChildren, this.childrenWalkers[NodeType.Finally] = ChildrenWalkers.walkFinallyChildren, this.childrenWalkers[NodeType.Catch] = ChildrenWalkers.walkCatchChildren, this.childrenWalkers[NodeType.List] = ChildrenWalkers.walkListChildren, this.childrenWalkers[NodeType.Script] = ChildrenWalkers.walkScriptChildren, this.childrenWalkers[NodeType.ClassDeclaration] = ChildrenWalkers.walkClassDeclChildren, this.childrenWalkers[NodeType.InterfaceDeclaration] = ChildrenWalkers.walkTypeDeclChildren, this.childrenWalkers[NodeType.ModuleDeclaration] = ChildrenWalkers.walkModuleDeclChildren, this.childrenWalkers[NodeType.ImportDeclaration] = ChildrenWalkers.walkImportDeclChildren, this.childrenWalkers[NodeType.With] = ChildrenWalkers.walkWithStatementChildren, this.childrenWalkers[NodeType.Label] = ChildrenWalkers.walkLabelChildren, this.childrenWalkers[NodeType.LabeledStatement] = ChildrenWalkers.walkLabeledStatementChildren, this.childrenWalkers[NodeType.EBStart] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.GotoEB] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.EndCode] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Error] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Comment] = ChildrenWalkers.walkNone, this.childrenWalkers[NodeType.Debugger] = ChildrenWalkers.walkNone, NodeType._map)if (void 0 === this.childrenWalkers[e]) throw Error("initWalkers function is not up to date with enum content!"); + }, 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) {}, 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) {}, 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 = {})); diff --git a/crates/swc/tests/tsc-references/parserRealSource14.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource14.2.minified.js index 865e4ffdf003..749e2443259c 100644 --- a/crates/swc/tests/tsc-references/parserRealSource14.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource14.2.minified.js @@ -1,191 +1,184 @@ //// [parserRealSource14.ts] -var TypeScript; +var TypeScript, TypeScript1, GetAstPathOptions, lastOf, max, isValidAstNode, AstPath, AstPathContext, GetAstPathOptions1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(TypeScript1) { - var GetAstPathOptions, GetAstPathOptions1, lastOf = function(items) { - return null === items || 0 === items.length ? null : items[items.length - 1]; - }, max = function(a, b) { - return a >= b ? a : b; - }, isValidAstNode = function(ast) { - return null !== ast && -1 !== ast.minChar && -1 !== ast.limChar; - }; - TypeScript1.lastOf = lastOf, TypeScript1.max = max, TypeScript1.min = function(a, b) { - return a <= b ? a : b; - }; - var AstPath = function() { - function AstPath() { - _class_call_check(this, AstPath), this.asts = [], this.top = -1; +TypeScript1 = TypeScript || (TypeScript = {}), lastOf = function(items) { + return null === items || 0 === items.length ? null : items[items.length - 1]; +}, max = function(a, b) { + return a >= b ? a : b; +}, isValidAstNode = function(ast) { + return null !== ast && -1 !== ast.minChar && -1 !== ast.limChar; +}, TypeScript1.lastOf = lastOf, TypeScript1.max = max, TypeScript1.min = function(a, b) { + return a <= b ? a : b; +}, AstPath = function() { + function AstPath() { + _class_call_check(this, AstPath), this.asts = [], this.top = -1; + } + var _proto = AstPath.prototype; + return _proto.clone = function() { + var clone = new AstPath(); + return clone.asts = this.asts.map(function(value) { + return value; + }), clone.top = this.top, clone; + }, _proto.pop = function() { + var head = this.ast(); + for(this.up(); this.asts.length > this.count();)this.asts.pop(); + return head; + }, _proto.push = function(ast) { + for(; this.asts.length > this.count();)this.asts.pop(); + this.top = this.asts.length, this.asts.push(ast); + }, _proto.up = function() { + if (this.top <= -1) throw Error("Invalid call to 'up'"); + this.top--; + }, _proto.down = function() { + 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; + }, _proto.ast = function() { + return AstPath.reverseIndexOf(this.asts, this.asts.length - (this.top + 1)); + }, _proto.parent = function() { + return AstPath.reverseIndexOf(this.asts, this.asts.length - this.top); + }, _proto.count = function() { + return this.top + 1; + }, _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(); + }, _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(); + }, _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(); + }, _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(); + }, _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(); + }, _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(); + }, _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; + }, _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; + }, _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; + }, _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]; + }, _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; + }, _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); + }, _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); + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _proto.isItemOfList = function() { + return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List; + }, _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]; + }, _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]; + }, _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; + }, _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]; + }, _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]; + }, _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]; + }, _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]; + }, _proto.isSynthesizedBlock = function() { + return this.count() >= 1 && this.asts[this.top - 0].nodeType === TypeScript.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.DontPruneSearchBasedOnPosition = 2] = "DontPruneSearchBasedOnPosition", TypeScript1.getAstPathToPosition = function(script, pos) { + var options = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : GetAstPathOptions.Default, 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]); } - var _proto = AstPath.prototype; - return _proto.clone = function() { - var clone = new AstPath(); - return clone.asts = this.asts.map(function(value) { - return value; - }), clone.top = this.top, clone; - }, _proto.pop = function() { - var head = this.ast(); - for(this.up(); this.asts.length > this.count();)this.asts.pop(); - return head; - }, _proto.push = function(ast) { - for(; this.asts.length > this.count();)this.asts.pop(); - this.top = this.asts.length, this.asts.push(ast); - }, _proto.up = function() { - if (this.top <= -1) throw Error("Invalid call to 'up'"); - this.top--; - }, _proto.down = function() { - 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; - }, _proto.ast = function() { - return AstPath.reverseIndexOf(this.asts, this.asts.length - (this.top + 1)); - }, _proto.parent = function() { - return AstPath.reverseIndexOf(this.asts, this.asts.length - this.top); - }, _proto.count = function() { - return this.top + 1; - }, _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(); - }, _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(); - }, _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(); - }, _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(); - }, _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(); - }, _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(); - }, _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; - }, _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; - }, _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; - }, _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]; - }, _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; - }, _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); - }, _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); - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _proto.isItemOfList = function() { - return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List; - }, _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]; - }, _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]; - }, _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; - }, _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]; - }, _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]; - }, _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]; - }, _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]; - }, _proto.isSynthesizedBlock = function() { - return this.count() >= 1 && this.asts[this.top - 0].nodeType === TypeScript.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; - var AstPathContext = function AstPathContext() { - _class_call_check(this, AstPathContext), this.path = new TypeScript.AstPath(); - }; - TypeScript1.AstPathContext = AstPathContext, (GetAstPathOptions = GetAstPathOptions1 = 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] : GetAstPathOptions1.Default, 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) { + if (isValidAstNode(cur)) { + var inclusive = hasFlag(options, GetAstPathOptions.EdgeInclusive) || cur.nodeType === TypeScript.NodeType.Name || pos === script.limChar, minChar = cur.minChar, limChar = cur.limChar + (inclusive ? 1 : 0); + if (pos >= minChar && pos < limChar) { + var previous = ctx.path.ast(); + (null == previous || cur.minChar >= previous.minChar && cur.limChar <= previous.limChar) && ctx.path.push(cur); } - }, ctx = new AstPathContext(); - return TypeScript.getAstWalkerFactory().walk(script, function(cur, parent, walker) { - if (isValidAstNode(cur)) { - var inclusive = hasFlag(options, GetAstPathOptions1.EdgeInclusive) || cur.nodeType === TypeScript.NodeType.Name || pos === script.limChar, minChar = cur.minChar, limChar = cur.limChar + (inclusive ? 1 : 0); - if (pos >= minChar && pos < limChar) { - 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, GetAstPathOptions1.DontPruneSearchBasedOnPosition) || (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; - }), bestOffset; - }, TypeScript1.walkAST = function(ast, callback) { - var path = new AstPath(); - TypeScript.getAstWalkerFactory().walk(ast, function(cur, parent, walker) { - var path = walker.state; - return path.push(cur), callback(path, walker), cur; - }, function(cur, parent, walker) { - return walker.state.pop(), cur; - }, null, path); - }; -}(TypeScript || (TypeScript = {})); + pos < limChar && lookInComments(cur.preComments), pos >= minChar && lookInComments(cur.postComments), hasFlag(options, GetAstPathOptions.DontPruneSearchBasedOnPosition) || (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; + }), bestOffset; +}, TypeScript1.walkAST = function(ast, callback) { + var path = new AstPath(); + TypeScript.getAstWalkerFactory().walk(ast, function(cur, parent, walker) { + var path = walker.state; + return path.push(cur), callback(path, walker), cur; + }, function(cur, parent, walker) { + return walker.state.pop(), cur; + }, null, path); +}; diff --git a/crates/swc/tests/tsc-references/parserRealSource2.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource2.2.minified.js index 5ba4748e0a2d..22eb7d5022e6 100644 --- a/crates/swc/tests/tsc-references/parserRealSource2.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource2.2.minified.js @@ -1,18 +1,15 @@ //// [parserRealSource2.ts] -var TypeScript; -!function(TypeScript) { - var CodeGenTarget, ModuleGenTarget, ErrorRecoverySet, AllowedElements, Modifiers, ASTFlags, DeclFlags, ModuleFlags, SymbolFlags, VarFlags, FncFlags, SignatureFlags, TypeFlags, TypeRelationshipFlags, CodeGenTarget1, ModuleGenTarget1; - TypeScript.hasFlag = function(val, flag) { - return (val & flag) != 0; - }, (ErrorRecoverySet = TypeScript.ErrorRecoverySet || (TypeScript.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 = TypeScript.AllowedElements || (TypeScript.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 = TypeScript.Modifiers || (TypeScript.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 = TypeScript.ASTFlags || (TypeScript.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 = TypeScript.DeclFlags || (TypeScript.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 = TypeScript.ModuleFlags || (TypeScript.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 = TypeScript.SymbolFlags || (TypeScript.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 = TypeScript.VarFlags || (TypeScript.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 = TypeScript.FncFlags || (TypeScript.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 = TypeScript.SignatureFlags || (TypeScript.SignatureFlags = {}))[SignatureFlags.None = 0] = "None", SignatureFlags[SignatureFlags.IsIndexer = 1] = "IsIndexer", SignatureFlags[SignatureFlags.IsStringIndexer = 2] = "IsStringIndexer", SignatureFlags[SignatureFlags.IsNumberIndexer = 4] = "IsNumberIndexer", TypeScript.ToDeclFlags = function(fncOrVarOrSymbolOrModuleFlags) { - return fncOrVarOrSymbolOrModuleFlags; - }, (TypeFlags = TypeScript.TypeFlags || (TypeScript.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 = TypeScript.TypeRelationshipFlags || (TypeScript.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 = TypeScript.CodeGenTarget || (TypeScript.CodeGenTarget = {}))[CodeGenTarget1.ES3 = 0] = "ES3", CodeGenTarget1[CodeGenTarget1.ES5 = 1] = "ES5", (ModuleGenTarget1 = ModuleGenTarget = TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {}))[ModuleGenTarget1.Synchronous = 0] = "Synchronous", ModuleGenTarget1[ModuleGenTarget1.Asynchronous = 1] = "Asynchronous", ModuleGenTarget1[ModuleGenTarget1.Local = 2] = "Local", TypeScript.codeGenTarget = CodeGenTarget.ES3, TypeScript.moduleGenTarget = ModuleGenTarget.Synchronous, TypeScript.optimizeModuleCodeGen = !0, TypeScript.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; - break; - } +var TypeScript, TypeScript1, CodeGenTarget, ModuleGenTarget, ErrorRecoverySet, AllowedElements, Modifiers, ASTFlags, DeclFlags, ModuleFlags, SymbolFlags, VarFlags, FncFlags, SignatureFlags, TypeFlags, TypeRelationshipFlags, CodeGenTarget1, ModuleGenTarget1; +(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.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) { + 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; + break; } - return builder; - }; -}(TypeScript || (TypeScript = {})); + } + return builder; +}; diff --git a/crates/swc/tests/tsc-references/parserRealSource3.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource3.2.minified.js index 20ecf156c3b3..84517dba8657 100644 --- a/crates/swc/tests/tsc-references/parserRealSource3.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource3.2.minified.js @@ -1,6 +1,3 @@ //// [parserRealSource3.ts] -var TypeScript; -!function(TypeScript) { - var NodeType; - (NodeType = TypeScript.NodeType || (TypeScript.NodeType = {}))[NodeType.None = 0] = "None", NodeType[NodeType.Empty = 1] = "Empty", NodeType[NodeType.EmptyExpr = 2] = "EmptyExpr", NodeType[NodeType.True = 3] = "True", NodeType[NodeType.False = 4] = "False", NodeType[NodeType.This = 5] = "This", NodeType[NodeType.Super = 6] = "Super", NodeType[NodeType.QString = 7] = "QString", NodeType[NodeType.Regex = 8] = "Regex", NodeType[NodeType.Null = 9] = "Null", NodeType[NodeType.ArrayLit = 10] = "ArrayLit", NodeType[NodeType.ObjectLit = 11] = "ObjectLit", NodeType[NodeType.Void = 12] = "Void", NodeType[NodeType.Comma = 13] = "Comma", NodeType[NodeType.Pos = 14] = "Pos", NodeType[NodeType.Neg = 15] = "Neg", NodeType[NodeType.Delete = 16] = "Delete", NodeType[NodeType.Await = 17] = "Await", NodeType[NodeType.In = 18] = "In", NodeType[NodeType.Dot = 19] = "Dot", NodeType[NodeType.From = 20] = "From", NodeType[NodeType.Is = 21] = "Is", NodeType[NodeType.InstOf = 22] = "InstOf", NodeType[NodeType.Typeof = 23] = "Typeof", NodeType[NodeType.NumberLit = 24] = "NumberLit", NodeType[NodeType.Name = 25] = "Name", NodeType[NodeType.TypeRef = 26] = "TypeRef", NodeType[NodeType.Index = 27] = "Index", NodeType[NodeType.Call = 28] = "Call", NodeType[NodeType.New = 29] = "New", NodeType[NodeType.Asg = 30] = "Asg", NodeType[NodeType.AsgAdd = 31] = "AsgAdd", NodeType[NodeType.AsgSub = 32] = "AsgSub", NodeType[NodeType.AsgDiv = 33] = "AsgDiv", NodeType[NodeType.AsgMul = 34] = "AsgMul", NodeType[NodeType.AsgMod = 35] = "AsgMod", NodeType[NodeType.AsgAnd = 36] = "AsgAnd", NodeType[NodeType.AsgXor = 37] = "AsgXor", NodeType[NodeType.AsgOr = 38] = "AsgOr", NodeType[NodeType.AsgLsh = 39] = "AsgLsh", NodeType[NodeType.AsgRsh = 40] = "AsgRsh", NodeType[NodeType.AsgRs2 = 41] = "AsgRs2", NodeType[NodeType.ConditionalExpression = 42] = "ConditionalExpression", NodeType[NodeType.LogOr = 43] = "LogOr", NodeType[NodeType.LogAnd = 44] = "LogAnd", NodeType[NodeType.Or = 45] = "Or", NodeType[NodeType.Xor = 46] = "Xor", NodeType[NodeType.And = 47] = "And", NodeType[NodeType.Eq = 48] = "Eq", NodeType[NodeType.Ne = 49] = "Ne", NodeType[NodeType.Eqv = 50] = "Eqv", NodeType[NodeType.NEqv = 51] = "NEqv", NodeType[NodeType.Lt = 52] = "Lt", NodeType[NodeType.Le = 53] = "Le", NodeType[NodeType.Gt = 54] = "Gt", NodeType[NodeType.Ge = 55] = "Ge", NodeType[NodeType.Add = 56] = "Add", NodeType[NodeType.Sub = 57] = "Sub", NodeType[NodeType.Mul = 58] = "Mul", NodeType[NodeType.Div = 59] = "Div", NodeType[NodeType.Mod = 60] = "Mod", NodeType[NodeType.Lsh = 61] = "Lsh", NodeType[NodeType.Rsh = 62] = "Rsh", NodeType[NodeType.Rs2 = 63] = "Rs2", NodeType[NodeType.Not = 64] = "Not", NodeType[NodeType.LogNot = 65] = "LogNot", NodeType[NodeType.IncPre = 66] = "IncPre", NodeType[NodeType.DecPre = 67] = "DecPre", NodeType[NodeType.IncPost = 68] = "IncPost", NodeType[NodeType.DecPost = 69] = "DecPost", NodeType[NodeType.TypeAssertion = 70] = "TypeAssertion", NodeType[NodeType.FuncDecl = 71] = "FuncDecl", NodeType[NodeType.Member = 72] = "Member", NodeType[NodeType.VarDecl = 73] = "VarDecl", NodeType[NodeType.ArgDecl = 74] = "ArgDecl", NodeType[NodeType.Return = 75] = "Return", NodeType[NodeType.Break = 76] = "Break", NodeType[NodeType.Continue = 77] = "Continue", NodeType[NodeType.Throw = 78] = "Throw", NodeType[NodeType.For = 79] = "For", NodeType[NodeType.ForIn = 80] = "ForIn", NodeType[NodeType.If = 81] = "If", NodeType[NodeType.While = 82] = "While", NodeType[NodeType.DoWhile = 83] = "DoWhile", NodeType[NodeType.Block = 84] = "Block", NodeType[NodeType.Case = 85] = "Case", NodeType[NodeType.Switch = 86] = "Switch", NodeType[NodeType.Try = 87] = "Try", NodeType[NodeType.TryCatch = 88] = "TryCatch", NodeType[NodeType.TryFinally = 89] = "TryFinally", NodeType[NodeType.Finally = 90] = "Finally", NodeType[NodeType.Catch = 91] = "Catch", NodeType[NodeType.List = 92] = "List", NodeType[NodeType.Script = 93] = "Script", NodeType[NodeType.ClassDeclaration = 94] = "ClassDeclaration", NodeType[NodeType.InterfaceDeclaration = 95] = "InterfaceDeclaration", NodeType[NodeType.ModuleDeclaration = 96] = "ModuleDeclaration", NodeType[NodeType.ImportDeclaration = 97] = "ImportDeclaration", NodeType[NodeType.With = 98] = "With", NodeType[NodeType.Label = 99] = "Label", NodeType[NodeType.LabeledStatement = 100] = "LabeledStatement", NodeType[NodeType.EBStart = 101] = "EBStart", NodeType[NodeType.GotoEB = 102] = "GotoEB", NodeType[NodeType.EndCode = 103] = "EndCode", NodeType[NodeType.Error = 104] = "Error", NodeType[NodeType.Comment = 105] = "Comment", NodeType[NodeType.Debugger = 106] = "Debugger", NodeType[NodeType.GeneralNode = 71] = "GeneralNode", NodeType[NodeType.LastAsg = 41] = "LastAsg"; -}(TypeScript || (TypeScript = {})); +var TypeScript, TypeScript1, NodeType; +(NodeType = (TypeScript1 = TypeScript || (TypeScript = {})).NodeType || (TypeScript1.NodeType = {}))[NodeType.None = 0] = "None", NodeType[NodeType.Empty = 1] = "Empty", NodeType[NodeType.EmptyExpr = 2] = "EmptyExpr", NodeType[NodeType.True = 3] = "True", NodeType[NodeType.False = 4] = "False", NodeType[NodeType.This = 5] = "This", NodeType[NodeType.Super = 6] = "Super", NodeType[NodeType.QString = 7] = "QString", NodeType[NodeType.Regex = 8] = "Regex", NodeType[NodeType.Null = 9] = "Null", NodeType[NodeType.ArrayLit = 10] = "ArrayLit", NodeType[NodeType.ObjectLit = 11] = "ObjectLit", NodeType[NodeType.Void = 12] = "Void", NodeType[NodeType.Comma = 13] = "Comma", NodeType[NodeType.Pos = 14] = "Pos", NodeType[NodeType.Neg = 15] = "Neg", NodeType[NodeType.Delete = 16] = "Delete", NodeType[NodeType.Await = 17] = "Await", NodeType[NodeType.In = 18] = "In", NodeType[NodeType.Dot = 19] = "Dot", NodeType[NodeType.From = 20] = "From", NodeType[NodeType.Is = 21] = "Is", NodeType[NodeType.InstOf = 22] = "InstOf", NodeType[NodeType.Typeof = 23] = "Typeof", NodeType[NodeType.NumberLit = 24] = "NumberLit", NodeType[NodeType.Name = 25] = "Name", NodeType[NodeType.TypeRef = 26] = "TypeRef", NodeType[NodeType.Index = 27] = "Index", NodeType[NodeType.Call = 28] = "Call", NodeType[NodeType.New = 29] = "New", NodeType[NodeType.Asg = 30] = "Asg", NodeType[NodeType.AsgAdd = 31] = "AsgAdd", NodeType[NodeType.AsgSub = 32] = "AsgSub", NodeType[NodeType.AsgDiv = 33] = "AsgDiv", NodeType[NodeType.AsgMul = 34] = "AsgMul", NodeType[NodeType.AsgMod = 35] = "AsgMod", NodeType[NodeType.AsgAnd = 36] = "AsgAnd", NodeType[NodeType.AsgXor = 37] = "AsgXor", NodeType[NodeType.AsgOr = 38] = "AsgOr", NodeType[NodeType.AsgLsh = 39] = "AsgLsh", NodeType[NodeType.AsgRsh = 40] = "AsgRsh", NodeType[NodeType.AsgRs2 = 41] = "AsgRs2", NodeType[NodeType.ConditionalExpression = 42] = "ConditionalExpression", NodeType[NodeType.LogOr = 43] = "LogOr", NodeType[NodeType.LogAnd = 44] = "LogAnd", NodeType[NodeType.Or = 45] = "Or", NodeType[NodeType.Xor = 46] = "Xor", NodeType[NodeType.And = 47] = "And", NodeType[NodeType.Eq = 48] = "Eq", NodeType[NodeType.Ne = 49] = "Ne", NodeType[NodeType.Eqv = 50] = "Eqv", NodeType[NodeType.NEqv = 51] = "NEqv", NodeType[NodeType.Lt = 52] = "Lt", NodeType[NodeType.Le = 53] = "Le", NodeType[NodeType.Gt = 54] = "Gt", NodeType[NodeType.Ge = 55] = "Ge", NodeType[NodeType.Add = 56] = "Add", NodeType[NodeType.Sub = 57] = "Sub", NodeType[NodeType.Mul = 58] = "Mul", NodeType[NodeType.Div = 59] = "Div", NodeType[NodeType.Mod = 60] = "Mod", NodeType[NodeType.Lsh = 61] = "Lsh", NodeType[NodeType.Rsh = 62] = "Rsh", NodeType[NodeType.Rs2 = 63] = "Rs2", NodeType[NodeType.Not = 64] = "Not", NodeType[NodeType.LogNot = 65] = "LogNot", NodeType[NodeType.IncPre = 66] = "IncPre", NodeType[NodeType.DecPre = 67] = "DecPre", NodeType[NodeType.IncPost = 68] = "IncPost", NodeType[NodeType.DecPost = 69] = "DecPost", NodeType[NodeType.TypeAssertion = 70] = "TypeAssertion", NodeType[NodeType.FuncDecl = 71] = "FuncDecl", NodeType[NodeType.Member = 72] = "Member", NodeType[NodeType.VarDecl = 73] = "VarDecl", NodeType[NodeType.ArgDecl = 74] = "ArgDecl", NodeType[NodeType.Return = 75] = "Return", NodeType[NodeType.Break = 76] = "Break", NodeType[NodeType.Continue = 77] = "Continue", NodeType[NodeType.Throw = 78] = "Throw", NodeType[NodeType.For = 79] = "For", NodeType[NodeType.ForIn = 80] = "ForIn", NodeType[NodeType.If = 81] = "If", NodeType[NodeType.While = 82] = "While", NodeType[NodeType.DoWhile = 83] = "DoWhile", NodeType[NodeType.Block = 84] = "Block", NodeType[NodeType.Case = 85] = "Case", NodeType[NodeType.Switch = 86] = "Switch", NodeType[NodeType.Try = 87] = "Try", NodeType[NodeType.TryCatch = 88] = "TryCatch", NodeType[NodeType.TryFinally = 89] = "TryFinally", NodeType[NodeType.Finally = 90] = "Finally", NodeType[NodeType.Catch = 91] = "Catch", NodeType[NodeType.List = 92] = "List", NodeType[NodeType.Script = 93] = "Script", NodeType[NodeType.ClassDeclaration = 94] = "ClassDeclaration", NodeType[NodeType.InterfaceDeclaration = 95] = "InterfaceDeclaration", NodeType[NodeType.ModuleDeclaration = 96] = "ModuleDeclaration", NodeType[NodeType.ImportDeclaration = 97] = "ImportDeclaration", NodeType[NodeType.With = 98] = "With", NodeType[NodeType.Label = 99] = "Label", NodeType[NodeType.LabeledStatement = 100] = "LabeledStatement", NodeType[NodeType.EBStart = 101] = "EBStart", NodeType[NodeType.GotoEB = 102] = "GotoEB", NodeType[NodeType.EndCode = 103] = "EndCode", NodeType[NodeType.Error = 104] = "Error", NodeType[NodeType.Comment = 105] = "Comment", NodeType[NodeType.Debugger = 106] = "Debugger", NodeType[NodeType.GeneralNode = 71] = "GeneralNode", NodeType[NodeType.LastAsg = 41] = "LastAsg"; diff --git a/crates/swc/tests/tsc-references/parserRealSource5.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource5.2.minified.js index a7815f980a81..655956e253bf 100644 --- a/crates/swc/tests/tsc-references/parserRealSource5.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource5.2.minified.js @@ -1,35 +1,32 @@ //// [parserRealSource5.ts] -var TypeScript; +var TypeScript, TypeScript1, PrintContext; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(TypeScript) { - var PrintContext = function() { - function PrintContext(outfile, parser) { - _class_call_check(this, PrintContext), this.outfile = outfile, this.parser = parser, this.builder = "", this.indent1 = " ", this.indentStrings = [], this.indentAmt = 0; +TypeScript1 = TypeScript || (TypeScript = {}), PrintContext = function() { + function PrintContext(outfile, parser) { + _class_call_check(this, PrintContext), this.outfile = outfile, this.parser = parser, this.builder = "", this.indent1 = " ", this.indentStrings = [], this.indentAmt = 0; + } + var _proto = PrintContext.prototype; + return _proto.increaseIndent = function() { + this.indentAmt++; + }, _proto.decreaseIndent = function() { + this.indentAmt--; + }, _proto.startLine = function() { + this.builder.length > 0 && CompilerDiagnostics.Alert(this.builder); + var indentString = this.indentStrings[this.indentAmt]; + if (void 0 === indentString) { + indentString = ""; + for(var i = 0; i < this.indentAmt; i++)indentString += this.indent1; + this.indentStrings[this.indentAmt] = indentString; } - var _proto = PrintContext.prototype; - return _proto.increaseIndent = function() { - this.indentAmt++; - }, _proto.decreaseIndent = function() { - this.indentAmt--; - }, _proto.startLine = function() { - this.builder.length > 0 && CompilerDiagnostics.Alert(this.builder); - var indentString = this.indentStrings[this.indentAmt]; - if (void 0 === indentString) { - indentString = ""; - for(var i = 0; i < this.indentAmt; i++)indentString += this.indent1; - this.indentStrings[this.indentAmt] = indentString; - } - this.builder += indentString; - }, _proto.write = function(s) { - this.builder += s; - }, _proto.writeLine = function(s) { - this.builder += s, this.outfile.WriteLine(this.builder), this.builder = ""; - }, PrintContext; - }(); - TypeScript.PrintContext = PrintContext, TypeScript.prePrintAST = function(ast, parent, walker) { - var pc = walker.state; - return ast.print(pc), pc.increaseIndent(), ast; - }, TypeScript.postPrintAST = function(ast, parent, walker) { - return walker.state.decreaseIndent(), ast; - }; -}(TypeScript || (TypeScript = {})); + this.builder += indentString; + }, _proto.write = function(s) { + this.builder += s; + }, _proto.writeLine = function(s) { + this.builder += s, this.outfile.WriteLine(this.builder), this.builder = ""; + }, PrintContext; +}(), TypeScript1.PrintContext = PrintContext, TypeScript1.prePrintAST = function(ast, parent, walker) { + var pc = walker.state; + return ast.print(pc), pc.increaseIndent(), ast; +}, TypeScript1.postPrintAST = function(ast, parent, walker) { + return walker.state.decreaseIndent(), ast; +}; diff --git a/crates/swc/tests/tsc-references/parserRealSource6.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource6.2.minified.js index ceefa394990b..854a77670bf7 100644 --- a/crates/swc/tests/tsc-references/parserRealSource6.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource6.2.minified.js @@ -1,87 +1,82 @@ //// [parserRealSource6.ts] -var TypeScript; +var TypeScript, TypeScript1, preFindEnclosingScope, EnclosingScopeContext; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(TypeScript1) { - var preFindEnclosingScope = function(ast, parent, walker) { - var context = walker.state, minChar = ast.minChar, limChar = ast.limChar; - if (ast.nodeType == NodeType.Script && context.pos > limChar && (limChar = context.pos), minChar <= context.pos && limChar >= context.pos) { - switch(ast.nodeType){ - case NodeType.Script: - context.scopeGetter = function() { - return null === ast.bod ? null : ast.bod.enclosingScope; - }, context.scopeStartAST = ast; - break; - case NodeType.ClassDeclaration: - context.scopeGetter = function() { - return null === ast.type || null === ast.type.instanceType.containedScope ? null : ast.type.instanceType.containedScope; - }, context.scopeStartAST = ast, context.enclosingClassDecl = ast; - break; - case NodeType.ObjectLit: - ast.targetType && (context.scopeGetter = function() { - return ast.targetType.containedScope; - }, context.objectLiteralScopeGetter = function() { - return ast.targetType.memberScope; - }, context.enclosingObjectLit = ast); - break; - case NodeType.ModuleDeclaration: - context.deepestModuleDecl = ast, context.scopeGetter = function() { - return null === ast.type ? null : ast.type.containedScope; - }, context.scopeStartAST = ast; - break; - case NodeType.InterfaceDeclaration: - context.scopeGetter = function() { - return null === ast.type ? null : ast.type.containedScope; - }, context.scopeStartAST = ast; - break; - case NodeType.FuncDecl: - context.skipNextFuncDeclForClass ? context.skipNextFuncDeclForClass = !1 : (context.scopeGetter = function() { - return ast.isConstructor && hasFlag(ast.fncFlags, FncFlags.ClassMethod) && ast.type && ast.type.enclosingType ? ast.type.enclosingType.constructorScope : ast.scopeType ? ast.scopeType.containedScope : ast.type ? ast.type.containedScope : null; - }, context.scopeStartAST = ast); - } - walker.options.goChildren = !0; - } else walker.options.goChildren = !1; - return ast; - }; - TypeScript1.TypeCollectionContext = function TypeCollectionContext(scopeChain, checker) { - _class_call_check(this, TypeCollectionContext), this.scopeChain = scopeChain, this.checker = checker, this.script = null; - }, TypeScript1.MemberScopeContext = function MemberScopeContext(flow, pos, matchFlag) { - _class_call_check(this, MemberScopeContext), this.flow = flow, this.pos = pos, this.matchFlag = matchFlag, this.type = null, this.ast = null, this.options = new AstWalkOptions(); - }; - var EnclosingScopeContext = function() { - function EnclosingScopeContext(logger, script, text, pos, isMemberCompletion) { - _class_call_check(this, EnclosingScopeContext), this.logger = logger, this.script = script, this.text = text, this.pos = pos, this.isMemberCompletion = isMemberCompletion, this.scopeGetter = null, this.objectLiteralScopeGetter = null, this.scopeStartAST = null, this.skipNextFuncDeclForClass = !1, this.deepestModuleDecl = null, this.enclosingClassDecl = null, this.enclosingObjectLit = null, this.publicsOnly = !0, this.useFullAst = !1; +TypeScript1 = TypeScript || (TypeScript = {}), preFindEnclosingScope = function(ast, parent, walker) { + var context = walker.state, minChar = ast.minChar, limChar = ast.limChar; + if (ast.nodeType == NodeType.Script && context.pos > limChar && (limChar = context.pos), minChar <= context.pos && limChar >= context.pos) { + switch(ast.nodeType){ + case NodeType.Script: + context.scopeGetter = function() { + return null === ast.bod ? null : ast.bod.enclosingScope; + }, context.scopeStartAST = ast; + break; + case NodeType.ClassDeclaration: + context.scopeGetter = function() { + return null === ast.type || null === ast.type.instanceType.containedScope ? null : ast.type.instanceType.containedScope; + }, context.scopeStartAST = ast, context.enclosingClassDecl = ast; + break; + case NodeType.ObjectLit: + ast.targetType && (context.scopeGetter = function() { + return ast.targetType.containedScope; + }, context.objectLiteralScopeGetter = function() { + return ast.targetType.memberScope; + }, context.enclosingObjectLit = ast); + break; + case NodeType.ModuleDeclaration: + context.deepestModuleDecl = ast, context.scopeGetter = function() { + return null === ast.type ? null : ast.type.containedScope; + }, context.scopeStartAST = ast; + break; + case NodeType.InterfaceDeclaration: + context.scopeGetter = function() { + return null === ast.type ? null : ast.type.containedScope; + }, context.scopeStartAST = ast; + break; + case NodeType.FuncDecl: + context.skipNextFuncDeclForClass ? context.skipNextFuncDeclForClass = !1 : (context.scopeGetter = function() { + return ast.isConstructor && hasFlag(ast.fncFlags, FncFlags.ClassMethod) && ast.type && ast.type.enclosingType ? ast.type.enclosingType.constructorScope : ast.scopeType ? ast.scopeType.containedScope : ast.type ? ast.type.containedScope : null; + }, context.scopeStartAST = ast); } - var _proto = EnclosingScopeContext.prototype; - return _proto.getScope = function() { - return this.scopeGetter(); - }, _proto.getObjectLiteralScope = function() { - return this.objectLiteralScopeGetter(); - }, _proto.getScopeAST = function() { - return this.scopeStartAST; - }, _proto.getScopePosition = function() { - return this.scopeStartAST.minChar; - }, _proto.getScriptFragmentStartAST = function() { - return this.scopeStartAST; - }, _proto.getScriptFragmentPosition = function() { - return this.getScriptFragmentStartAST().minChar; - }, _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; - } - return this.scriptFragment; - }, EnclosingScopeContext; - }(); - TypeScript1.EnclosingScopeContext = EnclosingScopeContext, TypeScript1.preFindMemberScope = function(ast, parent, walker) { - var memScope = walker.state; - return hasFlag(ast.flags, memScope.matchFlag) && (memScope.pos < 0 || memScope.pos == ast.limChar) && (memScope.ast = ast, null == ast.type && memScope.pos >= 0 && memScope.flow.inScopeTypeCheck(ast, memScope.scope), memScope.type = ast.type, memScope.options.stopWalk()), ast; - }, TypeScript1.pushTypeCollectionScope = function(container, valueMembers, ambientValueMembers, enclosedTypes, ambientEnclosedTypes, context, thisType, classType, moduleDecl) { - var builder = new SymbolScopeBuilder(valueMembers, ambientValueMembers, enclosedTypes, ambientEnclosedTypes, null, container), chain = new ScopeChain(container, context.scopeChain, builder); - chain.thisType = thisType, chain.classType = classType, chain.moduleDecl = moduleDecl, context.scopeChain = chain; - }, TypeScript1.popTypeCollectionScope = function(context) { - 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; - }; -}(TypeScript || (TypeScript = {})); + walker.options.goChildren = !0; + } else walker.options.goChildren = !1; + return ast; +}, TypeScript1.TypeCollectionContext = function TypeCollectionContext(scopeChain, checker) { + _class_call_check(this, TypeCollectionContext), this.scopeChain = scopeChain, this.checker = checker, this.script = null; +}, TypeScript1.MemberScopeContext = function MemberScopeContext(flow, pos, matchFlag) { + _class_call_check(this, MemberScopeContext), this.flow = flow, this.pos = pos, this.matchFlag = matchFlag, this.type = null, this.ast = null, this.options = new AstWalkOptions(); +}, EnclosingScopeContext = function() { + function EnclosingScopeContext(logger, script, text, pos, isMemberCompletion) { + _class_call_check(this, EnclosingScopeContext), this.logger = logger, this.script = script, this.text = text, this.pos = pos, this.isMemberCompletion = isMemberCompletion, this.scopeGetter = null, this.objectLiteralScopeGetter = null, this.scopeStartAST = null, this.skipNextFuncDeclForClass = !1, this.deepestModuleDecl = null, this.enclosingClassDecl = null, this.enclosingObjectLit = null, this.publicsOnly = !0, this.useFullAst = !1; + } + var _proto = EnclosingScopeContext.prototype; + return _proto.getScope = function() { + return this.scopeGetter(); + }, _proto.getObjectLiteralScope = function() { + return this.objectLiteralScopeGetter(); + }, _proto.getScopeAST = function() { + return this.scopeStartAST; + }, _proto.getScopePosition = function() { + return this.scopeStartAST.minChar; + }, _proto.getScriptFragmentStartAST = function() { + return this.scopeStartAST; + }, _proto.getScriptFragmentPosition = function() { + return this.getScriptFragmentStartAST().minChar; + }, _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; + } + return this.scriptFragment; + }, EnclosingScopeContext; +}(), TypeScript1.EnclosingScopeContext = EnclosingScopeContext, TypeScript1.preFindMemberScope = function(ast, parent, walker) { + var memScope = walker.state; + return hasFlag(ast.flags, memScope.matchFlag) && (memScope.pos < 0 || memScope.pos == ast.limChar) && (memScope.ast = ast, null == ast.type && memScope.pos >= 0 && memScope.flow.inScopeTypeCheck(ast, memScope.scope), memScope.type = ast.type, memScope.options.stopWalk()), ast; +}, TypeScript1.pushTypeCollectionScope = function(container, valueMembers, ambientValueMembers, enclosedTypes, ambientEnclosedTypes, context, thisType, classType, moduleDecl) { + var builder = new SymbolScopeBuilder(valueMembers, ambientValueMembers, enclosedTypes, ambientEnclosedTypes, null, container), chain = new ScopeChain(container, context.scopeChain, builder); + chain.thisType = thisType, chain.classType = classType, chain.moduleDecl = moduleDecl, context.scopeChain = chain; +}, TypeScript1.popTypeCollectionScope = function(context) { + 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; +}; diff --git a/crates/swc/tests/tsc-references/parserRealSource8.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource8.2.minified.js index 9e7a10e6e802..24d165898714 100644 --- a/crates/swc/tests/tsc-references/parserRealSource8.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource8.2.minified.js @@ -1,97 +1,92 @@ //// [parserRealSource8.ts] -var TypeScript; +var TypeScript, TypeScript1, pushAssignScope, popAssignScope, instanceCompare, instanceFilterStop, preAssignModuleScopes, preAssignClassScopes, preAssignInterfaceScopes, preAssignWithScopes, preAssignFuncDeclScopes, preAssignCatchScopes, ScopeSearchFilter; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(TypeScript1) { - var pushAssignScope = function(scope, context, type, classType, fnc) { - var chain = new ScopeChain(null, context.scopeChain, scope); - chain.thisType = type, chain.classType = classType, chain.fnc = fnc, context.scopeChain = chain; - }, popAssignScope = function(context) { - context.scopeChain = context.scopeChain.previous; - }, instanceCompare = function(a, b) { - return null != a && a.isInstanceProperty() ? a : b; - }, instanceFilterStop = function(s) { - return s.isInstanceProperty(); - }, preAssignModuleScopes = function(ast, context) { - var memberScope = null, aggScope = null; - ast.name && ast.mod && (ast.name.sym = ast.mod.symbol); - var mod = ast.mod; - mod && (memberScope = new SymbolTableScope(mod.members, mod.ambientMembers, mod.enclosedTypes, mod.ambientEnclosedTypes, mod.symbol), mod.memberScope = memberScope, context.modDeclChain.push(ast), context.typeFlow.checker.currentModDecl = ast, (aggScope = new SymbolAggregateScope(mod.symbol)).addParentScope(memberScope), aggScope.addParentScope(context.scopeChain.scope), pushAssignScope(aggScope, context, null, null, null), mod.containedScope = aggScope, mod.symbol && context.typeFlow.addLocalsFromScope(mod.containedScope, mod.symbol, ast.vars, mod.members.privateMembers, !0)); - }, preAssignClassScopes = function(ast, context) { - var memberScope = null, aggScope = null; - ast.name && ast.type && (ast.name.sym = ast.type.symbol); - var classType = ast.type; - if (classType) { - classType.symbol, memberScope = context.typeFlow.checker.scopeOf(classType), (aggScope = new SymbolAggregateScope(classType.symbol)).addParentScope(memberScope), aggScope.addParentScope(context.scopeChain.scope), classType.containedScope = aggScope, classType.memberScope = memberScope; - var instanceType = classType.instanceType; - memberScope = context.typeFlow.checker.scopeOf(instanceType), instanceType.memberScope = memberScope, (aggScope = new SymbolAggregateScope(instanceType.symbol)).addParentScope(context.scopeChain.scope), pushAssignScope(aggScope, context, instanceType, classType, null), instanceType.containedScope = aggScope; - } else ast.type = context.typeFlow.anyType; - }, preAssignInterfaceScopes = function(ast, context) { - var memberScope = null, aggScope = null; - ast.name && ast.type && (ast.name.sym = ast.type.symbol); - var interfaceType = ast.type; - memberScope = context.typeFlow.checker.scopeOf(interfaceType), interfaceType.memberScope = memberScope, (aggScope = new SymbolAggregateScope(interfaceType.symbol)).addParentScope(memberScope), aggScope.addParentScope(context.scopeChain.scope), pushAssignScope(aggScope, context, null, null, null), interfaceType.containedScope = aggScope; - }, 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); - pushAssignScope(withScope, context, null, null, null), withType.containedScope = withScope; - }, preAssignFuncDeclScopes = function(ast, context) { - var container = null, localContainer = null; - ast.type && (localContainer = ast.type.symbol); - var isStatic = hasFlag(ast.fncFlags, FncFlags.Static), parentScope = isStatic && null != context.scopeChain.fnc ? context.scopeChain.fnc.type.memberScope : context.scopeChain.scope; - if (context.scopeChain.thisType && (!ast.isConstructor || hasFlag(ast.fncFlags, FncFlags.ClassMethod))) { - var instType = context.scopeChain.thisType; - parentScope = instType.typeFlags & TypeFlags.IsClass || hasFlag(ast.fncFlags, FncFlags.ClassMethod) ? context.scopeChain.previous.scope.container && context.scopeChain.previous.scope.container.declAST && context.scopeChain.previous.scope.container.declAST.nodeType == NodeType.FuncDecl && context.scopeChain.previous.scope.container.declAST.isConstructor ? instType.constructorScope : isStatic && context.scopeChain.classType ? context.scopeChain.classType.containedScope : instType.containedScope : !ast.isMethod() || isStatic ? instType.constructorScope : instType.containedScope, container = instType.symbol; - } else ast.isConstructor && context.scopeChain.thisType && (container = context.scopeChain.thisType.symbol); - if (null == ast.type || hasFlag(ast.type.symbol.flags, SymbolFlags.TypeSetDuringScopeAssignment)) { - context.scopeChain.fnc && context.scopeChain.fnc.type && (container = context.scopeChain.fnc.type.symbol); - var funcScope = null, outerFnc = context.scopeChain.fnc, nameText = ast.name ? ast.name.actualText : null, fgSym = null; - isStatic ? (null == outerFnc.type.members && container.getType().memberScope && (outerFnc.type.members = container.type.memberScope.valueMembers), funcScope = context.scopeChain.fnc.type.memberScope, outerFnc.innerStaticFuncs[outerFnc.innerStaticFuncs.length] = ast) : funcScope = !ast.isConstructor && container && container.declAST && container.declAST.nodeType == NodeType.FuncDecl && container.declAST.isConstructor && !ast.isMethod() ? context.scopeChain.thisType.constructorScope : context.scopeChain.scope, nameText && "__missing" != nameText && !ast.isAccessor() && (fgSym = funcScope.findLocal(nameText, !1, !1)), context.typeFlow.checker.createFunctionSignature(ast, container, funcScope, fgSym, null == fgSym), (!ast.accessorSymbol && ast.fncFlags & FncFlags.ClassMethod && container && (!fgSym || fgSym.declAST.nodeType != NodeType.FuncDecl) && ast.isAccessor() || fgSym && fgSym.isAccessor()) && (ast.accessorSymbol = context.typeFlow.checker.createAccessorSymbol(ast, fgSym, container.getType(), ast.isMethod() && isStatic, !0, funcScope, container)), ast.type.symbol.flags |= SymbolFlags.TypeSetDuringScopeAssignment; - } - if (ast.name && ast.type && (ast.name.sym = ast.type.symbol), ast.scopeType = ast.type, !ast.isOverload) { - var funcTable = new StringHashTable(), funcMembers = new ScopedMembers(new DualStringHashTable(funcTable, new StringHashTable())), ambientFuncTable = new StringHashTable(), ambientFuncMembers = new ScopedMembers(new DualStringHashTable(ambientFuncTable, new StringHashTable())), funcStaticTable = new StringHashTable(), funcStaticMembers = new ScopedMembers(new DualStringHashTable(funcStaticTable, new StringHashTable())), ambientFuncStaticTable = new StringHashTable(), ambientFuncStaticMembers = new ScopedMembers(new DualStringHashTable(ambientFuncStaticTable, new StringHashTable())); - ast.unitIndex = context.typeFlow.checker.locationInfo.unitIndex; - var locals = new SymbolScopeBuilder(funcMembers, ambientFuncMembers, null, null, parentScope, localContainer), statics = new SymbolScopeBuilder(funcStaticMembers, ambientFuncStaticMembers, null, null, parentScope, null); - if (ast.isConstructor && context.scopeChain.thisType && (context.scopeChain.thisType.constructorScope = locals), ast.symbols = funcTable, !ast.isSpecialFn()) { - var group = ast.type, signature = ast.signature; - ast.isConstructor || (group.containedScope = locals, locals.container = group.symbol, group.memberScope = statics, statics.container = group.symbol), ast.enclosingFnc = context.scopeChain.fnc, group.enclosingType = isStatic ? context.scopeChain.classType : context.scopeChain.thisType; - var fgSym = ast.type.symbol; - if ((ast.fncFlags & FncFlags.Signature) == FncFlags.None && ast.vars && (context.typeFlow.addLocalsFromScope(locals, fgSym, ast.vars, funcTable, !1), context.typeFlow.addLocalsFromScope(statics, fgSym, ast.statics, funcStaticTable, !1)), signature.parameters) for(var len = signature.parameters.length, i = 0; i < len; i++){ - var paramSym = signature.parameters[i]; - context.typeFlow.checker.resolveTypeLink(locals, paramSym.parameter.typeLink, !0); - } - context.typeFlow.checker.resolveTypeLink(locals, signature.returnType, ast.isSignature()); - } - if (!ast.isConstructor || hasFlag(ast.fncFlags, FncFlags.ClassMethod)) { - var thisType = ast.isConstructor && hasFlag(ast.fncFlags, FncFlags.ClassMethod) ? context.scopeChain.thisType : null; - pushAssignScope(locals, context, thisType, null, ast); +TypeScript1 = TypeScript || (TypeScript = {}), pushAssignScope = function(scope, context, type, classType, fnc) { + var chain = new ScopeChain(null, context.scopeChain, scope); + chain.thisType = type, chain.classType = classType, chain.fnc = fnc, context.scopeChain = chain; +}, popAssignScope = function(context) { + context.scopeChain = context.scopeChain.previous; +}, instanceCompare = function(a, b) { + return null != a && a.isInstanceProperty() ? a : b; +}, instanceFilterStop = function(s) { + return s.isInstanceProperty(); +}, preAssignModuleScopes = function(ast, context) { + var memberScope = null, aggScope = null; + ast.name && ast.mod && (ast.name.sym = ast.mod.symbol); + var mod = ast.mod; + mod && (memberScope = new SymbolTableScope(mod.members, mod.ambientMembers, mod.enclosedTypes, mod.ambientEnclosedTypes, mod.symbol), mod.memberScope = memberScope, context.modDeclChain.push(ast), context.typeFlow.checker.currentModDecl = ast, (aggScope = new SymbolAggregateScope(mod.symbol)).addParentScope(memberScope), aggScope.addParentScope(context.scopeChain.scope), pushAssignScope(aggScope, context, null, null, null), mod.containedScope = aggScope, mod.symbol && context.typeFlow.addLocalsFromScope(mod.containedScope, mod.symbol, ast.vars, mod.members.privateMembers, !0)); +}, preAssignClassScopes = function(ast, context) { + var memberScope = null, aggScope = null; + ast.name && ast.type && (ast.name.sym = ast.type.symbol); + var classType = ast.type; + if (classType) { + classType.symbol, memberScope = context.typeFlow.checker.scopeOf(classType), (aggScope = new SymbolAggregateScope(classType.symbol)).addParentScope(memberScope), aggScope.addParentScope(context.scopeChain.scope), classType.containedScope = aggScope, classType.memberScope = memberScope; + var instanceType = classType.instanceType; + memberScope = context.typeFlow.checker.scopeOf(instanceType), instanceType.memberScope = memberScope, (aggScope = new SymbolAggregateScope(instanceType.symbol)).addParentScope(context.scopeChain.scope), pushAssignScope(aggScope, context, instanceType, classType, null), instanceType.containedScope = aggScope; + } else ast.type = context.typeFlow.anyType; +}, preAssignInterfaceScopes = function(ast, context) { + var memberScope = null, aggScope = null; + ast.name && ast.type && (ast.name.sym = ast.type.symbol); + var interfaceType = ast.type; + memberScope = context.typeFlow.checker.scopeOf(interfaceType), interfaceType.memberScope = memberScope, (aggScope = new SymbolAggregateScope(interfaceType.symbol)).addParentScope(memberScope), aggScope.addParentScope(context.scopeChain.scope), pushAssignScope(aggScope, context, null, null, null), interfaceType.containedScope = aggScope; +}, 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); + pushAssignScope(withScope, context, null, null, null), withType.containedScope = withScope; +}, preAssignFuncDeclScopes = function(ast, context) { + var container = null, localContainer = null; + ast.type && (localContainer = ast.type.symbol); + var isStatic = hasFlag(ast.fncFlags, FncFlags.Static), parentScope = isStatic && null != context.scopeChain.fnc ? context.scopeChain.fnc.type.memberScope : context.scopeChain.scope; + if (context.scopeChain.thisType && (!ast.isConstructor || hasFlag(ast.fncFlags, FncFlags.ClassMethod))) { + var instType = context.scopeChain.thisType; + parentScope = instType.typeFlags & TypeFlags.IsClass || hasFlag(ast.fncFlags, FncFlags.ClassMethod) ? context.scopeChain.previous.scope.container && context.scopeChain.previous.scope.container.declAST && context.scopeChain.previous.scope.container.declAST.nodeType == NodeType.FuncDecl && context.scopeChain.previous.scope.container.declAST.isConstructor ? instType.constructorScope : isStatic && context.scopeChain.classType ? context.scopeChain.classType.containedScope : instType.containedScope : !ast.isMethod() || isStatic ? instType.constructorScope : instType.containedScope, container = instType.symbol; + } else ast.isConstructor && context.scopeChain.thisType && (container = context.scopeChain.thisType.symbol); + if (null == ast.type || hasFlag(ast.type.symbol.flags, SymbolFlags.TypeSetDuringScopeAssignment)) { + context.scopeChain.fnc && context.scopeChain.fnc.type && (container = context.scopeChain.fnc.type.symbol); + var funcScope = null, outerFnc = context.scopeChain.fnc, nameText = ast.name ? ast.name.actualText : null, fgSym = null; + isStatic ? (null == outerFnc.type.members && container.getType().memberScope && (outerFnc.type.members = container.type.memberScope.valueMembers), funcScope = context.scopeChain.fnc.type.memberScope, outerFnc.innerStaticFuncs[outerFnc.innerStaticFuncs.length] = ast) : funcScope = !ast.isConstructor && container && container.declAST && container.declAST.nodeType == NodeType.FuncDecl && container.declAST.isConstructor && !ast.isMethod() ? context.scopeChain.thisType.constructorScope : context.scopeChain.scope, nameText && "__missing" != nameText && !ast.isAccessor() && (fgSym = funcScope.findLocal(nameText, !1, !1)), context.typeFlow.checker.createFunctionSignature(ast, container, funcScope, fgSym, null == fgSym), (!ast.accessorSymbol && ast.fncFlags & FncFlags.ClassMethod && container && (!fgSym || fgSym.declAST.nodeType != NodeType.FuncDecl) && ast.isAccessor() || fgSym && fgSym.isAccessor()) && (ast.accessorSymbol = context.typeFlow.checker.createAccessorSymbol(ast, fgSym, container.getType(), ast.isMethod() && isStatic, !0, funcScope, container)), ast.type.symbol.flags |= SymbolFlags.TypeSetDuringScopeAssignment; + } + if (ast.name && ast.type && (ast.name.sym = ast.type.symbol), ast.scopeType = ast.type, !ast.isOverload) { + var funcTable = new StringHashTable(), funcMembers = new ScopedMembers(new DualStringHashTable(funcTable, new StringHashTable())), ambientFuncTable = new StringHashTable(), ambientFuncMembers = new ScopedMembers(new DualStringHashTable(ambientFuncTable, new StringHashTable())), funcStaticTable = new StringHashTable(), funcStaticMembers = new ScopedMembers(new DualStringHashTable(funcStaticTable, new StringHashTable())), ambientFuncStaticTable = new StringHashTable(), ambientFuncStaticMembers = new ScopedMembers(new DualStringHashTable(ambientFuncStaticTable, new StringHashTable())); + ast.unitIndex = context.typeFlow.checker.locationInfo.unitIndex; + var locals = new SymbolScopeBuilder(funcMembers, ambientFuncMembers, null, null, parentScope, localContainer), statics = new SymbolScopeBuilder(funcStaticMembers, ambientFuncStaticMembers, null, null, parentScope, null); + if (ast.isConstructor && context.scopeChain.thisType && (context.scopeChain.thisType.constructorScope = locals), ast.symbols = funcTable, !ast.isSpecialFn()) { + var group = ast.type, signature = ast.signature; + ast.isConstructor || (group.containedScope = locals, locals.container = group.symbol, group.memberScope = statics, statics.container = group.symbol), ast.enclosingFnc = context.scopeChain.fnc, group.enclosingType = isStatic ? context.scopeChain.classType : context.scopeChain.thisType; + var fgSym = ast.type.symbol; + if ((ast.fncFlags & FncFlags.Signature) == FncFlags.None && ast.vars && (context.typeFlow.addLocalsFromScope(locals, fgSym, ast.vars, funcTable, !1), context.typeFlow.addLocalsFromScope(statics, fgSym, ast.statics, funcStaticTable, !1)), signature.parameters) for(var len = signature.parameters.length, i = 0; i < len; i++){ + var paramSym = signature.parameters[i]; + context.typeFlow.checker.resolveTypeLink(locals, paramSym.parameter.typeLink, !0); } + context.typeFlow.checker.resolveTypeLink(locals, signature.returnType, ast.isSignature()); } - }, preAssignCatchScopes = function(ast, context) { - if (ast.param) { - var catchTable = new ScopedMembers(new DualStringHashTable(new StringHashTable(), new StringHashTable())), catchLocals = new SymbolScopeBuilder(catchTable, null, null, null, context.scopeChain.scope, context.scopeChain.scope.container); - ast.containedScope = catchLocals, pushAssignScope(catchLocals, context, context.scopeChain.thisType, context.scopeChain.classType, context.scopeChain.fnc); - } - }; - TypeScript1.AssignScopeContext = function AssignScopeContext(scopeChain, typeFlow, modDeclChain) { - _class_call_check(this, AssignScopeContext), this.scopeChain = scopeChain, this.typeFlow = typeFlow, this.modDeclChain = modDeclChain; - }, TypeScript1.pushAssignScope = pushAssignScope, TypeScript1.popAssignScope = popAssignScope, TypeScript1.instanceCompare = instanceCompare, TypeScript1.instanceFilterStop = instanceFilterStop; - var ScopeSearchFilter = function() { - function ScopeSearchFilter(select, stop) { - _class_call_check(this, ScopeSearchFilter), this.select = select, this.stop = stop, this.result = null; + if (!ast.isConstructor || hasFlag(ast.fncFlags, FncFlags.ClassMethod)) { + var thisType = ast.isConstructor && hasFlag(ast.fncFlags, FncFlags.ClassMethod) ? context.scopeChain.thisType : null; + pushAssignScope(locals, context, thisType, null, ast); } - var _proto = ScopeSearchFilter.prototype; - return _proto.reset = function() { - this.result = null; - }, _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) { - 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) { - var context = walker.state, go = !0; - return ast && (ast.nodeType == NodeType.ModuleDeclaration ? (popAssignScope(context), context.modDeclChain.pop(), context.modDeclChain.length >= 1 && (context.typeFlow.checker.currentModDecl = context.modDeclChain[context.modDeclChain.length - 1])) : ast.nodeType == NodeType.ClassDeclaration ? popAssignScope(context) : ast.nodeType == NodeType.InterfaceDeclaration ? popAssignScope(context) : ast.nodeType == NodeType.With ? popAssignScope(context) : ast.nodeType == NodeType.FuncDecl ? (!ast.isConstructor || hasFlag(ast.fncFlags, FncFlags.ClassMethod)) && !ast.isOverload && popAssignScope(context) : ast.nodeType == NodeType.Catch ? ast.param && popAssignScope(context) : go = !1), walker.options.goChildren = go, ast; - }; -}(TypeScript || (TypeScript = {})); + } +}, preAssignCatchScopes = function(ast, context) { + if (ast.param) { + var catchTable = new ScopedMembers(new DualStringHashTable(new StringHashTable(), new StringHashTable())), catchLocals = new SymbolScopeBuilder(catchTable, null, null, null, context.scopeChain.scope, context.scopeChain.scope.container); + ast.containedScope = catchLocals, pushAssignScope(catchLocals, context, context.scopeChain.thisType, context.scopeChain.classType, context.scopeChain.fnc); + } +}, TypeScript1.AssignScopeContext = function AssignScopeContext(scopeChain, typeFlow, modDeclChain) { + _class_call_check(this, AssignScopeContext), this.scopeChain = scopeChain, this.typeFlow = typeFlow, this.modDeclChain = modDeclChain; +}, TypeScript1.pushAssignScope = pushAssignScope, TypeScript1.popAssignScope = popAssignScope, TypeScript1.instanceCompare = instanceCompare, TypeScript1.instanceFilterStop = instanceFilterStop, ScopeSearchFilter = function() { + function ScopeSearchFilter(select, stop) { + _class_call_check(this, ScopeSearchFilter), this.select = select, this.stop = stop, this.result = null; + } + var _proto = ScopeSearchFilter.prototype; + return _proto.reset = function() { + this.result = null; + }, _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) { + 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) { + var context = walker.state, go = !0; + return ast && (ast.nodeType == NodeType.ModuleDeclaration ? (popAssignScope(context), context.modDeclChain.pop(), context.modDeclChain.length >= 1 && (context.typeFlow.checker.currentModDecl = context.modDeclChain[context.modDeclChain.length - 1])) : ast.nodeType == NodeType.ClassDeclaration ? popAssignScope(context) : ast.nodeType == NodeType.InterfaceDeclaration ? popAssignScope(context) : ast.nodeType == NodeType.With ? popAssignScope(context) : ast.nodeType == NodeType.FuncDecl ? (!ast.isConstructor || hasFlag(ast.fncFlags, FncFlags.ClassMethod)) && !ast.isOverload && popAssignScope(context) : ast.nodeType == NodeType.Catch ? ast.param && popAssignScope(context) : go = !1), walker.options.goChildren = go, ast; +}; diff --git a/crates/swc/tests/tsc-references/parserindenter.2.minified.js b/crates/swc/tests/tsc-references/parserindenter.2.minified.js index 5f703538cad4..5d2ecb4b74a6 100644 --- a/crates/swc/tests/tsc-references/parserindenter.2.minified.js +++ b/crates/swc/tests/tsc-references/parserindenter.2.minified.js @@ -1,241 +1,238 @@ //// [parserindenter.ts] -var Formatting; +var Formatting, Formatting1, Indenter; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(Formatting) { - var Indenter = function() { - function Indenter(logger, tree, snapshot, languageHostIndentation, editorOptions, firstToken, smartIndent) { - _class_call_check(this, Indenter), this.logger = logger, this.tree = tree, this.snapshot = snapshot, this.languageHostIndentation = languageHostIndentation, this.editorOptions = editorOptions, this.firstToken = firstToken, this.smartIndent = smartIndent, this.indentationBag = new IndentationBag(this.snapshot), this.scriptBlockBeginLineNumber = -1, this.offsetIndentationDeltas = new Dictionary_int_int(), this.tree.Root.SetIndentationOverride(""), this.ApplyScriptBlockIndentation(this.languageHostIndentation, this.tree), this.FillInheritedIndentation(this.tree); - } - var _proto = Indenter.prototype; - return _proto.GetIndentationEdits = function(token, nextToken, node, sameLineIndent) { - this.logger.information() && this.logger.log("GetIndentationEdits(t1=[" + token.Span.startPosition() + "," + token.Span.endPosition() + "], t2=[" + (null == nextToken ? "null" : nextToken.Span.startPosition() + "," + nextToken.Span.endPosition()) + "])"); - var result = this.GetIndentationEditsWorker(token, nextToken, node, sameLineIndent); - if (this.logger.information()) for(var i = 0; i < result.count(); i++){ - var edit = result.get(i); - this.logger.log("edit: minChar=" + edit.position + ", limChar=" + (edit.position + edit.length) + ', text="' + TypeScript.stringToLiteral(edit.replaceWith, 30) + '"'); - } - return result; - }, _proto.GetIndentationEditsWorker = function(token, nextToken, node, sameLineIndent) { - var result = new List_TextEditInfo(), indentationInfo = null; - if (this.AdjustStartOffsetIfNeeded(token, node), this.scriptBlockBeginLineNumber == token.lineNumber() || !sameLineIndent && this.IsMultiLineString(token)) return result; - if (null == (indentationInfo = this.GetSpecialCaseIndentation(token, node))) { - for(; !node.CanIndent() && null != node.Parent && token.Span.span.start() == node.Parent.AuthorNode.Details.StartOffset;)node = node.Parent; - indentationInfo = node.CanIndent() && token.Span.span.start() == node.AuthorNode.Details.StartOffset ? node.GetEffectiveIndentation(this) : token.Token == AuthorTokenKind.atkIdentifier && null != nextToken && nextToken.Token == AuthorTokenKind.atkColon ? node.GetEffectiveChildrenIndentation(this) : this.ApplyIndentationDeltaFromParent(token, node); +Formatting1 = Formatting || (Formatting = {}), Indenter = function() { + function Indenter(logger, tree, snapshot, languageHostIndentation, editorOptions, firstToken, smartIndent) { + _class_call_check(this, Indenter), this.logger = logger, this.tree = tree, this.snapshot = snapshot, this.languageHostIndentation = languageHostIndentation, this.editorOptions = editorOptions, this.firstToken = firstToken, this.smartIndent = smartIndent, this.indentationBag = new IndentationBag(this.snapshot), this.scriptBlockBeginLineNumber = -1, this.offsetIndentationDeltas = new Dictionary_int_int(), this.tree.Root.SetIndentationOverride(""), this.ApplyScriptBlockIndentation(this.languageHostIndentation, this.tree), this.FillInheritedIndentation(this.tree); + } + var _proto = Indenter.prototype; + return _proto.GetIndentationEdits = function(token, nextToken, node, sameLineIndent) { + this.logger.information() && this.logger.log("GetIndentationEdits(t1=[" + token.Span.startPosition() + "," + token.Span.endPosition() + "], t2=[" + (null == nextToken ? "null" : nextToken.Span.startPosition() + "," + nextToken.Span.endPosition()) + "])"); + var result = this.GetIndentationEditsWorker(token, nextToken, node, sameLineIndent); + if (this.logger.information()) for(var i = 0; i < result.count(); i++){ + var edit = result.get(i); + this.logger.log("edit: minChar=" + edit.position + ", limChar=" + (edit.position + edit.length) + ', text="' + TypeScript.stringToLiteral(edit.replaceWith, 30) + '"'); + } + return result; + }, _proto.GetIndentationEditsWorker = function(token, nextToken, node, sameLineIndent) { + var result = new List_TextEditInfo(), indentationInfo = null; + if (this.AdjustStartOffsetIfNeeded(token, node), this.scriptBlockBeginLineNumber == token.lineNumber() || !sameLineIndent && this.IsMultiLineString(token)) return result; + if (null == (indentationInfo = this.GetSpecialCaseIndentation(token, node))) { + for(; !node.CanIndent() && null != node.Parent && token.Span.span.start() == node.Parent.AuthorNode.Details.StartOffset;)node = node.Parent; + indentationInfo = node.CanIndent() && token.Span.span.start() == node.AuthorNode.Details.StartOffset ? node.GetEffectiveIndentation(this) : token.Token == AuthorTokenKind.atkIdentifier && null != nextToken && nextToken.Token == AuthorTokenKind.atkColon ? node.GetEffectiveChildrenIndentation(this) : this.ApplyIndentationDeltaFromParent(token, node); + } + if (null != indentationInfo) { + var edit = this.GetIndentEdit(indentationInfo, token.Span.startPosition(), sameLineIndent); + null != edit && (this.RegisterIndentation(edit, sameLineIndent), result.add(edit), token.Token == AuthorTokenKind.atkComment && this.GetCommentIndentationEdits(token).foreach(function(item) { + result.add(item); + })); + } + return result; + }, _proto.GetCommentIndentationEdits = function(token) { + var result = new List_TextEditInfo(); + if (token.Token != AuthorTokenKind.atkComment) return result; + var commentLastLineNumber = this.snapshot.GetLineNumberFromPosition(token.Span.endPosition()); + if (token.lineNumber() == commentLastLineNumber) return result; + var commentFirstLineIndentationDelta = this.GetIndentationDelta(token.Span.startPosition(), null); + if (void 0 != commentFirstLineIndentationDelta) for(var line = token.lineNumber() + 1; line <= commentLastLineNumber; line++){ + var lineStartPosition = this.snapshot.GetLineFromLineNumber(line).startPosition(), lineIndent = this.GetLineIndentationForOffset(lineStartPosition), commentIndentationInfo = this.ApplyIndentationDelta2(lineIndent, commentFirstLineIndentationDelta); + if (null != commentIndentationInfo) { + var tokenStartPosition = lineStartPosition + lineIndent.length, commentIndentationEdit = this.GetIndentEdit(commentIndentationInfo, tokenStartPosition, !1); + null != commentIndentationEdit && result.add(commentIndentationEdit); } - if (null != indentationInfo) { - var edit = this.GetIndentEdit(indentationInfo, token.Span.startPosition(), sameLineIndent); - null != edit && (this.RegisterIndentation(edit, sameLineIndent), result.add(edit), token.Token == AuthorTokenKind.atkComment && this.GetCommentIndentationEdits(token).foreach(function(item) { - result.add(item); - })); + } + return result; + }, _proto.GetSpecialCaseIndentation = function(token, node) { + var indentationInfo = null; + switch(token.Token){ + case AuthorTokenKind.atkLCurly: + return this.GetSpecialCaseIndentationForLCurly(node); + case AuthorTokenKind.atkElse: + case AuthorTokenKind.atkRBrack: + return node.GetNodeStartLineIndentation(this); + case AuthorTokenKind.atkRCurly: + return node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkBlock && node.AuthorNode.EdgeLabel == AuthorParseNodeEdge.apneBody && (node = node.Parent), indentationInfo = node.GetNodeStartLineIndentation(this); + case AuthorTokenKind.atkWhile: + if (node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkDoWhile) return node.GetNodeStartLineIndentation(this); + return null; + case AuthorTokenKind.atkSColon: + return this.GetSpecialCaseIndentationForSemicolon(token, node); + case AuthorTokenKind.atkComment: + return this.GetSpecialCaseIndentationForComment(token, node); + default: + return indentationInfo; + } + }, _proto.GetSpecialCaseIndentationForLCurly = function(node) { + return node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkFncDecl || node.AuthorNode.EdgeLabel == AuthorParseNodeEdge.apneThen || node.AuthorNode.EdgeLabel == AuthorParseNodeEdge.apneElse ? node.GetNodeStartLineIndentation(this) : node.AuthorNode.Details.Kind != AuthorParseNodeKind.apnkObject || node.CanIndent() ? node.GetEffectiveIndentation(this) : null; + }, _proto.GetSpecialCaseIndentationForSemicolon = function(token, node) { + if (this.smartIndent) return node.GetEffectiveChildrenIndentation(this); + if (node.AuthorNode.Details.Kind != AuthorParseNodeKind.apnkFor) { + var semiColonStartSpan = new Span(token.Span.startPosition(), 0); + return (node = ParseTree.FindCommonParentNode(semiColonStartSpan, semiColonStartSpan, node)).GetEffectiveChildrenIndentation(this); + } + return null; + }, _proto.GetSpecialCaseIndentationForComment = function(token, node) { + var indentationInfo = null, twoCharSpan = token.Span.Intersection(new Span(token.Span.startPosition(), 2)); + if (null != twoCharSpan && ("//" == twoCharSpan.GetText() || "/*" == twoCharSpan.GetText())) { + for(; null == node.ChildrenIndentationDelta && null != node.Parent;)node = node.Parent; + indentationInfo = this.CanIndentComment(token, node) ? node.GetEffectiveChildrenIndentationForComment(this) : this.ApplyIndentationDeltaFromParent(token, node); + } + return indentationInfo; + }, _proto.CanIndentComment = function(token, node) { + switch(node.AuthorNode.Details.Kind){ + case AuthorParseNodeKind.apnkProg: + case AuthorParseNodeKind.apnkBlock: + case AuthorParseNodeKind.apnkSwitch: + case AuthorParseNodeKind.apnkCase: + case AuthorParseNodeKind.apnkDefaultCase: + case AuthorParseNodeKind.apnkIf: + case AuthorParseNodeKind.apnkFor: + case AuthorParseNodeKind.apnkForIn: + case AuthorParseNodeKind.apnkWhile: + case AuthorParseNodeKind.apnkWith: + case AuthorParseNodeKind.apnkDoWhile: + case AuthorParseNodeKind.apnkObject: + return !0; + case AuthorParseNodeKind.apnkFncDecl: + var result = !0; + return ParseNodeExtensions.FindChildrenWithEdge(node, AuthorParseNodeEdge.apneArgument).foreach(function(argumentNode) { + token.Span.startPosition() < argumentNode.AuthorNode.Details.StartOffset && (result = !1); + }), result; + } + return !1; + }, _proto.ApplyScriptBlockIndentation = function(languageHostIndentation, tree) { + if (null != languageHostIndentation && null != tree.StartNodeSelf) { + var scriptBlockIndentation = this.ApplyIndentationLevel(languageHostIndentation, 1); + tree.Root.SetIndentationOverride(scriptBlockIndentation); + } + }, _proto.GetIndentEdit = function(indentInfo, tokenStartPosition, sameLineIndent) { + var indentText = this.ApplyIndentationLevel(indentInfo.Prefix, indentInfo.Level); + if (sameLineIndent) return new TextEditInfo(tokenStartPosition, 0, indentText); + var snapshotLine = this.snapshot.GetLineFromPosition(tokenStartPosition), currentIndentSpan = new Span(snapshotLine.startPosition(), tokenStartPosition - snapshotLine.startPosition()), currentIndentText = this.snapshot.GetText(currentIndentSpan); + if (currentIndentText !== indentText) { + if (this.logger.debug()) for(var i = 0, len = currentIndentText.length; i < len; i++){ + var c = currentIndentText.charCodeAt(i); + if (!StringUtils.IsWhiteSpace(c)) { + Debug.Fail("Formatting error: Will remove user code when indenting the line: " + snapshotLine.getText()); + break; + } } - return result; - }, _proto.GetCommentIndentationEdits = function(token) { - var result = new List_TextEditInfo(); - if (token.Token != AuthorTokenKind.atkComment) return result; - var commentLastLineNumber = this.snapshot.GetLineNumberFromPosition(token.Span.endPosition()); - if (token.lineNumber() == commentLastLineNumber) return result; - var commentFirstLineIndentationDelta = this.GetIndentationDelta(token.Span.startPosition(), null); - if (void 0 != commentFirstLineIndentationDelta) for(var line = token.lineNumber() + 1; line <= commentLastLineNumber; line++){ - var lineStartPosition = this.snapshot.GetLineFromLineNumber(line).startPosition(), lineIndent = this.GetLineIndentationForOffset(lineStartPosition), commentIndentationInfo = this.ApplyIndentationDelta2(lineIndent, commentFirstLineIndentationDelta); - if (null != commentIndentationInfo) { - var tokenStartPosition = lineStartPosition + lineIndent.length, commentIndentationEdit = this.GetIndentEdit(commentIndentationInfo, tokenStartPosition, !1); - null != commentIndentationEdit && result.add(commentIndentationEdit); + return new TextEditInfo(currentIndentSpan.start(), currentIndentSpan.length(), indentText); + } + return null; + }, _proto.ApplyIndentationLevel = function(existingIndentation, level) { + var indentSize = this.editorOptions.IndentSize, tabSize = this.editorOptions.TabSize, convertTabsToSpaces = this.editorOptions.ConvertTabsToSpaces; + if (level < 0) { + if (StringUtils.IsNullOrEmpty(existingIndentation)) return ""; + var totalIndent = 0; + return (StringUtils.foreach(existingIndentation, function(c) { + " " == c ? totalIndent += tabSize : totalIndent++; + }), (totalIndent += level * indentSize) < 0) ? "" : this.GetIndentString(null, totalIndent, tabSize, convertTabsToSpaces); + } + return this.GetIndentString(existingIndentation, level * indentSize, tabSize, convertTabsToSpaces); + }, _proto.GetIndentString = function(prefix, totalIndentSize, tabSize, convertTabsToSpaces) { + var tabString = convertTabsToSpaces ? StringUtils.create(" ", tabSize) : " ", text = ""; + StringUtils.IsNullOrEmpty(prefix) || (text += prefix); + for(var pos = 0; pos <= totalIndentSize - tabSize;)text += tabString, pos += tabSize; + for(; pos < totalIndentSize;)text += " ", pos++; + return text; + }, _proto.ApplyIndentationDeltaFromParent = function(token, node) { + for(var indentationInfo = null, indentableParent = node; null != indentableParent && !indentableParent.CanIndent();)indentableParent = indentableParent.Parent; + if (null != indentableParent && indentableParent.AuthorNode.Details.Kind != AuthorParseNodeKind.apnkProg) { + var parentIndentationDeltaSize = this.GetIndentationDelta(indentableParent.AuthorNode.Details.StartOffset, token.Span.startPosition()); + void 0 !== parentIndentationDeltaSize && (indentationInfo = this.ApplyIndentationDelta1(token.Span.startPosition(), parentIndentationDeltaSize)); + } + return indentationInfo; + }, _proto.ApplyIndentationDelta1 = function(tokenStartPosition, delta) { + var snapshotLine = this.snapshot.GetLineFromPosition(tokenStartPosition), currentIndentSpan = new Span(snapshotLine.startPosition(), tokenStartPosition - snapshotLine.startPosition()), currentIndent = this.snapshot.GetText(currentIndentSpan); + return this.ApplyIndentationDelta2(currentIndent, delta); + }, _proto.ApplyIndentationDelta2 = function(currentIndent, delta) { + if (0 == delta) return null; + var newIndentSize = Indenter.GetIndentSizeFromIndentText(currentIndent, this.editorOptions) + delta; + newIndentSize < 0 && (newIndentSize = 0); + var newIndent = this.GetIndentString(null, newIndentSize, this.editorOptions.TabSize, this.editorOptions.ConvertTabsToSpaces); + return null != newIndent ? new IndentationInfo(newIndent, 0) : null; + }, _proto.GetIndentationDelta = function(tokenStartPosition, childTokenStartPosition) { + Debug.Assert(void 0 !== childTokenStartPosition, "Error: caller must pass 'null' for undefined position"); + var indentationDeltaSize = this.offsetIndentationDeltas.GetValue(tokenStartPosition); + if (null === indentationDeltaSize) { + var indentEditInfo = this.indentationBag.FindIndent(tokenStartPosition); + if (null == indentEditInfo) return null; + var origIndentText = this.snapshot.GetText(new Span(indentEditInfo.OrigIndentPosition, indentEditInfo.OrigIndentLength())), newIndentText = indentEditInfo.Indentation(), origIndentSize = Indenter.GetIndentSizeFromText(origIndentText, this.editorOptions, !0), newIndentSize = Indenter.GetIndentSizeFromIndentText(newIndentText, this.editorOptions); + if (null !== childTokenStartPosition) { + var childTokenLineStartPosition = this.snapshot.GetLineFromPosition(childTokenStartPosition).startPosition(), childIndentText = this.snapshot.GetText(new Span(childTokenLineStartPosition, childTokenStartPosition - childTokenLineStartPosition)); + Indenter.GetIndentSizeFromIndentText(childIndentText, this.editorOptions) < origIndentSize && (origIndentSize = Indenter.GetIndentSizeFromIndentText(origIndentText, this.editorOptions)); + } + indentationDeltaSize = newIndentSize - origIndentSize, this.offsetIndentationDeltas.Add(tokenStartPosition, indentationDeltaSize); + } + return indentationDeltaSize; + }, _proto.FillInheritedIndentation = function(tree) { + var offset = -1, indentNode = null; + if (null != tree.StartNodeSelf) { + if (this.smartIndent || null === tree.StartNodePreviousSibling || 0 != tree.StartNodeSelf.AuthorNode.Label || 0 != tree.StartNodePreviousSibling.Label) { + if (this.smartIndent) for(parent = tree.StartNodeSelf; null != parent && parent.AuthorNode.Details.StartOffset == this.firstToken.Span.startPosition();)parent = parent.Parent; + else { + var startNodeLineNumber = this.snapshot.GetLineNumberFromPosition(tree.StartNodeSelf.AuthorNode.Details.StartOffset); + for(parent = tree.StartNodeSelf.Parent; null != parent && startNodeLineNumber == this.snapshot.GetLineNumberFromPosition(parent.AuthorNode.Details.StartOffset);)parent = parent.Parent; } + for(; null != parent && !parent.CanIndent();)parent = parent.Parent; + null != parent && parent.AuthorNode.Details.Kind != AuthorParseNodeKind.apnkProg && (offset = parent.AuthorNode.Details.StartOffset, indentNode = parent); + } else { + indentNode = tree.StartNodeSelf, offset = tree.StartNodePreviousSibling.Details.StartOffset; + for(var parent, lineNum = this.snapshot.GetLineNumberFromPosition(offset), node = indentNode; null != node.Parent && this.snapshot.GetLineNumberFromPosition(node.Parent.AuthorNode.Details.StartOffset) == lineNum;)(node = node.Parent).CanIndent() && ((indentNode = node).IndentationDelta = 0); } - return result; - }, _proto.GetSpecialCaseIndentation = function(token, node) { - var indentationInfo = null; + } + if (null != indentNode) { + var indentOverride = this.GetLineIndentationForOffset(offset); + this.smartIndent || null === tree.StartNodePreviousSibling || null == indentNode.Parent || ParseNodeExtensions.GetChildren(indentNode.Parent).foreach(function(sibling) { + sibling !== indentNode && sibling.CanIndent() && sibling.SetIndentationOverride(indentOverride); + }); + var lastDelta = 0, lastLine = this.snapshot.GetLineNumberFromPosition(indentNode.AuthorNode.Details.StartOffset); + do { + var currentLine = this.snapshot.GetLineNumberFromPosition(indentNode.AuthorNode.Details.StartOffset); + lastLine != currentLine && (lastLine = currentLine, indentOverride = this.ApplyIndentationLevel(indentOverride, -lastDelta), lastDelta = 0), indentNode.CanIndent() && (indentNode.SetIndentationOverride(indentOverride), lastDelta = indentNode.IndentationDelta), indentNode = indentNode.Parent; + }while (null != indentNode); + } + }, _proto.GetLineIndentationForOffset = function(offset) { + if (null != (indentationEdit = this.indentationBag.FindIndent(offset))) return indentationEdit.Indentation(); + for(var indentationEdit, lineText = this.snapshot.GetLineFromPosition(offset).getText(), index = 0; index < lineText.length && (" " == lineText.charAt(index) || " " == lineText.charAt(index));)++index; + return lineText.substr(0, index); + }, _proto.RegisterIndentation = function(indent, sameLineIndent) { + var indentationInfo = null; + if (sameLineIndent) { + var lineStartPosition = this.snapshot.GetLineFromPosition(indent.Position).startPosition(), lineIndentLength = indent.Position - lineStartPosition; + indentationInfo = IndentationEditInfo.create2(indent.Position, indent.ReplaceWith, lineStartPosition, lineIndentLength); + } else indentationInfo = new IndentationEditInfo(indent); + this.indentationBag.AddIndent(indentationInfo); + }, _proto.RegisterIndentation2 = function(position, indent) { + this.RegisterIndentation(new TextEditInfo(position, 0, indent), !1); + }, _proto.AdjustStartOffsetIfNeeded = function(token, node) { + if (null != token) { + var updateStartOffset = !1; switch(token.Token){ + case AuthorTokenKind.atkFunction: + updateStartOffset = node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkFncDecl; + break; case AuthorTokenKind.atkLCurly: - return this.GetSpecialCaseIndentationForLCurly(node); - case AuthorTokenKind.atkElse: - case AuthorTokenKind.atkRBrack: - return node.GetNodeStartLineIndentation(this); - case AuthorTokenKind.atkRCurly: - return node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkBlock && node.AuthorNode.EdgeLabel == AuthorParseNodeEdge.apneBody && (node = node.Parent), indentationInfo = node.GetNodeStartLineIndentation(this); - case AuthorTokenKind.atkWhile: - if (node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkDoWhile) return node.GetNodeStartLineIndentation(this); - return null; - case AuthorTokenKind.atkSColon: - return this.GetSpecialCaseIndentationForSemicolon(token, node); - case AuthorTokenKind.atkComment: - return this.GetSpecialCaseIndentationForComment(token, node); - default: - return indentationInfo; - } - }, _proto.GetSpecialCaseIndentationForLCurly = function(node) { - return node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkFncDecl || node.AuthorNode.EdgeLabel == AuthorParseNodeEdge.apneThen || node.AuthorNode.EdgeLabel == AuthorParseNodeEdge.apneElse ? node.GetNodeStartLineIndentation(this) : node.AuthorNode.Details.Kind != AuthorParseNodeKind.apnkObject || node.CanIndent() ? node.GetEffectiveIndentation(this) : null; - }, _proto.GetSpecialCaseIndentationForSemicolon = function(token, node) { - if (this.smartIndent) return node.GetEffectiveChildrenIndentation(this); - if (node.AuthorNode.Details.Kind != AuthorParseNodeKind.apnkFor) { - var semiColonStartSpan = new Span(token.Span.startPosition(), 0); - return (node = ParseTree.FindCommonParentNode(semiColonStartSpan, semiColonStartSpan, node)).GetEffectiveChildrenIndentation(this); + updateStartOffset = node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkObject; + break; + case AuthorTokenKind.atkLBrack: + updateStartOffset = node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkArray; } - return null; - }, _proto.GetSpecialCaseIndentationForComment = function(token, node) { - var indentationInfo = null, twoCharSpan = token.Span.Intersection(new Span(token.Span.startPosition(), 2)); - if (null != twoCharSpan && ("//" == twoCharSpan.GetText() || "/*" == twoCharSpan.GetText())) { - for(; null == node.ChildrenIndentationDelta && null != node.Parent;)node = node.Parent; - indentationInfo = this.CanIndentComment(token, node) ? node.GetEffectiveChildrenIndentationForComment(this) : this.ApplyIndentationDeltaFromParent(token, node); - } - return indentationInfo; - }, _proto.CanIndentComment = function(token, node) { - switch(node.AuthorNode.Details.Kind){ - case AuthorParseNodeKind.apnkProg: - case AuthorParseNodeKind.apnkBlock: - case AuthorParseNodeKind.apnkSwitch: - case AuthorParseNodeKind.apnkCase: - case AuthorParseNodeKind.apnkDefaultCase: - case AuthorParseNodeKind.apnkIf: - case AuthorParseNodeKind.apnkFor: - case AuthorParseNodeKind.apnkForIn: - case AuthorParseNodeKind.apnkWhile: - case AuthorParseNodeKind.apnkWith: - case AuthorParseNodeKind.apnkDoWhile: - case AuthorParseNodeKind.apnkObject: - return !0; - case AuthorParseNodeKind.apnkFncDecl: - var result = !0; - return ParseNodeExtensions.FindChildrenWithEdge(node, AuthorParseNodeEdge.apneArgument).foreach(function(argumentNode) { - token.Span.startPosition() < argumentNode.AuthorNode.Details.StartOffset && (result = !1); - }), result; - } - return !1; - }, _proto.ApplyScriptBlockIndentation = function(languageHostIndentation, tree) { - if (null != languageHostIndentation && null != tree.StartNodeSelf) { - var scriptBlockIndentation = this.ApplyIndentationLevel(languageHostIndentation, 1); - tree.Root.SetIndentationOverride(scriptBlockIndentation); - } - }, _proto.GetIndentEdit = function(indentInfo, tokenStartPosition, sameLineIndent) { - var indentText = this.ApplyIndentationLevel(indentInfo.Prefix, indentInfo.Level); - if (sameLineIndent) return new TextEditInfo(tokenStartPosition, 0, indentText); - var snapshotLine = this.snapshot.GetLineFromPosition(tokenStartPosition), currentIndentSpan = new Span(snapshotLine.startPosition(), tokenStartPosition - snapshotLine.startPosition()), currentIndentText = this.snapshot.GetText(currentIndentSpan); - if (currentIndentText !== indentText) { - if (this.logger.debug()) for(var i = 0, len = currentIndentText.length; i < len; i++){ - var c = currentIndentText.charCodeAt(i); - if (!StringUtils.IsWhiteSpace(c)) { - Debug.Fail("Formatting error: Will remove user code when indenting the line: " + snapshotLine.getText()); - break; - } - } - return new TextEditInfo(currentIndentSpan.start(), currentIndentSpan.length(), indentText); - } - return null; - }, _proto.ApplyIndentationLevel = function(existingIndentation, level) { - var indentSize = this.editorOptions.IndentSize, tabSize = this.editorOptions.TabSize, convertTabsToSpaces = this.editorOptions.ConvertTabsToSpaces; - if (level < 0) { - if (StringUtils.IsNullOrEmpty(existingIndentation)) return ""; - var totalIndent = 0; - return (StringUtils.foreach(existingIndentation, function(c) { - " " == c ? totalIndent += tabSize : totalIndent++; - }), (totalIndent += level * indentSize) < 0) ? "" : this.GetIndentString(null, totalIndent, tabSize, convertTabsToSpaces); - } - return this.GetIndentString(existingIndentation, level * indentSize, tabSize, convertTabsToSpaces); - }, _proto.GetIndentString = function(prefix, totalIndentSize, tabSize, convertTabsToSpaces) { - var tabString = convertTabsToSpaces ? StringUtils.create(" ", tabSize) : " ", text = ""; - StringUtils.IsNullOrEmpty(prefix) || (text += prefix); - for(var pos = 0; pos <= totalIndentSize - tabSize;)text += tabString, pos += tabSize; - for(; pos < totalIndentSize;)text += " ", pos++; - return text; - }, _proto.ApplyIndentationDeltaFromParent = function(token, node) { - for(var indentationInfo = null, indentableParent = node; null != indentableParent && !indentableParent.CanIndent();)indentableParent = indentableParent.Parent; - if (null != indentableParent && indentableParent.AuthorNode.Details.Kind != AuthorParseNodeKind.apnkProg) { - var parentIndentationDeltaSize = this.GetIndentationDelta(indentableParent.AuthorNode.Details.StartOffset, token.Span.startPosition()); - void 0 !== parentIndentationDeltaSize && (indentationInfo = this.ApplyIndentationDelta1(token.Span.startPosition(), parentIndentationDeltaSize)); - } - return indentationInfo; - }, _proto.ApplyIndentationDelta1 = function(tokenStartPosition, delta) { - var snapshotLine = this.snapshot.GetLineFromPosition(tokenStartPosition), currentIndentSpan = new Span(snapshotLine.startPosition(), tokenStartPosition - snapshotLine.startPosition()), currentIndent = this.snapshot.GetText(currentIndentSpan); - return this.ApplyIndentationDelta2(currentIndent, delta); - }, _proto.ApplyIndentationDelta2 = function(currentIndent, delta) { - if (0 == delta) return null; - var newIndentSize = Indenter.GetIndentSizeFromIndentText(currentIndent, this.editorOptions) + delta; - newIndentSize < 0 && (newIndentSize = 0); - var newIndent = this.GetIndentString(null, newIndentSize, this.editorOptions.TabSize, this.editorOptions.ConvertTabsToSpaces); - return null != newIndent ? new IndentationInfo(newIndent, 0) : null; - }, _proto.GetIndentationDelta = function(tokenStartPosition, childTokenStartPosition) { - Debug.Assert(void 0 !== childTokenStartPosition, "Error: caller must pass 'null' for undefined position"); - var indentationDeltaSize = this.offsetIndentationDeltas.GetValue(tokenStartPosition); - if (null === indentationDeltaSize) { - var indentEditInfo = this.indentationBag.FindIndent(tokenStartPosition); - if (null == indentEditInfo) return null; - var origIndentText = this.snapshot.GetText(new Span(indentEditInfo.OrigIndentPosition, indentEditInfo.OrigIndentLength())), newIndentText = indentEditInfo.Indentation(), origIndentSize = Indenter.GetIndentSizeFromText(origIndentText, this.editorOptions, !0), newIndentSize = Indenter.GetIndentSizeFromIndentText(newIndentText, this.editorOptions); - if (null !== childTokenStartPosition) { - var childTokenLineStartPosition = this.snapshot.GetLineFromPosition(childTokenStartPosition).startPosition(), childIndentText = this.snapshot.GetText(new Span(childTokenLineStartPosition, childTokenStartPosition - childTokenLineStartPosition)); - Indenter.GetIndentSizeFromIndentText(childIndentText, this.editorOptions) < origIndentSize && (origIndentSize = Indenter.GetIndentSizeFromIndentText(origIndentText, this.editorOptions)); - } - indentationDeltaSize = newIndentSize - origIndentSize, this.offsetIndentationDeltas.Add(tokenStartPosition, indentationDeltaSize); - } - return indentationDeltaSize; - }, _proto.FillInheritedIndentation = function(tree) { - var offset = -1, indentNode = null; - if (null != tree.StartNodeSelf) { - if (this.smartIndent || null === tree.StartNodePreviousSibling || 0 != tree.StartNodeSelf.AuthorNode.Label || 0 != tree.StartNodePreviousSibling.Label) { - if (this.smartIndent) for(parent = tree.StartNodeSelf; null != parent && parent.AuthorNode.Details.StartOffset == this.firstToken.Span.startPosition();)parent = parent.Parent; - else { - var startNodeLineNumber = this.snapshot.GetLineNumberFromPosition(tree.StartNodeSelf.AuthorNode.Details.StartOffset); - for(parent = tree.StartNodeSelf.Parent; null != parent && startNodeLineNumber == this.snapshot.GetLineNumberFromPosition(parent.AuthorNode.Details.StartOffset);)parent = parent.Parent; - } - for(; null != parent && !parent.CanIndent();)parent = parent.Parent; - null != parent && parent.AuthorNode.Details.Kind != AuthorParseNodeKind.apnkProg && (offset = parent.AuthorNode.Details.StartOffset, indentNode = parent); - } else { - indentNode = tree.StartNodeSelf, offset = tree.StartNodePreviousSibling.Details.StartOffset; - for(var parent, lineNum = this.snapshot.GetLineNumberFromPosition(offset), node = indentNode; null != node.Parent && this.snapshot.GetLineNumberFromPosition(node.Parent.AuthorNode.Details.StartOffset) == lineNum;)(node = node.Parent).CanIndent() && ((indentNode = node).IndentationDelta = 0); - } - } - if (null != indentNode) { - var indentOverride = this.GetLineIndentationForOffset(offset); - this.smartIndent || null === tree.StartNodePreviousSibling || null == indentNode.Parent || ParseNodeExtensions.GetChildren(indentNode.Parent).foreach(function(sibling) { - sibling !== indentNode && sibling.CanIndent() && sibling.SetIndentationOverride(indentOverride); - }); - var lastDelta = 0, lastLine = this.snapshot.GetLineNumberFromPosition(indentNode.AuthorNode.Details.StartOffset); - do { - var currentLine = this.snapshot.GetLineNumberFromPosition(indentNode.AuthorNode.Details.StartOffset); - lastLine != currentLine && (lastLine = currentLine, indentOverride = this.ApplyIndentationLevel(indentOverride, -lastDelta), lastDelta = 0), indentNode.CanIndent() && (indentNode.SetIndentationOverride(indentOverride), lastDelta = indentNode.IndentationDelta), indentNode = indentNode.Parent; - }while (null != indentNode); - } - }, _proto.GetLineIndentationForOffset = function(offset) { - if (null != (indentationEdit = this.indentationBag.FindIndent(offset))) return indentationEdit.Indentation(); - for(var indentationEdit, lineText = this.snapshot.GetLineFromPosition(offset).getText(), index = 0; index < lineText.length && (" " == lineText.charAt(index) || " " == lineText.charAt(index));)++index; - return lineText.substr(0, index); - }, _proto.RegisterIndentation = function(indent, sameLineIndent) { - var indentationInfo = null; - if (sameLineIndent) { - var lineStartPosition = this.snapshot.GetLineFromPosition(indent.Position).startPosition(), lineIndentLength = indent.Position - lineStartPosition; - indentationInfo = IndentationEditInfo.create2(indent.Position, indent.ReplaceWith, lineStartPosition, lineIndentLength); - } else indentationInfo = new IndentationEditInfo(indent); - this.indentationBag.AddIndent(indentationInfo); - }, _proto.RegisterIndentation2 = function(position, indent) { - this.RegisterIndentation(new TextEditInfo(position, 0, indent), !1); - }, _proto.AdjustStartOffsetIfNeeded = function(token, node) { - if (null != token) { - var updateStartOffset = !1; - switch(token.Token){ - case AuthorTokenKind.atkFunction: - updateStartOffset = node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkFncDecl; - break; - case AuthorTokenKind.atkLCurly: - updateStartOffset = node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkObject; - break; - case AuthorTokenKind.atkLBrack: - updateStartOffset = node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkArray; - } - updateStartOffset && ParseNodeExtensions.SetNodeSpan(node, token.Span.startPosition(), node.AuthorNode.Details.EndOffset); - } - }, _proto.IsMultiLineString = function(token) { - return token.tokenID === TypeScript.TokenID.StringLiteral && this.snapshot.GetLineNumberFromPosition(token.Span.endPosition()) > this.snapshot.GetLineNumberFromPosition(token.Span.startPosition()); - }, Indenter.GetIndentSizeFromIndentText = function(indentText, editorOptions) { - return GetIndentSizeFromText(indentText, editorOptions, !1); - }, Indenter.GetIndentSizeFromText = function(text, editorOptions, includeNonIndentChars) { - for(var indentSize = 0, i = 0; i < text.length; i++){ - var c = text.charAt(i); - if (" " == c) indentSize = indentSize + editorOptions.TabSize - indentSize % editorOptions.TabSize; - else if (" " == c) indentSize += 1; - else if (includeNonIndentChars) indentSize += 1; - else break; - } - return indentSize; - }, Indenter; - }(); - Formatting.Indenter = Indenter; -}(Formatting || (Formatting = {})); + updateStartOffset && ParseNodeExtensions.SetNodeSpan(node, token.Span.startPosition(), node.AuthorNode.Details.EndOffset); + } + }, _proto.IsMultiLineString = function(token) { + return token.tokenID === TypeScript.TokenID.StringLiteral && this.snapshot.GetLineNumberFromPosition(token.Span.endPosition()) > this.snapshot.GetLineNumberFromPosition(token.Span.startPosition()); + }, Indenter.GetIndentSizeFromIndentText = function(indentText, editorOptions) { + return GetIndentSizeFromText(indentText, editorOptions, !1); + }, Indenter.GetIndentSizeFromText = function(text, editorOptions, includeNonIndentChars) { + for(var indentSize = 0, i = 0; i < text.length; i++){ + var c = text.charAt(i); + if (" " == c) indentSize = indentSize + editorOptions.TabSize - indentSize % editorOptions.TabSize; + else if (" " == c) indentSize += 1; + else if (includeNonIndentChars) indentSize += 1; + else break; + } + return indentSize; + }, Indenter; +}(), Formatting1.Indenter = Indenter; diff --git a/crates/swc/tests/tsc-references/plusOperatorWithBooleanType.2.minified.js b/crates/swc/tests/tsc-references/plusOperatorWithBooleanType.2.minified.js index 4c4b63d0ad89..b9837a6a56a7 100644 --- a/crates/swc/tests/tsc-references/plusOperatorWithBooleanType.2.minified.js +++ b/crates/swc/tests/tsc-references/plusOperatorWithBooleanType.2.minified.js @@ -1,6 +1,6 @@ //// [plusOperatorWithBooleanType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var M, A = function() { +var n, M, A = function() { function A() { _class_call_check(this, A); } @@ -8,9 +8,6 @@ var M, A = function() { return !1; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/plusOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/plusOperatorWithNumberType.2.minified.js index c666b659c20a..08f56767a745 100644 --- a/crates/swc/tests/tsc-references/plusOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/plusOperatorWithNumberType.2.minified.js @@ -1,6 +1,6 @@ //// [plusOperatorWithNumberType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var M, A = function() { +var M, n, A = function() { function A() { _class_call_check(this, A); } @@ -8,9 +8,6 @@ var M, A = function() { return 1; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; 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.2.minified.js b/crates/swc/tests/tsc-references/plusOperatorWithStringType.2.minified.js index ef4d7d3c19b7..7e651dc92fdd 100644 --- a/crates/swc/tests/tsc-references/plusOperatorWithStringType.2.minified.js +++ b/crates/swc/tests/tsc-references/plusOperatorWithStringType.2.minified.js @@ -1,6 +1,6 @@ //// [plusOperatorWithStringType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var STRING, M, A = function() { +var STRING, M, n, A = function() { function A() { _class_call_check(this, A); } @@ -8,9 +8,6 @@ var STRING, M, A = function() { return ""; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; 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/privateNameWhenNotUseDefineForClassFieldsInEsNext(target=es2020).2.minified.js b/crates/swc/tests/tsc-references/privateNameWhenNotUseDefineForClassFieldsInEsNext(target=es2020).2.minified.js index 69dc2b02f451..86fbfb1ec445 100644 --- a/crates/swc/tests/tsc-references/privateNameWhenNotUseDefineForClassFieldsInEsNext(target=es2020).2.minified.js +++ b/crates/swc/tests/tsc-references/privateNameWhenNotUseDefineForClassFieldsInEsNext(target=es2020).2.minified.js @@ -2,7 +2,7 @@ import { _ as _class_private_field_get } from "@swc/helpers/_/_class_private_field_get"; import { _ as _class_private_field_init } from "@swc/helpers/_/_class_private_field_init"; import { _ as _class_private_field_set } from "@swc/helpers/_/_class_private_field_set"; -var _prop = new WeakMap(); +var _foo, _Inner, _prop = new WeakMap(); class TestWithStatics { constructor(){ _class_private_field_init(this, _prop, { @@ -11,28 +11,25 @@ class TestWithStatics { }), _class_private_field_set(this, _prop, 0); } } -TestWithStatics.dd = _class_private_field_get(new TestWithStatics(), _prop), (()=>{ - var _foo, _Inner; - TestWithStatics["X_ z_ zz"] = (_foo = new WeakMap(), (_Inner = class Inner { - m() { - _class_private_field_get(new TestWithStatics(), _prop); - } - static M() { - return class { - m() { - _class_private_field_get(new TestWithStatics(), _prop), _class_private_field_get(new Inner(), _foo); - } - }; - } - constructor(){ - _class_private_field_init(this, _foo, { - writable: !0, - value: void 0 - }), _class_private_field_set(this, _foo, 10); - } - }).C = class { - m() { - _class_private_field_get(new TestWithStatics(), _prop), _class_private_field_get(new _Inner(), _foo); - } - }, _Inner); -})(); +TestWithStatics.dd = _class_private_field_get(new TestWithStatics(), _prop), TestWithStatics["X_ z_ zz"] = (_foo = new WeakMap(), (_Inner = class Inner { + m() { + _class_private_field_get(new TestWithStatics(), _prop); + } + static M() { + return class { + m() { + _class_private_field_get(new TestWithStatics(), _prop), _class_private_field_get(new Inner(), _foo); + } + }; + } + constructor(){ + _class_private_field_init(this, _foo, { + writable: !0, + value: void 0 + }), _class_private_field_set(this, _foo, 10); + } +}).C = class { + m() { + _class_private_field_get(new TestWithStatics(), _prop), _class_private_field_get(new _Inner(), _foo); + } +}, _Inner); diff --git a/crates/swc/tests/tsc-references/scopeResolutionIdentifiers.2.minified.js b/crates/swc/tests/tsc-references/scopeResolutionIdentifiers.2.minified.js index 8316e301c381..68b3b1716fcc 100644 --- a/crates/swc/tests/tsc-references/scopeResolutionIdentifiers.2.minified.js +++ b/crates/swc/tests/tsc-references/scopeResolutionIdentifiers.2.minified.js @@ -1,10 +1,4 @@ //// [scopeResolutionIdentifiers.ts] -var M1, M2, M3; +var M1, M2, M3, s, M4; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -!function(M1) { - var s; - M1.s = s; -}(M1 || (M1 = {})), M2 || (M2 = {}), function(M3) { - var M4; - M4 || (M4 = {}); -}(M3 || (M3 = {})); +(M1 || (M1 = {})).s = s, M2 || (M2 = {}), M3 || (M3 = {}), M4 || (M4 = {}); diff --git a/crates/swc/tests/tsc-references/staticPropertyNotInClassType.2.minified.js b/crates/swc/tests/tsc-references/staticPropertyNotInClassType.2.minified.js index 70bae6c06b22..41d71ae1ff13 100644 --- a/crates/swc/tests/tsc-references/staticPropertyNotInClassType.2.minified.js +++ b/crates/swc/tests/tsc-references/staticPropertyNotInClassType.2.minified.js @@ -1,45 +1,35 @@ //// [staticPropertyNotInClassType.ts] -var NonGeneric, Generic; +var NonGeneric, Generic, C, c, C1, c1; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _create_class } from "@swc/helpers/_/_create_class"; -!function(NonGeneric) { - var C = function() { - function C(a, b) { - _class_call_check(this, C), this.a = a, this.b = b; +NonGeneric || (NonGeneric = {}), ((C = function() { + function C(a, b) { + _class_call_check(this, C), this.a = a, this.b = b; + } + return C.prototype.fn = function() { + return this; + }, _create_class(C, null, [ + { + key: "x", + get: function() { + return 1; + }, + set: function(v) {} } - return C.prototype.fn = function() { - return this; - }, _create_class(C, null, [ - { - key: "x", - get: function() { - return 1; - }, - set: function(v) {} - } - ]), C; - }(); - (C || (C = {})).bar = ""; - var c = new C(1, 2); - c.fn(), c.foo, c.bar, c.x; -}(NonGeneric || (NonGeneric = {})), function(Generic) { - var C = function() { - function C(a, b) { - _class_call_check(this, C), this.a = a, this.b = b; + ]), C; +}()) || (C = {})).bar = "", (c = new C(1, 2)).fn(), c.foo, c.bar, c.x, Generic || (Generic = {}), ((C1 = function() { + function C(a, b) { + _class_call_check(this, C), this.a = a, this.b = b; + } + return C.prototype.fn = function() { + return this; + }, _create_class(C, null, [ + { + key: "x", + get: function() { + return 1; + }, + set: function(v) {} } - return C.prototype.fn = function() { - return this; - }, _create_class(C, null, [ - { - key: "x", - get: function() { - return 1; - }, - set: function(v) {} - } - ]), C; - }(); - (C || (C = {})).bar = ""; - var c = new C(1, ""); - c.fn(), c.foo, c.bar, c.x; -}(Generic || (Generic = {})); + ]), C; +}()) || (C1 = {})).bar = "", (c1 = new C1(1, "")).fn(), c1.foo, c1.bar, c1.x; diff --git a/crates/swc/tests/tsc-references/subtypingWithConstructSignatures.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithConstructSignatures.2.minified.js index 8cf20b482c3f..2b6ca0e79840 100644 --- a/crates/swc/tests/tsc-references/subtypingWithConstructSignatures.2.minified.js +++ b/crates/swc/tests/tsc-references/subtypingWithConstructSignatures.2.minified.js @@ -1,6 +1,3 @@ //// [subtypingWithConstructSignatures.ts] -var ConstructSignature; -!function(ConstructSignature) { - var rarg1, rarg2, r3arg1, r4arg1; - foo1(rarg1), foo1(rarg2), foo2(r3arg1), foo2(r4arg1); -}(ConstructSignature || (ConstructSignature = {})); +var ConstructSignature, rarg1, rarg2, r3arg1, r4arg1; +ConstructSignature || (ConstructSignature = {}), foo1(rarg1), foo1(rarg2), foo2(r3arg1), foo2(r4arg1); diff --git a/crates/swc/tests/tsc-references/subtypingWithConstructSignatures3.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithConstructSignatures3.2.minified.js index 9a9d71469e23..4c790c4a7f74 100644 --- a/crates/swc/tests/tsc-references/subtypingWithConstructSignatures3.2.minified.js +++ b/crates/swc/tests/tsc-references/subtypingWithConstructSignatures3.2.minified.js @@ -1,12 +1,6 @@ //// [subtypingWithConstructSignatures3.ts] -var Errors, WithGenericSignaturesInBaseType; +var Errors, WithGenericSignaturesInBaseType, r1arg1, r2arg1, r3arg1, r4arg1, r5arg1, r6arg1, r7arg1, r7arg3, r8arg, r9arg, r2arg2, r3arg2; 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(Errors) { - var r1arg1, r2arg1, r3arg1, r4arg1, r5arg1, r6arg1, r7arg1, r7arg3, r8arg, r9arg; - foo2(r1arg1), foo7(r2arg1), foo8(r3arg1), foo10(r4arg1), foo11(r5arg1), foo12(r6arg1), foo15(r7arg1), foo15(r7arg3), foo16(r8arg), foo17(r9arg); -}(Errors || (Errors = {})), function(WithGenericSignaturesInBaseType) { - var r2arg2, r3arg2; - foo2(r2arg2), foo3(r3arg2); -}(WithGenericSignaturesInBaseType || (WithGenericSignaturesInBaseType = {})); +Errors || (Errors = {}), foo2(r1arg1), foo7(r2arg1), foo8(r3arg1), foo10(r4arg1), foo11(r5arg1), foo12(r6arg1), foo15(r7arg1), foo15(r7arg3), foo16(r8arg), foo17(r9arg), WithGenericSignaturesInBaseType || (WithGenericSignaturesInBaseType = {}), foo2(r2arg2), foo3(r3arg2); 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 3264a00ea580..9cb16b86b282 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,6 +7,7 @@ Baz || (Baz = {}); export default class { } //// [locals.ts] +let Reflect, Reflect1, Reflect2, Reflect3; import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; class C extends B { @@ -27,14 +28,8 @@ C._ = [ })(), void _get(_get_prototype_of(C), "w", C).call(C), void _get(_get_prototype_of(C), "w", C).call(C), - (()=>{ - let Reflect; - Reflect || (Reflect = {}), _get(_get_prototype_of(C), "w", C).call(C); - })(), - (()=>{ - let Reflect; - Reflect || (Reflect = {}), _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), @@ -49,13 +44,7 @@ C._ = [ null ]; _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), (()=>{ - let Reflect; - Reflect || (Reflect = {}), _get(_get_prototype_of(C), "w", C).call(C); -})(), (()=>{ - let Reflect; - Reflect || (Reflect = {}), _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), 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); //// [varInContainingScopeStaticField1.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 3264a00ea580..9cb16b86b282 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,6 +7,7 @@ Baz || (Baz = {}); export default class { } //// [locals.ts] +let Reflect, Reflect1, Reflect2, Reflect3; import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; class C extends B { @@ -27,14 +28,8 @@ C._ = [ })(), void _get(_get_prototype_of(C), "w", C).call(C), void _get(_get_prototype_of(C), "w", C).call(C), - (()=>{ - let Reflect; - Reflect || (Reflect = {}), _get(_get_prototype_of(C), "w", C).call(C); - })(), - (()=>{ - let Reflect; - Reflect || (Reflect = {}), _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), @@ -49,13 +44,7 @@ C._ = [ null ]; _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), (()=>{ - let Reflect; - Reflect || (Reflect = {}), _get(_get_prototype_of(C), "w", C).call(C); -})(), (()=>{ - let Reflect; - Reflect || (Reflect = {}), _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), 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); //// [varInContainingScopeStaticField1.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=es2022).2.minified.js b/crates/swc/tests/tsc-references/superInStaticMembers1(target=es2022).2.minified.js index 40e2b6b0afa4..f4dc002d0178 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,6 +9,7 @@ export default class { //// [locals.ts] class C extends B { static{ + let Reflect, Reflect1; this._ = [ void super.w(), (()=>{ @@ -25,14 +26,8 @@ class C extends B { })(), void super.w(), void super.w(), - (()=>{ - let Reflect; - Reflect || (Reflect = {}), super.w(); - })(), - (()=>{ - let Reflect; - Reflect || (Reflect = {}), super.w(); - })(), + void (Reflect || (Reflect = {}), super.w()), + void (Reflect1 || (Reflect1 = {}), super.w()), void super.w(), void super.w(), void super.w(), 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 6168a0a5c5ca..a8b0fce5176c 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,7 +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 C = function(B1) { +var Reflect, Reflect1, Reflect2, Reflect3, C = function(B1) { _inherits(C, B1); var _super = _create_super(C); function C() { @@ -24,28 +24,19 @@ var C = function(B1) { } return C; }(B); -!function() { - var Reflect, Reflect1; - 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), - 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) - ]; -}(), _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), function() { - var Reflect; - Reflect || (Reflect = {}), _get(_get_prototype_of(C), "w", C).call(C); -}(), function() { - var Reflect; - Reflect || (Reflect = {}), _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); +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), + 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) +], _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); //// [varInContainingScopeStaticField1.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _get } from "@swc/helpers/_/_get"; @@ -651,39 +642,35 @@ var C = function(B1) { }(B); _get(_get_prototype_of(C), "w", C).call(C); //// [inContainingClassExprStaticField.ts] +var C; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; 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"; -!function() { - var C = function(B1) { - _inherits(C, B1); - var _super = _create_super(C); - function C() { - return _class_call_check(this, C), _super.apply(this, arguments); - } - return C; - }(B); - C._ = _get(_get_prototype_of(C), "w", C).call(C); -}(); +(C = function(B1) { + _inherits(C, B1); + var _super = _create_super(C); + function C() { + return _class_call_check(this, C), _super.apply(this, arguments); + } + return C; +}(B))._ = _get(_get_prototype_of(C), "w", C).call(C); //// [inContainingClassExprStaticBlock.ts] +var C; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; 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"; -!function() { - var C = function(B1) { - _inherits(C, B1); - var _super = _create_super(C); - function C() { - return _class_call_check(this, C), _super.apply(this, arguments); - } - return C; - }(B); - _get(_get_prototype_of(C), "w", C).call(C); -}(); +_get(_get_prototype_of(C = function(B1) { + _inherits(C, B1); + var _super = _create_super(C); + function C() { + return _class_call_check(this, C), _super.apply(this, arguments); + } + return C; +}(B)), "w", C).call(C); //// [funcExprInContainingScopeStaticField.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/symbolDeclarationEmit12.2.minified.js b/crates/swc/tests/tsc-references/symbolDeclarationEmit12.2.minified.js index fe0ed1bbd8fa..b2311b4ec98f 100644 --- a/crates/swc/tests/tsc-references/symbolDeclarationEmit12.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolDeclarationEmit12.2.minified.js @@ -1,11 +1,9 @@ //// [symbolDeclarationEmit12.ts] -var M; -!function(M) { - let _Symbol_toPrimitive = Symbol.toPrimitive, _Symbol_isConcatSpreadable = Symbol.isConcatSpreadable, _Symbol_toPrimitive1 = Symbol.toPrimitive, _Symbol_toPrimitive2 = Symbol.toPrimitive; - M.C = class { - [_Symbol_toPrimitive](x) {} - [_Symbol_isConcatSpreadable]() {} - get [_Symbol_toPrimitive1]() {} - set [_Symbol_toPrimitive2](x) {} - }; -}(M || (M = {})); +var M, M1; +let _Symbol_toPrimitive, _Symbol_isConcatSpreadable, _Symbol_toPrimitive1, _Symbol_toPrimitive2; +M1 = M || (M = {}), _Symbol_toPrimitive = Symbol.toPrimitive, _Symbol_isConcatSpreadable = Symbol.isConcatSpreadable, _Symbol_toPrimitive1 = Symbol.toPrimitive, _Symbol_toPrimitive2 = Symbol.toPrimitive, M1.C = class { + [_Symbol_toPrimitive](x) {} + [_Symbol_isConcatSpreadable]() {} + get [_Symbol_toPrimitive1]() {} + set [_Symbol_toPrimitive2](x) {} +}; diff --git a/crates/swc/tests/tsc-references/symbolProperty49.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty49.2.minified.js index cd53a684f468..1c75b68312b9 100644 --- a/crates/swc/tests/tsc-references/symbolProperty49.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty49.2.minified.js @@ -1,6 +1,3 @@ //// [symbolProperty49.ts] -var M; -!function(M) { - var Symbol; - Symbol.iterator, M.Symbol = Symbol; -}(M || (M = {})); +var M, M1, Symbol; +M1 = M || (M = {}), Symbol.iterator, M1.Symbol = Symbol; diff --git a/crates/swc/tests/tsc-references/thisAndSuperInStaticMembers2(target=es2015).2.minified.js b/crates/swc/tests/tsc-references/thisAndSuperInStaticMembers2(target=es2015).2.minified.js index f9b5f4eab421..e2e8de6df37a 100644 --- a/crates/swc/tests/tsc-references/thisAndSuperInStaticMembers2(target=es2015).2.minified.js +++ b/crates/swc/tests/tsc-references/thisAndSuperInStaticMembers2(target=es2015).2.minified.js @@ -1,4 +1,5 @@ //// [thisAndSuperInStaticMembers2.ts] +var _tmp; import { _ as _extends } from "@swc/helpers/_/_extends"; import { _ as _get } from "@swc/helpers/_/_get"; import { _ as _get_prototype_of } from "@swc/helpers/_/_get_prototype_of"; @@ -20,9 +21,6 @@ C.x = void 0, C.y1 = C.x, C.y2 = C.x(), C.y3 = null == C ? void 0 : C.x(), C.y4 x: 0 }, C.z12 = { x: _update(_get_prototype_of(C), "a", C, !0)._ = 0 } = { x: 0 -}, (()=>{ - var _tmp; - C.z13 = (_tmp = { - x: 0 - }, _update(_get_prototype_of(C), "a", C, !0)._ = _extends({}, _object_destructuring_empty(_tmp)), _tmp); -})(), C.z14 = ++_update(_get_prototype_of(C), "a", C, !0)._, C.z15 = --_update(_get_prototype_of(C), "a", C, !0)._, C.z16 = ++_update(_get_prototype_of(C), "a", C, !0)._, C.z17 = _update(_get_prototype_of(C), "a", C, !0)._++, C.z18 = _get(_get_prototype_of(C), "a", C)``; +}, C.z13 = (_tmp = { + x: 0 +}, _update(_get_prototype_of(C), "a", C, !0)._ = _extends({}, _object_destructuring_empty(_tmp)), _tmp), C.z14 = ++_update(_get_prototype_of(C), "a", C, !0)._, C.z15 = --_update(_get_prototype_of(C), "a", C, !0)._, C.z16 = ++_update(_get_prototype_of(C), "a", C, !0)._, C.z17 = _update(_get_prototype_of(C), "a", C, !0)._++, C.z18 = _get(_get_prototype_of(C), "a", C)``; diff --git a/crates/swc/tests/tsc-references/tsxElementResolution7.2.minified.js b/crates/swc/tests/tsc-references/tsxElementResolution7.2.minified.js index 36f1ef0911d0..cb53020c9670 100644 --- a/crates/swc/tests/tsc-references/tsxElementResolution7.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxElementResolution7.2.minified.js @@ -1,9 +1,3 @@ //// [file.tsx] -var my, q; -!function(my) { - var div; - my.div = div; -}(my || (my = {})), my.div, my.other, function(q) { - var mine = my; - mine.div, mine.non; -}(q || (q = {})); +var my, q, div, mine; +(my || (my = {})).div = div, my.div, my.other, q || (q = {}), (mine = my).div, mine.non; diff --git a/crates/swc/tests/tsc-references/tsxReactEmit6.2.minified.js b/crates/swc/tests/tsc-references/tsxReactEmit6.2.minified.js index f54c95aaae90..a4c4ec2d3f78 100644 --- a/crates/swc/tests/tsc-references/tsxReactEmit6.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxReactEmit6.2.minified.js @@ -4,15 +4,9 @@ Object.defineProperty(exports, "__esModule", { value: !0 }); -var M, _object_spread = require("@swc/helpers/_/_object_spread"), _object_spread_props = require("@swc/helpers/_/_object_spread_props"); -!function(M) { - var React1; - M.React = React1; -}(M || (M = {})), function(M) { - var foo; - _object_spread_props._(_object_spread._({ - x: "" - }, foo), { - y: "" - }); -}(M || (M = {})); +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._({ + x: "" +}, foo), { + y: "" +}); diff --git a/crates/swc/tests/tsc-references/twoInterfacesDifferentRootModule.2.minified.js b/crates/swc/tests/tsc-references/twoInterfacesDifferentRootModule.2.minified.js index 740abbe04425..a457d9d93139 100644 --- a/crates/swc/tests/tsc-references/twoInterfacesDifferentRootModule.2.minified.js +++ b/crates/swc/tests/tsc-references/twoInterfacesDifferentRootModule.2.minified.js @@ -1,6 +1,3 @@ //// [twoInterfacesDifferentRootModule.ts] -var M2; -!function(M2) { - var a, b; - a.foo, a.bar, b.foo, b.bar; -}(M2 || (M2 = {})); +var M2, a, b; +M2 || (M2 = {}), a.foo, a.bar, b.foo, b.bar; diff --git a/crates/swc/tests/tsc-references/twoInterfacesDifferentRootModule2.2.minified.js b/crates/swc/tests/tsc-references/twoInterfacesDifferentRootModule2.2.minified.js index 744da2ef2477..8106e5ea5500 100644 --- a/crates/swc/tests/tsc-references/twoInterfacesDifferentRootModule2.2.minified.js +++ b/crates/swc/tests/tsc-references/twoInterfacesDifferentRootModule2.2.minified.js @@ -1,6 +1,3 @@ //// [twoInterfacesDifferentRootModule2.ts] -var M; -!function(M) { - var M2, a, b, a1, b1; - M2 || (M2 = {}), a1.foo, a1.bar, b1.foo, b1.bar, a.foo, a.bar, b.foo, b.bar; -}(M || (M = {})); +var M, M2, a, b, a1, b1; +M || (M = {}), M2 || (M2 = {}), a1.foo, a1.bar, b1.foo, b1.bar, a.foo, a.bar, b.foo, b.bar; diff --git a/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads2.2.minified.js b/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads2.2.minified.js index 9f69cac57a8e..0498446137d9 100644 --- a/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads2.2.minified.js +++ b/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads2.2.minified.js @@ -1,6 +1,3 @@ //// [twoMergedInterfacesWithDifferingOverloads2.ts] -var a, G; -a(), a(1), a(1, 2), function(G) { - var a; - a(), a(!0), a(!0, 2), a(1, !0); -}(G || (G = {})); +var a, G, a1; +a(), a(1), a(1, 2), G || (G = {}), a1(), a1(!0), a1(!0, 2), a1(1, !0); diff --git a/crates/swc/tests/tsc-references/typeArgumentsWithStringLiteralTypes01.2.minified.js b/crates/swc/tests/tsc-references/typeArgumentsWithStringLiteralTypes01.2.minified.js index d5e0d91d06a7..2669cf81d890 100644 --- a/crates/swc/tests/tsc-references/typeArgumentsWithStringLiteralTypes01.2.minified.js +++ b/crates/swc/tests/tsc-references/typeArgumentsWithStringLiteralTypes01.2.minified.js @@ -1,5 +1,5 @@ //// [typeArgumentsWithStringLiteralTypes01.ts] -var n1, n2, n3; +var n1, n2, n3, n11, a, b, c, d, e, n21, a1, b1, c1, d1, e1, n31, a2, b2, c2, d2, e2; function fun1(x, y) { return randBool() ? x : y; } @@ -10,13 +10,4 @@ function fun3() { for(var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++)args[_key] = arguments[_key]; return args[+randBool()]; } -!function(n1) { - var a = n1.a = fun1("Hello", "World"), b = n1.b = fun1("Hello", "Hello"), c = n1.c = fun2("Hello", "World"), d = n1.d = fun2("Hello", "Hello"), e = n1.e = fun3("Hello", "Hello", "World", "Foo"); - a = takeReturnString(a), b = takeReturnString(b), c = takeReturnString(c), d = takeReturnString(d), e = takeReturnString(e), a = takeReturnHello(a), b = takeReturnHello(b), c = takeReturnHello(c), d = takeReturnHello(d), e = takeReturnHello(e), a = takeReturnHelloWorld(a), b = takeReturnHelloWorld(b), c = takeReturnHelloWorld(c), d = takeReturnHelloWorld(d), takeReturnHelloWorld(e); -}(n1 || (n1 = {})), function(n2) { - var a = n2.a = fun1("Hello", "Hello"), b = n2.b = fun1("Hello", "World"), c = n2.c = fun2("Hello", "Hello"), d = n2.d = fun2("Hello", "World"), e = n2.e = fun3("Hello", "World"); - a = takeReturnString(a), b = takeReturnString(b), c = takeReturnString(c), d = takeReturnString(d), e = takeReturnString(e), a = takeReturnHello(a), b = takeReturnHello(b), c = takeReturnHello(c), d = takeReturnHello(d), e = takeReturnHello(e), a = takeReturnHelloWorld(a), b = takeReturnHelloWorld(b), c = takeReturnHelloWorld(c), d = takeReturnHelloWorld(d), takeReturnHelloWorld(e); -}(n2 || (n2 = {})), function(n3) { - var a = n3.a = fun2("Hello", "World"), b = n3.b = fun2("World", "Hello"), c = n3.c = fun2("Hello", "Hello"), d = n3.d = fun2("World", "World"), e = n3.e = fun3("Hello", "World"); - a = takeReturnString(a), b = takeReturnString(b), c = takeReturnString(c), d = takeReturnString(d), e = takeReturnString(e), a = takeReturnHello(a), b = takeReturnHello(b), c = takeReturnHello(c), d = takeReturnHello(d), e = takeReturnHello(e), a = takeReturnHelloWorld(a), b = takeReturnHelloWorld(b), c = takeReturnHelloWorld(c), d = takeReturnHelloWorld(d), takeReturnHelloWorld(e); -}(n3 || (n3 = {})); +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"), a = takeReturnString(a), b = takeReturnString(b), c = takeReturnString(c), d = takeReturnString(d), e = takeReturnString(e), a = takeReturnHello(a), b = takeReturnHello(b), c = takeReturnHello(c), d = takeReturnHello(d), e = takeReturnHello(e), 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"), a1 = takeReturnString(a1), b1 = takeReturnString(b1), c1 = takeReturnString(c1), d1 = takeReturnString(d1), e1 = takeReturnString(e1), a1 = takeReturnHello(a1), b1 = takeReturnHello(b1), c1 = takeReturnHello(c1), d1 = takeReturnHello(d1), e1 = takeReturnHello(e1), 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"), a2 = takeReturnString(a2), b2 = takeReturnString(b2), c2 = takeReturnString(c2), d2 = takeReturnString(d2), e2 = takeReturnString(e2), a2 = takeReturnHello(a2), b2 = takeReturnHello(b2), c2 = takeReturnHello(c2), d2 = takeReturnHello(d2), e2 = takeReturnHello(e2), a2 = takeReturnHelloWorld(a2), b2 = takeReturnHelloWorld(b2), c2 = takeReturnHelloWorld(c2), d2 = takeReturnHelloWorld(d2), takeReturnHelloWorld(e2); diff --git a/crates/swc/tests/tsc-references/typeFromPropertyAssignment29.2.minified.js b/crates/swc/tests/tsc-references/typeFromPropertyAssignment29.2.minified.js index c2d2b4fecd31..1675034750f7 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, ExpandoExpr = function(n) { +var Ns, ExpandoNamespace, Ns1, ExpandoExpr = function(n) { return n.toString(); }; ExpandoExpr.prop = { @@ -24,12 +24,9 @@ function ExpandoMerge(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), function(Ns) { - var ExpandoNamespace = function() {}; - ExpandoNamespace.p6 = 42, Ns.foo = function() { - return ExpandoNamespace; - }; -}(Ns || (Ns = {})); +}, 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() { + return ExpandoNamespace; +}; var ExpandoExpr2 = function(n) { return n.toString(); }; diff --git a/crates/swc/tests/tsc-references/typeFromPropertyAssignment36.2.minified.js b/crates/swc/tests/tsc-references/typeFromPropertyAssignment36.2.minified.js index e9b4aaf91680..7f2ad83cdf2b 100644 --- a/crates/swc/tests/tsc-references/typeFromPropertyAssignment36.2.minified.js +++ b/crates/swc/tests/tsc-references/typeFromPropertyAssignment36.2.minified.js @@ -1,8 +1,5 @@ //// [typeFromPropertyAssignment36.ts] function d() {} -(function(b) { - var _$d = function() {}; - return _$d.e = 12, _$d.e, b && (_$d.q = !1), _$d.q, b ? _$d.q = !1 : _$d.q = !0, _$d.q, b ? _$d.r = 1 : _$d.r = 2, _$d.r, b && (_$d.s = "hi"), _$d; -})(!0).s, d.e = 12, d.e, d.q, d.q = !0, d.q, d.r = 2, d.r; -var g = function() {}; +((_$d = function() {}).e = 12, _$d.e, _$d.q = !1, _$d.q, _$d.q = !1, _$d.q, _$d.r = 1, _$d.r, _$d.s = "hi", _$d).s, d.e = 12, d.e, d.q, d.q = !0, d.q, d.r = 2, d.r; +var _$d, g = function() {}; g.expando, g.both = 0, g.both; diff --git a/crates/swc/tests/tsc-references/typeGuardsInFunctionAndModuleBlock.2.minified.js b/crates/swc/tests/tsc-references/typeGuardsInFunctionAndModuleBlock.2.minified.js index 788730e81b52..acca28808518 100644 --- a/crates/swc/tests/tsc-references/typeGuardsInFunctionAndModuleBlock.2.minified.js +++ b/crates/swc/tests/tsc-references/typeGuardsInFunctionAndModuleBlock.2.minified.js @@ -1,9 +1,3 @@ //// [typeGuardsInFunctionAndModuleBlock.ts] -var m, m1; -!function(m) { - var x, m2; - m2 || (m2 = {}), "string" == typeof x || x.toString(); -}(m || (m = {})), function(m1) { - var x, m2, m21; - (m21 = m2 || (m2 = {})).m3 || (m21.m3 = {}), "string" == typeof x || x.toString(); -}(m1 || (m1 = {})); +var m, m1, x, m2, x1, m21, m22; +m || (m = {}), m2 || (m2 = {}), "string" == typeof x || x.toString(), m1 || (m1 = {}), (m22 = m21 || (m21 = {})).m3 || (m22.m3 = {}), "string" == typeof x1 || x1.toString(); diff --git a/crates/swc/tests/tsc-references/typeGuardsInModule.2.minified.js b/crates/swc/tests/tsc-references/typeGuardsInModule.2.minified.js index 863fd7d26c89..584c74120bd9 100644 --- a/crates/swc/tests/tsc-references/typeGuardsInModule.2.minified.js +++ b/crates/swc/tests/tsc-references/typeGuardsInModule.2.minified.js @@ -1,12 +1,3 @@ //// [typeGuardsInModule.ts] -var var1, m1, m2, m3; -!function(m1) { - var var2, var3; - "string" == typeof var1 && var1.length, "string" == typeof var2 && var2.length, m1.var3 = var3; -}(m1 || (m1 = {})), function(m2) { - var var2, var3, m3, m31, var4, var5; - m31 = m3 || (m3 = {}), "string" == typeof var1 && var1.length, "string" == typeof var2 && var2.length, "string" == typeof var4 && var4.length, m31.var5 = var5, m2.var3 = var3; -}(m2 || (m2 = {})), function(m3) { - var m4, var2, var3; - m4 = m3.m4 || (m3.m4 = {}), "string" == typeof var1 && var1.length, "string" == typeof var2 && var2.length, m4.var3 = var3; -}(m3 || (m3 = {})); +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; diff --git a/crates/swc/tests/tsc-references/typeofOperatorWithAnyOtherType.2.minified.js b/crates/swc/tests/tsc-references/typeofOperatorWithAnyOtherType.2.minified.js index b5f956eb34f5..4db76f70b1f7 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithAnyOtherType.2.minified.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithAnyOtherType.2.minified.js @@ -1,7 +1,7 @@ //// [typeofOperatorWithAnyOtherType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _type_of } from "@swc/helpers/_/_type_of"; -var ANY, ANY1, obj, M, ANY2 = [ +var n, ANY, ANY1, obj, M, ANY2 = [ "", "" ], obj1 = { @@ -15,9 +15,6 @@ var A = function() { } return A.foo = function() {}, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; 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))), 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.2.minified.js b/crates/swc/tests/tsc-references/typeofOperatorWithBooleanType.2.minified.js index ea001e4eba51..50bd717590e9 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithBooleanType.2.minified.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithBooleanType.2.minified.js @@ -4,7 +4,7 @@ import { _ as _type_of } from "@swc/helpers/_/_type_of"; function foo() { return !0; } -var BOOLEAN, M, A = function() { +var n, BOOLEAN, M, A = function() { function A() { _class_call_check(this, A); } @@ -12,10 +12,7 @@ var BOOLEAN, M, A = function() { return !1; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; 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/typeofOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/typeofOperatorWithNumberType.2.minified.js index 2e1891a4eba6..6aa630f2cd8d 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithNumberType.2.minified.js @@ -1,7 +1,7 @@ //// [typeofOperatorWithNumberType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _type_of } from "@swc/helpers/_/_type_of"; -var NUMBER, M, NUMBER1 = [ +var n, NUMBER, M, NUMBER1 = [ 1, 2 ]; @@ -16,10 +16,7 @@ var A = function() { return 1; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; 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.2.minified.js b/crates/swc/tests/tsc-references/typeofOperatorWithStringType.2.minified.js index 3fd3b6116208..3b723686445b 100644 --- a/crates/swc/tests/tsc-references/typeofOperatorWithStringType.2.minified.js +++ b/crates/swc/tests/tsc-references/typeofOperatorWithStringType.2.minified.js @@ -1,7 +1,7 @@ //// [typeofOperatorWithStringType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _type_of } from "@swc/helpers/_/_type_of"; -var STRING, M, STRING1 = [ +var n, STRING, M, STRING1 = [ "", "abc" ]; @@ -16,10 +16,7 @@ var A = function() { return ""; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; 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/voidOperatorWithAnyOtherType.2.minified.js b/crates/swc/tests/tsc-references/voidOperatorWithAnyOtherType.2.minified.js index b3b20a69dcf5..4b043fb544b1 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithAnyOtherType.2.minified.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithAnyOtherType.2.minified.js @@ -1,14 +1,11 @@ //// [voidOperatorWithAnyOtherType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var M, A = function() { +var n, M, A = function() { function A() { _class_call_check(this, A); } return A.foo = function() {}, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/voidOperatorWithBooleanType.2.minified.js b/crates/swc/tests/tsc-references/voidOperatorWithBooleanType.2.minified.js index 846607800a2a..949804eefe19 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithBooleanType.2.minified.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithBooleanType.2.minified.js @@ -1,6 +1,6 @@ //// [voidOperatorWithBooleanType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var M, A = function() { +var n, M, A = function() { function A() { _class_call_check(this, A); } @@ -8,9 +8,6 @@ var M, A = function() { return !1; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; var objA = new A(); objA.a, M.n, A.foo(), objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/voidOperatorWithNumberType.2.minified.js b/crates/swc/tests/tsc-references/voidOperatorWithNumberType.2.minified.js index 766c676ed82e..4bf49e2beeed 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithNumberType.2.minified.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithNumberType.2.minified.js @@ -1,6 +1,6 @@ //// [voidOperatorWithNumberType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var M, A = function() { +var M, n, A = function() { function A() { _class_call_check(this, A); } @@ -8,9 +8,6 @@ var M, A = function() { return 1; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; 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.2.minified.js b/crates/swc/tests/tsc-references/voidOperatorWithStringType.2.minified.js index cd38ab504649..f250e616ae5e 100644 --- a/crates/swc/tests/tsc-references/voidOperatorWithStringType.2.minified.js +++ b/crates/swc/tests/tsc-references/voidOperatorWithStringType.2.minified.js @@ -1,6 +1,6 @@ //// [voidOperatorWithStringType.ts] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; -var STRING, M, A = function() { +var STRING, M, n, A = function() { function A() { _class_call_check(this, A); } @@ -8,9 +8,6 @@ var STRING, M, A = function() { return ""; }, A; }(); -!function(M) { - var n; - M.n = n; -}(M || (M = {})); +(M || (M = {})).n = n; var objA = new A(); objA.a, M.n, A.foo(), STRING.charAt(0), objA.a, M.n; From 56ab990c4391e34697f0db466b18c0de1d0afd11 Mon Sep 17 00:00:00 2001 From: austaras Date: Fri, 21 Jul 2023 16:32:08 +0800 Subject: [PATCH 3/3] correct pr id --- crates/swc_ecma_minifier/tests/fixture/pr/{7688 => 7690}/input.js | 0 .../swc_ecma_minifier/tests/fixture/pr/{7688 => 7690}/output.js | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename crates/swc_ecma_minifier/tests/fixture/pr/{7688 => 7690}/input.js (100%) rename crates/swc_ecma_minifier/tests/fixture/pr/{7688 => 7690}/output.js (100%) diff --git a/crates/swc_ecma_minifier/tests/fixture/pr/7688/input.js b/crates/swc_ecma_minifier/tests/fixture/pr/7690/input.js similarity index 100% rename from crates/swc_ecma_minifier/tests/fixture/pr/7688/input.js rename to crates/swc_ecma_minifier/tests/fixture/pr/7690/input.js diff --git a/crates/swc_ecma_minifier/tests/fixture/pr/7688/output.js b/crates/swc_ecma_minifier/tests/fixture/pr/7690/output.js similarity index 100% rename from crates/swc_ecma_minifier/tests/fixture/pr/7688/output.js rename to crates/swc_ecma_minifier/tests/fixture/pr/7690/output.js