onfleet / node-onfleet

Onfleet API wrapper in NodeJS
MIT License
18 stars 18 forks source link

[BUG] the type declaration for tasks.batchCreate is incorrect. #85

Closed murphp15 closed 1 year ago

murphp15 commented 1 year ago

Describe the bug In the documentation it says batchCreate should take in an array

declare class Task {
    batchCreate(tasks: Task.CreateTaskProps[]): Promise<Task.OnfleetTask[]>;

However this is not correct. It needs an outer "tasks" element for the api to accept it.

To Reproduce

// @ts-ignore
const result = await onfleetApi.tasks.batchCreate([array of Task.CreateTaskProps])
// errors from server

To Fix

// @ts-ignore
const result = await onfleetApi.tasks.batchCreate(
                {
                    // @ts-ignore
                    tasks: [array of Task.CreateTaskProps]
                })
omikader commented 1 year ago

+1, I'm getting this error when I use the signature in Task.d.ts

"Batch task creation requires that you provide a 'tasks' array property."
YokySantiago commented 1 year ago

This PR will fix the issue once it is approved and merged https://github.com/DefinitelyTyped/DefinitelyTyped/pull/64019

YokySantiago commented 1 year ago

New @types/onfleet__node-onfleet version has been release. Please use the version 1.3.2