avishayil/react-native-user-avatar

Typescript declarations

marcesengel opened this issue · 3 comments

Hey,

sorry for not preparing a PR (as I am not sure about the proper way to include typings into a module), but here are my TS module declarations for this package:

declare module 'react-native-user-avatar' {
  import { StyleProp, ImageStyle, ViewStyle } from 'react-native'

  const component:React.ComponentType<{
    name: string;
    src?: string;
    bgColor?: string;
    bgColors?: string[];
    textColor?: string;
    size?: number;
    imageStyle?: StyleProp<ImageStyle>;
    style?: StyleProp<ViewStyle>;
    borderRadius?: number;
    component?: React.ComponentType;
  }>;

  export default component;
}

Hey, thanks for helping with this! I looked around and did some research + found this article

Issue:
It appears the types are declared in the NPM module, but package.json has the types with the path of "types": "lib/typescript/src/index.d.ts".

Solution:
I modified the path from "types": "lib/typescript/src/index.d.ts". to "types": "src/types.tsx" because that's where the types file is. I'm not sure how to test it's working, but I think I fixed it @avishayil ?

Should be fixed with v1.0.8

raqso commented

Should be fixed with v1.0.8

@avishayil Version in the npm still has path: "types": "lib/typescript/src/index.d.ts", in package.json