surajitsarkar19 / react-native-radial-gradient

Radial gradient library for react native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add @types to support the project with typescript

ssthil opened this issue · comments

Any updates on this ? I'm still getting : could not find a declaration file for module react-native-radial-gradient.

Even though there's index.d.ts present.

Any updates on this ? I'm still getting : could not find a declaration file for module react-native-radial-gradient.

Even though there's index.d.ts present.

hi, you can use mine :
create 1 file in your typings folder called react-native-radial-gradient.d.ts

declare module 'react-native-radial-gradient' {
  import {Component} from 'react';
  import {StyleProp, ViewStyle} from 'react-native';

  interface RadialGradientProps {
    center?: [number, number];
    colors?: [string, string];
    radius?: number;
    style?: StyleProp<ViewStyle>;
    stops?: number[];
  }

  export default class RadialGradient extends Component<RadialGradientProps> {}
}

@surajitsarkar19 I think this problem is still there.
@rbayuokt 's code is a good tip, but we shouldn't have to type it manually.

For using with Functional Components, changed the typing too:

declare module 'react-native-radial-gradient' {
  import type { ReactElement } from 'react';
  import type { StyleProp, ViewStyle } from 'react-native';

  interface RadialGradientProps {
    center?: [number, number];
    colors?: [string, string];
    radius?: number;
    style?: StyleProp<ViewStyle>;
    stops?: number[];
    children?: ReactElement;
  }

  export default function RadialGradient(props: RadialGradientProps): JSX.Element {}
}