question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 (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;
  1. Directly exporting AwsLambda but blocked by default export of Agent

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jpike88commented, May 14, 2021

This is pain in the butt, just ran into this… how is it that this is the only library out of hundreds I’ve seen that decides to break TS in such a weird way? Why not just fix your declaration files so paying customers can use types without hassle?

Exported variable 'apm' has or is using name 'Agent' from external module "/server/node_modules/elastic-apm-node/index" but cannot be named.

Just bump the major version, and change how the exports from your declaration file are done, it’s worth it for such a critical issue as it renders your types useless outside an extremely simple use case.

0reactions
trusktrcommented, Dec 21, 2019

I’ve opened a request to fix issues like these in TypeScript by bringing declaration files to parity with language features. https://github.com/microsoft/TypeScript/issues/35822

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS Lambda function handler in TypeScript
The AWS Lambda function handler is the method in your function code that ... export const lambdaHandler = (event: APIGatewayEvent, context: Context, ...
Read more >
TypeScript on AWS Lambda: to bundle imports (how?) or not ...
AWS SDK for JavaScript v3 (AKA modular) is not installed globally in the lambda execution context.
Read more >
Hello Lambda | AWS CDK Workshop
Lambda handler code # We'll start with the AWS Lambda handler code. Create a directory lambda in the root of your project tree...
Read more >
How to Use TypeScript for AWS Lambda in 3 Steps | by Zi Zhao
When we are using NodeJS as the runtime for AWS Lambdas, JavaScript is the default language. However, due to the lack of typing...
Read more >
Build functions - Netlify Docs
Create functions source files in TypeScript, JavaScript, and Go. Use environment variables with functions, manage dependencies, and test locally.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found