Reputation: 122450
I'm looking at enabling the lint rule @typescript-eslint/no-invalid-void-type
. I want to make sure everything it's flagging is truly something I always want to get rid of. Just to check my understanding. Are the following statements correct?
void
in a type union, like string | void
.void
as a param. (Except for something like this: void
).void
in a container generic, like Array<void | string>
.void | undefined
on a function return signature (e.g. () => void | undefined
) is redundant.() => SomeType | void
, you should use () => SomeType | undefined
instead.And the reason for most of those statements being true is that you can't instantiate a value of type void, so something like Array<string | void> makes no sense. Right?
Upvotes: 2
Views: 1697
Reputation: 331
I add to disable this rule on the following code fragment which looks correct to me:
register<T>(
requestFunction: (reqId: number) => void,
cancelFunction: (reqId: number) => void | null | undefined, // eslint-disable-line @typescript-eslint/no-invalid-void-type
...
Upvotes: 0