Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript support? #1

Open
arslancharyev31 opened this issue Nov 23, 2020 · 2 comments
Open

Typescript support? #1

arslancharyev31 opened this issue Nov 23, 2020 · 2 comments

Comments

@arslancharyev31
Copy link

Good day. I was wondering if there are any plans to export typescript definitions so the Only component can be easily imported by TS?

@sag1v
Copy link
Owner

sag1v commented Nov 23, 2020

Yeah sure we can add a .d.ts file reflecting the proptypes.
Do you want to create a PR?

@arslancharyev31
Copy link
Author

arslancharyev31 commented Nov 23, 2020

It is possible to either generate the .d.ts file automatically (source) or manually. Which one would you prefer?

P.S. Running npm install outputs:

found 1982 vulnerabilities (831 low, 16 moderate, 1133 high, 2 critical)

So probably it's best to update the package with the latest dependencies before adding anything new.

P.S.S. Automatic generation may not be the best option since it generates very generic definitions with almost anything being typed as any:

index.d.ts
export default Only;
declare class Only {
  static defaultProps: {
      hiddenMode: string;
      className: string;
  };
  static propTypes: {
      /** A single child element */
      children: any;
      /** When true, children will rendered as is  */
      when: any;
      /** Determines how "react-only-when" should hide the child element
       * "withNull": Will not render the child
       * "withDisplay": Will render the child with display:none
       * "withVisibility": Will render the child with visibility:hidden
       * "withCss": Will render the child with a CSS class (you can pass it a custom className prop)
      */
      hiddenMode: any;
      /** This is working in combination with hiddenMode={"withCss"}   */
      className: any;
  };
  render(): any;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants