errors and warnings / classes / E3046
E3046 error
A field declared twice in one class (a constructor's parameter property included)
- area
- classes (x3xxx)
- fails the build
- yes
A field is declared twice in one class, also when a constructor's parameter
property (constructor(public x: number)) declares a field the class body
declares too. Keep one declaration.
Example
class Point x: number constructor(public x: number) endendprint(Point)class Point constructor(public x: number) endendprint(Point.new(1).x)The compiler reports it like this:
error[E3046]: the field `x` is declared twice ┌─ src/main.wowlua:3:24 │ 3 │ constructor(public x: number) │ ^ here
Related codes
| code | message |
|---|---|
| E3042 | Field and method/accessor with the same name (in a class or across its superclass) |
Offline
$ wowlua explain E3046 E3046 (error): A field declared twice in one class (a constructor's parameter property included)