Skip to content
Advertisement

type hinting a function that takes the return type as parameter

Is there a way to type hint a function that takes as argument its return type? I naively tried to do this:

JavaScript

but it doesn’t work.

Advertisement

Answer

Have a look at Generics, especially TypeVar. You can do something like this:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement