Effect CommunityEC
Effect Communityβ€’2y agoβ€’
18 replies
Patrick Roza

Improving `Array.isArray` for More Precise Type Narrowing

can Array.isArray be improved to work better to narrow array types, or is there an alternative?
like this is horrible πŸ˜„
import { Array } from "effect"
interface IntradayData { something: number } 

declare const _ = _: IntradayData | readonly IntradayData[] | null
Array.isArray(_) ? _[0] as IntradayData | undefined ?? null : _ as IntradayData

the original Array.isArray improved this, but ended up with
any
Was this page helpful?