Closed
Description
Bug Report
π Version & Regression Information
Tried in 4.4.4 and Nightly version
β― Playground Link
π» Code
export const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean';
const useAdapter = (syncDependencies: string[], asyncDependencies: string[] | boolean) => (dependencies: string[]): [boolean, boolean] => {
const useAsync = isBoolean(asyncDependencies)
? asyncDependencies
: asyncDependencies.reduce((prev, dep) => prev || dependencies.includes(dep), false)
const use = useAsync || syncDependencies.reduce((prev, dep) => prev || dependencies.includes(dep), false)
return [use, useAsync]
}
π Actual behavior
TypeScript thinks that syncDependencies.reduce()
returns a string
. If i remove useAsync ||
in front of the reduce statement or place it after the reduce statement || useAsync
it is detected as a boolean
π Expected behavior
The reduce statement should return a value of type boolean
because the value actually is a boolean