Merge pull request #5035 from jeffmo/import_type_shorthand

Strip Flow's new shorthand import-type specifiers
This commit is contained in:
Logan Smyth 2017-01-13 21:56:18 -08:00 committed by GitHub
commit 2e6713209c
4 changed files with 13 additions and 2 deletions

View File

@ -97,5 +97,9 @@ import type2, { foo3 } from "bar";
import type * as namespace from "bar";
export type { foo };
export type { foo2 } from "bar";
import {type T} from "foo";
import {type T2, V1} from "foo";
import {typeof V2} from "foo";
import {typeof V3, V4} from "foo";
export interface foo5 { p: number }
export interface foo6<T> { p: T }

View File

@ -90,3 +90,8 @@ var identity;
import type from "foo";
import type2, { foo3 } from "bar";
import "foo";
import { V1 } from "foo";
import "foo";
import { V4 } from "foo";

View File

@ -12,7 +12,7 @@
"babel-messages": "^6.8.0",
"babel-runtime": "^6.20.0",
"babel-types": "^6.21.0",
"babylon": "^6.11.0",
"babylon": "^6.15.0",
"debug": "^2.2.0",
"globals": "^9.0.0",
"invariant": "^2.2.0",

View File

@ -105,7 +105,7 @@ export let Pure = {
};
export let Flow = {
types: ["Flow", "ImportDeclaration", "ExportDeclaration"],
types: ["Flow", "ImportDeclaration", "ExportDeclaration", "ImportSpecifier"],
checkPath({ node }: NodePath): boolean {
if (t.isFlow(node)) {
return true;
@ -113,6 +113,8 @@ export let Flow = {
return node.importKind === "type" || node.importKind === "typeof";
} else if (t.isExportDeclaration(node)) {
return node.exportKind === "type";
} else if (t.isImportSpecifier(node)) {
return node.importKind === "type" || node.importKind === "typeof";
} else {
return false;
}