# `layout.promotion_required`

Declaration is used beyond the file that holds it.

Area 1, [Project layout and modules](../topics/project-layout-and-modules.md); not declinable; the next step is usually the agent's.

```jadpo
use planning/actions { SnoozeDays }

action postpone_all(days: SnoozeDays) -> Unit {}
```

```jadpo
type SnoozeDays = Int {
    min: 1
    max: 30
}

action snooze_todo(days: SnoozeDays) -> Unit {}
```

```text
error: `SnoozeDays` is used beyond this file
 --> domains/planning/actions/snooze_todo.jadpo:1:6
  |
1 | type SnoozeDays = Int {
  |      ^^^^^^^^^^ used by another file
  reason: A type used by one file lives in it; once another file uses it, it moves to a file of its own in `domains/planning/types/`. `domains/planning/actions/postpone_all.jadpo` uses it too.
  next: Move `SnoozeDays` to `domains/planning/types/snooze_days.jadpo`, or run `jadpo fmt --layout`, which moves it and updates the imports (agent)
  rule: layout.promotion_required
  help: https://jadpo.dev/docs/errors/layout.promotion_required

check failed: 1 error, 3 files
```

Moving to the right folder is not enough: a second declaration in a file
moves to a file of its own once another file uses it, so every name a `use`
line brings in is `<folder>/<name>.jadpo`. The edit makes the move, and
`jadpo fmt --layout` makes it and updates the imports:


```jadpo
type DiscountCode = Text {
    max_length: 12
}

type Basket = Object {
    code: DiscountCode
}
```

```text
error: `DiscountCode` is used beyond this file
 --> domains/sales/types/basket.jadpo:1:6
  |
1 | type DiscountCode = Text {
  |      ^^^^^^^^^^^^ used by another file
  reason: A declaration another file uses has a file of its own named after it, so its `use` line says where it is; `DiscountCode` is in `basket.jadpo`, named after another declaration, and moves to `domains/sales/types/`. `domains/sales/actions/apply_code.jadpo` uses it too.
  next: Move `DiscountCode` to `domains/sales/types/discount_code.jadpo`, or run `jadpo fmt --layout`, which moves it and updates the imports (agent)
  rule: layout.promotion_required
  help: https://jadpo.dev/docs/errors/layout.promotion_required

check failed: 1 error, 3 files
```

```jadpo
use sales/types { Basket, DiscountCode }

action apply_code(basket: Basket, code: DiscountCode) -> Unit {}
```
