patternfly / patternfly-react

A set of React components for the PatternFly project.
https://react-staging.patternfly.org/
MIT License
773 stars 350 forks source link

`react-core` type declarations contain bugs #10695

Open allisonkarlitskaya opened 2 months ago

allisonkarlitskaya commented 2 months ago

Quite simple: when we run tsc on our project we get a bunch of error output from the PatternFly type declarations:

node_modules/@patternfly/react-core/dist/esm/components/MenuToggle/MenuToggleCheckbox.d.ts:4:18 - error TS2430: Interface 'MenuToggleCheckboxProps' incorrectly extends interface 'Omit<HTMLProps<HTMLInputElement>, "disabled" | "type" | "onChange" | "checked">'.
  Types of property 'defaultChecked' are incompatible.
    Type 'boolean | null' is not assignable to type 'boolean | undefined'.
      Type 'null' is not assignable to type 'boolean | undefined'.

4 export interface MenuToggleCheckboxProps extends Omit<React.HTMLProps<HTMLInputElement>, 'type' | 'onChange' | 'disabled' | 'checked'>, OUIAProps {
                   ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@patternfly/react-core/dist/esm/components/NotificationDrawer/NotificationDrawerListItemHeader.d.ts:4:35 - error TS2304: Cannot find name 'SVGIconProps'.

4     success: React.ComponentClass<SVGIconProps, any>;
                                    ~~~~~~~~~~~~

node_modules/@patternfly/react-core/dist/esm/components/NotificationDrawer/NotificationDrawerListItemHeader.d.ts:5:34 - error TS2304: Cannot find name 'SVGIconProps'.

5     danger: React.ComponentClass<SVGIconProps, any>;
                                   ~~~~~~~~~~~~

node_modules/@patternfly/react-core/dist/esm/components/NotificationDrawer/NotificationDrawerListItemHeader.d.ts:6:35 - error TS2304: Cannot find name 'SVGIconProps'.

6     warning: React.ComponentClass<SVGIconProps, any>;
                                    ~~~~~~~~~~~~

node_modules/@patternfly/react-core/dist/esm/components/NotificationDrawer/NotificationDrawerListItemHeader.d.ts:7:32 - error TS2304: Cannot find name 'SVGIconProps'.

7     info: React.ComponentClass<SVGIconProps, any>;
                                 ~~~~~~~~~~~~

node_modules/@patternfly/react-core/dist/esm/components/NotificationDrawer/NotificationDrawerListItemHeader.d.ts:8:34 - error TS2304: Cannot find name 'SVGIconProps'.

8     custom: React.ComponentClass<SVGIconProps, any>;
                                   ~~~~~~~~~~~~

node_modules/@patternfly/react-core/dist/esm/helpers/Popper/thirdparty/popper-core/types.d.ts:118:34 - error TS2344: Type 'Options' does not satisfy the constraint 'Obj'.

118     fn: (arg0: ModifierArguments<Options>) => State | void;
                                     ~~~~~~~

  node_modules/@patternfly/react-core/dist/esm/helpers/Popper/thirdparty/popper-core/types.d.ts:112:33
    112 export interface Modifier<Name, Options> {
                                        ~~~~~~~
    This type parameter might need an `extends Obj` constraint.

node_modules/@patternfly/react-core/dist/esm/helpers/Popper/thirdparty/popper-core/types.d.ts:119:39 - error TS2344: Type 'Options' does not satisfy the constraint 'Obj'.

119     effect?: (arg0: ModifierArguments<Options>) => () => void | void;
                                          ~~~~~~~

  node_modules/@patternfly/react-core/dist/esm/helpers/Popper/thirdparty/popper-core/types.d.ts:112:33
    112 export interface Modifier<Name, Options> {
                                        ~~~~~~~
    This type parameter might need an `extends Obj` constraint.

Found 8 errors in 3 files.

Errors  Files
     1  node_modules/@patternfly/react-core/dist/esm/components/MenuToggle/MenuToggleCheckbox.d.ts:4
     5  node_modules/@patternfly/react-core/dist/esm/components/NotificationDrawer/NotificationDrawerListItemHeader.d.ts:4
     2  node_modules/@patternfly/react-core/dist/esm/helpers/Popper/thirdparty/popper-core/types.d.ts:118

We can't use skipLibCheck because we have .d.ts files in our own project that we want to check.

We're using "@patternfly/react-core": "5.3.3".

tlabaj commented 1 month ago

Do you have strict mode enabled?

allisonkarlitskaya commented 1 month ago

Yes.