Skip to content

Contradicting typescript type definition vs api call methods in .dev/api.js #58

@nschainblatt

Description

@nschainblatt

My response to this forum question contains additional context.

Type contradiction:

export type TMulticall = <T = any>(calls: TCallParams[]) => Promise<T[]>;

callXHR method non-error return value (which is used in each geoApi call method):

return { abort: function () { xhr.abort(); } }

Conclusion:
The type should either be corrected to show the developer the usage of success and error callbacks, or the development api should be updated to return the specified promise.

Current workaround (ts-ignore required to not error out due to type contradiction):

// Success callback
// @ts-ignore
geoApi.multiCall<any>(calls, (results) => console.debug("success callback results: ", results), (error) => console.error(error));
                                                                                                                                  
// Async Await (needs additional error handling, if rej gets called and awaited it will throw an error)
// @ts-ignore
const results = await new Promise((res, rej) => geoApi.multiCall<any>(calls, (results) => res(results), (error) => rej(error)));
console.debug("async await results: ", results);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions