Skip to content

[서브이슈] 129-2: 유틸리티 집계 함수 null/undefined 체크 강화 (strictNullChecks 대응) #132

@Seungwoo321

Description

@Seungwoo321

작업 개요

  • src/helper/utilities.ts 내 주요 집계 함수(uniques, sum, extremes, quantile, runningStat, sumOverSum)에서 null/undefined 체크를 TypeScript strictNullChecks 옵션에 맞게 강화
  • 기존 동작(값이 없으면 집계에서 무시)을 100% 유지하며, 타입 안전성만 강화

주요 변경 내역

  • 옵셔널 체이닝(record?.[attr]) 및 null/undefined 체크(raw != null) 패턴 적용
  • 값이 없거나 잘못된 값(null, undefined, NaN 등)은 집계에 포함하지 않고, 명확하게 NaN으로 처리
  • any, non-null assertion(!) 남발 없이 타입 가드/옵셔널 체이닝/기본값 등 TypeScript 표준 패턴만 사용

Before/After 예시 (sum 함수)

Before

push (record: DataRecord) {
  const val = parseFloat(String(record[attr]))
  if (!isNaN(val)) {
    this.sum += val
  }
}

After

push (record: DataRecord) {
  const raw = record?.[attr]
  const val = raw != null ? parseFloat(String(raw)) : NaN
  if (!isNaN(val)) {
    this.sum += val
  }
}

영향 및 결론

  • 기존 JS/TS 동작과 100% 동일하게 동작
  • strictNullChecks 등 TS strict 옵션에서 타입 안전성만 강화
  • 실무 데이터 신뢰성, 유지보수성, 협업 효율성 모두 향상

자세한 Before/After 및 함수별 상세 내역은 레퍼런스 문서로 별도 관리합니다. (커밋/PR에는 포함하지 않음)

이슈 완료 후, 129번 메인 이슈의 2번 체크리스트도 함께 체크 예정입니다.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions