I am still learning typescript, so I got stuck. Also couldnt find anything online.
I am using meteor js which has the following module declaration meteor.d.ts:
declare module 'meteor/meteor' {
type global_Error = Error;
module Meteor {
/** User **/
interface UserEmail {
address: string;
verified: boolean;
}
interface User {
_id: string;
username?: string | undefined;
emails?: UserEmail[] | undefined;
createdAt?: Date | undefined;
profile?: any;
services?: any;
}
function user(options?: { fields?: Mongo.FieldSpecifier | undefined }): User | null;
function userId(): string | null;
var users: Mongo.Collection<User>;
/** User **/
}
}
Now I have some additional Fields for a user, so I would like to extend the interface User in the module Meteor with some fields:
interface UserAdditonal {
field1: string
field2: string
field3: string
}
How would I do that? I tried this:
declare module "meteor/meteor" {
module Meteor {
function user(options?: {
fields?: Mongo.FieldSpecifier | undefined
}): (User & userAdditonal) | null
var users: Mongo.Collection<User & userAdditonal>
}
}
Which throws an error meteor.d.ts(56, 13): 'users' was also declared here. and also only works in the same file. Also it is more like overwriting, and less like extending
Is it possible to do globally, so I declare it in one file and all other files that import 'meteor/meteor' get the extended types without importing my file?
Any help is greatly appreciated!