Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Can't import flow types with sourceType script #474

Closed
Hilzu opened this issue May 23, 2017 · 1 comment
Closed

Can't import flow types with sourceType script #474

Hilzu opened this issue May 23, 2017 · 1 comment

Comments

@Hilzu
Copy link

Hilzu commented May 23, 2017

I'm writing an app with CommonJS modules and Flowtype. When setting sourceType to script it becomes impossible to use the Flow import type syntax. As far as I can tell Flow only has ES2015 style syntax for type imports.

Here's my eslint configuration:

{
  "parser": "babel-eslint",
  "parserOptions": {
    "sourceType": "script"
  },
  "plugins": [
    "flowtype",
  ],
  "extends": [
    "eslint:recommended",
    "plugin:flowtype/recommended"
  ]
}

Code like this triggers parse errors:

const { promisify } = require("./promise")
import type { Context } from "koa" 

Example error:

  15:1  error  Parsing error: 'import' and 'export' may appear only with 'sourceType: module'

  13 | const { promisify } = require("./promise")
  14 |
> 15 | import type { Context } from "koa"
     | ^

Is there a way to use CommonJS modules and the import type syntax together with babel-eslint ?

@kaicataldo
Copy link
Member

Thank you for the issue. Now that @babel/eslint-parser has been released, we are making this repository read-only. If this is a change you would still like to advocate for, please reopen this in the babel/babel monorepo.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants