I'm using Type Flavoring to keep different types of keys separate in my typescript app. However, I noticed that this has the strange side effect of allowing objects of the form
{[key: SomeFlavoredString]: ObjectA}
to be passed to functions that takes arguments of the form
{[key: SomeOtherFlavoredString]: ObjectB}
without complaining, which can lead to some surprising bugs. Here's a playground
I think what's going on is that it assumes that since the key types are disjoint, the extra keys are irrelevant and so it doesn't matter that the values at those incompatible keys are incompatible values, so it's equivalent to passing an empty object from the typescript compiler's perspective.
Is there some way to disable this or insist that my arguments can't have any incompatible values at any key? This doesn't seem like desirable behavior