I'm currently trying to use Ramda with Typescript, but i can't find any examples about declaring types for functions expressions created by pipe (or compose) function, below is my code:
interface VersionObject {
major: number;
minor: number;
patch: number;
}
const parseVersionString = pipe(
split('.'),
map(unless(isNaN, parseInt)), // btw, ts complain about this parseInt
zip(['major', 'minor', 'patch']),
fromPairs
);
What i'm trying to do is to declare that parseVersionString
receives an string
and returns a VersionObject
, how could i do that?
Two syntax variants which are equivalent:
const parseVersionString: (s: string) => VersionObject = pipe(
const parseVersionString: { (s: string): VersionObject } = pipe(
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.