Skip to content

Function: objectPrototype() ​

objectPrototype<ObjectConstruct>(target): InferPrototype<ObjectConstruct>

Get the prototype of a class: its prototype property, typed as an instance of the class (the object holding its methods, where the decorators store their metadata).

Type Parameters ​

ObjectConstruct ​

ObjectConstruct extends Function

Parameters ​

target ​

ObjectConstruct

A class. A function without prototype (an arrow function, a method) gives undefined.

Returns ​

InferPrototype<ObjectConstruct>

The class's prototype.

Example ​

typescript
import {objectPrototype} from 'lakutata/utils'

class User {
    public greet(): string {
        return 'hello'
    }
}

const prototype: User = objectPrototype(User)
console.log(prototype === User.prototype, typeof prototype.greet)
//true function

Released under the MIT License.