Add support for displaying default param values
This commit is contained in:
@@ -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>
|
||||
);
|
||||
});
|
||||
|
@@ -140,6 +140,7 @@ export interface Parameter {
|
||||
comment: string;
|
||||
isOptional: boolean;
|
||||
type: Type;
|
||||
defaultValue?: string;
|
||||
}
|
||||
|
||||
export interface TypeParameter {
|
||||
|
@@ -395,6 +395,7 @@ export const typeDocUtils = {
|
||||
name: entity.name,
|
||||
comment,
|
||||
isOptional,
|
||||
defaultValue: entity.defaultValue,
|
||||
type,
|
||||
};
|
||||
return parameter;
|
||||
|
Reference in New Issue
Block a user