refactor(domain): share AST property name reader
This commit is contained in:
@@ -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 "";
|
||||
};
|
||||
Reference in New Issue
Block a user