I am new to Typescript and have a doubt regarding function type.
I have the following type :
type IMyTest<R> = (
arg1: number,
arg2: string,
arg3: number
) => R;
Now, following signature is valid (doesn't give me an error) and I don't understand why its valid. As per my understandings, arg2 and arg3 are not marked as optional using the "?" sign and so the TypeScript compiler should raise an error, but it's not:
const myTest3: IMyTest<string> = (arg1: number):string => {
return "any string";
};
Live example on the playground
Is there any way to make the arguments mandatory ?
Right now, arg1?:string is same as arg1:string. According to my understandings,without the "?" sign, an argument is mandatory. But, that's not the case in here.