Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Fix TypeScript Types and argTypes generation #3

Merged
merged 9 commits into from
Dec 21, 2021

Conversation

dwightjack
Copy link
Contributor

This PR fixes two issues I've encountered trying v0.0.1 with a TypeScript project (and specs written in TS)

Type checking issue

In the spec file I received the following type checking errors:

const { Primary, Secondary } = composeStories(stories);

// ...

mount(Primary());
// ^-- Argument of type 'StoryFnVueReturnType' is not assignable to parameter of type 'VueComponent'.
//  Type 'string' is not assignable to type 'VueComponent'.
//  Expected 2 arguments, but got 0.

I am not completely if this is related to a change in the latest Storybook types. Anyway, I reworked the library types to fix the error.

ArgTypes generation.

Looking at the source code I guess that argTypes are collected only from globalConfig, but in storybook story files they can also be defined in Meta and in each individual story.

I changed the argTypes generation by merging them from args, the story,Meta, and globalConfig.

I also noticed that when running the examples on cypress ct, the console logged the following warnings:

image

image

So it seems that the onClick handler is not defined in the args and as a prop in argTypes.

I've updated the library to generate an empty function prop when a prop name either matches the argTypesRegex setting or an argType with an action property. If the prop is already a function (ie: has been set to a spy in the spec), it won't be changed.

"@vue/cli-service": "~4.5.0",
"@storybook/testing-vue": "../",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to import directly from the dist folder because this was causing yarn to re-install over and over the dev dependencies in a loop. Not sure why 🤔 .

@dwightjack
Copy link
Contributor Author

@elevatebart @yannbf any update on this PR? I know you have lots of projects to maintain, so, if you think it might be helpful, I am available to help to maintain this library 😃.

@yannbf
Copy link
Member

yannbf commented Sep 28, 2021

@elevatebart @yannbf any update on this PR? I know you have lots of projects to maintain, so, if you think it might be helpful, I am available to help to maintain this library 😃.

Hey @dwightjack thanks a lot for your contribution! Indeed, there are quite a few other projects hehe and would be super awesome to have a new helping hand! I'll try to check and test your contribution as soon as I can and will let you know!

@elevatebart if you could give a quick check that would be lovely!

package.json Outdated
"@storybook/addons": "^6.2.9",
"@storybook/client-api": "^6.2.9",
"@storybook/vue": "^6.2.9"
"@storybook/addons": "^6.3.7",
Copy link
Member

Choose a reason for hiding this comment

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

These should actually be moved to peerDeps, and support a bigger range like it's done in the react counterpart:

https://github.com/storybookjs/testing-react/blob/main/package.json#L77

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yannbf sorry for the late reply. I fixed the dependencies in c12a9ea.

I also rebased the branch over the latest upstream commit.

@dwightjack
Copy link
Contributor Author

Hi, just checking in. Any update on this PR? Is there something blocking it that I missed?

@yannbf
Copy link
Member

yannbf commented Dec 7, 2021

Hey @dwightjack thank you so much for your patience! Things have been quite busy but I'll try my best to get this down and have a release soon!

@yannbf yannbf added patch Increment the patch version when merged release labels Dec 21, 2021
@yannbf
Copy link
Member

yannbf commented Dec 21, 2021

Hey @dwightjack thanks once again for your patience! I tried making some small changes but I don't have the privileges. I'll merge and make a couple fixes in the following version!

@yannbf yannbf merged commit 37dbf3a into storybookjs:main Dec 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
patch Increment the patch version when merged release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants