CoffeeScript and scope

Are there any particular gotchas I should be aware of when using CoffeeScript in Meteor? The only one I’ve noticed so far is that my lib/collections/<file>.coffee files have to specify collections as such:

@Products = new Mongo.Collection 'products'

If I don’t include the @, nothing outside that file will see Products.

Other than that, everything else seems to work fine.

I’m using CoffeeScript all the time and I think you’ve found the only thing I came across. And sometimes I had problems because of missing braces, like this:

# always false
console.log email.match SimpleSchema.RegEx.Email and
email.match /^(.*)(@)(.*)(\.)(.{2,3})$/
# works
console.log email.match(SimpleSchema.RegEx.Email) and
email.match /^(.*)(@)(.*)(\.)(.{2,3})$/ helped me notice in those situations :wink:

The only other thing I can think of right now is if you use .coffee files in a package, you can only share variables between files by attaching them to an object called share. For more details, see the “Namespacing and CoffeeScript” section of the docs.