-
Notifications
You must be signed in to change notification settings - Fork 11
Custom Generic Methods & Functions
Roman Jámbor edited this page Jul 19, 2021
·
6 revisions
It is possible to declare custom methods and functions working with generic parameters. Such methods and functions must have JSDoc comment with property @reflectGeneric. It is needed because of optimization.
Decorator would be nicer, but it is not generated on interfaces and abstract things by the TypeScript, because it does not exist on runtime
/**
* @reflectGeneric
*/
function printTypeFullName<TType>() {
console.log(getType<TType>().fullName);
}
class Animal {}
printTypeFullName<Animal>();