-1

I'm using @awspilot/dynamodb in a node lambda function, but also using typescript.

A standard nodejs var x = require('x') becomes import * as x from 'x' in typescript no problem - but @awspilot/dynamodb needs the slightly more unusual:

var $db = new AWS.DynamoDB()
var awspilotDB = require('@awspilot/dynamodb')($db)

Is there a typescript-y way of rendering this as an import and still passing the extra parameter?

Thanks,

D

Dave Smith
  • 13
  • 4

1 Answers1

0

require('@awspilot/dynamodb') is returning a function. Therefore the following should work fine:

import * as DynamodbFactory from '@awspilot/dynamodb'
const awspilotDB = DynamodbFactory($db)

You can, of course, choose whatever name you like for DynamodbFactory.


Alternatively you can also use the require function with TypeScript as described here

schrej
  • 450
  • 3
  • 10