Strip TypeScript class properties without value assigned (#956)

Co-authored-by: 강동윤 <kdy1997.dev@gmail.com>
This commit is contained in:
LongYinan 2020-08-11 00:58:45 +08:00 committed by GitHub
parent dde9defbe4
commit 4ab3c58f6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 3 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "swc_ecma_transforms"
version = "0.19.3"
version = "0.19.4"
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
license = "Apache-2.0/MIT"
repository = "https://github.com/swc-project/swc.git"

View File

@ -388,6 +388,8 @@ impl ClassProperties {
}
};
let assigned_value = prop.value.is_some();
let value = prop.value.unwrap_or_else(|| undefined(prop_span));
let value = if prop.is_static {
value
@ -427,7 +429,7 @@ impl ClassProperties {
}
.into_stmt(),
);
} else {
} else if assigned_value {
constructor_exprs.push(Box::new(Expr::Assign(AssignExpr {
span: DUMMY_SP,
left: (PatOrExpr::Expr(Box::new(

View File

@ -762,6 +762,9 @@ test!(
"class A extends B {
foo = 'foo'
b = this.a;
declare1
declare2!: string
constructor(private readonly a: string, readonly c, private d: number = 1) {
super()

View File

@ -1,6 +1,6 @@
{
"name": "@swc/core",
"version": "1.2.17",
"version": "1.2.18",
"description": "Super-fast alternative for babel",
"main": "./index.js",
"author": "강동윤 <kdy1997.dev@gmail.com>",