Suggestion
Add an overload to Boolean defintion
interface BooleanConstructor {
new(value?: any): Boolean;
- <T>(value?: T): boolean;
+ <T>(value?: T): value is Exclude<T, false | null | undefined | 0 | ''>
readonly prototype: Boolean;
}
playground
Use Cases
Array.filter
declare const actions: Array<(() => void) | null | undefined>
actions.filter(Boolean).forEach(act => act())
Checklist
My suggestion meets these guidelines:
Suggestion
Add an overload to
Booleandefintioninterface BooleanConstructor { new(value?: any): Boolean; - <T>(value?: T): boolean; + <T>(value?: T): value is Exclude<T, false | null | undefined | 0 | ''> readonly prototype: Boolean; }playground
Use Cases
Array.filterChecklist
My suggestion meets these guidelines: