---
title: "Discussion on \"Topological Sorting, TDZ Crashes, and z.lazy() Cycle Guards: The Hidden Compiler Challenges of OpenAPI-to-Zod Codegen\" | Hashnode"
description: "Discussion on \"Topological Sorting, TDZ Crashes, and z.lazy() Cycle Guards: The Hidden Compiler Challenges of OpenAPI-to-Zod Codegen\". Why alphabetical Zod schema generation crashes with TDZ ReferenceErrors, how to handle circular $ref trees with z.lazy(), and OpenAPI 3.0 vs. 3.1 tips."
url: "https://hashnode.com/posts/topological-sorting-tdz-crashes-and-z-lazy-cycle-guards-the-hidden-compiler-challenges-of-openapi-to-zod-codegen/6b05716ba8766ca11e2de383"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Topological Sorting, TDZ Crashes, and z.lazy() Cycle Guards: The Hidden Compiler Challenges of OpenAPI-to-Zod Codegen](https://kivarotools.hashnode.dev/topological-sorting-tdz-crashes-and-z-lazy-cycle-guards-the-hidden-compiler-challenges-of-openapi-to-zod-codegen?utm_source=hashnode&utm_medium=feed)

Why alphabetical Zod schema generation crashes with TDZ ReferenceErrors, how to handle circular $ref trees with z.lazy(), and OpenAPI 3.0 vs. 3.1 tips.

3d ago · 3 min read · kivarotools.hashnode.dev  
Read the article

-   [#typescript](https://hashnode.com/tag/typescript)
-   [#zod](https://hashnode.com/tag/zod)
-   [#openapi](https://hashnode.com/tag/openapi)
-   [#compilers](https://hashnode.com/tag/compilers)
-   [#webdev](https://hashnode.com/tag/webdev)

## Written by

[Muhammad Ahmad](https://hashnode.com/@muhammadahmadsandhu)

@muhammadahmadsandhu · Pakistan

  
[View profile](https://hashnode.com/@muhammadahmadsandhu)

Founder & Lead Software Architect @ KivaroTools | BS Computer Science | Full-Stack & Systems Engineer

Founder &amp; Lead Software Architect @ KivaroTools | BS Computer Science | Full-Stack &amp; Systems Engineer (TypeScript, Next.js, Python, Java, C++, WebAssembly) | Privacy-First Web &amp; Financial Engines

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
