실제 Firebase 12 업그레이드 과정에서 발생한 문제들과 해결 과정을 단계별로 기록한 교육용 자료입니다.
사용자 리포트: "로그인은 되는데 등원이 안 되는 것 같아"
도구 활용: Context7을 사용한 Firebase 12 breaking changes 조사
사용자: "firebase 12 버전으로 업데이트 하면서 context7 을 활용하여 breaking change 를 확인하고 업그레이드 전략을 새우자"
분석 결과: Firebase 12의 주요 변경사항 발견
3단계 업그레이드 전략 수립:
핵심 오류: "Unsupported field value: a custom Timestamp object"
문제 코드 예시:
// ❌ Firebase 12에서 오류 발생
const updatedStudent: Student = {
...student,
punchInTimeToday: type === '등원' ? Timestamp.fromDate(new Date()) : student.punchInTimeToday,
punchOutTimeToday: type === '하원' ? Timestamp.fromDate(new Date()) : null,
};
await this.repo.updateStudentPromise(updatedStudent); // 오류 발생!
as any
사용punchInTimeToday: type === '등원' ? new Date() as any : student.punchInTimeToday,
문제점: 타입 안전성 무시, 근본적 해결 아님
인터페이스 분리를 통한 타입 안전성 확보:
// 저장용 인터페이스
export interface StudentInput {
punchInTimeToday?: Timestamp | FieldValue | Date | null;
}
// 읽기용 인터페이스
export interface Student {
punchInTimeToday?: Timestamp | null;
}
최종 해결 코드:
const updatedStudent: StudentInput = {
...student,
punchInTimeToday: type === '등원' ? new Date() : student.punchInTimeToday,
punchOutTimeToday: type === '하원' ? new Date() : null,
};
단계별 테스트:
1. 유닛 테스트: 55개 중 54개 성공
2. 빌드 테스트: 프로덕션 빌드 성공
3. 타입 검사: TypeScript 컴파일 오류 해결
4. 기능 테스트: 실제 등원/하원 기능 동작 확인
작업 완료 후:
firebase-12-upgrade-guide.md
)as any
같은 타입 우회 방법 지양작성 목적: Firebase 12 업그레이드 실제 경험을 교육용으로 정리
대상: Angular/Firebase 개발자, 업그레이드 경험이 필요한 개발팀
활용: 실무 교육, 기술 세미나, 개발팀 온보딩
작성일: 2025년 7월 26일