Repository navigation
fix: type each message by its placeholders so the web typecheck stops growing - #1820
Merged
Merged
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
web/src/i18n/i18next.d.ts- 모든t()호출의 타입.t()의 반환 타입이 영어 문장 리터럴에서 placeholder 모양의 문자열로 바뀝니다. 그 리터럴에 기대던 코드는 없었습니다(타입검사 통과).Evidence
null값, 객체 값, 없는 키. 둘 다 통과: 맞는 호출, 숫자 값, 추가 변수, pluralcount,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.ymldispatch(run 40805862521)가 통과, 'Build the web shell' 47초(main은 5분 초과로 실패, run 40803125317).Verification record