I’m really new to typescript and wonder how to set a type to a collection.
This is my part of the react component. I need to pull a user document from Users collection.
const user = useTracker(() => Users.find({_id: userId}).fetch(), [userId]);
I have a Cannot find name 'Users'. Did you mean 'user'?
error on my code editor.
I didn’t not mean to type user
, the collection name is the Users
.
The thing is the Users collection file is written in js
not tsx
.
Is there a way to define a type of the Users collection?
I use this method:
import { Meteor } from "meteor/meteor";
import { Mongo } from "meteor/mongo";
import { UserType } from "/imports/types/users";
const Users: Mongo.Collection<UserType> = Meteor.users;
export default Users;