react-step-progress-bar
react-step-progress-bar copied to clipboard
Typing for react-step-progress-bar
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.
Same issue when i tried in one f my react project
same issue here π€ππ
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!!!!
Thank you so much for your feedbacks ! I'll use typescript for the 2.0 !
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> {}
}
I have same issue in typescript
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> {}
}
Thank you @tomniermann @andresdsep π I hope the types will be included in future releases!
@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 π
Thank you very much, for typing this awesome libraryπππ