Sanctuary`Maybe`引用一个值,但在此处用作类型

时间:2019-12-26 07:50:18

标签: typescript maybe sanctuary

我有这样的功能

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

它得到any并返回Maybe<MemberId>

但是打字稿告诉我这个错误

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

我该怎么办?

0 个答案:

没有答案