Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: setLocale typescript support for added methods #2248

Open
vinsjo opened this issue Sep 30, 2024 · 0 comments
Open

types: setLocale typescript support for added methods #2248

vinsjo opened this issue Sep 30, 2024 · 0 comments

Comments

@vinsjo
Copy link

vinsjo commented Sep 30, 2024

Describe the bug
When adding custom method to schema using addMethod, it's possible to use module augmentation to extend the schema interface (See 'Extending built-in schema with new methods' example).

The same possibility to extend the built-in types referenced in LocaleObject isn't possible since they're not exported from index.ts, which causes typescript validation to fail when trying to pass default messages for added methods to setLocale.

To Reproduce

Example where I'm adding divisibleBy method to number schema:
https://codesandbox.io/p/sandbox/muddy-dust-59pzxg?file=%2Fsrc%2FYupNumberExtensionExample.ts

Expected behavior
MixedLocale, StringLocale, NumberLocale,DateLocale,ObjectLocale, ArrayLocale, TupleLocale and BooleanLocale interfaces should be exported from src/index.ts (lib/index.d.ts in build output) to support declaration merging and enable using setLocale in a type-safe way for extended methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant