language-tools
language-tools copied to clipboard
Completion for custom element tag name
Description
There doesn't seem to way to extend the language tool for custom elements.
Proposed solution
Vue and JSX templates have an interface that can be extended to include custom elements/web components. This would be a nice way for library authors to provide better type integration and descriptions within svelte templates.
Alternatives
No response
Additional Information, eg. Screenshots
No response
There are ways to enhance the typing.
https://svelte.dev/docs/typescript#enhancing-built-in-dom-types
Oh, this is fantastic! Thank you!
@jasonlyu123 do you have a working example of this? It doesn't seem to work in my sample app.
Can you provide a link to that example app?
Yeah, here's a simple repo.
https://github.com/break-stuff/svelte-custom-elements-demo
I have added a additional-svelte-typings.d.ts to the /src directory and updated the tsconfig.json to "include": ["src/**/*"] (basically just followed the steps in the docs).
It does work in your repo. Are you expecting to have completion for it as well?
Yes, I don't see any difference in having it vs not having it in my repo.
The difference is it will be type-check for the element.
There is another way to add custom tag name completion. It's only a local config, so it's not something library authors can leverage, but it's still a good workaround until we can figure out a way to provide the completion.
https://github.com/microsoft/vscode-html-languageservice/blob/main/docs/customData.md
Yeah, I created a package to generate that, but it would be nice if devs would only have to set one thing for types and autocomplete.
https://www.npmjs.com/package/custom-element-vs-code-integration