Install the package
Install decoders using your preferred package manager:Requirements
TypeScript version
Decoders requires TypeScript 4.5 or higher for proper type inference.Strict mode
Set"strict": true in your TypeScript configuration:
tsconfig.json
Platform support
Decoders works in all modern JavaScript environments:Node.js
Node.js 20+ (earlier versions likely work but are not tested)
Browsers
All modern browsers with ES2020 support
Bun
Full support for Bun runtime
Deno
Import from npm:
npm:decodersCloudflare Workers
Fully compatible with Workers runtime
Edge runtimes
Vercel Edge, Netlify Edge, and other edge runtimes
Import styles
Decoders supports both ESM and CommonJS imports.ES Modules (recommended)
CommonJS
Deno
Bundle size
Decoders has zero dependencies and is optimized for tree-shaking:- Minified: ~4KB
- Gzipped: ~1.5KB
- Tree-shakeable: Only import what you use
TypeScript configuration
For the best experience with decoders, we recommend these TypeScript settings:tsconfig.json
Why strict mode is required
Strict mode enables several TypeScript checks that are essential for proper type inference:strictNullChecks- Required for optional/nullable type inferencestrictFunctionTypes- Ensures decoder composition is type-safenoImplicitAny- Prevents accidentally losing type information
Verify installation
Create a test file to verify decoders is working correctly:test.ts
✓ Decoders is working!
IDE support
Decoders provides excellent IDE support through TypeScript:- Type inference - Hover over variables to see inferred types
- Auto-completion - Get suggestions for decoder methods
- Type errors - See errors inline as you type
- Go to definition - Jump to decoder source code
VS Code
For the best experience in VS Code:- Install the TypeScript extension (included by default)
- Enable “TypeScript: Enable Prompt Use Workspace” in settings
- Use the workspace TypeScript version
Other editors
Decoders works with any editor that supports TypeScript language server:- WebStorm / IntelliJ IDEA
- Vim / Neovim with CoC or LSP
- Emacs with Tide or LSP
- Sublime Text with LSP-typescript
Troubleshooting
Types are not inferred correctly
Make sure"strict": true is enabled in your tsconfig.json. Without strict mode, TypeScript cannot properly infer types from decoders.
Module not found error
If you seeCannot find module 'decoders':
- Make sure you installed the package:
npm install decoders - Check that
node_modulesexists in your project - Restart your TypeScript server (VS Code: Cmd/Ctrl + Shift + P → “TypeScript: Restart TS Server”)
Import errors in Deno
Use the npm specifier:Next steps
Quickstart
Build your first decoder in 5 minutes
Basic decoders
Learn about all the built-in decoders
