How not to trick TypeScript compiler and not be tricked by it