v0.13.7
errors and warnings / stdlib

errors and warnings / stdlib / E8104

E8104 error

saved.bind defaults type contains Secret<…>

area
stdlib (x8xxx)
fails the build
yes

The type of the defaults given to saved.bind contains a Secret<…> type, somewhere inside it (the message names the field). Secret values can't be compared or saved: the module drops them at logout, so such a field would never keep its value.

Store a plain value type instead, and keep secret values in memory only.

Example

× failswowlua.jsonjson
{    "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" },    "flavors": { "camelot": {} },    "addon": { "saved-variables": ["MyAddonDB"] }}
src/main.wowluawowlua
import * as saved from "wowlua:saved" interface Settings    lastTarget: Secret<string>?end local db = saved.bind("MyAddonDB", { version = 1, defaults = {} :: Settings })print(db)
✓ compileswowlua.jsonjson
{    "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" },    "flavors": { "camelot": {} },    "addon": { "saved-variables": ["MyAddonDB"] }}
src/main.wowluawowlua
import * as saved from "wowlua:saved" interface Settings    lastTarget: string?end local db = saved.bind("MyAddonDB", { version = 1, defaults = {} :: Settings })print(db)

The compiler reports it like this:

error[E8104]: the defaults of `saved.bind` contain a `Secret<…>` type (at `lastTarget`): secret values cannot be compared or saved
  ┌─ src/main.wowlua:7:62
  │
7 │ local db = saved.bind("MyAddonDB", { version = 1, defaults = {} :: Settings })
  │                                                              ^^^^^^^^^^^^^^ here

Offline

terminal
$ wowlua explain E8104
E8104 (error): saved.bind defaults type contains Secret<…>

source on GitHub ↗