facebook/idx

Accessing Data on Void

bezreyhan opened this issue · 1 comments

I get type errors when trying to access nested data on a value that could be void.

For example:

const fetchData: Promise<void | {data: {nested: 1}}>;
const response = await fetchData();
const nested = idx(response, _ => _.data.nested);

I get the following error from TypeScript: Property 'data' does not exist on type 'void'

Since the type void will always be undefined or null, shouldn't the code above pass the type checker?

Btw, thanks for this tool!

There is no active development on this project. If you are interested in fixing this, you are encouraged to send a pull request with tests. I can help review (or find reviewers) and merge, then publish.