TypeScript: Preserve decorated definite class properties (#11129)

* test: update fixture with decorated definite class property

* fix: don't remove decorated definite class properties
This commit is contained in:
James C. Davis 2020-02-27 15:31:23 -05:00 committed by GitHub
parent bb97823abd
commit a5f63299eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -74,7 +74,9 @@ export default declare(
);
}
if (!node.decorators) {
path.remove();
}
} else if (!allowDeclareFields && !node.value && !node.decorators) {
path.remove();
}
@ -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;

View File

@ -5,4 +5,5 @@ class C {
@foo d: number;
@foo e: number = 3;
f!: number;
@foo g!: number;
}

View File

@ -5,4 +5,6 @@ class C {
d;
@foo
e = 3;
@foo
g;
}