facebook/idx

`UnboxDeepRequired doesn't support enum type.

Closed this issue · 1 comments

enum MyEnum {
  'a' = 'a',
  'b' = 'b',
}
type MyType = {
  enum: MyEnum;
};
const e: MyEnum | null | undefined = idx({} as MyType, _ => _.enum);

Got:

Type 'IDXOptional<string>' is not assignable to type 'MyEnum | null | undefined'.
  Type 'string' is not assignable to type 'MyEnum | null | undefined'.ts(2322)

Because idxs return type is string | null | undefined instead of MyEnum | null | undefined

Related PR: #76

@mohsen1 @brieb @yungsters

I wonder if it's possible to narrow to your enum type before string without having access to that MyEnum type.

Don't forget that idx is a generic and you can always provide the type argument directly instead of relying on type inference.

I'll look into this later this week.