Don't parse class properties without initializers when classProperties is disabled and Flow is enabled (#300)
This commit is contained in:
parent
56a92ccec1
commit
aec4beff0c
@ -751,8 +751,13 @@ pp.parseClassBody = function (node) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pp.parseClassProperty = function (node) {
|
pp.parseClassProperty = function (node) {
|
||||||
|
const noPluginMsg = "You can only use Class Properties when the 'classProperties' plugin is enabled.";
|
||||||
|
if (!node.typeAnnotation && !this.hasPlugin("classProperties")) {
|
||||||
|
this.raise(node.start, noPluginMsg);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.match(tt.eq)) {
|
if (this.match(tt.eq)) {
|
||||||
if (!this.hasPlugin("classProperties")) this.unexpected();
|
if (!this.hasPlugin("classProperties")) this.raise(this.state.start, noPluginMsg);
|
||||||
this.next();
|
this.next();
|
||||||
node.value = this.parseMaybeAssign();
|
node.value = this.parseMaybeAssign();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
3
test/fixtures/experimental/class-properties/with-initializer-and-type-no-plugin/actual.js
vendored
Normal file
3
test/fixtures/experimental/class-properties/with-initializer-and-type-no-plugin/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
class Foo {
|
||||||
|
bar: string = 'bizz';
|
||||||
|
}
|
||||||
4
test/fixtures/experimental/class-properties/with-initializer-and-type-no-plugin/options.json
vendored
Normal file
4
test/fixtures/experimental/class-properties/with-initializer-and-type-no-plugin/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["flow"],
|
||||||
|
"throws": "You can only use Class Properties when the 'classProperties' plugin is enabled. (2:14)"
|
||||||
|
}
|
||||||
3
test/fixtures/experimental/class-properties/with-initializer-missing-plugin/actual.js
vendored
Normal file
3
test/fixtures/experimental/class-properties/with-initializer-missing-plugin/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
class Foo {
|
||||||
|
bar = 'bizz';
|
||||||
|
}
|
||||||
3
test/fixtures/experimental/class-properties/with-initializer-missing-plugin/options.json
vendored
Normal file
3
test/fixtures/experimental/class-properties/with-initializer-missing-plugin/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"throws": "You can only use Class Properties when the 'classProperties' plugin is enabled. (2:2)"
|
||||||
|
}
|
||||||
3
test/fixtures/experimental/class-properties/without-initializer-missing-plugin/actual.js
vendored
Normal file
3
test/fixtures/experimental/class-properties/without-initializer-missing-plugin/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
class Foo {
|
||||||
|
bar;
|
||||||
|
}
|
||||||
3
test/fixtures/experimental/class-properties/without-initializer-missing-plugin/options.json
vendored
Normal file
3
test/fixtures/experimental/class-properties/without-initializer-missing-plugin/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"throws": "You can only use Class Properties when the 'classProperties' plugin is enabled. (2:2)"
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user