Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Properties that are abstract should not be initialized. #15344

Merged
merged 1 commit into from Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/babel-plugin-transform-typescript/src/index.ts
Expand Up @@ -160,6 +160,8 @@ export default declare((api, opts: Options) => {
path.remove();
}
}
} else if (node.abstract) {
path.remove();
} else if (!process.env.BABEL_8_BREAKING) {
if (
!allowDeclareFields &&
Expand Down
@@ -0,0 +1,3 @@
abstract class A {
abstract prop: string;
}
@@ -0,0 +1,3 @@
{
"plugins": [["transform-typescript", { "allowDeclareFields": false }]]
}
@@ -0,0 +1 @@
class A {}
@@ -0,0 +1,3 @@
abstract class A {
abstract prop: string;
}
@@ -0,0 +1,3 @@
{
"plugins": [["transform-typescript", { "allowDeclareFields": true }]]
}
@@ -0,0 +1 @@
class A {}
Expand Up @@ -4,11 +4,8 @@ class Foo {
accessor #prop3 = 1;
accessor [prop4] = 1;
accessor prop5 = 1;
accessor prop6;
accessor #p;
accessor a;
accessor aa;
accessor #s;
accessor f = 1;
accessor g;
}
Expand Up @@ -4,5 +4,4 @@ class Foo {
accessor #prop3 = 1;
accessor [prop4] = 1;
accessor prop5 = 1;
accessor f = 1;
}
Expand Up @@ -4,11 +4,8 @@ class Foo {
accessor #prop3 = 1;
accessor [prop4] = 1;
accessor prop5 = 1;
accessor prop6;
accessor #p;
accessor a;
accessor aa;
accessor #s;
accessor f = 1;
accessor g;
}