faster-babel-types
raw JSON → 0.1.0 verified Sat Apr 25 auth: no javascript
faster-babel-types provides a drop-in replacement for @babel/types with optimized runtime performance and TypeScript support. Currently at version 0.1.0, this package is in early active development and is designed for projects that use @babel/types and want faster type checking or creation functions. It maintains the same API surface but aims to improve speed, especially in code paths that extensively use Babel AST types. The main differentiator is performance optimization for Babel plugin authors or tools that process large ASTs. However, it is experimental and not yet stable for production use.
Common errors
error Cannot find module 'faster-babel-types' ↓
cause Package not installed or not in node_modules.
fix
npm install faster-babel-types @babel/types
error TypeError: t.stringLiteral is not a function ↓
cause Used default import t but function is missing; named export casing may differ.
fix
Use named import: import { stringLiteral } from 'faster-babel-types'.
error Module not found: Error: Can't resolve 'faster-babel-types' ↓
cause Webpack or bundler may not resolve peer dependency correctly; missing @babel/types.
fix
Ensure @babel/types is installed as a direct dependency: npm install @babel/types
Warnings
breaking faster-babel-types is not API compatible with @babel/types for all functions; some optimizations may change behavior in edge cases. ↓
fix Test thoroughly with your Babel plugin or tooling; consider pinning version to avoid unexpected changes.
gotcha Never mix imports from @babel/types and faster-babel-types; use exclusively one to avoid type mismatches or performance regressions. ↓
fix Replace all imports of @babel/types with faster-babel-types.
gotcha TypeScript types bundled are preliminary and may diverge from @babel/types types; type errors can occur. ↓
fix Install @babel/types as a dev dependency and use its types if needed; report type issues upstream.
Install
npm install faster-babel-types yarn add faster-babel-types pnpm add faster-babel-types Imports
- t wrong
const t = require('faster-babel-types')correctimport t from 'faster-babel-types' - stringLiteral wrong
import { stringLiteral } from '@babel/types'correctimport { stringLiteral } from 'faster-babel-types' - isStringLiteral wrong
const { isStringLiteral } = require('faster-babel-types')correctimport { isStringLiteral } from 'faster-babel-types'
Quickstart
import t, { stringLiteral, isStringLiteral } from 'faster-babel-types';
const lit = stringLiteral('hello');
console.log(lit.type); // 'StringLiteral'
console.log(isStringLiteral(lit)); // true
console.log(t.isStringLiteral(lit)); // true