Skip to content

Commit

Permalink
fix(core): Correct shipping calculator typing
Browse files Browse the repository at this point in the history
* refactor: Update shipping calculator typing

* refactor: Update CalculateShippingFnResponse name
  • Loading branch information
jonyw4 authored and michaelbromley committed Jul 24, 2020
1 parent af76358 commit 9052845
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/core/src/config/shipping-method/shipping-calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ export class ShippingCalculator<T extends ShippingCalculatorArgs = {}> extends C
*
* @internal
*/
calculate(
order: Order,
args: ConfigArg[],
): ShippingCalculationResult | Promise<ShippingCalculationResult> | undefined {
calculate(order: Order, args: ConfigArg[]): CalculateShippingFnResult {
return this.calculateFn(order, argsArrayToHash(args));
}
}
Expand Down Expand Up @@ -90,6 +87,11 @@ export interface ShippingCalculationResult {
metadata?: Record<string, any>;
}

export type CalculateShippingFnResult =
| ShippingCalculationResult
| Promise<ShippingCalculationResult | undefined>
| undefined;

/**
* @description
* A function which implements the specific shipping calculation logic. It takes an {@link Order} and
Expand All @@ -103,4 +105,4 @@ export interface ShippingCalculationResult {
export type CalculateShippingFn<T extends ShippingCalculatorArgs> = (
order: Order,
args: ConfigArgValues<T>,
) => ShippingCalculationResult | Promise<ShippingCalculationResult> | undefined;
) => CalculateShippingFnResult;

0 comments on commit 9052845

Please sign in to comment.