<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/full-stack-type-safety-across-languages-with-nx-dotnet-ka8begadt" -->

---
title: Full-Stack Type Safety Across Languages with @nx/dotnet
description: A walkthrough shows how to keep a C# backend and TypeScript frontend type-safe in an Nx monorepo by generating an OpenAPI document from a .NET API at build...
canonical: https://daily.dev/posts/full-stack-type-safety-across-languages-with-nx-dotnet-ka8begadt
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Full-Stack Type Safety Across Languages with @nx/dotnet | daily.dev
og:description: A walkthrough shows how to keep a C# backend and TypeScript frontend type-safe in an Nx monorepo by generating an OpenAPI document from a .NET API at build...
og:url: https://daily.dev/posts/full-stack-type-safety-across-languages-with-nx-dotnet-ka8begadt
og:image: https://api.daily.dev/og/posts/ka8BeGAdt.png
og:image:alt: Full-Stack Type Safety Across Languages with @nx/dotnet
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

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

**[Nx](https://daily.dev/sources/nx)** · 8 min read · 1 upvotes · 0 comments

## Summary

A walkthrough shows how to keep a C# backend and TypeScript frontend type-safe in an Nx monorepo by generating an OpenAPI document from a .NET API at build time and turning it into TypeScript types via @hey-api/openapi-ts. It covers installing @nx/dotnet, wiring codegen into the Nx task graph with implicitDependencies and dependentTasksOutputFiles, and configuring targetDefaults so builds, serves, and typechecks stay in sync automatically. Renaming a C# property causes downstream TypeScript consumers to fail typechecking, demonstrating end-to-end type safety. The same pattern is said to generalize to protobuf, GraphQL SDL, or database schemas, and three community MIT plugins are mentioned as alternatives to hand-wiring.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://nx.dev/blog/dotnet-openapi-type-safety>

## Questions this post answers

### How do I automatically generate TypeScript types from a .NET API's OpenAPI document in an Nx monorepo?

Add the Microsoft.Extensions.ApiDescription.Server package to the .NET webapi project so dotnet build writes an OpenAPI document into the obj folder, then run the @hey-api/openapi-ts CLI against that document with the typescript plugin to emit types. Wire a codegen target with dependsOn ^build and implicitDependencies pointing at the .NET project so Nx orders and caches the steps correctly.

_Developers gluing .NET and TypeScript codebases together can track patterns like this on daily.dev._

### How does Nx keep generated TypeScript types in sync with a .NET OpenAPI spec without rebuilding everything every time?

Nx caches the codegen target by hashing dependentTasksOutputFiles (the OpenAPI JSON document) instead of source files, plus the library's own package.json and sharedGlobals. If a C# comment changes but the OpenAPI document stays identical, the build output is unchanged so the cached TypeScript types are reused instead of regenerated, keeping frontend-only work instant.

_Teams optimizing monorepo build caching can follow discussions like this on daily.dev._

### What happens if I rename a property on a C# record that's exposed through OpenAPI to a TypeScript frontend?

Renaming a property like Name to Title on a C# record causes the OpenAPI document to change, which invalidates the cached TypeScript types, and running nx run-many -t typecheck then fails with a TS2353 error in any consuming file still referencing the old property name, catching the break at typecheck time rather than at runtime.

_daily.dev helps developers stay ahead of breaking API contract changes across full-stack projects._

## Similar posts on daily.dev

- [Full-stack static typing with OpenAPI TypeScript and Microsoft.AspNetCore.OpenApi](https://daily.dev/posts/full-stack-static-typing-with-openapi-typescript-and-microsoft-aspnetcore-openapi-irja8ajaq) · John Reilly · 3 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#general-programming](https://daily.dev/tags/general-programming), [#typescript](https://daily.dev/tags/typescript), [#.net](https://daily.dev/tags/.net), [#openapi](https://daily.dev/tags/openapi)

[View this post on daily.dev](https://daily.dev/posts/full-stack-type-safety-across-languages-with-nx-dotnet-ka8begadt)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Full-Stack Type Safety Across Languages with @nx/dotnet","url":"https://daily.dev/posts/full-stack-type-safety-across-languages-with-nx-dotnet-ka8begadt","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/full-stack-type-safety-across-languages-with-nx-dotnet-ka8begadt"},"datePublished":"2026-09-01T15:01:29.462Z","dateModified":"2026-09-01T15:01:58.652Z","description":"A walkthrough shows how to keep a C# backend and TypeScript frontend type-safe in an Nx monorepo by generating an OpenAPI document from a .NET API at build...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9716faf1b27f8e9170994bfcab10951a?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9716faf1b27f8e9170994bfcab10951a?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Nx","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Nx","logo":"https://media.daily.dev/image/upload/s--09OCt--d--/f_auto/v1761722266/logos/nx","url":"https://daily.dev/sources/nx"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/full-stack-type-safety-across-languages-with-nx-dotnet-ka8begadt","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"webdev,general-programming,typescript,.net,openapi","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Nx","item":"https://daily.dev/sources/nx"},{"@type":"ListItem","position":3,"name":"Full-Stack Type Safety Across Languages with @nx/dotnet"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/full-stack-type-safety-across-languages-with-nx-dotnet-ka8begadt#faq","mainEntity":[{"@type":"Question","name":"How do I automatically generate TypeScript types from a .NET API's OpenAPI document in an Nx monorepo?","acceptedAnswer":{"@type":"Answer","text":"Add the Microsoft.Extensions.ApiDescription.Server package to the .NET webapi project so dotnet build writes an OpenAPI document into the obj folder, then run the @hey-api/openapi-ts CLI against that document with the typescript plugin to emit types. Wire a codegen target with dependsOn ^build and implicitDependencies pointing at the .NET project so Nx orders and caches the steps correctly. Developers gluing .NET and TypeScript codebases together can track patterns like this on daily.dev."}},{"@type":"Question","name":"How does Nx keep generated TypeScript types in sync with a .NET OpenAPI spec without rebuilding everything every time?","acceptedAnswer":{"@type":"Answer","text":"Nx caches the codegen target by hashing dependentTasksOutputFiles (the OpenAPI JSON document) instead of source files, plus the library's own package.json and sharedGlobals. If a C# comment changes but the OpenAPI document stays identical, the build output is unchanged so the cached TypeScript types are reused instead of regenerated, keeping frontend-only work instant. Teams optimizing monorepo build caching can follow discussions like this on daily.dev."}},{"@type":"Question","name":"What happens if I rename a property on a C# record that's exposed through OpenAPI to a TypeScript frontend?","acceptedAnswer":{"@type":"Answer","text":"Renaming a property like Name to Title on a C# record causes the OpenAPI document to change, which invalidates the cached TypeScript types, and running nx run-many -t typecheck then fails with a TS2353 error in any consuming file still referencing the old property name, catching the break at typecheck time rather than at runtime. daily.dev helps developers stay ahead of breaking API contract changes across full-stack projects."}}]}
```

