refactor(domain): share AST property name reader

This commit is contained in:
morluto
2026-09-29 19:07:05 +08:00
parent dcb036292e
commit 4f4cc59873
3 changed files with 14 additions and 15 deletions
+9
View File
@@ -0,0 +1,9 @@
import * as t from "@babel/types";
/** Read an identifier or literal property name without evaluating syntax. */
export const propertyName = (node: t.Node): string => {
if (t.isIdentifier(node)) return node.name;
if (t.isStringLiteral(node) || t.isNumericLiteral(node))
return String(node.value);
return "";
};