From 3b1136c03ba3068de174d8630603539c3567c210 Mon Sep 17 00:00:00 2001 From: reluc Date: Tue, 13 Feb 2024 10:57:13 +0100 Subject: [PATCH] fix(examples): do not ignore error but use cast --- examples/quickstart/simple-coffee-machine.js | 3 --- packages/examples/src/quickstart/simple-coffee-machine.ts | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/examples/quickstart/simple-coffee-machine.js b/examples/quickstart/simple-coffee-machine.js index 22884dc49..136e3ee1f 100644 --- a/examples/quickstart/simple-coffee-machine.js +++ b/examples/quickstart/simple-coffee-machine.js @@ -179,15 +179,12 @@ servient.start().then((WoT) => { thing.setActionHandler("refill", async (params, options) => { const selectedResource = await params.value(); console.info("received refill order of ", selectedResource); - // @ts-expect-error: Property doesn't exist error if (selectedResource.indexOf("water") !== -1) { waterAmount = 1000; } - // @ts-expect-error: Property doesn't exist error if (selectedResource.indexOf("beans") !== -1) { beansAmount = 1000; } - // @ts-expect-error: Property doesn't exist error if (selectedResource.indexOf("milk") !== -1) { milkAmount = 1000; } diff --git a/packages/examples/src/quickstart/simple-coffee-machine.ts b/packages/examples/src/quickstart/simple-coffee-machine.ts index ce79d3c9f..69fdc7c2f 100644 --- a/packages/examples/src/quickstart/simple-coffee-machine.ts +++ b/packages/examples/src/quickstart/simple-coffee-machine.ts @@ -186,17 +186,14 @@ servient.start().then((WoT) => { }); thing.setActionHandler("refill", async (params, options) => { - const selectedResource = await params.value(); + const selectedResource = (await params.value()) as Array<"water" | "beans" | "milk">; console.info("received refill order of ", selectedResource); - // @ts-expect-error: Property doesn't exist error if (selectedResource!.indexOf("water") !== -1) { waterAmount = 1000; } - // @ts-expect-error: Property doesn't exist error if (selectedResource!.indexOf("beans") !== -1) { beansAmount = 1000; } - // @ts-expect-error: Property doesn't exist error if (selectedResource!.indexOf("milk") !== -1) { milkAmount = 1000; }