Skip to main content
Deno 2 is finally here 🎉️
Learn more
Extremely Popular
Go to Latest
function hasProperty
Re-export
import { hasProperty } from "https://deno.land/x/discordeno@17.2.0/plugins/validations/deps.ts";

TS save way to check if a property exists in an object

Type Parameters

T extends { }
optional
Y extends PropertyKey = string

Parameters

obj: T
prop: Y

Returns

obj is T & Record<Y, unknown>