tuchk4 / storybook-readme

React Storybook addon to render README files in github style
MIT License
544 stars 249 forks source link

Add typings for v5.0.0 #124

Open tuchk4 opened 5 years ago

tuchk4 commented 5 years ago

Prev request typings request https://github.com/tuchk4/storybook-readme/issues/93 Prev DefinitelyTyped PR https://github.com/DefinitelyTyped/DefinitelyTyped/pull/29512

What new at 5.0.0

storybook-readme/index

addFooter and addHeader are the same

type addFooter =(md:string) => void;
type addHeader =(md:string) => void;
interface ICommonConfig {
  header: string;
  footer:  string;
  StoryPreview: React.ReactNode;
  DocPreview: React.ReactNode;
  HeaderPreview: React.ReactNode;
  FooterPreview: React.ReactNode;
}
type ConfigureReadme = (config: ICommonConfig) => void;

storybook-readme/vue/index

tuchk4 commented 5 years ago

cc @lonyele

lonyele commented 5 years ago

wow you've been doing a lot of works 😀 I should check some differences before I make something useful. I'll watch this repo and hopefully can help make this repo better. good works!👍

lonyele commented 5 years ago

@tuchk4 Hi, I've just pull requested v5 to DefinitelyTyped. Here is the link https://github.com/DefinitelyTyped/DefinitelyTyped/pull/34356


export type MakeDecoratorResult = (...args: any[]) => any;

export const addReadme: MakeDecoratorResult;
export function addFooter(md: string): void;
export function addHeader(md: string): void;
export interface ConfigureReadmeConfig {
  header: string;
  footer: string;
  StoryPreview: (props: { children: React.ReactNode }) => React.ReactNode;
  DocPreview: (props: { children: React.ReactNode }) => React.ReactNode;
  HeaderPreview: (props: { children: React.ReactNode }) => React.ReactNode;
  FooterPreview: (props: { children: React.ReactNode }) => React.ReactNode;
}

export function configureReadme(config: ConfigureReadmeConfig): void;

I looked up the actual code and changed some of it

Please let me know if something is wrong (btw I'm really sorry for updating typescript definition this late)

taylon commented 5 years ago

@lonyele I just updated the types and I'm having issues with the ConfigureReadmeConfig interface. I'm pretty sure those fields should all be optional since you are not required to provide all of them, in my code currently I only set StoryPreview and the other fields go with whatever default storybook-readme uses.

lonyele commented 5 years ago

@taylon You are definitely right. I just made a PR. Usually It only takes 1~3 days untill it is merged. Thanks for making this better one

Or... it gets merged super fast.(https://github.com/DefinitelyTyped/DefinitelyTyped/pull/34417)