Skip to main content

🔍 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 schema constant: 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/firetype instead of firetype
  • Check that the package is installed: npm list @anonymous-dev/firetype
  • For local installation, ensure your PATH includes 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:
  1. File naming: Ensure files are named exactly schema.ts
  2. Export syntax: Must be export const schema = z.object({...})
  3. Directory structure: Should match your Firestore collection structure
  4. CLI paths: Verify --input path points to the correct directory
Example:

Type safety not working

Problem: Generated types don’t provide expected type safety. Solutions:
  1. Regenerate types after schema changes
  2. Check Zod schema validity - invalid schemas may generate any types
  3. Verify import paths in generated file
  4. 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:
  1. Check Firestore rules - ensure rules allow the operations
  2. Verify authentication - user must be authenticated for secured operations
  3. Test with admin SDK - bypasses security rules for testing

Performance issues

Problem: Firetype operations are slow. Solutions:
  1. Disable validation in production:
  2. Use batch operations for multiple writes:
  3. Optimize queries with proper indexes

CLI Issues

Command not found in CI/CD

Problem: npx @anonymous-dev/firetype fails in CI environment. Solutions:
  1. Add to package.json:
  2. Use npm script: npm run generate-types
  3. 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 firetype and firestore

Advanced Debugging

Type Inspection

Inspect generated types using TypeScript’s utility types:

Runtime Type Checking

Add runtime type validation for debugging:

Performance Profiling

Profile Firetype operations: