Registry / serialization / babel-identifiers

babel-identifiers

JSON →
library2.0.1jsnpmunverified

Classifies Babel AST Identifier nodes into types (binding, reference, static) and grammars (javascript, jsx, flow, typescript). Stable v2.0.1 release with ESM/CJS support. Differentiates from general Babel utilities by focusing exclusively on identifier classification, enabling more precise lint rules and transformation logic. Lightweight with no runtime dependencies.

npm install babel-identifiers
INSTALL
IMPORT
SIG · BABEL-IDENTIFIERS
B
babel-identifiers
serializationjavascriptv2.0.1
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.

isIdentifierLike
import { isIdentifierLike } from 'babel-identifiers'
const { isIdentifierLike } = require('babel-identifiers')
Package uses named exports only; default import will not work. For CJS, use require('babel-identifiers').isIdentifierLike.
getIdentifierKind
import { getIdentifierKind } from 'babel-identifiers'
Returns 'binding', 'reference', or 'static'. Works with any Babel NodePath to an Identifier.
getIdentifierGrammar
import { getIdentifierGrammar } from 'babel-identifiers'
Returns 'javascript', 'jsx', 'flow', or 'typescript'. Determines grammar from ancestor nodes.

Demonstrates classifying identifiers by type and grammar using Babel parser and traverse.

import { isIdentifierLike, getIdentifierKind, getIdentifierGrammar } from 'babel-identifiers'; import { parse } from '@babel/parser'; import traverse from '@babel/traverse'; const code = `let x = 1; x; <jsx/>; ({y}: number);`; const ast = parse(code, { sourceType: 'module', plugins: ['jsx', 'typescript', 'flow'] }); traverse(ast, { Identifier(path) { if (isIdentifierLike(path)) { const kind = getIdentifierKind(path); const grammar = getIdentifierGrammar(path); console.log(path.node.name, kind, grammar); } } });
Debug
Known issues
gotchagetIdentifierGrammar may return 'javascript' for identifiers inside JSX if plugin is not enabled.
fix
Ensure Babel parser is configured with required plugins (jsx, typescript, flow) matching your code.
affects: >=0.0.0
gotchaWorks only with Babel AST NodePath, not raw AST nodes.
fix
Always pass a NodePath object, not a plain node.
affects: >=0.0.0
gotchaMissing type definitions: package does not ship TypeScript declarations.
fix
Create custom .d.ts file or use @types/babel__traverse for type compatibility.
affects: >=2.0.0
Errors
Common errors & fixes
Cannot find module 'babel-identifiers'
Package not installed or missing from dependencies.
fix
Run: npm install babel-identifiers
TypeError: getIdentifierKind is not a function
Importing incorrectly (e.g., default import instead of named).
fix
Use named import: import { getIdentifierKind } from 'babel-identifiers'
Argument passed to getIdentifierKind is not a NodePath
Passing a raw AST node instead of a Babel NodePath.
fix
Ensure you're inside a visitor callback with 'path' argument, or wrap node with NodePath.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
16
Amazon
1
OpenAI (training)
1
Resources
babel-identifiers — npm install babel-identifiers · libregistry