From 12bc76ba5442117c001bdd964a27d4773c17ee2e Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sun, 29 May 2022 17:47:27 +0200 Subject: [PATCH] refactor: use noImplicitOverride option --- src/active-effect.ts | 3 +-- src/actor/actor-sheet.ts | 18 ++++++------------ src/actor/actor.ts | 15 +++++---------- src/actor/character/character-sheet.ts | 3 +-- src/actor/character/character.ts | 9 +++------ src/actor/creature/creature-sheet.ts | 3 +-- src/actor/creature/creature.ts | 3 +-- src/apps/dialog-with-listeners.ts | 3 +-- src/chat-message.ts | 3 +-- src/item/item-sheet.ts | 17 +++++++---------- src/item/item.ts | 8 +------- src/item/spell/spell.ts | 6 ++---- src/item/talent/talent.ts | 6 ++---- src/item/weapon/weapon.ts | 6 ++---- src/rolls/check.ts | 19 +++++++------------ src/rolls/roll.ts | 5 ++--- src/token-document.ts | 2 +- tsconfig.json | 1 + 18 files changed, 45 insertions(+), 85 deletions(-) diff --git a/src/active-effect.ts b/src/active-effect.ts index d810e6b0..d3a28380 100644 --- a/src/active-effect.ts +++ b/src/active-effect.ts @@ -59,8 +59,7 @@ export class DS4ActiveEffect extends ActiveEffect { return this.originatingItem?.activeEffectFactor ?? 1; } - /** @override */ - apply(actor: DS4Actor, change: foundry.data.ActiveEffectData["changes"][number]): unknown { + override apply(actor: DS4Actor, change: foundry.data.ActiveEffectData["changes"][number]): unknown { change.value = Roll.replaceFormulaData(change.value, actor.data); try { change.value = Roll.safeEval(change.value).toString(); diff --git a/src/actor/actor-sheet.ts b/src/actor/actor-sheet.ts index 90e910fa..192b802c 100644 --- a/src/actor/actor-sheet.ts +++ b/src/actor/actor-sheet.ts @@ -21,8 +21,7 @@ import type { DS4Item } from "../item/item"; * The base sheet class for all {@link DS4Actor}s. */ export class DS4ActorSheet extends ActorSheet { - /** @override */ - static get defaultOptions(): ActorSheet.Options { + static override get defaultOptions(): ActorSheet.Options { return foundry.utils.mergeObject(super.defaultOptions, { classes: ["sheet", "ds4-actor-sheet"], height: 625, @@ -37,14 +36,12 @@ export class DS4ActorSheet extends ActorSheet { + override async getData(): Promise { const itemsByType = Object.fromEntries( Object.entries(this.actor.itemTypes).map(([itemType, items]) => { return [itemType, items.map((item) => item.data).sort((a, b) => (a.sort || 0) - (b.sort || 0))]; @@ -96,8 +93,7 @@ export class DS4ActorSheet extends ActorSheet notifications.error(e, { log: true })); } - /** @override */ - _onDragStart(event: DragEvent): void { + override _onDragStart(event: DragEvent): void { const target = event.currentTarget as HTMLElement; if (!(target instanceof HTMLElement)) return super._onDragStart(event); @@ -391,8 +386,7 @@ export class DS4ActorSheet extends ActorSheet { + protected override async _onDropItem(event: DragEvent, data: ActorSheet.DropData.Item): Promise { const item = await Item.fromDropData(data); if (item && !this.actor.canOwnItemType(item.data.type)) { notifications.warn( diff --git a/src/actor/actor.ts b/src/actor/actor.ts index ecad7f40..183e8018 100644 --- a/src/actor/actor.ts +++ b/src/actor/actor.ts @@ -25,8 +25,7 @@ declare global { * The Actor class for DS4 */ export class DS4Actor extends Actor { - /** @override */ - prepareData(): void { + override prepareData(): void { this.data.reset(); this.prepareBaseData(); this.prepareEmbeddedDocuments(); @@ -36,8 +35,7 @@ export class DS4Actor extends Actor { this.prepareFinalDerivedData(); } - /** @override */ - prepareBaseData(): void { + override prepareBaseData(): void { const data = this.data; data.data.rolling = { @@ -57,11 +55,10 @@ export class DS4Actor extends Actor { } /** - * @override * We override this with an empty implementation because we have our own custom way of applying * {@link ActiveEffect}s and {@link Actor#prepareEmbeddedDocuments} calls this. */ - applyActiveEffects(): void { + override applyActiveEffects(): void { return; } @@ -117,9 +114,8 @@ export class DS4Actor extends Actor { /** * Apply transformations to the Actor data after effects have been applied to the base data. - * @override */ - prepareDerivedData(): void { + override prepareDerivedData(): void { this.prepareCombatValues(); this.prepareChecks(); } @@ -281,9 +277,8 @@ export class DS4Actor extends Actor { /** * Handle how changes to a Token attribute bar are applied to the Actor. * This only differs from the base implementation by also allowing negative values. - * @override */ - async modifyTokenAttribute( + override async modifyTokenAttribute( attribute: string, value: number, isDelta = false, diff --git a/src/actor/character/character-sheet.ts b/src/actor/character/character-sheet.ts index 04f19ab8..379eb547 100644 --- a/src/actor/character/character-sheet.ts +++ b/src/actor/character/character-sheet.ts @@ -8,8 +8,7 @@ import { DS4ActorSheet } from "../actor-sheet"; * The Sheet class for DS4 Character Actors */ export class DS4CharacterActorSheet extends DS4ActorSheet { - /** @override */ - static get defaultOptions(): ActorSheet.Options { + static override get defaultOptions(): ActorSheet.Options { return foundry.utils.mergeObject(super.defaultOptions, { classes: ["sheet", "ds4-actor-sheet", "ds4-character-sheet"], }); diff --git a/src/actor/character/character.ts b/src/actor/character/character.ts index b8dd87a6..bda2cb65 100644 --- a/src/actor/character/character.ts +++ b/src/actor/character/character.ts @@ -7,19 +7,16 @@ import { DS4Actor } from "../actor"; import type { ItemType } from "../../item/item-data-source"; export class DS4Character extends DS4Actor { - /** @override */ - prepareFinalDerivedData(): void { + override prepareFinalDerivedData(): void { super.prepareFinalDerivedData(); this.data.data.slayerPoints.max = 3; } - /** @override */ - get finalDerivedDataProperties(): string[] { + override get finalDerivedDataProperties(): string[] { return [...super.finalDerivedDataProperties, "data.slayerPoints.max"]; } - /** @override */ - get ownableItemTypes(): Array { + override get ownableItemTypes(): Array { return [...super.ownableItemTypes, "talent", "racialAbility", "language", "alphabet"]; } } diff --git a/src/actor/creature/creature-sheet.ts b/src/actor/creature/creature-sheet.ts index 94aa940d..08f56773 100644 --- a/src/actor/creature/creature-sheet.ts +++ b/src/actor/creature/creature-sheet.ts @@ -8,8 +8,7 @@ import { DS4ActorSheet } from "../actor-sheet"; * The Sheet class for DS4 Creature Actors */ export class DS4CreatureActorSheet extends DS4ActorSheet { - /** @override */ - static get defaultOptions(): ActorSheet.Options { + static override get defaultOptions(): ActorSheet.Options { return foundry.utils.mergeObject(super.defaultOptions, { classes: ["sheet", "ds4-actor-sheet", "ds4-creature-sheet"], }); diff --git a/src/actor/creature/creature.ts b/src/actor/creature/creature.ts index f6ae06a7..1690195a 100644 --- a/src/actor/creature/creature.ts +++ b/src/actor/creature/creature.ts @@ -7,8 +7,7 @@ import { DS4Actor } from "../actor"; import type { ItemType } from "../../item/item-data-source"; export class DS4Creature extends DS4Actor { - /** @override */ - get ownableItemTypes(): Array { + override get ownableItemTypes(): Array { return [...super.ownableItemTypes, "specialCreatureAbility"]; } } diff --git a/src/apps/dialog-with-listeners.ts b/src/apps/dialog-with-listeners.ts index 574bbe9d..b2b053bc 100644 --- a/src/apps/dialog-with-listeners.ts +++ b/src/apps/dialog-with-listeners.ts @@ -6,8 +6,7 @@ * A simple extension to the {@link Dialog} class that allows attaching additional listeners. */ export class DialogWithListeners extends Dialog { - /** @inheritdoc */ - activateListeners(html: JQuery): void { + override activateListeners(html: JQuery): void { super.activateListeners(html); if (this.options.activateAdditionalListeners !== undefined) { this.options.activateAdditionalListeners(html, this); diff --git a/src/chat-message.ts b/src/chat-message.ts index 999e8d33..b4578b57 100644 --- a/src/chat-message.ts +++ b/src/chat-message.ts @@ -15,8 +15,7 @@ declare global { } export class DS4ChatMessage extends ChatMessage { - /** @override */ - prepareData(): void { + override prepareData(): void { super.prepareData(); if (this.data.flavor) { const game = getGame(); diff --git a/src/item/item-sheet.ts b/src/item/item-sheet.ts index 07aab57f..ce6a06de 100644 --- a/src/item/item-sheet.ts +++ b/src/item/item-sheet.ts @@ -15,8 +15,7 @@ import { isDS4ItemDataTypePhysical } from "./item-data-source-base"; * The Sheet class for DS4 Items */ export class DS4ItemSheet extends ItemSheet { - /** @override */ - static get defaultOptions(): ItemSheet.Options { + static override get defaultOptions(): ItemSheet.Options { return foundry.utils.mergeObject(super.defaultOptions, { classes: ["sheet", "ds4-item-sheet"], height: 400, @@ -26,14 +25,12 @@ export class DS4ItemSheet extends ItemSheet }); } - /** @override */ - get template(): string { + override get template(): string { const basePath = "systems/ds4/templates/sheets/item"; return `${basePath}/${this.item.data.type}-sheet.hbs`; } - /** @override */ - async getData(): Promise { + override async getData(): Promise { const data = { ...(await super.getData()), config: DS4, @@ -44,8 +41,9 @@ export class DS4ItemSheet extends ItemSheet return data; } - /** @override */ - setPosition(options: Partial = {}): (Application.Position & { height: number }) | void { + override setPosition( + options: Partial = {}, + ): (Application.Position & { height: number }) | void { const position = super.setPosition(options); if (position) { const sheetBody = this.element.find(".sheet-body"); @@ -56,8 +54,7 @@ export class DS4ItemSheet extends ItemSheet return position; } - /** @override */ - activateListeners(html: JQuery): void { + override activateListeners(html: JQuery): void { super.activateListeners(html); if (!this.options.editable) return; diff --git a/src/item/item.ts b/src/item/item.ts index 7a279bcd..1da26310 100644 --- a/src/item/item.ts +++ b/src/item/item.ts @@ -24,13 +24,7 @@ declare global { * The Item class for DS4 */ export class DS4Item extends Item { - /** @override */ - prepareData(): void { - super.prepareData(); - } - - /** @override */ - prepareDerivedData(): void { + override prepareDerivedData(): void { this.data.data.rollable = false; } diff --git a/src/item/spell/spell.ts b/src/item/spell/spell.ts index cf1fea29..dd9a2a75 100644 --- a/src/item/spell/spell.ts +++ b/src/item/spell/spell.ts @@ -9,14 +9,12 @@ import { DS4Item } from "../item"; import { calculateSpellPrice } from "./calculate-spell-price"; export class DS4Spell extends DS4Item { - /** @override */ - prepareDerivedData(): void { + override prepareDerivedData(): void { this.data.data.rollable = this.data.data.equipped; this.data.data.price = calculateSpellPrice(this.data.data); } - /** @override */ - async roll(options: { speaker?: { token?: TokenDocument; alias?: string } } = {}): Promise { + override async roll(options: { speaker?: { token?: TokenDocument; alias?: string } } = {}): Promise { const game = getGame(); if (!this.data.data.equipped) { diff --git a/src/item/talent/talent.ts b/src/item/talent/talent.ts index dea5782f..9d4875c9 100644 --- a/src/item/talent/talent.ts +++ b/src/item/talent/talent.ts @@ -5,15 +5,13 @@ import { DS4Item } from "../item"; export class DS4Talent extends DS4Item { - /** @override */ - prepareDerivedData(): void { + override prepareDerivedData(): void { super.prepareDerivedData(); const data = this.data.data; data.rank.total = data.rank.base + data.rank.mod; } - /** @override */ - get activeEffectFactor(): number | undefined { + override get activeEffectFactor(): number | undefined { return this.data.data.rank.total; } } diff --git a/src/item/weapon/weapon.ts b/src/item/weapon/weapon.ts index 8d3bc2df..34157629 100644 --- a/src/item/weapon/weapon.ts +++ b/src/item/weapon/weapon.ts @@ -11,13 +11,11 @@ import { DS4Item } from "../item"; import type { AttackType } from "./weapon-data-source"; export class DS4Weapon extends DS4Item { - /** @override */ - prepareDerivedData(): void { + override prepareDerivedData(): void { this.data.data.rollable = this.data.data.equipped; } - /** @override */ - async roll(options: { speaker?: { token?: TokenDocument; alias?: string } } = {}): Promise { + override async roll(options: { speaker?: { token?: TokenDocument; alias?: string } } = {}): Promise { const game = getGame(); if (!this.data.data.equipped) { return notifications.warn( diff --git a/src/rolls/check.ts b/src/rolls/check.ts index 9dcf8d0c..9491be3f 100644 --- a/src/rolls/check.ts +++ b/src/rolls/check.ts @@ -72,26 +72,22 @@ export class DS4Check extends DiceTerm { minimumFumbleResult = DS4Check.DEFAULT_MINIMUM_FUMBLE_RESULT; maximumCoupResult = DS4Check.DEFAULT_MAXIMUM_COUP_RESULT; - /** @override */ - get expression(): string { + override get expression(): string { return `ds${this.modifiers.join("")}`; } - /** @override */ - get total(): string | number | null | undefined { + override get total(): string | number | null | undefined { if (this.fumble) return 0; return super.total; } - /** @override */ - _evaluateSync({ minimize = false, maximize = false } = {}): this { + override _evaluateSync({ minimize = false, maximize = false } = {}): this { super._evaluateSync({ minimize, maximize }); this.evaluateResults(); return this; } - /** @override */ - roll({ minimize = false, maximize = false } = {}): DiceTerm.Result { + override roll({ minimize = false, maximize = false } = {}): DiceTerm.Result { // Swap minimize / maximize because in DS4, the best possible roll is a 1 and the worst possible roll is a 20 return super.roll({ minimize: maximize, maximize: minimize }); } @@ -109,20 +105,19 @@ export class DS4Check extends DiceTerm { } /** - * @override * @remarks "min" and "max" are filtered out because they are irrelevant for * {@link DS4Check}s and only result in some dice rolls being highlighted * incorrectly. */ - getResultCSS(result: DiceTerm.Result): (string | null)[] { + override getResultCSS(result: DiceTerm.Result): (string | null)[] { return super.getResultCSS(result).filter((cssClass) => cssClass !== "min" && cssClass !== "max"); } static readonly DEFAULT_CHECK_TARGET_NUMBER = 10; static readonly DEFAULT_MAXIMUM_COUP_RESULT = 1; static readonly DEFAULT_MINIMUM_FUMBLE_RESULT = 20; - static DENOMINATION = "s"; - static MODIFIERS = { + static override DENOMINATION = "s"; + static override MODIFIERS = { c: (): void => undefined, // Modifier is consumed in constructor for maximumCoupResult / minimumFumbleResult v: (): void => undefined, // Modifier is consumed in constructor for checkTargetNumber n: (): void => undefined, // Modifier is consumed in constructor for canFumble diff --git a/src/rolls/roll.ts b/src/rolls/roll.ts index 70b0fba0..653a5787 100644 --- a/src/rolls/roll.ts +++ b/src/rolls/roll.ts @@ -6,15 +6,14 @@ import { getGame } from "../helpers"; import { DS4Check } from "./check"; export class DS4Roll = Record> extends Roll { - static CHAT_TEMPLATE = "systems/ds4/templates/dice/roll.hbs"; + static override CHAT_TEMPLATE = "systems/ds4/templates/dice/roll.hbs"; /** - * @override * @remarks * This only differs from {@link Roll#render} in that it provides `isCoup` and `isFumble` properties to the roll * template if the first dice term is a ds4 check. */ - async render({ + override async render({ flavor, template = (this.constructor as typeof DS4Roll).CHAT_TEMPLATE, isPrivate = false, diff --git a/src/token-document.ts b/src/token-document.ts index cf829f0b..ad170f9f 100644 --- a/src/token-document.ts +++ b/src/token-document.ts @@ -21,7 +21,7 @@ function getFallbackData() { } export class DS4TokenDocument extends TokenDocument { - static getTrackedAttributes(data?: foundry.data.ActorData["data"], _path: string[] = []) { + static override getTrackedAttributes(data?: foundry.data.ActorData["data"], _path: string[] = []) { if (!data) { data = getFallbackData(); } diff --git a/tsconfig.json b/tsconfig.json index 9062a9a8..cfb0eda8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,7 @@ "forceConsistentCasingInFileNames": true, "strict": true, "noUncheckedIndexedAccess": true, + "noImplicitOverride": true, "resolveJsonModule": true, "importsNotUsedAsValues": "error" },