It's like typeclass in functional style.
Scala example:
def f[T](implicit t: SomeTrait[T]): SomeTrait[T] = t
There is only a type parameter T, and the returned data t depends on it.
Can I do something similar in Typescript ?
It's like typeclass in functional style.
Scala example:
def f[T](implicit t: SomeTrait[T]): SomeTrait[T] = t
There is only a type parameter T, and the returned data t depends on it.
Can I do something similar in Typescript ?
This article on Ad-hoc polymorphism in TypeScript with implicit context has some partial solutions to this problem, but it really isn't pretty.