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.
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.
@Keats @leonidax created an umbrella issue here: https://github.com/storybooks/storybook/issues/1166
Would love your feedback on the issue. And, if you're up for it, help to make this happen!
(not sure if we are considering lack of TS support a bug or not at this point)
@tmeasday seems like enough people are using it that it's close enough 馃槃
@shilman Sure, I would be happy to help... do you have a IRC channel or how can I join your slack channel?
@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
@leonidax slack is here. we are excited and grateful for your help! 馃帀
I created an example project with storybook typescript and less
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]@storybook/react but are not declared in in the @storybook/addon-actions package. they should be.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?
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;
}
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 :)
Thanks @leonidax ! Would have no idea what's going on without your sample repo. Super helpful!! 馃弲馃弳 馃憦
Most helpful comment
PS - as a temporary workaround you can add a type definition to your project, which I did successfully in @leonidax 's project: