Skip to content

Only allow AliasNode as a structural reference #1026

Closed

Description

@ssalbdivad

Currently, the rules about where aliases (for cyclic types) can occur are not strict enough, leading to confusing structures where you don't know when you're going to get an alias or a resolved node.

Now that the ID is calculated before the node itself is created, this could be used to ensure we can resolve to that reference ahead of time and only in structural positions, i.e. on a Sequence/Required/Optional/Index node.

Other changes I'd like to make alongside this one:

  • A layer above type/schema called node that would not accept parsed definitions but only what is now Inner and reduce it to a node.

  • This would be not be top-level callable, therefore we could construct nodes and stitch them together by referring cycles back to an object that is currently being constructed

  • Would be scopeless, simplifying caching

  • Would be wrapped by type/schema with scopes, which would make boundaries for .finalize explicit

UPDATE: I'm mitigating the mentioned related issues by simply not discriminating discriminated types for now. Part of this change should to re-introduce discrimination for cyclic types.

Related issues: #1237, #1209, #1188

Activity

  1. moved this from To do to Backlog in arktypeioon Jun 24, 2024
  2. ssalbdivad commented on Nov 18, 2026

    @ssalbdivad
    MemberAuthor

    Fixed in 3.0.0-beta.0 (#1728). Try it with npm i arktype@next.

  3. moved this from Backlog to Done (merged or closed) in arktypeioon Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Done (merged or closed)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions