You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Working on an integration with the vezgo-sdk (currently v1.1.0) on a TypeScript project. Running into a bit of frustration as, although the types used by the sdk are defined, they are not exported so they cannot be imported and easily re-utilized by integrating software. For instance, a simple utility function like this:
Return type of exported function has or is using name 'APIInterface' from external module ".../node_modules/vezgo-sdk-js/lib/vezgo" but cannot be named.ts(4058)
function initializeVezgo(): APIInterface
This is because the typescript compiler needs to provide type information about the return value of the function initializeVezgo to consumers of that function, but the type (APIInterface) is not exported by the vezgo sdk, so it cannot be utilized by the compiler. Currently, we're able to work around this by re-declaring local types from the output types using TypeScript utility functions (example below), but this rather clunky.
Example of how we're able to create workable types:
export type VezgoAPIInterface = ReturnType<typeof Vezgo.init>;
export type VezgoAPIUserInterface = ReturnType<VezgoAPIInterface['login']>;
export type VezgoAPIUserAccounts = VezgoAPIUserInterface['accounts'];
export type VezgoAccount = Exclude<
ReturnType<Awaited<ReturnType<VezgoAPIUserAccounts['getList']>>['at']>,
undefined
>;
// Declaration valid using re-declared type as return value
export function initializeVezgo(): VezgoAPIInterface {
const clientId = process.env['VEZGO_CLIENT_ID']!;
const secret = process.env['VEZGO_SECRET']!;
return Vezgo.init({
clientId,
secret,
});
}
It would be a lot simpler if the interfaces defined in index.d.ts were exported so that consumers of the sdk could directly reference the types declared there. If this change is desirable for the maintainers, I would be happy to provide a PR for it.
The text was updated successfully, but these errors were encountered:
Hello!
Working on an integration with the vezgo-sdk (currently v1.1.0) on a TypeScript project. Running into a bit of frustration as, although the types used by the sdk are defined, they are not exported so they cannot be imported and easily re-utilized by integrating software. For instance, a simple utility function like this:
Produces this error:
This is because the typescript compiler needs to provide type information about the return value of the function initializeVezgo to consumers of that function, but the type (APIInterface) is not exported by the vezgo sdk, so it cannot be utilized by the compiler. Currently, we're able to work around this by re-declaring local types from the output types using TypeScript utility functions (example below), but this rather clunky.
Example of how we're able to create workable types:
It would be a lot simpler if the interfaces defined in index.d.ts were exported so that consumers of the sdk could directly reference the types declared there. If this change is desirable for the maintainers, I would be happy to provide a PR for it.
The text was updated successfully, but these errors were encountered: