TypeScript Bindings Patterns

Develop TypeScript bindings and SDK packages for Rust libraries using NAPI-RS.

115|8|Updated Mar 30, 2025
One-click install
npx skills add https://github.com/Goldziher/spikard --skill typescript-bindings-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: TypeScript Bindings Patterns
Source: https://github.com/Goldziher/spikard/tree/main/.ai-rulez/skills/typescript-bindings-patterns
Command: npx skills add https://github.com/Goldziher/spikard --skill typescript-bindings-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses the need for efficient and type-safe communication between Rust core logic and TypeScript applications by providing robust bindings and SDK packages.

Core Features & Use Cases

  • NAPI-RS FFI: Implements the Foreign Function Interface using NAPI-RS for seamless Rust-TypeScript integration.
  • TypeScript SDK: Develops TypeScript-idiomatic APIs and type definitions.
  • Documentation: Ensures all exports are well-documented with JSDoc, including parameter, return, and example annotations.
  • Use Case: A developer needs to expose a high-performance Rust library for data processing to a Node.js application. This Skill ensures the Rust functions are callable from TypeScript with proper type safety and clear documentation.

Quick Start

Execute the pnpm build command to compile the TypeScript bindings.

Frequently Asked Questions about TypeScript Bindings Patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create TypeScript bindings for a Rust core library?

To create TypeScript bindings for a Rust core library, use NAPI-RS to develop the FFI bridge, ensuring type-idiomatic APIs and comprehensive JSDoc annotations while keeping core logic in Rust.

What is the best way to expose Rust functions to a Node.js application with type safety?

The best way to expose Rust functions to Node.js with type safety is by using NAPI-RS to build the FFI bridge, generating TypeScript SDK packages with type-idiomatic APIs and detailed JSDoc documentation.

How does NAPI-RS handle FFI bridge development between Rust and TypeScript?

NAPI-RS handles FFI bridge development by allowing developers to implement the foreign function interface, creating seamless Rust-TypeScript integration while ensuring core logic remains in Rust and TypeScript provides the SDK.

Do I need to keep core logic in Rust when building a TypeScript SDK package?

Yes, you need to keep core logic in Rust when building a TypeScript SDK package. The Skill manages development by focusing the FFI bridge on exposing high-performance Rust functions callable from TypeScript with type safety.

How to compile TypeScript bindings for a Node.js module using pnpm?

To compile TypeScript bindings for a Node.js module, execute the pnpm build command, which compiles the NAPI-RS FFI bridge and TypeScript SDK packages for the Rust core library.

Why should I add JSDoc annotations to TypeScript bindings for Rust?

You should add JSDoc annotations to TypeScript bindings to ensure exports are well-documented with parameter, return, and example annotations, creating a type-idiomatic API for Node.js applications consuming the Rust core.