Infer operator

The infer operator is used in conjunction with the extends operator in conditional types, and is used to get a specific part of a more complicated type. If the extends operator matches, the identifier declared by the infer operator can be used inside the true branch of the conditional type. When it fails, the identifier is set to the `never` type.

The infer operator is semantically equivalent to the `all` type, meaning that it matches all possible types. Like the `all` type, by default, the infer operator matches all remaining components of a multivalued type. In cases where this is not the desired behaviour, the infer operator can be supplied with a single generic parameter which determines how many type components it should match, e.g. `infer<1>` matches just a single component.

Example

The following example infers the element type of an array in order to be able to clear it.

This example creates a generic function which can call any other function and passes through all of its parameters and return types, but also logs the time it took to execute the function to the console. It is able to determine which parameter types the wrapped function has using the infer operator.