Why is void | MyType an acceptable return type under no-invalid-void-type?

2 days ago 3
ARTICLE AD BOX

I have configured the no-invalid-void-type linting rule as follows:

{ "@typescript-eslint/no-invalid-void-type": [ "error", { "allowInGenericTypeArguments": true } ] }

With this rule enabled, this type definition is acceptable:

interface IType<T> { data: T; } type VoidFunc2 = () => void | IType<void>;

The linter now allows void as a generic type argument - fine. However, void | IType<void> is still a union, IType could even include arbitrary data, and as such I do not see a fundamental difference between this and, say, void | undefined, which is still disallowed as a return type.

Question

What is the design philosophy and / or technical reason why the linter accepts the union void | SomeType whilst any other union with void is disallowed?

Read Entire Article