Skip to content

Commit

Permalink
Merge pull request #23893 from stilt0n/fix-invariant-bug
Browse files Browse the repository at this point in the history
Core: Fix error thrown if `docs.defaultName` is unset
  • Loading branch information
JReinhold authored Aug 21, 2023
2 parents e2c0069 + 8cd2f0b commit 03b85f4
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions code/lib/core-server/src/utils/StoryIndexGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ export class StoryIndexGenerator {
autodocs === true || (autodocs === 'tag' && hasAutodocsTag) || isStoriesMdx;

if (createDocEntry) {
const name = this.options.docs.defaultName;
invariant(name, 'expected a defaultName property in options.docs');
const name = this.options.docs.defaultName ?? 'Docs';
const { metaId } = indexInputs[0];
const { title } = entries[0];
const tags = indexInputs[0].tags || [];
Expand Down Expand Up @@ -407,8 +406,7 @@ export class StoryIndexGenerator {
// a) it is a stories.mdx transpiled to CSF, OR
// b) we have docs page enabled for this file
if (componentTags.includes(STORIES_MDX_TAG) || autodocsOptedIn) {
const name = this.options.docs.defaultName;
invariant(name, 'expected a defaultName property in options.docs');
const name = this.options.docs.defaultName ?? 'Docs';
invariant(csf.meta.title, 'expected a title property in csf.meta');
const id = toId(csf.meta.id || csf.meta.title, name);
entries.unshift({
Expand Down Expand Up @@ -511,8 +509,7 @@ export class StoryIndexGenerator {
title,
"makeTitle created an undefined title. This happens when a specifier's doesn't have any matches in its fileName"
);
const { defaultName } = this.options.docs;
invariant(defaultName, 'expected a defaultName property in options.docs');
const defaultName = this.options.docs.defaultName ?? 'Docs';

const name =
result.name ||
Expand Down

0 comments on commit 03b85f4

Please sign in to comment.