Getting Started with these Type Definitions - League-of-Foundry-Developers/foundry-vtt-dnd5e-types GitHub Wiki
Core Assumptions:
- These are expected to be installed beside
foundry-vtt-types
. - These do not fully type the methods marked private on Document classes, nor some of the private functions in the system files.
These are generated types created from the jsDoc of the system, as such they may be incomplete or just plain wrong. Please open an issue if you find something about that. We recommend resorting to some Declaration Merging if you encounter issues as well.
Installation & Setup
Instructions on the readme
Using the Types
If that's set up, you should be able to access types for things like Actor5e
and Item5e
now. More importantly, the contents of collections like game.actors.contents
will properly be typed as Actor5e
. (Please take note of the proper way to access game
from foundry-vtt-types)
type
Item and Actor Actor5e and Item5e are complicated to type correctly because of the various type
s they entail. Simply getting an item
and then looking for its spell level isn't going to be good enough to satisfy typescript.
Instead you'll probably need to introduce some type guards now:
DND5e
namespace
The There is a namespace: DND5e
which contains types for all of the 'string enumerables' that are defined in dnd5e/config.js. These are not typescript enums as that would not correspond to the runtime types.
They are however useful types for prompting when doing things like this: