From d565eca976a01c7353358647d0772c5d10abcc6f Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 8 Aug 2017 18:51:57 -0700 Subject: [PATCH] Don't enable class properties just because "typescript" plugin is enabled (#666) --- src/parser/statement.js | 7 +++---- test/fixtures/typescript/class/options.json | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 test/fixtures/typescript/class/options.json diff --git a/src/parser/statement.js b/src/parser/statement.js index bd3c35857b..8478373c47 100644 --- a/src/parser/statement.js +++ b/src/parser/statement.js @@ -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 { diff --git a/test/fixtures/typescript/class/options.json b/test/fixtures/typescript/class/options.json new file mode 100644 index 0000000000..9f3a0c2c0f --- /dev/null +++ b/test/fixtures/typescript/class/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "plugins": ["typescript", "classProperties"] +}