You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Auto-import named export from default exported #19877
Create another file where the default exported is exported as a named export
Try to import it
Reproduces without extensions: Yes
Thank you for this auto-import feature in JavaScript! This is something I have been awaiting for a long time! I am not sure of the limitations of this, but I have trouble auto-importing default export's from an index.js file.
What I am doing here is that I am using an higher order component to wrap the function and use that as the default export. But this will never be picked up from the auto-import suggestions?
Is this a limitation or is something which can be integrated in VSCode?
Also want to thank you for the new auto import feature. It would be nice if you can make it work with default exports as well in the future. Here are some suggestions:
We have many default exports in the following forms
So sometimes a default name for the exported default function can be aquired from the module (this could be an extra bonus feature).
However in general cases the module name (folder-name, folderName, FolderName) or the filename can be used (converted camelCase/PascalCase version if name is kebab-case) as a default name for auto import. So if I type someFunction, SomeFunction or some-function it could find the module to import. Plus it could show us an extra option like import as which could ask for a name.
Maybe the whole auto import could be improved later via using (fuzzy) search so we could narrow the results eg typing: utils/feature/some-func, u/f/sf, etc ... which eventually will be replaced with the found import if accepted.
Activity
mjbvz commentedon Nov 9, 2017
From Zoltan Feher (@zfeher) on November 9, 2017 8:40
Also want to thank you for the new auto import feature. It would be nice if you can make it work with default exports as well in the future. Here are some suggestions:
We have many default exports in the following forms
So sometimes a default name for the exported default function can be aquired from the module (this could be an extra bonus feature).
However in general cases the module name (folder-name, folderName, FolderName) or the filename can be used (converted camelCase/PascalCase version if name is kebab-case) as a default name for auto import. So if I type
someFunction,SomeFunctionorsome-functionit could find the module to import. Plus it could show us an extra option likeimport aswhich could ask for a name.Maybe the whole auto import could be improved later via using (fuzzy) search so we could narrow the results eg typing:
utils/feature/some-func,u/f/sf, etc ... which eventually will be replaced with the found import if accepted.mjbvz commentedon Nov 9, 2017
Auto-import does work for
defaultexports but only if there is an understandable symbol name currently. Example:A basic example of Jan Hartmann (@janhartmann)'s request would recognizing exports such as :
As Zoltan Feher (@zfeher) mentioned, instead of trying to get the symbol name in this case, we also could use the filename instead
mhegazy commentedon Nov 9, 2017
Should be fixed by #19875