14. implement ThisParameterType<T>

TypeScript
Is this helpful ?

  - accepted / - tried

For a function type T, ThisParameterType<T> extracts the this type. If this is not set, unknown is used.

Please implement MyThisParameterType<T> by yourself.

function Foo(this: {a: string}) {}
function Bar() {}

type A = MyThisParameterType<typeof Foo> // {a: string}
type B = MyThisParameterType<typeof Bar> // unknown

Let's try to solve this problem within 5 mintues.

Discuss(4)