mirror of
https://github.com/swc-project/swc.git
synced 2024-11-27 13:38:33 +03:00
fix(es/transforms/typescript): Remove declare
d class properties (#2530)
swc_ecma_transforms_typescript: - `strip`: Remove class properties with `declare` keyword.
This commit is contained in:
parent
6876b1b26c
commit
693181ee6a
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -1141,9 +1141,9 @@ checksum = "9fbe11972c601a48aa12a0e2aa032e9e251655ce6c6836cac26e5c0b3b5a5dcc"
|
||||
|
||||
[[package]]
|
||||
name = "napi-derive"
|
||||
version = "1.1.0"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e7ed160148f94ee17936f00288029cb0cfb37c08bbace9f514f735dcd869ed7"
|
||||
checksum = "4d57bc36513971ab3c60e5af84092662fb1b2fa686d0ef4aadab0d0fb6414bb9"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -1531,9 +1531,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.21"
|
||||
version = "0.3.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10e2fcbb64ecbe64c8e040a386c3104d384583af58b956d870aaaf229df6e66d"
|
||||
checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f"
|
||||
|
||||
[[package]]
|
||||
name = "pmutil"
|
||||
@ -1548,9 +1548,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.14"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3ca011bd0129ff4ae15cd04c4eef202cadf6c51c21e47aba319b4e0501db741"
|
||||
checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba"
|
||||
|
||||
[[package]]
|
||||
name = "precomputed-hash"
|
||||
@ -2984,7 +2984,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms_typescript"
|
||||
version = "0.56.0"
|
||||
version = "0.56.1"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"swc_atoms 0.2.9",
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_transforms_typescript"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.56.0"
|
||||
version = "0.56.1"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
@ -366,6 +366,7 @@ where
|
||||
|
||||
class.body.retain(|c| match c {
|
||||
ClassMember::Constructor(Constructor { body: None, .. }) => false,
|
||||
ClassMember::ClassProp(ClassProp { declare: true, .. }) => false,
|
||||
_ => true,
|
||||
});
|
||||
|
||||
|
@ -4140,6 +4140,42 @@ to!(
|
||||
"
|
||||
);
|
||||
|
||||
test_with_config!(
|
||||
deno_12532_declare_class_prop,
|
||||
strip::Config {
|
||||
use_define_for_class_fields: true,
|
||||
no_empty_export: true,
|
||||
..Default::default()
|
||||
},
|
||||
"
|
||||
export class Foo {
|
||||
x: number;
|
||||
constructor(x: number) {
|
||||
this.x = x;
|
||||
}
|
||||
}
|
||||
export class Bar extends Foo {
|
||||
declare x: 123;
|
||||
constructor() {
|
||||
super(123);
|
||||
}
|
||||
}
|
||||
",
|
||||
"
|
||||
export class Foo {
|
||||
x;
|
||||
constructor(x){
|
||||
this.x = x;
|
||||
}
|
||||
}
|
||||
export class Bar extends Foo {
|
||||
constructor() {
|
||||
super(123);
|
||||
}
|
||||
}
|
||||
"
|
||||
);
|
||||
|
||||
#[testing::fixture("tests/fixture/**/input.ts")]
|
||||
#[testing::fixture("tests/fixture/**/input.tsx")]
|
||||
fn exec(input: PathBuf) {
|
||||
|
Loading…
Reference in New Issue
Block a user