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

Collect errors correctly #399

Merged
merged 2 commits into from
Jan 11, 2020
Merged

Collect errors correctly #399

merged 2 commits into from
Jan 11, 2020

Conversation

snewcomer
Copy link
Collaborator

close #396

@snewcomer snewcomer added the bug label Jan 11, 2020
@snewcomer snewcomer self-assigned this Jan 11, 2020
@snewcomer snewcomer changed the title Sn/collect errors Collect errors correctly Jan 11, 2020
@snewcomer snewcomer merged commit 41f0ef0 into master Jan 11, 2020
@snewcomer snewcomer deleted the sn/collect-errors branch January 11, 2020 16:39
@@ -70,8 +70,8 @@ export interface ChangesetDef {
_runningValidations: RunningValidations,
_bareChanges: { [s: string]: any },

changes: any, // { key: string; value: any; }[], //ComputedProperty<object[], object[]>,
errors: { key: string; value: any; validation: ValidationErr | ValidationErr[] }[], //ComputedProperty<object[], object[]>,
Copy link
Contributor

Choose a reason for hiding this comment

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

@snewcomer Any specific reason for this change? It was super helpful to have the actual shape of the error here. I would suggest making a type (or an interface) specifically for the error.

Here is an example of a function that is written in TS which was working fine before this change:

  get errors(): string[] {
    const fieldErrors = this.args.changeset.errors.filter(error => {
      return error.key === this.fullFieldName;
    });

    return fieldErrors.reduce(
      (errors: string[], error: ValidationError): string[] => {
        return [...errors, ...error.validation];
      },
      []
    );
  }

Now typescript is not happy, with the following error:

Property 'key' does not exist on type 'object'.

25       return error.key === this.fullFieldName;

Probably the same would apply for changes above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This should be an easy fix...

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

Successfully merging this pull request may close these issues.

Errors from nested keys have incorrect key
2 participants