Skip to content

Commit

Permalink
TypeScript: Preserve decorated definite class properties (#11129)
Browse files Browse the repository at this point in the history
* test: update fixture with decorated definite class property

* fix: don't remove decorated definite class properties
  • Loading branch information
jamescdavis committed Feb 27, 2020
1 parent bb97823 commit a5f6329
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/babel-plugin-transform-typescript/src/index.js
Expand Up @@ -74,7 +74,9 @@ export default declare(
);
}

path.remove();
if (!node.decorators) {
path.remove();
}
} else if (!allowDeclareFields && !node.value && !node.decorators) {
path.remove();
}
Expand All @@ -84,6 +86,7 @@ export default declare(
if (node.readonly) node.readonly = null;
if (node.optional) node.optional = null;
if (node.typeAnnotation) node.typeAnnotation = null;
if (node.definite) node.definite = null;
},
method({ node }) {
if (node.accessibility) node.accessibility = null;
Expand Down
Expand Up @@ -5,4 +5,5 @@ class C {
@foo d: number;
@foo e: number = 3;
f!: number;
@foo g!: number;
}
Expand Up @@ -5,4 +5,6 @@ class C {
d;
@foo
e = 3;
@foo
g;
}

0 comments on commit a5f6329

Please sign in to comment.