Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Added typescript definitions #51

Merged
merged 1 commit into from
Oct 27, 2016
Merged

Added typescript definitions #51

merged 1 commit into from
Oct 27, 2016

Conversation

ephys
Copy link
Contributor

@ephys ephys commented Sep 30, 2016

Would these match your needs for issue #33 ?

Don't hesitate to point out anything I might have done wrong or missed! :)

Copy link
Contributor

@frederickfogerty frederickfogerty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ephys, I've given some feedback on this PR. I think my first comment is probably the most important - have you written declaration files for modules before? I haven't, so I don't know the correct format - if you have before, ignore my comment.

@@ -0,0 +1,29 @@
declare module 'storybook-addon-knobs' {
import WrapStory from "../src/components/WrapStory.js";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work @ephys? WrapStory has no declaration file, so wouldn't this throw an error?

story: string,
}

export function knob<T>(name: string, options: KnobOption<T>): T;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this 👍

@@ -0,0 +1,29 @@
declare module 'storybook-addon-knobs' {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be @kadira/storybook-addon-knobs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not actually sure how declaration files work when included with modules.

Using redux definitions as reference:
https://github.com/reactjs/redux/blob/master/index.d.ts

Seems like we don't need the declare module wrapper?

@frederickfogerty
Copy link
Contributor

Thanks for the PR by the way @ephys


export function knob<T>(name: string, options: KnobOption<T>): T;

export function text(name: string, value: string): string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also support null for the value. Is that something supported by TS.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this can be value: string | null.

If you want it to be optional as well, the syntax is value?: string | null

@arunoda
Copy link
Contributor

arunoda commented Oct 6, 2016

@frederickfogerty Thanks for reviewing this.
I'm not a TS guy (I should start learning it).

Could you ping me when it's ready to merge?

@frederickfogerty
Copy link
Contributor

@arunoda this is @ephys's PR, so it's up to @ephys to make the changes and respond to the comments

@arunoda
Copy link
Contributor

arunoda commented Oct 6, 2016

@frederickfogerty Yep I got it.
I mean once he made changes, you could double check it :)
So, I am confident to merge it.


export function select<T>(name: string, options: { [s: string]: T }, value: string): T;

export function date(name: string, value: Date = new Date(0));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value: Date = new Date(0) is causing an error when I try to compile this. Parameter initializers are not needed in declarations, this can just be value?: Date.

@frederickfogerty
Copy link
Contributor

@arunoda For sure! If I happen to miss any updates, please ping me and I'll give it another review 😄

@ephys
Copy link
Contributor Author

ephys commented Oct 6, 2016

Thanks for the review! I'll include the changes this afternoon (gmt) :)

@aivarsak
Copy link

Hi!
Any plans on merging this PR?

@arunoda
Copy link
Contributor

arunoda commented Oct 10, 2016

@aivarsak we are waiting for some changes from @ephys.
Seems like he is busy these days :)

@ephys
Copy link
Contributor Author

ephys commented Oct 13, 2016

More sick than busy, unfortunately the result is the same. :( On hold until I get better

@aivarsak
Copy link

@ephys ok, wish you getting well soon

@ephys
Copy link
Contributor Author

ephys commented Oct 13, 2016

Thank you!

@frederickfogerty
Copy link
Contributor

Get well soon 😄 @ephys

@frederickfogerty
Copy link
Contributor

Alternatively, @ephys @arunoda if you want to give me write access to the PR I can get this updated/merged?

@roonyh
Copy link
Contributor

roonyh commented Oct 26, 2016

@frederickfogerty Not sure if that is possible in Github. But I think you can easily submit another PR with work on top of this commit.

  • Fork this repo and clone.
  • git checkout -b Ephys-master master
  • git pull https://github.com/Ephys/storybook-addon-knobs.git master
  • Do your work :)
  • Commit and PR

@frederickfogerty
Copy link
Contributor

@roonyh thanks, I just wanted to give as much credit as possible to @ephys, so I wanted to work on this PR instead. If he doesn't get back to me, I'll pull his fork.

And by the way, the steps should add his fork as a separate remote, and then pull from that.. not sure if pulling directly from a git repo would work (I'm willing to give it a try though)

@roonyh
Copy link
Contributor

roonyh commented Oct 26, 2016

@frederickfogerty Ephys' commit will be preserved with his info so he definitely will be credited for his work :) It does not matter who make the PR much, as long as the author field carries correct details in each commit. So don't worry about that.

I think I have successfully pulled from urls like that. Give it a try :)

@frederickfogerty
Copy link
Contributor

Thanks @roonyh, you were correct! I love learning new stuff.

@arunoda @ephys I have created a newer version of this PR over on #65.

@roonyh roonyh merged commit 4639158 into storybook-eol:master Oct 27, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants