🔍 Troubleshooting
Common issues and their solutions when working with Firetype.Common Issues
”Cannot find module” errors
Problem: TypeScript can’t find the generated types. Solution: Make sure you’ve generated types before importing them:Schema validation errors
Problem: Your schema files aren’t being recognized. Solutions:- Ensure schema files export a
schemaconstant:export const schema = z.object({...}) - Check that schema files are named exactly
schema.ts - Verify the directory structure matches your Firestore collections
CLI not found
Problem:firetype command not recognized.
Solutions:
- Use
npx @anonymous-dev/firetypeinstead offiretype - Check that the package is installed:
npm list @anonymous-dev/firetype - For local installation, ensure your
PATHincludes node_modules/.bin
Type errors in generated code
Problem: TypeScript errors in the generated index.ts file. Solutions:- Update to the latest version:
npm update @anonymous-dev/firetype - Regenerate types after schema changes
- Check that your Zod schemas are valid
Validation not working
Problem: Runtime validation isn’t catching invalid data. Solution: Enable validation explicitly:Import errors
Problem: Can’t import from the generated types. Solutions:- Check the output path in your generation command
- Ensure the generated file exists:
ls types/index.ts - Use correct relative imports:
import { createFireTypeAdmin } from "../types"
Schema Issues
Schema not generating types
Symptoms: Schema files exist but no types are generated for them. Check:- File naming: Ensure files are named exactly
schema.ts - Export syntax: Must be
export const schema = z.object({...}) - Directory structure: Should match your Firestore collection structure
- CLI paths: Verify
--inputpath points to the correct directory
Type safety not working
Problem: Generated types don’t provide expected type safety. Solutions:- Regenerate types after schema changes
- Check Zod schema validity - invalid schemas may generate
anytypes - Verify import paths in generated file
- Update TypeScript to latest version
Complex schema types
Problem: Union types, discriminated unions, or complex validations not working. Check:Runtime Issues
Validation errors not descriptive
Problem: Zod errors are not helpful for debugging. Solution: Use detailed error formatting:Firestore permission errors
Problem: Operations fail with permission denied errors. Solutions:- Check Firestore rules - ensure rules allow the operations
- Verify authentication - user must be authenticated for secured operations
- Test with admin SDK - bypasses security rules for testing
Performance issues
Problem: Firetype operations are slow. Solutions:-
Disable validation in production:
-
Use batch operations for multiple writes:
- Optimize queries with proper indexes
CLI Issues
Command not found in CI/CD
Problem:npx @anonymous-dev/firetype fails in CI environment.
Solutions:
-
Add to package.json:
-
Use npm script:
npm run generate-types - Cache node_modules in CI to avoid reinstallation
Debug mode
Enable verbose logging:Getting Help
Issue Reporting
When reporting bugs, please include:- Version: Firetype version (
npm list @anonymous-dev/firetype) - Environment: Node.js, TypeScript, Firebase SDK versions
- Steps to reproduce: Minimal code example
- Expected vs actual behavior
- Schema structure (anonymized)
Minimal Reproduction
Create a minimal project that reproduces the issue:Community Support
- GitHub Issues: For bugs and feature requests
- GitHub Discussions: For questions and general help
- Stack Overflow: Tag with
firetypeandfirestore