I want to create a re-usable type for functions, so that I can say:
type MyFunc = ...
const func1: MyFunc = ...
const func2: MyFunc = ...
The following doesn't work, but basically I want:
type Book = {
id: string;
title: string;
}
type createBook = (book: Partial<Book>) => Book;
const someBookFactory: createBook = ({ title }) => ({ id: /* autogenerated */, title });
const someOtherBookFactory: createBook = ({ id, title }) => ({ id, title });
Is this possible in TypeScript?