{"id":19174,"library":"babel-plugin-tcomb","title":"babel-plugin-tcomb","description":"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.","status":"abandoned","version":"0.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/gcanti/babel-plugin-tcomb","tags":["javascript","flow","babel","babel-plugin","tcomb","type-checking","types","runtime"],"install":[{"cmd":"npm install babel-plugin-tcomb","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-tcomb","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-tcomb","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The plugin is used as a Babel plugin, not imported directly in source code.","wrong":null,"symbol":"default","correct":"// .babelrc\n{\n  \"plugins\": [\"tcomb\"]\n}"},{"note":"tcomb is a CommonJS module with default export; ES6 default import works with Babel.","wrong":"import { t } from 'tcomb'","symbol":"tcomb","correct":"import t from 'tcomb'"},{"note":"Without annotations, no runtime checks are generated. Annotations must be Flow-standard.","wrong":"function add(a, b) { return a + b; }","symbol":"Flow type annotations","correct":"function add(a: number, b: number): number { return a + b; }"}],"quickstart":{"code":"// .babelrc\n{\n  \"plugins\": [\n    \"syntax-flow\",\n    \"tcomb\",\n    \"transform-flow-strip-types\"\n  ]\n}\n\n// src/index.js\nfunction sum(a: number, b: number): number {\n  return a + b;\n}\n\n// This will throw at runtime:\nsum(1, 'x'); // Uncaught TypeError: [tcomb] Invalid value \"x\" supplied to b: Number","lang":"javascript","description":"Shows Babel setup and runtime type checking triggered by a Flow-annotated function call with a type mismatch."},"warnings":[{"fix":"Upgrade to Babel 7 or pin to 0.3.27 for Babel 6.","message":"Version 0.4.0 requires Babel 7; incompatible with Babel 6 projects.","severity":"breaking","affected_versions":"0.4.0"},{"fix":"Consider alternatives like babel-plugin-runtime-typecheck or TypeScript with ttypescript.","message":"Package is no longer maintained; last release 0.4.0 (2020). No bug fixes or updates for newer Babel versions.","severity":"deprecated","affected_versions":">=0.4.0"},{"fix":"Add plugin order: transform-modules-commonjs before tcomb, or use Babel env with modules: 'commonjs'.","message":"tcomb must be requireable at runtime; if using ES modules, ensure transform-modules-commonjs or similar is applied before tcomb plugin.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"Set passPerPreset: true in .babelrc.","message":"Passing passPerPreset: true may be required when using multiple presets to avoid conflicts.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"Stick with v0.3.27 for Babel 6, or upgrade entire project to Babel 7.","message":"Removed support for Babel 6 in v0.4.0; no migration path for Babel 6 projects.","severity":"breaking","affected_versions":"0.4.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install --save-dev tcomb","cause":"tcomb is a peer dependency and not installed automatically.","error":"Error: Cannot find module 'tcomb'"},{"fix":"Correct the call to pass a number: sum(1, 2);","cause":"Runtime type check failed – argument type mismatch.","error":"TypeError: [tcomb] Invalid value \"x\" supplied to b: Number"},{"fix":"Ensure plugins array contains 'tcomb' after 'syntax-flow' and before 'transform-flow-strip-types'. Try passPerPreset: true.","cause":"Plugin order or misconfiguration in .babelrc.","error":"Error: Plugin 0 specified in \"...\" provided an invalid property of type \"...\""},{"fix":"Add import t from 'tcomb' at the top of your file, or ensure CommonJS require('tcomb') works.","cause":"tcomb not imported or requireable in your source module.","error":"ReferenceError: t is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}