import-js icon indicating copy to clipboard operation
import-js copied to clipboard

Invalid import of module url is added processing Flow type

Open verkholantsev opened this issue 6 years ago • 1 comments

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.

verkholantsev avatar Apr 11 '18 11:04 verkholantsev

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.

trotzig avatar Apr 11 '18 14:04 trotzig

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.

mikabytes avatar Feb 07 '24 08:02 mikabytes