Use of generics for typing collections and documents #4404
              
                Unanswered
              
          
                  
                    
                      nthonymiller
                    
                  
                
                  asked this question in
                Q&A
              
            Replies: 1 comment 5 replies
-
| @nthonymiller yes both  So for example let's say I have a  const cityConverter = {
    toFirestore: (city: City) => {
        return {
            name: city.name,
            state: city.state,
            country: city.country
            };
    },
    fromFirestore: (snapshot, options) => {
        const data = snapshot.data(options);
        return new City(data.name, data.state, data.country);
    }
};
const ref = doc(collection(db, "cities"), "LA").withConverter(cityConverter);In this case  | 
Beta Was this translation helpful? Give feedback.
                  
                    5 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
You have the API:
Can this be strongly typed by using typescript generics?
Beta Was this translation helpful? Give feedback.
All reactions