/foundry-vtt-types

Unofficial type declarations for the Foundry Virtual Tabletop API

Primary LanguageTypeScriptMIT LicenseMIT

foundry-vtt-types

TypeScript type definitions for Foundry Virtual Tabletop (unofficial)

League Discord Server GitHub 0.7.x issues by-label GitHub closed 0.7.x issues by-label GitHub 0.8.x issues by-label GitHub closed 0.8.x issues by-label npm (tag)

Supported Foundry VTT versions

We aim to support the latest patch release of minor versions of Foundry VTT, starting with 0.7.

At the moment, the latest 0.7.x and 0.8.x versions are supported. However, note that work on 0.8.x has not been completed yet, so there are still quite a few things which are either missing or typed incorrectly. Take a look at 0.8.x issues to see what still needs to be done.

Installation

You can install foundry-vtt-types from the npm registry. We provide distribution tags for the different supported Foundry VTT versions that have the form fvtt-<foundry-version>. For example, the distribution tag for Foundry VTT 0.8.8 is fvtt-0.8.8.

In order to install the desired version, run

npm install --save-dev @league-of-foundry-developers/foundry-vtt-types@fvtt-<foundry-version>

For example, to install the type definitions for Foundry VTT 0.8.8 run

npm install --save-dev @league-of-foundry-developers/foundry-vtt-types@fvtt-0.8.8

You can then update foundry-vtt-types using the regular update mechanism for npm (see npm update).

Usage

Add foundry-vtt-types to your types section in your tsconfig.json:

{
  "compilerOptions": {
    "types": ["@league-of-foundry-developers/foundry-vtt-types"],
    "moduleResolution": "node",
    "strictNullChecks": true,
  }
}

This will make the type definitions available globally in your project.

Make sure you are using "moduleResolution": "node", too. It is required for some dependencies to be resolved correctly.

Also make sure to set "strictNullChecks": true because otherwise, some of the conditional types used in the type definitions resolve incorrectly and you will see a lot of errors.

You can find some information about how to actually work with the type definitions in the Wiki. If you are working with Foundry VTT 0.8.x, a good starting point is [0.8.x] FAQ.

Acknowledgments

Originally forked from Foundry Project Creator Types by @NickEastNL

Contributing

Contributions are very welcome in order to decrease the individual workload. Filing issues for wrong / missing types is also a great way to help us improve the type definitions.

There are individual branches for the different supported Foundry VTT versions that are being worked on. They are named according to the minor version of the Foundry VTT version, e.g. the branch for Foundry VTT 0.8 is called foundry-0.8.x. All work to improve the type definitions for a specific version needs to be done through Pull Requests to the corresponding branch.

Please read CONTRIBUTING.md for more details on how to contribute.

If you have any specific questions, feel free to contact us in the League of Extraordinary Foundry Developers Discord.

Type-Checking, Linting, Testing

When contributing, make sure sure that the type checks pass, the linter is green and the tests are green. We do have checks in the CI but running this locally also helps you while developing and saves you time as you don't have to wait for the CI.

You can run type checking and linting with the following command:

npm run lint

You can run the tests with

npm run test

License

This project is licensed under the MIT license. You can find a copy at LICENSE.