fix: repair cross-package bugs so all tests and typecheck pass - #148
Open
stooit wants to merge 1 commit into
Open
fix: repair cross-package bugs so all tests and typecheck pass#148stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- api.ts: import renamed useDebounce (was useThrottle), keep public useSearchDebounce alias — clears TS2305 and the api import test - Button: forward aria-label to the button element with an iconOnly fallback derived from string children (WCAG 2.2 SC 4.1.2); dev-only warning when no accessible name can be derived - formatDate: use en-GB so the day is non-padded (1/03/2024); en-AU always zero-pads the numeric day under ICU - tsconfig: add bun-types to compilerOptions.types so bun:test resolves, clearing the remaining test-file type errors
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.
Summary
Fixes all failing tests and eliminates all type errors in the monorepo.
bun run testnow reports 13/13 pass (was 8 pass / 5 fail) andnpx tsc --noEmitexits 0 (was 5 errors, incl. 1 real source error + 4 test-file resolution errors).Four cross-package bugs were fixed, matching the areas flagged in the task:
1. Renamed hook broke a consumer —
apps/web/src/lib/api.tsThe hook was renamed to
useDebounceinpackages/utils, butapi.tsstill imported/aliased the olduseThrottle. Switched the import touseDebouncewhile preserving the publicuseSearchDebouncealias the test asserts. This also cleared the real type errorTS2305: Module '@e2e/utils' has no exported member 'useThrottle'. No caller churn.2. Missing accessibility attribute —
packages/ui/src/components/Button/Button.tsxariaLabelwas destructured but never applied to the<button>. Now forwarded asaria-label, with aniconOnlyfallback that derives the label from string children when no explicit label is given, falling back to"Button"only when nothing can be derived — satisfying WCAG 2.2 SC 4.1.2 (Name, Role, Value). Normal text buttons get no strayaria-label. A dev-onlyconsole.warn(gated onNODE_ENV) fires only when no accessible name can be derived at all.3. Wrong locale in date formatting —
packages/utils/src/format/date.tsformatDate(1 March 2024)returned"01/03/2024"but should be"1/03/2024"(non-padded day). Under ICU,en-AUalways zero-pads the numeric day, so the locale was switched toen-GB, which produces the expected1/03/2024. A code comment records why to prevent a well-meaning revert.4. tsconfig — resolve
bun:testtype errorsAdded
"types": ["bun-types"]tocompilerOptionsso thebun:testimports in test files type-resolve.bun-typeswas already a devDependency. This clears the last 4tscerrors without modifying any test file.DataTable stale-closure test
The flagged "sorts descending on second click" test already passes and the source is correct — each click is a separate React batch, so the handler is recreated with fresh state. Left untouched per the "fix only what tests require" constraint.
Assumptions / decisions
bun run testscript (uses--preload ./packages/ui/test/setup.tsfor happy-dom). A barebun testmisses the preload and yields spuriousdocument is not definederrors.en-GBoveren-AU+dateStyle:"short"because the latter yields a 2-digit year, conflicting with the test's documented15/06/2024expectation.Verification
bun run test→ 13 pass, 0 failnpx tsc --noEmit→ exit 0