Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addon-actions doesn't have a TS declaration file #1159

Closed
Keats opened this issue May 30, 2017 · 12 comments
Closed

addon-actions doesn't have a TS declaration file #1159

Keats opened this issue May 30, 2017 · 12 comments

Comments

@Keats
Copy link

Keats commented May 30, 2017

Which means trying to import { action } will result in:

(3,24): error TS7016: Could not find a declaration file for module '@storybook/addon-actions'. '/home/vincent/Code/moody/frontend/node_modules/@storybook/addon-actions/dist/index.js' implicitly has an 'any' type.
@MoctezumaDev
Copy link

MoctezumaDev commented May 30, 2017

Yes I have the same issue, I also tried to do something similar because the Readme.md in "@storybook/addon-actions" points you to do the following:

import { action, decorateAction } from "@storybook/addon-actions"

But there is no *.d.ts file

Which also makes me wonder which is the right way to use actions

Since you can also import it directly from "@storybook/react"

I tried like this but like the ticket #1153 the actions are not being logged.

@shilman shilman mentioned this issue May 30, 2017
2 tasks
@shilman
Copy link
Member

shilman commented May 30, 2017

@Keats @leonidaX created an umbrella issue here: #1166

Would love your feedback on the issue. And, if you're up for it, help to make this happen!

@tmeasday
Copy link
Member

(not sure if we are considering lack of TS support a bug or not at this point)

@shilman
Copy link
Member

shilman commented May 30, 2017

@tmeasday seems like enough people are using it that it's close enough 😄

@MoctezumaDev
Copy link

@shilman Sure, I would be happy to help... do you have a IRC channel or how can I join your slack channel?

@MoctezumaDev
Copy link

@tmeasday I would say that more and more people are going to start using TypeScript

https://trends.google.com/trends/explore?date=all&q=TypeScript

@shilman
Copy link
Member

shilman commented May 31, 2017

@leonidaX slack is here. we are excited and grateful for your help! 🎉

https://storybooks-slackin.herokuapp.com/

@MoctezumaDev
Copy link

I created an example project with storybook typescript and less

https://github.com/leonidax/storybook-ts-less-example

@shilman
Copy link
Member

shilman commented Jun 1, 2017

Thanks for creating a repo @leonidaX . I checked it out and answered your question on #1153

As for the lack of typescript definitions on the actions package, here's the story:

  • actions/linkTo used to come bundled with @kadira/storybook. they still come bundled with @storybook/react but are now deprecated and we plan to remove them soon. this is documented (here)[https://github.com/storybooks/storybook/blob/master/MIGRATION.md#deprecated-embedded-addons]
  • when i deprecated the packages, i didn't update the typescript definitions so they are still declared in @storybook/react but are not declared in in the @storybook/addon-actions package. they should be.
  • the problem you had with actions not getting logged was due to a bug in your code. AFAICT it was a different problem from the other problems people were having with inconsistent NPM modules.

And for the followup, I think we should have a uniform way to support Typescript in Storybook packages so that all @storybook/* have proper type definitions.

I'd like to close this issue and continue the discussion in #1166. @leonidaX @Keats are you OK with that?

@shilman
Copy link
Member

shilman commented Jun 1, 2017

PS - as a temporary workaround you can add a type definition to your project, which I did successfully in @leonidaX 's project:

declare module "@storybook/addon-actions" {
  export function action(name: string, ...params: any[]): any;
}

@MoctezumaDev
Copy link

Yes I did something like that directly in the module but I suppose I can put it in a global.d.ts while the proper fix gets it to a released version.

Im ok with closing this ticket and moving the conversation to #1166

Thanks for all the help :)

@shilman
Copy link
Member

shilman commented Jun 1, 2017

Thanks @leonidaX ! Would have no idea what's going on without your sample repo. Super helpful!! 🏅🏆 👏

@shilman shilman closed this as completed Jun 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants