In TS 1.5 this:
//Relation.ts
export function Relation(cls: any) {
return function () {
console.log(cls);
}
}
//Foo.ts
import {Relation} from "./Relation";
export class Foo {
@Relation(Foo)
info: string;
}
Compiles without error. In TS 1.6, it reports the error:
error TS1240: Unable to resolve signature of property decorator when called as an expression.
Supplied parameters do not match any signature of call target.
On the decorator call in Foo.ts. This is a very cryptic message. What it wants you to do is change Relation.ts to read like this:
export function Relation(cls: any): PropertyDecorator {
return function () {
console.log(cls);
}
}
or this:
export function Relation(cls: any) {
return function (target: Object, propertyKey: string | symbol) {
console.log(cls);
}
}
It would be very useful for the error message to indicate what exactly is wrong and how it could be fixed. Something akin to
error TS1240: Expression type is not assignable to decorator type [[PropertyDecorator]]. Ensure [[@Relation(Foo)]] has a type assignable to [[PropertyDecorator]].
would be more useful in actually understanding what's wrong and why you need to change your code.
In TS 1.5 this:
Compiles without error. In TS 1.6, it reports the error:
On the decorator call in
Foo.ts. This is a very cryptic message. What it wants you to do is changeRelation.tsto read like this:or this:
It would be very useful for the error message to indicate what exactly is wrong and how it could be fixed. Something akin to
would be more useful in actually understanding what's wrong and why you need to change your code.