1

I have a function like this

export const createMemberId: (x: any) => Maybe<MemberId> = (x: any) => {
    try {
        return Just({
            memberId: mongoose.Types.ObjectId(x),
        });
    } catch (e) {
        return Nothing;
    }
};

It gets any and return Maybe<MemberId>

But typescript show me this error

`Maybe` refers to a value, but being used as type here

What should I do?

mohsen saremi
  • 685
  • 8
  • 22
  • This is the problem discussed in [sanctuary-js/sanctuary#649](https://github.com/sanctuary-js/sanctuary/issues/649), I believe. – davidchambers Dec 26 '19 at 08:52
  • I saw that issue but didn't find solution. Can you explain how should I do this? – mohsen saremi Dec 26 '19 at 08:59
  • The problem is that the `Maybe` export refers to [`S.Maybe`](https://sanctuary.js.org/#Maybe) rather than to a type constructor. This is one of several problems that currently prevent me from recommending the use of Sanctuary in a TypeScript project. – davidchambers Dec 26 '19 at 12:40

0 Answers0