-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect inferred typing when using operation and endpoint #244
Comments
This is still an issue on |
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? |
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. |
@jakeleventhal @pradeep-gox Sorry this topic did not get the attention in the past as it should have. I see the issue. However changing it as proposed in #290 would result in a big breaking change for everyone. I see basically three options:
What do you think? |
I prefer a major version upgrade with breaking changes to get a "correct" solution. If people do not pin packages, it is on them |
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
The text was updated successfully, but these errors were encountered: