Monday 5 June 2017

Nodejs require('this')(that) in Typescript

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



via Dave Smith

No comments:

Post a Comment