@ Reflect.metadata generates error TS1238: it is not possible to allow the signature of a class decorator when invoking an expression

I tried applying the @Reflect.metadata decorator to the TypeScript class, following the example lines 82-84 of reflect-metadata.d.ts :

 /// <reference path="node_modules/reflect-metadata/reflect-metadata.d.ts"/> @Reflect.metadata('key', 0) class C { } 

However, the TypeScript 1.7.2 compiler generates the following error in the @Reflect.metadata line:

error TS1238: it is not possible to allow the signature of a class decorator when called as an expression.
Cannot invoke an expression whose type does not have a call signature.

What's wrong?

+6
source share
1 answer

From TypeScript docs :

Decorators are checked as call expressions

Starting at 1.6, decorator type checking is more accurate; the compiler will check the decorator expression as a call expression with the decorated object as a parameter. This can lead to an error that was not in previous releases.

I assume that you probably need to use a newer version of TypeScript or an older version of reflect-metadata .

Latest issues:

  • typescript@2.3.2
  • reflect-metadata@0.1.10
0
source

All Articles