Skip to content

Instantly share code, notes, and snippets.



Last active Jan 10, 2020
What would you like to do?
// Let's define our valueToFilter type
const filterArrayByValue = <T, P extends keyof T>(
items: T[],
propertyName: P,
valueToFilter: T[P] //Partial<T>
): T[] => {
return items.filter(item =>item[propertyName] === valueToFilter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment