14 lines
372 B
TypeScript
14 lines
372 B
TypeScript
|
class GenericClass<T> {
|
||
|
payload: T;
|
||
|
}
|
||
|
|
||
|
var genericObject = new GenericClass<{ greeting: string }>();
|
||
|
|
||
|
function genericFunction<T>(object: GenericClass<T>, callback: (payload: T) => void) {
|
||
|
callback(object.payload);
|
||
|
}
|
||
|
|
||
|
genericFunction(genericObject, ({greeting}) => {
|
||
|
var s = greeting.toLocaleLowerCase(); // Greeting should be of type string
|
||
|
});
|