facebook / facebook/flow

[Help] Function that returns a polymorphic instance of a Class

Open
#4,210 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

So I have a class `DataLoader` - you may have recognized the [dataloader module](https://github.com/facebook/dataloader).

I have a function that returns a new DataLoader with default options.
```
const myFn = (batchLoadFn) => new DataLoader(batchLoadFn, { cache: false });
```

I tried to type it as
```
const myFn/*: (fn: any) => Dataloader */ = ... ;
```

But it won't work. Any idea on how to achieve the right typing?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.