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

Typing for react-step-progress-bar #20

Open
gothraven opened this issue Oct 8, 2019 · 10 comments
Open

Typing for react-step-progress-bar #20

gothraven opened this issue Oct 8, 2019 · 10 comments

Comments

@gothraven
Copy link

First of all, thank you for this amazing library, now that i'm using it in a Typescript project, i was looking for its types i tried npm install @types/react-step-progress-bar but it does not exist.

@mannamh
Copy link

mannamh commented Nov 8, 2019

Same issue when i tried in one f my react project

@rknyra
Copy link

rknyra commented Jan 27, 2021

same issue here 🤔😕😕

@ghernandezr
Copy link

ghernandezr commented Mar 26, 2021

I solve this issue declaring my own .d.ts file, I am using create-react-app, this search for the file src/global.d.ts
This is how it look to me, any suggestion is welcome:

declare module 'react-step-progress-bar' {
  interface ProgressBarProps {
    percent?: number;
    filledBackground?: any;
    height?: string | number;
    stepPositions?: number;
  }

  interface StepProps {
    transition?: any;
    position?: any;
  }
  class ProgressBar extends React.Component<ProgressBarProps, any> {}
  class Step extends React.Component<StepProps, any> {}
}  

Thanks!!!!

@pierreericgarcia
Copy link
Owner

Thank you so much for your feedbacks ! I'll use typescript for the 2.0 !

@andresdsep
Copy link

Had a closer look to the package code and made a couple of changes to @ghernandezr's types:

declare module 'react-step-progress-bar' {
  import React from 'react';

  interface ProgressBarProps {
    percent: number;
    stepPositions?: Array<number>;
    unfilledBackground?: string;
    filledBackground?: string;
    width?: number;
    height?: number;
    hasStepZero?: boolean;
    text?: string;
  }
  interface StepProps {
    children: (props: {
      accomplished: boolean;
      transitionState: string;
      index: number;
      position: number;
    }) => React.ReactNode;
    transition?: 'scale' | 'rotate' | 'skew';
    transitionDuration?: number;
  }
  class ProgressBar extends React.Component<ProgressBarProps, any> {}
  class Step extends React.Component<StepProps, any> {}
}

@pinefirst
Copy link

I have same issue in typescript

@tomniermann
Copy link

tomniermann commented Feb 2, 2023

ProgressBarProps also needs children so...

declare module 'react-step-progress-bar' {
  import React from 'react'

  interface ProgressBarProps {
    percent: number
    stepPositions?: number[]
    unfilledBackground?: string
    filledBackground?: string
    width?: number
    height?: number
    hasStepZero?: boolean
    text?: string
    children?:
    | React.ReactChild
    | React.ReactChild[]
  }
  interface StepProps {
    children: (props: {
      accomplished: boolean
      transitionState: string
      index: number
      position: number
    }) => React.ReactNode
    transition?: 'scale' | 'rotate' | 'skew'
    transitionDuration?: number
  }
  class ProgressBar extends React.Component<ProgressBarProps, any> {}
  class Step extends React.Component<StepProps, any> {}
}

@gothraven
Copy link
Author

Thank you @tomniermann @andresdsep 🙏 I hope the types will be included in future releases!

@gothraven
Copy link
Author

@pierreericgarcia I'm looking forward to help with adding types and or transforming the code base into typescript but I don't see branches for that matter, I'd love to get in touch with you if there is more I should know about the migration to typescript 🙏

@temirovtemirlan
Copy link

Thank you very much, for typing this awesome library🚀🚀🚀

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

9 participants