When I try to use a generic type with an arrow function in Typescript Playground, I get an error message saying Cannot find name 'T'
For more details, check out this link
function hasAllProperties <T>(obj: any, props: (keyof T)[]): obj is T {
return props.every((prop) => obj.hasOwnProperty(prop))
}
// This code throws an error and won't compile
const hasAllPropertiesArrow = <T>(obj: any, props: (keyof T)[]): obj is T => {
return props.every((prop) => obj.hasOwnProperty(prop))
}
Since I am new to generic types, I believe the issue lies in my lack of understanding rather than a bug in the TypeScript playground. Could someone please help me rewrite the normal function as an arrow function?