TypeScript: type of the current class as a type variable

I want to declare a function in TypeScript that returns the type of the current instance type, for example. in a free API that returns this .

Is there a type variable for this type? (I would prefer not to use the ugly Java method X<T extends X<T>> .)

+5
source share
1 answer

There is no way to do this in TypeScript yet. See Question https://github.com/Microsoft/TypeScript/issues/285 for voting / discussion.

+7
source

Source: https://habr.com/ru/post/1211515/


All Articles