diff --git a/plugins/flow.js b/plugins/flow.js index 34919438f4..46a34e754f 100644 --- a/plugins/flow.js +++ b/plugins/flow.js @@ -791,16 +791,15 @@ acorn.plugins.flow = function (instance) { instance.extend("parseImportSpecifiers", function (inner) { return function (node) { - node.isType = false - if (this.isContextual("type")) { - var start = this.markPosition() - var typeId = this.parseIdent() - if ((this.type === tt.name && this.value !== "from") || this.type === tt.braceL || this.type === tt.star) { - node.isType = true - } else { - node.specifiers.push(this.parseImportSpecifierDefault(typeId, start)) - if (this.isContextual("from")) return - this.eat(tt.comma) + node.importKind = "value" + var kind = + (this.type === tt._typeof ? "typeof" : + (this.isContextual("type") ? "type" : null)) + if (kind) { + var lh = this.lookahead() + if ((lh.type === tt.name && lh.value !== "from") || lh.type === tt.braceL || lh.type === tt.star) { + this.next() + node.importKind = kind } } inner.call(this, node) diff --git a/src/options.js b/src/options.js index 6a81762f40..cd4af9c49a 100755 --- a/src/options.js +++ b/src/options.js @@ -1,4 +1,4 @@ -import {has, isArray} from "./util" +import {has} from "./util" import {SourceLocation} from "./location" // A second optional argument can be given to further configure @@ -94,11 +94,11 @@ export function getOptions(opts) { for (let opt in defaultOptions) options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt] - if (isArray(options.onToken)) { + if (Array.isArray(options.onToken)) { let tokens = options.onToken options.onToken = (token) => tokens.push(token) } - if (isArray(options.onComment)) + if (Array.isArray(options.onComment)) options.onComment = pushComment(options, options.onComment) return options diff --git a/src/util.js b/src/util.js index 3517f8d212..f6b0b2cdb7 100755 --- a/src/util.js +++ b/src/util.js @@ -1,7 +1,3 @@ -export function isArray(obj) { - return Object.prototype.toString.call(obj) === "[object Array]" -} - // Checks if an object has a property. export function has(obj, propName) {