errors and warnings / classes / E3022
E3022 error
User decorator signature does not accept the target
- area
- classes (x3xxx)
- fails the build
- yes
A user decorator's parameters don't accept the declaration it decorates: a
function decorator is (fn: F, ctx: DecoratorContext) -> F?, and its fn
must take the decorated function's type. A method's function takes self
first, a class decorator gets the class table and a field decorator nil.
The second parameter must take the DecoratorContext, and any further
parameters must be optional. Fix the decorator's signature, or decorate a
fitting declaration.
Example
local function onNumbers(fn: (n: number) -> (), _ctx: DecoratorContext) return fnend @onNumberslocal function greet(name: string) print(name)endgreet("Ana")local function onNumbers(fn: (n: number) -> (), _ctx: DecoratorContext) return fnend @onNumberslocal function double(n: number) print(n * 2)enddouble(2)The compiler reports it like this:
error[E3022]: `@onNumbers` does not accept this function: it takes `(n: number) -> ()`, and the value is `(name: string) -> ()` ┌─ src/main.wowlua:5:1 │ 5 │ @onNumbers │ ^^^^^^^^^^ here
Related codes
| code | message |
|---|---|
| E3021 | Decorator not applicable to this target (including user decorators on enums, interfaces and aliases) |
Offline
$ wowlua explain E3022 E3022 (error): User decorator signature does not accept the target