Skip to content

Commit

Permalink
fix: Missing comments on optional methods
Browse files Browse the repository at this point in the history
Resolves #1490
  • Loading branch information
Gerrit0 committed Jan 31, 2021
1 parent fa95b07 commit e4fb866
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/lib/converter/symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ function convertFunctionOrMethod(
symbol,
locationDeclaration
);
const signatures = type.getCallSignatures();
// Need to get the non nullable type because interface methods might be declared
// with a question token. See GH1490.
const signatures = type.getNonNullableType().getCallSignatures();

const reflection = context.createDeclarationReflection(
context.scope.kindOf(
Expand Down
5 changes: 5 additions & 0 deletions src/test/converter/comment/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,8 @@ export class CommentedClass {
export function gh1164(scope: string) {
return scope;
}

export interface GH1490 {
/** With comment */
optionalMethod?(): void;
}
64 changes: 57 additions & 7 deletions src/test/converter/comment/specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,49 @@
}
]
},
{
"id": 29,
"name": "GH1490",
"kind": 256,
"kindString": "Interface",
"flags": {},
"children": [
{
"id": 30,
"name": "optionalMethod",
"kind": 2048,
"kindString": "Method",
"flags": {
"isOptional": true
},
"signatures": [
{
"id": 31,
"name": "optionalMethod",
"kind": 4096,
"kindString": "Call signature",
"flags": {},
"comment": {
"shortText": "With comment"
},
"type": {
"type": "intrinsic",
"name": "void"
}
}
]
}
],
"groups": [
{
"title": "Methods",
"kind": 2048,
"children": [
30
]
}
]
},
{
"id": 2,
"name": "gh1164",
Expand Down Expand Up @@ -191,6 +234,13 @@
5
]
},
{
"title": "Interfaces",
"kind": 256,
"children": [
29
]
},
{
"title": "Functions",
"kind": 64,
Expand All @@ -201,7 +251,7 @@
]
},
{
"id": 29,
"id": 32,
"name": "comment2",
"kind": 1,
"kindString": "Module",
Expand All @@ -211,21 +261,21 @@
},
"children": [
{
"id": 30,
"id": 33,
"name": "multiply",
"kind": 64,
"kindString": "Function",
"flags": {},
"signatures": [
{
"id": 31,
"id": 34,
"name": "multiply",
"kind": 4096,
"kindString": "Call signature",
"flags": {},
"parameters": [
{
"id": 32,
"id": 35,
"name": "a",
"kind": 32768,
"kindString": "Parameter",
Expand All @@ -236,7 +286,7 @@
}
},
{
"id": 33,
"id": 36,
"name": "b",
"kind": 32768,
"kindString": "Parameter",
Expand All @@ -260,7 +310,7 @@
"title": "Functions",
"kind": 64,
"children": [
30
33
]
}
]
Expand All @@ -272,7 +322,7 @@
"kind": 1,
"children": [
1,
29
32
]
}
]
Expand Down

0 comments on commit e4fb866

Please sign in to comment.