Function: objectParentConstructor()
Call Signature
objectParentConstructor<
ClassConstructor>(target):Function|null
Get the parent class of a class: the one it extends.
Type Parameters
ClassConstructor
ClassConstructor extends Function
Parameters
target
ClassConstructor
A class. The types only accept a class, but an object passed with a cast gives its class's parent (objectParentConstructor(new Admin() as any) is objectParentConstructor(Admin)).
Returns
Function | null
The parent class, or null for a class which extends nothing (a base class, Object), a plain object, or a function which is not a class (an arrow function).
Example
import {objectParentConstructor} from 'lakutata/utils'
class User {
}
class Admin extends User {
}
console.log(objectParentConstructor(Admin) === User, objectParentConstructor(User))
//true nullCall Signature
objectParentConstructor<
ClassPrototype>(target):Function|null
Get the parent class of a class: the one it extends.
Type Parameters
ClassPrototype
ClassPrototype extends Object
Parameters
target
IConstructor<ClassPrototype>
A class. The types only accept a class, but an object passed with a cast gives its class's parent (objectParentConstructor(new Admin() as any) is objectParentConstructor(Admin)).
Returns
Function | null
The parent class, or null for a class which extends nothing (a base class, Object), a plain object, or a function which is not a class (an arrow function).
Example
import {objectParentConstructor} from 'lakutata/utils'
class User {
}
class Admin extends User {
}
console.log(objectParentConstructor(Admin) === User, objectParentConstructor(User))
//true null