#Is it possible to detect the value of "experimentalDecorators" via the type system?

2 messages · Page 1 of 1 (latest)

vagrant osprey
#

The compiler option "experimentalDecorators" changes the function signature used by decorators. As the author of a library, I can't control whether my users are using modern or experimental decorators. I'm currently using overloads to type my decorators, one signature for each mode. However, this means that if someone uses a decorator incorrectly, they get two type errors (one per overload), even though only one is actually relevant. If I could detect which mode they're using, then I could use a conditional type to provide them with only the correct signature.

type Decorator = IsExperimentalDecorators ? ExperimentalDecorator : ModernDecorator
rich sedge
#

@vagrant osprey There might be a trick to detect it at a type-level, but isn't the runtime logic is also different between the experimental and modern version?