chore: add a typecheck gate and align TypeScript versions - #211
Open
childrentime wants to merge 3 commits into
Open
chore: add a typecheck gate and align TypeScript versions#211childrentime wants to merge 3 commits into
childrentime wants to merge 3 commits into
Conversation
The repo had no working `tsc` invocation. Neither config was clean on main: `packages/core/tsconfig.json` reported 7 errors, and the root config — pinned to TypeScript 4.9.5 — produced 258 just parsing zod's .d.cts. - Add `typecheck` (`tsc --noEmit`) to @reactuses/core and a root passthrough, wired into CI after lint. - Align root TypeScript 4.9.5 -> ^5.8.3 to match packages/core. The two versions disagreed about lib.dom, so an editor using the root TS flagged code that CI required (GeolocationCoordinates.toJSON exists in 5.8, not in 4.9). - Point `typescript.tsdk` at the workspace TypeScript so editors and CI agree. Fixes the 7 pre-existing errors: - useGeolocation: give `initCoord` the `toJSON` that lib.dom now requires; it returns its own fields, so JSON output is unchanged. - useOrientation: `ScreenOrientation.lock()` ships in browsers but is absent from lib.dom, which declares only `unlock()` — narrow via a local interface. - Specs: prefix two genuinely unused params with `_`, and widen the `as const` entries in useMap's reset case, which adds a third key. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
CI caught what a local run could not: scripts/tsdoc.ts imports @reactuses/ts-document, whose `lib/` output is gitignored. It resolves on a machine where that package has been built and never on a fresh checkout. Point the gate at a dedicated tsconfig covering src, global.d.ts and jest-setup.ts. Specs stay in — 4 of the 7 errors this PR fixes were in specs, and reverting either a source or a spec fix still fails the gate. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Lost to a stray `git checkout main -- <path>` while verifying the gate; that form stages the file, so it rode along in the previous commit unnoticed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ostapondo
reviewed
Jul 29, 2026
| return Promise.reject(new Error('Not supported')) | ||
| } | ||
| return window.screen.orientation.lock(type) | ||
| return (window.screen.orientation as LockableScreenOrientation).lock(type) |
There was a problem hiding this comment.
Confirmed the inverted guard you mention in the description — isBrowser is
typeof window !== 'undefined', so lockOrientation / unlockOrientation
return early exactly when we are in a browser, and only ever reach
window.screen during SSR. Happy to pick this up as a follow-up PR with
tests, if nobody else is on it.
ostapondo
approved these changes
Jul 29, 2026
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.
Problem
The repo had no working
tscinvocation, and notypecheckscript. Neither config was clean onmain:packages/core/tsconfig.json→ 7 errorstsconfig.json→ 258 errors, all fromzod@4.4.3's.d.cts, which the pinned TypeScript 4.9.5 cannot parseUnderneath that sat a version split: root TypeScript was 4.9.5,
packages/core's was 5.8.3. The two disagree aboutlib.dom—GeolocationCoordinates.toJSONexists in 5.8 but not in 4.9 — so an editor picking up the root TypeScript flags code that CI requires, and vice versa.Changes
The gate
typecheck(tsc --noEmit) on@reactuses/core, plus a root passthrough, wired into CI after lint.The version split
^4.9.5→^5.8.3, matchingpackages/core.typescript.tsdk→ the workspace TypeScript, so editors and CI resolve the samelib.dom.The 7 pre-existing errors
useGeolocation:initCoordgains thetoJSONthat lib.dom now requires. It returns its own fields, soJSON.stringifyoutput is unchanged; the constant is internal (not exported fromsrc/index.ts).useOrientation:ScreenOrientation.lock()ships in browsers but is absent from lib.dom, which declares onlyunlock()— narrowed via a local interface rather than ananycast._;useMap's reset case widened past itsas constliterals, since that test adds a third key.No runtime behavior changes.
Verification
pnpm typecheck,pnpm lint,pnpm build, and the full 307-test suite all pass. Full suite run 3× on this branch and 3× onmain— see the note below.Notes for review
1. An unrelated bug I did not touch.
useOrientation's lock guards look inverted:With
isBrowser = typeof window !== 'undefined', this returns early in every browser — solockOrientation/unlockOrientationare no-ops where they should work, and fall through to touchwindowduring SSR. Neither is covered byindex.spec.ts. Left alone deliberately: it's a behavior fix, not a type fix, and belongs in its own PR.2. A flaky test, pre-existing.
useDebounce/index.spec.tsfailed twice under full-suite parallel load, both times immediately after a heavy install + build. It passes 5/5 in isolation and 3/3 on the full suite once the machine is quiet — andmainshows 3/3 as well, so it is timing sensitivity rather than anything in this change. Worth watching once CI runs it on shared runners.Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com