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

Error TS2339: Property 'value' does not exist on type 'ValidationError’ #795

Closed
francjohny opened this issue Nov 6, 2019 · 2 comments · Fixed by #794
Closed

Error TS2339: Property 'value' does not exist on type 'ValidationError’ #795

francjohny opened this issue Nov 6, 2019 · 2 comments · Fixed by #794

Comments

@francjohny
Copy link
Contributor

Current Behavior

Accessing property in union of object types fails for properties not defined on all union members.

error TS2339: Property 'value' does not exist on type 'ValidationError'.
  Property 'value' does not exist on type '{ location?: undefined; param: "_error"; msg: any; nestedErrors: ValidationError[]; }'.

Possible Solution

#794

Environment

TypeScript v3.7.2

@gustavohenke
Copy link
Member

You would have to check the discriminator, so

if (error.param === '_error') {
  // has nestedErrors
} else {
  // has value
}

but I can see how annoying it must be.
...and location is there for some reason I don't recall 🤷‍♂

@lock
Copy link

lock bot commented Jan 24, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants