Generics
interface GenericInterface<Data> {
content: Data
}
type FunctionOf<X, Y> = (i: X) => Y
// functions and classes can also receive type parameters.
function makeData<Input>(i: Input) {
return { data: i }
}
function cantInfer<Output>(i: any): Output {
return i
}
class GenericClass<Input> {
constructor(public data: Input) { }
}Argument inference
Bounded type parameters
Last updated