-
Notifications
You must be signed in to change notification settings - Fork 935
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
Can't export MixedSchema when declaration=true set in tsconfig #1162
Comments
i'm not really clear on what this error means...usually it's because types aren't exported by the package, but they are so unsure why this is happening... |
I just did some digging and these few lines may be the issue
When Mixed is exported in this way only the class constructor is exported, not the class instance types. (This doc explains it nicely https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions). One way to fix it would be to use namespace merging.
I have created a sample implementation that shows how it will work in the sandbox. |
hmm, the code is currently like this for a reason, Mixed, needs different types than Base, but i don't actually want them to be distinct classes. extending Mixed, should extend all other schema (it's weird) |
So if I understand correctly: |
It's more strict Mixed has to be the same as Base. This is because |
Same issue here :) |
PR's welcome if you know what might be wrong with how it's currently set up! |
How about something like this?
Here's a sandbox to demonstrate I'll put up a PR if you think it might work |
If it works go for it, happy to take a PR |
I'm having this issue as well. |
I'm having this issue as well. |
Bumping to yup@0.32.9 fixed the issue! thanks, guys 🙌 |
I'm getting the same error when using Ref, eg:
|
I'm trying to make a Typescript package with a yup schema.
My plan is to import this package in a couple projects and use the same validator.
I'm having some difficulty exporting the schema.
What I'm trying to do is export a mixed schema like so. But I'm getting a compiler error.
The following example summarizes the problem I'm having.
Which produces an error:
I've also tried a few variations without success.
How do I export 'a'?
Appreciate the help!
Here's the sandbox: https://codesandbox.io/s/pedantic-ishizaka-f7th5?file=/src/index.ts
The text was updated successfully, but these errors were encountered: