Skip to content

Commit

Permalink
feat: getEnhancerByName accept generic parameter
Browse files Browse the repository at this point in the history
Signed-off-by: Douglas McConnachie <[email protected]>
  • Loading branch information
dougal83 committed Apr 18, 2020
1 parent fbcedbc commit 1d46514
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/openapi-v3/src/enhancers/spec-enhancer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ export class OASEnhancerService {
* Find an enhancer by its name
* @param name The name of the enhancer you want to find
*/
async getEnhancerByName(name: string): Promise<OASEnhancer | undefined> {
async getEnhancerByName<T extends OASEnhancer>(
name: string,
): Promise<T | undefined> {
// Get the latest list of enhancers
const enhancers = await this.getEnhancers();
return enhancers.find(e => e.name === name);
return enhancers.find(e => e.name === name) as T | undefined;
}

/**
Expand Down

0 comments on commit 1d46514

Please sign in to comment.