eslint-plugin-strict-null-checks
eslint-plugin-strict-null-checks copied to clipboard
Possible issue with typings where the parameters can be `null`.
Seems that the checker is not picking up on a libraries typings where the parameters can indeed be null.
Don't pass nullish arguments to a function that expects a non-nullish type.eslint[strict-null-checks/all](file:///all)


Are non-imported functions working correctly? For example does adding this not generate a warning?:
function foo(value: {value: number} | null) {}
foo(null);
First off, thanks for your work on this plugin @JaroslawPokropinski.
Just ran into this as well with a slightly different usage (function param initializers), and I can confirm it doesn't work for non-imported functions. Here's a trivial example:

In that example, TS tweaks the type of foo from what we defined it as to const foo: (bar?: number) => number because of the bar = 2 initializer.
If you have any hints about where to get started debugging this I can take a crack at submitting a PR.
Hello @doytch, have you been able to find the root cause of this issue ?
I'm also have this other issue (that look familiar).
That’s an odd one. But no, I never found a solution.
What I ended up doing is stopping use of this plugin in our org and used an interesting little feature in VSCode instead since almost all of us use it.
I added a nested tsconfig in our codebase. That is, if our normal tsconfig was at the project root ~, I put a new tsconfig in ~/src.
That tsconfig simply inherited the main tsconfig but turned on strictNullChecks. Absolutely nothing uses a nested tsconfig file by default - except VSCode’s TS server.
So that showed everybody errors during development but didn’t break builds. That may or may not meet your requirements (and I thiiink we might’ve been relying on undocumented VSCode behaviour so it’s not reliable long-term), but just figured I’d throw it out there.
That's a freaking awesome tips you got right there, thank you for sharing this, I think I will go for this too. The ratio simplicity / efficiency is right where I need it to be. Have a great day!