storybook-readme icon indicating copy to clipboard operation
storybook-readme copied to clipboard

Add typings for v5.0.0

Open tuchk4 opened this issue 6 years ago • 5 comments

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

  • Added addReadme decorator that is result of makeDecorator(). According to storybooks code it should be type MakeDecoratorResult = (...args: any) => any;
  • Added addHeader
  • Added addFooter

addFooter and addHeader are the same

type addFooter =(md:string) => void;
type addHeader =(md:string) => void;
  • Added configureReadme
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

  • Added addReadme
  • Added addHeader
  • Added addFooter
  • Added configureReadme

tuchk4 avatar Mar 14 '19 10:03 tuchk4

cc @lonyele

tuchk4 avatar Mar 16 '19 19:03 tuchk4

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 avatar Mar 17 '19 11:03 lonyele

@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

  • addFooter, addHeader should be a function because It takes string and add it to config.js internally to be used later

  • inside of interface ConfigureReadmeConfig, I changed StoryPreview, DocPreview, HeaderPreview, FooterPreview to a function as you wrote on https://github.com/tuchk4/storybook-readme#global-configuration

  • same as addFooter, addHeader, I changed ConfigureReadme to a function. (btw DefinitelyTyped lint doesn't allow I prefix on name so I changed it to ConfigureReadmeConfig)

  • since It is fully backward compatibility, I added new types for v5 and left all previous types with a comment

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

lonyele avatar Mar 31 '19 10:03 lonyele

@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.

taylon avatar Apr 02 '19 23:04 taylon

@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)

lonyele avatar Apr 02 '19 23:04 lonyele