'Where in Typescript Generics
I have a function that takes an object and a name of a class (which is contained by that object). Getting all the properties of an object isn't hard (keyof O), and figuring out if a key is a class isn't hard either (O[N] extends {new: (..args: any[]) => any}). However, I cant combine them:
function foo<O, N extends keyof O where O[N] extends {new: (...args: any[]) => any}> (obj: O, name: N){}
I have seen Extract<T, U>, but I can not use T inside of the check for U. How else would I go about this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
