Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Commit

Permalink
Improve error message on attempt to destructure named import
Browse files Browse the repository at this point in the history
  • Loading branch information
existentialism committed Jan 12, 2017
1 parent aa1a4be commit f231993
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/parser/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,11 @@ pp.parseImportSpecifiers = function (node) {
if (first) {
first = false;
} else {
// Detect an attempt to deep destructure
if (this.eat(tt.colon)) {
this.unexpected(null, "ES2015 named imports do not destructure. Use another statement for destructuring after the import.");
}

this.expect(tt.comma);
if (this.eat(tt.braceR)) break;
}
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/es2015/uncategorised/392/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import foo, { bar: { a } } from 'my-module';
4 changes: 4 additions & 0 deletions test/fixtures/es2015/uncategorised/392/options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"throws": "ES2015 named imports do not destructure. Use another statement for destructuring after the import. (1:19)",
"sourceType": "module"
}

0 comments on commit f231993

Please sign in to comment.