ishandutta2007
ishandutta2007

Reputation: 18194

Module has no exported member 'AWS'

Can someone help me understand how different the namespace and module is?

AWS.d.ts

declare module AWS {
  ...
  ...
}
export = AWS

helper.d.ts

export declare namespace Helpers{
  ...
  ...
}

app.component.d.ts

import {Helpers} from 'mystartup_commons'; //<= works fine
import {AWS} from 'aws-sdk';

Error:

ERROR in /Users/ishandutta2007/Documents/Projects/myproj/src/app/app.component.ts (1,9): Module '"/Users/is handutta2007/Documents/Projects/myproj/node_modules/aws-sdk/typings/AWS"' has no exported member 'AWS'.)

Upvotes: 6

Views: 11501

Answers (4)

Expert Ngobeni
Expert Ngobeni

Reputation: 70

Issue was resolve on Github: node_modules/aws-sdk/index has no default export #2654

Import module you want to use instead of AWS from aws-sdk

Javascript sample:

const aws = require('aws-sdk')
let s3 = new aws.S3();

Typescript:

import { config, S3 } from 'aws-sdk';
import {
  Buckets,
  GetObjectOutput,
  ListBucketsOutput,
  PutObjectRequest 
} from 'aws-sdk/clients/s3';
import { createReadStream } from 'fs';

Upvotes: -1

edzillion
edzillion

Reputation: 3661

I believe that the reason that the aws-sdk has no default export is because they want developers to only import the packages they need. e.g.

import { s3 } from 'aws-sdk';

Upvotes: 5

ishandutta2007
ishandutta2007

Reputation: 18194

adding a reference path to node's definition file and using * as did the trick

app.component.d.ts

/// <reference path="../../node_modules/@types/node/index.d.ts"/>
import * as AWS from 'aws-sdk';

Upvotes: 14

Sergey Mell
Sergey Mell

Reputation: 8040

  1. You have a typo: modeule instead of module
  2. Seems like you can't export whole module. See here https://www.typescriptlang.org/docs/handbook/modules.html https://www.typescriptlang.org/docs/handbook/namespaces-and-modules.html

Upvotes: 0

Related Questions