facebook/idx

[TS] v2.5.0 DeepRequired generic breaks input.focus()

Closed this issue · 3 comments

After upgrading to v2.5.0 I get the following error:
screen shot 2018-11-23 at 16 39 54

Context:
screen shot 2018-11-23 at 16 39 36

@mohsen1, any ideas?

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

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;