diff --git a/types/newrelic/index.d.ts b/types/newrelic/index.d.ts index a5fd434d99..10700022df 100644 --- a/types/newrelic/index.d.ts +++ b/types/newrelic/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for newrelic 3.4 +// Type definitions for newrelic 4.11 // Project: http://github.com/newrelic/node-newrelic // Definitions by: Matt R. Wilson // Brooks Patton +// Michael Bond // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // https://docs.newrelic.com/docs/agents/nodejs-agent/api-guides/nodejs-agent-api @@ -321,6 +322,14 @@ export const instrumentMessages: Instrument; export function shutdown(cb?: (error?: Error) => void): void; export function shutdown(options?: { collectPendingData?: boolean, timeout?: number }, cb?: (error?: Error) => void): void; +/** + * Wraps an AWS Lambda function with NewRelic instrumentation and returns the value of the handler + * + * @param handler a callback function whose value is returned from setLambdaHandler + * @returns the value returned by handler + */ +export function setLambdaHandler(handler: (...args: any[]) => T): T; + export interface Instrument { (opts: { moduleName: string, onRequire: () => void, onError?: (err: Error) => void }): void; (moduleName: string, onRequire: () => void, onError?: (err: Error) => void): void; diff --git a/types/newrelic/newrelic-tests.ts b/types/newrelic/newrelic-tests.ts index 29eabfeb21..9bc909d57c 100644 --- a/types/newrelic/newrelic-tests.ts +++ b/types/newrelic/newrelic-tests.ts @@ -104,3 +104,5 @@ newrelic.shutdown({ collectPendingData: true, timeout: 3000 }, (err) => { newrelic.shutdown((err) => { const error: Error | undefined = err; }); + +newrelic.setLambdaHandler(() => void 0); // $ExpectType undefined