[TS] v2.5.0 DeepRequired generic breaks input.focus()
Closed this issue · 3 comments
sseppola commented
sseppola commented
What improvement does the current definition give over the previous definition?
By the looks of it, now lets me write accessors without using !
in places where something could be null or undefined, eg:
const id = idx(this.props, _ => _.card!.id);
I'm by no means an expert here, but it seems like it thinks the function is an object here, so perhaps we could check if T is a function type first
mohsen1 commented
I'm looking into this. Something like this will fix it:
/**
* DeepRequired
* Required that works for deeply nested structure
*/
type DeepRequired<T> = T extends any[]
? DeepRequiredArray<T[number]>
: T extends (...args: any[]) => infer R
? (...args: any[]) => DeepRequired<R>
: T extends object ? DeepRequiredObject<T> : T;