Use a ref to break the self-reference cycle that caused TS7022. Co-authored-by: Orca <help@stably.ai>