Skip to content

Commit

Permalink
refactor(askui-nodejs): replace typecasts with signature overloading …
Browse files Browse the repository at this point in the history
…(#APD-483)
  • Loading branch information
adi-wan-askui committed Jun 19, 2024
1 parent 74d4597 commit 3c117dd
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/askui-nodejs/src/execution/ui-control-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Exec,
Executable,
FluentFilters,
FluentFiltersGetter,
ApiCommands,
Separators,
PC_AND_MODIFIER_KEY,
Expand Down Expand Up @@ -621,11 +620,19 @@ export class UiControlClient extends ApiCommands {
await command.exec();
}

private evaluateMatchingProperty(
command: FluentFiltersOrRelations,
text: ExpectExistenceInputParameterText,
): FluentFiltersOrRelations;
private evaluateMatchingProperty(
command: FluentFiltersOrRelationsGetter,
text: ExpectExistenceInputParameterText,
): FluentFiltersOrRelationsGetter;
// eslint-disable-next-line class-methods-use-this
private evaluateMatchingProperty(
command: FluentFiltersGetter | FluentFiltersOrRelationsGetter | FluentFiltersOrRelations,
command: FluentFiltersOrRelations | FluentFiltersOrRelationsGetter,
text: ExpectExistenceInputParameterText,
): FluentFiltersOrRelationsGetter | FluentFiltersOrRelations {
): FluentFiltersOrRelations | FluentFiltersOrRelationsGetter {
switch (text.matching ?? 'similar') {
case 'exact':
return command.withExactText(text.value);
Expand Down Expand Up @@ -702,7 +709,7 @@ export class UiControlClient extends ApiCommands {
const acc = await accumulatorPromise;
const command = this.get()[param.type]();
let finalCommand = param.text !== undefined
? this.evaluateMatchingProperty(command, param.text) as FluentFiltersOrRelationsGetter
? this.evaluateMatchingProperty(command, param.text)
: command;
if (param.relation) {
finalCommand = this.evaluateRelation(
Expand Down

0 comments on commit 3c117dd

Please sign in to comment.