import ngstorage with webpack

2019-08-29 09:19发布

I am trying to import npm package ngstorage in my angularjs v1.x (typescript) project using @types/ngstorage

the index.d.ts contains

declare namespace angular.storage {

        export interface IStorageService {
        }
}

if I do like below in my .ts files

import * as angular from 'angular';

var storage: angular.storage.IStorageService;

I am getting compilation error

namespace angular and no exported member storage

1条回答
叛逆
2楼-- · 2019-08-29 09:40

finally I was able to get it work

        import { ngStorage } from 'ngStorage';

the namespace and not the package name should matter when doing an import

查看更多
登录 后发表回答