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

Prefer Annotating Types Over Asserting #3042

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JNygaard-Skylight
Copy link
Collaborator

PULL REQUEST

Summary

Where possible, annotate the returned value of the evaluate function instead of asserting it.

Related Issue

Fixes # n/a

Acceptance Criteria

n/a

Additional Information

We use the evaluate function from the fhirpath library throughout. the ecr-viewer. However, it is typed to return any. To take advantage of type hints in IDEs, we need to either assert the expected type, e.g., const rrDetails: Observation[] = evaluate(fhirBundle, mappings.rrDetails); or assert the expected type, e.g., const rrDetails = evaluate(fhirBundle, mappings.rrDetails) as Observation[];. Both options more-or-less do the same thing, but there are a few reasons to prefer annotation. In brief it is the difference between saying, "I know the type of this value, and throw an error if it does not fit this type," and "Treat this value as this type no matter what."

See:

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

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

Project coverage is 88.56%. Comparing base (6f59c59) to head (9bd215d).

Files with missing lines Patch % Lines
...wer/src/app/view-data/components/PatientBanner.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3042      +/-   ##
==========================================
+ Coverage   86.82%   88.56%   +1.74%     
==========================================
  Files         219       82     -137     
  Lines       13612     4180    -9432     
  Branches      705      704       -1     
==========================================
- Hits        11818     3702    -8116     
+ Misses       1785      469    -1316     
  Partials        9        9              
Flag Coverage Δ
ecr-viewer 90.05% <83.33%> (+0.03%) ⬆️
fhir-converter ?
ingestion ?
message-parser ?
message-refiner ?
orchestration 85.67% <ø> (ø)
record-linkage ?
trigger-code-reference ?
validation ?

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

Files with missing lines Coverage Δ
.../ecr-viewer/src/app/services/ecrMetadataService.ts 92.64% <100.00%> (ø)
...viewer/src/app/services/evaluateFhirDataService.ts 94.89% <100.00%> (+0.48%) ⬆️
...ners/ecr-viewer/src/app/services/formatService.tsx 98.01% <100.00%> (ø)
...ainers/ecr-viewer/src/app/services/labsService.tsx 94.93% <100.00%> (ø)
...ecr-viewer/src/app/view-data/components/common.tsx 99.38% <100.00%> (ø)
...wer/src/app/view-data/components/PatientBanner.tsx 80.00% <0.00%> (ø)

... and 137 files with indirect coverage changes

@JNygaard-Skylight JNygaard-Skylight marked this pull request as draft December 12, 2024 19:17
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.

1 participant