From f1feb4ab1cc831dc8d204b113d2dc23f943fbfbe Mon Sep 17 00:00:00 2001 From: Shark that walks like a man Date: Thu, 18 Mar 2021 06:29:31 -0500 Subject: [PATCH] Turn on noUnusedParameters --- .betterer.results | 355 +++++------------- .betterer.ts | 1 - src/module/actor/base.ts | 15 +- src/module/actor/sheet/updated-npc-sheet.ts | 38 +- src/module/dc.ts | 2 +- src/module/item/data-definitions.ts | 2 +- src/module/item/encumbrance.ts | 2 +- src/module/item/runes.ts | 13 +- src/module/migrations/574-migrate-bulk.ts | 2 +- .../578-migrate-item-image-paths.ts | 3 +- .../579-add-container-attributes.ts | 2 +- .../580-add-item-rarity-and-level.ts | 2 +- .../583-add-hp-threshold-hardness.ts | 2 +- .../migrations/586-add-splash-damage.ts | 2 +- src/module/migrations/base.ts | 4 +- src/module/packs/compendium-browser.ts | 21 +- src/module/rules/elements/base-speed.ts | 7 +- .../rules/elements/dexterity-modifier-cap.ts | 3 +- .../rules/elements/fixed-proficiency.ts | 2 +- src/module/rules/elements/sense.ts | 3 +- src/module/rules/elements/set-property.ts | 4 +- src/module/rules/elements/toggle-property.ts | 3 +- .../rules/elements/token-effect-icon.ts | 2 +- src/module/rules/rule-element.ts | 14 +- src/module/system/damage/damage.ts | 7 +- src/module/system/effect-panel.ts | 4 +- src/module/system/rolls.ts | 12 +- src/module/system/trait-selector.ts | 26 +- src/pf2e.ts | 100 +++-- src/scripts/dice.ts | 21 +- tests/module/migration.test.ts | 55 +-- tests/setup.ts | 18 +- tsconfig.json | 1 + types/foundry-pc-types/index.d.ts | 2 +- .../sidebar/apps/compendiumdirectory.d.ts | 6 - .../types/apps/sidebar/sidebar-tab/base.d.ts | 33 +- .../{apps => sidebar-tab}/chat-log.d.ts | 4 +- types/foundry-pc-types/types/core/hooks.d.ts | 12 + .../types/framework/entities/item.d.ts | 4 +- 39 files changed, 323 insertions(+), 486 deletions(-) rename types/foundry-pc-types/types/apps/sidebar/{apps => sidebar-tab}/chat-log.d.ts (95%) diff --git a/.betterer.results b/.betterer.results index 5c05a650fd8..e170344e72e 100644 --- a/.betterer.results +++ b/.betterer.results @@ -198,36 +198,20 @@ exports[`stricter compilation`] = { "src/module/actor/sheet/trick-magic-item-popup.ts:2898717897": [ [69, 29, 24, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'TrickMagicItemDifficultyData\'.", "722473979"] ], - "src/module/actor/sheet/updated-npc-sheet.ts:19310585": [ - [163, 24, 44, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ action: { label: string; actions: never[]; }; reaction: { label: string; actions: never[]; }; free: { label: string; actions: never[]; }; passive: { label: string; actions: never[]; }; }\'.", "556974482"], - [167, 24, 42, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ action: { label: string; actions: never[]; }; reaction: { label: string; actions: never[]; }; free: { label: string; actions: never[]; }; passive: { label: string; actions: never[]; }; }\'.", "2618376781"], - [172, 24, 42, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ action: { label: string; actions: never[]; }; reaction: { label: string; actions: never[]; }; free: { label: string; actions: never[]; }; passive: { label: string; actions: never[]; }; }\'.", "1398294565"], - [258, 27, 9, "Parameter \'actorData\' implicitly has an \'any\' type.", "2399949438"], - [258, 38, 8, "Parameter \'increase\' implicitly has an \'any\' type.", "4194692161"], - [258, 48, 18, "Parameter \'adjustBackToNormal\' implicitly has an \'any\' type.", "3959891131"], - [264, 66, 1, "Parameter \'m\' implicitly has an \'any\' type.", "177608"], - [333, 69, 5, "\'match\' is declared but its value is never read.", "174531222"], - [333, 69, 5, "Parameter \'match\' implicitly has an \'any\' type.", "174531222"], - [333, 76, 6, "Parameter \'number\' implicitly has an \'any\' type.", "1682699846"], - [339, 25, 5, "\'match\' is declared but its value is never read.", "174531222"], - [339, 25, 5, "Parameter \'match\' implicitly has an \'any\' type.", "174531222"], - [339, 32, 1, "Parameter \'a\' implicitly has an \'any\' type.", "177604"], - [339, 35, 1, "Parameter \'b\' implicitly has an \'any\' type.", "177607"], - [339, 38, 1, "Parameter \'c\' implicitly has an \'any\' type.", "177606"], - [339, 41, 1, "Parameter \'d\' implicitly has an \'any\' type.", "177601"], - [393, 22, 5, "Parameter \'event\' implicitly has an \'any\' type.", "165702089"], - [393, 29, 10, "Parameter \'damageRoll\' implicitly has an \'any\' type.", "3282163187"], - [393, 41, 4, "Parameter \'item\' implicitly has an \'any\' type.", "2087854480"], - [401, 22, 46, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ acid: string; bleed: string; bludgeoning: string; chaotic: string; cold: string; electricity: string; energy: string; evil: string; fire: string; force: string; good: string; lawful: string; mental: string; ... 6 more ...; sonic: string; }\'.", "1897423331"], - [428, 23, 16, "Parameter \'attackEffectName\' implicitly has an \'any\' type.", "1516278013"], - [428, 41, 5, "Parameter \'event\' implicitly has an \'any\' type.", "165702089"], - [428, 48, 11, "Parameter \'triggerItem\' implicitly has an \'any\' type.", "2011880424"], - [433, 25, 5, "\'index\' is declared but its value is never read.", "178792571"], + "src/module/actor/sheet/updated-npc-sheet.ts:3210291204": [ + [164, 24, 44, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ action: { label: string; actions: never[]; }; reaction: { label: string; actions: never[]; }; free: { label: string; actions: never[]; }; passive: { label: string; actions: never[]; }; }\'.", "556974482"], + [168, 24, 42, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ action: { label: string; actions: never[]; }; reaction: { label: string; actions: never[]; }; free: { label: string; actions: never[]; }; passive: { label: string; actions: never[]; }; }\'.", "2618376781"], + [173, 24, 42, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ action: { label: string; actions: never[]; }; reaction: { label: string; actions: never[]; }; free: { label: string; actions: never[]; }; passive: { label: string; actions: never[]; }; }\'.", "1398294565"], + [259, 27, 9, "Parameter \'actorData\' implicitly has an \'any\' type.", "2399949438"], + [265, 66, 1, "Parameter \'m\' implicitly has an \'any\' type.", "177608"], + [394, 22, 5, "Parameter \'event\' implicitly has an \'any\' type.", "165702089"], + [394, 29, 10, "Parameter \'damageRoll\' implicitly has an \'any\' type.", "3282163187"], + [394, 41, 4, "Parameter \'item\' implicitly has an \'any\' type.", "2087854480"], + [402, 22, 46, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ acid: string; bleed: string; bludgeoning: string; chaotic: string; cold: string; electricity: string; energy: string; evil: string; fire: string; force: string; good: string; lawful: string; mental: string; ... 6 more ...; sonic: string; }\'.", "1897423331"], [435, 16, 33, "Object is possibly \'undefined\'.", "2536647008"], - [441, 35, 28, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ \'All-Around Vision\': { actionType: string; actionCost: number; description: string; }; \'Aquatic Ambush\': { actionType: string; actionCost: number; description: string; }; \'Attack of Opportunity\': { ...; }; ... 37 more ...; Wavesense: { ...; }; }\'.", "3840936178"], + [441, 35, 28, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{ \'All-Around Vision\': { actionType: string; actionCost: number; description: string; }; \'Aquatic Ambush\': { actionType: string; actionCost: number; description: string; }; \'Attack of Opportunity\': { ...; }; ... 37 more ...; Wavesense: { ...; }; }\'.\\n No index signature with a parameter of type \'string\' was found on type \'{ \'All-Around Vision\': { actionType: string; actionCost: number; description: string; }; \'Aquatic Ambush\': { actionType: string; actionCost: number; description: string; }; \'Attack of Opportunity\': { ...; }; ... 37 more ...; Wavesense: { ...; }; }\'.", "3840936178"], [461, 66, 17, "Argument of type \'any\' is not assignable to parameter of type \'never\'.", "543775335"], [462, 61, 17, "Argument of type \'any\' is not assignable to parameter of type \'never\'.", "543775335"], - [488, 53, 5, "\'index\' is declared but its value is never read.", "178792571"], [506, 49, 6, "Argument of type \'string | undefined\' is not assignable to parameter of type \'string\'.\\n Type \'undefined\' is not assignable to type \'string\'.", "1635831453"], [507, 31, 4, "Object is possibly \'null\'.", "2087854480"], [525, 49, 6, "Argument of type \'string | undefined\' is not assignable to parameter of type \'string\'.\\n Type \'undefined\' is not assignable to type \'string\'.", "1635831453"] @@ -315,10 +299,9 @@ exports[`stricter compilation`] = { [741, 24, 9, "Variable \'condition\' implicitly has an \'any\' type.", "1256906070"], [742, 24, 9, "Variable \'condition\' implicitly has an \'any\' type.", "1256906070"] ], - "src/module/dc.ts:2823997716": [ + "src/module/dc.ts:3519847467": [ [88, 16, 29, "Object is possibly \'undefined\'.", "2125181224"], - [124, 33, 10, "Parameter \'spellLevel\' implicitly has an \'any\' type.", "2499768053"], - [152, 35, 5, "\'value\' is declared but its value is never read.", "189936718"] + [124, 33, 10, "Parameter \'spellLevel\' implicitly has an \'any\' type.", "2499768053"] ], "src/module/degree-of-success.ts:1041086816": [ [23, 31, 56, "Element implicitly has an \'any\' type because index expression is not of type \'number\'.", "1741159767"], @@ -423,9 +406,6 @@ exports[`stricter compilation`] = { [161, 35, 37, "Argument of type \'string | undefined\' is not assignable to parameter of type \'string\'.\\n Type \'undefined\' is not assignable to type \'string\'.", "3139842489"], [224, 22, 20, "Object is possibly \'undefined\'.", "1464649994"] ], - "src/module/item/encumbrance.ts:885866946": [ - [63, 4, 9, "\'actorSize\' is declared but its value is never read.", "2400415563"] - ], "src/module/item/identification.ts:998412798": [ [81, 12, 11, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{ occult: number; primal: number; divine: number; arcane: number; }\'.\\n No index signature with a parameter of type \'string\' was found on type \'{ occult: number; primal: number; divine: number; arcane: number; }\'.", "2400593949"] ], @@ -433,10 +413,8 @@ exports[`stricter compilation`] = { [11, 22, 13, "No overload matches this call.\\n Overload 1 of 2, \'(o: { [s: string]: KitEntryData; } | ArrayLike): KitEntryData[]\', gave the following error.\\n Argument of type \'Record | { [key: number]: KitEntryData; } | undefined\' is not assignable to parameter of type \'{ [s: string]: KitEntryData; } | ArrayLike\'.\\n Type \'undefined\' is not assignable to type \'{ [s: string]: KitEntryData; } | ArrayLike\'.\\n Overload 2 of 2, \'(o: {}): any[]\', gave the following error.\\n Argument of type \'Record | { [key: number]: KitEntryData; } | undefined\' is not assignable to parameter of type \'{}\'.\\n Type \'undefined\' is not assignable to type \'{}\'.", "3364010987"], [15, 33, 4, "Object is possibly \'null\'.", "2088096188"] ], - "src/module/item/runes.ts:1204236038": [ - [67, 4, 4, "Parameter \'rune\' implicitly has an \'any\' type.", "2088285833"], - [75, 14, 37, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ kinWarding: string; returning: string; ghostTouch: string; disrupting: string; pacifying: string; fearsome: string; shifting: string; conducting: string; wounding: string; bloodbane: string; ... 24 more ...; vorpal: string; }\'.", "1778002718"], - [107, 48, 14, "Argument of type \'RuneDiceModifier | undefined\' is not assignable to parameter of type \'RuneDiceModifier\'.\\n Type \'undefined\' is not assignable to type \'RuneDiceModifier\'.", "1922701432"] + "src/module/item/runes.ts:868787938": [ + [110, 48, 14, "Argument of type \'RuneDiceModifier | undefined\' is not assignable to parameter of type \'RuneDiceModifier\'.\\n Type \'undefined\' is not assignable to type \'RuneDiceModifier\'.", "1922701432"] ], "src/module/item/spell-consumables.ts:789767543": [ [37, 15, 36, "Element implicitly has an \'any\' type because expression of type \'number\' can\'t be used to index type \'{ 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; }\'.\\n No index signature with a parameter of type \'number\' was found on type \'{ 1: string; 2: string; 3: string; 4: string; 5: string; 6: string; 7: string; 8: string; 9: string; 10: string; }\'.", "3413808636"], @@ -461,40 +439,19 @@ exports[`stricter compilation`] = { [81, 42, 9, "Object is possibly \'null\'.", "920340027"], [156, 61, 9, "Argument of type \'MigrationBase\' is not assignable to parameter of type \'never\'.", "175358601"] ], - "src/module/migrations/574-migrate-bulk.ts:2470174957": [ - [5, 32, 5, "\'actor\' is declared but its value is never read.", "169990478"] - ], "src/module/migrations/576-add-coins.ts:4177769545": [ [8, 10, 7, "Not all code paths return a value.", "75217135"], [12, 31, 4, "Object is possibly \'null\'.", "2088096188"] ], - "src/module/migrations/578-migrate-item-image-paths.ts:1639601748": [ - [4, 32, 5, "\'actor\' is declared but its value is never read.", "169990478"] - ], - "src/module/migrations/579-add-container-attributes.ts:1591261580": [ - [4, 32, 5, "\'actor\' is declared but its value is never read.", "169990478"] - ], - "src/module/migrations/580-add-item-rarity-and-level.ts:601356914": [ - [4, 32, 5, "\'actor\' is declared but its value is never read.", "169990478"] - ], - "src/module/migrations/583-add-hp-threshold-hardness.ts:3139109607": [ - [4, 32, 5, "\'actor\' is declared but its value is never read.", "169990478"] - ], - "src/module/migrations/586-add-splash-damage.ts:3716672898": [ - [4, 32, 5, "\'actor\' is declared but its value is never read.", "169990478"] - ], "src/module/migrations/601-migrate-effect-compendia.ts:3048448483": [ [193, 35, 56, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ QuZ5frBMJF3gi7RY: string; \'7z1iY4AaNEAIKuAU\': string; \'1mKjaWC65KWPuFR4\': string; mi4Md1fB2XThCand: string; R106i7WCXvHLGMTu: string; kkDbalYEavzRpYlp: string; qVKrrKpTghgMIuGH: string; ... 171 more ...; LXf1Cqi1zyo4DaLv: string; }\'.", "1452348804"], [201, 35, 56, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ QuZ5frBMJF3gi7RY: string; \'7z1iY4AaNEAIKuAU\': string; \'1mKjaWC65KWPuFR4\': string; mi4Md1fB2XThCand: string; R106i7WCXvHLGMTu: string; kkDbalYEavzRpYlp: string; qVKrrKpTghgMIuGH: string; ... 171 more ...; LXf1Cqi1zyo4DaLv: string; }\'.", "1452348804"], [212, 35, 56, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ QuZ5frBMJF3gi7RY: string; \'7z1iY4AaNEAIKuAU\': string; \'1mKjaWC65KWPuFR4\': string; mi4Md1fB2XThCand: string; R106i7WCXvHLGMTu: string; kkDbalYEavzRpYlp: string; qVKrrKpTghgMIuGH: string; ... 171 more ...; LXf1Cqi1zyo4DaLv: string; }\'.", "1452348804"] ], - "src/module/migrations/base.ts:3841216907": [ - [20, 23, 27, "Element implicitly has an \'any\' type because expression of type \'\\"version\\"\' can\'t be used to index type \'Function\'.\\n Property \'version\' does not exist on type \'Function\'.", "3561871897"], - [32, 22, 5, "\'actor\' is declared but its value is never read.", "169990478"], - [40, 21, 4, "\'item\' is declared but its value is never read.", "2087854480"], - [40, 41, 5, "\'actor\' is declared but its value is never read.", "169990478"] + "src/module/migrations/base.ts:377294328": [ + [20, 23, 27, "Element implicitly has an \'any\' type because expression of type \'\\"version\\"\' can\'t be used to index type \'Function\'.\\n Property \'version\' does not exist on type \'Function\'.", "3561871897"] ], - "src/module/packs/compendium-browser.ts:2707072762": [ + "src/module/packs/compendium-browser.ts:253064665": [ [6, 23, 3, "Parameter \'obj\' implicitly has an \'any\' type.", "193420290"], [32, 21, 10, "Parameter \'entityType\' implicitly has an \'any\' type.", "4117825542"], [32, 33, 5, "Parameter \'packs\' implicitly has an \'any\' type.", "187697487"], @@ -542,17 +499,8 @@ exports[`stricter compilation`] = { [609, 12, 18, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{}\'.\\n No index signature with a parameter of type \'string\' was found on type \'{}\'.", "1939187447"], [609, 33, 32, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{ abj: string; con: string; div: string; enc: string; evo: string; ill: string; nec: string; trs: string; }\'.\\n No index signature with a parameter of type \'string\' was found on type \'{ abj: string; con: string; div: string; enc: string; evo: string; ill: string; nec: string; trs: string; }\'.", "4188739037"], [661, 12, 4, "Object is possibly \'null\'.", "2088096188"], - [789, 47, 3, "\'app\' is declared but its value is never read.", "193410244"], - [789, 58, 4, "\'data\' is declared but its value is never read.", "2087377941"], - [813, 42, 3, "\'app\' is declared but its value is never read.", "193410244"], - [813, 53, 4, "\'data\' is declared but its value is never read.", "2087377941"], - [836, 16, 3, "Parameter \'obj\' implicitly has an \'any\' type.", "193420290"], - [837, 63, 3, "\'key\' is declared but its value is never read.", "193424690"], [840, 18, 6, "Parameter \'action\' implicitly has an \'any\' type.", "1314712411"], - [852, 15, 11, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ 1: string; 2: string; 3: string; \'1 or 2\': string; \'1 to 3\': string; \'2 or 3\': string; free: string; reaction: string; passive: string; }\'.", "3579989790"], - [865, 23, 2, "Parameter \'li\' implicitly has an \'any\' type.", "5860992"], - [881, 20, 7, "Parameter \'element\' implicitly has an \'any\' type.", "4115912507"], - [928, 27, 7, "Parameter \'element\' implicitly has an \'any\' type.", "4115912507"] + [852, 15, 11, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ 1: string; 2: string; 3: string; \'1 or 2\': string; \'1 to 3\': string; \'2 or 3\': string; free: string; reaction: string; passive: string; }\'.", "3579989790"] ], "src/module/progress.ts:3731401366": [ [18, 12, 5, "Parameter \'label\' implicitly has an \'any\' type.", "173467459"], @@ -570,57 +518,24 @@ exports[`stricter compilation`] = { "src/module/recall-knowledge.ts:2789490162": [ [83, 8, 6, "Type \'Set\' is not assignable to type \'Set\'.\\n Type \'string | undefined\' is not assignable to type \'string\'.\\n Type \'undefined\' is not assignable to type \'string\'.", "2174869639"] ], - "src/module/rules/elements/base-speed.ts:3776048729": [ - [8, 75, 10, "\'synthetics\' is declared but its value is never read.", "819513877"], - [15, 88, 5, "Parameter \'speed\' implicitly has an \'any\' type.", "195170146"] - ], - "src/module/rules/elements/fixed-proficiency.ts:4292112577": [ + "src/module/rules/elements/fixed-proficiency.ts:2740606708": [ [23, 49, 23, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{ ac: { ability: string; shortform: string; }; }\'.\\n No index signature with a parameter of type \'string\' was found on type \'{ ac: { ability: string; shortform: string; }; }\'.", "995344920"], [32, 24, 33, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'Abilities\'.", "3408718350"], - [40, 59, 23, "\'statisticsModifiers\' is declared but its value is never read.", "2964993122"], [44, 23, 18, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'Skills | Record\'.\\n No index signature with a parameter of type \'string\' was found on type \'Skills | Record\'.", "306189134"], [44, 45, 22, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{ perception: PerceptionData; classDC: ClassDCData; ac: ArmorClassData; initiative: InitiativeData; dexCap: DexterityModifierCapData[]; ... 17 more ...; resolve: { ...; }; } | { ...; }\'.\\n No index signature with a parameter of type \'string\' was found on type \'{ perception: PerceptionData; classDC: ClassDCData; ac: ArmorClassData; initiative: InitiativeData; dexCap: DexterityModifierCapData[]; ... 17 more ...; resolve: { ...; }; } | { ...; }\'.", "3981920995"] ], - "src/module/rules/elements/sense.ts:908945286": [ - [8, 75, 10, "\'synthetics\' is declared but its value is never read.", "819513877"], - [12, 61, 1, "Parameter \'s\' implicitly has an \'any\' type.", "177622"] - ], - "src/module/rules/elements/set-property.ts:3731891633": [ - [8, 64, 4, "\'item\' is declared but its value is never read.", "2087854480"], - [8, 103, 6, "\'tokens\' is declared but its value is never read.", "1754069997"], - [24, 64, 4, "\'item\' is declared but its value is never read.", "2087854480"], - [24, 103, 6, "\'tokens\' is declared but its value is never read.", "1754069997"] - ], - "src/module/rules/elements/toggle-property.ts:1814995957": [ - [8, 60, 10, "\'synthetics\' is declared but its value is never read.", "819513877"] + "src/module/rules/elements/sense.ts:3565090616": [ + [11, 61, 1, "Parameter \'s\' implicitly has an \'any\' type.", "177622"] ], - "src/module/rules/elements/token-effect-icon.ts:1301551144": [ + "src/module/rules/elements/token-effect-icon.ts:2139503383": [ [43, 35, 6, "Parameter \'source\' implicitly has an \'any\' type.", "2169993400"], - [51, 58, 2, "Parameter \'fx\' implicitly has an \'any\' type.", "5860955"], - [62, 18, 9, "\'actorData\' is declared but its value is never read.", "2399949438"] + [51, 58, 2, "Parameter \'fx\' implicitly has an \'any\' type.", "5860955"] ], "src/module/rules/elements/token-size.ts:2456587457": [ [19, 12, 26, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ tiny: number; small: number; medium: number; large: number; huge: number; gargantuan: number; }\'.", "4123781574"] ], - "src/module/rules/rule-element.ts:2470248493": [ - [51, 13, 9, "\'actorData\' is declared but its value is never read.", "2399949438"], - [51, 38, 4, "\'item\' is declared but its value is never read.", "2087854480"], - [51, 58, 12, "\'actorUpdates\' is declared but its value is never read.", "1404544972"], - [51, 77, 6, "\'tokens\' is declared but its value is never read.", "1754069997"], - [62, 13, 9, "\'actorData\' is declared but its value is never read.", "2399949438"], - [62, 38, 4, "\'item\' is declared but its value is never read.", "2087854480"], - [62, 58, 12, "\'actorUpdates\' is declared but its value is never read.", "1404544972"], - [62, 77, 6, "\'tokens\' is declared but its value is never read.", "1754069997"], - [75, 24, 9, "\'actorData\' is declared but its value is never read.", "2399949438"], - [75, 49, 10, "\'synthetics\' is declared but its value is never read.", "819513877"], - [83, 23, 9, "\'actorData\' is declared but its value is never read.", "2399949438"], - [83, 48, 10, "\'synthetics\' is declared but its value is never read.", "819513877"], - [92, 18, 9, "\'actorData\' is declared but its value is never read.", "2399949438"], - [92, 40, 4, "\'item\' is declared but its value is never read.", "2087854480"], - [92, 60, 5, "\'token\' is declared but its value is never read.", "183304158"], + "src/module/rules/rule-element.ts:2730556755": [ [102, 20, 8, "Parameter \'ruleData\' implicitly has an \'any\' type.", "3983415099"], - [102, 30, 4, "Parameter \'item\' implicitly has an \'any\' type.", "2087854480"], - [134, 70, 5, "\'match\' is declared but its value is never read.", "174531222"], [135, 31, 12, "Element implicitly has an \'any\' type because expression of type \'any\' can\'t be used to index type \'{ actor: any; item: any; rule: any; }\'.", "3474459842"] ], "src/module/settings/variant-rules.ts:983869531": [ @@ -657,12 +572,9 @@ exports[`stricter compilation`] = { [137, 39, 1, "Parameter \'r\' implicitly has an \'any\' type.", "177623"], [211, 15, 55, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'Readonly<{ acid: string; bludgeoning: string; chaotic: string; cold: string; electricity: string; evil: string; fire: string; force: string; good: string; lawful: string; mental: string; negative: string; piercing: string; poison: string; positive: string; slashing: string; sonic: string; }>\'.\\n No index signature with a parameter of type \'string\' was found on type \'Readonly<{ acid: string; bludgeoning: string; chaotic: string; cold: string; electricity: string; evil: string; fire: string; force: string; good: string; lawful: string; mental: string; negative: string; piercing: string; poison: string; positive: string; slashing: string; sonic: string; }>\'.", "1732035407"] ], - "src/module/system/damage/damage.ts:1757823338": [ - [42, 24, 46, "No overload matches this call.\\n Overload 1 of 2, \'(...items: ConcatArray[]): never[]\', gave the following error.\\n Argument of type \'string[]\' is not assignable to parameter of type \'ConcatArray\'.\\n The types returned by \'slice(...)\' are incompatible between these types.\\n Type \'string[]\' is not assignable to type \'never[]\'.\\n Type \'string\' is not assignable to type \'never\'.\\n Overload 2 of 2, \'(...items: ConcatArray[]): never[]\', gave the following error.\\n Argument of type \'string[]\' is not assignable to parameter of type \'ConcatArray\'.", "1795448959"], - [43, 24, 48, "No overload matches this call.\\n Overload 1 of 2, \'(...items: ConcatArray[]): never[]\', gave the following error.\\n Argument of type \'string[]\' is not assignable to parameter of type \'ConcatArray\'.\\n Overload 2 of 2, \'(...items: ConcatArray[]): never[]\', gave the following error.\\n Argument of type \'string[]\' is not assignable to parameter of type \'ConcatArray\'.", "218787449"], - [59, 92, 5, "\'first\' is declared but its value is never read.", "171247519"], - [65, 22, 3, "\'key\' is declared but its value is never read.", "193424690"], - [66, 24, 5, "\'value\' is declared but its value is never read.", "189936718"] + "src/module/system/damage/damage.ts:571186852": [ + [41, 24, 46, "No overload matches this call.\\n Overload 1 of 2, \'(...items: ConcatArray[]): never[]\', gave the following error.\\n Argument of type \'string[]\' is not assignable to parameter of type \'ConcatArray\'.\\n The types returned by \'slice(...)\' are incompatible between these types.\\n Type \'string[]\' is not assignable to type \'never[]\'.\\n Type \'string\' is not assignable to type \'never\'.\\n Overload 2 of 2, \'(...items: ConcatArray[]): never[]\', gave the following error.\\n Argument of type \'string[]\' is not assignable to parameter of type \'ConcatArray\'.", "1795448959"], + [42, 24, 48, "No overload matches this call.\\n Overload 1 of 2, \'(...items: ConcatArray[]): never[]\', gave the following error.\\n Argument of type \'string[]\' is not assignable to parameter of type \'ConcatArray\'.\\n Overload 2 of 2, \'(...items: ConcatArray[]): never[]\', gave the following error.\\n Argument of type \'string[]\' is not assignable to parameter of type \'ConcatArray\'.", "218787449"] ], "src/module/system/damage/weapon.ts:4107512752": [ [47, 8, 6, "Parameter \'weapon\' implicitly has an \'any\' type.", "2011618087"], @@ -684,9 +596,9 @@ exports[`stricter compilation`] = { [559, 25, 2, "Parameter \'nm\' implicitly has an \'any\' type.", "5861190"], [560, 26, 2, "Parameter \'nm\' implicitly has an \'any\' type.", "5861190"] ], - "src/module/system/effect-panel.ts:2917564602": [ + "src/module/system/effect-panel.ts:99641435": [ [69, 47, 17, "Object is possibly \'undefined\'.", "3522991458"], - [82, 67, 17, "Object is possibly \'undefined\'.", "3522991458"], + [82, 68, 17, "Object is possibly \'undefined\'.", "3522991458"], [89, 34, 17, "Object is possibly \'undefined\'.", "3522991458"], [114, 20, 4, "Object is possibly \'null\'.", "2087854480"], [114, 49, 4, "Object is possibly \'null\'.", "2087854480"], @@ -716,7 +628,7 @@ exports[`stricter compilation`] = { [218, 12, 12, "Type \'null\' is not assignable to type \'ItemPF2e\'.", "3224621615"], [221, 8, 43, "Type \'ItemPF2e | null\' is not assignable to type \'ItemPF2e\'.\\n Type \'null\' is not assignable to type \'ItemPF2e\'.", "1218488989"] ], - "src/module/system/rolls.ts:1192777479": [ + "src/module/system/rolls.ts:1196725279": [ [37, 12, 24, "Object is possibly \'undefined\'.", "426866902"], [40, 79, 15, "Argument of type \'string[] | undefined\' is not assignable to parameter of type \'string[]\'.\\n Type \'undefined\' is not assignable to type \'string[]\'.", "2021033028"], [45, 16, 15, "Object is possibly \'undefined\'.", "2021033028"], @@ -727,117 +639,53 @@ exports[`stricter compilation`] = { [106, 87, 13, "Object is possibly \'null\'.", "992180339"], [106, 103, 13, "Object is possibly \'null\'.", "3204381064"], [178, 16, 6, "Parameter \'damage\' implicitly has an \'any\' type.", "1116830222"], - [178, 43, 5, "\'event\' is declared but its value is never read.", "165702089"], - [178, 43, 5, "Parameter \'event\' implicitly has an \'any\' type.", "165702089"], - [178, 50, 9, "Parameter \'callback\' implicitly has an \'any\' type.", "3822844403"], + [178, 77, 9, "Parameter \'callback\' implicitly has an \'any\' type.", "3822844403"], [181, 37, 1, "Parameter \'o\' implicitly has an \'any\' type.", "177610"] ], - "src/module/system/trait-selector.ts:9264512": [ + "src/module/system/trait-selector.ts:2820214531": [ [80, 40, 1, "Element implicitly has an \'any\' type because index expression is not of type \'number\'.", "177614"], [81, 45, 1, "Element implicitly has an \'any\' type because index expression is not of type \'number\'.", "177614"], [114, 16, 19, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{}\'.\\n No index signature with a parameter of type \'string\' was found on type \'{}\'.", "3636578787"], - [134, 11, 12, "Parameter \'searchString\' implicitly has an \'any\' type.", "2612787646"], - [136, 61, 1, "\'i\' is declared but its value is never read.", "177612"], [138, 42, 4, "Argument of type \'string | null\' is not assignable to parameter of type \'string\'.\\n Type \'null\' is not assignable to type \'string\'.", "2087876002"], - [143, 22, 4, "Parameter \'html\' implicitly has an \'any\' type.", "2087820472"], - [153, 57, 2, "Parameter \'ev\' implicitly has an \'any\' type.", "5860790"], - [158, 62, 2, "Parameter \'ev\' implicitly has an \'any\' type.", "5860790"], - [167, 63, 2, "Parameter \'ev\' implicitly has an \'any\' type.", "5860790"], - [172, 68, 2, "Parameter \'ev\' implicitly has an \'any\' type.", "5860790"], - [181, 61, 2, "Parameter \'ev\' implicitly has an \'any\' type.", "5860790"], - [185, 62, 2, "Parameter \'ev\' implicitly has an \'any\' type.", "5860790"], - [214, 23, 7, "Parameter \'current\' implicitly has an \'any\' type.", "3937726892"], - [214, 32, 7, "Parameter \'choices\' implicitly has an \'any\' type.", "3821181085"], - [216, 49, 1, "Parameter \'t\' implicitly has an \'any\' type.", "177617"], - [218, 18, 3, "Parameter \'val\' implicitly has an \'any\' type.", "193428222"], - [224, 21, 3, "Parameter \'val\' implicitly has an \'any\' type.", "193428222"] + [216, 23, 7, "Parameter \'current\' implicitly has an \'any\' type.", "3937726892"], + [216, 32, 7, "Parameter \'choices\' implicitly has an \'any\' type.", "3821181085"], + [218, 49, 1, "Parameter \'t\' implicitly has an \'any\' type.", "177617"], + [220, 18, 3, "Parameter \'val\' implicitly has an \'any\' type.", "193428222"], + [226, 21, 3, "Parameter \'val\' implicitly has an \'any\' type.", "193428222"] ], "src/module/system/world-clock/index.ts:1853293595": [ [114, 23, 34, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{ January: string; February: string; March: string; April: string; May: string; June: string; July: string; August: string; September: string; October: string; November: string; December: string; }\'.\\n No index signature with a parameter of type \'string\' was found on type \'{ January: string; February: string; March: string; April: string; May: string; June: string; July: string; August: string; September: string; October: string; November: string; December: string; }\'.", "2128514067"], [126, 23, 38, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{ Monday: string; Tuesday: string; Wednesday: string; Thursday: string; Friday: string; Saturday: string; Sunday: string; }\'.\\n No index signature with a parameter of type \'string\' was found on type \'{ Monday: string; Tuesday: string; Wednesday: string; Thursday: string; Friday: string; Saturday: string; Sunday: string; }\'.", "1647180819"], [139, 15, 42, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{ One: string; Two: string; Few: string; Other: string; }\'.\\n No index signature with a parameter of type \'string\' was found on type \'{ One: string; Two: string; Few: string; Other: string; }\'.", "837659766"] ], - "src/pf2e.ts:4136648642": [ - [27, 27, 3, "\'log\' is declared but its value is never read.", "193412897"], - [28, 30, 3, "\'log\' is declared but its value is never read.", "193412897"], - [34, 36, 4, "\'html\' is declared but its value is never read.", "2087820472"], - [35, 28, 2, "Parameter \'li\' implicitly has an \'any\' type.", "5860992"], + "src/pf2e.ts:3985375696": [ + [40, 12, 7, "Object is possibly \'null\'.", "1236122734"], [41, 12, 7, "Object is possibly \'null\'.", "1236122734"], [42, 12, 7, "Object is possibly \'null\'.", "1236122734"], [43, 12, 7, "Object is possibly \'null\'.", "1236122734"], - [44, 12, 7, "Object is possibly \'null\'.", "1236122734"], - [47, 29, 2, "Parameter \'li\' implicitly has an \'any\' type.", "5860992"], + [52, 12, 7, "Object is possibly \'null\'.", "1236122734"], [53, 12, 7, "Object is possibly \'null\'.", "1236122734"], [54, 12, 7, "Object is possibly \'null\'.", "1236122734"], [55, 12, 7, "Object is possibly \'null\'.", "1236122734"], - [56, 12, 7, "Object is possibly \'null\'.", "1236122734"], - [59, 32, 2, "Parameter \'li\' implicitly has an \'any\' type.", "5860992"], - [69, 29, 7, "Object is possibly \'null\'.", "1236122734"], - [72, 32, 2, "Parameter \'li\' implicitly has an \'any\' type.", "5860992"], - [74, 24, 7, "Object is possibly \'null\'.", "1236122734"], - [75, 26, 7, "Object is possibly \'null\'.", "1236122734"], - [79, 16, 5, "Object is possibly \'null\'.", "169990478"], - [79, 31, 5, "Object is possibly \'null\'.", "169990478"], - [79, 84, 7, "Object is possibly \'null\'.", "1236122734"], - [84, 23, 2, "Parameter \'li\' implicitly has an \'any\' type.", "5860992"], - [86, 24, 7, "Object is possibly \'null\'.", "1236122734"], - [87, 33, 7, "Object is possibly \'null\'.", "1236122734"], - [90, 19, 5, "Object is possibly \'null\'.", "169990478"], - [90, 35, 7, "Object is possibly \'null\'.", "1236122734"], - [100, 23, 2, "Parameter \'li\' implicitly has an \'any\' type.", "5860992"], - [106, 23, 2, "Parameter \'li\' implicitly has an \'any\' type.", "5860992"], - [112, 23, 2, "Parameter \'li\' implicitly has an \'any\' type.", "5860992"], - [118, 23, 2, "Parameter \'li\' implicitly has an \'any\' type.", "5860992"], - [124, 23, 2, "Parameter \'li\' implicitly has an \'any\' type.", "5860992"], - [130, 23, 2, "Parameter \'li\' implicitly has an \'any\' type.", "5860992"], - [130, 58, 39, "Argument of type \'ChatMessage>> | null\' is not assignable to parameter of type \'ChatMessage>>\'.\\n Type \'null\' is not assignable to type \'ChatMessage>>\'.", "1605622680"], - [136, 23, 2, "Parameter \'li\' implicitly has an \'any\' type.", "5860992"], - [136, 58, 39, "Argument of type \'ChatMessage>> | null\' is not assignable to parameter of type \'ChatMessage>>\'.\\n Type \'null\' is not assignable to type \'ChatMessage>>\'.", "1605622680"], - [142, 23, 2, "Parameter \'li\' implicitly has an \'any\' type.", "5860992"], - [142, 58, 39, "Argument of type \'ChatMessage>> | null\' is not assignable to parameter of type \'ChatMessage>>\'.\\n Type \'null\' is not assignable to type \'ChatMessage>>\'.", "1605622680"], - [148, 23, 2, "Parameter \'li\' implicitly has an \'any\' type.", "5860992"], - [148, 58, 39, "Argument of type \'ChatMessage>> | null\' is not assignable to parameter of type \'ChatMessage>>\'.\\n Type \'null\' is not assignable to type \'ChatMessage>>\'.", "1605622680"], - [159, 46, 13, "Type \'undefined\' cannot be used as an index type.", "2739722006"], - [163, 32, 4, "\'data\' is declared but its value is never read.", "2087377941"], - [163, 38, 7, "\'options\' is declared but its value is never read.", "717644789"], - [170, 28, 6, "\'parent\' is declared but its value is never read.", "1898500505"], - [170, 28, 6, "Parameter \'parent\' implicitly has an \'any\' type.", "1898500505"], - [170, 36, 5, "Parameter \'child\' implicitly has an \'any\' type.", "177053519"], - [170, 43, 7, "\'options\' is declared but its value is never read.", "717644789"], - [170, 43, 7, "Parameter \'options\' implicitly has an \'any\' type.", "717644789"], - [170, 52, 6, "Parameter \'userID\' implicitly has an \'any\' type.", "1765117817"], - [187, 25, 6, "Parameter \'parent\' implicitly has an \'any\' type.", "1898500505"], - [187, 33, 5, "Parameter \'child\' implicitly has an \'any\' type.", "177053519"], - [187, 40, 7, "Parameter \'options\' implicitly has an \'any\' type.", "717644789"], - [187, 49, 6, "Parameter \'userID\' implicitly has an \'any\' type.", "1765117817"], - [199, 25, 6, "Parameter \'parent\' implicitly has an \'any\' type.", "1898500505"], - [199, 33, 5, "Parameter \'child\' implicitly has an \'any\' type.", "177053519"], - [199, 40, 7, "Parameter \'options\' implicitly has an \'any\' type.", "717644789"], - [199, 49, 6, "Parameter \'userID\' implicitly has an \'any\' type.", "1765117817"], - [211, 37, 5, "\'child\' is declared but its value is never read.", "177053519"], - [211, 44, 7, "\'options\' is declared but its value is never read.", "717644789"], - [211, 53, 6, "\'userId\' is declared but its value is never read.", "1765117785"], - [218, 24, 4, "\'user\' is declared but its value is never read.", "2087973204"], - [218, 30, 4, "\'diff\' is declared but its value is never read.", "2087386312"], - [218, 36, 7, "\'options\' is declared but its value is never read.", "717644789"], - [218, 45, 2, "\'id\' is declared but its value is never read.", "5861160"], - [222, 28, 5, "\'scene\' is declared but its value is never read.", "195772731"], - [222, 60, 7, "\'options\' is declared but its value is never read.", "717644789"], - [222, 69, 6, "\'userId\' is declared but its value is never read.", "1765117785"], - [234, 28, 5, "\'scene\' is declared but its value is never read.", "195772731"], - [241, 50, 1, "Parameter \'i\' implicitly has an \'any\' type.", "177612"], - [241, 85, 1, "Parameter \'x\' implicitly has an \'any\' type.", "177629"], - [244, 51, 1, "Parameter \'i\' implicitly has an \'any\' type.", "177612"], - [244, 85, 1, "Parameter \'x\' implicitly has an \'any\' type.", "177629"], - [250, 46, 4, "Parameter \'item\' implicitly has an \'any\' type.", "2087854480"], - [257, 25, 5, "\'scene\' is declared but its value is never read.", "195772731"], - [264, 46, 4, "Parameter \'item\' implicitly has an \'any\' type.", "2087854480"], - [267, 48, 4, "Parameter \'item\' implicitly has an \'any\' type.", "2087854480"], - [323, 26, 6, "\'combat\' is declared but its value is never read.", "1544097395"], - [323, 34, 4, "\'diff\' is declared but its value is never read.", "2087386312"], - [323, 40, 7, "\'options\' is declared but its value is never read.", "717644789"], - [323, 49, 6, "\'userID\' is declared but its value is never read.", "1765117817"], - [324, 4, 21, "Object is possibly \'undefined\'.", "3711663627"] + [68, 29, 7, "Object is possibly \'null\'.", "1236122734"], + [73, 24, 7, "Object is possibly \'null\'.", "1236122734"], + [74, 26, 7, "Object is possibly \'null\'.", "1236122734"], + [78, 16, 5, "Object is possibly \'null\'.", "169990478"], + [78, 31, 5, "Object is possibly \'null\'.", "169990478"], + [78, 84, 7, "Object is possibly \'null\'.", "1236122734"], + [85, 24, 7, "Object is possibly \'null\'.", "1236122734"], + [86, 33, 7, "Object is possibly \'null\'.", "1236122734"], + [89, 19, 5, "Object is possibly \'null\'.", "169990478"], + [89, 35, 7, "Object is possibly \'null\'.", "1236122734"], + [129, 58, 39, "Argument of type \'ChatMessage>> | null\' is not assignable to parameter of type \'ChatMessage>>\'.\\n Type \'null\' is not assignable to type \'ChatMessage>>\'.", "1605622680"], + [135, 58, 39, "Argument of type \'ChatMessage>> | null\' is not assignable to parameter of type \'ChatMessage>>\'.\\n Type \'null\' is not assignable to type \'ChatMessage>>\'.", "1605622680"], + [141, 58, 39, "Argument of type \'ChatMessage>> | null\' is not assignable to parameter of type \'ChatMessage>>\'.\\n Type \'null\' is not assignable to type \'ChatMessage>>\'.", "1605622680"], + [147, 58, 39, "Argument of type \'ChatMessage>> | null\' is not assignable to parameter of type \'ChatMessage>>\'.\\n Type \'null\' is not assignable to type \'ChatMessage>>\'.", "1605622680"], + [157, 46, 13, "Type \'undefined\' cannot be used as an index type.", "2739722006"], + [243, 93, 1, "Object is possibly \'undefined\'.", "177629"], + [243, 110, 1, "Object is possibly \'undefined\'.", "177612"], + [246, 93, 1, "Object is possibly \'undefined\'.", "177629"], + [246, 110, 1, "Object is possibly \'undefined\'.", "177612"] ], "src/scripts/actor/status-effects.ts:3110844344": [ [66, 12, 29, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{}\'.\\n No index signature with a parameter of type \'string\' was found on type \'{}\'.", "1681612056"], @@ -865,30 +713,18 @@ exports[`stricter compilation`] = { [7, 32, 14, "Object is possibly \'null\'.", "2758697215"], [8, 34, 14, "Object is possibly \'null\'.", "2758697215"] ], - "src/scripts/dice.ts:3077979661": [ - [48, 8, 9, "\'advantage\' is declared but its value is never read.", "4039243726"], - [49, 8, 11, "\'situational\' is declared but its value is never read.", "2632299150"], - [50, 8, 11, "\'fastForward\' is declared but its value is never read.", "337554590"], - [75, 23, 9, "Parameter \'rollParts\' implicitly has an \'any\' type.", "2722079100"], - [75, 34, 3, "Parameter \'adv\' implicitly has an \'any\' type.", "193409622"], - [75, 39, 5, "Parameter \'form\' implicitly has an \'any\' type.", "171184460"], - [143, 16, 4, "Variable \'roll\' implicitly has type \'any\' in some locations where its type cannot be determined.", "2088305240"], - [172, 36, 4, "Variable \'roll\' implicitly has an \'any\' type.", "2088305240"], - [208, 8, 5, "\'actor\' is declared but its value is never read.", "169990478"], - [235, 23, 9, "Parameter \'rollParts\' implicitly has an \'any\' type.", "2722079100"], - [235, 34, 4, "Parameter \'crit\' implicitly has an \'any\' type.", "2087776457"], - [235, 40, 5, "Parameter \'form\' implicitly has an \'any\' type.", "171184460"], - [303, 12, 4, "Variable \'roll\' implicitly has type \'any\' in some locations where its type cannot be determined.", "2088305240"], - [305, 27, 8, "Argument of type \'string | undefined\' is not assignable to parameter of type \'string\'.\\n Type \'undefined\' is not assignable to type \'string\'.", "294681333"], - [328, 45, 4, "Variable \'roll\' implicitly has an \'any\' type.", "2088305240"], - [337, 10, 3, "Parameter \'add\' implicitly has an \'any\' type.", "193409604"], - [337, 15, 8, "Parameter \'multiply\' implicitly has an \'any\' type.", "270968777"], - [342, 37, 1, "Parameter \'t\' implicitly has an \'any\' type.", "177617"], - [343, 28, 5, "\'match\' is declared but its value is never read.", "174531222"], - [343, 28, 5, "Parameter \'match\' implicitly has an \'any\' type.", "174531222"], - [343, 35, 2, "Parameter \'nd\' implicitly has an \'any\' type.", "5861199"], - [343, 39, 1, "Parameter \'d\' implicitly has an \'any\' type.", "177601"], - [343, 42, 4, "Parameter \'mods\' implicitly has an \'any\' type.", "2087698480"] + "src/scripts/dice.ts:1560540118": [ + [69, 23, 9, "Parameter \'rollParts\' implicitly has an \'any\' type.", "2722079100"], + [69, 34, 3, "Parameter \'adv\' implicitly has an \'any\' type.", "193409622"], + [69, 39, 5, "Parameter \'form\' implicitly has an \'any\' type.", "171184460"], + [137, 16, 4, "Variable \'roll\' implicitly has type \'any\' in some locations where its type cannot be determined.", "2088305240"], + [166, 36, 4, "Variable \'roll\' implicitly has an \'any\' type.", "2088305240"], + [228, 23, 9, "Parameter \'rollParts\' implicitly has an \'any\' type.", "2722079100"], + [228, 34, 4, "Parameter \'crit\' implicitly has an \'any\' type.", "2087776457"], + [228, 40, 5, "Parameter \'form\' implicitly has an \'any\' type.", "171184460"], + [296, 12, 4, "Variable \'roll\' implicitly has type \'any\' in some locations where its type cannot be determined.", "2088305240"], + [298, 27, 8, "Argument of type \'string | undefined\' is not assignable to parameter of type \'string\'.\\n Type \'undefined\' is not assignable to type \'string\'.", "294681333"], + [321, 45, 4, "Variable \'roll\' implicitly has an \'any\' type.", "2088305240"] ], "src/scripts/hooks/setup.ts:3484729149": [ [112, 12, 14, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{ chatDamageButtonShieldToggle: boolean; statusEffects: { overruledByModule: boolean; lastIconType: StatusEffectIconType; effectsIconFolder: string; effectsIconFileType: string; keepFoundryStatusEffects: boolean; foundryStatusEffects: string[]; }; ... 88 more ...; Item: { ...; }; }\'.\\n No index signature with a parameter of type \'string\' was found on type \'{ chatDamageButtonShieldToggle: boolean; statusEffects: { overruledByModule: boolean; lastIconType: StatusEffectIconType; effectsIconFolder: string; effectsIconFileType: string; keepFoundryStatusEffects: boolean; foundryStatusEffects: string[]; }; ... 88 more ...; Item: { ...; }; }\'.", "2970018665"], @@ -1025,39 +861,20 @@ exports[`stricter compilation`] = { [283, 16, 50, "Type \'TreasureData\' is not assignable to type \'RecursivePartial | RecursivePartial | RecursivePartial | ... 15 more ... | RecursivePartial<...>\'.", "2770170968"], [299, 20, 50, "Type \'TreasureData\' is not assignable to type \'RecursivePartial | RecursivePartial | RecursivePartial | ... 15 more ... | RecursivePartial<...>\'.", "2770170968"] ], - "tests/module/migration.test.ts:2312926046": [ - [23, 16, 7, "\'context\' is declared but its value is never read.", "3716929786"], - [24, 23, 13, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{ worldSchemaVersion: number; }\'.\\n No index signature with a parameter of type \'string\' was found on type \'{ worldSchemaVersion: number; }\'.", "3438702673"], - [26, 16, 7, "\'context\' is declared but its value is never read.", "3716929786"], - [27, 16, 13, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{ worldSchemaVersion: number; }\'.\\n No index signature with a parameter of type \'string\' was found on type \'{ worldSchemaVersion: number; }\'.", "3438702673"], - [63, 17, 3, "\'msg\' is declared but its value is never read.", "193414780"], - [63, 30, 5, "\'other\' is declared but its value is never read.", "182229153"], - [91, 36, 5, "\'actor\' is declared but its value is never read.", "169990478"], - [98, 36, 5, "\'actor\' is declared but its value is never read.", "169990478"], - [197, 40, 5, "\'actor\' is declared but its value is never read.", "169990478"], - [204, 40, 5, "\'actor\' is declared but its value is never read.", "169990478"] - ], - "tests/setup.ts:3076395142": [ - [3, 27, 4, "Parameter \'name\' implicitly has an \'any\' type.", "2087876002"], - [18, 14, 6, "\'module\' is declared but its value is never read.", "1465948607"], - [18, 14, 6, "Parameter \'module\' implicitly has an \'any\' type.", "1465948607"], - [18, 22, 10, "Parameter \'settingKey\' implicitly has an \'any\' type.", "3923127780"], - [41, 15, 12, "\'compendiumID\' is declared but its value is never read.", "3714276071"], - [41, 15, 12, "Parameter \'compendiumID\' implicitly has an \'any\' type.", "3714276071"], - [41, 29, 8, "\'quantity\' is declared but its value is never read.", "1014043998"], - [41, 29, 8, "Parameter \'quantity\' implicitly has an \'any\' type.", "1014043998"], - [43, 27, 9, "Not all code paths return a value.", "892774129"], - [43, 28, 2, "Parameter \'id\' implicitly has an \'any\' type.", "5861160"], - [60, 17, 5, "Parameter \'token\' implicitly has an \'any\' type.", "183304158"], - [72, 21, 6, "Parameter \'object\' implicitly has an \'any\' type.", "1687850384"], - [72, 29, 3, "Parameter \'key\' implicitly has an \'any\' type.", "193424690"], - [72, 34, 5, "Parameter \'value\' implicitly has an \'any\' type.", "189936718"], - [79, 31, 1, "Parameter \'o\' implicitly has an \'any\' type.", "177610"], - [79, 34, 1, "Parameter \'i\' implicitly has an \'any\' type.", "177612"], - [93, 19, 8, "Parameter \'original\' implicitly has an \'any\' type.", "3343918940"], - [97, 22, 3, "Parameter \'obj\' implicitly has an \'any\' type.", "193420290"], - [108, 4, 8, "Parameter \'original\' implicitly has an \'any\' type.", "3343918940"], - [167, 20, 1, "Argument of type \'unknown\' is not assignable to parameter of type \'{} | undefined\'.\\n Type \'unknown\' is not assignable to type \'{}\'.", "177619"] + "tests/module/migration.test.ts:1538292704": [ + [25, 23, 13, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{ worldSchemaVersion: number; }\'.\\n No index signature with a parameter of type \'string\' was found on type \'{ worldSchemaVersion: number; }\'.", "3438702673"], + [28, 16, 13, "Element implicitly has an \'any\' type because expression of type \'string\' can\'t be used to index type \'{ worldSchemaVersion: number; }\'.\\n No index signature with a parameter of type \'string\' was found on type \'{ worldSchemaVersion: number; }\'.", "3438702673"] + ], + "tests/setup.ts:1866916009": [ + [62, 17, 5, "Parameter \'token\' implicitly has an \'any\' type.", "183304158"], + [74, 21, 6, "Parameter \'object\' implicitly has an \'any\' type.", "1687850384"], + [74, 29, 3, "Parameter \'key\' implicitly has an \'any\' type.", "193424690"], + [74, 34, 5, "Parameter \'value\' implicitly has an \'any\' type.", "189936718"], + [81, 31, 1, "Parameter \'o\' implicitly has an \'any\' type.", "177610"], + [81, 34, 1, "Parameter \'i\' implicitly has an \'any\' type.", "177612"], + [99, 22, 3, "Parameter \'obj\' implicitly has an \'any\' type.", "193420290"], + [110, 4, 8, "Parameter \'original\' implicitly has an \'any\' type.", "3343918940"], + [169, 20, 1, "Argument of type \'unknown\' is not assignable to parameter of type \'{} | undefined\'.\\n Type \'unknown\' is not assignable to type \'{}\'.", "177619"] ] }` }; diff --git a/.betterer.ts b/.betterer.ts index 42768d51806..adff16a48df 100644 --- a/.betterer.ts +++ b/.betterer.ts @@ -5,7 +5,6 @@ export default { 'stricter compilation': typescript('./tsconfig.json', { strict: true, noImplicitReturns: true, - noUnusedParameters: true, }).include( './packs/scripts/*.ts', './packs/scripts/packman/*.ts', diff --git a/src/module/actor/base.ts b/src/module/actor/base.ts index 233b8685b7a..c87d96cf647 100644 --- a/src/module/actor/base.ts +++ b/src/module/actor/base.ts @@ -727,15 +727,12 @@ export class ActorPF2e extends Actor { } } - /* -------------------------------------------- */ - /** * Apply rolled dice damage to the token or tokens which are currently controlled. * This allows for damage to be scaled by a multiplier to account for healing, critical hits, or resistance * - * @param {JQuery} roll The chat entry which contains the roll data - * @param {Number} multiplier A damage multiplier to apply to the rolled damage. - * @return {Promise} + * @param roll The chat entry which contains the roll data + * @param multiplier A damage multiplier to apply to the rolled damage. */ static async applyDamage(roll: JQuery, multiplier: number, attribute = 'attributes.hp', modifier = 0) { if (canvas.tokens.controlled.length > 0) { @@ -938,10 +935,10 @@ export class ActorPF2e extends Actor { /** * Handle how changes to a Token attribute bar are applied to the Actor. * This allows for game systems to override this behavior and deploy special logic. - * @param {string} attribute The attribute path - * @param {number} value The target attribute value - * @param {boolean} isDelta Whether the number represents a relative change (true) or an absolute change (false) - * @param {boolean} isBar Whether the new value is part of an attribute bar, or just a direct value + * @param attribute The attribute path + * @param value The target attribute value + * @param isDelta Whether the number represents a relative change (true) or an absolute change (false) + * @param isBar Whether the new value is part of an attribute bar, or just a direct value */ async modifyTokenAttribute(attribute: string, value: number, isDelta = false, isBar = true): Promise { if (value === undefined || value === null || Number.isNaN(value)) { diff --git a/src/module/actor/sheet/updated-npc-sheet.ts b/src/module/actor/sheet/updated-npc-sheet.ts index 7923e5d89ca..d43c2048745 100644 --- a/src/module/actor/sheet/updated-npc-sheet.ts +++ b/src/module/actor/sheet/updated-npc-sheet.ts @@ -2,6 +2,7 @@ import { NPCSheetPF2e } from './npc'; import { DicePF2e } from '@scripts/dice'; import { ModifierPF2e, MODIFIER_TYPE } from '../../modifiers'; import { ActorPF2e } from '../base'; +import { ItemPF2e } from '@item/base'; /** * @category Other @@ -256,7 +257,7 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e { * If the creature has limits on how many times or how often it can use an ability * (such as a spellcaster’s spells or a dragon’s Breath Weapon), in/decrease the damage by 4 instead. */ - _applyAdjustmentToData(actorData, increase, adjustBackToNormal) { + _applyAdjustmentToData(actorData, increase: boolean, adjustBackToNormal: boolean) { const positive = increase ? 1 : -1; const mod = 2 * positive; @@ -329,15 +330,15 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e { } } } else if (item.type === 'action') { - let actionDescr = getProperty(item.data, 'description.value'); + let actionDescr: string | undefined = getProperty(item.data, 'description.value'); if (actionDescr !== undefined) { - actionDescr = actionDescr.replace(/DC (\d+)+/g, (match, number) => { + actionDescr = actionDescr.replace(/DC (\d+)+/g, (_match, number) => { return `DC ${parseInt(number, 10) + mod}`; }); // Assuming that all abilities with damage in the description are damage attacks that cant be done each turn and as increase twice as much. actionDescr = actionDescr.replace( /(\d+)?d(\d+)([+-]\d+)?(\s+[a-z]+[\s.,])?/g, - (match, a, b, c, d) => { + (_match, a, b, c, d) => { // match: '1d4+1 rounds.', a: 1, b: 4, c: '+1', d: ' rounds.' const bonus = parseInt(c, 10); if (d?.substring(1, 7) !== 'rounds') { @@ -426,15 +427,14 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e { * Toggle expansion of an attackEffect ability if it exists. * */ - expandAttackEffect(attackEffectName, event, triggerItem) { + expandAttackEffect(attackEffectName: string, event: JQuery.TriggeredEvent, triggerItem: ItemPF2e) { const actionList = $(event.currentTarget).parents('form').find('.item.action-item'); let toggledAnything = false; const mAbilities = CONFIG.PF2E.monsterAbilities(); - console.log('PF2e System | mAbilities: ', mAbilities); - actionList.each((index, element) => { + actionList.each((_index, element) => { // 'this' = element found if ($(element).attr('data-item-name').trim().toLowerCase() === attackEffectName.trim().toLowerCase()) { - $(element).find('h4').click(); + $(element).find('h4').trigger('click'); toggledAnything = true; } }); @@ -443,7 +443,7 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e { if (newAbilityInfo) { const newAction = { name: attackEffectName, - type: 'action', + type: 'action' as const, data: { actionType: { value: newAbilityInfo.actionType }, actionCategory: { value: 'offensive' }, @@ -464,14 +464,14 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e { } } - triggerItem.actor.createOwnedItem(newAction, { displaySheet: false }); + triggerItem.actor?.createOwnedItem(newAction, { displaySheet: false }); } } } /* -------------------------------------------- */ /* Event Listeners and Handlers - /* -------------------------------------------- */ + /* -------------------------------------------- */ /** * Activate event listeners using the prepared sheet HTML @@ -481,23 +481,23 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e { super.activateListeners(html); if (!this.options.editable) return; - html.find('.npc-detail-text textarea').focusout(async (event) => { + html.find('.npc-detail-text textarea').on('focusout', async (event) => { event.target.style.height = '5px'; event.target.style.height = `${event.target.scrollHeight}px`; }); - html.find('.npc-detail-text textarea').each((index, element) => { + html.find('.npc-detail-text textarea').each((_index, element) => { element.style.height = '5px'; element.style.height = `${element.scrollHeight}px`; }); - html.find('.isNPCEditable').change((ev) => { - this.actor.setFlag('pf2e', 'editNPC', { value: ev.target.checked }); + html.find('.isNPCEditable').on('change', (event) => { + this.actor.setFlag('pf2e', 'editNPC', { value: event.target.checked }); }); // NPC Weapon Rolling - html.find('button.npc-damageroll').click((ev) => { + html.find('button.npc-damageroll').on('click', (ev) => { ev.preventDefault(); ev.stopPropagation(); @@ -516,7 +516,7 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e { } }); - html.find('button.npc-attackEffect').click((ev) => { + html.find('button.npc-attackEffect').on('click', (ev) => { ev.preventDefault(); ev.stopPropagation(); @@ -541,7 +541,7 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e { } }); - html.find('a.npc-elite-adjustment').click((e) => { + html.find('a.npc-elite-adjustment').on('click', (e) => { e.preventDefault(); console.log(`PF2e System | Adding Elite adjustment to NPC`); const eliteButton = $(e.currentTarget); @@ -550,7 +550,7 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e { weakButton.toggleClass('hidden'); this.npcAdjustment(eliteButton.hasClass('active')); }); - html.find('a.npc-weak-adjustment').click((e) => { + html.find('a.npc-weak-adjustment').on('click', (e) => { e.preventDefault(); console.log(`PF2e System | Adding Weak adjustment to NPC`); const weakButton = $(e.currentTarget); diff --git a/src/module/dc.ts b/src/module/dc.ts index bf4a54d6630..18c312ba5b4 100644 --- a/src/module/dc.ts +++ b/src/module/dc.ts @@ -150,5 +150,5 @@ export function combineDCAdjustments(first: DCAdjustment, second: DCAdjustment): */ export function createDifficultyScale(dc: number, startAt: DCAdjustment): number[] { const beginAtIndex = adjustmentScale.indexOf(startAt); - return adjustmentScale.filter((value, index) => index >= beginAtIndex).map((value) => adjustDC(dc, value)); + return adjustmentScale.filter((_value, index) => index >= beginAtIndex).map((value) => adjustDC(dc, value)); } diff --git a/src/module/item/data-definitions.ts b/src/module/item/data-definitions.ts index a88a89c77c0..061ca336723 100644 --- a/src/module/item/data-definitions.ts +++ b/src/module/item/data-definitions.ts @@ -759,7 +759,7 @@ export interface EffectDetailsData extends ItemDescriptionData { }; start?: { value: number; - initiative: number; + initiative: number | null; }; } diff --git a/src/module/item/encumbrance.ts b/src/module/item/encumbrance.ts index 253511ead5a..45a4428d9c9 100644 --- a/src/module/item/encumbrance.ts +++ b/src/module/item/encumbrance.ts @@ -61,7 +61,7 @@ export function calculateEncumbrance( bonusBulkEncumbrance: number, bonusBulkLimit: number, combinedBulk: Bulk, - actorSize: Size = 'med', + _actorSize: Size = 'med', ): InventoryWeight { const encumberedAt = Math.floor(strengthModifier + bonusBulkEncumbrance + 5); const limit = Math.floor(strengthModifier + bonusBulkLimit + 10); diff --git a/src/module/item/runes.ts b/src/module/item/runes.ts index 6b76aa3e5a6..31bfefc7928 100644 --- a/src/module/item/runes.ts +++ b/src/module/item/runes.ts @@ -2,6 +2,9 @@ import { isBlank, toNumber } from '../utils'; import { DamageDieSize } from '../system/damage/damage'; import { ArmorData, ArmorDetailsData, WeaponData, WeaponDetailsData } from './data-definitions'; import { PF2DiceModifier } from '../modifiers'; +import { ConfigPF2e } from '@scripts/config'; + +type WeaponPropertyRuneType = keyof ConfigPF2e['PF2E']['weaponPropertyRunes']; export function getPropertySlots(itemData: WeaponData | ArmorData): number { let slots = 0; @@ -15,12 +18,12 @@ export function getPropertySlots(itemData: WeaponData | ArmorData): number { return slots; } -export function getPropertyRunes(itemData: WeaponData | ArmorData, slots: number): string[] { - const runes = []; +export function getPropertyRunes(itemData: WeaponData | ArmorData, slots: number): WeaponPropertyRuneType[] { + const runes: WeaponPropertyRuneType[] = []; type RuneIndex = 'propertyRune1' | 'propertyRune2' | 'propertyRune3' | 'propertyRune4'; for (let i = 1; i <= slots; i += 1) { - const rune = itemData.data[`propertyRune${i}` as RuneIndex]?.value; - if (!isBlank(rune)) { + const rune = itemData.data[`propertyRune${i}` as RuneIndex]?.value as WeaponPropertyRuneType | undefined; + if (rune && !isBlank(rune)) { runes.push(rune); } } @@ -65,7 +68,7 @@ interface RuneDiceModifier { } function toModifier( - rune, + rune: WeaponPropertyRuneType, { damageType = undefined, dieSize = 'd6', diceNumber = 1 }: RuneDiceModifier, ): PF2DiceModifier { const traits = []; diff --git a/src/module/migrations/574-migrate-bulk.ts b/src/module/migrations/574-migrate-bulk.ts index f316d7f8f71..7a6ca27861d 100644 --- a/src/module/migrations/574-migrate-bulk.ts +++ b/src/module/migrations/574-migrate-bulk.ts @@ -3,7 +3,7 @@ import { MigrationBase } from './base'; export class Migration574MigrateBulk extends MigrationBase { static version = 0.574; - async updateItem(item: any, actor?: any) { + async updateItem(item: any) { const itemName = item?.name?.trim(); if (['weapon', 'melee', 'armor', 'equipment', 'consumable', 'backpack'].includes(item.type)) { // migrate stacked items diff --git a/src/module/migrations/578-migrate-item-image-paths.ts b/src/module/migrations/578-migrate-item-image-paths.ts index 9d15e2c6d11..86f78ae770a 100644 --- a/src/module/migrations/578-migrate-item-image-paths.ts +++ b/src/module/migrations/578-migrate-item-image-paths.ts @@ -1,8 +1,9 @@ import { MigrationBase } from './base'; +import { ItemDataPF2e } from '@item/data-definitions'; export class Migration578MigrateItemImagePaths extends MigrationBase { static version = 0.578; - async updateItem(item: any, actor?: any) { + async updateItem(item: ItemDataPF2e) { const itemImage = item.img; // folder name change diff --git a/src/module/migrations/579-add-container-attributes.ts b/src/module/migrations/579-add-container-attributes.ts index c02afe6a604..9f227d1043b 100644 --- a/src/module/migrations/579-add-container-attributes.ts +++ b/src/module/migrations/579-add-container-attributes.ts @@ -2,7 +2,7 @@ import { MigrationBase } from './base'; export class Migration579AddContainerAttributes extends MigrationBase { static version = 0.579; - async updateItem(item: any, actor?: any) { + async updateItem(item: any) { if (['weapon', 'melee', 'armor', 'equipment', 'consumable', 'backpack'].includes(item.type)) { const itemName = item?.name?.trim(); if (itemName === 'Backpack') { diff --git a/src/module/migrations/580-add-item-rarity-and-level.ts b/src/module/migrations/580-add-item-rarity-and-level.ts index 983aec7c9cd..cc58b0bb78b 100644 --- a/src/module/migrations/580-add-item-rarity-and-level.ts +++ b/src/module/migrations/580-add-item-rarity-and-level.ts @@ -2,7 +2,7 @@ import { MigrationBase } from './base'; export class Migration580AddItemRarityAndLevel extends MigrationBase { static version = 0.58; - async updateItem(item: any, actor?: any) { + async updateItem(item: any) { item.data.rarity = { value: 'common' }; if (['treasure', 'backpack'].includes(item.type)) { diff --git a/src/module/migrations/583-add-hp-threshold-hardness.ts b/src/module/migrations/583-add-hp-threshold-hardness.ts index a95df474483..10935b49766 100644 --- a/src/module/migrations/583-add-hp-threshold-hardness.ts +++ b/src/module/migrations/583-add-hp-threshold-hardness.ts @@ -2,7 +2,7 @@ import { MigrationBase } from './base'; export class Migration583AddHpThresholdHardness extends MigrationBase { static version = 0.583; - async updateItem(item: any, actor?: any) { + async updateItem(item: any) { if (['weapon', 'melee', 'armor', 'equipment', 'consumable', 'backpack'].includes(item.type)) { item.data.brokenThreshold = { value: 0 }; item.data.hp = { value: 0 }; diff --git a/src/module/migrations/586-add-splash-damage.ts b/src/module/migrations/586-add-splash-damage.ts index 2099ba98c60..83693640b0e 100644 --- a/src/module/migrations/586-add-splash-damage.ts +++ b/src/module/migrations/586-add-splash-damage.ts @@ -2,7 +2,7 @@ import { MigrationBase } from './base'; export class Migration586AddSplashDamage extends MigrationBase { static version = 0.586; - async updateItem(item: any, actor?: any) { + async updateItem(item: any) { if (['weapon', 'melee'].includes(item.type)) { item.data.splashDamage = { value: '0' }; } diff --git a/src/module/migrations/base.ts b/src/module/migrations/base.ts index bc201fdc847..857fdb772e2 100644 --- a/src/module/migrations/base.ts +++ b/src/module/migrations/base.ts @@ -30,7 +30,7 @@ export abstract class MigrationBase { * Update the actor to the latest schema version. * @param actor This should be effectively a `ActorDataPF2e` from the previous version. */ - async updateActor(actor: any): Promise {} + async updateActor(_actor: ActorDataPF2e): Promise {} /** * Update the item to the latest schema version. @@ -38,7 +38,7 @@ export abstract class MigrationBase { * @param actor If the item is part of an actor, this is set to the actor. For instance * if you only want to update items that are on a npc you can do that here. */ - async updateItem(item: ItemDataPF2e, actor?: ActorDataPF2e): Promise {} + async updateItem(_item: ItemDataPF2e, _actor?: ActorDataPF2e): Promise {} /** * Update the user to the latest schema version. diff --git a/src/module/packs/compendium-browser.ts b/src/module/packs/compendium-browser.ts index 932838ed59d..7319cdb5d83 100644 --- a/src/module/packs/compendium-browser.ts +++ b/src/module/packs/compendium-browser.ts @@ -787,7 +787,7 @@ class CompendiumBrowser extends Application { } hookCompendiumList() { - Hooks.on('renderCompendiumDirectory', (app, html, data) => { + Hooks.on('renderCompendiumDirectory', (_app, html) => { if (html.find('.compendium-browser-btn').length) { console.error('Compendium Browser - Already hooked'); return; @@ -805,13 +805,13 @@ class CompendiumBrowser extends Application { target.append(importButton); // Handle button clicks - importButton.click((ev) => { + importButton.on('click', (ev) => { ev.preventDefault(); this.render(true); }); }); - Hooks.on('renderActorDirectory', (app, html, data) => { + Hooks.on('renderActorDirectory', (_app, html) => { if (html.find('.bestiary-browser-btn').length) { console.error('Compendium Browser - Already hooked'); return; @@ -827,15 +827,15 @@ class CompendiumBrowser extends Application { } // Handle button clicks - bestiaryImportButton.click((ev) => { + bestiaryImportButton.on('click', (ev) => { ev.preventDefault(); this.openTab('bestiary'); }); }); } - clearObject(obj) { - return Object.fromEntries(Object.entries(obj).filter(([key, value]) => value)); + clearObject(obj: object) { + return Object.fromEntries(Object.entries(obj).filter(([_key, value]) => value)); } _getActionImg(action) { @@ -863,7 +863,7 @@ class CompendiumBrowser extends Application { ); } - async filterSpells(li) { + async filterSpells(li: JQuery) { let counter = 0; li.hide(); for (const spell of li) { @@ -879,7 +879,7 @@ class CompendiumBrowser extends Application { } } - getFilterResult(element) { + getFilterResult(element: HTMLElement) { if (this.sorters.text !== '') { const searches = this.sorters.text.split(','); for (const search of searches) { @@ -926,13 +926,13 @@ class CompendiumBrowser extends Application { return this.isWithinFilteredBounds(element); } - isWithinFilteredBounds(element): boolean { + isWithinFilteredBounds(element: HTMLElement): boolean { const rangeIdentifiers = Object.keys(this.ranges); for (const range of rangeIdentifiers) { const lowerBound = this.ranges[range].lowerBound; const upperBound = this.ranges[range].upperBound; - const filter = +element.dataset[range]; + const filter = Number(element.dataset[range] ?? 0); if (filter < lowerBound || upperBound < filter) { return false; @@ -1001,4 +1001,3 @@ class CompendiumBrowser extends Application { } export const compendiumBrowser = new CompendiumBrowser(); -// vim: ts=2 sw=2 et diff --git a/src/module/rules/elements/base-speed.ts b/src/module/rules/elements/base-speed.ts index 0192ed4eeb9..b8e0137ac37 100644 --- a/src/module/rules/elements/base-speed.ts +++ b/src/module/rules/elements/base-speed.ts @@ -1,19 +1,18 @@ import { PF2RuleElement } from '../rule-element'; -import { PF2RuleElementSynthetics } from '../rules-data-definitions'; import { CharacterData, FamiliarData, NPCData } from '@actor/data-definitions'; /** * @category RuleElement */ export class PF2BaseSpeedRuleElement extends PF2RuleElement { - onBeforePrepareData(actorData: CharacterData | NPCData | FamiliarData, synthetics: PF2RuleElementSynthetics) { + onBeforePrepareData(actorData: CharacterData | NPCData | FamiliarData) { const value = super.resolveValue(this.ruleData.value, this.ruleData, this.item, actorData); const label = super.getDefaultLabel(this.ruleData, this.item); if (this.ruleData.selector && label && value) { - const selector = this.ruleData.selector.endsWith('-speed') + const selector: string = this.ruleData.selector.endsWith('-speed') ? this.ruleData.selector.substring(-6) : this.ruleData.selector; - const existing = (actorData as any).data.attributes.speed.otherSpeeds.find((speed) => { + const existing = (actorData as any).data.attributes.speed.otherSpeeds.find((speed: { type: string }) => { return speed.type === selector; }); if (existing) { diff --git a/src/module/rules/elements/dexterity-modifier-cap.ts b/src/module/rules/elements/dexterity-modifier-cap.ts index 2d772fdb992..84eb205a6a0 100644 --- a/src/module/rules/elements/dexterity-modifier-cap.ts +++ b/src/module/rules/elements/dexterity-modifier-cap.ts @@ -1,12 +1,11 @@ import { CharacterData, NPCData } from '@actor/data-definitions'; import { PF2RuleElement } from '../rule-element'; -import { PF2RuleElementSynthetics } from '../rules-data-definitions'; /** * @category RuleElement */ export class PF2DexterityModifierCapRuleElement extends PF2RuleElement { - onBeforePrepareData(actorData: CharacterData | NPCData, _synthetics: PF2RuleElementSynthetics) { + onBeforePrepareData(actorData: CharacterData | NPCData) { const label = super.getDefaultLabel(this.ruleData, this.item); const value = super.resolveValue(this.ruleData.value, this.ruleData, this.item, actorData); if (label && value !== undefined) { diff --git a/src/module/rules/elements/fixed-proficiency.ts b/src/module/rules/elements/fixed-proficiency.ts index d3490456439..0a494dda365 100644 --- a/src/module/rules/elements/fixed-proficiency.ts +++ b/src/module/rules/elements/fixed-proficiency.ts @@ -38,7 +38,7 @@ export class PF2FixedProficiencyRuleElement extends PF2RuleElement { } } - onAfterPrepareData(actorData: CharacterData | NPCData, { statisticsModifiers }: PF2RuleElementSynthetics) { + onAfterPrepareData(actorData: CharacterData | NPCData) { const selector = super.resolveInjectedProperties(this.ruleData.selector, this.ruleData, this.item, actorData); const { data } = actorData; const skill: SkillAbbreviation | string = SKILL_EXPANDED[selector]?.shortform ?? selector; diff --git a/src/module/rules/elements/sense.ts b/src/module/rules/elements/sense.ts index 826e8e6e665..862b6a4fefb 100644 --- a/src/module/rules/elements/sense.ts +++ b/src/module/rules/elements/sense.ts @@ -1,12 +1,11 @@ import { PF2RuleElement } from '../rule-element'; -import { PF2RuleElementSynthetics } from '../rules-data-definitions'; import { CharacterData, FamiliarData, NPCData } from '@actor/data-definitions'; /** * @category RuleElement */ export class PF2SenseRuleElement extends PF2RuleElement { - onBeforePrepareData(actorData: CharacterData | NPCData | FamiliarData, synthetics: PF2RuleElementSynthetics) { + onBeforePrepareData(actorData: CharacterData | NPCData | FamiliarData) { const label = super.getDefaultLabel(this.ruleData, this.item); const range = super.resolveValue(this.ruleData.range, this.ruleData, this.item, actorData); if (this.ruleData.selector && label) { diff --git a/src/module/rules/elements/set-property.ts b/src/module/rules/elements/set-property.ts index 9230633409c..f2f28eabc25 100644 --- a/src/module/rules/elements/set-property.ts +++ b/src/module/rules/elements/set-property.ts @@ -6,7 +6,7 @@ import { PF2RuleElement } from '../rule-element'; * @category RuleElement */ export class PF2SetPropertyRuleElement extends PF2RuleElement { - onCreate(actorData: CharacterData | NPCData | FamiliarData, item: ItemDataPF2e, actorUpdates: any, tokens: any[]) { + onCreate(actorData: CharacterData | NPCData | FamiliarData, _item: ItemDataPF2e, actorUpdates: any) { if ( this.ruleData.property && typeof this.ruleData.on?.added !== 'undefined' && @@ -22,7 +22,7 @@ export class PF2SetPropertyRuleElement extends PF2RuleElement { } } - onDelete(actorData: CharacterData | NPCData | FamiliarData, item: ItemDataPF2e, actorUpdates: any, tokens: any[]) { + onDelete(actorData: CharacterData | NPCData | FamiliarData, _item: ItemDataPF2e, actorUpdates: any) { if ( this.ruleData.property && typeof this.ruleData.on?.removed !== 'undefined' && diff --git a/src/module/rules/elements/toggle-property.ts b/src/module/rules/elements/toggle-property.ts index 7912cedd690..3ec84ab6df1 100644 --- a/src/module/rules/elements/toggle-property.ts +++ b/src/module/rules/elements/toggle-property.ts @@ -1,12 +1,11 @@ import { CharacterData, NPCData } from '@actor/data-definitions'; import { PF2RuleElement } from '../rule-element'; -import { PF2RuleElementSynthetics } from '../rules-data-definitions'; /** * @category RuleElement */ export class PF2TogglePropertyRuleElement extends PF2RuleElement { - onBeforePrepareData(actorData: CharacterData | NPCData, synthetics: PF2RuleElementSynthetics) { + onBeforePrepareData(actorData: CharacterData | NPCData) { const label = super.getDefaultLabel(this.ruleData, this.item); if (label && this.ruleData.property) { (actorData.data as any).toggles.actions.push({ diff --git a/src/module/rules/elements/token-effect-icon.ts b/src/module/rules/elements/token-effect-icon.ts index f358c774014..cb3ade9a037 100644 --- a/src/module/rules/elements/token-effect-icon.ts +++ b/src/module/rules/elements/token-effect-icon.ts @@ -60,7 +60,7 @@ export class PF2TokenEffectIconRuleElement extends PF2RuleElement { } } - onCreateToken(actorData: CharacterData | NPCData, item: ItemDataPF2e, token: TokenData) { + onCreateToken(_actorData: CharacterData | NPCData, item: ItemDataPF2e, token: TokenData) { token.effects = token.effects ?? []; if (!token.effects.includes(item.img)) { token.effects.push(item.img); diff --git a/src/module/rules/rule-element.ts b/src/module/rules/rule-element.ts index 139d56df43f..476b929a49f 100644 --- a/src/module/rules/rule-element.ts +++ b/src/module/rules/rule-element.ts @@ -49,7 +49,7 @@ export abstract class PF2RuleElement { * multiple times onto a canvas. Works similar to actorUpdates and used if you want to change values on the token * object */ - onCreate(actorData: CreatureData, item: ItemDataPF2e, actorUpdates: any, tokens: any[]) {} + onCreate(_actorData: CreatureData, _item: ItemDataPF2e, _actorUpdates: any, _tokens: any[]) {} /** * Run after an item holding this rule is removed from an actor. This method is used for cleaning up any values @@ -60,7 +60,7 @@ export abstract class PF2RuleElement { * @param actorUpdates see onCreate * @param tokens see onCreate */ - onDelete(actorData: CreatureData, item: ItemDataPF2e, actorUpdates: any, tokens: any[]) {} + onDelete(_actorData: CreatureData, _item: ItemDataPF2e, _actorUpdates: any, _tokens: any[]) {} /** * Run in Actor#prepareDerivedData which is similar to an init method and is the very first thing that is run after @@ -73,7 +73,7 @@ export abstract class PF2RuleElement { * @param synthetics object holding various values that are used to set values on the actorData object, e.g. * damage modifiers or bonuses */ - onBeforePrepareData(actorData: CreatureData, synthetics: PF2RuleElementSynthetics) {} + onBeforePrepareData(_actorData: CreatureData, _synthetics: PF2RuleElementSynthetics) {} /** * Run after all actor preparation callbacks have been run so you should see all final values here. @@ -81,7 +81,7 @@ export abstract class PF2RuleElement { * @param actorData see onBeforePrepareData * @param synthetics see onBeforePrepareData */ - onAfterPrepareData(actorData: CreatureData, synthetics: PF2RuleElementSynthetics) {} + onAfterPrepareData(_actorData: CreatureData, _synthetics: PF2RuleElementSynthetics) {} /** * Run before a new token is created of the actor that holds the item. @@ -90,7 +90,7 @@ export abstract class PF2RuleElement { * @param item the item data of the item containing the rule element * @param token the token data of the token to be created */ - onCreateToken(actorData: ActorData, item: ItemDataPF2e, token: TokenData) {} + onCreateToken(_actorData: ActorData, _item: ItemDataPF2e, _token: TokenData) {} /** * Used to look up the label when displaying a rule effect. By default uses the label field on a rule and if absent @@ -100,7 +100,7 @@ export abstract class PF2RuleElement { * @param item * @return human readable label of the rule */ - getDefaultLabel(ruleData, item): string { + getDefaultLabel(ruleData, item: ItemDataPF2e): string { return game.i18n.localize(ruleData.label ?? item?.name); } @@ -132,7 +132,7 @@ export abstract class PF2RuleElement { item: itemData, rule: ruleData, }; - return (source ?? '').replace(/{(actor|item|rule)\|(.*?)}/g, (match, obj, prop) => { + return (source ?? '').replace(/{(actor|item|rule)\|(.*?)}/g, (_match, obj, prop) => { return getProperty(objects[obj] ?? itemData, prop); }); } diff --git a/src/module/system/damage/damage.ts b/src/module/system/damage/damage.ts index b9f807a36c3..09c943644db 100644 --- a/src/module/system/damage/damage.ts +++ b/src/module/system/damage/damage.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-use-before-define */ import { combineObjects } from '../../utils'; /** The possible standard damage die sizes. */ @@ -57,14 +56,14 @@ export const DamageCategory = Object.freeze({ /** Get the full current map of damage types -> their current damage category (taking custom mappings into account). */ currentTypeMappings: () => - combineObjects(BASE_DAMAGE_TYPES_TO_CATEGORIES, CUSTOM_DAMAGE_TYPES_TO_CATEGORIES, (first, second) => second), + combineObjects(BASE_DAMAGE_TYPES_TO_CATEGORIES, CUSTOM_DAMAGE_TYPES_TO_CATEGORIES, (_first, second) => second), /** Map a damage category to the set of damage types in it. */ toDamageTypes: (category: string) => { // Get all of the types in the current mappings which map to the given category const types = Object.entries(DamageCategory.currentTypeMappings()) - .filter(([key, value]) => value === category) - .map(([key, value]) => key); + .filter(([_key, value]) => value === category) + .map(([key]) => key); // And return as a set to eliminate duplicates. return new Set(types); diff --git a/src/module/system/effect-panel.ts b/src/module/system/effect-panel.ts index ec3a2c4202d..3e2c5725956 100644 --- a/src/module/system/effect-panel.ts +++ b/src/module/system/effect-panel.ts @@ -80,14 +80,14 @@ export class EffectPanel extends Application { ); } } else { - effect.data.expired = initiative < effect.data.start.initiative; + effect.data.expired = initiative < (effect.data.start.initiative ?? 0); } } effect.data.remaining = effect.data.expired ? game.i18n.localize('PF2E.EffectPanel.Expired') : EffectPanel.getRemainingDurationLabel( remaining, - effect.data.start.initiative, + effect.data.start.initiative ?? 0, effect.data.duration.expiry, ); } diff --git a/src/module/system/rolls.ts b/src/module/system/rolls.ts index 8967d5e29e9..68e09c33523 100644 --- a/src/module/system/rolls.ts +++ b/src/module/system/rolls.ts @@ -32,7 +32,7 @@ export class CheckPF2e { static roll( check: StatisticModifier, context: CheckModifiersContext = {}, - event: JQuery.Event | undefined, + event?: JQuery.Event, callback?: (roll: Roll) => void, ) { if (context?.options?.length > 0) { @@ -171,12 +171,12 @@ export class CheckPF2e { */ export class PF2DamageRoll { /** - * @param {object} damage - * @param {object} context - * @param {jQuery.Event} event - * @param {function} callback + * @param damage + * @param context + * @param event + * @param callback */ - static roll(damage, context: any = {}, event, callback?) { + static roll(damage, context: any = {}, _event: JQuery.Event | undefined, callback?) { if (context?.options?.length > 0) { // change default roll mode to blind GM roll if the 'secret' option is specified if (context.options.map((o) => o.toLowerCase()).includes('secret')) { diff --git a/src/module/system/trait-selector.ts b/src/module/system/trait-selector.ts index 1b8916e6658..be532831bf8 100644 --- a/src/module/system/trait-selector.ts +++ b/src/module/system/trait-selector.ts @@ -130,33 +130,33 @@ export class TraitSelector5e extends FormApplication { /** * Filter the potential traits to only show ones which match a provided search string - * @param {string} searchString The search string to match + * @param searchString The search string to match */ - search(searchString) { + search(searchString: string) { const query = new RegExp((RegExp as any).escape(searchString), 'i'); - (this.element as JQuery).find('li.trait-item').each((i, li) => { + (this.element as JQuery).find('li.trait-item').each((_i, li) => { const name = li.getElementsByClassName('trait-label')[0].textContent; li.style.display = query.test(name) ? 'flex' : 'none'; }); this.searchString = searchString; } - activateListeners(html) { + activateListeners(html: JQuery) { super.activateListeners(html); // Search filtering - html.find('input[name="search"]').keyup(this._onFilterResults.bind(this)); + html.find('input[name="search"]').on('keyup', this._onFilterResults.bind(this)); if (this.searchString) { this.search(this.searchString); } if (this.options.has_values) { - html.find('input[id^=input_value]').focusin((ev) => { + html.find('input[id^=input_value]').on('focusin', (ev) => { const name = ev.currentTarget.name; html.find(`input[type=checkbox][name="${name}"]`).prop('checked', true); }); if (!this.options.allow_empty_values) { - html.find('input[id^=input_value]').focusout((ev) => { + html.find('input[id^=input_value]').on('focusout', (ev) => { const input = ev.currentTarget; if (input.value === '') html.find(`input[type=checkbox][name="${input.name}"]`).prop('checked', false); @@ -165,12 +165,12 @@ export class TraitSelector5e extends FormApplication { } if (this.options.has_placeholders) { - html.find('input[id^=input_placeholder]').focusin((ev) => { + html.find('input[id^=input_placeholder]').on('focusin', (ev) => { const name = ev.currentTarget.name; html.find(`input[type=checkbox][name="${name}"]`).prop('checked', true); }); if (this.options.allow_empty_values) { - html.find('input[id^=input_placeholder]').focusout((ev) => { + html.find('input[id^=input_placeholder]').on('focusout', (ev) => { const input = ev.currentTarget; if (input.value === '') html.find(`input[type=checkbox][name="${input.name}"]`).prop('checked', false); @@ -179,13 +179,15 @@ export class TraitSelector5e extends FormApplication { } if (this.options.has_exceptions) { - html.find('input[id^=input_exception]').focusin((ev) => { + html.find('input[id^=input_exception]').on('focusin', (ev) => { const name = ev.currentTarget.name; html.find(`input[type=checkbox][name="${name}"]`).prop('checked', true); }); - html.find('input[id^=input_exception]').focusout((ev) => { + html.find('input[id^=input_exception]').on('focusout', (ev) => { const inputException = ev.currentTarget; - const inputValue = html.find(`input[id=input_value][name="${inputException.name}"]`).val(); + const inputValue = html + .find(`input[id=input_value][name="${inputException.name}"]`) + .val(); if (inputValue === '') html.find(`input[type=checkbox][name="${inputException.name}"]`).prop('checked', false); }); diff --git a/src/pf2e.ts b/src/pf2e.ts index d6b24e27b93..a76fecc0d3b 100644 --- a/src/pf2e.ts +++ b/src/pf2e.ts @@ -1,5 +1,4 @@ import { CheckPF2e } from './module/system/rolls'; -import { EffectPanel } from './module/system/effect-panel'; import { RuleElements } from './module/rules/rules'; import { updateMinionActors } from './scripts/actor/update-minions'; import { PF2E } from './scripts/hooks'; @@ -25,19 +24,19 @@ PF2E.Hooks.listen(); /* -------------------------------------------- */ // Activate global listeners -Hooks.on('renderChatLog', (log, html) => ItemPF2e.chatListeners(html)); -Hooks.on('renderChatPopout', (log, html) => ItemPF2e.chatListeners(html)); +Hooks.on('renderChatLog', (_log, html) => ItemPF2e.chatListeners(html)); +Hooks.on('renderChatPopout', (_log, html) => ItemPF2e.chatListeners(html)); // Chat hooks - refactor out. /** * Hook into chat log context menu to add damage application options */ -Hooks.on('getChatLogEntryContext', (html, options) => { - const canApplyDamage = (li) => { +Hooks.on('getChatLogEntryContext', (_html, options) => { + const canApplyDamage: ContextOptionCondition = (li) => { const { messageId } = li.data(); const message = game.messages.get(messageId); - return ( + return !!( canvas.tokens.controlled.length && message.isRoll && message.data && @@ -45,11 +44,11 @@ Hooks.on('getChatLogEntryContext', (html, options) => { message.data.flavor.includes('Damage') ); }; - const canApplyHealing = (li) => { + const canApplyHealing: ContextOptionCondition = (li) => { const { messageId } = li.data(); const message = game.messages.get(messageId); - return ( + return !!( canvas.tokens.controlled.length && message.isRoll && message.data && @@ -57,7 +56,7 @@ Hooks.on('getChatLogEntryContext', (html, options) => { message.data.flavor.includes('Healing') ); }; - const canApplyInitiative = (li) => { + const canApplyInitiative: ContextOptionCondition = (li) => { const { messageId } = li.data(); const message = game.messages.get(messageId); @@ -70,7 +69,7 @@ Hooks.on('getChatLogEntryContext', (html, options) => { return validActor && message.isRoll && validRollType; }; - const canHeroPointReroll = (li): boolean => { + const canHeroPointReroll: ContextOptionCondition = (li): boolean => { const message = game.messages.get(li.data('messageId')); const actorId = message.data.speaker.actor; const canReroll = message.getFlag('pf2e', 'canReroll'); @@ -82,7 +81,7 @@ Hooks.on('getChatLogEntryContext', (html, options) => { } return false; }; - const canReroll = (li): boolean => { + const canReroll: ContextOptionCondition = (li): boolean => { const message = game.messages.get(li.data('messageId')); const actorId = message.data.speaker.actor; const canRerollMessage = message.getFlag('pf2e', 'canReroll'); @@ -98,13 +97,13 @@ Hooks.on('getChatLogEntryContext', (html, options) => { name: 'Apply Damage', icon: '', condition: canApplyDamage, - callback: (li) => ActorPF2e.applyDamage(li, 1), + callback: (li: JQuery) => ActorPF2e.applyDamage(li, 1), }, { name: 'Apply Healing', icon: '', condition: canApplyHealing, - callback: (li) => ActorPF2e.applyDamage(li, -1), + callback: (li: JQuery) => ActorPF2e.applyDamage(li, -1), }, { name: 'Double Damage', @@ -149,7 +148,6 @@ Hooks.on('getChatLogEntryContext', (html, options) => { callback: (li) => CheckPF2e.rerollFromMessage(game.messages.get(li.data('messageId')), { keep: 'best' }), }, ); - return options; }); Hooks.on('preCreateItem', (itemData: Partial) => { @@ -161,23 +159,27 @@ Hooks.on('preCreateItem', (itemData: Partial) => { })(); }); -Hooks.on('updateActor', (actor, data, options, userID) => { +Hooks.on('updateActor', (actor, _data, _options, userID) => { if (userID === game.userId) { // ensure minion-type actors with the updated actor as master should also be updated updateMinionActors(actor); } }); -function preCreateOwnedItem(parent, child, options, userID) { +function preCreateOwnedItem( + _parent: ActorPF2e, + child: DeepPartial, + _options: EntityCreateOptions, + userID: string, +) { if (userID === game.userId) { if (child.type === 'effect') { - child.data.start = child.data.start || {}; - child.data.start.value = game.time.worldTime; + const data = child.data!; + data.start = data.start ?? { value: 0, initiative: null }; + data.start!.value = game.time.worldTime; if (game.combat && game.combat.turns?.length > game.combat.turn) { - child.data.start.initiative = game.combat.turns[game.combat.turn].initiative; - } else { - child.data.start.initiative = null; + data.start!.initiative = game.combat.turns[game.combat.turn].initiative; } } } @@ -185,7 +187,7 @@ function preCreateOwnedItem(parent, child, options, userID) { Hooks.on('preCreateOwnedItem', preCreateOwnedItem); -function createOwnedItem(parent, child, options, userID) { +function createOwnedItem(parent: ActorPF2e | null, child: ItemDataPF2e, options: EntityCreateOptions, userID: string) { if (parent instanceof ActorPF2e) { if (userID === game.userId) { parent.onCreateOwnedItem(child, options, userID); @@ -197,7 +199,7 @@ function createOwnedItem(parent, child, options, userID) { Hooks.on('createOwnedItem', createOwnedItem); -function deleteOwnedItem(parent, child, options, userID) { +function deleteOwnedItem(parent: ActorPF2e | null, child: ItemDataPF2e, options: EntityDeleteOptions, userID: string) { if (parent instanceof ActorPF2e) { if (userID === game.userId) { parent.onDeleteOwnedItem(child, options, userID); @@ -209,18 +211,18 @@ function deleteOwnedItem(parent, child, options, userID) { Hooks.on('deleteOwnedItem', deleteOwnedItem); -Hooks.on('updateOwnedItem', (parent, child, options, userId) => { +Hooks.on('updateOwnedItem', (parent) => { if (parent instanceof ActorPF2e) { game.pf2e.effectPanel?.refresh(); } }); // effect panel -Hooks.on('updateUser', (user, diff, options, id) => { +Hooks.on('updateUser', () => { game.pf2e.effectPanel?.refresh(); }); -Hooks.on('preCreateToken', (scene: Scene, token: TokenData, options, userId) => { +Hooks.on('preCreateToken', (_scene: Scene, token: TokenData) => { const actor = game.actors.get(token.actorId); if (actor) { actor.items.forEach((item: ItemPF2e) => { @@ -232,62 +234,56 @@ Hooks.on('preCreateToken', (scene: Scene, token: TokenData, options, userId) => } }); -Hooks.on('preUpdateToken', (scene, token, data, options, userID) => { +Hooks.on('preUpdateToken', (_scene, token, data, options, userID) => { if (!token.actorLink && data.actorData?.items) { // Preparation for synthetic actors to fake some of the other hooks in the 'updateToken' hook where this data is // not otherwise available options.pf2e = { items: { added: - data.actorData.items?.filter((i) => !token.actorData.items?.map((x) => x._id)?.includes(i._id)) ?? + data.actorData?.items?.filter((i) => !token.actorData?.items?.map((x) => x._id)?.includes(i._id)) ?? [], removed: - token.actorData.items?.filter((i) => !data.actorData.items?.map((x) => x._id)?.includes(i._id)) ?? + token.actorData?.items?.filter((i) => !data.actorData?.items?.map((x) => x._id)?.includes(i._id)) ?? [], }, }; - const canvasToken = canvas.tokens.get(token._id); - if (canvasToken) { - options.pf2e.items.added.forEach((item) => { - preCreateOwnedItem(canvasToken.actor, item, options, userID); + const actor = canvas.tokens.get(token._id)?.actor; + if (actor) { + options.pf2e.items.added.forEach((item: ItemDataPF2e) => { + preCreateOwnedItem(actor, item, options, userID); }); } } }); -Hooks.on('updateToken', (scene, token: TokenData, data, options, userID) => { +Hooks.on('updateToken', (_scene, token: TokenData, data, options, userID) => { if (!token.actorLink && options.pf2e?.items) { // Synthetic actors do not trigger the 'createOwnedItem' and 'deleteOwnedItem' hooks, so use the previously // prepared data from the 'preUpdateToken' hook to trigger the callbacks from here instead - const canvasToken = canvas.tokens.get(token._id); - if (canvasToken) { - const actor = canvasToken.actor; - options.pf2e.items.added.forEach((item) => { + const actor = canvas.tokens.get(token._id)?.actor; + if (actor) { + options.pf2e.items.added.forEach((item: ItemDataPF2e) => { createOwnedItem(actor, item, options, userID); }); - options.pf2e.items.removed.forEach((item) => { + options.pf2e.items.removed.forEach((item: ItemDataPF2e) => { deleteOwnedItem(actor, item, options, userID); }); } } if ('disposition' in data && game.userId === userID) { - const canvasToken = canvas.tokens.get(token._id); - if (canvasToken) { - const actor = canvasToken.actor; - if (actor instanceof NPCPF2e) { - (actor as NPCPF2e).updateNPCAttitudeFromDisposition(data.disposition); - } + const actor = canvas.tokens.get(token._id)?.actor; + if (actor instanceof NPCPF2e) { + (actor as NPCPF2e).updateNPCAttitudeFromDisposition(data.disposition); } } game.pf2e.effectPanel?.refresh(); }); -Hooks.on('controlToken', (_token: Token, _selected: boolean) => { - if (game.pf2e.effectPanel instanceof EffectPanel) { - game.pf2e.effectPanel.refresh(); - } +Hooks.on('controlToken', () => { + game.pf2e.effectPanel?.refresh(); }); // world clock application @@ -321,11 +317,11 @@ Hooks.on('getSceneControlButtons', (controls: any[]) => { ); }); -Hooks.on('updateCombat', (combat, diff, options, userID) => { - game.pf2e.effectPanel.refresh(); +Hooks.on('updateCombat', () => { + game.pf2e.effectPanel?.refresh(); }); -Hooks.on('renderChatMessage', (message: ChatMessage, html: JQuery) => { +Hooks.on('renderChatMessage', (message, html) => { // remove elements the user does not have permission to see if (!game.user.isGM) { html.find('[data-visibility="gm"]').remove(); diff --git a/src/scripts/dice.ts b/src/scripts/dice.ts index 15e022acf6b..16e4b755507 100644 --- a/src/scripts/dice.ts +++ b/src/scripts/dice.ts @@ -16,7 +16,7 @@ export class FormulaPreservingRoll extends Roll { */ export class DicePF2e { _rolled: any; - terms: any; + terms?: string[]; _formula: any; /** * A standardized helper function for managing core PF2e "d20 rolls" @@ -46,9 +46,6 @@ export class DicePF2e { title, speaker, flavor, - advantage = true, - situational = true, - fastForward = true, onClose, dialogOptions, rollMode, @@ -62,9 +59,6 @@ export class DicePF2e { title: string; speaker: object; flavor?: any; - advantage?: boolean; - situational?: boolean; - fastForward?: boolean; onClose?: any; dialogOptions?: object; rollMode?: string; @@ -206,7 +200,6 @@ export class DicePF2e { event, partsCritOnly = [], parts, - actor, data, template, title, @@ -335,13 +328,13 @@ export class DicePF2e { }); } - alter(add, multiply) { + alter(add: number, multiply: number) { const rgx = new RegExp(Roll.rgx.dice, 'g'); if (this._rolled) throw new Error('You may not alter a Roll which has already been rolled'); // Update dice roll terms - this.terms = this.terms.map((t) => - t.replace(rgx, (match, nd, d, mods) => { + this.terms = this.terms?.map((t) => + t.replace(rgx, (_match, nd, d, mods) => { nd = nd * (multiply || 1) + (add || 0); mods = mods || ''; return `${nd}d${d}${mods}`; @@ -349,7 +342,7 @@ export class DicePF2e { ); // Update the formula - this._formula = this.terms.join(' '); + this._formula = this.terms?.join(' '); return this; } } @@ -357,7 +350,7 @@ export class DicePF2e { /** * Highlight critical success or failure on d20 rolls */ -Hooks.on('renderChatMessage', (message: ChatMessage, html: any) => { +Hooks.on('renderChatMessage', (message, html) => { if (!message.isRoll || message.getFlag(game.system.id, 'damageRoll')) return; const dice: any = message.roll.dice[0] ?? {}; if (dice.faces !== 20) return; @@ -383,7 +376,7 @@ Hooks.on('renderChatMessage', (message: ChatMessage, html: any) => { html.find('.dice-total').append(btnContainer); - setInitiativeButton.click((ev) => { + setInitiativeButton.on('click', (ev) => { ev.stopPropagation(); ActorPF2e.setCombatantInitiative(html); }); diff --git a/tests/module/migration.test.ts b/tests/module/migration.test.ts index 3c643522bd0..7cb80ee2357 100644 --- a/tests/module/migration.test.ts +++ b/tests/module/migration.test.ts @@ -1,14 +1,15 @@ import { populateFoundryUtilFunctions } from '../fixtures/foundryshim'; import { ActorDataPF2e } from '@actor/data-definitions'; -import { MigrationRunner } from '../../src/module/migration-runner'; -import { MigrationBase } from 'src/module/migrations/base'; -import { FakeActor } from 'tests/fakes/fake-actor'; +import { MigrationRunner } from '@module/migration-runner'; +import { MigrationBase } from '@module/migrations/base'; +import { FakeActor, RecursivePartial } from 'tests/fakes/fake-actor'; import { FakeItem } from 'tests/fakes/fake-item'; import { FakeUser } from 'tests/fakes/fake-user'; import { FakeScene } from 'tests/fakes/fake-scene'; -const characterData = require('../../packs/data/iconics.db/amiri-level-1.json'); -const itemData = require('../../packs/data/equipment.db/scale-mail.json'); +import characterData from '../../packs/data/iconics.db/amiri-level-1.json'; +import * as itemData from '../../packs/data/equipment.db/scale-mail.json'; +import { ItemDataPF2e } from '@item/data-definitions'; declare let game: any; @@ -21,10 +22,10 @@ describe('test migration runner', () => { game = { settings: { - get(context: string, key: string) { + get(_context: string, key: string) { return settings[key]; }, - set(context: string, key: string, value: any) { + set(_context: string, key: string, value: any) { settings[key] = value; }, }, @@ -61,7 +62,7 @@ describe('test migration runner', () => { (global as any).ui = { notifications: { - info(msg: string, other?: any) {}, + info(_msg: string, _other?: any) {}, }, }; @@ -89,14 +90,14 @@ describe('test migration runner', () => { class UpdateItemName extends MigrationBase { static version = 13; - async updateItem(item: any, actor?: any) { + async updateItem(item: any) { item.name = 'updated'; } } class RemoveItemProperty extends MigrationBase { static version = 14; - async updateItem(item: any, actor?: any) { + async updateItem(item: any) { delete item.data.someFakeProperty; } } @@ -118,7 +119,7 @@ describe('test migration runner', () => { }); test("expect previous version migrations don't run", async () => { - game.actors.entities.push(new FakeActor(characterData)); + game.actors.entities.push(new FakeActor(characterData as any)); settings.worldSchemaVersion = 20; const migrationRunner = new MigrationRunner([new ChangeNameMigration()]); @@ -127,7 +128,7 @@ describe('test migration runner', () => { }); test('expect update causes version to be updated', async () => { - game.actors.entities.push(new FakeActor(characterData)); + game.actors.entities.push(new FakeActor(characterData as RecursivePartial)); const migrationRunner = new MigrationRunner([new ChangeNameMigration()]); await migrationRunner.runMigration(); @@ -135,7 +136,7 @@ describe('test migration runner', () => { }); test('expect update actor name in world', async () => { - game.actors.entities.push(new FakeActor(characterData)); + game.actors.entities.push(new FakeActor(characterData as RecursivePartial)); const migrationRunner = new MigrationRunner([new ChangeNameMigration()]); await migrationRunner.runMigration(); @@ -143,7 +144,7 @@ describe('test migration runner', () => { }); test('expect update actor deep property', async () => { - game.actors.entities.push(new FakeActor(characterData)); + game.actors.entities.push(new FakeActor(characterData as RecursivePartial)); const migrationRunner = new MigrationRunner([new ChangeSizeMigration()]); await migrationRunner.runMigration(); @@ -151,8 +152,8 @@ describe('test migration runner', () => { }); test('expect unlinked actor in scene gets migrated', async () => { - characterData._id = 'actor1'; - game.actors.entities.push(new FakeActor(characterData)); + (characterData as { _id: string })._id = 'actor1'; + game.actors.entities.push(new FakeActor(characterData as RecursivePartial)); const scene = new FakeScene(); scene.addToken({ _id: 'token1', @@ -168,7 +169,7 @@ describe('test migration runner', () => { }); test('update world actor item', async () => { - game.actors.entities.push(new FakeActor(characterData)); + game.actors.entities.push(new FakeActor(characterData as RecursivePartial)); const migrationRunner = new MigrationRunner([new UpdateItemName()]); await migrationRunner.runMigration(); @@ -176,7 +177,7 @@ describe('test migration runner', () => { }); test('update world item', async () => { - game.items.entities.push(new FakeItem(itemData)); + game.items.entities.push(new FakeItem(itemData as unknown as Partial)); const migrationRunner = new MigrationRunner([new UpdateItemName()]); await migrationRunner.runMigration(); @@ -184,7 +185,7 @@ describe('test migration runner', () => { }); test('properties can be removed', async () => { - game.items.entities.push(new FakeItem(itemData)); + game.items.entities.push(new FakeItem(itemData as unknown as Partial)); game.items.entities[0]._data.data.someFakeProperty = 123123; const migrationRunner = new MigrationRunner([new RemoveItemProperty()]); @@ -195,19 +196,19 @@ describe('test migration runner', () => { test('migrations run in sequence', async () => { class ChangeItemProp extends MigrationBase { static version = 13; - async updateItem(item: any, actor?: any) { + async updateItem(item: any) { item.data.prop = 456; } } class UpdateItemNameWithProp extends MigrationBase { static version = 14; - async updateItem(item: any, actor?: any) { + async updateItem(item: any) { item.name = `${item.data.prop}`; } } - game.items.entities.push(new FakeItem(itemData)); + game.items.entities.push(new FakeItem(itemData as unknown as Partial)); game.items.entities[0]._data.data.prop = 123; const migrationRunner = new MigrationRunner([new ChangeItemProp(), new UpdateItemNameWithProp()]); @@ -224,7 +225,7 @@ describe('test migration runner', () => { } } - game.actors.entities.push(new FakeActor(characterData)); + game.actors.entities.push(new FakeActor(characterData as RecursivePartial)); const migrationRunner = new MigrationRunner([new RemoveItemsFromActor()]); await migrationRunner.runMigration(); @@ -244,7 +245,7 @@ describe('test migration runner', () => { } test('migrations can add items to actors', async () => { - game.actors.entities.push(new FakeActor(characterData)); + game.actors.entities.push(new FakeActor(characterData as RecursivePartial)); game.actors.entities[0]._data.items = []; const migrationRunner = new MigrationRunner([new AddItemToActor()]); @@ -261,7 +262,7 @@ describe('test migration runner', () => { } test('migrations can reference previously added items', async () => { - game.actors.entities.push(new FakeActor(characterData)); + game.actors.entities.push(new FakeActor(characterData as RecursivePartial)); game.actors.entities[0]._data.items = []; const migrationRunner = new MigrationRunner([new AddItemToActor(), new SetActorPropertyToAddedItem()]); @@ -270,8 +271,8 @@ describe('test migration runner', () => { }); test('migrations can reference previously added items on tokens', async () => { - characterData._id = 'actor1'; - game.actors.entities.push(new FakeActor(characterData)); + (characterData as { _id: string })._id = 'actor1'; + game.actors.entities.push(new FakeActor(characterData as RecursivePartial)); game.actors.entities[0]._data.items = []; const scene = new FakeScene(); diff --git a/tests/setup.ts b/tests/setup.ts index 6c6485dfe0d..d60469f7269 100644 --- a/tests/setup.ts +++ b/tests/setup.ts @@ -1,12 +1,12 @@ -const path = require('path'); -const fs = require('fs'); +import * as path from 'path'; +import * as fs from 'fs'; -export const fetchSpell = (name) => { +export const fetchSpell = (name: string) => { const spellsDb = './packs/data/spells.db/'; const spellFiles = fs.readdirSync(spellsDb); for (const file of spellFiles) { - const content = fs.readFileSync(path.resolve(spellsDb, file)); + const content = fs.readFileSync(path.resolve(spellsDb, file), 'utf-8'); const json = JSON.parse(content); if (json.name === name) return json; } @@ -16,7 +16,7 @@ export const fetchSpell = (name) => { //@ts-ignore global.game = Object.freeze({ settings: Object.freeze({ - get: (module, settingKey) => { + get: (_module: string, settingKey: string) => { switch (settingKey) { /* Proficiency Modifiers */ case 'proficiencyUntrainedModifier': @@ -39,9 +39,9 @@ global.game = Object.freeze({ }, }), packs: Object.freeze({ - find: (compendiumID, quantity) => { + find: (_compendiumID: string, _quantity: number) => { return Object.freeze({ - getEntity: (id) => { + getEntity: (id: string) => { switch (id) { case 'JuNPeK5Qm1w6wpb4': return { data: require('../packs/data/equipment.db/platinum-pieces.json') }; @@ -51,6 +51,8 @@ global.game = Object.freeze({ return { data: require('../packs/data/equipment.db/silver-pieces.json') }; case 'lzJ8AVhRcbFul5fh': return { data: require('../packs/data/equipment.db/copper-pieces.json') }; + default: + return { data: {} }; } }, }); @@ -91,7 +93,7 @@ function setProperty(object, key, value) { return changed; } -function duplicate(original) { +function duplicate(original: unknown) { return JSON.parse(JSON.stringify(original)); } diff --git a/tsconfig.json b/tsconfig.json index 5493127d95b..1f885af3adf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ "noEmit": true, "noImplicitThis": true, "noUnusedLocals": true, + "noUnusedParameters": true, "forceConsistentCasingInFileNames": true, "esModuleInterop": true, "sourceMap": true, diff --git a/types/foundry-pc-types/index.d.ts b/types/foundry-pc-types/index.d.ts index 87d045698a3..65301e77e7c 100644 --- a/types/foundry-pc-types/index.d.ts +++ b/types/foundry-pc-types/index.d.ts @@ -37,7 +37,7 @@ import './types/apps/placeables/placeables-hud'; import './types/apps/sidebar/apps/rolltabledirectory'; import './types/apps/sidebar/apps/actor-directory'; import './types/apps/sidebar/apps/item-directory'; -import './types/apps/sidebar/apps/chat-log'; +import './types/apps/sidebar/sidebar-tab/chat-log'; import './types/apps/sidebar/apps/clientsettings'; import './types/apps/sidebar/apps/combattracker'; import './types/apps/sidebar/apps/compendiumdirectory'; diff --git a/types/foundry-pc-types/types/apps/sidebar/apps/compendiumdirectory.d.ts b/types/foundry-pc-types/types/apps/sidebar/apps/compendiumdirectory.d.ts index 1d513060411..a66da0687fe 100644 --- a/types/foundry-pc-types/types/apps/sidebar/apps/compendiumdirectory.d.ts +++ b/types/foundry-pc-types/types/apps/sidebar/apps/compendiumdirectory.d.ts @@ -1,9 +1,3 @@ -declare interface EntryContextOption { - name: string; - icon: string; - callback: (li: JQuery) => Promise; -} - declare class CompendiumDirectory extends SidebarTab { /** @override */ static get defaultOptions(): typeof SidebarTab['defaultOptions'] & { diff --git a/types/foundry-pc-types/types/apps/sidebar/sidebar-tab/base.d.ts b/types/foundry-pc-types/types/apps/sidebar/sidebar-tab/base.d.ts index f6e558fb647..a6aad6f78c4 100644 --- a/types/foundry-pc-types/types/apps/sidebar/sidebar-tab/base.d.ts +++ b/types/foundry-pc-types/types/apps/sidebar/sidebar-tab/base.d.ts @@ -1,14 +1,41 @@ +declare type ContextOptionCondition = (li: JQuery) => boolean; +declare interface EntryContextOption { + name: string; + icon: string; + condition: ContextOptionCondition; + callback: (li: JQuery) => void; +} + /** * An abstract pattern followed by the different tabs of the sidebar */ -declare class SidebarTab extends Application { +declare abstract class SidebarTab extends Application { + /** @override */ + constructor(options?: ApplicationOptions); + + /** + * The base name of this sidebar tab + */ + tabName: string; + + /** + * A reference to the pop-out variant of this SidebarTab, if one exists + */ + protected _popout: this; + + /** + * Denote whether or not this is the original version of the sidebar tab, or a pop-out variant + */ + protected _original: this; + /** * Only close the pop-out version of the sidebar tab */ close(): Promise; /** - * Render the SidebarTab as a pop-out container + * Get the set of ContextMenu options which should be used for Entities in a SidebarDirectory + * @return The Array of context options passed to the ContextMenu instance */ - static renderPopout(original: SidebarTab): void; + protected _getEntryContextOptions(): EntryContextOption[]; } diff --git a/types/foundry-pc-types/types/apps/sidebar/apps/chat-log.d.ts b/types/foundry-pc-types/types/apps/sidebar/sidebar-tab/chat-log.d.ts similarity index 95% rename from types/foundry-pc-types/types/apps/sidebar/apps/chat-log.d.ts rename to types/foundry-pc-types/types/apps/sidebar/sidebar-tab/chat-log.d.ts index ed4617a58bb..23b0c3ab7d8 100644 --- a/types/foundry-pc-types/types/apps/sidebar/apps/chat-log.d.ts +++ b/types/foundry-pc-types/types/apps/sidebar/sidebar-tab/chat-log.d.ts @@ -115,8 +115,8 @@ declare class ChatLog extends SidebarTab { /** * Update the content of a previously posted message after its data has been replaced - * @param {ChatMessage} message The ChatMessage instance to update - * @param {boolean} notify Trigger a notification which shows the log as having a new unread message + * @param message The ChatMessage instance to update + * @param notify Trigger a notification which shows the log as having a new unread message */ updateMessage(message: ChatMessage, { notify }?: { notify?: boolean }): void; diff --git a/types/foundry-pc-types/types/core/hooks.d.ts b/types/foundry-pc-types/types/core/hooks.d.ts index d30c2595524..90cef80f680 100644 --- a/types/foundry-pc-types/types/core/hooks.d.ts +++ b/types/foundry-pc-types/types/core/hooks.d.ts @@ -16,7 +16,15 @@ declare type HookParamsSetup = HookParameters<'setup', never>; declare type HookParamsReady = HookParameters<'ready', never>; declare type HookParamsCanvasReady = HookParameters<'canvasReady', [Canvas]>; declare type HookParamsDropCanvasData = HookParameters<'dropCanvasData', [Canvas, DropCanvasData]>; +declare type HookParamsGetChatLogEntryContext = HookParameters< + 'getChatLogEntryContext', + [JQuery, EntryContextOption[]] +>; declare type HookParamsHotbarDrop = HookParameters<'hotbarDrop', [Hotbar, unknown, string]>; +declare type HookParamsPreUpdateToken = HookParameters< + 'preUpdateToken', + [Scene, TokenData, Partial, { diff: boolean; [key: string]: any }, string] +>; declare type HookParamsRenderChatLog = HookParameters< 'renderChatLog', [ChatLog, JQuery, ReturnType] @@ -54,6 +62,8 @@ declare class Hooks { static on(...args: HookParamsCanvasReady): number; static on(...args: HookParamsDropCanvasData): number; static on(...args: HookParamsHotbarDrop): number; + static on(...args: HookParamsGetChatLogEntryContext): number; + static on(...args: HookParamsPreUpdateToken): number; static on(...args: HookParamsRenderChatLog): number; static on(...args: HookParamsRenderChatPopout): number; static on(...args: HookParamsRenderChatMessage): number; @@ -77,6 +87,8 @@ declare class Hooks { static once(...args: HookParamsCanvasReady): number; static once(...args: HookParamsDropCanvasData): number; static once(...args: HookParamsHotbarDrop): number; + static once(...args: HookParamsGetChatLogEntryContext): number; + static once(...args: HookParamsPreUpdateToken): number; static once(...args: HookParamsRenderChatMessage): number; static once(...args: HookParamsRenderChatPopout): number; static once(...args: HookParamsRenderCompendiumDirectory): number; diff --git a/types/foundry-pc-types/types/framework/entities/item.d.ts b/types/foundry-pc-types/types/framework/entities/item.d.ts index 69201bae661..b50a7280801 100644 --- a/types/foundry-pc-types/types/framework/entities/item.d.ts +++ b/types/foundry-pc-types/types/framework/entities/item.d.ts @@ -57,8 +57,6 @@ declare interface ItemConstructorOptions extends EntityConstruc actor?: A; } -declare type ItemCreateData = DeepPartial; - type _Actor = Actor>; declare class Item extends Entity { /** The item's collection of ActiveEffects */ @@ -119,7 +117,7 @@ declare class Item extends Entity { */ static createOwned>( this: new (data: I['data'], options?: ItemConstructorOptions) => I, - itemData: ItemCreateData, + itemData: DeepPartial, actor: A, ): Promise;