Skip to content
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

typescript error: get() params is not optional, per_page param is not available in other endpoints #25

Closed
coycoylaniba opened this issue Mar 16, 2023 · 7 comments

Comments

@coycoylaniba
Copy link

get parameters should be optional
api.get("endpoint") Expected 2 arguments, but got 1. index.d.ts(15, 52): An argument for 'params' was not provided.

per_page is not available in other endpoints aside from webhook (which is webhook is not in the endpoints either)
Argument of type '{ status: string; per_page: number; }' is not assignable to parameter of type 'WooRestApiParams'. Object literal may only specify known properties, and 'per_page' does not exist in type 'WooRestApiParams'.

package.json
"woocommerce-rest-ts-api": "^2.0.0",

@Yuri-Lima
Copy link
Owner

Hi, @coycoylaniba.

Can y give an example what endpoits those param is not available, please? Because in my test it was. Let me check it please.

Thanks

@coycoylaniba
Copy link
Author

this end points

node_modules/woocommerce-rest-ts-api/dist/src/typesANDinterfaces.d.ts:
export declare type WooRestApiEndpoint = "coupons" | "customers" | "orders" | "products" | "system_status";

Yuri-Lima added a commit that referenced this issue Mar 18, 2023
Get params should be optional

BREAKING CHANGE: Params must be optional since we could use the endpoit with/without it

#25
github-actions bot pushed a commit that referenced this issue Mar 18, 2023
# [6.0.0](v5.0.10...v6.0.0) (2023-03-18)

### Bug Fixes

* **component:** params should be optional ([9284915](9284915)), closes [#25](#25)

### BREAKING CHANGES

* **component:** Params must be optional since we could use the endpoit with/without it
@Yuri-Lima
Copy link
Owner

Check the latest version and let me know @coycoylaniba

Thank you.

@coycoylaniba
Copy link
Author

hello sir, the params type error is fixed. but i have another problem, if i do "products/:productId"
this error shows up
Argument of type 'string' is not assignable to parameter of type 'WooRestApiEndpoint'.

@Yuri-Lima
Copy link
Owner

For while, if you want to use it like that is not possible, you would have to use it as a Parameter, in my opinion, it becomes a bit clear than direct if not leave your thoughts about that.

Thanks @coycoylaniba

@coycoylaniba
Copy link
Author

oh okay thanks, will try it

@Yuri-Lima
Copy link
Owner

@coycoylaniba just to know.
Was everything ok?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants