ashlsun / untitled-inventory-app

a text-based inventory app for your fridge
https://ashlsun.github.io/untitled-inventory-app/
2 stars 0 forks source link

29 use svelte stores #38

Closed Rettend closed 4 months ago

Rettend commented 4 months ago
Rettend commented 4 months ago

😮 this is new to me

okay here we go if you haven't looked it up yet:

// we have an object type
type User = {
  id: number
  name: string
}

// user is of type User
const user: User = {
  id: 1,
  name: 'asd'
}

// user's type is { id: number, name: string }
const user = {
  id: 1,
  name: 'asd'
} satisfies User

so satisfies will keep the inferred type, but will still provide typechecking for user.

In our case, both would work, but there are cases where you have to use satisfies

Rettend commented 4 months ago

thanks for your work cleaning things up! bun i was significantly faster than npm i on my mac :D

also, what exactly was the problem you discovered with Item tests?!

because of how we used events like deleteItem, when the quantity was 1 and you pressed the left arrow, it would not decrease it (because it would return early). so i increased the quantity to 2, and made two tests, one where it should decrease quantity and one where it should call the delete event.

i'm not sure how to write this clearer