This is completely valid but I still do think not being able to annotate literals to dictionary keys is a flaw and that it should get implemented
As I said in my first post, primitive dictionary annotations aren’t really meant for that. They are simply used to denote a common key and value type that is the same through out the entire table, whereas the type of annotation I proposed is exactly meant for that where a common key or value type may or may not be present.
Edit: keep in mind that literals are not valid key types anyways, they are polymorphic unless collapsed into a certain state, therefore are not hashable.
Sounds good.
Hope this gets fixed.
I suppose ForeverHD can mark your post as the solution now as this really isn’t an issue solvable by us users.
Those are valid points, do you think annotating Literals to primitive dict keys should be a thing?
It would allow for the following aswell (im aware this isn’t very useful)
type someDict<UnionOfLiteralKeys> = {[UnionOfLiteralKeys]: someType}
I personally don’t think it should be a thing as simply denoting each possible key literal as a different key and assigning the appropriate type to it does the job pretty well, and in my opinion would be a lot more readable than this.