mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-04 18:00:08 +00:00
add: hasOwnProperty
This commit is contained in:
@@ -204,3 +204,13 @@ export function validateSlashCommands(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Typescript is not so good as we developers so we need this little utility function to help it out
|
||||
// Taken from https://fettblog.eu/typescript-hasownproperty/
|
||||
/** TS save way to check if a property exists in an object */
|
||||
export function hasOwnProperty<T extends {}, Y extends PropertyKey>(
|
||||
obj: T,
|
||||
prop: Y,
|
||||
): obj is T & Record<Y, unknown> {
|
||||
return obj.hasOwnProperty(prop);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user