Attempting to reproduce the code found in this blog post, but encountering some perplexing errors.
import { option, identity, apply } from 'fp-ts';
import type { Kind, URIS } from 'fp-ts/HKT';
import { pipe } from 'fp-ts/lib/function';
type OrderId = string;
type OrderState = 'active' | 'deleted';
interface User {
readonly name: string;
readonly isActive: boolean;
}
interface OrderHKD<F extends URIS> {
readonly id: Kind<F, OrderId>;
readonly issuer: Kind<F, User>;
readonly date: Kind<F, Date>;
readonly comment: Kind<F, string>;
readonly state: Kind<F, OrderState>;
}
type Order = OrderHKD<identity.URI>;
type OrderOption = OrderHKD<option.URI>;
const validateOrder = (inputOrder: OrderOption): option.Option<Order> =>
pipe(inputOrder, apply.sequenceS(option.Apply));
// ^
// | here
// Argument of type '<NER extends Record<string, Option<any>>>(r: EnforceNonEmptyRecord<NER>) => Option<{ [K in keyof NER]: [NER[K]] extends [Option<infer A>] ? A : never; }>' is not assignable to parameter of type '(a: OrderOption) => Option<{ [x: string]: any; }>'.
// Types of parameters 'r' and 'a' are incompatible.
// Type 'OrderOption' is not assignable to type 'Record<string, Option<any>>'.
// Index signature for type 'string' is missing in type 'OrderHKD<"Option">'.ts(2345)