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

IsOptional Typescript dialect #101

Closed
thevtm opened this issue Jul 5, 2017 · 1 comment · Fixed by #102
Closed

IsOptional Typescript dialect #101

thevtm opened this issue Jul 5, 2017 · 1 comment · Fixed by #102

Comments

@thevtm
Copy link

thevtm commented Jul 5, 2017

In Typescript the optional word is used to mean that an property in the object can be undefined.

Optional Properties
Not all properties of an interface may be required. Some exist under certain conditions or may not be there at all. These optional properties are popular when creating patterns like “option bags” where you pass an object to a function that only has a couple of properties filled in.

From the Typescript hand book

But the IsOptional decorator checks if its an empty string and not null.

return object[propertyName] !== "" && object[propertyName] !== null;

Source

In my opinion IsOptional should check if it is undefined (and maybe null) and the current version should be renamed.

@codebycorey
Copy link

@pleerock I opened a PR to address this issue.
#102

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

Successfully merging a pull request may close this issue.

2 participants