Better type inference for transaction meta properties #27
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "meta-typing"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR adds better type inference for a transactions
getMeta&setMetamethods.It uses some TypeScript inference based on the fact that
PluginandPluginKeyare already generically typed. This allows us to enforce that the shape of the meta property is properly inferred for more accurate type checking.See the example below, given this code:
It is correctly inferred:
Plugins and plugin keys are parameterized by the type of their plugin state. While in some cases you might use
setMetawith this same type, there is nothing that requires this—you can put anything in meta fields, their key simply doesn't constrain the value type. As such, I don't think this patch is a good idea.Ah, you know, on further reflection, indeed is dumb.
Pull request closed