diff --git a/packages/typedoc-signature/lib/internal/concise.ts b/packages/typedoc-signature/lib/internal/concise.ts index 849961518..04aa2bfc4 100644 --- a/packages/typedoc-signature/lib/internal/concise.ts +++ b/packages/typedoc-signature/lib/internal/concise.ts @@ -100,7 +100,7 @@ export function enumReflection(ctx: Context, r: J.Reflection): Signature { return s } -export function functionsDeclaration(f: J.Reflection): Signature { +export function functionsDeclaration(ctx: Context, f: J.Reflection): Signature { const s: Signature = [] if (!isCallSignatureReflection(f)) { @@ -109,16 +109,20 @@ export function functionsDeclaration(f: J.Reflection): Signature { let t: Token - t = new TextToken() - t.text = " " - s.push(t) - const b = parameters(f) s.push(...b) - t = new TextToken() - t.text = ": " - s.push(t) + if (f.type) { + if ("name" in f.type && f.type.name === "void") { + return s + } + t = new TextToken() + t.text = ": " + s.push(t) + + const b = type(ctx, f.type) + s.push(...b) + } return s } @@ -139,20 +143,34 @@ export function interfaceReflection(ctx: Context, r: J.Reflection): Signature { return s } -export function methodDeclaration(m: J.Reflection): Signature { +export function methodDeclaration(ctx: Context, m: J.Reflection): Signature { const s: Signature = [] if (!isSignatureReflection(m)) { return s } + let t: Token + const b = parameters(m) s.push(...b) - const t = new TextToken() + t = new TextToken() t.text = ": " s.push(t) + if (m.type) { + if ("name" in m.type && m.type.name === "void") { + return s + } + t = new TextToken() + t.text = ": " + s.push(t) + + const b = type(ctx, m.type) + s.push(...b) + } + return s } @@ -285,7 +303,7 @@ export function arrayType(ctx: Context, a: J.ArrayType): Signature { const s: Signature = [] let t: Token - if (isUnionType(a.elementType.type)) { + if (isUnionType(a.elementType)) { t = new TextToken() t.text = "(" s.push(t) @@ -294,7 +312,7 @@ export function arrayType(ctx: Context, a: J.ArrayType): Signature { const b = type(ctx, a.elementType) s.push(...b) - if (isUnionType(a.elementType.type)) { + if (isUnionType(a.elementType)) { const t = new TextToken() t.text = ")" s.push(t) diff --git a/packages/typedoc-signature/lib/internal/verbose.ts b/packages/typedoc-signature/lib/internal/verbose.ts index 84147cea3..9183537ae 100644 --- a/packages/typedoc-signature/lib/internal/verbose.ts +++ b/packages/typedoc-signature/lib/internal/verbose.ts @@ -133,7 +133,7 @@ export function classDeclaration(ctx: Context, r: J.Reflection): Signature { if (isMethodReflection(c) && c.signatures) { for (const cs of c.signatures) { if (isSignatureReflection(cs)) { - const md = methodDeclaration(cs, c, ctx) + const md = methodDeclaration(ctx, cs, c) const ts: Signature = [] for (const e of md) { if (e instanceof EntityToken) { @@ -394,9 +394,9 @@ export function interfaceReflection(ctx: Context, r: J.Reflection): Signature { } export function methodDeclaration( + ctx: Context, r: J.Reflection, p: J.Reflection, - ctx: Context, ): Signature { let s: Signature = [] @@ -717,7 +717,7 @@ export function arrayType(ctx: Context, a: J.ArrayType): Signature { let s: Signature = [] let t: Token - if (isUnionType(a.elementType.type)) { + if (isUnionType(a.elementType)) { t = new TextToken() t.text = "(" s.push(t) @@ -726,7 +726,7 @@ export function arrayType(ctx: Context, a: J.ArrayType): Signature { const b = type(ctx, a.elementType) s.push(...b) - if (isUnionType(a.elementType.type)) { + if (isUnionType(a.elementType)) { t = ctx.s.nt() s.push(t) diff --git a/packages/typedoc-signature/lib/main.ts b/packages/typedoc-signature/lib/main.ts index fc588eb36..b15106a5c 100644 --- a/packages/typedoc-signature/lib/main.ts +++ b/packages/typedoc-signature/lib/main.ts @@ -79,14 +79,14 @@ export function compute(ct: Transport): void { c.push(...C.enumReflection(cf, t)) } else if (isFunctionReflection(p) && isCallSignatureReflection(t)) { v.push(...V.functionsDeclaration(cf, t)) - c.push(...C.functionsDeclaration(t)) + c.push(...C.functionsDeclaration(cf, t)) r.push(...C.returns(cf, t.type)) } else if (isInterfaceReflection(t)) { v.push(...V.interfaceReflection(cf, t)) c.push(...C.interfaceReflection(cf, t)) } else if (isMethodReflection(p) && isCallSignatureReflection(t)) { - v.push(...V.methodDeclaration(t, p, cf)) - c.push(...C.methodDeclaration(t)) + v.push(...V.methodDeclaration(cf, t, p)) + c.push(...C.methodDeclaration(cf, t)) r.push(...C.returns(cf, t.type)) } else if (isPropertyReflection(t)) { v.push(...V.propertyReflection(cf, t))