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 is missing #8

Open
danazkari opened this issue Jul 28, 2021 · 12 comments
Open

Typescript Support is missing #8

danazkari opened this issue Jul 28, 2021 · 12 comments

Comments

@danazkari
Copy link

Hello! I love the simplicity of this project and was about to use it, but I was trying to use typescript and it seems like lit-element-state does not support typescript.

Can support be added? Can I help do it?

@gitaarik
Copy link
Owner

Hi @danazkari, nice that you like the project! I myself am not very familiar with TypeScript. What is necessary to support it? I thought that you could include JavaScript modules in TypeScript without any problems.

@danazkari
Copy link
Author

Yup essentially you can... But since it's typed, when you want it needs to know about the types the module has, and since you create a new extendable class out of observeState function, it doesn't know what type of class you're returning.

I can add on my project a file to support the lib but since I have to do it anyways, might as well do it right and contribute to the project 😉

https://github.com/DefinitelyTyped/DefinitelyTyped#how-can-i-contribute

Basically there are two ways, one to add the file to your project or the better way I think, which would be to contribute to DefinitelyTyped which gives people to optionally add the typings only if needed.

@danazkari
Copy link
Author

A way to start working on this is to use perhaps scaffold a TS project with open-wc/open-wc-starter-app, import gitaarik/lit-state and then complete the lit-state.d.ts file until it runs properly.

I could avoid using TS altogether but it would really help me to use it on this project I'm working on.

@gitaarik
Copy link
Owner

gitaarik commented Aug 4, 2021

Hey @danazkari,

Looks interesting. As I said, I am not familiar with TypeScript, so I would have to learn these concepts before I understand what exactly is needed. I am interested in it, but my time is limited, and I can't promise you that I can fix this any time soon. If you are interested, you can of course maybe make a pull request to fix the issue. In the meantime, I will try to learn more about TypeScript.

@danazkari
Copy link
Author

Hey @danazkari,

Looks interesting. As I said, I am not familiar with TypeScript, so I would have to learn these concepts before I understand what exactly is needed. I am interested in it, but my time is limited, and I can't promise you that I can fix this any time soon. If you are interested, you can of course maybe make a pull request to fix the issue. In the meantime, I will try to learn more about TypeScript.

Yeah man it's all good, take ur time, I'm using the ticket as notepad, I wasn't expecting you to work on this actually, but rather I'd like to donate a bit of my time for the project with this 😁

Cheers!

@gitaarik
Copy link
Owner

gitaarik commented Aug 5, 2021

Ok cool. I'm excited to see the progress on this :).

@marcelpanse
Copy link

@danazkari Did you create the types? Can you share them with me?

@danazkari
Copy link
Author

@danazkari Did you create the types? Can you share them with me?

Hey! I'm really sorry mate but I wasn't able to, didn't find the time to do it

@christophe-g
Copy link
Contributor

Early preview of a TS state manager for lit: https://github.com/lit-apps/lit-app/tree/main/packages/state.

Not yet released to npm

@gitaarik
Copy link
Owner

gitaarik commented Jul 7, 2022

Nice work!

@christophe-g
Copy link
Contributor

@gitaarik - Yes, thanks ; )

I will slowly transition to this new approach in our apps (for instance accessiblesurveys.com), mostly for better TS support.
But I had loved lit-state - thanks a lot for it and all the apprecitated work around it !

@gitaarik
Copy link
Owner

Thank you, also for your contribution :)

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

No branches or pull requests

4 participants