Typescript - Unable to export `Agent#lambda(...)` from client library due to absence of exported inline AwsLambda.Context.
See original GitHub issueIs 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
- Currently hacking by adding
as any
when exporting function from typescript file.
export const run = apmInstance.lambda({} as any) as any;
- Directly exporting AwsLambda but blocked by default export of
Agent
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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