Enhance typings of AbstractFulfillmentService #6948
gempain
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In the docs, the
AbstractFulfillmentService
has most method arguments and return types typed asRecord<string, unknown>
. It's a bit IMO to implement a proper provider with what's in the docs. For example, no where is it mentioned that fulfilment provider options can have a propertyis_return
to filter them (see #6946 and #6947 for a bug / solution I found).From my understanding, you typed the
Record<string, unknown>
but you still expect some magic props to be present.I think an improvement in typing there would be needed. Especially understanding how the types returned by some of the methods would come back in other methods to be manipulated. I have a hard time understanding how data flows through those methods.
From what I was able to gather from the docs, the signature of
calculatePrice
is:In the end, I realize that
FulfillmentProviderData
,FulfilmentData≤
,ShippingOptionData
, andShippingMethodData
are or can be the same.getFulfillmentOptions
returns a list ofShippingMethodData
, passed tovalidateFulfillmentData
(the second argument beingdata: FulfillmentProviderData
and always and empty object{}
at runtime; I don't know whether there is a flow where theFulfillmentProviderData
returned bycreateFulfillment
comes back there so I don't know if those types are linked). I'm not sure what one should to with thedata
argument ofvalidateFulfillmentData
, so I just either merge it withoptionData
or just returnoptionData
.First and second arguments of
calculatePrice
contain the same value (probably because what's returned byvalidateFulfillmentData
.What's so special about thet
data
arg ofvalidateFulfillmentData
?Keep up the great work 🚀
Beta Was this translation helpful? Give feedback.
All reactions