-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do this
Milestone
Description
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.
jan-molak, jaywick, nkronlage, Glavin001, cypherix93 and 18 more
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do this