From 1976628b163139d0b31dfdb85257e89c3470f191 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Tue, 26 Jul 2022 19:27:22 -0500 Subject: [PATCH] Fixed modifier typing --- src/game/modifiers.tsx | 57 ++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/src/game/modifiers.tsx b/src/game/modifiers.tsx index 54f9a95..72108ef 100644 --- a/src/game/modifiers.tsx +++ b/src/game/modifiers.tsx @@ -46,27 +46,22 @@ export type ModifierFromOptionalParams = T extends undefined : WithRequired; /** An object that configures an additive modifier via {@link createAdditiveModifier}. */ -export interface AdditiveModifierOptions< - T extends Computable | undefined, - S extends Computable | undefined -> { +export interface AdditiveModifierOptions { /** The amount to add to the input value. */ addend: Computable; /** Description of what this modifier is doing. */ - description?: T; + description?: Computable | undefined; /** A computable that will be processed and passed directly into the returned modifier. */ - enabled?: S; + enabled?: Computable | undefined; } /** * Create a modifier that adds some value to the input value. * @param optionsFunc Additive modifier options. */ -export function createAdditiveModifier< - T extends Computable | undefined, - S extends Computable | undefined, - R = ModifierFromOptionalParams ->(optionsFunc: () => AdditiveModifierOptions): R { +export function createAdditiveModifier( + optionsFunc: () => T +): ModifierFromOptionalParams { return createLazyProxy(() => { const { addend, description, enabled } = optionsFunc(); @@ -95,31 +90,26 @@ export function createAdditiveModifier< )) }; - }) as unknown as R; + }) as unknown as ModifierFromOptionalParams; } /** An object that configures an multiplicative modifier via {@link createMultiplicativeModifier}. */ -export interface MultiplicativeModifierOptions< - T extends Computable | undefined, - S extends Computable | undefined -> { +export interface MultiplicativeModifierOptions { /** The amount to multiply the input value by. */ multiplier: Computable; /** Description of what this modifier is doing. */ - description?: T; + description?: Computable | undefined; /** A computable that will be processed and passed directly into the returned modifier. */ - enabled?: S; + enabled?: Computable | undefined; } /** * Create a modifier that multiplies the input value by some value. * @param optionsFunc Multiplicative modifier options. */ -export function createMultiplicativeModifier< - T extends Computable | undefined, - S extends Computable | undefined, - R = ModifierFromOptionalParams ->(optionsFunc: () => MultiplicativeModifierOptions): R { +export function createMultiplicativeModifier( + optionsFunc: () => T +): ModifierFromOptionalParams { return createLazyProxy(() => { const { multiplier, description, enabled } = optionsFunc(); @@ -147,31 +137,26 @@ export function createMultiplicativeModifier< )) }; - }) as unknown as R; + }) as unknown as ModifierFromOptionalParams; } /** An object that configures an exponential modifier via {@link createExponentialModifier}. */ -export interface ExponentialModifierOptions< - T extends Computable | undefined, - S extends Computable | undefined -> { +export interface ExponentialModifierOptions { /** The amount to raise the input value to the power of. */ exponent: Computable; /** Description of what this modifier is doing. */ - description?: T; + description?: Computable | undefined; /** A computable that will be processed and passed directly into the returned modifier. */ - enabled?: S; + enabled?: Computable | undefined; } /** * Create a modifier that raises the input value to the power of some value. * @param optionsFunc Exponential modifier options. */ -export function createExponentialModifier< - T extends Computable | undefined, - S extends Computable | undefined, - R = ModifierFromOptionalParams ->(optionsFunc: () => ExponentialModifierOptions): R { +export function createExponentialModifier( + optionsFunc: () => T +): ModifierFromOptionalParams { return createLazyProxy(() => { const { exponent, description, enabled } = optionsFunc(); @@ -199,7 +184,7 @@ export function createExponentialModifier< )) }; - }) as unknown as R; + }) as unknown as ModifierFromOptionalParams; } /**