Skip to content

Commit

Permalink
fix(typedoc-plugin-appium): allow commands as properties referencing …
Browse files Browse the repository at this point in the history
…async methods

Instead of only inspecting `ReflectionKind.Method`, we now examine `ReflectionKind.Property`, which can be of type `ReflectionType` pointing to an async function.  Example:

```js
async function baz() {}

class Foo {
  async bar() {} // ReflectionKind.Method
  baz = baz; // ReflectionKind.Property referencing a function
}
```

Also ensures `static` methods aren't picked up; this could happen if a static method shares the same name with a known command method as defined in the builtin routes.
  • Loading branch information
boneskull committed Jan 9, 2023
1 parent daee4b2 commit 1bdab7b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/typedoc-plugin-appium/lib/guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,18 @@ export function isExternalDriverDeclarationReflection(
export function isAsyncMethodDeclarationReflection(
value: any
): value is AsyncMethodDeclarationReflection {
if (
!isDeclarationReflection(value) ||
!value.kindOf(ReflectionKind.Method | ReflectionKind.Property) ||
value.flags.isStatic
) {
return false;
}
const signatures =
(value.type instanceof ReflectionType ? value.type.declaration.signatures : value.signatures) ??
[];
return Boolean(
isDeclarationReflection(value) &&
value.kindOf(ReflectionKind.Method) &&
value.signatures?.find(
(sig) => sig.type instanceof ReferenceType && sig.type.name === 'Promise'
)
signatures.find((sig) => sig.type instanceof ReferenceType && sig.type.name === 'Promise')
);
}

Expand Down

0 comments on commit 1bdab7b

Please sign in to comment.