leefsmp / Re-Flex

Resizable Flex layout container components for advanced React web applications
https://leefsmp.github.io/Re-Flex/index.html
MIT License
639 stars 72 forks source link

Fix demo minSize and maxSize type #159

Closed lfpose closed 2 years ago

lfpose commented 2 years ago

Problem

If we run the demo, we get an error with tsserver due to the type definition of minSize and maxSize in the index.d.ts file.

Also this mentions that number should be preferred. https://github.com/leefsmp/Re-Flex/issues/95

index.d.ts

  export type ReflexElementProps = {
      propagateDimensions?: boolean;
      propagateDimensionsRate?: number;
      resizeHeight?: boolean;
      resizeWidth?: boolean;
      size?: number;
      minSize?: number;
      maxSize?: number;
      flex?: number;
      direction?: PosNeg | [PosNeg, PosNeg];
      onStartResize?: (args: HandlerProps) => void;
      onStopResize?: (args: HandlerProps) => void;
      onResize?: (args: HandlerProps) => void;
  } & StyleAndClass;

Solution

Change minSize="200" to minSize={200} for all instances in the demo.jsx file

Error

The error looks like this:

  maxSize='800 [tsserver 2769] [E] No overload matches this call.
>                Overload 2 of 2, '(props: ReflexElementProps, context: any):
  <div classNa ReflexElement', gave the following error.
    <Sidebar o     Type 'string' is not assignable to type 'number | undefined'.
  </div>         Overload 2 of 2, '(props: ReflexElementProps, context: any):
</ReflexElemen ReflexElement', gave the following error.
<ReflexSplitte     Type 'string' is not assignable to type 'number | undefined'.