Update types

This commit is contained in:
Johannes Loher 2021-02-07 12:16:48 +01:00
parent d5db788c31
commit f64e459cd2
3 changed files with 11 additions and 9 deletions

2
package-lock.json generated
View file

@ -3119,7 +3119,7 @@
}
},
"foundry-vtt-types": {
"version": "github:League-of-Foundry-Developers/foundry-vtt-types#e17295657bcdf61775f3eaf86900be594e5cec57",
"version": "github:League-of-Foundry-Developers/foundry-vtt-types#32d849fd2afa4e88319c0105c989cec62bb888c2",
"from": "github:League-of-Foundry-Developers/foundry-vtt-types#foundry-0.7.9",
"dev": true,
"requires": {

View file

@ -2,12 +2,12 @@ import { DS4 } from "../../config";
import { DS4Item } from "../../item/item";
import { DS4ItemData } from "../../item/item-data";
import { DS4Actor } from "../actor";
import { DS4ActorData } from "../actor-data";
/**
* The base Sheet class for all DS4 Actors
*/
// TODO(types): Remove first generic parameter once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/pull/273 is merged
export class DS4ActorSheet extends ActorSheet<unknown, DS4Actor> {
export class DS4ActorSheet extends ActorSheet<DS4Actor> {
// TODO(types): Improve mergeObject in upstream so that it isn't necessary to provide all parameters (see https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues/272)
/** @override */
static get defaultOptions(): BaseEntitySheet.Options {
@ -49,7 +49,7 @@ export class DS4ActorSheet extends ActorSheet<unknown, DS4Actor> {
* object itemsByType.
* @returns The data fed to the template of the actor sheet
*/
getData(): ActorSheet.Data<DS4Actor> {
getData(): ActorSheet.Data<DS4Actor> | Promise<ActorSheet.Data<DS4Actor>> {
const data = {
...super.getData(),
// Add the localization config to the data:
@ -216,7 +216,10 @@ export class DS4ActorSheet extends ActorSheet<unknown, DS4Actor> {
}
/** @override */
async _onDropItem(event: DragEvent, data: Parameters<typeof DS4Item.fromDropData>[0]): Promise<unknown> {
protected async _onDropItem(
event: DragEvent,
data: { type: "Item" } & (DeepPartial<ActorSheet.OwnedItemData<DS4Actor>> | { pack: string } | { id: string }),
): Promise<boolean | undefined | ActorSheet.OwnedItemData<DS4Actor>> {
const item = ((await Item.fromDropData(data)) as unknown) as DS4Item;
if (item && !this.actor.canOwnItemType(item.data.type)) {
ui.notifications.warn(
@ -229,6 +232,6 @@ export class DS4ActorSheet extends ActorSheet<unknown, DS4Actor> {
);
return false;
}
return super["_onDropItem"](event, data); // TODO(types): Add _onDropItem to upstream (fixed by https://github.com/League-of-Foundry-Developers/foundry-vtt-types/pull/273)
return super._onDropItem(event, data);
}
}

View file

@ -5,8 +5,7 @@ import { isDS4ItemDataTypePhysical } from "./item-data";
/**
* The Sheet class for DS4 Items
*/
// TODO(types): Remove first generic parameter once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/pull/273 is merged
export class DS4ItemSheet extends ItemSheet<unknown, DS4Item> {
export class DS4ItemSheet extends ItemSheet<DS4Item> {
/** @override */
static get defaultOptions(): BaseEntitySheet.Options {
const superDefaultOptions = super.defaultOptions;
@ -42,7 +41,7 @@ export class DS4ItemSheet extends ItemSheet<unknown, DS4Item> {
}
/** @override */
getData(): ItemSheet.Data<DS4Item> {
getData(): ItemSheet.Data<DS4Item> | Promise<ItemSheet.Data<DS4Item>> {
const data = {
...super.getData(),
config: DS4,