Skip to content

Deeply nested scopes breaks type inference of generics mixed with private aliasΒ #1437

Closed

Description

@paulzhng

Report a bug

πŸ”Ž Search Terms

  • private
  • private alias
  • nested scopes

🧩 Context

ArkType version: 2.1-20
TypeScript version (5.1+): 5.7.3

πŸ§‘β€πŸ’» Repro

Playground Link: https://arktype.io/playground?code=import%2520%257Bgeneric%252C%2520scope%257D%2520from%2520%2522arktype%2522%253B%250A%250Aconst%2520%2524scope1%2520%253D%2520scope%28%257B%250A%2520%2520%2522%2523private%2522%253A%2520%2522string%2522%252C%2520%252F%252F%2520If%2520not%2520private%252C%2520it%2520works%250A%2520%2520%2522generic%253Ct%253E%2522%253A%2520%2522private%2522%252C%250A%257D%29%253B%250A%250Aconst%2520%2524scope2%2520%253D%2520scope%28%257B%250A%2520%2520...%2524scope1.export%28%29%252C%250A%257D%29%253B%250A%250Aconst%2520%2524scope3%2520%253D%2520scope%28%257B%250A%2520%2520...%2524scope2.export%28%29%252C%250A%257D%29%253B%250A%250Aconst%2520Thing1%2520%253D%2520%2524scope1.type%28%2522generic%253Cstring%253E%2522%29%253B%250Aconst%2520Thing2%2520%253D%2520%2524scope2.type%28%2522generic%253Cstring%253E%2522%29%253B%250A%250Aconst%2520Thing%2520%253D%2520%2524scope3.type%28%2522generic%253Cstring%253E%2522%29%253B%250Aconst%2520out%2520%253D%2520Thing%28%2522hello%2522%29%253B

import {generic, scope} from "arktype";

const $scope1 = scope({
  "#private": "string", // If not private, it works
  "generic<t>": "private",
});

const $scope2 = scope({
  ...$scope1.export(),
});

const $scope3 = scope({
  ...$scope2.export(),
});

const Thing1 = $scope1.type("generic<string>");
const Thing2 = $scope2.type("generic<string>");
const Thing3 = $scope3.type("generic<string>");

// string
type T1 = typeof Thing1.inferIn;

// string
type T2 = typeof Thing2.inferIn;

// never
type T3 = typeof Thing3.inferIn;

Activity

  1. added
    bug
    on Apr 24, 2025
  2. moved this from To do to Backlog in arktypeioon Apr 29, 2025
  3. ssalbdivad commented on Nov 18, 2026

    @ssalbdivad
    Member

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

  4. 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

Labels

bug

Type

No type

Projects

  • Status
    Done (merged or closed)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions