Skip to content

Commit e07f22b

Browse files
committed
fix: respect falsy custom options
1 parent 31ce4e8 commit e07f22b

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/plugin.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ function processModule(
135135

136136
/** Inject typescript docgen information into modules at the end of a build */
137137
export default class DocgenPlugin implements webpack.WebpackPluginInstance {
138+
public static defaultOptions = {
139+
setDisplayName: true,
140+
typePropName: "type",
141+
docgenCollectionName: "STORYBOOK_REACT_CLASSES",
142+
};
143+
138144
private name = "React Docgen Typescript Plugin";
139145
private options: PluginOptions;
140146

@@ -266,6 +272,7 @@ export default class DocgenPlugin implements webpack.WebpackPluginInstance {
266272
typePropName,
267273
...docgenOptions
268274
} = this.options;
275+
const { defaultOptions } = DocgenPlugin;
269276

270277
let compilerOptions = {
271278
jsx: ts.JsxEmit.React,
@@ -286,9 +293,12 @@ export default class DocgenPlugin implements webpack.WebpackPluginInstance {
286293
return {
287294
docgenOptions,
288295
generateOptions: {
289-
docgenCollectionName: docgenCollectionName || "STORYBOOK_REACT_CLASSES",
290-
setDisplayName: setDisplayName || true,
291-
typePropName: typePropName || "type",
296+
docgenCollectionName:
297+
docgenCollectionName === undefined
298+
? defaultOptions.docgenCollectionName
299+
: docgenCollectionName,
300+
setDisplayName: setDisplayName ?? defaultOptions.setDisplayName,
301+
typePropName: typePropName ?? defaultOptions.typePropName,
292302
},
293303
compilerOptions,
294304
};

0 commit comments

Comments
 (0)