0

Im looking through a project's code and one of their function's return statements reads

return null!;

What does "!" after null mean? Also, when I rewrite it like:

return !null;

I get a linting error

Nephter
  • 147
  • 1
  • 11
  • 2
    That's _TypeScript_, and it's bonkers - they're returning `null` and asserting that it's [**not** `null`](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#non-null-assertion-operator-postfix-). – jonrsharpe Jun 09 '22 at 15:00
  • `return null!;` should be a syntax error (in JavaScript). – Pointy Jun 09 '22 at 15:00
  • Ah, you're right I'll change the tag @Pointy – Nephter Jun 09 '22 at 15:34

0 Answers0