``` function assert(condition: boolean, message: string) { if (!condition) { throw new Error(message); } }
assert(x !== null, "x can't be null");
// Flow understands that x can't be null here because `invariant` throws an error otherwise, but TS doesn't ```
However, TypeScript couldn't understand that `x` can't be null after that call since it doesn't understand what `assert` does. For that reason, we had to write a codemod that replaced all of our `assert` calls with an if condition that threw an error inline.
The new `asserts` syntax is nice (it would be even better if TS could do this automatically like Flow though), and will be a much welcome update for us.