Back to browse
GitHub Repository
0 starsTypeScript

Wit-ts – A type-level WIT parser for TypeScript

by mattmarcello·Feb 17, 2026·1 point·0 comments

AI Analysis

●●SolidBig BrainNiche Gem

abitype for WebAssembly—pure types from WIT strings, but adoption depends on Component Model maturity.

Strengths
  • Dual parsing (runtime + type-level) with zero codegen—pure TypeScript string inference
  • Two-pass type resolution handles complex nested records, variants, and enums correctly
  • Directly inspired by abitype's proven pattern; same DX philosophy applied to WIT
Weaknesses
  • WebAssembly Component Model is pre-1.0 and not yet production-adopted; tooling ecosystem immature
  • No formatter, documentation, or runnable examples in repo—unclear if beyond proof-of-concept
Target Audience

WebAssembly component authors using TypeScript

Similar To

abitype · TypeChain

Post Description

I wrote a parser (runtime and type-level) for WebAssembly Interface Types (https://component-model.bytecodealliance.org/design/wit.html).

const wit = [ "record user { name: string, age: u32 }", "variant api-error { not-found, unauthorized(string) }", "get-user: func(id: u64) -> user;", "create-post: func(author: user, post: post) -> result<post, api-error>;", ] as const;

type Client = WitClient<ParseWit<typeof wit>>; // Client["get-user"]: (id: bigint) => Promise<{ name: string; age: number }> // Client["create-post"]: (author: ...) => Promise<["ok", {...}] | ["err", ["not-found"] | ["unauthorized", string]]>

Why did I do this? Good question. I originally did this work as part of this project: https://sdk.kontor.network/. Kontor is a new Bitcoin metaprotocol that uses WITs to define smart contract interfaces.

I carved wit-ts out of the project and removed some domain specific stuff from it, refactored some internals, and extended it to be compatible with a broader subset of the wit specification. Technically there are some valid wit types that would not be handled cleanly here ( e.g. recursive types ).

Tremendous debt is owed to the https://github.com/wevm/abitype project, which does the same thing for Ethereum ABIs and was the direct inspiration for the type-level approach.

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