-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Labels
Description
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:
postmark.js/src/client/ServerClient.ts
Lines 236 to 245 in 62dfe1f
| /** | |
| * 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.