End to End Type Safety in a Monorepo

Juri Strumpflohner
Published
A walkthrough of Craigory’s full-stack type safety demo: an ASP.NET Core API and TypeScript frontends in one Nx monorepo. The .NET build emits an OpenAPI spec, codegen turns it into TypeScript types, and the Nx task graph keeps both sides in sync, so renaming a property in C# fails the TypeScript typecheck.
-
🔗 Links:
-
Blog post, Full-Stack Type Safety Across Languages with @nx/dotnet: https://nx.dev/blog/dotnet-openapi-type-safety
-
Demo repo: https://github.com/nrwl/nx-examples
-
@nx/dotnet docs: https://nx.dev/docs/technologies/dotnet/introduction
-
📚 Related:
-
Polyglot Nx Monorepo with Rust and TanStack: https://youtu.be/lyHbNUdLQhI
⏱ Chapters:
- 00:00 Coming up
- 00:37 Why frontend and backend share a repo
- 01:43 The @nx/dotnet type safety blog post
- 02:36 Explore the workspace with nx graph
- 04:50 The .NET products API
- 05:26 Add .NET support with @nx/dotnet
- 07:05 Inferred targets and caching
- 08:18 Share the C# type with the frontend
- 09:01 OpenAPI spec from the .NET build
- 10:25 Generate TypeScript types with codegen
- 12:53 Restore types through the task pipeline
- 15:12 Implicit dependencies and dependsOn
- 17:15 Cache generated types across tasks
- 18:09 Rename in C#, typecheck fails
- 19:08 Wrap-up