Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add importKind to ImportSpecifier (import {type MyType} from './types') #725

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions def/es6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,12 @@ export default function (fork: Fork) {
.field("id", or(def("Identifier"), null), defaults["null"])
.field("name", or(def("Identifier"), null), defaults["null"]);

// import {<id [as name]>} from ...;
// import {[type] <id [as name]>} from ...;
def("ImportSpecifier")
.bases("ModuleSpecifier")
.build("imported", "local")
.field("imported", def("Identifier"));
.build("imported", "local", "importKind")
.field("imported", def("Identifier"))
.field("importKind", or("type", null), defaults["null"]);
Copy link

Choose a reason for hiding this comment

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

Suggested change
.field("importKind", or("type", null), defaults["null"]);
.field("importKind", or("value", "type"), () => "value");

This way it matches the convention found on ImportDeclaration below.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks! I'd make the change, but as far as I can tell this project is dead. @benjamn doesn't work at Facebook anymore, and I guess nobody else has stepped in to maintain it.

Copy link

Choose a reason for hiding this comment

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

Fair enough. In a future where someone does step up to merge PRs here again, this PR thread can serve as a record of a change that should be made.

I think it's too soon to call the project dead; dormant, yes. Ben merged and wrote a burst of changes as recently as last November.

There's a recent thread over on the related project Recast, where he titled the issue "Recast needs additional maintainers": benjamn/recast#1086 (comment) I expect that if there do arise additional maintainers for Recast, they'll also end up maintaining ast-types, given that they're closely related and ast-types is smaller.


// import <id> from ...;
def("ImportDefaultSpecifier")
Expand Down
7 changes: 6 additions & 1 deletion gen/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -952,11 +952,16 @@ export interface SuperBuilder {
}

export interface ImportSpecifierBuilder {
(imported: K.IdentifierKind, local?: K.IdentifierKind | null): namedTypes.ImportSpecifier;
(
imported: K.IdentifierKind,
local?: K.IdentifierKind | null,
importKind?: "type" | null
): namedTypes.ImportSpecifier;
from(
params: {
comments?: K.CommentKind[] | null,
id?: K.IdentifierKind | null,
importKind?: "type" | null,
imported: K.IdentifierKind,
loc?: K.SourceLocationKind | null,
local?: K.IdentifierKind | null,
Expand Down
1 change: 1 addition & 0 deletions gen/namedTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ export namespace namedTypes {
export interface ImportSpecifier extends Omit<ModuleSpecifier, "type"> {
type: "ImportSpecifier";
imported: K.IdentifierKind;
importKind?: "type" | null;
}

export interface ImportDefaultSpecifier extends Omit<ModuleSpecifier, "type"> {
Expand Down