Open jakeleventhal opened 11 months ago
@amz-tools
This is still an issue on 1.0.0
and is a blocker for wanting to have any sort of type inferencing
I can fix this myself. Can @amz-tools please provide some guidance for how to fix this?
@jakeleventhal How did you go about fixing this? Do we need to rewrite all the nested types ourselves?
@jakeleventhal How did you go about fixing this? Do we need to rewrite all the nested types ourselves?
import { GetOrderPath, GetOrderResponse } from 'amazon-sp-api/lib/typings/operations/orders';
async getOrder(orderId: string): Promise<GetOrderResponse['payload']> {
try {
const order = await this.sellingPartner.callAPI({
operation: 'orders.getOrder',
path: { orderId } as GetOrderPath
});
return order;
} catch (err) {
const handledError = await this.handleAPIError(err);
throw handledError;
}
}
annoying, but works
@amz-tools any guidance here? Will gladly take this on.
This is still an issue, it'd be great if it could be corrected as others migrate to newest version and need to make use of type checking
+1
I assume this is the following piece of code in the SellingPartner.js lib file, which causes this problem. @amz-tools IMO, I think the developers could do the transformation/processing of the response. The raw json response from the sp-api should be returned for better consistency.
When making calls the API using inferred types (endpoint + operation), I am getting the wrong type for my
payload
variable.It seems to think that i should be destructuring
payload
when the value is already destructured. Below is what i see when i logpayload