Although I haven't fully resolved TypeScript issues on my own, I have encountered the need for generic types with different arguments several times. Due to my limited understanding of this topic, I have decided to ask for assistance. The task at hand seems straightforward:
interface sampleType{
typeOne: (arg1:number,arg2:customType) => 0 | Promise<any>
typeTwo: (arg1:string) => 0 | Promise<any>
typeThree: () => 0 | Promise<any>
}
What I aim to achieve is as follows:
const caseOne:sampleType<number,customType>;
const caseTwo:sampleType<string>;
const caseThree:sampleType;
The generic type "sampleType" requires one type argument.
I would like to implement such a type feature, but I am unsure how to create an optional type. Perhaps using overloading could be a solution, but I have yet to find a way:
type simpleType<T1, T2> = (arg1?: T1, arg2?: T2) => 0 | Promise<any>;;
This summarizes my current dilemma, and I welcome any advice or suggestions on alternative approaches for writing clean TypeScript code.