Skip to content

Commit e5cd9d1

Browse files
committed
Fix rendering of optional methods
Resolves #2995
1 parent ef3a42e commit e5cd9d1

File tree

6 files changed

+437
-0
lines changed

6 files changed

+437
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ title: Changelog
77
### Bug Fixes
88

99
- Fixed link resolution not working correctly in first comment on the file in some cases, #2994.
10+
- Optional methods are now rendered with a trailing `?` in the reflection preview and signature, #2995.
1011
- The `compilerOptions` option now functions properly with non-boolean options, #3000.
1112
- Configuration errors within the `compilerOptions` option are now handled gracefully, #3000.
1213

src/lib/output/formatter.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ export class FormattedCodeBuilder {
961961
const id = this.newId();
962962
return group(id, [
963963
name,
964+
sig.parent.flags.isOptional ? simpleElement(<span class="tsd-signature-symbol">?</span>) : emptyNode,
964965
this.typeParameters(sig),
965966
...this.parameters(sig, id),
966967
nodes(
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface gh2995 {
2+
optionalMethod?(filter: string, args: string[]): any;
3+
}

src/test/converter2/renderer/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,5 @@ export interface DisabledGroups {
136136

137137
export * as ExpandType from "./expandType";
138138
export * as GH2982 from "./gh2982";
139+
export { gh2995 } from "./gh2995";
139140
export { box as boxAlias };

0 commit comments

Comments
 (0)