-
Notifications
You must be signed in to change notification settings - Fork 18
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
VSCode intellisense on Vue files without importing #6
Comments
Same issue here so I've subscribed. vue-tsc makes a lot of different .d.ts files of all components; importing one-by-one works fine with intellisense. But the Bear in mind: I do have Vue Language Feature(Volar) and Typescript Vue Plugin(Volar) installed. (With Takeover mode as described in https://vuejs.org/guide/typescript/overview.html#volar-takeover-mode) |
After a bit of looking into how ts seems to associate/link i.e: Change {
// ...
"types": "./dist/main.d.ts",
// ...
} to {
// ...
"types": "./dist/my-library-vue-ts.es.d.ts", // based on the example
// ...
} If you export the This comment on a bug help lead me in the correct direction microsoft/TypeScript#52363 (comment) |
These changes have no effect on my machine. I've downloaded (and renamed) your repo, renamed it to
I get an immediate error if I build this project and install it in another project stating:
on Removing the
|
@timenengwerda I see your import is I was only able to get the typings to work when I had my types match my imports as mentioned above(I might not have been clear 😅 ) If you change your types from |
Thanks for the quick response. It doesn't make any difference at all: package
vite.config.ts
|
I see in the types you removed the {
// ...
"main": "./dist/my-sample-library.umd.cjs",
"module": "./dist/my-sample-library.js",
"exports": {
".": {
"import": "./dist/my-sample-library.js",
"require": "./dist/my-sample-library.umd.cjs"
},
"./dist/my-sample-library.css": {
"import": "./dist/my-sample-library.css",
"require": "./dist/my-sample-library.css"
}
},
"types": "./dist/my-sample-library.d.ts",
// ...
} Only think I changes from the blog was I didnt use formats from the |
Sorry that was just bad copy/pasting on my side. (I've tried a couple of different things and didn't give the best example). Adding Have you tried building it and installing it as an npm package in another Vue project: Then adding it to that main.ts file And adding If I import it directly into App.vue
Hovering over MyButton DOES give me intellisense and errors on wrong props |
Yip have a tester project that uses a file reference for the package like you did. I remember having an issue with types in general in VS Code. Till i imported any random package (currently have written it off to a extension issue) Might not be the same issue you are having, but in the test project try add something like vue-router and just import the package in Hope that make sense 😅 |
The explanation makes sense. Why that would work doesn't, haha! Unfortunately I still haven't been able to get it to work. I'm pretty sure my Intellisense is fine since importing it directly does work. I'll just call it a day for now and live without the intellisense for this one package. |
In your
~/src/components/main.ts
file you add the components as globals and export them:and
A project can use these components by either installing the plugin and making the components global, or by importing the individual components.
However, VSCode IntelliSense seems to only work if the components are imported. If only installed using
app.use()
, then IntelliSense doesn't work with the components.Is this a known issue, and do you know how to address it?
The text was updated successfully, but these errors were encountered: