-
Notifications
You must be signed in to change notification settings - Fork 48
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
Fix StatusListener typing #98
Conversation
Will it remove the argument names from the autocomplete? Can we define a multiple interfaces instead? Like: interface StatusListener {
('synchronized'): void
('syncError', { error: Error })
…
} |
No.
It doesn't work with inferring. So you won't be able to write status(store.client, (state, details) => {
switch(status) {
case 'syncError':
console.log(details.error); // <- here details is inferred as { error: Error }
// ... <- here you can use your IDE to generate all the branches as state is correct union type
}); |
Got it. Can you fix a type test and we can release it. |
On it |
The only downside (I guess because of the amateur TS support of the feature) is that you can not pass a callback with one parameter in the signature — it must be the full tuple. Had do ignore eslint warning about unused argument in test |
Not a solution |
Could you please elaborate on what you mean by that? :) |
I guess it's backwards incompatible. Ok, I see |
Yes. But also it is not useful. |
Besides backward incompatibility, I don't see any downsides. It's definitely better than it was because you don't have to check the structure of the |
Will try to fix it somehow |
You need to disable linter if you need only single argument |
Yeah, I know. That's what I'm trying to deal with |
Ok, the current approach is the recommended one by TS https://devblogs.microsoft.com/typescript/announcing-typescript-4-6/#control-flow-analysis-for-dependent-parameters |
aeh, there is a bug so let's fix it at least :) |
Thanks. Released in 0.18.4. |
Fixed
details
type forsyncError
type and made it more inferring-friendly