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

fix: clarify TS Docs for better DX #3076

Merged
merged 7 commits into from
Jan 13, 2025
Merged

fix: clarify TS Docs for better DX #3076

merged 7 commits into from
Jan 13, 2025

Conversation

taefi
Copy link
Contributor

@taefi taefi commented Dec 20, 2024

Fixes #2936

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.60%. Comparing base (d0f59c8) to head (02c1310).
Report is 6 commits behind head on main.

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           
Flag Coverage Δ
unittests 92.60% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@taefi taefi marked this pull request as ready for review January 8, 2025 14:25
@taefi taefi requested a review from cromoteca January 8, 2025 14:26
*/
export type Operation = {
export interface Operation {
Copy link
Contributor

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.

Copy link
Contributor Author

@taefi taefi Jan 9, 2025

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDEs can definitely propose types, 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.

Copy link
Contributor

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.

Copy link
Contributor

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.

@taefi taefi requested a review from cromoteca January 9, 2025 19:33
*/
export type Operation = {
export interface Operation {
Copy link
Contributor

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.

@cromoteca cromoteca merged commit b5626fa into main Jan 13, 2025
15 checks passed
@cromoteca cromoteca deleted the taefi/fix-2936-dx branch January 13, 2025 18:05
vaadin-bot pushed a commit that referenced this pull request Jan 13, 2025
* fix: clarify TS Docs for better DX

Fixes #2936

* add TS Docs example

---------

Co-authored-by: Luciano Vernaschi <[email protected]>
cromoteca added a commit that referenced this pull request Jan 13, 2025
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]>
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Hilla 24.7.0.alpha7 and is also targeting the upcoming stable 24.7.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DX] Documentation example and TS Docs for the returned operation result of client-side API should be enhanced
4 participants