{"id":25053,"library":"capnpc-ts","title":"capnpc-ts","description":"Cap'n Proto schema compiler for TypeScript, version 0.7.0. Generates TypeScript type definitions and serialization code from .capnp schema files. Requires the capnp command-line tool (C++ reference implementation). Updated irregularly; key differentiator: enables type-safe Cap'n Proto usage in TypeScript without external RPC dependencies.","status":"active","version":"0.7.0","language":"javascript","source_language":"en","source_url":"https://github.com/jdiaz5513/capnp-ts","tags":["javascript","capnp","rpc","typescript"],"install":[{"cmd":"npm install capnpc-ts","lang":"bash","label":"npm"},{"cmd":"yarn add capnpc-ts","lang":"bash","label":"yarn"},{"cmd":"pnpm add capnpc-ts","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to compile .capnp schemas; capnpc-ts is a plugin for the capnp tool","package":"capnp","optional":false}],"imports":[{"note":"Package is typically installed globally to use as a CLI tool; dev dependency usage is possible but not common.","wrong":"npm install capnpc-ts --save-dev","symbol":"capnpc-ts","correct":"npm install -g capnpc-ts"},{"note":"The -o option expects the plugin name without 'capnpc-' prefix; use 'ts' not the full package name.","wrong":"capnpc -o capnpc-ts schema.capnp","symbol":"capnpc-ts as a plugin","correct":"capnpc -o ts path/to/schema.capnp"},{"note":"The generated file exports types as named exports; default import will fail unless explicitly set.","wrong":"import MyStruct from './schema.capnp.ts'","symbol":"Generated TS code","correct":"import { MyStruct } from './schema.capnp.ts'"}],"quickstart":{"code":"// Install the compiler globally\nnpm install -g capnpc-ts\n\n// Create a sample schema file: example.capnp\n// @0xbf5147cbbecf40c1;\n// struct Person {\n//   name @0 :Text;\n//   age  @1 :UInt32;\n// }\n\n// Compile the schema\nconst { execSync } = require('child_process');\nexecSync('capnpc -o ts example.capnp', { stdio: 'inherit' });\n\n// Use the generated code\nconst { Person } = require('./example.capnp.ts');\nconst msg = new capnp.Message();\nconst person = msg.initRoot(Person);\nperson.setName('Alice');\nperson.setAge(30);\nconsole.log(person.getName()); // 'Alice'","lang":"javascript","description":"Install capnpc-ts globally, compile a sample .capnp schema to TypeScript, and use the generated code."},"warnings":[{"fix":"Install capnp from https://capnproto.org/install.html or via package manager (e.g., brew install capnp on macOS).","message":"Must have capnp tool installed separately; capnpc-ts does not bundle the Cap'n Proto compiler.","severity":"gotcha","affected_versions":"all"},{"fix":"Be aware that the output path includes the .capnp extension; adjust tsconfig.json if needed to include .ts files.","message":"Generated output file has a .ts extension appended to the original schema file, e.g., myschema.capnp.ts.","severity":"gotcha","affected_versions":"all"},{"fix":"Use -o ts instead of -o capnpc-ts.","message":"Plugin name is 'ts', not 'capnpc-ts'. Using capnpc -o capnpc-ts fails.","severity":"gotcha","affected_versions":"all"},{"fix":"Install @capnp-ts/core as a runtime dependency: npm install @capnp-ts/core.","message":"Generated TypeScript code depends on @capnp-ts/core library for runtime support, but this may not be documented clearly.","severity":"breaking","affected_versions":">=0.6.0"}],"env_vars":null,"search_vec":"'0.7.0':12 'c':31 'cap':4,42 'capnp':21,26,53 'capnpc':2 'capnpc-t':1 'code':19 'command':28 'command-lin':27 'compil':8 'definit':16 'depend':51 'differenti':37 'enabl':38 'extern':49 'file':23 'generat':13 'implement':33 'irregular':35 'javascript':52 'key':36 'line':29 'n':5,43 'proto':6,44 'refer':32 'requir':24 'rpc':50,54 'safe':41 'schema':7,22 'serial':18 'tool':30 'ts':3 'type':15,40 'type-saf':39 'typescript':10,14,47,55 'updat':34 'usag':45 'version':11 'without':48","created_at":"2026-05-01T13:42:45.960468+00:00","updated_at":"2026-05-01T13:42:45.960468+00:00","problems":[{"fix":"Ensure capnpc-ts is installed globally: npm install -g capnpc-ts. Verify plugin is accessible.","cause":"capnpc-ts not installed or not on PATH; capnp cannot find the plugin.","error":"capnpc: Invalid option 'ts'"},{"fix":"Use named import: import { MyStruct } from './my.capnp.ts';","cause":"Using default import when generated code uses named exports.","error":"module '...' has no exported member 'MyStruct'"},{"fix":"Install runtime dependency: npm install @capnp-ts/core (or capnp-ts for older versions).","cause":"Missing runtime dependency @capnp-ts/core (or older capnp-ts package).","error":"Cannot find module 'capnp-ts'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/jdiaz5513/capnp-ts","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/capnpc-ts","openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","type-stubs"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-01","next_check":"2026-07-30","install_tag":null}}