Home / Companies / Nx / Blog / Post Details
Content Deep Dive

Full-Stack Type Safety Across Languages with @nx/dotnet

Blog post from Nx

Post Details
Company
Nx
Date Published
Author
Craigory Coppola
Word Count
1,699
Company Posts That Month
4
Language
English
Hacker News Points
-
Post removed?
No
Summary

Nx can provide end-to-end type safety between a C# backend and TypeScript frontend in a polyglot monorepo by generating TypeScript types from a .NET API’s OpenAPI specification and incorporating the process into its task graph. Using the @nx/dotnet plugin, Nx infers .NET project builds and dependencies, while ASP.NET Core produces an OpenAPI JSON document during the API build; the @hey-api/openapi-ts generator then converts that document into TypeScript types, including API field descriptions as JSDoc. By declaring an implicit dependency from the types library to the API, configuring code generation to depend on the API build, and hashing dependent task output files, Nx ensures regenerated types reflect API-contract changes while preserving cache efficiency when outputs are unchanged. Target defaults further make build, serve, and typecheck tasks run code generation before consuming projects compile, so changes such as renaming a C# DTO property automatically cause affected TypeScript code to fail type checking. Although the example uses OpenAPI, the same build-schema-generate-task-graph pattern can support protobuf, GraphQL, or database schemas, and several community Nx plugins can automate parts of the OpenAPI workflow.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.