This is interface
interface User {
_id: string;
username?: string | undefined;
emails?: UserEmail[] | undefined;
createdAt?: Date | undefined;
profile?: UserProfile;
services?: any;
}
i can’t find it in docs: Users and Accounts | Meteor Guide
was it removed? If yes then in which release?
If my users
always has field email
, firstName
and similar, how can I use interface with my real User to return it from Meteor.users.find()
?
For other collections I am doing this
export const Settings = new Mongo.Collection<Setting>('settings');
1 Like
Have you tried npm install --save-dev @types/meteor
?
Hello there! We started using zodern:types
in an effort to bring the types into Meteor core.
You can check how to use them here
In the matter of updating your return type for Meteor.users type
, I think we have discussed this on Slack link once, but it has been some time, I could not find it.
Maybe @radekmie remembers this talk that we had once there.
I think it has something to do with using the declare global
link for examples
I’m not sure if I got you right, @gustawdaniel1.
- This interface was never in Meteor docs, or at least I newer saw that there.
- It was a part of the
@types/meteor
package, i.e., TypeScript definitions hosted on Definitely Typed.
- Now it got moved to Core (i.e.,
meteor/meteor
repo) and is accessible using zodern:types
.
Finally, if you’d like to extend it in your app, because you made some changes and your users always have additional fields (e.g., email
or firstName
), you can do that by extending this interface:
declare module 'meteor/meteor' {
interface User {
email: string;
firstName: string;
}
}