Skip to content

Commit

Permalink
Function properties in type space are really properties
Browse files Browse the repository at this point in the history
Resolves #1637.
  • Loading branch information
Gerrit0 committed Jul 1, 2022
1 parent 98903d3 commit 3622a81
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@

### Bug Fixes

- Function properties in type space will no longer be interpreted as methods, #1637.
- TypeDoc will no longer crash if a comment contains an empty `@example` tag, #1967.
- TypeDoc will now detect attempted inheritance from accessors and inherit from the getter or setter, #1968.
- `intentionallyNotExported` will now properly respect qualified names, #1972.
Expand Down
14 changes: 13 additions & 1 deletion src/lib/converter/plugins/ImplementsPlugin.ts
Expand Up @@ -6,7 +6,7 @@ import {
ReflectionKind,
SignatureReflection,
} from "../../models/reflections/index";
import { ReferenceType, Type } from "../../models/types";
import { ReferenceType, ReflectionType, Type } from "../../models/types";
import { filterMap, zip } from "../../utils/array";
import { Component, ConverterComponent } from "../components";
import type { Context } from "../context";
Expand Down Expand Up @@ -468,6 +468,18 @@ function handleInheritedComments(
for (const [cs, ps] of zip(child.signatures, parent.signatures)) {
copyComment(cs, ps);
}
} else if (
parent.kindOf(ReflectionKind.Property) &&
parent.type instanceof ReflectionType &&
parent.type.declaration.signatures &&
child.signatures
) {
for (const [cs, ps] of zip(
child.signatures,
parent.type.declaration.signatures
)) {
copyComment(cs, ps);
}
}
}

Expand Down
16 changes: 1 addition & 15 deletions src/lib/converter/symbols.ts
Expand Up @@ -614,20 +614,6 @@ function convertProperty(
exportSymbol
);
}

// Special case: "arrow properties" in type space should be treated as methods.
if (
ts.isPropertySignature(declaration) &&
declaration.type &&
ts.isFunctionTypeNode(declaration.type)
) {
return convertArrowAsMethod(
context,
symbol,
declaration.type,
exportSymbol
);
}
}

const reflection = context.createDeclarationReflection(
Expand Down Expand Up @@ -671,7 +657,7 @@ function convertProperty(
function convertArrowAsMethod(
context: Context,
symbol: ts.Symbol,
arrow: ts.ArrowFunction | ts.FunctionTypeNode,
arrow: ts.ArrowFunction,
exportSymbol?: ts.Symbol
) {
const reflection = context.createDeclarationReflection(
Expand Down
10 changes: 8 additions & 2 deletions src/test/issueTests.ts
Expand Up @@ -276,8 +276,14 @@ export const issueTests: {
},

gh1624(project) {
ok(
query(project, "Foo.baz").signatures?.[0]?.hasComment(),
// #1637
equal(query(project, "Bar.baz").kind, ReflectionKind.Property);

equal(
Comment.combineDisplayParts(
query(project, "Foo.baz").signatures?.[0]?.comment?.summary
),
"Some property style doc.",
"Property methods declared in interface should still allow comment inheritance"
);
},
Expand Down

0 comments on commit 3622a81

Please sign in to comment.