Questions tagged [class-expression]

4 questions
2
votes
1 answer

Generic class expression broken if duplicate constructor is removed

I stumbled upon this weird behaviour, If I remove one of the constructor signatures in IFoo the compiler triggers the following error : Type 'typeof (Anonymous class)' is not assignable to type 'IFoo'. What is actually happening ? type Foo = { …
Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134
2
votes
2 answers

When we should use class expression in Javascript?

I have recently got to know that we do have class expressions too like function expressions in JS. I know some points about it(MDN) like: Class expressions may omit the class name ("binding identifier"), which is not possible with class…
Apoorva Chikara
  • 8,277
  • 3
  • 20
  • 35
0
votes
1 answer

How do you subclass a generic Class expression with constructor overload

Angular's FormControl is defined as class expression with constructor overload in an interface. This is due to a typescript limitation. I was able to narrow the code down to : export interface FormControl { setValue(value:…
Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134
-1
votes
0 answers

JS / TS - Add decorators to ES6 class expressions

I have a class expression (see MDN - Class Expressions) like this: const XYZ = class {} I want to add a decorator like we have in regular classes (see TS Class Decorator) to that, how can I do this? Adding them before or inline throws an error