Skip to content

Commit 7a0916c

Browse files
phateddanez
authored andcommitted
Add importer to options for backwards-compat work
1 parent 0946e6d commit 7a0916c

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

bin/react-docgen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ if (argv.resolver) {
103103
}
104104

105105
function parse(source, filename) {
106-
return parser.parse(source, resolver, null, null, {
106+
return parser.parse(source, resolver, null, {
107107
filename,
108108
});
109109
}

src/__tests__/main-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ describe('main', () => {
226226
it(`processes component "${fileNames[i]}" without errors`, () => {
227227
let result;
228228
expect(() => {
229-
result = parse(fileContent, null, null, null, {
229+
result = parse(fileContent, null, null, {
230230
filename: filePath,
231231
babelrc: false,
232232
});

src/main.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,17 @@ function defaultParse(
4848
src: string | Buffer,
4949
resolver?: ?Resolver,
5050
handlers?: ?Array<Handler>,
51-
importer?: ?Importer,
52-
options?: Options = {},
51+
// Used for backwards compatibility of this method
52+
options?: Options & { importer?: Importer } = {},
5353
): Array<DocumentationObject> | DocumentationObject {
5454
if (!resolver) {
5555
resolver = defaultResolver;
5656
}
5757
if (!handlers) {
5858
handlers = defaultHandlers;
5959
}
60-
if (!importer) {
61-
importer = defaultImporter;
62-
}
60+
61+
const { importer = defaultImporter } = options;
6362

6463
return parse(String(src), resolver, handlers, importer, options);
6564
}

0 commit comments

Comments
 (0)