# AUR0151

## Error Message

`AUR0151: No binding behavior definition found for type <TypeName>`

Where `<TypeName>` is the name of the class associated with the binding behavior.

## Description

This error occurs when Aurelia attempts to resolve a binding behavior resource (e.g., used in a binding expression like `myProp & myBehavior`) but cannot find the associated definition metadata for the specified type (class). Binding behavior definitions are typically created using the `@bindingBehavior` decorator or by following naming conventions recognized by Aurelia.

## Cause

Common causes for this error include:

1. **Missing Decorator or Convention:** The class intended to be a binding behavior is missing the `@bindingBehavior('behavior-name')` decorator, and it doesn't follow a recognized naming convention (like `MyBehaviorBindingBehavior`).
2. **Incorrect Registration:** The binding behavior class was defined but not correctly registered with the Aurelia container, either globally (`Aurelia.register(...)`) or locally within a component's `dependencies` array.
3. **Build/Packaging Issues:** The build process might not be correctly including or processing the binding behavior file, or there might be issues with module resolution.
4. **Typo in Class Name:** The class name provided during registration or inferred by convention might have a typo.

## Solution

1. **Add Decorator/Follow Convention:** Ensure your binding behavior class has the `@bindingBehavior('behavior-name')` decorator applied, or that it follows the `*BindingBehavior` naming convention.
2. **Register the Behavior:** Verify that the binding behavior is registered correctly.
   * **Global Registration:** Use `Aurelia.register(MyBindingBehavior)` in your main application setup (`main.ts` or similar).
   * **Local Registration:** Add the binding behavior class to the `dependencies` array of the component's `dependencies` array.
3. **Check Build Configuration:** Ensure your build setup (e.g., Webpack, Vite) is configured to correctly process and bundle Aurelia resources, including decorators and conventions. Verify module imports and exports.
4. **Verify Class Name:** Double-check the spelling of the binding behavior class name in its definition and registration.

## Example

```typescript
// my-behavior.ts
import { bindingBehavior } from 'aurelia';

// Correct: Using the decorator
@bindingBehavior('myBehavior')
export class MyBehavior {
  // Behavior logic...
}

// Incorrect: Missing decorator and doesn't follow convention
// export class MyBehavior { /* ... */ } // This would likely cause AUR0151 if used

// --- main.ts or component definition ---
import { Aurelia } from 'aurelia';
import { MyBehavior } from './my-behavior';
// import { MyComponent } from './my-component'; // If registering locally

// Global Registration:
// Aurelia.register(MyBehavior) /* ... */;

// Local Registration (in my-component.ts):
// @customElement({
//   name: 'my-component',
//   template: `<input value.bind="message & myBehavior">`,
//   dependencies: [MyBehavior] // Register locally
// })
// export class MyComponent { message = 'Hello'; }
```

## Debugging Tips

* Verify the exact name (`<TypeName>`) mentioned in the error message matches the intended class name.
* Search your codebase for the binding behavior's class name and decorator (`@bindingBehavior`) to ensure it's defined correctly.
* Check your `main.ts` (or equivalent startup file) for global registrations.
* Check the `dependencies` array of the component(s) where the binding behavior is used.
* Inspect the build output or use browser developer tools to see if the binding behavior module is loaded correctly.

\</rewritten\_file>
