fix(es/typescript): Don't generate class field for abstract properties (#6174)

This commit is contained in:
Austaras 2022-10-16 23:49:37 +08:00 committed by GitHub
parent 55a836ac82
commit 9d93b6cd85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 5 deletions

View File

@ -4,9 +4,6 @@ class A {
foo() {
console.log(this.x);
}
constructor(){
_define_property(this, "x", void 0);
}
}
class B extends A {
constructor(...args){

View File

@ -1,6 +1,5 @@
//// [abstractProperty.ts]
class A {
x;
foo() {
console.log(this.x);
}

View File

@ -1972,7 +1972,12 @@ where
{
false
}
ClassMember::ClassProp(ClassProp { declare: true, .. }) => false,
ClassMember::ClassProp(
ClassProp { declare: true, .. }
| ClassProp {
is_abstract: true, ..
},
) => false,
ClassMember::ClassProp(ClassProp {
value: None,
ref decorators,

View File

@ -4637,3 +4637,21 @@ test!(
foo();
"#
);
test_with_config!(
issue_6023,
strip::Config {
use_define_for_class_fields: true,
..Default::default()
},
"
abstract class Shape {
abstract height: number;
abstract width: number;
}
",
"
class Shape {
}
"
);