valibot: using `union` as key of `record` adds `undefined` to the value type
import * as v from 'valibot';
const record = v.record(v.union([v.string()]), v.string());
const t: v.Output<typeof record> = { a: undefined }
// ^ { [x: string]: string | undefined; }
// ^ should not be here
const result = v.safeParse(record, t);
console.log(result); // errors correctly
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (12 by maintainers)
Commits related to this issue
- Add support for numbers and symbols to entriesFromList #492 — committed to fabian-hiller/valibot by fabian-hiller 2 years ago
The next version of Valibot will allow you to write the following code to solve your problem. Feel free to give me feedback on this in the long run.
Thank you very much for your promptness. Now this also works with numbers and symbols. I’ll try to study the issue. If I have a proposal, I will publish it.
Thank you, I’ll do that 😃