I think you can safely just say:

   if @cheatsheet && @cheatsheet.hasClass("shown")

If the cheatsheet is an object it will definitely be truthy, and if it is undefined or null then it will not be.