Skip to content

Bug - Modal, DropDownItem, TreeView - strict TypeScript type checking fails #7553

@starpit

Description

@starpit

Describe the problem
When strict: true type checking is enabled in TypeScript, three modules (at least) fail to compile. This seems to be due to a few uses of ... | null, e.g. in DropDownItem:

    tabIndex?: number | null; <-- removing the | null part makes typescript happy

why does patternfly have both the ? and the | null? this not only seems unnecessary duplication, but... doesn't type check.

Interface 'ModalProps' incorrectly extends interface 'HTMLProps<HTMLDivElement>'.
  Types of property ''aria-labelledby'' are incompatible.
    Type 'string | null | undefined' is not assignable to type 'string | undefined'.
      Type 'null' is not assignable to type 'string | undefined'.
Interface 'DropdownItemProps' incorrectly extends interface 'InternalDropdownItemProps'.
  Types of property 'tabIndex' are incompatible.
    Type 'number | null | undefined' is not assignable to type 'number | undefined'.
      Type 'null' is not assignable to type 'number | undefined'.
Interface 'TreeViewCheckProps' incorrectly extends interface 'Partial<InputHTMLAttributes<HTMLInputElement>>'.
  Types of property 'checked' are incompatible.
    Type 'boolean | null | undefined' is not assignable to type 'boolean | undefined'.
      Type 'null' is not assignable to type 'boolean | undefined'.

How do you reproduce the problem?
Enable strict type checking.

Expected behavior
Strict type checking is goodness, and should work.

Is this issue blocking you?
The workaround is not to use strict type checking...

Screenshots
n/a

What is your environment?

  • OS: any
  • Browser any
  • Version @patternfly/react-core@4.221.3

What is your product and what release date are you targeting?

Any other information?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions