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

Solves typing issues in prependDeep + allow JS for incremental transition to Typescript #1060

Merged
merged 5 commits into from
Nov 19, 2020

Conversation

Bartmr
Copy link

@Bartmr Bartmr commented Oct 6, 2020

No description provided.

@Bartmr Bartmr mentioned this pull request Oct 6, 2020
@@ -22,8 +22,8 @@ export default function merge(
target[key] = sourceVal;
} else if (targetVal === sourceVal) {
continue;
} else if (isSchema(targetVal)) {
if (isSchema(sourceVal)) target[key] = sourceVal.concat(targetVal);
} else if (targetVal instanceof MixedSchema) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code was correct, things that don't extend MixedSchema should be included here.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what specifically is this fixing? Likely the more correct fix is to expand the Schema interface such that it is accurate. This may generally require a lot of typing rework. There are lots of places that use MixedSchema simply as a shortcut/laziness on my part while trying to verify the type approach would work

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to solve the typing issues that Typescript reported.

Not all schema types have concat I think. Other solution might be changing Schema from interface to class that has a concat method and use instanceof to detect if a given value is a schema at all

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah fair, this is ultimately a fairly niche-y case

@jquense jquense merged commit 334404a into jquense:ts Nov 19, 2020
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

Successfully merging this pull request may close these issues.

2 participants