Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

E016: Cyclic Type Import

Severity: Warning

type import of `./b.nix` is cyclic — it leads back to this file; the imported type is unconstrained

A type-level import in a doc comment — import("./b.nix").T or typeof import("./b.nix") — needs the other file’s types, but inferring that file leads back to the file being checked (directly, or through further imports). Tix breaks the cycle by treating the imported type as unconstrained (?) at the point where it loops.

Common causes

  • Two files whose annotations reference each other’s exported types.
  • A type T = typeof value; export whose value imports a file that annotates something with import("<this file>").T.

How to fix

  • Move the shared type into a .tix stub, or into an inline type alias in one of the files, so neither file needs the other’s inference to know it.
  • Break the cycle by annotating one side with an explicit type instead of typeof.