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] Allow for getOrders flexibility without throwing an error #182

Open
davidstackio opened this issue Jan 6, 2022 · 1 comment

Comments

@davidstackio
Copy link

Thinking the types for getAll() needs updated to allow for not including ALL the parameters. They should all be optional. I believe the file is order.d.ts.

I'm expecting to write code like this:
openOrders = await alpaca.getOrders({ status: "open", limit: "500" });

Without getting this error:

error TS2345: Argument of type '{ status: string; limit: string; }' is not assignable to parameter of type '{ status: any; until: any; after: any; limit: any; direction: any; nested: any; }'.
  Type '{ status: string; limit: string; }' is missing the following properties from type '{ status: any; until: any; after: any; limit: any; direction: any; nested: any; }': until, after, direction, nested

I think all it needs is some question marks after the optional parameters: https://www.typescriptlang.org/docs/handbook/2/functions.html#optional-parameters

@davidstackio
Copy link
Author

Yep, just tried it by adding question marks to all the parameters and it worked!
image

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

1 participant