jacklein / rn-bottom-drawer

a react native bottom drawer component
MIT License
186 stars 84 forks source link

Typescript compatible? #41

Open rkynaa opened 3 years ago

rkynaa commented 3 years ago

Hi, I want to use this library. However, the language that I use is typescript and seems like I can't use the library. Is it typescript compatible? image

melnyczuk commented 3 years ago

You can get around this by adding a custom TypeScript definition file global.d.ts at the project root and including this in your tsconfig.json as part of the typeRoots field:

"typeRoots": ["./node_modules/@types", "./global"],

Inside global.d.ts you can then define the type of the component:

declare module 'rn-bottom-drawer' {
  import {FC} from 'react';
  const BottomDrawer: FC<{
    containerHeight: number;
    offset?: number;
    downDisplay?: number;
    backgroundColor?: string;
    startUp?: boolean;
    roundedEdges?: boolean;
    shadow?: boolean;
    onExpanded: () => void;
    onCollapsed: () => void;
  }>;
  export default BottomDrawer;
}