-
-
Notifications
You must be signed in to change notification settings - Fork 136
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Using type.declare<Expected>().type({...}) returns a validator that results in an incorrect type when used.
Let's say we defined these two identical validators.
type Expected = { a: number; b?: number }
const Type_with_declare = type.declare<Expected, { side: "out" }>().type({
a: "string.numeric.parse",
"b?": "number"
})
const Type_without_declare = type({
a: "string.numeric.parse",
"b?": "number"
});When used, they return different types. Despite the fact that their actual returned values being identical. Essentially, their runtime behavior is still as expected but it's returned Type does not correctly represent it.
// typed as '((In: {a: string; b?: number;}) => Expected) | ArkErrors'
const result_with_declare = Type_with_declare({
a: "3"
});
// typed as '{a: number; b?: number;} | ArkErrors'
const result_without_declare = Type_without_declare({
a: "3"
});In both cases, the actual result is { a: 3 } as expected.
π§© Context
- ArkType version: 2.1.29
- TypeScript version (5.1+): 5.9.3
π§βπ» Repro
Playground Link: Here
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
To do