mirror of
https://github.com/hanzoai/ui.git
synced 2026-11-20 22:36:27 +00:00
This file has now broken from BOTH directions in one day, which is the useful part of the story. Declaring the Web Speech names inside `declare global` MERGES with whatever lib.dom already provides rather than shadowing it, so on a lib that HAS them every small difference is an error: `readonly` vs mutable (TS2687), a second `[index: number]` (TS2374), and `error: string` against the real `SpeechRecognitionErrorCode` union (TS2717) — 7 errors. Deleting the declarations fixed that locally and immediately broke CI the other way, on a lib that does NOT carry them: TS2552: Cannot find name "SpeechRecognitionEvent" Same file, same code, opposite failure — because the Speech API is only partly standardised and how much of it ships varies by TypeScript version. There is no "correct" set of globals to declare; the premise was wrong. So the types are module-LOCAL now (SpeechRecognizer, SpeechRecognitionEventLike, …), describing exactly the surface this component touches. Local names collide with nothing and depend on nothing. The constructor and `webkitAudioContext` are read through narrow casts instead of a `Window` augmentation, for the same reason: lib.dom may already declare those properties, and re-declaring them with a different type is itself the error. Behaviour is unchanged except that the missing-API paths are now explicit — `getSpeechRecognizerCtor()` returns undefined instead of `"webkitSpeechRecognition" in window` guarding a `window.SpeechRecognition` read, and a browser with no AudioContext throws a named error rather than `new undefined()`. Verified: app typecheck is 0 errors under BOTH the workspace TypeScript (5.9.3, what node resolves) AND 7.0.2 (the binary CI actually invokes). pkgs/ui stays 0. Co-authored-by: Hanzo Dev <[email protected]>