-
Notifications
You must be signed in to change notification settings - Fork 1
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
Full TypeScript support for $
#1
Comments
I wonder if we need to wait for something like this, or if there is a workaround that we can use today. |
By the way, the two APIs that could work are (as far as I know):
Of course, I'd prefer to avoid them 🙂 |
Thanks for creating this issue! It completely slipped my mind that TS will block you on assignment as it now believes that I think you're right that there's no way to address this currently in TS. Either we go for an optional I've opted to make the I've published a new version (0.0.5) with these changes |
That makes sense. What do you think, @DAreRodz? |
By the way, I updated the Stackblitz to the latest version and it works great now 🙂 |
Hey @luisherranz, thanks for pinging me (although I'm pretty sure you and @melnikov-s have more context on this issue than me, haha 😅). Well, I can give my two cents. If we have to choose either an optional I also agree with @melnikov-s when he says that, most of the time, you pass signals to text nodes and dom attributes and that there are no issues with signals being typed as |
Great. Thank you, folks. I think we'll also go with that option. @melnikov-s, I'm going to close this issue but if you find more TS problems with this solution in the future please let us know 🙂 |
@melnikov-s, I've finally published the package: https://github.com/luisherranz/deepsignal/ I'm happy with how TypeScript ended up working. Thanks for your help. I ended up using I haven't tested the library in a real project yet tho, so there may still be issues. This is a Stackblitz example using TypeScript. |
I have been trying to make it work but have not yet succeeded. It's not clear to me that it's possible.
In principle, going through the object properties and adding a new property with
$
seems possible since TypeScript 4.3:But there is a problem:
If
$
is optional, TypeScript assumes thatstore.$prop
may not exist: playgroundIf
$
is not optional, you cannot mutate the object without adding properties starting with$
: playgroundAre you familiar with this problem? Any ideas on how to fix it?
By the way, I tested your library and it looks like you are just adding
$
to the getters, aren't you? Is it for some reason? What is your idea regarding TypeScript?I've recreated the example you have in the README in Stackblitz, and added a few
$
to test this. I'm not sure if I'm doing it right.The text was updated successfully, but these errors were encountered: