{"id":19002,"library":"babel-identifiers","title":"babel-identifiers","description":"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.","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/babel-utils/babel-identifiers","tags":["javascript"],"install":[{"cmd":"npm install babel-identifiers","lang":"bash","label":"npm"},{"cmd":"yarn add babel-identifiers","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-identifiers","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package uses named exports only; default import will not work. For CJS, use require('babel-identifiers').isIdentifierLike.","wrong":"const { isIdentifierLike } = require('babel-identifiers')","symbol":"isIdentifierLike","correct":"import { isIdentifierLike } from 'babel-identifiers'"},{"note":"Returns 'binding', 'reference', or 'static'. Works with any Babel NodePath to an Identifier.","wrong":"","symbol":"getIdentifierKind","correct":"import { getIdentifierKind } from 'babel-identifiers'"},{"note":"Returns 'javascript', 'jsx', 'flow', or 'typescript'. Determines grammar from ancestor nodes.","wrong":"","symbol":"getIdentifierGrammar","correct":"import { getIdentifierGrammar } from 'babel-identifiers'"}],"quickstart":{"code":"import { isIdentifierLike, getIdentifierKind, getIdentifierGrammar } from 'babel-identifiers';\nimport { parse } from '@babel/parser';\nimport traverse from '@babel/traverse';\n\nconst code = `let x = 1; x; <jsx/>; ({y}: number);`;\nconst ast = parse(code, { sourceType: 'module', plugins: ['jsx', 'typescript', 'flow'] });\ntraverse(ast, {\n  Identifier(path) {\n    if (isIdentifierLike(path)) {\n      const kind = getIdentifierKind(path);\n      const grammar = getIdentifierGrammar(path);\n      console.log(path.node.name, kind, grammar);\n    }\n  }\n});","lang":"typescript","description":"Demonstrates classifying identifiers by type and grammar using Babel parser and traverse."},"warnings":[{"fix":"Ensure Babel parser is configured with required plugins (jsx, typescript, flow) matching your code.","message":"getIdentifierGrammar may return 'javascript' for identifiers inside JSX if plugin is not enabled.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always pass a NodePath object, not a plain node.","message":"Works only with Babel AST NodePath, not raw AST nodes.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Create custom .d.ts file or use @types/babel__traverse for type compatibility.","message":"Missing type definitions: package does not ship TypeScript declarations.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run: npm install babel-identifiers","cause":"Package not installed or missing from dependencies.","error":"Cannot find module 'babel-identifiers'"},{"fix":"Use named import: import { getIdentifierKind } from 'babel-identifiers'","cause":"Importing incorrectly (e.g., default import instead of named).","error":"TypeError: getIdentifierKind is not a function"},{"fix":"Ensure you're inside a visitor callback with 'path' argument, or wrap node with NodePath.","cause":"Passing a raw AST node instead of a Babel NodePath.","error":"Argument passed to getIdentifierKind is not a NodePath"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}