Skip to content

Commit

Permalink
fix: TS plugin shouldn't remove #privateField! (#14890)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu committed Aug 30, 2022
1 parent 2626f18 commit 7ddad47
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/babel-plugin-transform-typescript/src/index.ts
Expand Up @@ -124,7 +124,11 @@ export default declare((api, opts: Options) => {
if (!process.env.BABEL_8_BREAKING) {
// keep the definitely assigned fields only when `allowDeclareFields` (equivalent of
// Typescript's `useDefineForClassFields`) is true
if (!allowDeclareFields && !node.decorators) {
if (
!allowDeclareFields &&
!node.decorators &&
!t.isClassPrivateProperty(node)
) {
path.remove();
}
}
Expand Down
@@ -1,3 +1,5 @@
class A {
x!;

#y!;
}
@@ -1,3 +1,4 @@
class A {
x;
#y;
}
@@ -1,3 +1,5 @@
class A {
x!;

#y!;
}
@@ -1 +1,3 @@
class A {}
class A {
#y;
}

0 comments on commit 7ddad47

Please sign in to comment.