Open fsoikin opened 8 years ago
Would exposing getConstraintOfTypeParameter
on the API address the issue?
It would solve half the issue: now I can use that function to get the value while making sure it's calculated. But that is assuming that I know which function to use. If I was just exploring the API, I would see the constraint
property and wouldn't think twice about just using it. It will be only after hours of debugging and googling (and possibly finding this issue) that I would gain the necessary knowledge.
So to solve the other half, the property needs to be hidden. But I'm not sure if it will break something somewhere.
Agreed. so what we need to do is 1. expose the getConstraintOfTypeParameter on the TypeChecker interface, 2, add Type.getConstraint() method on the TypeObject class, and 3, mark type.constraint as internal.
3 is a breaking change, so not sure if/when we can do it. but other ones should be doable.
PRs are definitely welcomed.
Because of this, I have to go through this awkward motion every time:
For some members (such as "properties" - above), there is an accessor function, which I can use to be sure the data is up to date. Another category of members don't need an accessor function, because they are calculated eagerly, and so are "always there".
But there is this third category of members, which fall through the gap. One example is
TypeParameter.constraint
. Another isInterfaceTypeWithDeclaredMembers.declaredProperties
. There are probably more, but I haven't come across them yet.