fix(typedoc-plugin-appium): allow commands as properties referencing 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.
This commit is contained in:
Christopher Hiller
2023-01-09 14:10:51 -08:00
parent 0ca54b7994
commit 9d5a737daa

View File

@@ -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')
);
}