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

Type Definition for getTemplates() Method Not Exposed in ServerClient Type #167

Open
zbruhnke opened this issue Dec 9, 2024 · 0 comments

Comments

@zbruhnke
Copy link

zbruhnke commented Dec 9, 2024

Description

The getTemplates() method is implemented in ServerClient class but its type definition is not properly exposed in the public TypeScript interface. This causes TypeScript errors when trying to use the method, requiring type assertions to work around the issue.

Implementation vs Types

The method is implemented here:

/**
* Create a new template on the associated server.
*
* @param options - Configuration options to be used to create the Template.
* @param callback If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public createTemplate(options: CreateTemplateRequest, callback?: Callback<Template>): Promise<Template> {
return this.processRequestWithBody(ClientOptions.HttpMethod.POST, "/templates/", options, callback);
}

public getTemplates(filter: TemplateFilteringParameters = new TemplateFilteringParameters(),
                    callback?: Callback<Templates>): Promise<Templates> {
    this.setDefaultPaginationValues(filter);
    return this.processRequestWithoutBody(ClientOptions.HttpMethod.GET, "/templates", filter, callback);
}

However, when using the package, TypeScript doesn't recognize this method on the ServerClient type.

Reproduction

import { ServerClient } from 'postmark';

const client = new ServerClient('API_KEY');

// TypeScript error: Property 'getTemplates' does not exist on type 'ServerClient'
const templates = await client.getTemplates();

Expected Behavior

The getTemplates() method should be included in the public TypeScript interface for ServerClient, matching its implementation.

Current Workaround

const templates = await (client as any).getTemplates();

Environment

  • postmark package version: 4.0.5
  • TypeScript version: 5.0.4
  • Node.js version: 24.1.0

Possible Fix

The type definition for getTemplates should be included in the public interface of ServerClient.

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