Closed lydell closed 5 years ago
Repro repo: https://github.com/lydell/babel-eslint-flow-import-issue
package.json:
{ "private": true, "scripts": { "test": "eslint test.js" }, "dependencies": { "babel-eslint": "10.0.2", "eslint": "6.0.0" } }
.eslintrc.json:
{ "parser": "babel-eslint" }
test.js:
// @flow declare module "cross-spawn" { import typeof childProcess from "child_process"; declare module.exports: { sync: $PropertyType<childProcess, "spawnSync">, }; }
Result:
$ npm test > @ test /home/lydell/stuff/babel-eslint > eslint test.js /home/lydell/stuff/babel-eslint/test.js 4:3 error Parsing error: Imports within a `declare module` body must always be `import type` or `import typeof` 2 | 3 | declare module "cross-spawn" { > 4 | import typeof childProcess from "child_process"; | ^ 5 | 6 | declare module.exports: { 7 | sync: $PropertyType<childProcess, "spawnSync">, ✖ 1 problem (1 error, 0 warnings) npm ERR! Test failed. See above for more details.
Expected: No errors.
Flow itself accepts this input.
Just realized this is a bug in @babel/parser, so I filed a bug there: https://github.com/babel/babel/issues/10124
But I think the bug is most likely to be found by babel-eslint users.
Fixed by https://github.com/babel/babel/pull/10132.
Repro repo: https://github.com/lydell/babel-eslint-flow-import-issue
package.json:
.eslintrc.json:
test.js:
Result:
Expected: No errors.
Flow itself accepts this input.