Skip to content

Conversation

@mitko-slapdash
Copy link
Contributor

Fixes https://github.com/woutervh-/typescript-is/issues/57

Hi @woutervh- I took a stab at adding info about the input data to the error message of TypeGuardError. For example:

'TypeGuardError: validation failed at undefined: expected a number, found: undefined'
'TypeGuardError: validation failed at $.children.[0].children: expected an array, found: null'
'TypeGuardError: validation failed at $.children: expected an array, found: "foo"'

I'm not sure if you're OK with the error message including the data at the error path, but we've been using a custom catcher in some places which replaces the error message as defined in this PR and found it very helpful!

I was also considering adding an option to gate the printing of the "found" data into the error message but couldn't figure out how/wheter options can be accessed from index.js

Test plan: existing unit tests

@woutervh-
Copy link
Owner

Thanks, good stuff! :)

@woutervh- woutervh- merged commit 525f078 into woutervh-:master May 31, 2020
@woutervh-
Copy link
Owner

Released v0.16.1
https://github.com/woutervh-/typescript-is/releases/tag/v0.16.1

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