chore: fix issues due to updated types

This commit is contained in:
Johannes Loher 2021-10-10 12:13:27 +02:00
parent 88c6e3f6da
commit c40574f0f5

View file

@ -46,9 +46,7 @@ export async function migrateActors(getActorUpdateData: ActorUpdateDataGetter):
} }
} }
type SceneUpdateDataGetter = ( type SceneUpdateDataGetter = (sceneData: foundry.data.SceneData) => DeepPartial<foundry.data.SceneData["_source"]>;
sceneData: foundry.documents.BaseScene["data"],
) => DeepPartial<foundry.documents.BaseScene["data"]["_source"]>;
export async function migrateScenes(getSceneUpdateData: SceneUpdateDataGetter): Promise<void> { export async function migrateScenes(getSceneUpdateData: SceneUpdateDataGetter): Promise<void> {
for (const scene of getGame().scenes ?? []) { for (const scene of getGame().scenes ?? []) {
@ -98,7 +96,7 @@ export function getActorUpdateDataGetter(getItemUpdateData: ItemUpdateDataGetter
} }
export function getSceneUpdateDataGetter(getActorUpdateData: ActorUpdateDataGetter): SceneUpdateDataGetter { export function getSceneUpdateDataGetter(getActorUpdateData: ActorUpdateDataGetter): SceneUpdateDataGetter {
return (sceneData: foundry.documents.BaseScene["data"]) => { return (sceneData: foundry.data.SceneData) => {
const tokens = sceneData.tokens.map((token: TokenDocument) => { const tokens = sceneData.tokens.map((token: TokenDocument) => {
const t = token.toObject(); const t = token.toObject();
if (!t.actorId || t.actorLink) { if (!t.actorId || t.actorLink) {
@ -166,7 +164,7 @@ export function getCompendiumMigrator(
const updateData = getActorUpdateData(doc.toObject()); const updateData = getActorUpdateData(doc.toObject());
updateData && (await doc.update(updateData)); updateData && (await doc.update(updateData));
} else if (doc instanceof Scene && getSceneUpdateData) { } else if (doc instanceof Scene && getSceneUpdateData) {
const updateData = getSceneUpdateData(doc.data); const updateData = getSceneUpdateData(doc.data as foundry.data.SceneData);
updateData && updateData &&
(await doc.update( (await doc.update(
updateData as DeepPartial<Parameters<foundry.data.SceneData["_initializeSource"]>[0]>, updateData as DeepPartial<Parameters<foundry.data.SceneData["_initializeSource"]>[0]>,