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

Disallow import type { type a } from '' #305

Merged
merged 1 commit into from Jan 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .flowconfig
@@ -1,6 +1,7 @@
[ignore]
.*/lib/.*
.*/test/.*
.*/build/.*

[include]

Expand Down
4 changes: 4 additions & 0 deletions src/plugins/flow.js
Expand Up @@ -1223,6 +1223,10 @@ export default function (instance) {
specifier.local = specifier.imported.__clone();
}

if (node.importKind !== "value" && specifier.importKind !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per this discussion with @loganfsmyth, I guess this should stick to explicitly listing out "type" and "typeof"

babel/babel#5035 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed that in #312

this.raise(firstIdentLoc, "`The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements`");
}

this.checkLVal(specifier.local, true, undefined, "import specifier");
node.specifiers.push(this.finishNode(specifier, "ImportSpecifier"));
};
Expand Down
@@ -0,0 +1,2 @@
import typeof {typeof t} from "foo";
import type {type t} from "foo";
@@ -0,0 +1,3 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably just not familiar with how the test runner/fixtures work, but shouldn't this output have 2 throws (one for each line)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, babylon throws at the first error, and never parses the second line. I extracted that in a second test.

"throws": "`The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements` (1:15)"
}