During the compilation of Meteor, an error in the console states "Property 'Collection' does not exist on type 'typeof Mongo'." I'm curious if anyone has encountered this issue before and how they resolved it.
I am working with meteor/react.
This is my TypeScript class code:
import { Mongo } from 'meteor/mongo';
import MongoCollection from '../../lib/MongoCollection';
class Entries extends MongoCollection {
public collection: any;
constructor() {
super();
this.collection = new Mongo.Collection('entries');
}
}
export let Entries = new Entries();
The MongoCollection.ts file contains:
import * as _ from 'lodash';
import * as moment from 'moment-timezone';
interface CommonSchema {
_id: string;
createdAt?: string;
updatedAt?: string;
}
class MongoCollection {
collection: any;
aggregate = (selector: object = {}, options: object = {}) => {
return this.collection.aggregate(selector, options);
}
find = (selector: object = {}, options: object = {}) => {
return this.collection.find(selector, options);
}
first = (selector: object = {}, options: object = {}) => {
return this.collection.findOne(selector, options);
}
where = (selector: object = {}, options: object = {}) => {
return this.find(selector, options).fetch();
}
count = (selector: object = {}, options: object = {}) => {
return this.find(selector, options).count();
}
beforeInsert = (doc: CommonSchema, beforeInsertAttrs: object): object => {
const { createdAt } = doc;
if (typeof createdAt === 'undefined') {
doc.createdAt = moment().tz('America/New_York').format();
}
doc.updatedAt = moment().tz('America/New_York').format();
_.extend(doc, beforeInsertAttrs);
return doc;
}
insert = (doc, beforeInsertAttrs): string => {
let newDoc: object = this.beforeInsert(doc, beforeInsertAttrs);
const _id: string = this.collection.insert(newDoc);
return _id;
}
update = () => {}
}
export default MongoCollection;
The specific console warning reads:
Property 'Collection' does not exist on type 'typeof Mongo'.
Any assistance on resolving this issue would be greatly appreciated. Thank you!