microsoft / devicescript

TypeScript for Tiny IoT Devices (ESP32, RP2040, ...)
https://microsoft.github.io/devicescript/
MIT License
3.27k stars 118 forks source link

onChange handler does not exist #210

Closed tballmsft closed 1 year ago

tballmsft commented 1 year ago

Following the guide and am getting this error from TSC:

image

tballmsft commented 1 year ago

compiling also fails

C:\Github\mydevice>devs devtools src/main.ts
using devs: v1.10.3, runtime: v6.3.0, node: v18.12.1 from C:\Github\mydevice\node_modules\@devicescript\cli\built
devs: v1.10.3, runtime: v6.3.0, node: v18.12.1
   http     : http://127.0.0.1:8081
   websocket: ws://127.0.0.1:8081
   tcpsocket: tcp://127.0.0.1:8082
   dbgserver: tcp://127.0.0.1:8083
building src/main.ts...
build src/main.ts Failed
src\main.ts:7:17 - error TS2339: Property 'onChange' does not exist on type 'Register<number>'.

7 sensor.pressure.onChange(10, async () => {
                  ~~~~~~~~
watching src/main.ts...
tballmsft commented 1 year ago

this compiles. Should the example be changed?

sensor.pressure.subscribe(async () => {
    // read sensor reading
...
pelikhan commented 1 year ago

https://github.com/microsoft/devicescript/commit/6a74959590ee4765727ac90be6697debe4de593d