Skip to content

Commit 1efeefe

Browse files
fix defaults
1 parent 516456a commit 1efeefe

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/index.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import ts from "typescript";
44
import * as docGen from "react-docgen-typescript";
55
import generateDocgenCodeBlock from "react-docgen-typescript-loader/dist/generateDocgenCodeBlock";
66

7-
interface LoaderOptions {
7+
interface TypescriptOptions {
88
/**
99
* Specify the location of the tsconfig.json to use. Can not be used with
1010
* compilerOptions.
1111
**/
1212
tsconfigPath?: string;
1313
/** Specify TypeScript compiler options. Can not be used with tsconfigPath. */
1414
compilerOptions?: ts.CompilerOptions;
15+
}
16+
17+
interface LoaderOptions {
1518
/**
1619
* Specify the docgen collection name to use. All docgen information will
1720
* be collected into this global object. Set to null to disable.
@@ -46,7 +49,9 @@ interface LoaderOptions {
4649
typePropName?: string;
4750
}
4851

49-
export type PluginOptions = docGen.ParserOptions & LoaderOptions;
52+
export type PluginOptions = docGen.ParserOptions &
53+
LoaderOptions &
54+
TypescriptOptions;
5055

5156
interface Module {
5257
userRequest: string;
@@ -60,7 +65,7 @@ function processModule(
6065
parser: docGen.FileParser,
6166
webpackModule: Module,
6267
tsProgram: ts.Program,
63-
loaderOptions: PluginOptions
68+
loaderOptions: Required<LoaderOptions>
6469
) {
6570
if (!webpackModule) {
6671
return;
@@ -79,9 +84,6 @@ function processModule(
7984
filename: webpackModule.userRequest,
8085
source: webpackModule.userRequest,
8186
componentDocs,
82-
typePropName: "type",
83-
docgenCollectionName: "STORYBOOK_REACT_CLASSES",
84-
setDisplayName: true,
8587
...loaderOptions,
8688
}).substring(webpackModule.userRequest.length);
8789

@@ -119,9 +121,9 @@ export default class DocgenPlugin {
119121
const pathRegex = RegExp(`\\${path.sep}src.+\\.tsx`);
120122
const {
121123
tsconfigPath,
122-
docgenCollectionName,
123-
setDisplayName,
124-
typePropName,
124+
docgenCollectionName = "STORYBOOK_REACT_CLASSES",
125+
setDisplayName = true,
126+
typePropName = "type",
125127
compilerOptions: userCompilerOptions,
126128
...docgenOptions
127129
} = this.options;

0 commit comments

Comments
 (0)