/**
 * Interface for a function that returns a type.
 */
export type ForwardRefFn<T = any> = () => T;

/**
 * Interface for the object returned by forwardRef.
 */
export interface ForwardReference<T = any> {
	forwardRef: ForwardRefFn<T>;
}

/**
 * Allows to refer to a reference which is not yet defined.
 * Useful for circular dependencies between classes or modules.
 *
 * @param fn A function that returns the reference
 */
export function forwardRef<T>(fn: ForwardRefFn<T>): ForwardReference<T> {
	return { forwardRef: fn };
}
