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

Incorrect typescript typings with addon-jest's withTests #8058

Closed
rakeshpai opened this issue Sep 12, 2019 · 9 comments
Closed

Incorrect typescript typings with addon-jest's withTests #8058

rakeshpai opened this issue Sep 12, 2019 · 9 comments

Comments

@rakeshpai
Copy link

addDecorator(withTests({ results })); leads to a TypeScript error.

Argument of type '(args_0: string | (() => void), args_1: { kind: string; parameters: AddonParameters; }) => void | ((storyFn: () => void, { kind }: { kind: string; }) => void)' is not assignable to parameter of type 'StoryDecorator'.
  Types of parameters 'args_1' and 'context' are incompatible.
    Property 'parameters' is missing in type '{ kind: string; story: string; }' but required in type '{ kind: string; parameters: AddonParameters; }'.ts(2345)

It looks like the return type of withTests is not compatible with the accepted argument type of addDecorator.

To Reproduce
In a TypeScript project:

...
import { withTests } from '@storybook/addon-jest';
import results from '../jest-test-results.json';

...
addDecorator(withTests({ results }));

Dependencies
@storybook/react: 5.1.11
@storybook/addon-jest: ^5.1.11

@shilman
Copy link
Member

shilman commented Sep 12, 2019

@rakeshpai Is this fixed in 5.2? addon-jest got a nice overhaul from @CodeByAlex and I'm betting he fixed it 😆

@CodeByAlex
Copy link
Member

@rakeshpai I’ll check on this and fix it if it doesn’t work

@CodeByAlex CodeByAlex self-assigned this Sep 12, 2019
@rakeshpai
Copy link
Author

Just tried this with "@storybook/addon-jest": "^5.2.0-rc.11", and I get a very similar error (same code as before).

Argument of type 'DecoratorFunction<unknown>' is not assignable to parameter of type 'StoryDecorator'.
  Types of parameters 'c' and 'context' are incompatible.
    Type '{ kind: string; story: string; }' is missing the following properties from type 'StoryContext': id, name, parametersts ts(2345)

Thanks for looking into this!

@stale
Copy link

stale bot commented Oct 14, 2019

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Oct 14, 2019
@Tarni-Baghel
Copy link

@CodeByAlex We got the same error in "@storybook/addon-jest": "^5.2.3"
Please let us know once you deploy the latest version.

@stale stale bot removed the inactive label Oct 14, 2019
@shilman
Copy link
Member

shilman commented Oct 14, 2019

Egads!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.0-alpha.19 containing PR #8410 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Oct 14, 2019
@shilman shilman added the bug label Oct 14, 2019
@sharmavikram
Copy link

sharmavikram commented Oct 15, 2019

Hello @shilman, addon-Info not working in @storybook/addon-info 5.2.3. and i am using react with typescript and following https://github.com/storybookjs/storybook/tree/master/addons/info url for implementing addon. but it is showing an error.

Property 'story' is missing in type 'StoryContext' but required in type '{ kind: string; story: string; }'

@Tarni-Baghel
Copy link

Egads!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.0-alpha.19 containing PR #8410 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

Thanks @shilman @CodeByAlex
It is working now.

@shilman
Copy link
Member

shilman commented Oct 22, 2019

Jeepers creepers!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.2.5 containing PR #8410 that references this issue. Upgrade today to try it out!

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

5 participants