Skip to content

PropItem.defaultValue is typed as any instead of a more narrow type #537

@lukasnys

Description

@lukasnys

The defaultValue field on PropItem is typed as any, but at runtime it is always either null or { value: ... }. This means TypeScript gives no warning when consumers access prop.defaultValue.value without a null check.

Suggested fix

// Before
export  interface PropItem {
  ...
  defaultValue: any;
  ...
}

// After
export  interface PropItem {
  ...
  defaultValue: { value: any } | null;
  ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions