elastic / elastic/apm-agent-nodejs

Typescript - Unable to export `Agent#lambda(...)` from client library due to absence of exported inline AwsLambda.Context.

Open
#977 5 comments 0 reactions 1 assignee Assigned to @trentm View on GitHub
8.9-candidate agent-nodejs bug
Dominant language
JavaScript
Stars
594
Forks
244
Avg merge
1d 8h
Merged PRs (30d)
16

Description

**Is your feature request related to a problem?**
It's currently not possible to export a function form a typescript module when calling `Agent#lambda` because the interface [`AwsLambda#Context`](https://github.com/elastic/apm-agent-nodejs/blob/master/index.d.ts#L228) (defined in-line) is not exported in `index.d.ts`.

```
// Typescript file: some-app.ts
import apm = require('elastic-apm-node');
const apmInstance = apm.start();

export const run = apmInstance.lambda({} as any); // ERROR: Exported variable 'run' has or is using name 'AwsLambda.Context' from external module [...]
```

**Describe the solution you'd like**
`AwsLambda` could potentially be exported (?). Might be tricky since we currently export a default agent with `export =`.

**Describe alternatives you've considered**
1) Currently hacking by adding `as any` when exporting function from typescript file.
```
export const run = apmInstance.lambda({} as any) as any;
```
2) Directly exporting AwsLambda but blocked by default export of `Agent`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.