question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect typescript typings with addon-jest's `withTests`

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Tarni-Baghelcommented, Oct 16, 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.

Thanks @shilman @CodeByAlex It is working now.

1reaction
Tarni-Baghelcommented, Oct 14, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript using the incorrect type with jest when there are ...
When I go to mock a named import with the js-cookie package, it mocks a particular instance of the property, but incorrectly chooses...
Read more >
Documentation - Do's and Don'ts - TypeScript
Don't ever use the types Number , String , Boolean , Symbol , or Object These types ... WRONG */. function reverse(s: String):...
Read more >
TypeScript - Dynamoose
FAQ​. What does beta mean in terms of TypeScript support?​. TypeScript Beta Support means that typings might be wrong or missing. This can...
Read more >
Typescript imports are incorrectly imported from `@types/`
What steps will reproduce the problem? Use jsx in a tsx file. Get the prompt to import react. Import react; WS inserts import...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found