diff --git a/types/newrelic/index.d.ts b/types/newrelic/index.d.ts index 202dd95b74..b6166e7608 100644 --- a/types/newrelic/index.d.ts +++ b/types/newrelic/index.d.ts @@ -7,6 +7,7 @@ // Kenneth Aasan // Jon Flaishans // Dylan Smith +// BlueJeans by Verizon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // https://docs.newrelic.com/docs/agents/nodejs-agent/api-guides/nodejs-agent-api @@ -356,12 +357,12 @@ export function getLinkingMetadata(omitSupportability?: boolean): LinkingMetadat export function getTraceMetadata(): TraceMetadata; /** - * Wraps an AWS Lambda function with NewRelic instrumentation and returns the value of the handler + * Wraps an AWS Lambda function with NewRelic instrumentation and returns the wrapped function. * - * The handler is a callback function whose value is returned from setLambdaHandler - * Returns the value returned by handler + * The handler should be an AWS Lambda handler function. + * Returns a function with identical signature to the provided handler function. */ -export function setLambdaHandler(handler: (...args: any[]) => T): T; +export function setLambdaHandler any>(handler: T): T; export interface Instrument { (opts: { moduleName: string; onRequire: () => void; onError?: (err: Error) => void }): void; diff --git a/types/newrelic/newrelic-tests.ts b/types/newrelic/newrelic-tests.ts index ac4d386f8d..09f4d6cdd1 100644 --- a/types/newrelic/newrelic-tests.ts +++ b/types/newrelic/newrelic-tests.ts @@ -122,4 +122,6 @@ newrelic.getLinkingMetadata(); newrelic.getLinkingMetadata(true); newrelic.getTraceMetadata(); -newrelic.setLambdaHandler(() => void 0); // $ExpectType undefined +newrelic.setLambdaHandler(() => void 0); // $ExpectType () => undefined +newrelic.setLambdaHandler((event: unknown, context: unknown) => ({ statusCode: 200, body: "Hello!" })); // $ExpectType (event: unknown, context: unknown) => { statusCode: number; body: string; } +newrelic.setLambdaHandler({some: "object"}); // $ExpectError