diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js
index 0ef5ca4270ef..e63401b4747b 100644
--- a/packages/babel-parser/src/parser/expression.js
+++ b/packages/babel-parser/src/parser/expression.js
@@ -1170,6 +1170,12 @@ export default class ExpressionParser extends LValParser {
}
}
// fall through
+ case tt.relational: {
+ if (this.state.value === "<") {
+ throw this.expectOnePlugin(["jsx", "flow", "typescript"]);
+ }
+ }
+ // fall through
default:
throw this.unexpected();
}
diff --git a/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-jsx-expression/input.js b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-jsx-expression/input.js
new file mode 100644
index 000000000000..f56238150ab2
--- /dev/null
+++ b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-jsx-expression/input.js
@@ -0,0 +1 @@
+
() => {}
diff --git a/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-ts-type-param-no-flow/options.json b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-ts-type-param-no-flow/options.json
new file mode 100644
index 000000000000..5047d6993fe8
--- /dev/null
+++ b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-ts-type-param-no-flow/options.json
@@ -0,0 +1,3 @@
+{
+ "plugins": ["typescript"]
+}
diff --git a/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-ts-type-param-no-flow/output.json b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-ts-type-param-no-flow/output.json
new file mode 100644
index 000000000000..d1ca421c201b
--- /dev/null
+++ b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-ts-type-param-no-flow/output.json
@@ -0,0 +1,42 @@
+{
+ "type": "File",
+ "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
+ "program": {
+ "type": "Program",
+ "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
+ "sourceType": "script",
+ "interpreter": null,
+ "body": [
+ {
+ "type": "ExpressionStatement",
+ "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
+ "expression": {
+ "type": "ArrowFunctionExpression",
+ "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
+ "id": null,
+ "generator": false,
+ "async": false,
+ "params": [],
+ "body": {
+ "type": "BlockStatement",
+ "start":11,"end":13,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":13}},
+ "body": [],
+ "directives": []
+ },
+ "typeParameters": {
+ "type": "TSTypeParameterDeclaration",
+ "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}},
+ "params": [
+ {
+ "type": "TSTypeParameter",
+ "start":1,"end":4,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":4}},
+ "name": "div"
+ }
+ ]
+ }
+ }
+ }
+ ],
+ "directives": []
+ }
+}
\ No newline at end of file
diff --git a/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-ts-type-param/input.js b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-ts-type-param/input.js
new file mode 100644
index 000000000000..2791c2c7a3a0
--- /dev/null
+++ b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-ts-type-param/input.js
@@ -0,0 +1 @@
+
() => {}
diff --git a/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-ts-type-param/output.json b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-ts-type-param/output.json
new file mode 100644
index 000000000000..44b47bc7920b
--- /dev/null
+++ b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-ts-type-param/output.json
@@ -0,0 +1,43 @@
+{
+ "type": "File",
+ "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
+ "program": {
+ "type": "Program",
+ "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
+ "sourceType": "script",
+ "interpreter": null,
+ "body": [
+ {
+ "type": "ExpressionStatement",
+ "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
+ "expression": {
+ "type": "ArrowFunctionExpression",
+ "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
+ "id": null,
+ "generator": false,
+ "async": false,
+ "params": [],
+ "body": {
+ "type": "BlockStatement",
+ "start":11,"end":13,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":13}},
+ "body": [],
+ "directives": []
+ },
+ "typeParameters": {
+ "type": "TypeParameterDeclaration",
+ "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}},
+ "params": [
+ {
+ "type": "TypeParameter",
+ "start":1,"end":4,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":4}},
+ "name": "div",
+ "variance": null
+ }
+ ]
+ }
+ }
+ }
+ ],
+ "directives": []
+ }
+}
\ No newline at end of file
diff --git a/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-type-param/input.js b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-type-param/input.js
new file mode 100644
index 000000000000..2791c2c7a3a0
--- /dev/null
+++ b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-type-param/input.js
@@ -0,0 +1 @@
+
() => {}
diff --git a/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-type-param/options.json b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-type-param/options.json
new file mode 100644
index 000000000000..f11e7c5d0451
--- /dev/null
+++ b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-type-param/options.json
@@ -0,0 +1,4 @@
+{
+ "plugins": [],
+ "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'jsx, flow, typescript' (1:0)"
+}
diff --git a/packages/babel-parser/test/fixtures/jsx/errors/_no_plugin/input.js b/packages/babel-parser/test/fixtures/jsx/errors/_no_plugin/input.js
new file mode 100644
index 000000000000..7c89b545c5ac
--- /dev/null
+++ b/packages/babel-parser/test/fixtures/jsx/errors/_no_plugin/input.js
@@ -0,0 +1 @@
+
diff --git a/packages/babel-parser/test/fixtures/jsx/errors/_no_plugin/options.json b/packages/babel-parser/test/fixtures/jsx/errors/_no_plugin/options.json
new file mode 100644
index 000000000000..7e0538ba8978
--- /dev/null
+++ b/packages/babel-parser/test/fixtures/jsx/errors/_no_plugin/options.json
@@ -0,0 +1,4 @@
+{
+ "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'jsx, flow, typescript' (1:0)",
+ "plugins": []
+}
diff --git a/packages/babel-parser/test/fixtures/jsx/errors/unclosed-jsx-element/input.js b/packages/babel-parser/test/fixtures/jsx/errors/unclosed-jsx-element/input.js
new file mode 100644
index 000000000000..2791c2c7a3a0
--- /dev/null
+++ b/packages/babel-parser/test/fixtures/jsx/errors/unclosed-jsx-element/input.js
@@ -0,0 +1 @@
+
() => {}
diff --git a/packages/babel-parser/test/fixtures/jsx/errors/unclosed-jsx-element/options.json b/packages/babel-parser/test/fixtures/jsx/errors/unclosed-jsx-element/options.json
new file mode 100644
index 000000000000..05048c2000ee
--- /dev/null
+++ b/packages/babel-parser/test/fixtures/jsx/errors/unclosed-jsx-element/options.json
@@ -0,0 +1,4 @@
+{
+ "plugins": ["jsx"],
+ "throws": "Unexpected token (1:13)"
+}