-
Notifications
You must be signed in to change notification settings - Fork 55
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
added --return-errors flag #122
base: master
Are you sure you want to change the base?
Conversation
documentation fix fix fix
Hmm... actually there's an error in my code, which i suspect also exist in the |
Ok completely rewrote to output new function. Comments are welcome. Feels like it could use some cleanup. |
Hey @wiegell, thanks for your contribution! I would have preferred to discuss a change like this in an issue before you opened a PR. tbh I had already considered such a feature, but not as a global flag. The current Either way I don't want to just have a flag for how the entire thing works because So, this is my proposal: /**
* @see {isFoo} ts-auto-guard:type-guard
* @see {validateFoo} ts-auto-guard:validator
**/
interface Foo { /* ... */ } |
Also if this is just intended for debugging then I'd be happy to update the debug functionality to just fire off a single error which includes the full information of mismatched fields... Let me know what this is for. |
Yea i just thought i would have to do a minor tweak and all of a sudden i had written a lot of code. And i wanted to get going using it in my project. So i had already written the code and i thought i might as well make the PR instead of an issue :)
Sounds reasonable, although i actually think that the --debug flag falls in the same category. |
Hey @wiegell somehow I missed the notification that you responded. Sorry bout that.
The However a user could use a validator in its place for debugging so I'd actually be happy to remove the debug mode and instead give the option to create a validator which they can manually switch out for the failing check. |
): string | null { | ||
const { debug } = options | ||
const propertyName = property.name | ||
|
||
const isIdentifier = propertyName[0] !== '"' | ||
const varName = isIdentifier | ||
? `${objName}.${propertyName}` | ||
: `${objName}[${propertyName}]` | ||
? `${objName}?.${propertyName}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ?
shouldn't be necessary because if the object is undefined
then it should be checked before the code attempts to access a property.
I'm def open to getting this merged if you're interested in working on it more. 👍 |
I have some other stuff going on atm., and my fork satisfies my current needs. |
@wiegell I'll leave it open as a reference. tbh this project is just running in the background for me, but someone might want to pick it up later. |
On second thought it should maybe export to entirely different function, so you could have both the regular type guard and this new one concurrently.
Thoughts?