# AUR9991

## Error Message

`AUR9991: Invalid @children usage. @children decorator can only be used on a field`

## Description

This error occurs when the `@children` decorator, used for querying child elements within a component's view, is applied incorrectly. The decorator is designed *only* to be used on class properties (fields).

## Cause

The direct cause is applying the `@children` decorator to something that is not a class property. Examples include:

1. **Decorating a Method:** Applying `@children` to a method definition.
2. **Decorating a Class:** Applying `@children` directly to the class declaration.
3. **Decorating a Getter/Setter:** Applying `@children` to an accessor property.

## Solution

Ensure that the `@children` decorator is only applied directly to a class property declaration.

## Example

```typescript
import { customElement, children } from 'aurelia';

@customElement({
  name: 'my-component',
  template: `<slot></slot>`
})
export class MyComponent {

  // Correct: @children applied to a class property
  @children('div.item')
  items: HTMLDivElement[];

  // Incorrect: @children applied to a method
  // @children('div.item')
  // getItems() { /* ... */ }

  // Incorrect: @children applied to a getter
  // @children('div.item')
  // get itemElements() { /* ... */ }
}

// Incorrect: Applying @children to the class itself
// @children('div.item')
// @customElement({ /* ... */ })
// export class InvalidComponent { /* ... */ }
```

## Debugging Tips

* Review the code where the `@children` decorator is used.
* Verify that the decorator is placed directly above a property declaration (e.g., `items: HTMLElement[];`).
* Ensure the decorator is not applied to methods, getters, setters, or the class itself.

```
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aurelia.io/developer-guides/error-messages/runtime-html/aur9991.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
