0

I am trying to create a definition file for the Vogels library. This library wraps the AWS SDK, so it also includes a property that exports the entire AWS SDK.

declare module "vogels" {
  import AWS = require('aws-sdk');

  export function define(modelName: String, config: any): void;
  export var AWS: AWS;      /* THIS LINE DOESN'T TRANSPILE */
}

This library is used like this:

import vogels = require('vogels');

vogels.AWS.config.update({region: region});

var model = vogels.define('test', {
  ..
  }
});

Unfortunately, exporting the AWS property from the "vogels" module doesn't work, because AWS is not considered a type. How can I export the AWS property without replicating the entire AWS definitions in my module?

1 Answer 1

2

This seems to be the way to export the entire AWS module and the define function:

declare module "vogels" {
  import AWS = require('aws-sdk');

  function define(modelName: String, config: any): void;

  export = { AWS, define }
}

You can only have a single export = in a module, so all exported variables should be in that line (of course you can split it across multiple lines). Don't export anything else, but only define interfaces, variables, ... The actual export is done later.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.