Skip to content

Non-required attributes are not automatically generated to have | null appended to type #148

@mkmckenzie

Description

@mkmckenzie

The documentation states:

Non-required attributes automatically have | null appended to their type.

However after generating types, there is not a single instance of null in the generated files, despite dozens of attributes being non-required.

Node version: 16.17.0
Package version: 3.4.0

Yarn script:

yarn contentful-typescript-codegen --output src/types/contentful/types.generated.ts --fieldsOnly && contentful-typescript-codegen --output server/types/contentful/types.generated.ts --fieldsOnly

Expected output:

      /** Add To Bag Text */
    addToBagText?: string | null;

    /** Bag Text */
    bagText?: string | null;

    /** Added To Bag Text */
    addedToBagText?: string | null;

Actual output:

      /** Add To Bag Text */
    addToBagText?: string | undefined;

    /** Bag Text */
    bagText?: string | undefined;

    /** Added To Bag Text */
    addedToBagText?: string | undefined;

Any debugging guidance would be greatly appreciated! Thank you!

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