> For the complete documentation index, see [llms.txt](https://docs.aurelia.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aurelia.io/developer-guides/error-messages/runtime-html/aur9990.md).

# AUR9990

## Error Message

`AUR9990: Invalid @slotted usage. @slotted decorator can only be used on a field`

## Description

This error occurs when the `@slotted` decorator, used for accessing nodes projected into specific slots within a component's shadow DOM, is applied incorrectly. The decorator is designed *only* to be used on class properties (fields).

## Cause

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

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

The decorator's implementation checks the context where it's applied and throws this error if it's not a 'field'.

## Solution

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

## Example

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

@customElement({
  name: 'my-card',
  template: `<template shadowrootmode="open">
    <slot name="header"></slot>
    <slot></slot> <!-- Default slot -->
    <slot name="footer"></slot>
  </template>`
})
export class MyCard {

  // Correct: @slotted applied to class properties
  @slotted('header') // Matches <slot name="header">
  headerNodes: Node[];

  @slotted() // Matches the default slot <slot>
  contentNodes: Node[];

  // Incorrect: @slotted applied to a method
  // @slotted('footer')
  // getFooter() { /* ... */ }

  // Incorrect: @slotted applied to a getter
  // @slotted()
  // get defaultSlotNodes() { /* ... */ }
}

// Incorrect: Applying @slotted to the class itself
// @slotted()
// @customElement({ /* ... */ })
// export class InvalidCard { /* ... */ }

```

## Debugging Tips

* Review the code where the `@slotted` decorator is used.
* Verify that the decorator is placed directly above a property declaration (e.g., `headerNodes: Node[];`).
* Ensure the decorator is not applied to methods, getters, setters, or the class itself.
* Confirm that the component using `@slotted` has Shadow DOM enabled (`shadowrootmode="open"` or configured via `shadowOptions` in the definition), as `@slotted` relies on the Shadow DOM projection mechanism.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
