Do I have to declare every used component one by one in moduleMetadata.declarations in the Story (Angular Storybook)?

Viewed 121

I am trying to write a story for a high level angular component which have many possible child components depending on the input data.

I end up having to list all the components in the story as follows:

export default {
    title: 'My Application/Data Explorer Component',
    component: DataExplorerComponent,
    decorators: [
        moduleMetadata({
            // here is the annoyoing bit:
            declarations: [
                MyTextComponent,
                MyTableComponent,
                MyGraphComponent,
                ...
            ],
        }),
    ],
} as Meta;

Since all of those child components are already declared in the app.module.ts, can I avoid having to list all of them again in the my-component.stories.ts like shown above?

The component list gets long pretty quickly as many of those components have their own sub-components, and if I forget to maintain this list, the story renders wrong but without any errors, and it can be annoying to find which components are missing in the declarations.

0 Answers
Related