Deno 2.0 Decorators
#26737
Replies: 2 comments 2 replies
-
|
With the |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
I don't fully understand why, or when this changed, but the issue is with the typing of the argument to your decorator. You have it typed as So function PluginDecorator(name: string) {
return (_ctor: new () => void) => { // note the insertion of `new`
console.log("Plugin found: " + name);
}
}
@PluginDecorator("My first Plugin")
class myFirstPlugin {
}This works, but as per the example in the typescript reference on class decorators (it's the example at the end of the function PluginDecorator(name: string) {
return <T extends { new (...args: any[]): {} }>(_ctor: T) => {
console.log("Plugin found: " + name);
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have some older decorators with parameters that used to work in Deno/Typescript, here illustrated with a simple example:
It now gives me an error:
In Deno 2.0 the following options are depreciated:
and now gives me
Value is deprecated, and I have not been able to find a work around for this. Can somebody please advise, it would much appreciated, best of all if you could provide me with a small working example?Beta Was this translation helpful? Give feedback.
All reactions