sekizlipenguen / react-native-popup-confirm-toast

MIT License
89 stars 12 forks source link

adds missing type definitions for config and other methods #22

Closed jrdn91 closed 8 months ago

jrdn91 commented 8 months ago

I created this type definition for my own project (with the help of copilot) and figured I would try to get it pulled in or at least posted here for others to copy into their project.

If you are looking to get your own project working with these type definitions in the mean time, just create a file wherever your other type files are called react-native-popup-confirm-toast.d.ts and paste the code in the PR. you shoult be all good after that.

I didn't go so far as to look into all the code to make sure functions don't return an event for instance so the functions may not be 100% accurate in that regard but I doubt many will need anything in such an event anyway since they're mostly just used as callbacks it seems.

sekizlipenguen commented 8 months ago

Hello @jrdn91 ,

Thank you for your support. I think there are a few problems, I'm sending you the list.

  1. SheetConfig

    
    export interface SPSheet {
         show: (props: Config) => void
         setHeight: (height: number, onOpenComplete: () => void) => void
         hide: () => void
     }
  2. export interface Root (Missing, how can we do this?)

Screenshot 2024-01-22 at 19 33 26

jrdn91 commented 8 months ago

@sekizlipenguen ah yes I missed the Root, also updated the config type for SPSheet, just missed the copy paste. I made the Root return a type of FunctionComponent (FC) since it looks like all it does is render, even though the prop types says it takes a style prop, that style prop doesn't appear to be used at all

sekizlipenguen commented 8 months ago

This looks great, I have one more question. The icon field is not just "react-native-vector-icons". This place can take any "component".

import { IconProps } from "react-native-vector-icons/Icon"
    export interface Config {
        icon?: FC<IconProps>
    }
jrdn91 commented 8 months ago

Ah, I saw this (react-native-vector-icons or component) in the docs so I think CoPilot got confused, just fixed it to be FC