typescript-book
typescript-book copied to clipboard
Generic instantiation
In type space using type e.g.
type Foo<T> = {foo: T}
type Bar = Foo<number>;
In variables space (investigating):
// A function that takes argument of type `T`
// And returns an object of type `{foo:T}`
const foo = <T>(x: T) => ({ foo: x });
// Instantiate `T` as number in a variable bar
const bar = foo<number>; // Error: Invalid syntax