【发布时间】:2017-06-26 10:31:43
【问题描述】:
基于socially project,我尝试扩展用户添加字段:
export interface User extends Meteor.User {
experience: number;
}
但是我得到以下错误:
client/imports/app/parties/party-details.component.ts (71, 7): Type 'Observable<User[]>' is not assignable to type 'Observable<User>'.
Type 'User[]' is not assignable to type 'User'.
Property 'experience' is missing in type 'User[]'.
据我了解,这是因为集合定义:
export const Users = MongoObservable.fromExisting(Meteor.users);
它使用Meteor.users(不带experience field)而不是我的自定义打字稿定义版本(带experience field)。
更新
相关文件:
我该如何解决这个问题?或者换句话说:如何扩展 angular-meteor 项目的用户模型?
更新 2
我想将问题改写为:如何扩展 Meteor 用户集合?
export const Users = MongoObservable.fromExisting(Meteor.users);
额外问题:我如何在创建新用户时使用0 启动该字段?
【问题讨论】:
-
能否为第 71 行的 party-details.component.ts 添加代码以及如何声明 Observable,我认为问题出在:
Type 'User[]' is not assignable to type 'User'缺少体验错误可能只是一个第一个错误的后果 -
我没有触摸
party-details.component.ts组件。我只是将体验添加到用户模型中。对我来说还没有意义。
标签: meteor angular-meteor