Thanks to visit codestin.com
Credit goes to tsed.dev

Skip to content

getConstructor

@tsed/core

Usage

typescript
import { getConstructor } from "@tsed/core";

See /packages/core/src/utils/constructorOf.ts.

Overview

ts
function getConstructor(target: any): Type<any>;
  • target (any): A class constructor or an instance.

Description

Get the class constructor from a class or an instance.

If target is already a constructor, it is returned as-is; otherwise the constructor of the instance is returned.

ts
class A {}
getConstructor(A) === A; // true
getConstructor(new A()) === A; // true

Released under the MIT License.