Skip to content

Option<String> generates string | undefined as type instead of string | null #53

@chris13524

Description

@chris13524

The examples here cover scenarios where I add 1 of 3 different attributes to my optional field to make it generate ? or | undefined.

However, I'm not adding any attributes. Serde's normal behavior with an Option is to allow it to be null. However, if a field isn't supplied (set to undefined in JS) then serde will fail when it doesn't have the field it expects.

To summarize, if my field is just a normal Option<String> with no fallback for the missing value, so tsify should generate string | null to be accurate to serde's behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions