Skip to content

Commit 1dc5659

Browse files
committed
fix: Setters should always have a void return type
Closes #1215
1 parent d9e66b2 commit 1dc5659

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/lib/converter/factories/signature.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as ts from "typescript";
22
import * as assert from "assert";
33
import {
44
DeclarationReflection,
5+
IntrinsicType,
56
ParameterReflection,
67
PredicateType,
78
Reflection,
@@ -67,6 +68,8 @@ export function createSignature(
6768
const predicate = context.checker.getTypePredicateOfSignature(signature);
6869
if (predicate) {
6970
sigRef.type = convertPredicate(predicate, context.withScope(sigRef));
71+
} else if (kind == ReflectionKind.SetSignature) {
72+
sigRef.type = new IntrinsicType("void");
7073
} else {
7174
sigRef.type = context.converter.convertType(
7275
context.withScope(sigRef),

src/test/converter2.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
DeclarationReflection,
88
ProjectReflection,
99
ReflectionKind,
10+
SignatureReflection,
1011
} from "../lib/models";
1112

1213
function query(project: ProjectReflection, name: string) {
@@ -56,6 +57,12 @@ const issueTests: Record<string, (project: ProjectReflection) => void> = {
5657
equal(refl.signatures?.[0]?.comment?.returns, "Test description.\n");
5758
},
5859

60+
gh1215(project) {
61+
const foo = query(project, "Foo.bar");
62+
ok(foo.setSignature instanceof SignatureReflection);
63+
equal(foo.setSignature.type?.toString(), "void");
64+
},
65+
5966
gh1255(project) {
6067
const foo = query(project, "C.foo");
6168
equal(foo.comment?.shortText, "Docs!");
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare class Foo {
2+
set bar(bar: string);
3+
}

0 commit comments

Comments
 (0)