-
Notifications
You must be signed in to change notification settings - Fork 28
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
PhET TypeScript conventions for export
are being violated.
#184
Comments
export
are being violated.
Recently @chrisklus suggested exporting option types inline and we have been exercising this strategy in Center and Spread to see how it goes. It has been working very seamlessly, and it seems like the best way to export options types. I recommend revising the conventions to promote this. |
The best way to export types for you perhaps. The best way to export types for a team is to follow the conventions that we established. And it's fine to revisit conventions. But it would be more polite to have that discussion before propagating to common code. What you've done is more than "exercising this strategy in Center and Spread to see how it goes". Here's how this wasted 1/2 hour of my time: WebStorm wasn't finding a type that I expected in VerticalCheckboxGroup.ts, so I went there to see if it was exported. It wasn't in the exports at the bottom of the file (where they're supposed to be by PhET's convention) so I added the type. Then I got some brand new TypeScript errors. A few minutes of head-scratching later, and I figured it out. Then I spent more time investigating, then creating this issue. I get it that it may be easier for you to type |
Inline exports for types don't break this convention unless multiple type are being exported, which I've never needed to do. I wasn't aware that grouping type and modules exports was required, and that was never specified, only shown in the example. |
Today's dev meeting: @pixelzoom does this mean we can/should also: |
Result of the vote: MK: First opinion is I don’t care, second opinion is to be able to export wherever you want. It is annoying to have to export a type at the bottom of the file. I see value in that annoyance, as it is meant to be an extra step to ensure that the API for a file is explicit and purposeful. Therefore it seems reasonable to be "developer preference", put them where you desire but be aware they may not always be at the bottom of the file. I'll update the documentation. |
Fixed and ready for review, @pixelzoom would you like to review? |
👍🏻 |
I don't think this is complete, I see https://github.com/phetsims/phet-info/blob/master/doc/best-practices-for-modules.md, which is pointed to in the CRC, can we please update those too. Or at least upvote my sentiment to combine conventions documents in #186 (comment). |
I upvoted the comment #186 (comment) to combine conventions documents. Also, the code review checklist now points to the typescript conventions doc, where this pattern is described. New development is in TypeScript, so perhaps this is sufficient. OK to close? |
I first encountered this in VerticalCheckboxGroup.ts
… and I see this
export type
pattern using in many repos.From https://github.com/phetsims/phet-info/blob/master/doc/typescript-conventions.md#multiple-exports:
A possibly-incomplete list of repos where this needs to be fixed:
Assigning to @samreid and @chrisklus, since they seem to be responsible for many of these.
The text was updated successfully, but these errors were encountered: