When you have strictNullChecks enabled in tsconfig, you are explicitly required to pass undefined as a value to a function when it is not optional and a generic or the parameter type for that argument is a union with undefined, for example:
function test<T extends object | undefined>(arg: T): void {
}
test({}); // fine
test(undefined); // fine, but eslint complains on rule unicorn/no-useless-undefined
test(); // not fine, compiler throws TS2554: Expected 1 arguments, but got 0
I ran into this issue with the unicorn/no-useless-undefined rule and worked around it by setting checkArguments: false but it seems like an incorrect implementation to me.
When you have
strictNullChecksenabled in tsconfig, you are explicitly required to passundefinedas a value to a function when it is not optional and a generic or the parameter type for that argument is a union withundefined, for example:I ran into this issue with the
unicorn/no-useless-undefinedrule and worked around it by settingcheckArguments: falsebut it seems like an incorrect implementation to me.