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 1 commit 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

All modified and coverable lines are covered by tests ✅

Project coverage is 85.67%. Comparing base (2bd0e03) to head (d1ff026).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3042      +/-   ##
==========================================
- Coverage   86.00%   85.67%   -0.34%     
==========================================
  Files         162       25     -137     
  Lines       10855     1424    -9431     
==========================================
- Hits         9336     1220    -8116     
+ Misses       1519      204    -1315     
Flag Coverage Δ
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.

see 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