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(mf-parser): provide getInfo advanced typings #241

Merged
merged 6 commits into from
Dec 9, 2024

Conversation

tpoisseau
Copy link
Collaborator

rework of #231

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 97.05882% with 2 lines in your changes missing coverage. Please review.

Project coverage is 96.55%. Comparing base (f94e399) to head (0ee1597).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/mf-parser/src/MF.ts 95.83% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #241      +/-   ##
==========================================
- Coverage   96.55%   96.55%   -0.01%     
==========================================
  Files         209      210       +1     
  Lines       19713    19757      +44     
  Branches     2223     2238      +15     
==========================================
+ Hits        19034    19076      +42     
- Misses        671      673       +2     
  Partials        8        8              

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

@tpoisseau
Copy link
Collaborator Author

Any idea why locally I have this error in my tests:

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  packages/isotopic-distribution/src/__tests__/isotopicDistribution.test.js > test isotopicDistribution > extreme case with very few points
AssertionError: expected NaN to be close to 12010735.5, received difference is NaN, but expected 0.005
 ❯ packages/isotopic-distribution/src/__tests__/isotopicDistribution.test.js:396:26
    394|     });
    395| 
    396|     expect(profile.x[0]).toBeCloseTo(12010735.5);
       |                          ^
    397|     expect(profile.y[0]).toBeCloseTo(100);
    398|   });

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

But not in CI ?

@tpoisseau tpoisseau marked this pull request as ready for review December 9, 2024 13:34
@tpoisseau tpoisseau requested review from targos and lpatiny December 9, 2024 13:34
@targos
Copy link
Member

targos commented Dec 9, 2024

I would use fix for the commit message because it has effect on TS users, not only documentation (and docs prefix doesn't trigger a new release-please pull request)

@targos
Copy link
Member

targos commented Dec 9, 2024

I don't have the error locally. Did you run npm test or something else?

Copy link
Member

@lpatiny lpatiny left a comment

Choose a reason for hiding this comment

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

I'm not able to judge TS migration anyway but I plan to simplify the library (and make breaking changes) to avoid custom name for properties among other. Don't hesitate to create issues if you see some complex pattern.

@stropitek
Copy link

Ref: #234

@tpoisseau tpoisseau force-pushed the docs/mf-parser/GetInfoOptionsOnly branch from 109208e to 0ee1597 Compare December 9, 2024 14:14
@tpoisseau tpoisseau changed the title docs: getInfo advanced typings fix(mf-parser): provide getInfo advanced typings Dec 9, 2024
@tpoisseau
Copy link
Collaborator Author

I don't have the error locally. Did you run npm test or something else?

It happen with npm test and npm run test-only

Copy link
Member

@targos targos left a comment

Choose a reason for hiding this comment

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

Difficult to review TS change impact but LGTM based on updated test.

@tpoisseau
Copy link
Collaborator Author

Refs: #226

@targos
Copy link
Member

targos commented Dec 9, 2024

Maybe we don't have the same dependency tree, but this is weird.

@tpoisseau
Copy link
Collaborator Author

@lpatiny

Typescript is very rich in its ability to define and express types, but if we can use simple types and avoid dynamic properties in the future, I'd be very grateful ^^.

In terms of suggestions, I'd say strongly type all the inputs and outputs of each function. I went down the rabbit hole on my previous PR #231. I had a lot of trouble typing MFParsedPart and ToPartsPart. Properties should not be added dynamically, and mutations should be avoided as much as possible. I also recommend defining all discriminated types rather than one type that would be the approximate fusion of all possibilities.

I think you'll find this abandoned RP useful for examples of precisely defined types.

@tpoisseau tpoisseau merged commit 06a4121 into main Dec 9, 2024
10 checks passed
@tpoisseau tpoisseau deleted the docs/mf-parser/GetInfoOptionsOnly branch December 9, 2024 14:34
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.

4 participants