Closed mattgrande closed 6 years ago
Should it be import S from 'sanctuary'
rather than import * as S from 'sanctuary'
? I don't know, I'm just suggesting something to try.
S.Maybe<number>
doesn't look right. S.Maybe
is not a TypeScript type constructor.
import S from 'sanctuary'
works the same as import * as...
, from what I'm seeing.
Oh well, thanks for your help.
S.Maybe<number>
doesn't look right.S.Maybe
is not a TypeScript type constructor.
That is the problem. This works:
import * as S from 'sanctuary';
interface Maybe<A> {
constructor: {
'@@type': 'sanctuary/Maybe';
};
}
const parseNumber = (v: string): Maybe<number> => {
const n = parseInt(v, 10);
return isNaN(n) ? S.Nothing : S.Just(n);
};
I don't know whether it's possible to import the Maybe
interface. You could ask the people who contributed the type definitions to DefinitelyTyped.
Cool, will do.
Running into the same issue. Was this ever resolved?
I'm no TypeScript expert, @elie222. Does the following work for you?
interface Maybe<A> {
constructor: {
'@@type': 'sanctuary-maybe/Maybe@1';
};
}
That didn't work for me, but the following did:
interface Maybe<A> {
'@@type': 'sanctuary/Maybe';
}
I guess I'm wondering if I'm doing something foolish here? I'm just getting errors when I try to specify my types. Eg,
This highlights the
S
inS.Maybe
saying "Cannot find namespace 'S'"I also tried importing the specific things:
... and that says "Cannot find name 'Maybe'." If I change everything to
any
, it works fine, so Sanctuary is there & working, but not the types.Versions in package.json: