Skip to content

Custom Generic Methods & Functions

Roman Jámbor edited this page Jul 19, 2021 · 6 revisions

Custom Generic Methods & Functions

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.

/**
 * @reflectGeneric
 */
function printTypeFullName<TType>() {
	console.log(getType<TType>().fullName);
}

class Animal {}

printTypeFullName<Animal>();
Clone this wiki locally