ccorcos / tuple-database

406 stars 19 forks source link

fix type #20

Closed tanishqkancharla closed 1 year ago

tanishqkancharla commented 1 year ago

Fix TupleTransactionApi.set type.

Before, it type-checked to have the wrong value assigned to a tuple:

type Schema = {
  key: ["0"]
  value: true
} | {
  key: ["1"]
  value: false
}

// ...
// this used to type-check
tx.set(["0"], false)

Now, it throws a type error, and the value needs to correspond to the right key.

Am I missing something? Is there a reason this wasn't done already?

ccorcos commented 1 year ago

Huh, I wonder why it works one way but not the other way...

You know, you can use // @ts-error and stuff like that along to make certain type assertions in a test file... That would be cool.