Validate importKind and ensure code generation exists.

This commit is contained in:
Logan Smyth 2017-01-13 22:13:27 -08:00
parent 2e6713209c
commit 80a757819f
4 changed files with 17 additions and 0 deletions

View File

@ -1,6 +1,11 @@
import * as t from "babel-types";
export function ImportSpecifier(node: Object) {
if (node.importKind === "type" || node.importKind === "typeof") {
this.word(node.importKind);
this.space();
}
this.print(node.imported, node);
if (node.local && node.local.name !== node.imported.name) {
this.space();

View File

@ -97,6 +97,10 @@ import type { foo as bar } from "baz";
import type from "foo";
import type, { foo } from "bar";
import type * as namespace from "bar";
import { type Foo } from "bar";
import { typeof Foo } from "bar";
import { type Foo as Bar } from "bar";
import { typeof Foo as Bar } from "bar";
export type { foo };
export type { bar } from "bar";
export interface baz { p: number };

View File

@ -101,6 +101,10 @@ import type { foo as bar } from "baz";
import type from "foo";
import type, { foo } from "bar";
import type * as namespace from "bar";
import { type Foo } from "bar";
import { typeof Foo } from "bar";
import { type Foo as Bar } from "bar";
import { typeof Foo as Bar } from "bar";
export type { foo };
export type { bar } from "bar";
export interface baz { p: number };

View File

@ -227,6 +227,10 @@ defineType("ImportSpecifier", {
},
imported: {
validate: assertNodeType("Identifier")
},
importKind: {
// Handle Flowtype's extension "import {typeof foo} from"
validate: assertOneOf(null, "type", "typeof")
}
}
});