Add support for displaying default param values

This commit is contained in:
Fabio Berger
2018-04-11 17:39:30 +09:00
parent 34446cf569
commit bce97c2543
3 changed files with 4 additions and 0 deletions

View File

@@ -91,6 +91,7 @@ function renderParameters(
) {
const params = _.map(parameters, (p: Parameter) => {
const isOptional = p.isOptional;
const hasDefaultValue = !_.isUndefined(p.defaultValue);
const type = (
<Type
type={p.type}
@@ -103,6 +104,7 @@ function renderParameters(
<span key={`param-${p.type}-${p.name}`}>
{p.name}
{isOptional && '?'}: {type}
{hasDefaultValue && ` = ${p.defaultValue}`}
</span>
);
});

View File

@@ -140,6 +140,7 @@ export interface Parameter {
comment: string;
isOptional: boolean;
type: Type;
defaultValue?: string;
}
export interface TypeParameter {

View File

@@ -395,6 +395,7 @@ export const typeDocUtils = {
name: entity.name,
comment,
isOptional,
defaultValue: entity.defaultValue,
type,
};
return parameter;