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

stateVar decorator is readonly #9

Open
rubenpoppe opened this issue Oct 26, 2021 · 10 comments
Open

stateVar decorator is readonly #9

rubenpoppe opened this issue Oct 26, 2021 · 10 comments

Comments

@rubenpoppe
Copy link

When using the stateVar decorator I get the error that I can't assign to a read only property. (I am using typescript if that could be the problem.)

import { LitState, stateVar } from 'lit-element-state';

class State extends LitState {
	@stateVar()
	counter = 0
}

export const state = new State();
@gitaarik
Copy link
Owner

gitaarik commented Oct 26, 2021 via email

@rubenpoppe
Copy link
Author

I'll rig up an all javascript project and let you know

@rubenpoppe
Copy link
Author

That works with babel, like the demo in the docs. There must go something wrong when typescript compiles the decorator to javascript.

@gitaarik
Copy link
Owner

gitaarik commented Oct 27, 2021 via email

@rubenpoppe
Copy link
Author

With experimentalDecorators in tsconfig it does. I don't really know much about lit and decorators, but when I have more time I'll maybe look into it some more.

@gitaarik
Copy link
Owner

Ok. At the moment I'm too busy to look into this issue.

@arulselvan
Copy link

+1

Tried this lib today with my Vite + Lit 2.0 + Typescript project setup, but overall this lib is very promising for Lit state management, thanks!

image

@arulselvan
Copy link

using without Decorator https://gitaarik.github.io/lit-state/build/#basic-usage/no-decorator-usage/ working fine. will try later to play around more, again thanks for the awesome lib!

@gitaarik
Copy link
Owner

gitaarik commented Dec 7, 2021

Hi @arulselvan, nice that it's working without decorators :). I guess decorator support works a bit different in TypeScript. Maybe one of us will find a way to make it work in TypeScript at some point.

@nesl247
Copy link

nesl247 commented Feb 13, 2024

I just found this library and issue and was curious about it. I see typescript 5.0 added support for this. https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/. I just wanted to update this issue in case anyone was interested. I haven’t tested it out yet but it should work I imagine.

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