Back to browse
GitHub Repository

Seamless, type-safe interop between .NET WebAssembly and TypeScript

12 starsC#

TypeShim – .NET WebAssembly Meets TypeScript

by ArcadeMode·Mar 3, 2026·1 point·1 comment

AI Analysis

●●SolidBig BrainNiche Gem

Auto-generates type-safe .NET↔TypeScript glue code, but WASM-in-JS is still niche.

Strengths
  • Eliminates manual JSExport/JSImport boilerplate with single [TSExport] annotation, removing the biggest friction point for .NET WASM interop.
  • Sub-100ms codegen with comprehensive test coverage across multiple runtimes ensures reliable, production-ready code generation.
  • Full OOP support (classes, instance members, constructors, value types) maps cleanly across the interop boundary without object handle workarounds.
Weaknesses
  • Addresses a real pain in a genuinely small market: .NET WASM + TypeScript is an uncommon combination versus Blazor or pure JS/WASM stacks.
  • No evidence of adoption or feedback from users shipping this in production, limiting visibility into real-world pain points.
Target Audience

Developers building .NET WASM applications that interact with TypeScript frontend code.

Similar To

Blazor (Microsoft's higher-level WASM framework) · wasm-bindgen (Rust↔JS codegen, analogous approach)

Post Description

I'm a big proponent of WebAssembly and .NET. When I found out .NET now runs in the browser on WASM with ánd without Blazor, I figured that could be something. Since Blazor is often too big of a step for TypeScript developers, I figured the recently added ability to include a .NET WASM app as a library in a JS bundle could be a good stepping stone for WASM to gain some ground in this JS-heavy web we have.

Using the JSExport/JSImport interop is relatively cumbersome, it only supports static methods, has no OOP concepts (like classes, just object handles) and it requires manually writing TypeScript definitions for the exported methods. So I decided to try and make some tooling that would improve the developer experience and reliability higher.

Enter TypeShim: a codegen tool that creates a seamless programming experience between .NET WebAssembly and TypeScript. Complete class level exports are translated to C# codegen to automatically define your JSExports/JSImports with a TypeScript class that wraps these methods. This creates proxies that look exactly like your C# classes and behave all the same, static/member, constructors, properties, methods, even things like reference equality. TypeShim supports all types that JSExport supports but includes your own classes in that list, so it provides a superset of what JSExport offers.

--

As Roslyn codegen wouldnt allow me to generate code that the JSExport codegen could consume, I had to make my own CLI codegen tool (which was a lot of fun). Thank Roslyn for exporting its APIs, allowing me to run my own compilation, which I could then use to build C# and TypeScript matching the classes that were marked for export.

It was also a good excuse to do some performance optimization work (because why not?!), NativeAOT turned out particularly suited for such short-running tooling and by taking care of a few bottlenecks found with PerfView, I managed to get codegen times down to ~100ms for projects with 100+ classes requiring codegen.

It took me down paths I hadnt expected to ever expected to end up at, like finding two bugs while E2E testing the solution, which would crash the .NET WASM runtime, which led me to dive into the dotnet/runtime repo and fix them. The dotnet team was grateful and very welcoming, inviting me to try fixing the same issues in the new .NET11 interop implementation which runs on the CoreCLR instead of mono. Great experience, I'll be going back for more TypeShim adjacent challenges: adding more types to the interop library.

--

Anyway, that was a bit of excitement about my recent open source activity. If you have a moment to look at TypeShim, maybe even leave a star, that would be greatly appreciated. But mostly I would love to hear your feedback!

Best, ArcadeMode

Similar Projects

Security●●Solid

Leviathan-crypto – WebAssembly cryptography library for TypeScript

WASM isolation prevents JIT speculation attacks on key material—clever security layer.

WizardryBig Brain
vitonsky
102mo ago
SaaS●●Solid

DotNetDevs – a reverse job board for .NET developers

Clean, focused take on the RailsDevs idea for the .NET community — profiles include visibility flags (Actively Looking/Open to Opportunities/Not Interested), links to GitHub/LinkedIn, and project entries, plus employer filters for seniority and contract vs full-time. It isn't reinventing hiring, but the use of ASP.NET MVC + HTMX and a recruiter-free pitch make it a practical, well-scoped niche product that actually solves the 'LinkedIn noise' problem for .NET folks.

Niche GemSlickShip It
Nannooskeeska
203mo ago