v0.13.7
errors and warnings / stdlib

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

× failswowlua.jsonjson
{    "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" },    "flavors": { "camelot": {} },    "addon": { "saved-variables": ["PlaygroundDB"] }}
src/main.wowluawowlua
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" },        } }),    },})
✓ compileswowlua.jsonjson
{    "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" },    "flavors": { "camelot": {} },    "addon": { "saved-variables": ["PlaygroundDB"] }}
src/main.wowluawowlua
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
codemessage
E8070Settings control bound to a field of the wrong type
E8113Settings control key not found in the store's type

Offline

terminal
$ wowlua explain E8107
E8107 (error): Settings dropdown option value not in the field's type

source on GitHub ↗