Skip to content

Optional object index signatures do not work.Β #1580

@Bas950

Description

@Bas950

Report a bug

πŸ”Ž Search Terms

🧩 Context

  • ArkType version:
  • TypeScript version (5.1+):
  • Other context you think may be relevant (JS flavor, OS, etc.):

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

Playground Link: https://arktype.io/playground?code=import%2520%257B%2520scope%2520%257D%2520from%2520%2522arktype%2522%250A%250Aconst%2520Thing%2520%253D%2520scope%28%257B%250A%2509Locales%253A%2520%27%2522en%2522%2520%257C%2520%2522nl%2522%2520%257C%2520%2522de%2522%27%252C%250A%2509Option%253A%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%27%255BLocales%255D%253F%27%253A%2520%27string%27%252C%250A%2520%2520%2520%2520%257D%252C%250A%257D%29.export%28%29%250A%250Aconst%2520out%2520%253D%2520Thing.Option%28%257B%250A%2520%2520%2520%2520en%253A%2520%2522test%2522%250A%257D%29%250A

import { scope } from "arktype"

const Thing = scope({
	Locales: '"en" | "nl" | "de"',
	Option: {
        '[Locales]?': 'string',
    },
}).export()

const out = Thing.Option({
    en: "test"
})

Out currently resolves to:

const out: ArkErrors | {
    '[Locales]'?: string;
}

Instead of:

const out: ArkErrors | {
    en?: string;
    nl?: string;
    de?: string;
}

Also I noticed that if you have a pipe in the index signature it also breaks (playground link)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

To do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions