模块'“mongoose”'没有导出成员'PaginateResult'

时间:2017-07-06 18:47:55

标签: angular typescript webpack angular-cli

我似乎无法将mongoose-paginate类型添加到使用Angular 4的angular-cli项目设置中.Webpack正在抛出

import {PaginateResult} from "mongoose";

...

getAll(page: number): Observable<PaginateResult<Operation>> {
    ...
}

在Webstorm中按住Ctrl键单击PaginateResult可打开正确的文件定义。这些类型已正确安装在node_modules/@types目录中(我使用npm install --save @types/mongoose-paginate安装了它们)。

然而,webpack正在抛出:

ERROR in /Users/geoffroy/dev/git/ezvat/client4/src/app/components/operations/operation.service.ts (8,9): Module '"mongoose"' has no exported member 'PaginateResult'.

发生了什么事?

1 个答案:

答案 0 :(得分:1)

导入mongoose-paginate模块

import * as mongoosePaginate from 'mongoose-paginate';

似乎没有导入它就找不到正确的命名空间。我发现它使用了DefinitelyTyped repo https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/mongoose-paginate/mongoose-paginate-tests.ts

中的测试