Don't enable class properties just because "typescript" plugin is enabled (#666)

This commit is contained in:
Andy 2017-08-08 18:51:57 -07:00 committed by Brian Ng
parent 00ad6d8310
commit d565eca976
2 changed files with 7 additions and 4 deletions

View File

@ -1145,18 +1145,17 @@ export default class StatementParser extends ExpressionParser {
}
parseClassProperty(node: N.ClassProperty): N.ClassProperty {
const hasPlugin =
this.hasPlugin("classProperties") || this.hasPlugin("typescript");
const noPluginMsg =
"You can only use Class Properties when the 'classProperties' plugin is enabled.";
if (!node.typeAnnotation && !hasPlugin) {
if (!node.typeAnnotation && !this.hasPlugin("classProperties")) {
this.raise(node.start, noPluginMsg);
}
this.state.inClassProperty = true;
if (this.match(tt.eq)) {
if (!hasPlugin) this.raise(this.state.start, noPluginMsg);
if (!this.hasPlugin("classProperties"))
this.raise(this.state.start, noPluginMsg);
this.next();
node.value = this.parseMaybeAssign();
} else {

View File

@ -0,0 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
}