alpaca-trade-api-js
alpaca-trade-api-js copied to clipboard
[Typescript] Allow for getOrders flexibility without throwing an error
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
Yep, just tried it by adding question marks to all the parameters and it worked!
