'typescript gives property is missing a type
I have a function with some default values, when I try to call the function and since it has some defaults so I do not need to pass in any values for defaults for example
function myFunc(
{
str1,
str2,
timeout = 3000,
} : {
str1: string,
str2: string,
timeout: number,
}
): Promise<any | undefined> {
// some logics here
}
await myFunc({
str1: 'string 1',
str2: 'string 2'
})
I get an error such as
Property 'timeout' is missing in type '{ str1: string; str2: string; timeout: number;}'
How can I resolve this since there is a default value declared, I shouldn't have to pass in the property if I don't need to override the default isn't it?
Thanks in advance for any help and suggestions.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
