-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
I have a large map in my code that looks something like this:
export const MANAGE_ACTIONS = {
actionType: {
nameFunc: () => {},
iconFunc: () => {},
},
...
};
which I elsewhere use to fetch the relevant functions per actionType so I'm expecting the values to all be objects,
and now all of a sudden I'm getting:
MANAGE_ACTIONS.displayName === 'MANAGE_ACTIONS' // true
After a short debugging this seems to be the problem:
const parentAncestor = ancestors[ancestors.length - 2]
if (parentAncestor && ['ReturnStatement', 'ArrowFunctionExpression'].includes(parentAncestor.type)) {
// ArrowFunctionExpression is present when no Babel plugins are used when transforming JSX
const variableDeclaratorIdx = ancestors.findIndex(ancestor => ancestor.type === 'VariableDeclarator')
if (variableDeclaratorIdx != -1) {
const variableDeclarator = ancestors[variableDeclaratorIdx]
addDisplayName(parser, variableDeclarator)
}
}
the assumption here about arrow functions is a little too generic :)
Expected
if nameFunc returns JSX then MANAGE_ACTIONS.actionType.nameFunc.displayName === 'nameFunc'
Actual
MANAGE_ACTIONS.displayName === 'MANAGE_ACTIONS'
Metadata
Metadata
Assignees
Labels
No labels