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.

Type information missing for "loaders"

See original GitHub issue

Describe the bug There is no TypeScript type information for any of the loaders feature.

In particular, there is no loaders property on Story/BaseStory.

To Reproduce

export const Default = Template.bind({});
Default.loaders = createLoaders();

TS2339: Property ‘loaders’ does not exist on type 'Story '.

System

  System:
    OS: Windows 10 10.0.18363
    CPU: (8) x64 Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
  Binaries:
    Node: 14.15.3 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.9 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 91.0.4472.106
    Edge: Spartan (44.18362.1593.0)
  npmPackages:
    @storybook/addon-actions: ^6.3.0 => 6.3.0
    @storybook/addon-essentials: ^6.3.0 => 6.3.0
    @storybook/addon-links: ^6.3.0 => 6.3.0
    @storybook/html: ^6.3.0 => 6.3.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
phbernardcommented, Aug 23, 2021

A workaround, based on Storybook example:

type TodoItemStory = {
  loaders?: (() => Promise<any>)[];
} & Story<TodoItemProps>;

export const Primary: TodoItemStory = (args: TodoItemProps, { loaded: { todo } }) => <TodoItem {...args} todo={todo} />;

Primary.loaders = [
  async () => ({
    todo: (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
  }),
];
1reaction
unionalcommented, Nov 3, 2022

Type assertion (as) is fine in this case.

What you can do further is to create a type alias, so it will save you some typing:

type Story = ComponentStory<typeof MyComponent> & { loaders: ... }

so you can use the same Story type in each of your story in the file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing loaders in custom npm package - Stack Overflow
I had this problem recently and resolved it by updating my webpack config to check whether the package in question is symlinked locally....
Read more >
"Mandatory field is missing" in SIS version 2 (more technical ...
When loading student information files there are errors such as: "Mandatory field is missing: email type." This occurs when testing version ...
Read more >
Common error messages in Data Loader - Salesforce Help
Here's a list of common Data Loader errors you'll receive as you use Data ... Note: Some Ids such as record types or...
Read more >
Object Manager Loader errors encountered when ... - IBM
Cause. Error messages that should be in the ERROR_MESSAGES table are missing when processing international strings. These DB2 specific messages ...
Read more >
Error for Worker.dat "The corresponding date effective record ...
Fusion HCM Data Loader: Error for Worker.dat "The corresponding date ... is missing for the {CHILDNAME} (PER-1531696)" (Doc ID 2149175.1).
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