Skip to content

馃悰 Fix import cycles - #174

Merged
flovouin merged 2 commits into
mainfrom
fix/cycles
Aug 6, 2026
Merged

馃悰 Fix import cycles#174
flovouin merged 2 commits into
mainfrom
fix/cycles

Conversation

@flovouin

@flovouin flovouin commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

馃摑 Description of the PR

Removes the circular imports present in the nestjs sources. Three cycles existed: between the error DTOs and the OpenAPI decorators, within the pagination decorators, and between the healthcheck barrel and its module.

Because the project compiles with verbatimModuleSyntax, an import { X } statement is emitted verbatim into the JavaScript output even when X is only ever used in a type position. Several OpenAPI and pagination decorators imported classes purely for typing, which turned type-only dependencies into real runtime edges. These are now import type statements, which are fully erased at compile time. Modules that reached for a sibling barrel re-exporting them now import the specific file they need instead.

The error DTO cycle was the one that could actually fail at runtime: try-map.ts builds its error cases at module load time, so entering the cycle from the wrong side left a DTO class in its temporal dead zone. The healthcheck cycle was latent rather than live, as the shared constant is only read inside a static factory method; it would have become a genuine failure as soon as anything used it during module evaluation. To break it, HEALTHCHECK_ENDPOINT moved out of the healthcheck barrel into its own module, and the barrel re-exports it.

The public API is unchanged: every symbol is still exported from the same package entry points as before.

馃搵 Check list

  • 馃И Unit tests have been written.
  • 馃摑 Documentation has been updated.

@flovouin flovouin added the bug Something isn't working label Aug 6, 2026
@flovouin
flovouin merged commit 7690c2b into main Aug 6, 2026
2 checks passed
@flovouin
flovouin deleted the fix/cycles branch August 6, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant