I'm writing a mapper to translate between a serialized entity state and a form state.
Given two interfaces A and B: How can I get a third interface C that contains the properties that are present in A but missing in B?
interface A {
name: string;
age: number;
id: string;
version: number;
}
// could be written interface B extends Omit<A, "version" | "id"> {}
interface B {
name: string;
age: number;
}
interface PropertiesThatArePresentInAButNotInB {
// ???
}
// this is my mapper interface (just for illustrating the use case)
interface IEntityFormStateMapper<
E extends Entity<A>,
FS extends B,
OP extends PropertiesThatArePresentInAButNotInB
> {
toEntity: (formState: FS, omittedEntityProps: OP) => Result<Error, E>;
toFormState: (entity?: E) => Result<Error, [FS, OP]>;
}