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

Typescript support #163

Closed
ok-AK opened this issue Aug 24, 2020 · 28 comments
Closed

Typescript support #163

ok-AK opened this issue Aug 24, 2020 · 28 comments
Assignees
Labels
enhancement New feature or request

Comments

@ok-AK
Copy link

ok-AK commented Aug 24, 2020

Hello,
Are there plans to add Typescript support to this library? Looks great and love the library!

@csaltos
Copy link
Contributor

csaltos commented Sep 18, 2020

Now Svelte supports TypeScript directly, please check out this post as a reference -> https://svelte.dev/blog/svelte-and-typescript

@EduardsE
Copy link

Does anybody have an instruction on how to get this to work with TypeScript?

@ok-AK
Copy link
Author

ok-AK commented Oct 11, 2020

Does anybody have an instruction on how to get this to work with TypeScript?

Svelte Material UI currently does not have typescript types defined. You can still use this lib in your typescript project and create your own typescript components that consume this lib but Svelte Material UI components will remain untyped as you do so.

@EduardsE
Copy link

EduardsE commented Oct 11, 2020

Svelte Material UI currently does not have typescript types defined. You can still use this lib in your typescript project and create your own typescript components that consume this lib but Svelte Material UI components will remain untyped as you do so.

It does compile, but I'm having difficulty configuring it in VSCode.
I keep doing this for every component and I'd rather not:
image

Otherwise it's red squiggly lines all the way

@chalkplum
Copy link

yeah i've stopped using it, why not create @types

@maranmaran
Copy link

any update on types?

@hperrin
Copy link
Owner

hperrin commented Apr 26, 2021

The current plan is to work on migrating to Typescript as the next major feature. It will take a lot of work, though.

@hperrin hperrin self-assigned this Apr 26, 2021
@hperrin hperrin added the enhancement New feature or request label Apr 26, 2021
@korompaiistvan
Copy link

hi @hperrin, I love the project it has helped me a lot to dip my toes into Svelte :)
I just found this project and it might help you create ts definitions https://github.com/IBM/sveld

@hperrin
Copy link
Owner

hperrin commented May 10, 2021

Thank you. That does look promising.

@hperrin
Copy link
Owner

hperrin commented Sep 3, 2021

I've been using SMUI in a TypeScript project recently, and it reeeeeeeeally makes me want to spend a weekend translating this to TypeScript.

@hperrin
Copy link
Owner

hperrin commented Sep 3, 2021

Oooooooooooooooof:
https://github.com/sciactive/nymphjs/tree/1c51dd52768b14f6f6674f6d06001c883b46ef51/packages/tilmeld-setup/app/types

@hperrin
Copy link
Owner

hperrin commented Sep 8, 2021

Getting started on this today. I'm not sure how I'm going to handle events, since you can add ad hoc events with modifiers. Wish me luck.

@hperrin
Copy link
Owner

hperrin commented Sep 8, 2021

YO!!!! cf9c6af

@hperrin
Copy link
Owner

hperrin commented Sep 8, 2021

It seems like it's working!

@hperrin
Copy link
Owner

hperrin commented Sep 8, 2021

Based on how long it took to translate just that (very simple) component, "a weekend" was a very optimistic time frame.

@hperrin
Copy link
Owner

hperrin commented Sep 9, 2021

You can follow along with my progress here:
https://github.com/hperrin/svelte-material-ui/commits/typescript

@hperrin hperrin pinned this issue Sep 9, 2021
@hperrin hperrin added this to To do in TypeScript Migration via automation Sep 10, 2021
@hperrin
Copy link
Owner

hperrin commented Sep 10, 2021

Better yet, you can follow my progress in the newly created project:
https://github.com/hperrin/svelte-material-ui/projects/1

@hperrin hperrin moved this from To do to In progress in TypeScript Migration Sep 10, 2021
@hperrin
Copy link
Owner

hperrin commented Sep 14, 2021

Closed with 331afa5! Fully typed SMUI!!!

@hperrin hperrin closed this as completed Sep 14, 2021
TypeScript Migration automation moved this from In progress to Done Sep 14, 2021
@marekdedic
Copy link

Hi, great to hear that! Could you please add some more detail about setting up svelte-preprocess to the docs? I'm currently getting

Message:
    Module parse failed: Unexpected token (2:12)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| import Button from './Button.svelte';
> import type { ButtonComponentDev } from './Button.types';
| export * from './Button.types';

and I am not really sure about the issue as I already have svelte-preprocess configured and use TypeScript in the project...

Thnaks!

@hperrin
Copy link
Owner

hperrin commented Sep 14, 2021

@marekdedic Can you try with the latest beta? I fixed some type issues with the ".0" beta, so the ".1" beta might help.

@marekdedic
Copy link

marekdedic commented Sep 15, 2021

@hperrin It's still the same. I think it's probably just that my webpack config isn't 100% correct (but it works for my TS code), so better docs would be the way to go...

@hperrin
Copy link
Owner

hperrin commented Sep 16, 2021

I just tested it in Webpack myself, and I'm getting the same issue...

@roociferSonOfTheMorning
Copy link

roociferSonOfTheMorning commented Sep 17, 2021

I'm also having similar issues. I am using svelte-typescript, running the setup typescript step and then installing the smui button.

it fails to compile:
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
node_modules/@smui/common/smui.d.ts (5:7)

@hperrin
Copy link
Owner

hperrin commented Sep 18, 2021

I've fixed most of the issue... I've got one more beta to publish that I think will fix the last parts.

@hperrin
Copy link
Owner

hperrin commented Sep 18, 2021

It worked! Typed SMUI works in Webpack now!

@marekdedic
Copy link

Thanks! Unfortunately, I'm getting a different error now :/

Module not found: Error: Can't resolve '../_index.scss' in '/home/user/project/node_modules/@smui/button'

@marekdedic
Copy link

That error seems to be fixed on beta 7, however, there is an even newer one :)

Message:
    Module not found: Error: Can't resolve './classAdderBuilder' in '/home/user/project/node_modules/@smui/common/classadder'
Did you mean 'classAdderBuilder.ts'?
BREAKING CHANGE: The request './classAdderBuilder' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
export 'classAdderBuilder' (imported as 'classAdderBuilder') was not found in '@smui/common/classadder/index.js' (module has no exports)

@hperrin
Copy link
Owner

hperrin commented Feb 1, 2022

This should also be fixed now. :)

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
No open projects
Development

No branches or pull requests

9 participants