-
Notifications
You must be signed in to change notification settings - Fork 74
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
Add a TypeScript component template #29
Comments
I've "migrated" this component template to support TypeScript: https://github.com/devrnt/component-template. This fork is ready to be used if TypeScript is desired. Known warnings when building (and solutions)
Possible improvements
|
I'm having troubles with this template, I built a component using it (https://github.com/jnordberg/svelte-qr) and it works fine when installing it locally (in a svelte typescript template project) with
|
Looks like svelte is trying to use the Does it work if you remove the |
If I remove the However I was able to get it to work by changing typescript rollup plugin in the project consuming svelte-qr. Switching from |
This works and it's really weird that |
Removing My current best guess is that |
It would also be great to understand what definitions to extend for component development. From |
It has been a while since I've read any updates regarding TypeScript in Svelte (since the "official" TypeScript support). I think you should take a look at the docs of |
@devrnt I managed to get types outputted, but not for the |
Auto-generation of |
For non
|
Same problem here! I think this really needs to be addressed, since it seems to be documented nowhere and caused me at least 5 hours of searching (originally had another error message from a local The solution from @jnordberg about replacing For @devrnt's solution, removing the I also saw rollup/plugins#282 (which seems to define the same problem) and tried the given solution (moving the Anyway, I really think this should be moved to a separate issue since it's unclear if it's related to Svelte itself or to the typescript plugin, and it seems to be more a bug that just a misconfiguration or something. |
I've made a component template that supports the It does this by preprocessing the .svelte components and using that for the |
Nice one! Can't wait to try it! |
I used this template without modification and consume in in a svelte-kit project by using yarn link and I get the following error
|
…lick and hover events. This package was not set up very well when consumed by other svelte apps, especially the typescript svelte apps. Notably, there were no typings exported, and the "svelte" key was not present in the package.json. I followed [this](https://github.com/mattjennings/svelte-typescript-component-template) wonderful template to get running. The only downside is we don't get real `.d.ts` files for the popover. But without autogenerated typings I don't plan to pursue it. See: sveltejs/component-template#29 (comment). I may look to use [sveld](https://github.com/IBM/sveld) to do this in the future. Additionally, I found a lot of edge cases if you want both "click" and "hover". Primarily you might want this for keyboard and touch devices if you like hover but want to remain accessible. I made it work a lot better, and added some nice features like escape to close or click away to close.
To everyone who wants to place TypeScript files or Svelte files which require preprocessors inside node_modules: It is strongly advised to not do this. It's not officially supported and also places the burden of preprocessing your package on all your users. Instead you should preprocess Svelte files, transpile TS to JS and provide type definitions. More info: https://github.com/sveltejs/language-tools/blob/master/docs/preprocessors/typescript.md#typing-components-authoring-packages . SvelteKit's |
I can't speak for absolutely everyone, but I am approaching this from wanting to reference components in another sibling project (like in a monorepo) while maintaining HMR and other niceties. If creating a component library with SvelteKit's package command (which I am) there are a couple of complications. You can add a local reference like It would be nice if this configuration was possible out of the box. |
This allows importing the library without having to use TypeScript preprocessors which is the recommended way sveltejs/component-template#29
Hey, I refactored my tiny library from including the raw TS files to using the SvelteKit
Adding
to my |
Is your feature request related to a problem? Please describe.
Many people want to use Svelte with TypeScript. With
svelte-preprocess
, a fitting rollup-config and Svelte extension from VSCode this is working good already.Describe the solution you'd like
Add a
sveltejs/typescript-component-template
similar to https://github.com/sveltejs/component-template.How important is this feature to you?
Important to get the word out that Svelte supports TypeScript in the component-template as well.
Related issues
This issue is based on the issue in the
svelte/svelte
repository. The app-template is already "migrated" to TypeScript, but this issue addresses the component-template.The text was updated successfully, but these errors were encountered: