-
Notifications
You must be signed in to change notification settings - Fork 64
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
use TS type guards over : boolean
in type check functions (R.is, R.is[X])
#109
Comments
Could sombody take a look at this mr, please? I just meet a use case that might need to merge this mr, function grepSomethingRecursively(grepPatterns: String | String[]) {
if (R.is(Array, grepPatterns)) {
R.forEach(doSomething, grepPatterns)
//throw exception: argument of type 'string | string[]' is not assignable to parameter of type 'string[]'.
} else {
...
}
}
In contrast, the |
Hi @tycho01 ,I just copy your mr and try to run with this function, it throws the exception also.
|
@TylerYang: thanks for reporting this! I just merged in your use-case as a new test and implemented a fix. |
NP : ) |
We now have e.g.
is(ctor: any, val: any): boolean;
, which the TS docs tell us we can further strengthen using type guards. Let's do that. :)Edit: on second thought, I don't think at the type level we get enough information to better type the other is functions, beside the generic one...
The text was updated successfully, but these errors were encountered: