Skip to content
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

Review the in/out covariant/contravariant type parameter annotations #389

Closed
samreid opened this issue Apr 19, 2022 · 2 comments
Closed
Assignees

Comments

@samreid
Copy link
Member

samreid commented Apr 19, 2022

In #370, we designed the Property interfaces to support covariant usages and I think that issue is at a good point. TypeScript 4.7 Beta introduced a new feature that overlaps with that somewhat:

Optional Variance Annotations for Type Parameters
https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-beta/#optional-variance-annotations-for-type-parameters

It allows you to specify in and/or out annotations on type parameters. I thought I would bring it to our attention in case it informs #370 or other covariant/contravariant discussions. Tagging @pixelzoom and @jonathanolson so they are aware. Not really sure what would have to happen for this issue to be closed. Perhaps review/understand the new annotations and determine where they are appropriate to use in our codebase?

@samreid samreid self-assigned this Apr 19, 2022
@pixelzoom
Copy link
Contributor

pixelzoom commented Apr 20, 2022

Thanks, I read the reference. Variance annotations sounds like a feature to be used judiciously. It also isn't clear to me whether TS will prevent you from (for example) using the in annotation for something that is actually used as an output. (And I didn't have time or inclination to experiment.)

@samreid
Copy link
Member Author

samreid commented Aug 3, 2022

We applied a usage of this (incorrectly) in Joist as part of phetsims/joist#783 and had some discussion as a team. Any more effort here can be done on-demand in the future when necessary. Closing.

@samreid samreid closed this as completed Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants