errors and warnings / classes / E3021
E3021 error
Decorator not applicable to this target (including user decorators on enums, interfaces and aliases)
- area
- classes (x3xxx)
- fails the build
- yes
A decorator is used on a declaration it can't apply to. User decorators work
on functions, classes and class members; on enums, interfaces, type aliases,
declare statements and imports they can't take effect (enum members are
inlined, types have no value at run time). Each core decorator has its own
targets: @script only on instance methods of widget classes, @inline and
@debugOnly on functions and methods, and so on. The code also covers a
@script without a script name or with options other than { hook = true }
or { hook = false }.
Example
@script("OnClick")local function clicked()endclicked()class Clicker extends Button @script("OnClick") function clicked() print("clicked") endendprint(Clicker)The compiler reports it like this:
error[E3021]: `@script` cannot be applied to functions ┌─ src/main.wowlua:1:1 │ 1 │ @script("OnClick") │ ^^^^^^^^^^^^^^^^^^ here
Related codes
Offline
$ wowlua explain E3021 E3021 (error): Decorator not applicable to this target (including user decorators on enums, interfaces and aliases)