react-step-progress-bar icon indicating copy to clipboard operation
react-step-progress-bar copied to clipboard

Typing for react-step-progress-bar

Open gothraven opened this issue 5 years ago β€’ 10 comments

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.

gothraven avatar Oct 08 '19 13:10 gothraven

Same issue when i tried in one f my react project

mannamh avatar Nov 08 '19 19:11 mannamh

same issue here πŸ€”πŸ˜•πŸ˜•

rknyra avatar Jan 27 '21 11:01 rknyra

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!!!!

ghernandezr avatar Mar 26 '21 13:03 ghernandezr

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

pierreericgarcia avatar Nov 18 '21 14:11 pierreericgarcia

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> {}
}

andresdsep avatar Feb 09 '22 01:02 andresdsep

I have same issue in typescript

pinefirst avatar Jan 05 '23 09:01 pinefirst

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> {}
}

tomniermann avatar Feb 02 '23 19:02 tomniermann

Thank you @tomniermann @andresdsep πŸ™ I hope the types will be included in future releases!

gothraven avatar Feb 03 '23 12:02 gothraven

@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 πŸ™

gothraven avatar Feb 03 '23 12:02 gothraven

Thank you very much, for typing this awesome libraryπŸš€πŸš€πŸš€

temirovtemirlan avatar Nov 10 '23 19:11 temirovtemirlan