_addIssue
blocks every
, some
& check
actions rewrite due to a possible type issue
#540
Labels
bug
Something isn't working
I was trying to rewrite the
every
action and I ran into this issue.Issue
FunctionReference<unknown[], TContext>
reduces to(...args: unknown[]) => TContext
. This creates a problem. Since function parameter types are contravariant (reference: microsoft/TypeScript#18654), the only valid function types that can be assigned are the functions that haveunknown
orany
parameter types (reference: microsoft/TypeScript#24439). This is the type error I get while rewriting the action:Why did I or any other contributor did not run into this issue earlier while writing actions that were merged to
rewrite-with-pipe
?This is because any action's reference passed to
_addIssue
is reduced to(requirement: unknown, message?: unknown) => <ReturnTypeOfTheActionHere>
if the action has two or more overloads with generic parameters. Try commenting the first overload of any action maybebytes
and notice_addIssue
creates a type error.The requirements of
every
,some
andcheck
are functions so they can't be reduced tounknown
.My suggestion
Change
FunctionReference<unknown[], TContext>
toFunctionReference<any[], TContext>
and update all of the relevant affected places. Reading the implementation, I noticed it doesn't really care about the types of the parameters of the function reference passed to_addIssue
, so it is safe to useany
?Your suggestion/guidance?
Do you have a better suggestion? Also, I apologize if this was a false alarm. I am trying to limit the help needed so that the rewrite is as smooth as possible but I will need some guidance for this issue.
Incomplete
every
implementation so that you can reproduce the issue:The text was updated successfully, but these errors were encountered: