Skip to content

fix: type each message by its placeholders so the web typecheck stops growing - #1820

Merged
yansfil merged 1 commit into
mainfrom
fix/web-typecheck-catalog-growth
Oct 29, 2026
Merged

yansfil merged 1 commit into
mainfrom
fix/web-typecheck-catalog-growth

Conversation

@yansfil

@yansfil yansfil commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes with-hide/hide-private#115
Related: #1819

Summary

nightly의 performance (macOS) topology lane이 'Build the web shell' 5분 제한에 걸려 실패합니다(main 047d0944d에서도 재현, run 40803125317). 그 단계의 4m26s가 웹 타입검사(tsc --noEmit)였고 vite build는 15초였습니다.

원인: 번역 문구 타입이 영어 문장 전체(리터럴)여서, i18next가 번역 함수 타입을 만날 때마다 메시지 약 3,800개의 문장을 다시 파싱했습니다. 그래서 타입검사 시간이 catalog와 함께 자랐습니다(10-24엔 단계 전체 3분).

수정: 각 메시지를 문장이 아니라 그 {{이름}} placeholder만으로 타입을 매깁니다(web/src/i18n/i18next.d.ts). 호출부 검사는 그대로 남습니다. 로컬 타입검사 87초 -> 14초.

스크린샷 없음: 타입 선언만 바뀌고 화면에 그리는 것은 같습니다.

Review

  • 판단해 주세요: conductor가 고른 안 C(placeholder만 담은 타입)를 생성 스크립트 없이 TypeScript 타입 하나로 만들었습니다. catalog에서 한 번 계산되는 mapped type이라 생성 파일과 최신 여부 검사가 필요 없고, 같은 속도가 나옵니다. 생성 스크립트 방식이 꼭 필요한지 판단해 주세요.
  • 판단해 주세요: 시간 제한(5분)은 그대로 두었습니다.
  • 조심해서 볼 파일: web/src/i18n/i18next.d.ts - 모든 t() 호출의 타입. t()의 반환 타입이 영어 문장 리터럴에서 placeholder 모양의 문자열로 바뀝니다. 그 리터럴에 기대던 코드는 없었습니다(타입검사 통과).

Evidence

  • 확인한 것: 같은 호출 묶음을 두 타입으로 검사해 오류가 같음을 확인. 둘 다 오류: placeholder 누락, null 값, 객체 값, 없는 키. 둘 다 통과: 맞는 호출, 숫자 값, 추가 변수, plural count, defaultValue, options 생략(i18next 규칙).
  • 확인한 것: instance.test.ts의 @ts-expect-error 세 줄(틀린 이름, null, 객체)이 여전히 오류를 잡습니다(쓰이지 않으면 tsc가 실패).
  • 확인한 것: tsc --noEmit --extendedDiagnostics 같은 기계에서 87.1초 -> 12.8초(Check time). 원인 추적: trace에서 105초 중 92.6초가 t() 호출 11곳, 리터럴 키 한 번만 쓰는 파일도 14초.
  • 확인한 것: scripts/verify-web.sh web typecheck|lint|test|build 통과(테스트 2243개), desktop typecheck 통과.
  • 확인한 것: 이 브랜치의 perf.yml dispatch(run 40805862521)가 통과, 'Build the web shell' 47초(main은 5분 초과로 실패, run 40803125317).
  • 확인하지 못한 것: 다음 예약 nightly는 아직입니다. 이슈는 그 nightly가 이 lane을 통과시킬 때 닫힙니다.
Verification record

… growing with the catalog

i18next parsed the whole English sentence of every message once per
translator type it met, so tsc --noEmit took 4m26s of the nightly
performance lane's 5-minute build step and then timed out. Each message is
now typed by its {{name}} placeholders only: a wrong placeholder name, a
missing one, or a null or object value still fails the typecheck, and the
check takes 14 s instead of 87 s locally.

Closes with-hide/hide-private#115
@yansfil
yansfil merged commit 8a865d8 into main Oct 29, 2026
49 checks passed
@yansfil
yansfil deleted the fix/web-typecheck-catalog-growth branch October 29, 2026 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant