Skip to content

Function name conflict, unexpected parameter mutation - effector/babel-plugin #603

@7iomka

Description

@7iomka

Somewhere inside your code (in my case, is a custom react hook, for example usePress from yandex )

const attach = (target: T, id: number) => {
      cache.currentPointerTarget = target;
      cache.currentPointerId = id;
      cache.isPressed = true;

      disableTextSelection();
      setPressed(true);
};
// ..
attach(event.currentTarget, event.pointerId);

What is the current behavior:
effector/babel-plugin mutate at least first parameter target when function with the same name as api method get called
So, target in this example instead of and DOM element is transformed into

{
  and: DOM ELEMENT HERE,
  or: {sid: xxx}
}

What is the expected behavior:
The source code of the corresponded file does not change if the function that is used

  • is defined in the same file
  • imported from anywhere exc. effector, even if the name of this function is the same as the name of one of the effector API methods.

Which versions of effector packages, and which browser and OS are affected by this issue? Did this work in previous versions of effector?:
Latest Effector version.

The only workaround for now is to manually rename all source files that contains the same function names as effector API (not sure if all, but at least attach)

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions