diff --git a/packages/babel-generator/test/fixtures/flow/type-annotations/actual.js b/packages/babel-generator/test/fixtures/flow/type-annotations/actual.js index 15eddadab1..03e37dd3fb 100644 --- a/packages/babel-generator/test/fixtures/flow/type-annotations/actual.js +++ b/packages/babel-generator/test/fixtures/flow/type-annotations/actual.js @@ -98,7 +98,7 @@ import type { foo, bar } from "baz"; import type { foo as bar } from "baz"; import type from "foo"; import type, { foo } from "bar"; -import type * as namespace from "bar"; +import typeof * as namespace from "bar"; import { type Foo } from "bar"; import { typeof Foo } from "bar"; import { type Foo as Bar } from "bar"; diff --git a/packages/babel-generator/test/fixtures/flow/type-annotations/expected.js b/packages/babel-generator/test/fixtures/flow/type-annotations/expected.js index c86dca2e60..569abf1895 100644 --- a/packages/babel-generator/test/fixtures/flow/type-annotations/expected.js +++ b/packages/babel-generator/test/fixtures/flow/type-annotations/expected.js @@ -221,7 +221,7 @@ import type { foo, bar } from "baz"; import type { foo as bar } from "baz"; import type from "foo"; import type, { foo } from "bar"; -import type * as namespace from "bar"; +import typeof * as namespace from "bar"; import { type Foo } from "bar"; import { typeof Foo } from "bar"; import { type Foo as Bar } from "bar"; diff --git a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/actual.js b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/actual.js index 77aa96cf9b..a9aec24aa5 100644 --- a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/actual.js +++ b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/actual.js @@ -95,7 +95,7 @@ import type { foo2, bar } from "baz"; import type { foo as bar2 } from "baz"; import type from "foo"; import type2, { foo3 } from "bar"; -import type * as namespace from "bar"; +import typeof * as namespace from "bar"; export type { foo }; export type { foo2 } from "bar"; import {type T} from "foo"; diff --git a/packages/babylon/src/plugins/flow.js b/packages/babylon/src/plugins/flow.js index a8bf59ccb7..6cdee82a8c 100644 --- a/packages/babylon/src/plugins/flow.js +++ b/packages/babylon/src/plugins/flow.js @@ -1926,6 +1926,12 @@ export default (superClass: Class): Class => } if (kind) { const lh = this.lookahead(); + + // import type * is not allowed + if (kind === "type" && lh.type === tt.star) { + this.unexpected(lh.start); + } + if ( isMaybeDefaultImport(lh) || lh.type === tt.braceL || diff --git a/packages/babylon/test/fixtures/flow/type-annotations/89/actual.js b/packages/babylon/test/fixtures/flow/type-annotations/89/actual.js deleted file mode 100644 index 4bb55696a1..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/89/actual.js +++ /dev/null @@ -1 +0,0 @@ -import type foo from "bar"; \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-annotations/89/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/89/expected.json deleted file mode 100644 index 8e0461be54..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/89/expected.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 27, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 27 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 27, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 27 - } - }, - "sourceType": "module", - "body": [ - { - "type": "ImportDeclaration", - "start": 0, - "end": 27, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 27 - } - }, - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "start": 12, - "end": 15, - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 15 - } - }, - "local": { - "type": "Identifier", - "start": 12, - "end": 15, - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 15 - }, - "identifierName": "foo" - }, - "name": "foo" - } - } - ], - "importKind": "type", - "source": { - "type": "StringLiteral", - "start": 21, - "end": 26, - "loc": { - "start": { - "line": 1, - "column": 21 - }, - "end": { - "line": 1, - "column": 26 - } - }, - "extra": { - "rawValue": "bar", - "raw": "\"bar\"" - }, - "value": "bar" - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-annotations/90/actual.js b/packages/babylon/test/fixtures/flow/type-annotations/90/actual.js deleted file mode 100644 index 5e640258eb..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/90/actual.js +++ /dev/null @@ -1 +0,0 @@ -import typeof foo from "bar"; \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-annotations/90/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/90/expected.json deleted file mode 100644 index d098b0cce8..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/90/expected.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 29, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 29 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 29, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 29 - } - }, - "sourceType": "module", - "body": [ - { - "type": "ImportDeclaration", - "start": 0, - "end": 29, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 29 - } - }, - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "start": 14, - "end": 17, - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 17 - } - }, - "local": { - "type": "Identifier", - "start": 14, - "end": 17, - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 17 - }, - "identifierName": "foo" - }, - "name": "foo" - } - } - ], - "importKind": "typeof", - "source": { - "type": "StringLiteral", - "start": 23, - "end": 28, - "loc": { - "start": { - "line": 1, - "column": 23 - }, - "end": { - "line": 1, - "column": 28 - } - }, - "extra": { - "rawValue": "bar", - "raw": "\"bar\"" - }, - "value": "bar" - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-annotations/91/actual.js b/packages/babylon/test/fixtures/flow/type-annotations/91/actual.js deleted file mode 100644 index 09eb6f4a3c..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/91/actual.js +++ /dev/null @@ -1 +0,0 @@ -import type {foo, bar} from "baz"; \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-annotations/91/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/91/expected.json deleted file mode 100644 index d92c31cc91..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/91/expected.json +++ /dev/null @@ -1,172 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 34, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 34 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 34, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 34 - } - }, - "sourceType": "module", - "body": [ - { - "type": "ImportDeclaration", - "start": 0, - "end": 34, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 34 - } - }, - "specifiers": [ - { - "type": "ImportSpecifier", - "start": 13, - "end": 16, - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 16 - } - }, - "imported": { - "type": "Identifier", - "start": 13, - "end": 16, - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 16 - }, - "identifierName": "foo" - }, - "name": "foo" - }, - "importKind": null, - "local": { - "type": "Identifier", - "start": 13, - "end": 16, - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 16 - }, - "identifierName": "foo" - }, - "name": "foo" - } - }, - { - "type": "ImportSpecifier", - "start": 18, - "end": 21, - "loc": { - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 21 - } - }, - "imported": { - "type": "Identifier", - "start": 18, - "end": 21, - "loc": { - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 21 - }, - "identifierName": "bar" - }, - "name": "bar" - }, - "importKind": null, - "local": { - "type": "Identifier", - "start": 18, - "end": 21, - "loc": { - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 21 - }, - "identifierName": "bar" - }, - "name": "bar" - } - } - ], - "importKind": "type", - "source": { - "type": "StringLiteral", - "start": 28, - "end": 33, - "loc": { - "start": { - "line": 1, - "column": 28 - }, - "end": { - "line": 1, - "column": 33 - } - }, - "extra": { - "rawValue": "baz", - "raw": "\"baz\"" - }, - "value": "baz" - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-annotations/92/actual.js b/packages/babylon/test/fixtures/flow/type-annotations/92/actual.js deleted file mode 100644 index 5d07032612..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/92/actual.js +++ /dev/null @@ -1 +0,0 @@ -import typeof {foo as bar} from "baz"; \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-annotations/92/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/92/expected.json deleted file mode 100644 index f655b4ac19..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/92/expected.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 38, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 38 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 38, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 38 - } - }, - "sourceType": "module", - "body": [ - { - "type": "ImportDeclaration", - "start": 0, - "end": 38, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 38 - } - }, - "specifiers": [ - { - "type": "ImportSpecifier", - "start": 15, - "end": 25, - "loc": { - "start": { - "line": 1, - "column": 15 - }, - "end": { - "line": 1, - "column": 25 - } - }, - "imported": { - "type": "Identifier", - "start": 15, - "end": 18, - "loc": { - "start": { - "line": 1, - "column": 15 - }, - "end": { - "line": 1, - "column": 18 - }, - "identifierName": "foo" - }, - "name": "foo" - }, - "importKind": null, - "local": { - "type": "Identifier", - "start": 22, - "end": 25, - "loc": { - "start": { - "line": 1, - "column": 22 - }, - "end": { - "line": 1, - "column": 25 - }, - "identifierName": "bar" - }, - "name": "bar" - } - } - ], - "importKind": "typeof", - "source": { - "type": "StringLiteral", - "start": 32, - "end": 37, - "loc": { - "start": { - "line": 1, - "column": 32 - }, - "end": { - "line": 1, - "column": 37 - } - }, - "extra": { - "rawValue": "baz", - "raw": "\"baz\"" - }, - "value": "baz" - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-annotations/93/actual.js b/packages/babylon/test/fixtures/flow/type-annotations/93/actual.js deleted file mode 100644 index 9e9384c856..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/93/actual.js +++ /dev/null @@ -1 +0,0 @@ -import type from "foo"; \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-annotations/93/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/93/expected.json deleted file mode 100644 index f28a6ae4c4..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/93/expected.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 23, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 23, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, - "sourceType": "module", - "body": [ - { - "type": "ImportDeclaration", - "start": 0, - "end": 23, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "start": 7, - "end": 11, - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 11 - } - }, - "local": { - "type": "Identifier", - "start": 7, - "end": 11, - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 11 - }, - "identifierName": "type" - }, - "name": "type" - } - } - ], - "importKind": "value", - "source": { - "type": "StringLiteral", - "start": 17, - "end": 22, - "loc": { - "start": { - "line": 1, - "column": 17 - }, - "end": { - "line": 1, - "column": 22 - } - }, - "extra": { - "rawValue": "foo", - "raw": "\"foo\"" - }, - "value": "foo" - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-annotations/94/actual.js b/packages/babylon/test/fixtures/flow/type-annotations/94/actual.js deleted file mode 100644 index 2c685d8e2d..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/94/actual.js +++ /dev/null @@ -1 +0,0 @@ -import type, {foo} from "bar"; \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-annotations/94/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/94/expected.json deleted file mode 100644 index 75eb3f453a..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/94/expected.json +++ /dev/null @@ -1,154 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 30, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 30 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 30, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 30 - } - }, - "sourceType": "module", - "body": [ - { - "type": "ImportDeclaration", - "start": 0, - "end": 30, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 30 - } - }, - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "start": 7, - "end": 11, - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 11 - } - }, - "local": { - "type": "Identifier", - "start": 7, - "end": 11, - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 11 - }, - "identifierName": "type" - }, - "name": "type" - } - }, - { - "type": "ImportSpecifier", - "start": 14, - "end": 17, - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 17 - } - }, - "imported": { - "type": "Identifier", - "start": 14, - "end": 17, - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 17 - }, - "identifierName": "foo" - }, - "name": "foo" - }, - "importKind": null, - "local": { - "type": "Identifier", - "start": 14, - "end": 17, - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 17 - }, - "identifierName": "foo" - }, - "name": "foo" - } - } - ], - "importKind": "value", - "source": { - "type": "StringLiteral", - "start": 24, - "end": 29, - "loc": { - "start": { - "line": 1, - "column": 24 - }, - "end": { - "line": 1, - "column": 29 - } - }, - "extra": { - "rawValue": "bar", - "raw": "\"bar\"" - }, - "value": "bar" - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-annotations/95/actual.js b/packages/babylon/test/fixtures/flow/type-annotations/95/actual.js deleted file mode 100644 index 7758aa5430..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/95/actual.js +++ /dev/null @@ -1 +0,0 @@ -import type * as namespace from "bar"; \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-annotations/95/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/95/expected.json deleted file mode 100644 index ba8c5759bb..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/95/expected.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 38, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 38 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 38, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 38 - } - }, - "sourceType": "module", - "body": [ - { - "type": "ImportDeclaration", - "start": 0, - "end": 38, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 38 - } - }, - "specifiers": [ - { - "type": "ImportNamespaceSpecifier", - "start": 12, - "end": 26, - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 26 - } - }, - "local": { - "type": "Identifier", - "start": 17, - "end": 26, - "loc": { - "start": { - "line": 1, - "column": 17 - }, - "end": { - "line": 1, - "column": 26 - }, - "identifierName": "namespace" - }, - "name": "namespace" - } - } - ], - "importKind": "type", - "source": { - "type": "StringLiteral", - "start": 32, - "end": 37, - "loc": { - "start": { - "line": 1, - "column": 32 - }, - "end": { - "line": 1, - "column": 37 - } - }, - "extra": { - "rawValue": "bar", - "raw": "\"bar\"" - }, - "value": "bar" - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-annotations/96/actual.js b/packages/babylon/test/fixtures/flow/type-annotations/96/actual.js deleted file mode 100644 index 27c08e852b..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/96/actual.js +++ /dev/null @@ -1 +0,0 @@ -import typeof * as namespace from "bar"; \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-annotations/96/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/96/expected.json deleted file mode 100644 index b102606c92..0000000000 --- a/packages/babylon/test/fixtures/flow/type-annotations/96/expected.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 40, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 40 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 40, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 40 - } - }, - "sourceType": "module", - "body": [ - { - "type": "ImportDeclaration", - "start": 0, - "end": 40, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 40 - } - }, - "specifiers": [ - { - "type": "ImportNamespaceSpecifier", - "start": 14, - "end": 28, - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 28 - } - }, - "local": { - "type": "Identifier", - "start": 19, - "end": 28, - "loc": { - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 28 - }, - "identifierName": "namespace" - }, - "name": "namespace" - } - } - ], - "importKind": "typeof", - "source": { - "type": "StringLiteral", - "start": 34, - "end": 39, - "loc": { - "start": { - "line": 1, - "column": 34 - }, - "end": { - "line": 1, - "column": 39 - } - }, - "extra": { - "rawValue": "bar", - "raw": "\"bar\"" - }, - "value": "bar" - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-imports/import-type/actual.js b/packages/babylon/test/fixtures/flow/type-imports/import-type/actual.js index 061648d235..70d71926f9 100644 --- a/packages/babylon/test/fixtures/flow/type-imports/import-type/actual.js +++ b/packages/babylon/test/fixtures/flow/type-imports/import-type/actual.js @@ -3,7 +3,12 @@ import type {named} from "foo"; import type Def, {named} from "foo"; import type switch from "foo"; import type { switch } from "foo"; +import type { foo, bar } from "baz"; +import type from "foo"; +import type, { foo } from "bar"; +import typeof foo from "bar"; import typeof switch from "foo"; import typeof { switch } from "foo"; -import type * as ns from "foo"; -import type * as switch from "foo"; +import typeof { foo as bar } from "baz"; +import typeof * as ns from "foo"; +import typeof * as switch from "foo"; diff --git a/packages/babylon/test/fixtures/flow/type-imports/import-type/expected.json b/packages/babylon/test/fixtures/flow/type-imports/import-type/expected.json index b455ce4bba..6b639360f7 100644 --- a/packages/babylon/test/fixtures/flow/type-imports/import-type/expected.json +++ b/packages/babylon/test/fixtures/flow/type-imports/import-type/expected.json @@ -1,29 +1,29 @@ { "type": "File", "start": 0, - "end": 300, + "end": 469, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 9, - "column": 35 + "line": 14, + "column": 37 } }, "program": { "type": "Program", "start": 0, - "end": 300, + "end": 469, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 9, - "column": 35 + "line": 14, + "column": 37 } }, "sourceType": "module", @@ -467,7 +467,7 @@ { "type": "ImportDeclaration", "start": 163, - "end": 195, + "end": 199, "loc": { "start": { "line": 6, @@ -475,14 +475,14 @@ }, "end": { "line": 6, - "column": 32 + "column": 36 } }, "specifiers": [ { - "type": "ImportDefaultSpecifier", + "type": "ImportSpecifier", "start": 177, - "end": 183, + "end": 180, "loc": { "start": { "line": 6, @@ -490,13 +490,13 @@ }, "end": { "line": 6, - "column": 20 + "column": 17 } }, - "local": { + "imported": { "type": "Identifier", "start": 177, - "end": 183, + "end": 180, "loc": { "start": { "line": 6, @@ -504,6 +504,404 @@ }, "end": { "line": 6, + "column": 17 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "importKind": null, + "local": { + "type": "Identifier", + "start": 177, + "end": 180, + "loc": { + "start": { + "line": 6, + "column": 14 + }, + "end": { + "line": 6, + "column": 17 + }, + "identifierName": "foo" + }, + "name": "foo" + } + }, + { + "type": "ImportSpecifier", + "start": 182, + "end": 185, + "loc": { + "start": { + "line": 6, + "column": 19 + }, + "end": { + "line": 6, + "column": 22 + } + }, + "imported": { + "type": "Identifier", + "start": 182, + "end": 185, + "loc": { + "start": { + "line": 6, + "column": 19 + }, + "end": { + "line": 6, + "column": 22 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "importKind": null, + "local": { + "type": "Identifier", + "start": 182, + "end": 185, + "loc": { + "start": { + "line": 6, + "column": 19 + }, + "end": { + "line": 6, + "column": 22 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "importKind": "type", + "source": { + "type": "StringLiteral", + "start": 193, + "end": 198, + "loc": { + "start": { + "line": 6, + "column": 30 + }, + "end": { + "line": 6, + "column": 35 + } + }, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + } + }, + { + "type": "ImportDeclaration", + "start": 200, + "end": 223, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 23 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 207, + "end": 211, + "loc": { + "start": { + "line": 7, + "column": 7 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "local": { + "type": "Identifier", + "start": 207, + "end": 211, + "loc": { + "start": { + "line": 7, + "column": 7 + }, + "end": { + "line": 7, + "column": 11 + }, + "identifierName": "type" + }, + "name": "type" + } + } + ], + "importKind": "value", + "source": { + "type": "StringLiteral", + "start": 217, + "end": 222, + "loc": { + "start": { + "line": 7, + "column": 17 + }, + "end": { + "line": 7, + "column": 22 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + }, + { + "type": "ImportDeclaration", + "start": 224, + "end": 256, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 32 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 231, + "end": 235, + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 11 + } + }, + "local": { + "type": "Identifier", + "start": 231, + "end": 235, + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 11 + }, + "identifierName": "type" + }, + "name": "type" + } + }, + { + "type": "ImportSpecifier", + "start": 239, + "end": 242, + "loc": { + "start": { + "line": 8, + "column": 15 + }, + "end": { + "line": 8, + "column": 18 + } + }, + "imported": { + "type": "Identifier", + "start": 239, + "end": 242, + "loc": { + "start": { + "line": 8, + "column": 15 + }, + "end": { + "line": 8, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "importKind": null, + "local": { + "type": "Identifier", + "start": 239, + "end": 242, + "loc": { + "start": { + "line": 8, + "column": 15 + }, + "end": { + "line": 8, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ], + "importKind": "value", + "source": { + "type": "StringLiteral", + "start": 250, + "end": 255, + "loc": { + "start": { + "line": 8, + "column": 26 + }, + "end": { + "line": 8, + "column": 31 + } + }, + "extra": { + "rawValue": "bar", + "raw": "\"bar\"" + }, + "value": "bar" + } + }, + { + "type": "ImportDeclaration", + "start": 257, + "end": 286, + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 29 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 271, + "end": 274, + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 17 + } + }, + "local": { + "type": "Identifier", + "start": 271, + "end": 274, + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 17 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ], + "importKind": "typeof", + "source": { + "type": "StringLiteral", + "start": 280, + "end": 285, + "loc": { + "start": { + "line": 9, + "column": 23 + }, + "end": { + "line": 9, + "column": 28 + } + }, + "extra": { + "rawValue": "bar", + "raw": "\"bar\"" + }, + "value": "bar" + } + }, + { + "type": "ImportDeclaration", + "start": 287, + "end": 319, + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 32 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 301, + "end": 307, + "loc": { + "start": { + "line": 10, + "column": 14 + }, + "end": { + "line": 10, + "column": 20 + } + }, + "local": { + "type": "Identifier", + "start": 301, + "end": 307, + "loc": { + "start": { + "line": 10, + "column": 14 + }, + "end": { + "line": 10, "column": 20 }, "identifierName": "switch" @@ -515,15 +913,15 @@ "importKind": "typeof", "source": { "type": "StringLiteral", - "start": 189, - "end": 194, + "start": 313, + "end": 318, "loc": { "start": { - "line": 6, + "line": 10, "column": 26 }, "end": { - "line": 6, + "line": 10, "column": 31 } }, @@ -536,44 +934,44 @@ }, { "type": "ImportDeclaration", - "start": 196, - "end": 232, + "start": 320, + "end": 356, "loc": { "start": { - "line": 7, + "line": 11, "column": 0 }, "end": { - "line": 7, + "line": 11, "column": 36 } }, "specifiers": [ { "type": "ImportSpecifier", - "start": 212, - "end": 218, + "start": 336, + "end": 342, "loc": { "start": { - "line": 7, + "line": 11, "column": 16 }, "end": { - "line": 7, + "line": 11, "column": 22 } }, "imported": { "type": "Identifier", - "start": 212, - "end": 218, + "start": 336, + "end": 342, "loc": { "start": { - "line": 7, + "line": 11, "column": 16 }, "end": { - "line": 7, + "line": 11, "column": 22 }, "identifierName": "switch" @@ -583,15 +981,15 @@ "importKind": null, "local": { "type": "Identifier", - "start": 212, - "end": 218, + "start": 336, + "end": 342, "loc": { "start": { - "line": 7, + "line": 11, "column": 16 }, "end": { - "line": 7, + "line": 11, "column": 22 }, "identifierName": "switch" @@ -603,15 +1001,15 @@ "importKind": "typeof", "source": { "type": "StringLiteral", - "start": 226, - "end": 231, + "start": 350, + "end": 355, "loc": { "start": { - "line": 7, + "line": 11, "column": 30 }, "end": { - "line": 7, + "line": 11, "column": 35 } }, @@ -624,45 +1022,133 @@ }, { "type": "ImportDeclaration", - "start": 233, - "end": 264, + "start": 357, + "end": 397, "loc": { "start": { - "line": 8, + "line": 12, "column": 0 }, "end": { - "line": 8, - "column": 31 + "line": 12, + "column": 40 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 373, + "end": 383, + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 12, + "column": 26 + } + }, + "imported": { + "type": "Identifier", + "start": 373, + "end": 376, + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 12, + "column": 19 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "importKind": null, + "local": { + "type": "Identifier", + "start": 380, + "end": 383, + "loc": { + "start": { + "line": 12, + "column": 23 + }, + "end": { + "line": 12, + "column": 26 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "importKind": "typeof", + "source": { + "type": "StringLiteral", + "start": 391, + "end": 396, + "loc": { + "start": { + "line": 12, + "column": 34 + }, + "end": { + "line": 12, + "column": 39 + } + }, + "extra": { + "rawValue": "baz", + "raw": "\"baz\"" + }, + "value": "baz" + } + }, + { + "type": "ImportDeclaration", + "start": 398, + "end": 431, + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 33 } }, "specifiers": [ { "type": "ImportNamespaceSpecifier", - "start": 245, - "end": 252, + "start": 412, + "end": 419, "loc": { "start": { - "line": 8, - "column": 12 + "line": 13, + "column": 14 }, "end": { - "line": 8, - "column": 19 + "line": 13, + "column": 21 } }, "local": { "type": "Identifier", - "start": 250, - "end": 252, + "start": 417, + "end": 419, "loc": { "start": { - "line": 8, - "column": 17 + "line": 13, + "column": 19 }, "end": { - "line": 8, - "column": 19 + "line": 13, + "column": 21 }, "identifierName": "ns" }, @@ -670,19 +1156,19 @@ } } ], - "importKind": "type", + "importKind": "typeof", "source": { "type": "StringLiteral", - "start": 258, - "end": 263, + "start": 425, + "end": 430, "loc": { "start": { - "line": 8, - "column": 25 + "line": 13, + "column": 27 }, "end": { - "line": 8, - "column": 30 + "line": 13, + "column": 32 } }, "extra": { @@ -694,45 +1180,45 @@ }, { "type": "ImportDeclaration", - "start": 265, - "end": 300, + "start": 432, + "end": 469, "loc": { "start": { - "line": 9, + "line": 14, "column": 0 }, "end": { - "line": 9, - "column": 35 + "line": 14, + "column": 37 } }, "specifiers": [ { "type": "ImportNamespaceSpecifier", - "start": 277, - "end": 288, + "start": 446, + "end": 457, "loc": { "start": { - "line": 9, - "column": 12 + "line": 14, + "column": 14 }, "end": { - "line": 9, - "column": 23 + "line": 14, + "column": 25 } }, "local": { "type": "Identifier", - "start": 282, - "end": 288, + "start": 451, + "end": 457, "loc": { "start": { - "line": 9, - "column": 17 + "line": 14, + "column": 19 }, "end": { - "line": 9, - "column": 23 + "line": 14, + "column": 25 }, "identifierName": "switch" }, @@ -740,19 +1226,19 @@ } } ], - "importKind": "type", + "importKind": "typeof", "source": { "type": "StringLiteral", - "start": 294, - "end": 299, + "start": 463, + "end": 468, "loc": { "start": { - "line": 9, - "column": 29 + "line": 14, + "column": 31 }, "end": { - "line": 9, - "column": 34 + "line": 14, + "column": 36 } }, "extra": { diff --git a/packages/babylon/test/fixtures/flow/type-imports/invalid-import-type-namespace/actual.js b/packages/babylon/test/fixtures/flow/type-imports/invalid-import-type-namespace/actual.js new file mode 100644 index 0000000000..e05b582d9d --- /dev/null +++ b/packages/babylon/test/fixtures/flow/type-imports/invalid-import-type-namespace/actual.js @@ -0,0 +1 @@ +import type * as namespace from "bar"; diff --git a/packages/babylon/test/fixtures/flow/type-imports/invalid-import-type-namespace/options.json b/packages/babylon/test/fixtures/flow/type-imports/invalid-import-type-namespace/options.json new file mode 100644 index 0000000000..9e093bfdcd --- /dev/null +++ b/packages/babylon/test/fixtures/flow/type-imports/invalid-import-type-namespace/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (1:12)" +} diff --git a/scripts/tests/flow/flow_tests_whitelist.txt b/scripts/tests/flow/flow_tests_whitelist.txt index 2f0ba69391..3f0abc41bf 100644 --- a/scripts/tests/flow/flow_tests_whitelist.txt +++ b/scripts/tests/flow/flow_tests_whitelist.txt @@ -57,5 +57,3 @@ types/parameter_defaults/migrated_0031.js types/parameter_defaults/migrated_0032.js types/string_literal_invalid/migrated_0000.js types/typecasts_invalid/migrated_0001.js -types/import_types/namespace.js -types/import_types/namespace_reserved_value.js