Registry / storage / tsbuffer-schema

tsbuffer-schema

JSON →
library2.2.0jsnpmunverified

TSBuffer Schema provides TypeScript type definitions and schema declarations for TSBuffer, a TypeScript runtime type checking and binary serialization library (v2.2.0, stable, monthly releases). It includes schema types like TSBufferSchema and TSBufferProto for defining binary-encoded message structures, plus number type aliases (int, uint) for optimized encoding. Differentiates from protobuf by tight TypeScript integration, runtime type validation, and no code generation step — schemas are written as TypeScript types.

npm install tsbuffer-schema
INSTALL
IMPORT
SIG · TSBUFFER-SCHEMA
T
tsbuffer-schema
storagejavascriptv2.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TSBufferSchema
import { TSBufferSchema } from 'tsbuffer-schema'
import TSBufferSchema from 'tsbuffer-schema'
Named export only; default import will fail.
TSBufferProto
import { TSBufferProto } from 'tsbuffer-schema'
import { TSBufferProto } from 'tsbuffer-schema/dist/index'
Correct path is the package root; no subpath import needed.
Overwrite
import { Overwrite } from 'tsbuffer-schema'
import { Overwrite } from 'tsbuffer'
Overwrite is a utility type exported from tsbuffer-schema, not from tsbuffer.

Shows importing schema types, defining a schema, using Overwrite override type, and creating a TSBufferProto object in TypeScript.

import { TSBufferSchema, TSBufferProto, Overwrite } from 'tsbuffer-schema'; // Define a schema for a user object type UserSchema = { id: TSBufferSchema<number>; name: TSBufferSchema<string>; email?: TSBufferSchema<string>; }; // Use Overwrite to override a type interface BaseUser { id: number; name: string; } type AdminUser = Overwrite<BaseUser, { role: 'admin' | 'user' }>; // Create a proto (collection of schemas) const proto: TSBufferProto = { User: { fields: [ { id: 0, type: 'int32' }, { id: 1, type: 'string' }, { id: 2, type: 'string', optional: true } ] } }; console.log('TSBuffer schema example');
Debug
Known issues
gotchaTSBufferProto expects numeric field IDs starting from 0; no gaps allowed unless explicitly configured.
fix
Ensure field IDs are sequential integers starting from 0 for each object type in the proto.
affects: >=1.0.0
gotchaNumber type aliases like 'int', 'uint' are not standard TypeScript types; they are custom string literals used by TSBuffer runtime.
fix
Only use these aliases within TSBufferSchema definitions; they have no meaning in plain TypeScript type system.
affects: >=1.0.0
deprecatedThe Overwrite utility type might be removed in future major versions in favor of TypeScript's built-in Omit or utility types.
fix
Consider using TypeScript's `Omit` and intersection types: `type AdminUser = Omit<BaseUser, 'role'> & { role: 'admin' | 'user' }`.
affects: >=2.0.0
Errors
Common errors & fixes
Type 'typeof import("tsbuffer-schema")' has no property 'TSBufferSchema'.
Using a default import instead of named import.
fix
Change to `import { TSBufferSchema } from 'tsbuffer-schema'`.
Cannot find module 'tsbuffer-schema' or its corresponding type declarations.
Package not installed or TypeScript resolution fails.
fix
Run `npm install tsbuffer-schema` and ensure tsconfig.json includes node module resolution.
Argument of type '{ fields: { id: number; type: string; }[] }' is not assignable to parameter of type 'TSBufferSchema<…>'.
Directly using a plain object where a TSBufferSchema generic is expected.
fix
Define a type alias using TSBufferSchema<YourInterface> and use that type for type-checking, not the raw object literal.
Upgrade
Version history
2.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
22
OpenAI (training)
1
Resources
tsbuffer-schema — npm install tsbuffer-schema · libregistry