When I learn TypeScript types, infer keyword is one of the most difficult concepts. This article tries to give a simple explanation to this confusing topic.
In the official documentation, infer is mentioned in the Conditional Types section:
Within the
extends
clause of a conditional type, it is now possible to haveinfer
declarations that introduce a type variable to be inferred. Such inferred type variables may be referenced in the true branch of the conditional type. It is possible to have multipleinfer
locations for the same type variable.
If the above definition is as clear as mud to you, don’t worry, you’re not alone.
#javascript #typescript #progamming #web-development #webdev