Skip to content

Commit

Permalink
fix: doc tools types
Browse files Browse the repository at this point in the history
  • Loading branch information
efrenaragon96 committed Jul 3, 2023
1 parent 96afbdc commit d5e4b0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 10 additions & 8 deletions code/lib/docs-tools/src/argTypes/docgen/createPropDef.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { JsDocTags, PropDefaultValue } from './PropDef';
import type { JsDocParam, JsDocTags, PropDefaultValue } from './PropDef';
import type { PropDef, DocgenInfo, DocgenType, DocgenPropDefaultValue } from './types';
import { TypeSystem } from './types';
import type { JsDocParsingResult } from '../jsdocParser';
Expand Down Expand Up @@ -90,13 +90,15 @@ function applyJsDocResult(propDef: PropDef, jsDocParsingResult?: JsDocParsingRes
propDef.description = jsDocParsingResult.description;
}

const value: JsDocTags = {
returns: extractedTags?.returns,
params: extractedTags?.params?.map((x) => ({
name: x.getPrettyName(),
description: x.description,
})),
};
const value = {
...extractedTags,
params: extractedTags?.params?.map(
(x): JsDocParam => ({
name: x.getPrettyName(),
description: x.description,
})
),
} satisfies JsDocTags;

if (Object.values(value).filter(Boolean).length > 0) {
// eslint-disable-next-line no-param-reassign
Expand Down
8 changes: 3 additions & 5 deletions code/lib/docs-tools/src/argTypes/jsdocParser.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import type { Annotation } from 'doctrine';
import doctrine from 'doctrine';
import type { JsDocParam, JsDocReturns } from './docgen';

export interface ExtractedJsDocParam {
name?: string;
export interface ExtractedJsDocParam extends JsDocParam {
type?: any;
description?: string | null;
getPrettyName: () => string | undefined;
getTypeName: () => string | null;
}

export interface ExtractedJsDocReturns {
export interface ExtractedJsDocReturns extends JsDocReturns {
type?: any;
description?: string | null;
getTypeName: () => string | null;
}

Expand Down

0 comments on commit d5e4b0f

Please sign in to comment.