Recipes

Type player.data Keys

Give player.data a schema so get/set are checked and autocompleted.

Each player carries a small key/value store at player.data. Augment CustomizablePlayerStorage to declare its keys and value types — get and set then autocomplete and type-check against your schema.

Declare the schema

typed-player-data.ts
await ..('enabledAutoplay', true);

const enabled = await ..('enabledAutoplay');
const enabled: boolean | undefined

get returns V | undefined for the key's declared type — here boolean | undefined — so unset keys are handled at the type level.

enabledAutoplay is a real key

The built-in autoplay reads enabledAutoplay from this exact store to decide whether to run per-player. Declaring it here is how you get a typed toggle for autoplay.

Keys starting with internal_

Hoshimi keeps its own bookkeeping under internal_-prefixed keys, and those are hidden from every enumeration (keys(), values(), entries(), all()). Don't declare or write them — treat that prefix as reserved.