Registry / serialization / babel-plugin-tcomb

babel-plugin-tcomb

JSON →
library0.4.0jsnpmunverified

Babel plugin that adds runtime type checking from Flow annotations using tcomb. Version 0.4.0, released 2020-09-05. This is the latest stable release; prior versions support Babel 6, latest supports Babel 7. Transforms Flow type annotations into runtime assertions via tcomb. Different from flow-remove-types or babel-plugin-transform-flow-strip-types because it keeps the type information for runtime validation. Works alongside Flow for hybrid static + dynamic checking. Supports refinement types, immutability enforcement, and IO boundary validation. Abandoned as of November 2021; no commits or releases since 0.4.0.

npm install babel-plugin-tcomb
INSTALL
IMPORT
SIG · BABEL-PLUGIN-TCOMB
B
babel-plugin-tcomb
serializationjavascriptv0.4.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default
// .babelrc { "plugins": ["tcomb"] }
The plugin is used as a Babel plugin, not imported directly in source code.
tcomb
import t from 'tcomb'
import { t } from 'tcomb'
tcomb is a CommonJS module with default export; ES6 default import works with Babel.
Flow type annotations
function add(a: number, b: number): number { return a + b; }
function add(a, b) { return a + b; }
Without annotations, no runtime checks are generated. Annotations must be Flow-standard.

Shows Babel setup and runtime type checking triggered by a Flow-annotated function call with a type mismatch.

// .babelrc { "plugins": [ "syntax-flow", "tcomb", "transform-flow-strip-types" ] } // src/index.js function sum(a: number, b: number): number { return a + b; } // This will throw at runtime: sum(1, 'x'); // Uncaught TypeError: [tcomb] Invalid value "x" supplied to b: Number
Debug
Known issues
breakingVersion 0.4.0 requires Babel 7; incompatible with Babel 6 projects.
fix
Upgrade to Babel 7 or pin to 0.3.27 for Babel 6.
affects: 0.4.0
deprecatedPackage is no longer maintained; last release 0.4.0 (2020). No bug fixes or updates for newer Babel versions.
fix
Consider alternatives like babel-plugin-runtime-typecheck or TypeScript with ttypescript.
affects: >=0.4.0
gotchatcomb must be requireable at runtime; if using ES modules, ensure transform-modules-commonjs or similar is applied before tcomb plugin.
fix
Add plugin order: transform-modules-commonjs before tcomb, or use Babel env with modules: 'commonjs'.
affects: >=0.3.0
gotchaPassing passPerPreset: true may be required when using multiple presets to avoid conflicts.
fix
Set passPerPreset: true in .babelrc.
affects: >=0.3.0
breakingRemoved support for Babel 6 in v0.4.0; no migration path for Babel 6 projects.
fix
Stick with v0.3.27 for Babel 6, or upgrade entire project to Babel 7.
affects: 0.4.0
Errors
Common errors & fixes
Error: Cannot find module 'tcomb'
tcomb is a peer dependency and not installed automatically.
fix
npm install --save-dev tcomb
TypeError: [tcomb] Invalid value "x" supplied to b: Number
Runtime type check failed – argument type mismatch.
fix
Correct the call to pass a number: sum(1, 2);
Error: Plugin 0 specified in "..." provided an invalid property of type "..."
Plugin order or misconfiguration in .babelrc.
fix
Ensure plugins array contains 'tcomb' after 'syntax-flow' and before 'transform-flow-strip-types'. Try passPerPreset: true.
ReferenceError: t is not defined
tcomb not imported or requireable in your source module.
fix
Add import t from 'tcomb' at the top of your file, or ensure CommonJS require('tcomb') works.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
babel-plugin-tcomb — npm install babel-plugin-tcomb · libregistry