Skip to content

Commit 67100a8

Browse files
committed
fix(core): correctly flag optional nested parameters
1 parent 65225e4 commit 67100a8

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

.changeset/honest-houses-wait.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'typedoc-plugin-markdown': patch
3+
---
4+
5+
- Correctly flag optional nested parameters (#765).

packages/typedoc-plugin-markdown/src/theme/context/partials/member.parametersList.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,12 @@ function getReflectionType(
133133
if (parameter.comment) {
134134
block.push(context.partials.comment(parameter.comment));
135135
}
136-
flatten?.forEach((flat) => {
137-
typeMd.push('\n' + heading(options.headingLevel + 2, flat.name));
136+
flatten?.forEach((flat: ParameterReflection) => {
137+
const name = [flat.name];
138+
if (flat.flags.isOptional) {
139+
name.push('?');
140+
}
141+
typeMd.push('\n' + heading(options.headingLevel + 2, name.join('')));
138142
typeMd.push(getOtherType(context, flat));
139143
});
140144
block.push(typeMd.join('\n\n'));

packages/typedoc-plugin-markdown/test/specs/__snapshots__/objects-and-params.spec.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ A nested object.
400400
401401
\`number\`
402402
403-
#### parent
403+
#### parent?
404404
405405
\`number\`
406406

packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.function.spec.ts.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -834,11 +834,11 @@ Defined in: [functions.ts:1](http://source-url)
834834
835835
various options
836836
837-
#### bar
837+
#### bar?
838838
839839
\`number\` = \`43\`
840840
841-
#### foo
841+
#### foo?
842842
843843
\`number\` = \`42\`
844844
@@ -921,7 +921,7 @@ A nested object.
921921
922922
\`number\`
923923
924-
#### parent
924+
#### parent?
925925
926926
\`number\`
927927

0 commit comments

Comments
 (0)