-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PhetioGroup.getElement return type improvements #262
Comments
Same decision should apply to the new method |
I think that we should assert that index is in range. And we could do a type assertion/coercion as well to make typescript happy. |
I was surprised to see that array access already returns the array type (without undefined). So we don't need type assertion or coercion. Fixed and ready for review. |
More discussion in phetsims/projectile-motion#277. We aren't going to change the typescript compiler option for all array accesses, but we are keeping the PhetioGroup assertion. Closing |
Related to #254, @marlitas and I observed that PhetioGroup currently has:
However, it should really have return type
T | undefined
since there is no guard on the index. Alternatively, we could throw an error if the index is out of bounds and keep the specific return type ofT
, but that would be inconsistent with how the language treats array indices/access. @zepumph what do you recommend?We observed 10 or so occurrences that would need updating if we make this
T | undefined
.The text was updated successfully, but these errors were encountered: