-
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
Rework subscribe function to add more typesafety #1
Comments
Something like this could be on the right track? The idea is that you can curry the path out from an object type using keyof typed options. |
So this is now an important fix. The subscribing is based on the way you write the state piece out and if it compiles differently then it can break. Line 49 in a90cefd
|
This looks like a promising solution rather than currying. |
This is somewhat solved in #2 but I still feel like this needs to be left open and continue to investigate the solution. As @JamesYFC has suggested, maybe the solution could be to add more layers to the tuple path type but it seems limiting to have a hard upper limit of how deep the state can be until intellesense breaks. |
@JamesYFC there is an issue with the new tuple path method that we missed. It seems to only support a depth of 2 at the moment subscribe(['one', 'two']); // Works fine
subscribe(['one', 'two', 'three']); //Types of property '['2']' are incompatible.
// Type 'string' is not assignable to type 'undefined'. |
Will take a look in a day or two, internet access is sketchy atm
Sent from Yahoo Mail for iPhone
On Tuesday, November 19, 2019, 1:19 pm, Kalvin Pearce <[email protected]> wrote:
@JamesYFC there is an issue with the new tuple path method that we missed. It seems to only support a depth of 2 at the moment
subscribe(['one', 'two']); // Works fine
subscribe(['one', 'two', 'three']); //Types of property '['2']' are incompatible.
// Type 'string' is not assignable to type 'undefined'.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Closing now due to being fixed in b19bf2f |
Current limit is 10 paths deep but after adding more I realised TS currently doesn't types of more than 10 deep... at 13 it will throw errors. |
Need to look into if theres a better way of subscribing to state pieces. At the moment there is little safety around what gets put in the stateValue param. Would be good to rework to make it more typesafe if possible?
This would remove the need for branching statement and broken subscribes.
seorsum/src/index.ts
Lines 44 to 60 in 446d28f
The text was updated successfully, but these errors were encountered: