mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 06:36:08 +03:00
refactor(es): Remove settings related to privateInObject
(#6468)
This commit is contained in:
parent
40ad709523
commit
c57307d002
@ -17,7 +17,6 @@ use swc_ecma_minifier::option::{terser::TerserTopLevelOptions, MinifyOptions};
|
||||
use swc_ecma_parser::Syntax;
|
||||
use swc_ecma_transforms::{
|
||||
compat,
|
||||
compat::es2022::private_in_object,
|
||||
feature::{enable_available_feature_from_es_version, FeatureFlag},
|
||||
fixer::{fixer, paren_remover},
|
||||
helpers, hygiene,
|
||||
@ -330,7 +329,6 @@ impl<'a, 'b, P: swc_ecma_visit::Fold> PassBuilder<'a, 'b, P> {
|
||||
paren_remover(comments.map(|v| v as &dyn Comments)),
|
||||
self.fixer
|
||||
),
|
||||
Optional::new(private_in_object(), syntax.private_in_object()),
|
||||
compat_pass,
|
||||
// module / helper
|
||||
Optional::new(
|
||||
|
@ -1009,7 +1009,6 @@ impl Compiler {
|
||||
decorators: true,
|
||||
decorators_before_export: true,
|
||||
import_assertions: true,
|
||||
private_in_object: true,
|
||||
..Default::default()
|
||||
}),
|
||||
IsModule::Bool(true),
|
||||
|
12
crates/swc/tests/fixture/issues-6xxx/6373/input/.swcrc
Normal file
12
crates/swc/tests/fixture/issues-6xxx/6373/input/.swcrc
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "ecmascript"
|
||||
},
|
||||
"target": "es5"
|
||||
},
|
||||
"module": {
|
||||
"type": "es6"
|
||||
},
|
||||
"isModule": true
|
||||
}
|
1
crates/swc/tests/fixture/issues-6xxx/6373/input/input.js
Normal file
1
crates/swc/tests/fixture/issues-6xxx/6373/input/input.js
Normal file
@ -0,0 +1 @@
|
||||
class x { static #y = #y in x ; }
|
@ -0,0 +1,9 @@
|
||||
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
|
||||
var x = function x() {
|
||||
"use strict";
|
||||
_class_call_check(this, x);
|
||||
};
|
||||
var _y = {
|
||||
writable: true,
|
||||
value: x === x
|
||||
};
|
@ -1,10 +1,9 @@
|
||||
//// [privateNameInInExpressionUnused.ts]
|
||||
var _brand_check_brand = new WeakSet();
|
||||
class Foo {
|
||||
#unused;
|
||||
#brand = void _brand_check_brand.add(this);
|
||||
#brand;
|
||||
isFoo(v) {
|
||||
// This should count as using/reading '#brand'
|
||||
return _brand_check_brand.has(v);
|
||||
return #brand in v;
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +1 @@
|
||||
//// [privateNameInInExpressionUnused.ts]
|
||||
new WeakSet();
|
||||
|
@ -238,15 +238,6 @@ impl Syntax {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn private_in_object(self) -> bool {
|
||||
match self {
|
||||
Syntax::Es(EsConfig {
|
||||
private_in_object, ..
|
||||
}) => private_in_object,
|
||||
Syntax::Typescript(_) => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn allow_super_outside_method(self) -> bool {
|
||||
match self {
|
||||
Syntax::Es(EsConfig {
|
||||
@ -321,9 +312,6 @@ pub struct EsConfig {
|
||||
#[serde(default)]
|
||||
pub import_assertions: bool,
|
||||
|
||||
#[serde(default, rename = "privateInObject")]
|
||||
pub private_in_object: bool,
|
||||
|
||||
#[serde(default, rename = "allowSuperOutsideMethod")]
|
||||
pub allow_super_outside_method: bool,
|
||||
|
||||
|
@ -487,7 +487,7 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
}
|
||||
|
||||
if self.input.syntax().private_in_object() && eat!(self, '#') {
|
||||
if eat!(self, '#') {
|
||||
let id = self.parse_ident_name()?;
|
||||
return Ok(Box::new(Expr::PrivateName(PrivateName {
|
||||
span: span!(self, start),
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
x Unexpected token `#`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
|
||||
| for template literal, (, or an identifier
|
||||
x Expected ident
|
||||
,-[$DIR/tests/test262-parser/fail/c3731145e0e65d1d.js:1:1]
|
||||
1 | #=
|
||||
: ^
|
||||
: ^
|
||||
`----
|
||||
|
@ -2,7 +2,6 @@ use std::{fs::read_to_string, path::PathBuf};
|
||||
|
||||
use serde::Deserialize;
|
||||
use swc_common::{chain, Mark};
|
||||
use swc_ecma_parser::{EsConfig, Syntax};
|
||||
use swc_ecma_transforms_base::pass::noop;
|
||||
use swc_ecma_transforms_compat::{
|
||||
es2015::{arrow, classes, new_target::new_target},
|
||||
@ -96,10 +95,7 @@ fn fixture(input: PathBuf) {
|
||||
|
||||
let output = input.parent().unwrap().join("output.js");
|
||||
test_fixture(
|
||||
Syntax::Es(EsConfig {
|
||||
private_in_object: true,
|
||||
..Default::default()
|
||||
}),
|
||||
Default::default(),
|
||||
&|t| get_passes(t, &options.plugins),
|
||||
&input,
|
||||
&output,
|
||||
|
@ -2,7 +2,6 @@ use std::path::PathBuf;
|
||||
|
||||
use serde::Deserialize;
|
||||
use swc_common::chain;
|
||||
use swc_ecma_parser::{EsConfig, Syntax};
|
||||
use swc_ecma_transforms_base::pass::noop;
|
||||
use swc_ecma_transforms_compat::{
|
||||
es2015::classes,
|
||||
@ -32,10 +31,7 @@ fn fixture(input: PathBuf) {
|
||||
|
||||
let output = parent.join("output.js");
|
||||
test_fixture(
|
||||
Syntax::Es(EsConfig {
|
||||
private_in_object: true,
|
||||
..Default::default()
|
||||
}),
|
||||
Default::default(),
|
||||
&|t| {
|
||||
let mut pass: Box<dyn Fold> = Box::new(noop());
|
||||
|
||||
|
@ -236,7 +236,6 @@ fn identity(entry: PathBuf) {
|
||||
decorators: true,
|
||||
decorators_before_export: true,
|
||||
export_default_from: true,
|
||||
private_in_object: true,
|
||||
import_assertions: true,
|
||||
allow_super_outside_method: true,
|
||||
..Default::default()
|
||||
|
Loading…
Reference in New Issue
Block a user