errors and warnings / stdlib / E8107
E8107 error
Settings dropdown option value not in the field's type
- area
- stdlib (x8xxx)
- fails the build
- yes
A settings.dropdown option has a value that the bound store field can't
hold. Picking that option would write a value of the wrong type into the
SavedVariable. Fix the option's value, or widen the field's type so that it
includes the value.
Example
{ "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" }, "flavors": { "camelot": {} }, "addon": { "saved-variables": ["PlaygroundDB"] }}import * as settings from "wowlua:settings"import * as saved from "wowlua:saved" interface Options anchor: "TOPLEFT" | "CENTER"end local db = saved.bind("PlaygroundDB", { version = 1, defaults = { anchor = "CENTER" } :: Options }) settings.register({ title = "Playground", store = db, controls = { settings.dropdown("anchor", { label = "Anchor", options = { { value = "TOPLEFT", label = "Top left" }, { value = "BOTTOM", label = "Bottom" }, } }), },}){ "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" }, "flavors": { "camelot": {} }, "addon": { "saved-variables": ["PlaygroundDB"] }}import * as settings from "wowlua:settings"import * as saved from "wowlua:saved" interface Options anchor: "TOPLEFT" | "CENTER" | "BOTTOM"end local db = saved.bind("PlaygroundDB", { version = 1, defaults = { anchor = "CENTER" } :: Options }) settings.register({ title = "Playground", store = db, controls = { settings.dropdown("anchor", { label = "Anchor", options = { { value = "TOPLEFT", label = "Top left" }, { value = "BOTTOM", label = "Bottom" }, } }), },})The compiler reports it like this:
error[E8107]: the option value `"BOTTOM"` is not a `"TOPLEFT" | "CENTER"` (the type of `anchor`) ┌─ src/main.wowlua:16:23 │ 16 │ { value = "BOTTOM", label = "Bottom" }, │ ^^^^^^^^ here
Related codes
| code | message |
|---|---|
| E8070 | Settings control bound to a field of the wrong type |
| E8113 | Settings control key not found in the store's type |
Offline
$ wowlua explain E8107 E8107 (error): Settings dropdown option value not in the field's type