Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto-import inconsistencies within template #1643

Closed
theoephraim opened this issue Jul 27, 2022 · 1 comment
Closed

auto-import inconsistencies within template #1643

theoephraim opened this issue Jul 27, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@theoephraim
Copy link

Having some funky behaviour around auto-import suggestions only within vue templates, which leads me to believe it is a volar issue. The issue is that in the script section of a vue file (or other .ts files) importing a component that is exposed via an index file works correctly, while within the template block, the import suggestion is to import from the file directly.

Correct behaviour (within script block)
Screen Shot 2022-07-25 at 8 51 27 AM

Incorrect behaviour (within template tag)
Screen Shot 2022-07-25 at 8 51 51 AM

I'm unclear on what scenarios this occurs, but in my case specifically, the module @si/ui-lib is a shared component library within the monorepo, and is being used directly without being built first - meaning

my web app's package.json includes the dependency via pnpm workspace linking

"@si/ui-lib": "workspace:*",

and @si/ui-lib's package.json exports the ts files directly

"main": "src/index.ts",
"types": "src/index.ts",

the index file just re-exports the components, for example

export { default as CoolButton } from './components/CoolButton/CoolButton.vue';

I have tried many different iterations of tsconfig files using aliases, project references, etc... What I have now seems to work the best and be very simple, with the only issue being this auto-import in vue templates.

Let me know if you need a minimal repro and I'll set one up.

Cheers!

@louia
Copy link

louia commented Mar 3, 2023

The component/function autocomplete feature not work actualy.

I use Typescript with TakeOver with vue 3.2 on the latest version of vscode.

If there is no import of the library into the project, volar does not recognize the library. You have to import your component manually for the first time and then the auto-import will work as expected.

BUT if you remove all the imports to the lib you will have a error like this in the suggestions window :
image

I don't understand that volar can't analyze the dependencies in the node_modules to propose the autocompletion of the imports

Is this a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants