Closed mifopen closed 2 years ago
Will it remove the argument names from the autocomplete?
Can we define a multiple interfaces instead?
Like:
interface StatusListener {
('synchronized'): void
('syncError', { error: Error })
…
}
Will it remove the argument names from the autocomplete?
No.
Can we define a multiple interfaces instead?
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
});
It doesn't work with inferring
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
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
Not a solution
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
Not a solution
Could you please elaborate on what you mean by that? :)
I guess it's backwards incompatible. Ok, I see
I guess it's backwards incompatible. Ok, I see
Yes. But also it is not useful.
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 details
before accessing it.
Will try to fix it somehow
Besides backward incompatibility, I don't see any downsides.
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
And there is no workaround for not declaring the second parameter in this case. And of course, the language does nothing with the fact that someone wants to use such lint rules. So for a better solution here we have to wait for https://github.com/microsoft/TypeScript/issues/22609.
I will close the PR and patch the package locally for us as we always use details
parameter. Sorry for bothering you.
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