AUR0107
Error Message
AUR0107: Ast eval error: expression is not a function.
Description
This error occurs during the evaluation of a binding expression when an attempt is made to invoke an expression using call syntax (()), but the expression itself evaluates to a value that is not a function type (e.g., it evaluates to a string, number, object, null, or undefined).
This is similar to AUR0111 (ast_name_is_not_a_function), but typically occurs when the part being called is itself a computed expression rather than a direct variable or property name.
Cause
The fundamental cause is trying to execute something that isn't executable. This often happens when:
Incorrect Return Type: An inner expression (e.g., a function call, a property access) returns a non-function value, which is then immediately invoked. Example:
getHandler()()wheregetHandler()returns a string instead of a function.Array/Object Access: Attempting to call an element retrieved from an array or object that isn't a function. Example:
actions[type]()whereactions[type]resolves tonullor a non-function value.Typo/Logic Error: A simple mistake in the expression logic leads to a non-function value being in the position where a function is expected for invocation.
Solution
Verify Expression Result: Ensure that the expression preceding the
()evaluates to a function at runtime. Useconsole.logor debugging tools to inspect the value and its type just before the call attempt.Check Function Returns: If the expression involves a function call (like
getHandler()()), verify that the inner function (getHandler) correctly returns another function under all conditions.Check Array/Object Contents: If accessing an array element or object property before calling (like
actions[type]()), ensure the value stored at that index/key is indeed a function. Provide defaults or add checks if necessary.Correct Logic: Review the binding expression for any logical errors or typos.
Example
Debugging Tips
Isolate the complex expression being called in the template.
Use
console.logor breakpoints in the view model to evaluate the parts of the expression and determine what the non-function value is and why it's occurring.Refactor complex call logic into view model methods for better clarity and easier debugging, performing necessary type checks within the method before invocation.
Last updated
Was this helpful?