mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 02:06:08 +03:00
fix(es): Use paren_remover
pass (#5753)
**Description:** We now apply the paren_remover pass before applying other transforms. **Related issue:** - Closes #5652 - Closes #5752
This commit is contained in:
parent
0fe604817a
commit
9c998d4406
@ -91,10 +91,14 @@ impl Comments for SwcComments {
|
||||
}
|
||||
|
||||
fn move_leading(&self, from: BytePos, to: BytePos) {
|
||||
let cmt = self.leading.remove(&from);
|
||||
let cmt = self.take_leading(from);
|
||||
|
||||
if let Some(cmt) = cmt {
|
||||
self.leading.entry(to).or_default().extend(cmt.1);
|
||||
if let Some(mut cmt) = cmt {
|
||||
if from < to && self.has_leading(to) {
|
||||
cmt.extend(self.take_leading(to).unwrap());
|
||||
}
|
||||
|
||||
self.add_leading_comments(to, cmt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,10 +123,14 @@ impl Comments for SwcComments {
|
||||
}
|
||||
|
||||
fn move_trailing(&self, from: BytePos, to: BytePos) {
|
||||
let cmt = self.trailing.remove(&from);
|
||||
let cmt = self.take_trailing(from);
|
||||
|
||||
if let Some(cmt) = cmt {
|
||||
self.trailing.entry(to).or_default().extend(cmt.1);
|
||||
if let Some(mut cmt) = cmt {
|
||||
if from < to && self.has_trailing(to) {
|
||||
cmt.extend(self.take_trailing(to).unwrap());
|
||||
}
|
||||
|
||||
self.add_trailing_comments(to, cmt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,8 @@ use swc_ecma_transforms::{
|
||||
compat,
|
||||
compat::es2022::private_in_object,
|
||||
feature::{enable_available_feature_from_es_version, FeatureFlag},
|
||||
fixer, helpers, hygiene,
|
||||
fixer::{fixer, paren_remover},
|
||||
helpers, hygiene,
|
||||
hygiene::hygiene_with_config,
|
||||
modules,
|
||||
optimization::const_modules,
|
||||
@ -324,6 +325,10 @@ impl<'a, 'b, P: swc_ecma_visit::Fold> PassBuilder<'a, 'b, P> {
|
||||
|
||||
chain!(
|
||||
self.pass,
|
||||
Optional::new(
|
||||
paren_remover(comments.map(|v| v as &dyn Comments)),
|
||||
self.fixer
|
||||
),
|
||||
Optional::new(private_in_object(), syntax.private_in_object()),
|
||||
compat_pass,
|
||||
// module / helper
|
||||
|
@ -22,7 +22,7 @@ use swc_cached::regex::CachedRegex;
|
||||
use swc_common::{
|
||||
chain,
|
||||
collections::{AHashMap, AHashSet},
|
||||
comments::SingleThreadedComments,
|
||||
comments::{Comments, SingleThreadedComments},
|
||||
errors::Handler,
|
||||
plugin::metadata::TransformPluginMetadataContext,
|
||||
FileName, Mark, SourceMap, SyntaxContext,
|
||||
|
2
crates/swc/tests/fixture/issues-5xxx/5752/input/index.ts
Normal file
2
crates/swc/tests/fixture/issues-5xxx/5752/input/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
let foo: { bar?: number } = { bar: 123 }
|
||||
delete (foo.bar);
|
@ -0,0 +1,4 @@
|
||||
var foo = {
|
||||
bar: 123
|
||||
};
|
||||
delete foo.bar;
|
@ -382,12 +382,12 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
|
||||
}
|
||||
} else {
|
||||
// By default, we never revalidate.
|
||||
(data).revalidate = false;
|
||||
data.revalidate = false;
|
||||
}
|
||||
props.pageProps = Object.assign({}, props.pageProps, "props" in data ? data.props : undefined);
|
||||
// pass up revalidate and props for export
|
||||
// TODO: change this to a different passing mechanism
|
||||
(renderOpts).revalidate = "revalidate" in data ? data.revalidate : undefined;
|
||||
renderOpts.revalidate = "revalidate" in data ? data.revalidate : undefined;
|
||||
renderOpts.pageData = props;
|
||||
// this must come after revalidate is added to renderOpts
|
||||
if (renderOpts.isNotFound) {
|
||||
|
@ -344,8 +344,8 @@ fn issue_528() {
|
||||
//foo
|
||||
a,
|
||||
//bar
|
||||
(//baz
|
||||
b)
|
||||
//baz
|
||||
b
|
||||
];"
|
||||
);
|
||||
}
|
||||
|
@ -2,6 +2,6 @@
|
||||
// Must emit as (x + 1) * 3
|
||||
(x + 1) * 3;
|
||||
// Should still emit as x.y
|
||||
(x).y;
|
||||
x.y;
|
||||
// Emit as new (x())
|
||||
new (x());
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @param {A} a
|
||||
* @returns { asserts a is B }
|
||||
*/ var foo = function(a) {
|
||||
if (/** @type { B } */ (a).y !== 0) throw TypeError();
|
||||
if (/** @type { B } */ a.y !== 0) throw TypeError();
|
||||
return undefined;
|
||||
};
|
||||
export var main = function() {
|
||||
|
@ -11,7 +11,7 @@ var x3;
|
||||
x3.a = value;
|
||||
x3["a"] = value;
|
||||
// parentheses, the contained expression is reference
|
||||
(x1) = value;
|
||||
x1 = value;
|
||||
function fn2(x4) {
|
||||
x4 = value;
|
||||
}
|
||||
|
@ -96,13 +96,13 @@ var B = /*#__PURE__*/ function(A) {
|
||||
// element access (assign)
|
||||
_superprop_set("x", f);
|
||||
// destructuring assign with property access
|
||||
(ref = {
|
||||
ref = {
|
||||
f: f
|
||||
}, _superprop_update_x._ = ref.f, ref);
|
||||
}, _superprop_update_x._ = ref.f, ref;
|
||||
// destructuring assign with element access
|
||||
(ref1 = {
|
||||
ref1 = {
|
||||
f: f
|
||||
}, _superprop_update("x")._ = ref1.f, ref1);
|
||||
}, _superprop_update("x")._ = ref1.f, ref1;
|
||||
return [
|
||||
2
|
||||
];
|
||||
|
@ -62,15 +62,15 @@ class B extends A {
|
||||
f
|
||||
});
|
||||
// property access in arrow
|
||||
(()=>_superprop_get_x().call(_this));
|
||||
()=>_superprop_get_x().call(_this);
|
||||
// element access in arrow
|
||||
(()=>_superprop_get("x").call(_this));
|
||||
/*#__PURE__*/ // property access in async arrow
|
||||
_async_to_generator(function*() {
|
||||
()=>_superprop_get("x").call(_this);
|
||||
// property access in async arrow
|
||||
/*#__PURE__*/ _async_to_generator(function*() {
|
||||
return _superprop_get_x().call(_this);
|
||||
});
|
||||
/*#__PURE__*/ // element access in async arrow
|
||||
_async_to_generator(function*() {
|
||||
// element access in async arrow
|
||||
/*#__PURE__*/ _async_to_generator(function*() {
|
||||
return _superprop_get("x").call(_this);
|
||||
});
|
||||
})();
|
||||
@ -83,9 +83,9 @@ class B extends A {
|
||||
// property access (read)
|
||||
const a = _superprop_get_x();
|
||||
// property access in arrow
|
||||
(()=>_superprop_get_x().call(_this));
|
||||
/*#__PURE__*/ // property access in async arrow
|
||||
_async_to_generator(function*() {
|
||||
()=>_superprop_get_x().call(_this);
|
||||
// property access in async arrow
|
||||
/*#__PURE__*/ _async_to_generator(function*() {
|
||||
return _superprop_get_x().call(_this);
|
||||
});
|
||||
})();
|
||||
@ -108,9 +108,9 @@ class B extends A {
|
||||
f
|
||||
});
|
||||
// property access (assign) in arrow
|
||||
(()=>_superprop_set_x(f));
|
||||
/*#__PURE__*/ // property access (assign) in async arrow
|
||||
_async_to_generator(function*() {
|
||||
()=>_superprop_set_x(f);
|
||||
// property access (assign) in async arrow
|
||||
/*#__PURE__*/ _async_to_generator(function*() {
|
||||
return _superprop_set_x(f);
|
||||
});
|
||||
})();
|
||||
@ -123,9 +123,9 @@ class B extends A {
|
||||
// element access (read)
|
||||
const a = _superprop_get("x");
|
||||
// element access in arrow
|
||||
(()=>_superprop_get("x").call(_this));
|
||||
/*#__PURE__*/ // element access in async arrow
|
||||
_async_to_generator(function*() {
|
||||
()=>_superprop_get("x").call(_this);
|
||||
// element access in async arrow
|
||||
/*#__PURE__*/ _async_to_generator(function*() {
|
||||
return _superprop_get("x").call(_this);
|
||||
});
|
||||
})();
|
||||
@ -148,9 +148,9 @@ class B extends A {
|
||||
f
|
||||
});
|
||||
// element access (assign) in arrow
|
||||
(()=>_superprop_set("x", f));
|
||||
/*#__PURE__*/ // element access (assign) in async arrow
|
||||
_async_to_generator(function*() {
|
||||
()=>_superprop_set("x", f);
|
||||
// element access (assign) in async arrow
|
||||
/*#__PURE__*/ _async_to_generator(function*() {
|
||||
return _superprop_set("x", f);
|
||||
});
|
||||
})();
|
||||
@ -163,9 +163,9 @@ class B extends A {
|
||||
// property access (read)
|
||||
const a = _superprop_get_x();
|
||||
// property access in arrow
|
||||
(()=>_superprop_get_x().call(_this));
|
||||
/*#__PURE__*/ // property access in async arrow
|
||||
_async_to_generator(function*() {
|
||||
()=>_superprop_get_x().call(_this);
|
||||
// property access in async arrow
|
||||
/*#__PURE__*/ _async_to_generator(function*() {
|
||||
return _superprop_get_x().call(_this);
|
||||
});
|
||||
})();
|
||||
@ -188,9 +188,9 @@ class B extends A {
|
||||
f
|
||||
});
|
||||
// property access (assign) in arrow
|
||||
(()=>_superprop_set_x(f));
|
||||
/*#__PURE__*/ // property access (assign) in async arrow
|
||||
_async_to_generator(function*() {
|
||||
()=>_superprop_set_x(f);
|
||||
// property access (assign) in async arrow
|
||||
/*#__PURE__*/ _async_to_generator(function*() {
|
||||
return _superprop_set_x(f);
|
||||
});
|
||||
})();
|
||||
@ -203,9 +203,9 @@ class B extends A {
|
||||
// element access (read)
|
||||
const a = _superprop_get("x");
|
||||
// element access in arrow
|
||||
(()=>_superprop_get("x").call(_this));
|
||||
/*#__PURE__*/ // element access in async arrow
|
||||
_async_to_generator(function*() {
|
||||
()=>_superprop_get("x").call(_this);
|
||||
// element access in async arrow
|
||||
/*#__PURE__*/ _async_to_generator(function*() {
|
||||
return _superprop_get("x").call(_this);
|
||||
});
|
||||
})();
|
||||
@ -228,9 +228,9 @@ class B extends A {
|
||||
f
|
||||
});
|
||||
// element access (assign) in arrow
|
||||
(()=>_superprop_set("x", f));
|
||||
/*#__PURE__*/ // element access (assign) in async arrow
|
||||
_async_to_generator(function*() {
|
||||
()=>_superprop_set("x", f);
|
||||
// element access (assign) in async arrow
|
||||
/*#__PURE__*/ _async_to_generator(function*() {
|
||||
return _superprop_set("x", f);
|
||||
});
|
||||
})();
|
||||
|
@ -5,7 +5,7 @@ import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
|
||||
import _inherits from "@swc/helpers/src/_inherits.mjs";
|
||||
import _to_consumable_array from "@swc/helpers/src/_to_consumable_array.mjs";
|
||||
import _create_super from "@swc/helpers/src/_create_super.mjs";
|
||||
var _obj, _obj1, _obj2, _obj3, _instance, _obj4, _instance1, _instance2, _instance3;
|
||||
var _obj, _obj1, _obj2, _obj3, _instance, _obj4, _instance1, _obj5, _obj6, _obj7, _obj8, _instance2, _obj9, _instance3, _instance4, _instance5, _instance6;
|
||||
function foo(x, y) {
|
||||
for(var _len = arguments.length, z = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
||||
z[_key - 2] = arguments[_key];
|
||||
@ -58,48 +58,48 @@ obj.foo(1, 2, "abc");
|
||||
"abc"
|
||||
]));
|
||||
obj.foo(1, 2, "abc");
|
||||
obj.foo.apply(this, [
|
||||
(_obj5 = obj).foo.apply(_obj5, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a)));
|
||||
obj.foo.apply(this, [
|
||||
(_obj6 = obj).foo.apply(_obj6, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a), [
|
||||
"abc"
|
||||
]));
|
||||
obj.foo.apply(this, [
|
||||
(_obj7 = obj).foo.apply(_obj7, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a))).foo(1, 2, "abc");
|
||||
obj.foo.apply(this, [
|
||||
(_instance2 = (_obj8 = obj).foo.apply(_obj8, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a))).foo.apply(this, [
|
||||
].concat(_to_consumable_array(a)))).foo.apply(_instance2, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a)));
|
||||
obj.foo.apply(this, [
|
||||
(_instance3 = (_obj9 = obj).foo.apply(_obj9, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a))).foo.apply(this, [
|
||||
].concat(_to_consumable_array(a)))).foo.apply(_instance3, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a), [
|
||||
"abc"
|
||||
]));
|
||||
xa[1].foo(1, 2, "abc");
|
||||
(_instance2 = xa[1]).foo.apply(_instance2, [
|
||||
(_instance4 = xa[1]).foo.apply(_instance4, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a)));
|
||||
(_instance3 = xa[1]).foo.apply(_instance3, [
|
||||
(_instance5 = xa[1]).foo.apply(_instance5, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a), [
|
||||
"abc"
|
||||
]));
|
||||
xa[1].foo.apply(this, [
|
||||
(_instance6 = xa[1]).foo.apply(_instance6, [
|
||||
1,
|
||||
2,
|
||||
"abc"
|
||||
|
@ -1,5 +1,5 @@
|
||||
//// [callWithSpread.ts]
|
||||
var _obj, _obj1, _obj2, _obj3, _instance, _obj4, _instance1, _instance2, _instance3, a, obj, xa;
|
||||
var _obj, _obj1, _obj2, _obj3, _instance, _obj4, _instance1, _obj5, _obj6, _obj7, _obj8, _instance2, _obj9, _instance3, _instance4, _instance5, _instance6, a, obj, xa;
|
||||
import _to_consumable_array from "@swc/helpers/src/_to_consumable_array.mjs";
|
||||
function foo(x, y) {
|
||||
for(var _len = arguments.length, z = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++)z[_key - 2] = arguments[_key];
|
||||
@ -37,40 +37,40 @@ foo(1, 2, "abc"), foo.apply(void 0, [
|
||||
2
|
||||
].concat(_to_consumable_array(a), [
|
||||
"abc"
|
||||
])), obj.foo(1, 2, "abc"), obj.foo.apply(this, [
|
||||
])), obj.foo(1, 2, "abc"), (_obj5 = obj).foo.apply(_obj5, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a))), obj.foo.apply(this, [
|
||||
].concat(_to_consumable_array(a))), (_obj6 = obj).foo.apply(_obj6, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a), [
|
||||
"abc"
|
||||
])), obj.foo.apply(this, [
|
||||
])), (_obj7 = obj).foo.apply(_obj7, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a))).foo(1, 2, "abc"), obj.foo.apply(this, [
|
||||
].concat(_to_consumable_array(a))).foo(1, 2, "abc"), (_instance2 = (_obj8 = obj).foo.apply(_obj8, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a))).foo.apply(this, [
|
||||
].concat(_to_consumable_array(a)))).foo.apply(_instance2, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a))), obj.foo.apply(this, [
|
||||
].concat(_to_consumable_array(a))), (_instance3 = (_obj9 = obj).foo.apply(_obj9, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a))).foo.apply(this, [
|
||||
].concat(_to_consumable_array(a)))).foo.apply(_instance3, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a), [
|
||||
"abc"
|
||||
])), xa[1].foo(1, 2, "abc"), (_instance2 = xa[1]).foo.apply(_instance2, [
|
||||
])), xa[1].foo(1, 2, "abc"), (_instance4 = xa[1]).foo.apply(_instance4, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a))), (_instance3 = xa[1]).foo.apply(_instance3, [
|
||||
].concat(_to_consumable_array(a))), (_instance5 = xa[1]).foo.apply(_instance5, [
|
||||
1,
|
||||
2
|
||||
].concat(_to_consumable_array(a), [
|
||||
"abc"
|
||||
])), xa[1].foo.apply(this, [
|
||||
])), (_instance6 = xa[1]).foo.apply(_instance6, [
|
||||
1,
|
||||
2,
|
||||
"abc"
|
||||
|
@ -46,7 +46,7 @@ var needsExemplar = function() {
|
||||
var _ = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : x;
|
||||
return void 0;
|
||||
};
|
||||
var expected = /** @type {{name: string, readonly middleInit: string, readonly lastName: string, zip: number, readonly houseNumber: number, zipStr: string}} */ (/** @type {*} */ (null));
|
||||
var expected = /** @type {{name: string, readonly middleInit: string, readonly lastName: string, zip: number, readonly houseNumber: number, zipStr: string}} */ /** @type {*} */ null;
|
||||
/**
|
||||
*
|
||||
* @param {typeof returnExemplar} a
|
||||
|
@ -6,7 +6,7 @@ var obj = {
|
||||
Object.defineProperty(exports, "thing", obj);
|
||||
/**
|
||||
* @type {string}
|
||||
*/ var str = /** @type {string} */ ("other");
|
||||
*/ var str = /** @type {string} */ "other";
|
||||
Object.defineProperty(exports, str, {
|
||||
value: 42,
|
||||
writable: true
|
||||
|
@ -1,5 +1,5 @@
|
||||
//// [classWithStaticFieldInParameterBindingPattern.ts]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
var _class;
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
(({ [(_class = class {
|
||||
}, _class.x = 1, _class).x]: b = "" })=>{})();
|
||||
|
@ -1,7 +1,7 @@
|
||||
//// [classWithStaticFieldInParameterBindingPattern.ts]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
|
||||
var _class;
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
(function(param) {
|
||||
var tmp = param[(_class = function _class() {
|
||||
"use strict";
|
||||
|
@ -1,5 +1,5 @@
|
||||
//// [classWithStaticFieldInParameterInitializer.ts]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
var _class;
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
((b = (_class = class {
|
||||
}, _class.x = 1, _class))=>{})();
|
||||
|
@ -1,7 +1,7 @@
|
||||
//// [classWithStaticFieldInParameterInitializer.ts]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
|
||||
var _class;
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
(function() {
|
||||
var b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : (_class = function _class() {
|
||||
"use strict";
|
||||
|
@ -15,7 +15,7 @@ x3.a += value;
|
||||
x3["a"] *= value;
|
||||
x3["a"] += value;
|
||||
// parentheses, the contained expression is reference
|
||||
(x1) *= value;
|
||||
x1 *= value;
|
||||
x1 += value;
|
||||
function fn2(x4) {
|
||||
x4 *= value;
|
||||
|
@ -12,14 +12,12 @@ var ref = x3.a;
|
||||
x3.a = Math.pow(ref, value);
|
||||
var ref1 = x3["a"];
|
||||
x3["a"] = Math.pow(ref1, value);
|
||||
var // parentheses, the contained expression is reference
|
||||
ref2 = (x1);
|
||||
(x1) = Math.pow(ref2, value);
|
||||
// parentheses, the contained expression is reference
|
||||
x1 = Math.pow(x1, value);
|
||||
function fn2(x4) {
|
||||
var ref = x4;
|
||||
x4 = Math.pow(ref, value);
|
||||
x4 = Math.pow(x4, value);
|
||||
}
|
||||
var ref3 = x3.a;
|
||||
x3.a = Math.pow(ref3, value);
|
||||
var ref4 = x3["a"];
|
||||
x3["a"] = Math.pow(ref4, value);
|
||||
var ref2 = x3.a;
|
||||
x3.a = Math.pow(ref2, value);
|
||||
var ref3 = x3["a"];
|
||||
x3["a"] = Math.pow(ref3, value);
|
||||
|
@ -3,10 +3,8 @@ x1 = Math.pow(x1, value);
|
||||
var value, x1, x3, ref = x3.a;
|
||||
x3.a = Math.pow(ref, value);
|
||||
var ref1 = x3.a;
|
||||
x3.a = Math.pow(ref1, value);
|
||||
var ref2 = x1;
|
||||
x1 = Math.pow(ref2, value);
|
||||
x3.a = Math.pow(ref1, value), x1 = Math.pow(x1, value);
|
||||
var ref2 = x3.a;
|
||||
x3.a = Math.pow(ref2, value);
|
||||
var ref3 = x3.a;
|
||||
x3.a = Math.pow(ref3, value);
|
||||
var ref4 = x3.a;
|
||||
x3.a = Math.pow(ref4, value);
|
||||
|
@ -3,7 +3,7 @@ var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, ref10, ref11, ref
|
||||
o1 === null || o1 === void 0 ? void 0 : delete o1.b;
|
||||
delete (o1 === null || o1 === void 0 ? void 0 : o1.b);
|
||||
o2 === null || o2 === void 0 ? void 0 : delete o2.b.c;
|
||||
delete (o2 === null || o2 === void 0 ? void 0 : o2.b.c);
|
||||
o2 === null || o2 === void 0 ? void 0 : delete o2.b.c;
|
||||
(ref = o3.b) === null || ref === void 0 ? void 0 : delete ref.c;
|
||||
delete ((ref1 = o3.b) === null || ref1 === void 0 ? void 0 : ref1.c);
|
||||
(ref3 = (ref2 = o4.b) === null || ref2 === void 0 ? void 0 : ref2.c.d) === null || ref3 === void 0 ? void 0 : delete ref3.e;
|
||||
|
@ -1,3 +1,3 @@
|
||||
//// [deleteChain.ts]
|
||||
var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, ref10, ref11, ref12, ref13, ref14, ref15;
|
||||
null == o1 || delete o1.b, delete (null == o1 ? void 0 : o1.b), null == o2 || delete o2.b.c, delete (null == o2 ? void 0 : o2.b.c), null === (ref = o3.b) || void 0 === ref || delete ref.c, delete (null === (ref1 = o3.b) || void 0 === ref1 ? void 0 : ref1.c), null === (ref3 = null === (ref2 = o4.b) || void 0 === ref2 ? void 0 : ref2.c.d) || void 0 === ref3 || delete ref3.e, null === (ref5 = null === (ref4 = o4.b) || void 0 === ref4 ? void 0 : ref4.c.d) || void 0 === ref5 || delete ref5.e, delete (null === (ref7 = null === (ref6 = o4.b) || void 0 === ref6 ? void 0 : ref6.c.d) || void 0 === ref7 ? void 0 : ref7.e), null === (ref9 = null === (ref8 = o5.b) || void 0 === ref8 ? void 0 : ref8.call(o5).c.d) || void 0 === ref9 || delete ref9.e, delete (null === (ref11 = null === (ref10 = o5.b) || void 0 === ref10 ? void 0 : ref10.call(o5).c.d) || void 0 === ref11 ? void 0 : ref11.e), null === (ref13 = null === (ref12 = o6.b) || void 0 === ref12 ? void 0 : ref12.c.d) || void 0 === ref13 || delete ref13.e, delete (null === (ref15 = null === (ref14 = o6.b) || void 0 === ref14 ? void 0 : ref14.c.d) || void 0 === ref15 ? void 0 : ref15.e);
|
||||
null == o1 || delete o1.b, delete (null == o1 ? void 0 : o1.b), null == o2 || delete o2.b.c, null == o2 || delete o2.b.c, null === (ref = o3.b) || void 0 === ref || delete ref.c, delete (null === (ref1 = o3.b) || void 0 === ref1 ? void 0 : ref1.c), null === (ref3 = null === (ref2 = o4.b) || void 0 === ref2 ? void 0 : ref2.c.d) || void 0 === ref3 || delete ref3.e, null === (ref5 = null === (ref4 = o4.b) || void 0 === ref4 ? void 0 : ref4.c.d) || void 0 === ref5 || delete ref5.e, delete (null === (ref7 = null === (ref6 = o4.b) || void 0 === ref6 ? void 0 : ref6.c.d) || void 0 === ref7 ? void 0 : ref7.e), null === (ref9 = null === (ref8 = o5.b) || void 0 === ref8 ? void 0 : ref8.call(o5).c.d) || void 0 === ref9 || delete ref9.e, delete (null === (ref11 = null === (ref10 = o5.b) || void 0 === ref10 ? void 0 : ref10.call(o5).c.d) || void 0 === ref11 ? void 0 : ref11.e), null === (ref13 = null === (ref12 = o6.b) || void 0 === ref12 ? void 0 : ref12.c.d) || void 0 === ref13 || delete ref13.e, delete (null === (ref15 = null === (ref14 = o6.b) || void 0 === ref14 ? void 0 : ref14.c.d) || void 0 === ref15 ? void 0 : ref15.e);
|
||||
|
@ -281,9 +281,9 @@ var DerivedWithParenthesis = /*#__PURE__*/ function(Base) {
|
||||
function DerivedWithParenthesis() {
|
||||
_class_call_check(this, DerivedWithParenthesis);
|
||||
var _this;
|
||||
var _temp;
|
||||
_temp = _this = _super.call(this), _this.prop = true, _temp;
|
||||
return _possible_constructor_return(_this);
|
||||
_this = _super.call(this);
|
||||
_this.prop = true;
|
||||
return _this;
|
||||
}
|
||||
return DerivedWithParenthesis;
|
||||
}(Base);
|
||||
@ -295,9 +295,9 @@ var DerivedWithParenthesisAfterStatement = /*#__PURE__*/ function(Base) {
|
||||
_class_call_check(this, DerivedWithParenthesisAfterStatement);
|
||||
var _this;
|
||||
_this.prop;
|
||||
var _temp;
|
||||
_temp = _this = _super.call(this), _this.prop = true, _temp;
|
||||
return _possible_constructor_return(_this);
|
||||
_this = _super.call(this);
|
||||
_this.prop = true;
|
||||
return _this;
|
||||
}
|
||||
return DerivedWithParenthesisAfterStatement;
|
||||
}(Base);
|
||||
@ -308,10 +308,10 @@ var DerivedWithParenthesisBeforeStatement = /*#__PURE__*/ function(Base) {
|
||||
function DerivedWithParenthesisBeforeStatement() {
|
||||
_class_call_check(this, DerivedWithParenthesisBeforeStatement);
|
||||
var _this;
|
||||
var _temp;
|
||||
_temp = _this = _super.call(this), _this.prop = true, _temp;
|
||||
_this = _super.call(this);
|
||||
_this.prop = true;
|
||||
_this.prop;
|
||||
return _possible_constructor_return(_this);
|
||||
return _this;
|
||||
}
|
||||
return DerivedWithParenthesisBeforeStatement;
|
||||
}(Base);
|
||||
|
@ -6,6 +6,6 @@ var foo = {
|
||||
var bar;
|
||||
var ref;
|
||||
// reassignment in destructuring pattern
|
||||
(ref = foo, foo = ref.foo, bar = ref.bar, ref);
|
||||
ref = foo, foo = ref.foo, bar = ref.bar, ref;
|
||||
// reassignment in subsequent var
|
||||
var foo = foo.foo, baz = foo.baz;
|
||||
|
@ -1,6 +1,6 @@
|
||||
//// [fixSignatureCaching.ts]
|
||||
// Repro from #10697
|
||||
import _instanceof from "@swc/helpers/src/_instanceof.mjs";
|
||||
// Repro from #10697
|
||||
(function(define1, undefined) {
|
||||
define1(function() {
|
||||
"use strict";
|
||||
@ -528,23 +528,23 @@ import _instanceof from "@swc/helpers/src/_instanceof.mjs";
|
||||
// Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
|
||||
// Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
|
||||
// Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
|
||||
(t.version("Android") > 2.1 && t.is("Webkit")) || // Windows Phone 7-7.5 - Tested on the HTC Surround (7.0) HTC Trophy (7.5), LG-E900 (7.5), Nokia Lumia 800
|
||||
t.version("Android") > 2.1 && t.is("Webkit") || // Windows Phone 7-7.5 - Tested on the HTC Surround (7.0) HTC Trophy (7.5), LG-E900 (7.5), Nokia Lumia 800
|
||||
t.version("Windows Phone OS") >= 7.0 || // Blackberry 7 - Tested on BlackBerry Torch 9810
|
||||
// Blackberry 6.0 - Tested on the Torch 9800 and Style 9670
|
||||
t.is("BlackBerry") && t.version("BlackBerry") >= 6.0 || // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
|
||||
t.match("Playbook.*Tablet") || // Palm WebOS (1.4-2.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0)
|
||||
(t.version("webOS") >= 1.4 && t.match("Palm|Pre|Pixi")) || // Palm WebOS 3.0 - Tested on HP TouchPad
|
||||
t.version("webOS") >= 1.4 && t.match("Palm|Pre|Pixi") || // Palm WebOS 3.0 - Tested on HP TouchPad
|
||||
t.match("hp.*TouchPad") || // Firefox Mobile (12 Beta) - Tested on Android 2.3 device
|
||||
(t.is("Firefox") && t.version("Firefox") >= 12) || // Chrome for Android - Tested on Android 4.0, 4.1 device
|
||||
(t.is("Chrome") && t.is("AndroidOS") && t.version("Android") >= 4.0) || // Skyfire 4.1 - Tested on Android 2.3 device
|
||||
(t.is("Skyfire") && t.version("Skyfire") >= 4.1 && t.is("AndroidOS") && t.version("Android") >= 2.3) || // Opera Mobile 11.5-12: Tested on Android 2.3
|
||||
(t.is("Opera") && t.version("Opera Mobi") > 11 && t.is("AndroidOS")) || // Meego 1.2 - Tested on Nokia 950 and N9
|
||||
t.is("Firefox") && t.version("Firefox") >= 12 || // Chrome for Android - Tested on Android 4.0, 4.1 device
|
||||
t.is("Chrome") && t.is("AndroidOS") && t.version("Android") >= 4.0 || // Skyfire 4.1 - Tested on Android 2.3 device
|
||||
t.is("Skyfire") && t.version("Skyfire") >= 4.1 && t.is("AndroidOS") && t.version("Android") >= 2.3 || // Opera Mobile 11.5-12: Tested on Android 2.3
|
||||
t.is("Opera") && t.version("Opera Mobi") > 11 && t.is("AndroidOS") || // Meego 1.2 - Tested on Nokia 950 and N9
|
||||
t.is("MeeGoOS") || // Tizen (pre-release) - Tested on early hardware
|
||||
t.is("Tizen") || // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
|
||||
// @todo: more tests here!
|
||||
t.is("Dolfin") && t.version("Bada") >= 2.0 || // UC Browser - Tested on Android 2.3 device
|
||||
((t.is("UC Browser") || t.is("Dolfin")) && t.version("Android") >= 2.3) || // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
|
||||
(t.match("Kindle Fire") || t.is("Kindle") && t.version("Kindle") >= 3.0) || // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
|
||||
(t.is("UC Browser") || t.is("Dolfin")) && t.version("Android") >= 2.3 || // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
|
||||
t.match("Kindle Fire") || t.is("Kindle") && t.version("Kindle") >= 3.0 || // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
|
||||
t.is("AndroidOS") && t.is("NookTablet") || // Chrome Desktop 11-21 - Tested on OS X 10.7 and Windows 7
|
||||
t.version("Chrome") >= 11 && !$isMobile || // Safari Desktop 4-5 - Tested on OS X 10.7 and Windows 7
|
||||
t.version("Safari") >= 5.0 && !$isMobile || // Firefox Desktop 4-13 - Tested on OS X 10.7 and Windows 7
|
||||
@ -556,7 +556,7 @@ import _instanceof from "@swc/helpers/src/_instanceof.mjs";
|
||||
}
|
||||
if (t.os("iOS") && t.version("iPad") < 4.3 || t.os("iOS") && t.version("iPhone") < 3.1 || t.os("iOS") && t.version("iPod") < 3.1 || // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
|
||||
t.is("Blackberry") && t.version("BlackBerry") >= 5 && t.version("BlackBerry") < 6 || //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
|
||||
(t.version("Opera Mini") >= 5.0 && t.version("Opera Mini") <= 6.5 && (t.version("Android") >= 2.3 || t.is("iOS"))) || // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
|
||||
t.version("Opera Mini") >= 5.0 && t.version("Opera Mini") <= 6.5 && (t.version("Android") >= 2.3 || t.is("iOS")) || // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
|
||||
t.match("NokiaN8|NokiaC7|N97.*Series60|Symbian/3") || // @todo: report this (tested on Nokia N71)
|
||||
t.version("Opera Mobi") >= 11 && t.is("SymbianOS")) {
|
||||
return "B";
|
||||
|
@ -55,9 +55,9 @@ var K = /*#__PURE__*/ function(_superClass) {
|
||||
}
|
||||
return K;
|
||||
}(B1());
|
||||
var C = /*#__PURE__*/ function(_superClass) {
|
||||
var C = /*#__PURE__*/ function(_anon) {
|
||||
"use strict";
|
||||
_inherits(C, _superClass);
|
||||
_inherits(C, _anon);
|
||||
var _super = _create_super(C);
|
||||
function C() {
|
||||
_class_call_check(this, C);
|
||||
|
@ -31,9 +31,9 @@ var A = function A() {
|
||||
return _class_call_check(this, _class), _super.apply(this, arguments);
|
||||
}
|
||||
return _class;
|
||||
}(A)), C = function(_superClass) {
|
||||
}(A)), C = function(_anon) {
|
||||
"use strict";
|
||||
_inherits(C, _superClass);
|
||||
_inherits(C, _anon);
|
||||
var _super = _create_super(C);
|
||||
function C() {
|
||||
return _class_call_check(this, C), _super.apply(this, arguments);
|
||||
|
@ -8,11 +8,11 @@
|
||||
//// [index.js]
|
||||
/**
|
||||
* @typedef {import("./externs")} Foo
|
||||
*/ let a = /** @type {Foo} */ (/** @type {*} */ (undefined));
|
||||
*/ let a = /** @type {Foo} */ /** @type {*} */ undefined;
|
||||
a = new Foo({
|
||||
doer: Foo.Bar
|
||||
});
|
||||
const q = /** @type {import("./externs").Bar} */ ({
|
||||
const q = /** @type {import("./externs").Bar} */ {
|
||||
doer: (q)=>q
|
||||
});
|
||||
const r = /** @type {typeof import("./externs").Bar} */ ((r)=>r);
|
||||
};
|
||||
const r = /** @type {typeof import("./externs").Bar} */ (r)=>r;
|
||||
|
@ -39,7 +39,7 @@ export var D = function D(a, b) {
|
||||
get: /**
|
||||
* @return {U}
|
||||
*/ function get() {
|
||||
return /** @type {*} */ (null);
|
||||
return /** @type {*} */ null;
|
||||
},
|
||||
set: /**
|
||||
* @param {U} _p
|
||||
@ -50,7 +50,7 @@ export var D = function D(a, b) {
|
||||
get: /**
|
||||
* @return {U}
|
||||
*/ function get() {
|
||||
return /** @type {*} */ (null);
|
||||
return /** @type {*} */ null;
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -191,7 +191,7 @@ export var M = /*#__PURE__*/ function(_superClass) {
|
||||
}
|
||||
return O;
|
||||
}(N);
|
||||
var x = /** @type {*} */ (null);
|
||||
var x = /** @type {*} */ null;
|
||||
export var VariableBase = /*#__PURE__*/ function(x) {
|
||||
"use strict";
|
||||
_inherits(VariableBase, x);
|
||||
|
@ -11,7 +11,7 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
|
||||
var Foo = function Foo() {
|
||||
"use strict";
|
||||
_class_call_check(this, Foo);
|
||||
this.a = /** @type {Foo} */ (null);
|
||||
this.a = /** @type {Foo} */ null;
|
||||
};
|
||||
export { Foo as default };
|
||||
export var X = Foo;
|
||||
@ -29,7 +29,7 @@ var Bar = /*#__PURE__*/ function(Fab) {
|
||||
_class_call_check(this, Bar);
|
||||
var _this;
|
||||
_this = _super.apply(this, arguments);
|
||||
_this.x = /** @type {Bar} */ (null);
|
||||
_this.x = /** @type {Bar} */ null;
|
||||
return _this;
|
||||
}
|
||||
return Bar;
|
||||
|
@ -13,7 +13,7 @@ Object.defineProperty(module.exports.b, "cat", {
|
||||
* @param {number} b
|
||||
* @return {string}
|
||||
*/ function d(a, b) {
|
||||
return /** @type {*} */ (null);
|
||||
return /** @type {*} */ null;
|
||||
}
|
||||
Object.defineProperty(module.exports, "d", {
|
||||
value: d
|
||||
@ -24,7 +24,7 @@ Object.defineProperty(module.exports, "d", {
|
||||
* @param {U} b
|
||||
* @return {T & U}
|
||||
*/ function e(a, b) {
|
||||
return /** @type {*} */ (null);
|
||||
return /** @type {*} */ null;
|
||||
}
|
||||
Object.defineProperty(module.exports, "e", {
|
||||
value: e
|
||||
|
@ -13,7 +13,7 @@ c.Cls = function _class() {
|
||||
* @param {number} b
|
||||
* @return {string}
|
||||
*/ export function d(a, b) {
|
||||
return /** @type {*} */ (null);
|
||||
return /** @type {*} */ null;
|
||||
}
|
||||
/**
|
||||
* @template T,U
|
||||
@ -21,7 +21,7 @@ c.Cls = function _class() {
|
||||
* @param {U} b
|
||||
* @return {T & U}
|
||||
*/ export function e(a, b) {
|
||||
return /** @type {*} */ (null);
|
||||
return /** @type {*} */ null;
|
||||
}
|
||||
/**
|
||||
* @template T
|
||||
|
@ -13,7 +13,7 @@ module.exports.c.Cls = function _class() {
|
||||
* @param {number} b
|
||||
* @return {string}
|
||||
*/ module.exports.d = function d(a, b) {
|
||||
return /** @type {*} */ (null);
|
||||
return /** @type {*} */ null;
|
||||
};
|
||||
/**
|
||||
* @template T,U
|
||||
@ -21,7 +21,7 @@ module.exports.c.Cls = function _class() {
|
||||
* @param {U} b
|
||||
* @return {T & U}
|
||||
*/ module.exports.e = function e(a, b) {
|
||||
return /** @type {*} */ (null);
|
||||
return /** @type {*} */ null;
|
||||
};
|
||||
/**
|
||||
* @template T
|
||||
|
@ -1,5 +1,6 @@
|
||||
//// [logicalAssignment3.ts]
|
||||
a.baz && (a.baz = result.baz);
|
||||
b.baz || (b.baz = result.baz);
|
||||
var ref;
|
||||
(ref = c.baz) !== null && ref !== void 0 ? ref : c.baz = result.baz;
|
||||
var _a, _b, _c;
|
||||
(_a = a).baz && (_a.baz = result.baz);
|
||||
(_b = b).baz || (_b.baz = result.baz);
|
||||
var _baz;
|
||||
(_baz = (_c = c).baz) !== null && _baz !== void 0 ? _baz : _c.baz = result.baz;
|
||||
|
@ -1,3 +1,3 @@
|
||||
//// [logicalAssignment3.ts]
|
||||
var ref;
|
||||
a.baz && (a.baz = result.baz), b.baz || (b.baz = result.baz), null !== (ref = c.baz) && void 0 !== ref || (c.baz = result.baz);
|
||||
var _a, _b, _c, _baz;
|
||||
(_a = a).baz && (_a.baz = result.baz), (_b = b).baz || (_b.baz = result.baz), null !== (_baz = (_c = c).baz) && void 0 !== _baz || (_c.baz = result.baz);
|
||||
|
@ -1,4 +1,5 @@
|
||||
//// [logicalAssignment3.ts]
|
||||
a.baz && (a.baz = result.baz);
|
||||
b.baz || (b.baz = result.baz);
|
||||
c.baz ?? (c.baz = result.baz);
|
||||
var _a, _b, _c;
|
||||
(_a = a).baz && (_a.baz = result.baz);
|
||||
(_b = b).baz || (_b.baz = result.baz);
|
||||
(_c = c).baz ?? (_c.baz = result.baz);
|
||||
|
@ -1,2 +1,3 @@
|
||||
//// [logicalAssignment3.ts]
|
||||
a.baz && (a.baz = result.baz), b.baz || (b.baz = result.baz), c.baz, c.baz = result.baz;
|
||||
var _a, _b, _c;
|
||||
(_a = a).baz && (_a.baz = result.baz), (_b = b).baz || (_b.baz = result.baz), (_c = c).baz, _c.baz = result.baz;
|
||||
|
@ -1,13 +1,13 @@
|
||||
//// [optionalChainingInTypeAssertions.ts]
|
||||
var ref, ref1, /*a1*/ ref2, /*b1*/ ref3;
|
||||
var ref, ref1, /*a1*/ /*a2*/ ref2, /*b1*/ ref3 /*b3*/ ;
|
||||
class Foo {
|
||||
m() {}
|
||||
}
|
||||
const foo = new Foo();
|
||||
(ref = foo.m) === null || ref === void 0 ? void 0 : ref();
|
||||
(ref1 = foo.m) === null || ref1 === void 0 ? void 0 : ref1();
|
||||
(ref2 = (/*a2*/ foo.m)) === null || ref2 === void 0 ? void 0 : ref2();
|
||||
(ref3 = (foo.m /*b3*/ )) === null || ref3 === void 0 ? void 0 : ref3();
|
||||
(ref = foo.m) === null || ref === void 0 ? void 0 : ref.call(foo);
|
||||
(ref1 = foo.m) === null || ref1 === void 0 ? void 0 : ref1.call(foo);
|
||||
(ref2 = foo.m) === null || ref2 === void 0 ? void 0 : ref2.call(foo);
|
||||
(ref3 = foo.m) === null || ref3 === void 0 ? void 0 : ref3.call(foo);
|
||||
// https://github.com/microsoft/TypeScript/issues/50148
|
||||
(foo === null || foo === void 0 ? void 0 : foo.m).length;
|
||||
(foo === null || foo === void 0 ? void 0 : foo.m).length;
|
||||
|
@ -3,4 +3,4 @@ var ref, ref1, ref2, ref3;
|
||||
const foo = new class {
|
||||
m() {}
|
||||
}();
|
||||
null === (ref = foo.m) || void 0 === ref || ref(), null === (ref1 = foo.m) || void 0 === ref1 || ref1(), null === (ref2 = foo.m) || void 0 === ref2 || ref2(), null === (ref3 = foo.m) || void 0 === ref3 || ref3(), (null == foo ? void 0 : foo.m).length, (null == foo ? void 0 : foo.m).length, (null == foo ? void 0 : foo.m).length, (null == foo ? void 0 : foo.m).length;
|
||||
null === (ref = foo.m) || void 0 === ref || ref.call(foo), null === (ref1 = foo.m) || void 0 === ref1 || ref1.call(foo), null === (ref2 = foo.m) || void 0 === ref2 || ref2.call(foo), null === (ref3 = foo.m) || void 0 === ref3 || ref3.call(foo), (null == foo ? void 0 : foo.m).length, (null == foo ? void 0 : foo.m).length, (null == foo ? void 0 : foo.m).length, (null == foo ? void 0 : foo.m).length;
|
||||
|
@ -5,8 +5,8 @@ class Foo {
|
||||
const foo = new Foo();
|
||||
foo.m?.();
|
||||
foo.m?.();
|
||||
/*a1*/ (/*a2*/ foo.m)?.();
|
||||
/*b1*/ (foo.m /*b3*/ )?.();
|
||||
/*a1*/ /*a2*/ foo.m?.();
|
||||
/*b1*/ foo.m /*b3*/ ?.();
|
||||
// https://github.com/microsoft/TypeScript/issues/50148
|
||||
(foo?.m).length;
|
||||
(foo?.m).length;
|
||||
|
@ -2,4 +2,4 @@
|
||||
o1(o1 !== null && o1 !== void 0 ? o1 : 1);
|
||||
(o2 === null || o2 === void 0 ? void 0 : o2.b)(o1 !== null && o1 !== void 0 ? o1 : 1);
|
||||
(o3 === null || o3 === void 0 ? void 0 : o3.b())(o1 !== null && o1 !== void 0 ? o1 : 1);
|
||||
(o4 === null || o4 === void 0 ? void 0 : o4.b().c)(o1 !== null && o1 !== void 0 ? o1 : 1);
|
||||
o4 === null || o4 === void 0 ? void 0 : o4.b().c(o1 !== null && o1 !== void 0 ? o1 : 1);
|
||||
|
@ -1,2 +1,2 @@
|
||||
//// [parentheses.ts]
|
||||
o1(null != o1 ? o1 : 1), (null == o2 ? void 0 : o2.b)(null != o1 ? o1 : 1), (null == o3 ? void 0 : o3.b())(null != o1 ? o1 : 1), (null == o4 ? void 0 : o4.b().c)(null != o1 ? o1 : 1);
|
||||
o1(null != o1 ? o1 : 1), (null == o2 ? void 0 : o2.b)(null != o1 ? o1 : 1), (null == o3 ? void 0 : o3.b())(null != o1 ? o1 : 1), null == o4 || o4.b().c(null != o1 ? o1 : 1);
|
||||
|
@ -6,7 +6,7 @@ import _class_private_field_update from "@swc/helpers/src/_class_private_field_u
|
||||
var _test = /*#__PURE__*/ new WeakMap();
|
||||
class C {
|
||||
test() {
|
||||
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _ref10, _ref11, _ref12, _ref13;
|
||||
var _ref, _ref1, _ref2, _ref3;
|
||||
_class_private_field_update(this.getInstance(), _test).value++;
|
||||
_class_private_field_update(this.getInstance(), _test).value--;
|
||||
++_class_private_field_update(this.getInstance(), _test).value;
|
||||
@ -17,16 +17,16 @@ class C {
|
||||
const d = --_class_private_field_update(this.getInstance(), _test).value;
|
||||
for(_class_private_field_set(this.getInstance(), _test, 0); _class_private_field_get(_ref = this.getInstance(), _test) < 10; ++_class_private_field_update(this.getInstance(), _test).value){}
|
||||
for(_class_private_field_set(this.getInstance(), _test, 0); _class_private_field_get(_ref1 = this.getInstance(), _test) < 10; _class_private_field_update(this.getInstance(), _test).value++){}
|
||||
_class_private_field_get(_ref2 = this.getInstance(), _test)++;
|
||||
_class_private_field_get(_ref3 = this.getInstance(), _test)--;
|
||||
++_class_private_field_get(_ref4 = this.getInstance(), _test);
|
||||
--_class_private_field_get(_ref5 = this.getInstance(), _test);
|
||||
const e = _class_private_field_get(_ref6 = this.getInstance(), _test)++;
|
||||
const f = _class_private_field_get(_ref7 = this.getInstance(), _test)--;
|
||||
const g = ++_class_private_field_get(_ref8 = this.getInstance(), _test);
|
||||
const h = --_class_private_field_get(_ref9 = this.getInstance(), _test);
|
||||
for(_class_private_field_set(this.getInstance(), _test, 0); _class_private_field_get(_ref10 = this.getInstance(), _test) < 10; ++_class_private_field_get(_ref11 = this.getInstance(), _test)){}
|
||||
for(_class_private_field_set(this.getInstance(), _test, 0); _class_private_field_get(_ref12 = this.getInstance(), _test) < 10; _class_private_field_get(_ref13 = this.getInstance(), _test)++){}
|
||||
_class_private_field_update(this.getInstance(), _test).value++;
|
||||
_class_private_field_update(this.getInstance(), _test).value--;
|
||||
++_class_private_field_update(this.getInstance(), _test).value;
|
||||
--_class_private_field_update(this.getInstance(), _test).value;
|
||||
const e = _class_private_field_update(this.getInstance(), _test).value++;
|
||||
const f = _class_private_field_update(this.getInstance(), _test).value--;
|
||||
const g = ++_class_private_field_update(this.getInstance(), _test).value;
|
||||
const h = --_class_private_field_update(this.getInstance(), _test).value;
|
||||
for(_class_private_field_set(this.getInstance(), _test, 0); _class_private_field_get(_ref2 = this.getInstance(), _test) < 10; ++_class_private_field_update(this.getInstance(), _test).value){}
|
||||
for(_class_private_field_set(this.getInstance(), _test, 0); _class_private_field_get(_ref3 = this.getInstance(), _test) < 10; _class_private_field_update(this.getInstance(), _test).value++){}
|
||||
}
|
||||
getInstance() {
|
||||
return new C();
|
||||
@ -46,15 +46,15 @@ class C {
|
||||
const d = --_class_private_field_update(this, _test).value;
|
||||
for(_class_private_field_set(this, _test, 0); _class_private_field_get(this, _test) < 10; ++_class_private_field_update(this, _test).value){}
|
||||
for(_class_private_field_set(this, _test, 0); _class_private_field_get(this, _test) < 10; _class_private_field_update(this, _test).value++){}
|
||||
_class_private_field_get(this, _test)++;
|
||||
_class_private_field_get(this, _test)--;
|
||||
++_class_private_field_get(this, _test);
|
||||
--_class_private_field_get(this, _test);
|
||||
const e = _class_private_field_get(this, _test)++;
|
||||
const f = _class_private_field_get(this, _test)--;
|
||||
const g = ++_class_private_field_get(this, _test);
|
||||
const h = --_class_private_field_get(this, _test);
|
||||
for(_class_private_field_set(this, _test, 0); _class_private_field_get(this, _test) < 10; ++_class_private_field_get(this, _test)){}
|
||||
for(_class_private_field_set(this, _test, 0); _class_private_field_get(this, _test) < 10; _class_private_field_get(this, _test)++){}
|
||||
_class_private_field_update(this, _test).value++;
|
||||
_class_private_field_update(this, _test).value--;
|
||||
++_class_private_field_update(this, _test).value;
|
||||
--_class_private_field_update(this, _test).value;
|
||||
const e = _class_private_field_update(this, _test).value++;
|
||||
const f = _class_private_field_update(this, _test).value--;
|
||||
const g = ++_class_private_field_update(this, _test).value;
|
||||
const h = --_class_private_field_update(this, _test).value;
|
||||
for(_class_private_field_set(this, _test, 0); _class_private_field_get(this, _test) < 10; ++_class_private_field_update(this, _test).value){}
|
||||
for(_class_private_field_set(this, _test, 0); _class_private_field_get(this, _test) < 10; _class_private_field_update(this, _test).value++){}
|
||||
}
|
||||
}
|
||||
|
@ -139,16 +139,16 @@ var __9 = {
|
||||
writable: true,
|
||||
value: (()=>{
|
||||
(class Reflect {
|
||||
}) // no collision
|
||||
;
|
||||
} // no collision
|
||||
);
|
||||
super.w();
|
||||
})()
|
||||
};
|
||||
var __10 = {
|
||||
writable: true,
|
||||
value: (()=>{
|
||||
(function Reflect() {}) // no collision
|
||||
;
|
||||
(function Reflect() {} // no collision
|
||||
);
|
||||
super.w();
|
||||
})()
|
||||
};
|
||||
|
@ -139,16 +139,16 @@ var __9 = {
|
||||
writable: true,
|
||||
value: (()=>{
|
||||
(class Reflect {
|
||||
}) // no collision
|
||||
;
|
||||
} // no collision
|
||||
);
|
||||
super.w();
|
||||
})()
|
||||
};
|
||||
var __10 = {
|
||||
writable: true,
|
||||
value: (()=>{
|
||||
(function Reflect() {}) // no collision
|
||||
;
|
||||
(function Reflect() {} // no collision
|
||||
);
|
||||
super.w();
|
||||
})()
|
||||
};
|
||||
|
@ -107,13 +107,13 @@ class C extends B {
|
||||
}
|
||||
static{
|
||||
(class Reflect {
|
||||
}) // no collision
|
||||
;
|
||||
} // no collision
|
||||
);
|
||||
super.w();
|
||||
}
|
||||
static{
|
||||
(function Reflect() {}) // no collision
|
||||
;
|
||||
(function Reflect() {} // no collision
|
||||
);
|
||||
super.w();
|
||||
}
|
||||
}
|
||||
|
@ -165,16 +165,16 @@ var __9 = {
|
||||
(function Reflect() {
|
||||
"use strict";
|
||||
_class_call_check(this, Reflect);
|
||||
}) // no collision
|
||||
;
|
||||
} // no collision
|
||||
);
|
||||
_superprop_get_w().call(_this);
|
||||
}()
|
||||
};
|
||||
var __10 = {
|
||||
writable: true,
|
||||
value: function() {
|
||||
(function Reflect() {}) // no collision
|
||||
;
|
||||
(function Reflect() {} // no collision
|
||||
);
|
||||
_superprop_get_w().call(_this);
|
||||
}()
|
||||
};
|
||||
|
@ -18,9 +18,9 @@ var validCommentedPlainSingle = "nope";
|
||||
var invalidPlain = "nope";
|
||||
var validPlain = "nope";
|
||||
// @ts-expect-error
|
||||
(({
|
||||
({
|
||||
a: true
|
||||
}).a === false); // <-- compiles (as expected via comment)
|
||||
}).a === false; // <-- compiles (as expected via comment)
|
||||
({
|
||||
a: true
|
||||
}).a === false; // Should error
|
||||
|
@ -50,21 +50,21 @@ function foo10(x) {
|
||||
// Mixing typeguards
|
||||
var b;
|
||||
return typeof x === "string" ? x // string
|
||||
: (b = x) // x is number | boolean
|
||||
&& typeof x === "number" && x.toString(); // x is number
|
||||
: (b = x // x is number | boolean
|
||||
) && typeof x === "number" && x.toString(); // x is number
|
||||
}
|
||||
function foo11(x) {
|
||||
// Mixing typeguards
|
||||
var b;
|
||||
return typeof x === "string" ? x // string
|
||||
: (b = x) // x is number | boolean
|
||||
&& typeof x === "number" && (x = 10) // assignment to x
|
||||
&& x; // x is number
|
||||
: (b = x // x is number | boolean
|
||||
) && typeof x === "number" && (x = 10 // assignment to x
|
||||
) && x; // x is number
|
||||
}
|
||||
function foo12(x) {
|
||||
// Mixing typeguards
|
||||
var b;
|
||||
return typeof x === "string" ? (x = 10) && x.toString().length // number
|
||||
: (b = x) // x is number | boolean
|
||||
&& typeof x === "number" && x; // x is number
|
||||
: (b = x // x is number | boolean
|
||||
) && typeof x === "number" && x; // x is number
|
||||
}
|
||||
|
@ -29,14 +29,14 @@ function foo6(x) {
|
||||
return typeof x !== "string" // string | number | boolean
|
||||
&& (typeof x !== "number" // number | boolean
|
||||
? x // boolean
|
||||
: x === 10) // number
|
||||
;
|
||||
: x === 10 // number
|
||||
);
|
||||
}
|
||||
function foo7(x) {
|
||||
var y;
|
||||
var z;
|
||||
// Mixing typeguard narrowing
|
||||
return typeof x !== "string" && (z = x) // number | boolean
|
||||
&& (typeof x === "number" ? (x = 10) && x.toString() // x is number
|
||||
return typeof x !== "string" && (z = x // number | boolean
|
||||
) && (typeof x === "number" ? (x = 10) && x.toString() // x is number
|
||||
: (y = x) && x.toString()); // x is boolean
|
||||
}
|
||||
|
@ -30,14 +30,14 @@ function foo6(x) {
|
||||
return typeof x === "string" // string | number | boolean
|
||||
|| (typeof x !== "number" // number | boolean
|
||||
? x // boolean
|
||||
: x === 10) // number
|
||||
;
|
||||
: x === 10 // number
|
||||
);
|
||||
}
|
||||
function foo7(x) {
|
||||
var y;
|
||||
var z;
|
||||
// Mixing typeguard narrowing
|
||||
return typeof x === "string" || (z = x) // number | boolean
|
||||
|| (typeof x === "number" ? (x = 10) && x.toString() // number | boolean | string
|
||||
return typeof x === "string" || (z = x // number | boolean
|
||||
) || (typeof x === "number" ? (x = 10) && x.toString() // number | boolean | string
|
||||
: (y = x) && x.toString()); // number | boolean | string
|
||||
}
|
||||
|
@ -379,10 +379,14 @@ impl Comments for SingleThreadedComments {
|
||||
}
|
||||
|
||||
fn move_leading(&self, from: BytePos, to: BytePos) {
|
||||
let cmt = self.leading.borrow_mut().remove(&from);
|
||||
let cmt = self.take_leading(from);
|
||||
|
||||
if let Some(cmt) = cmt {
|
||||
self.leading.borrow_mut().entry(to).or_default().extend(cmt);
|
||||
if let Some(mut cmt) = cmt {
|
||||
if from < to && self.has_leading(to) {
|
||||
cmt.extend(self.take_leading(to).unwrap());
|
||||
}
|
||||
|
||||
self.add_leading_comments(to, cmt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,14 +419,14 @@ impl Comments for SingleThreadedComments {
|
||||
}
|
||||
|
||||
fn move_trailing(&self, from: BytePos, to: BytePos) {
|
||||
let cmt = self.trailing.borrow_mut().remove(&from);
|
||||
let cmt = self.take_trailing(from);
|
||||
|
||||
if let Some(cmt) = cmt {
|
||||
self.trailing
|
||||
.borrow_mut()
|
||||
.entry(to)
|
||||
.or_default()
|
||||
.extend(cmt);
|
||||
if let Some(mut cmt) = cmt {
|
||||
if from < to && self.has_trailing(to) {
|
||||
cmt.extend(self.take_trailing(to).unwrap());
|
||||
}
|
||||
|
||||
self.add_trailing_comments(to, cmt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,21 +294,16 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
|
||||
if self.input.syntax().typescript() && op == op!("delete") {
|
||||
fn is_valid_arg(e: &Expr) -> bool {
|
||||
match e {
|
||||
Expr::Member(..)
|
||||
| Expr::OptChain(OptChainExpr {
|
||||
base: OptChainBase::Member(..),
|
||||
..
|
||||
}) => true,
|
||||
Expr::Paren(expr) => is_valid_arg(expr.expr.unwrap_parens()),
|
||||
_ => false,
|
||||
match arg.unwrap_parens() {
|
||||
Expr::Member(..)
|
||||
| Expr::OptChain(OptChainExpr {
|
||||
base: OptChainBase::Member(..),
|
||||
..
|
||||
}) => {}
|
||||
expr => {
|
||||
self.emit_err(expr.span(), SyntaxError::TS2703);
|
||||
}
|
||||
}
|
||||
|
||||
if !is_valid_arg(&arg) {
|
||||
self.emit_err(arg.unwrap_parens().span(), SyntaxError::TS2703);
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(Box::new(Expr::Unary(UnaryExpr {
|
||||
|
@ -1,5 +1,6 @@
|
||||
use rustc_hash::FxHashMap;
|
||||
use swc_atoms::js_word;
|
||||
use swc_common::{collections::AHashMap, comments::Comments, util::take::Take, Span, Spanned};
|
||||
use swc_common::{comments::Comments, util::take::Take, Span, Spanned};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
|
||||
|
||||
@ -36,7 +37,7 @@ struct Fixer<'a> {
|
||||
///
|
||||
/// Key is span of inner expression, and value is span of the paren
|
||||
/// expression.
|
||||
span_map: AHashMap<Span, Span>,
|
||||
span_map: FxHashMap<Span, Span>,
|
||||
|
||||
in_for_stmt_head: bool,
|
||||
|
||||
@ -929,20 +930,6 @@ impl Fixer<'_> {
|
||||
|
||||
/// Removes paren
|
||||
fn unwrap_expr(&mut self, e: &mut Expr) {
|
||||
if let Expr::Paren(paren) = &*e {
|
||||
match &*paren.expr {
|
||||
Expr::Call(..) | Expr::Fn(..) => {}
|
||||
_ => {
|
||||
let inner_span = paren.span;
|
||||
if let Some(comments) = self.comments {
|
||||
if comments.has_leading(inner_span.lo) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
match e {
|
||||
Expr::Seq(SeqExpr { exprs, .. }) if exprs.len() == 1 => {
|
||||
self.unwrap_expr(exprs.last_mut().unwrap());
|
||||
|
@ -391,12 +391,12 @@ export async function renderToHTML(req, res, pathname, query, renderOpts) {
|
||||
}
|
||||
} else {
|
||||
// By default, we never revalidate.
|
||||
(data).revalidate = false;
|
||||
data.revalidate = false;
|
||||
}
|
||||
props.pageProps = Object.assign({}, props.pageProps, "props" in data ? data.props : undefined);
|
||||
// pass up revalidate and props for export
|
||||
// TODO: change this to a different passing mechanism
|
||||
(renderOpts).revalidate = "revalidate" in data ? data.revalidate : undefined;
|
||||
renderOpts.revalidate = "revalidate" in data ? data.revalidate : undefined;
|
||||
renderOpts.pageData = props;
|
||||
// this must come after revalidate is added to renderOpts
|
||||
if (renderOpts.isNotFound) {
|
||||
|
@ -36,10 +36,14 @@ impl Comments for SwcComments {
|
||||
}
|
||||
|
||||
fn move_leading(&self, from: BytePos, to: BytePos) {
|
||||
let cmt = self.leading.remove(&from);
|
||||
let cmt = self.take_leading(from);
|
||||
|
||||
if let Some(cmt) = cmt {
|
||||
self.leading.entry(to).or_default().extend(cmt.1);
|
||||
if let Some(mut cmt) = cmt {
|
||||
if from < to && self.has_leading(to) {
|
||||
cmt.extend(self.take_leading(to).unwrap());
|
||||
}
|
||||
|
||||
self.add_leading_comments(to, cmt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,10 +72,14 @@ impl Comments for SwcComments {
|
||||
}
|
||||
|
||||
fn move_trailing(&self, from: BytePos, to: BytePos) {
|
||||
let cmt = self.trailing.remove(&from);
|
||||
let cmt = self.take_trailing(from);
|
||||
|
||||
if let Some(cmt) = cmt {
|
||||
self.trailing.entry(to).or_default().extend(cmt.1);
|
||||
if let Some(mut cmt) = cmt {
|
||||
if from < to && self.has_trailing(to) {
|
||||
cmt.extend(self.take_trailing(to).unwrap());
|
||||
}
|
||||
|
||||
self.add_trailing_comments(to, cmt);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user