-
Notifications
You must be signed in to change notification settings - Fork 56
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
fix: clarify TS Docs for better DX #3076
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3076 +/- ##
=======================================
Coverage 92.60% 92.60%
=======================================
Files 85 85
Lines 3164 3164
Branches 775 775
=======================================
Hits 2930 2930
Misses 183 183
Partials 51 51
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
*/ | ||
export type Operation = { | ||
export interface Operation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to rollback this change as types are to be preferred to interfaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know about the general preference of types over interfaces, but I explained the motivation for this change internally, here: https://vaadin.slack.com/archives/C01EJJNMAC9/p1736339840532009
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDEs can definitely propose type
s, so it must be a glitch in your own IDE. Or maybe the solution is the export
you added in index.ts
. But I'd still like to keep it as a type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the definition of interface
and type
in the TypeScript system, an interface
gives the name to the type, while the type
does not do that. I guess, this is the case here. So, if we want a slightly better intellisense here, the interface
is preferable; the downside is that you cannot use dynamic type creation like Readonly<...>
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the interface then.
*/ | ||
export type Operation = { | ||
export interface Operation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the interface then.
|
* fix: clarify TS Docs for better DX Fixes #2936 * add TS Docs example --------- Co-authored-by: Luciano Vernaschi <[email protected]>
fix: clarify TS Docs for better DX (#3076) * fix: clarify TS Docs for better DX Fixes #2936 * add TS Docs example --------- Co-authored-by: Soroosh Taefi <[email protected]> Co-authored-by: Luciano Vernaschi <[email protected]>
This ticket/PR has been released with Hilla 24.7.0.alpha7 and is also targeting the upcoming stable 24.7.0 version. |
Fixes #2936