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

Enhance type inference in Document.subscribe #814

Merged
merged 2 commits into from
May 20, 2024
Merged

Conversation

chacha912
Copy link
Contributor

What this PR does / why we need it?

  • Improve doc.subscribe() to infer event types appropriately based on the topic
  • Complete TODO(chacha912): Remove any type after specifying the type of DocEvent
  • as-is: All events are inferred as the DocEvent.
    image
  • to-be: The event types are inferred appropriately based on the topic.
    image

Any background context you want to provide?

What are the relevant tickets?

Fixes #

Checklist

  • Added relevant tests or not required
  • Didn't break anything

@chacha912 chacha912 requested a review from hackerwins May 13, 2024 10:36
Copy link

codecov bot commented May 13, 2024

Codecov Report

Attention: Patch coverage is 63.63636% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 80.81%. Comparing base (2e33940) to head (29685f6).

Files Patch % Lines
src/document/document.ts 63.63% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #814      +/-   ##
==========================================
+ Coverage   80.74%   80.81%   +0.07%     
==========================================
  Files          59       59              
  Lines        4481     4477       -4     
  Branches      908      905       -3     
==========================================
  Hits         3618     3618              
+ Misses        601      599       -2     
+ Partials      262      260       -2     

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

@hackerwins hackerwins force-pushed the type-infer-doc-event branch 4 times, most recently from 63fbc54 to 4712007 Compare May 20, 2024 08:02
Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution.
We can code more types safely.

@hackerwins hackerwins merged commit d4fad10 into main May 20, 2024
2 checks passed
@hackerwins hackerwins deleted the type-infer-doc-event branch May 20, 2024 08:45
@hackerwins hackerwins changed the title Improve doc.subscribe() to infer event types appropriately based on the topic Enhance type inference in Document.subscribe May 20, 2024
hackerwins added a commit that referenced this pull request May 20, 2024
This commit improves the type inference for the types used in
Document.subscribe. Additionally, it removes the code that forces
casting in the test code to align with these improvements.

---------

Co-authored-by: Hackerwins <susukang98@gmail.com>
@coderabbitai coderabbitai bot mentioned this pull request May 24, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants