Перейти к основному содержимому

Разные шаблоны

Абстрактный конструктор

type TConstructor<T> = new (...args: any[]) => T;

Еще вариант:

interface IConstructor<T> extends Function {
new (...args: any[]): T;
}

https://www.typescriptlang.org/docs/handbook/generics.html#using-class-types-in-generics

Тип Ссылка на класс

class Class1 { }
let Cls: typeof Class1;
Cls = Class1;

Доступ к классу из метода его экземляров

class Class1 {
static method1() {}
constructor() {
(this.constructor as typeof Class1).method1();
}
}

Описание this в функциях

type MyFunction = (this: number, a: number) => void;

const func1: MyFunction = function(a: number) {
let b = this; // number
}

Тип элемента массива

type TArray1 = (string  |number)[]
type TArrayElementType<A extends Array<any>> = NonNullable<ReturnType<A['pop']>>;
let c: TArrayElementType<TArray1>; // c typeof (string |number)

Песочница

Ключ класса или интерфейса

P extends keyof T

Здесь P ключ класса T.
Песочница