我似乎无法将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'.
发生了什么事?
答案 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
中的测试