Babel plugin (v2.1.11) that compiles spectypes validators at build time, producing fast, eval-free runtime validation for TypeScript/JavaScript. Current stable version is 2.1.11 with bi-monthly releases. Key differentiators: compiles validators into simple if/else statements (no eval or new Function), can outperform ajv in benchmarks, detailed error messages with failure paths, TypeScript type inference, and extensive property-based testing. Requires @babel/core as a peer dependency and spectypes runtime package.
npm install babel-plugin-spectypesVerified import paths — ran on the pinned version, not inferred.
Shows installation, Babel configuration, and basic usage with array, number, and struct validators compiled by the plugin.
Review the changelog and update your validator usage accordingly.
Ensure all validators are imported directly from 'spectypes' and that the Babel plugin is configured correctly.
Upgrade to the latest version and replace deprecated validators with their modern equivalents.
Ensure babel-plugin-spectypes runs after any import transformation plugins, or use 'plugin ordering' to control execution order.
Add '@babel/preset-typescript' to your Babel presets if you are using TypeScript.
Run 'npm install spectypes' to install the runtime package.
Ensure you are using a build step with Babel and Webpack/Rollup, or use CommonJS require correctly: const { array } = require('spectypes').Add 'import { array } from \"spectypes\"' at the top of your file.Run 'npm install --save-dev babel-plugin-spectypes' and ensure your .babelrc or babel.config.js includes '\"plugins\": [\"babel-plugin-spectypes\"]'.