Skip to content

IsOptional Typescript dialect #101

Closed
@thevtm

Description

@thevtm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions