The Scripting app's type checker doesn't recognize Health/HealthUnit/
HealthUnitPrefix as global types. @ts-nocheck skips type checking
entirely — the APIs exist at runtime.
- Remove all TS type annotations (HealthQuantityType, HealthUnit etc.)
to avoid 'string not assignable' errors — let the app infer types
- HealthMetricPrefix → HealthUnitPrefix (correct enum name per docs)
- HealthUnit.fromString('mmHg') → HealthUnit.millimeterOfMercury()
(confirmed in docs: line 35229)
Scripting app expects TypeScript with import from 'scripting' and Script.exit().
- Renamed health-sync.js → health-sync.tsx
- Added 'import { Script } from "scripting"' and Script.exit() at end
- Added TypeScript type annotations
- Health/HealthUnit/Notification/fetch are global APIs (no import needed)
- fetch() instead of new Request() + req.loadJSON() (Scriptable API)
- Notification.schedule({title, body}) instead of new Notification() + n.schedule()
- allowInsecureRequest: true for HTTP (Scripting app blocks HTTP by default)
- This was the real reason 'nothing happened' — Scriptable API doesn't exist in Scripting app
Old script used deprecated Health.read() with Health.Types.* and .quantity
— every read silently failed in try/catch, so no samples were ever collected.
Rewrote to use Health.queryQuantitySamples() with string type identifiers
and .quantityValue(unit) per current Scripting app docs. Added proper units
(kg, mmHg, count/min, count, percent) for each metric type.
Also adds /scriptable/health-sync.js endpoint to serve the script directly.