## Documentation index

This index lists every available documentation page and its Markdown source.

- [About VDL](https://vdl.varavel.com/docs/about/index.md)
- [Guides](https://vdl.varavel.com/docs/guides/index.md)
  - [Installation](https://vdl.varavel.com/docs/guides/installation/index.md)
  - [CLI Commands](https://vdl.varavel.com/docs/guides/cli/index.md)
  - [Editor Integration](https://vdl.varavel.com/docs/guides/editors/index.md)
  - [Project Configuration](https://vdl.varavel.com/docs/guides/configuration/index.md)
  - [Creating Plugins](https://vdl.varavel.com/docs/guides/creating-plugins/index.md)
- [Language](https://vdl.varavel.com/docs/language/index.md)
  - [Start Here](https://vdl.varavel.com/docs/language/start-here/index.md)
  - [Files and Comments](https://vdl.varavel.com/docs/language/files/index.md)
  - [Includes](https://vdl.varavel.com/docs/language/includes/index.md)
  - [Docstrings](https://vdl.varavel.com/docs/language/docstrings/index.md)
  - [Types](https://vdl.varavel.com/docs/language/types/index.md)
  - [Field Types](https://vdl.varavel.com/docs/language/field-types/index.md)
  - [Enums](https://vdl.varavel.com/docs/language/enums/index.md)
  - [Constants and Literals](https://vdl.varavel.com/docs/language/constants/index.md)
  - [Annotations](https://vdl.varavel.com/docs/language/annotations/index.md)
  - [Spreads and References](https://vdl.varavel.com/docs/language/spreads-references/index.md)
  - [Naming and Validation](https://vdl.varavel.com/docs/language/naming-validation/index.md)
- [VDL Plugin Protocols](https://vdl.varavel.com/docs/protocols/index.md)
  - [Introduction](https://vdl.varavel.com/docs/protocols/introduction/index.md)
  - [VPP-0: Core](https://vdl.varavel.com/docs/protocols/core/index.md)
  - [VPP-1: Deprecations](https://vdl.varavel.com/docs/protocols/deprecations/index.md)
  - [VPP-2: HTTP-RPC](https://vdl.varavel.com/docs/protocols/http-rpc/index.md)
  - [VPP-3: Policy](https://vdl.varavel.com/docs/protocols/policy/index.md)
  - [VPP-4: Events](https://vdl.varavel.com/docs/protocols/events/index.md)
- [Reference](https://vdl.varavel.com/docs/reference/index.md)
  - [Language Specification](https://vdl.varavel.com/docs/reference/spec/index.md)
  - [Formatting Guide](https://vdl.varavel.com/docs/reference/formatting-guide/index.md)


## Documentation content

The documentation for the current page follows, reproduced verbatim.


## References

A reference points to a named VDL symbol.

References appear in several places:

- field types
- spreads
- constant values
- annotation arguments

## Type References

Fields can reference declared types.

```vdl
type UserId string

type User {
  id UserId
}
```

Fields can also reference enums.

```vdl
enum Status {
  Active
  Disabled
}

type User {
  status Status
}
```

## Constant References

Constants can reference other constants by name.

```vdl
const defaultLimit = 100
const pageSize = defaultLimit
```

## Enum Member References

Use `EnumName.MemberName` to reference an enum member in literal values.

```vdl
enum Status {
  Active = "active"
  Disabled = "disabled"
}

const defaultStatus = Status.Active
```

## Type Spreads

Type spreads copy fields from another object type.

```vdl
type AuditFields {
  createdAt datetime
  updatedAt datetime
}

type Article {
  ...AuditFields
  id string
  title string
}
```

After analysis, plugins see `Article` as if it had all fields directly.

Only object types can be spread into object types.

A type alias that resolves
to an object type can also be spread.

```vdl
type Address {
  city string
}

type PostalAddress Address

type User {
  ...PostalAddress
  name string
}
```

Invalid (aliases to non-object types cannot be spread):

```vdl
type UserId string

type User {
  ...UserId
  name string
}
```

## Inline Object Spreads

Inline objects can also spread object types.

```vdl
type Money {
  amount int
  currency string
}

type Order {
  id string
  payment {
    ...Money
    provider string
  }
}
```

## Field Conflicts

Spreads cannot introduce a field that already exists in the same object.

Invalid:

```vdl
type BaseUser {
  id string
}

type User {
  ...BaseUser
  id string
}
```

Rename one field or avoid the spread.

## Enum Spreads

Enum spreads copy members from another enum.

```vdl
enum StandardRole {
  Viewer = "viewer"
  Editor = "editor"
}

enum ProjectRole {
  ...StandardRole
  Owner = "owner"
}
```

Enum spreads must reference enums, not enum members.

Invalid:

```vdl
enum Role {
  Viewer = "viewer"
}

enum ProjectRole {
  ...Role.Viewer
  Owner = "owner"
}
```

## Object Literal Spreads

Object literals can spread constant objects.

```vdl
const baseConfig = {
  retries 3
  timeoutMs 5000
}

const productionConfig = {
  ...baseConfig
  timeoutMs 10000
}
```

Only object constants can be used this way.

## Spread Cycles

Spreads cannot form cycles.

Invalid:

```vdl
type A {
  ...B
  a string
}

type B {
  ...A
  b string
}
```

Keep spread hierarchies simple and acyclic.

## Name Forms

VDL supports two reference forms:

| Form          | Used for                                      |
| ------------- | --------------------------------------------- |
| `Name`        | Types, constants, spreads                     |
| `Name.Member` | Enum member references in literal expressions |

Spreads must use `Name`, not `Name.Member`.
