claus / react-dat-gui

React dat.GUI
MIT License
292 stars 56 forks source link

TypeScript type definitions bug #20

Closed engina closed 5 years ago

engina commented 5 years ago

index.d.ts declares style as StyleSheet

export interface DatGuiProps {
    data: any;                      // The data your dat.GUI controller will mutate
    onUpdate: (data: any) => any;   // The method which will be called whenever an update is handled by the controller
    children: any; // The dat.GUI components that make up the controller
    liveUpdate?: boolean;           // Determines if live updates should occur, defaults to true
    labelWidth?: number;            // The width of the labels in pixels, defaults to 40
    className?: string;             // The class name to set on the DatGui div
    style?: StyleSheet;             // The style object to set on the DatGui div
}

But source declares it as style: PropTypes.object,

And latter is the expected type. I think this is an unintentional bug.

This is a temporary solution meanwhile:

const style = {
/* actual style */
      position: "inherit",
/* below is to trick ts compiler into believing this is a StyleSheet instance*/
      disabled: false,
      href: null,
      media: null!,
      ownerNode: null!,
      parentStyleSheet: null,
      title: null,
      type: "",
    };
rohan-deshpande commented 5 years ago

Hey thanks for this, PRs are welcome!

tim-soft commented 5 years ago

I believe this is fixed in https://github.com/claus/react-dat-gui/pull/33

style?: StyleSheet; -> style?: React.CSSProperties;