import-js
import-js copied to clipboard
Invalid import of module url is added processing Flow type
Hey there, thank you for import-js
! Looks like I've found an issue, please read the description.
Prerequisites
Step one. Create example.js
with this content
// example.js
type T = url => null;
Step two. Run importjs.
$ importjs fix example.js
{"messages":["Imported url from 'url'"],"fileContent":"import url from 'url';\n\ntype T = url => null;\n","unresolvedImports":{}}
Expected behaviour
No imports is added.
Actual behaviour
Import of module url
is added to fileContent
Config
// .importjs.js
module.exports = {
environments: ['node'],
declarationKeyword: 'import',
};
Version
$ importjs --version
2.10.1
Please let me know if you need more details.
Thanks for the report! That does indeed look like a bug. I'd be happy to review a PR fixing things if anyone has the bandwidth to take it on.
You'll need to add the --overwrite
flag to importjs for the import to be written back to file. Like this:
importjs fix --overwrite example.js
It adds the import url from 'url'
as expected.
Closing this, but if you need more guidance feel free to reopen. Thanks.