Typescript type for `just-partition` does not narrow type correctly when using a type guard
- Linguagem predominante
- JavaScript
- Estrelas
- 6.2k
- Forks
- 210
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
The Typescript type for `just-partition` does not narrow type correctly when using a type guard
I'm not sure what the best way to report/describe TS issues, so I will use screenshots,
I hope that that is okay,
In contrast with how using `Array.filter()` correctly narrows the type
The type returned from `partition`, when using the example type guard, is a tuple of unions of the possible values
```TS
[PromiseRejectedResult | PromiseFulfilledResult, PromiseRejectedResult | PromiseFulfilledResult]
```
What I would really like/expect is that the types would be correctly inferred, in the same way that `Array.filter()` does
```TS
[ PromiseFulfilledResult, PromiseRejectedResult ]
```
I can work around this by casting the result, but that is not ideal
I have a suggested fix, using a function Type override
I will open a PR,
I just wanted to link the PR to an issue
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.