Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Constructor<T = {}> = new (...args: any[]) => T;
- interface Properties <TBase> {
- value: TBase
- }
- function ResponseObject<TBase extends Constructor>(Base: TBase): TBase {
- return class extends Base implements Properties<TBase> {
- public value: TBase;
- constructor (...values: any[]) {
- let thisType = typeof values[0];
- if (thisType == "object" ||
- thisType == "number" ||
- thisType == "boolean"
- ) { super(values[0]); }
- if (Base.toString() == "Array") {
- super(...values);
- }
- this.value = values[0];
- }
- public toBlaze(): string{
- return "OK!";
- }
- }
- }
- const Responsed = ResponseObject(Number);
- const Res = new Responsed(56.02323);
- console.log(Res.toBlaze());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement