Cannot import es6 exported function
I have never had this issue until lately.
WebStorm 2021.3.2, Build #WS-213.6777.57
When I try to Option + Enter on this, it provides me an option to import, but never actually follows through with performing the import:
createSQLAndMigrationFile
Here's part of the file that method is exported from:
import * as path from 'path';
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const DBMigrate = require('db-migrate');
export async function createSQLAndMigrationFile(sqlFileName: string, scope: string) {
... some code is in here
}
So when I Opt + Enter on that from my test, you can see it gave me the option but when I hit enter to import, it does nothing. For other modules I've used, Opt + Enter works fine.
I have to end up manually adding the import at the top of my test file (which sucks). Then it's fine:
Is it because I'm using commonJS requires in the file I'm exporting from? or is this a bug?
Please sign in to leave a comment.
Can't reproduce with similar code
Please could you try composing a sample project the issue can be repeated with?
Give me your github username and I'll add you as a collaborator to https://github.com/dschinkel/we-do-tdd
- then go to
- Remove the import for resetDatabase() and try Opt + Enter
it's lena-spb
thx, added you but don't post any of my code in here.
Thanks
this is a known issue, tracked at https://youtrack.jetbrains.com/issue/WEB-54951; the problem will go away if you remove the package.json from the src/LocalDB folder; see https://youtrack.jetbrains.com/issue/WEB-54083#focus=Comments-27-5661613.0-0 for more info about the root cause of the issue
awesome good to know. Thank you Elena.