WebGL Mecanim State Behaviour: OnStateEnter() OnStateUpdate().. cannot take parameters error.

I have a simple class with Mecanim State Machine Behaviour which looks like this:

public class AnimationStateChanger : StateMachineBehaviour {

    public string stateName;

    public bool onStateEnter = false;
    public bool onStateExit = false;

    public int changeToState;


    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (onStateEnter)
        {    
            animator.SetInteger(stateName, changeToState);    
        }
    }

  
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (onStateExit)
            animator.SetInteger(stateName, changeToState);
    }
}

In the Unity Editor and Windows Build i don’t get any errors. However when i build it for WebGL i get:
Script Error: (AnimationStateChanger) OnStateEnter() can not take parameters.
Script Error: (AnimationStateChanger) OnStateExit() can not take parameters.
Script Error: (AnimationStateChanger) OnStateUpdate() can not take parameters.
and etc including all overridable methods. Any ideas?

So it seems to be an internal bug in Unity, because even with an empty state machine behaviour script the errors thrown are the same. It seems that Unity internally can’t recognize the overridable methods with parameters when building for Web GL. Reported it as a bug.