DanielXMoore / Civet

A TypeScript superset that favors more types and less typing
https://civet.dev
MIT License
1.34k stars 28 forks source link

CoffeeScript incompatibility with predefined values #944

Open bbrk24 opened 5 months ago

bbrk24 commented 5 months ago
'civet coffeeCompat'

class Foo
  [Symbol.toStringTag]: 'Foo'

console.log Foo::[Symbol.toStringTag]

This prints 'Foo' in CoffeeScript and undefined in Civet.

edemaine commented 5 months ago

One could argue that this is a bug in CoffeeScript. See https://github.com/jashkenas/coffeescript/issues/4552 (especially toward the end).

That said, it currently is how CoffeeScript works, so it probably make sense to have a compatibility flag that triggers CoffeeScript's IIFE behavior, and perhaps the same coffeeClasses flag makes sense. Related to #457.

STRd6 commented 4 months ago

As a workaround you can do this:

'civet coffeeCompat'

class Foo
  get [Symbol.toStringTag]() 'Foo'

console.log Foo::[Symbol.toStringTag]