You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
463 B

/**
* Interface that designates a particular value as able to be constructed.
*/
export default interface Instantiable<T> {
new(...args: any[]): T
}
/**
* Returns true if the given value is instantiable.
* @param what
*/
const isInstantiable = <T>(what: any): what is Instantiable<T> => {
return (typeof what === 'object' || typeof what === 'function') && 'constructor' in what && typeof what.constructor === 'function'
}
export { isInstantiable }