Skip to content

Commit

Permalink
fix(examples): do not ignore error but use cast
Browse files Browse the repository at this point in the history
  • Loading branch information
relu91 committed Feb 13, 2024
1 parent 3c6d9fb commit 3b1136c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
3 changes: 0 additions & 3 deletions examples/quickstart/simple-coffee-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 1 addition & 4 deletions packages/examples/src/quickstart/simple-coffee-machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3b1136c

Please sign in to comment.