As someone who is learning TypeScript, I have been exploring various sources and courses in order to enhance my skills. However, I have encountered a challenge regarding how to make the compiler prompt for arguments when defining a typed function.
Let's consider a straightforward example: imagine I have a function that expects two strings, firstName
and lastName
, and should return their concatenation:
type FuncType = (firstName: string, lastName: string) => string;
const getFullName: FuncType = () => "";
It is evident that the function definition here is incomplete. Nevertheless, at this stage of defining the function, I would have expected the compiler to notify me of the missing parameters (firstName
and lastName
) as they are clearly required based on the type FuncType
.
However, that is not happening. Can anyone guide me on what I might be overlooking?