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: constrain entity fields type to string-keyed object #235

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

wschurman
Copy link
Member

Why

This allows us to remove the any typecast in EntityConfiguration.ts and is more correct: only string-keyed field objects are allowed.

This is in preparation for addressing this comment: #233 (comment)

How

Add type constraint where necessary.

Test Plan

yarn tsc

Copy link

codecov bot commented Jun 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (7c3c985) to head (4caea03).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #235   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           69        69           
  Lines         1895      1895           
  Branches       261       261           
=========================================
  Hits          1895      1895           
Flag Coverage Δ
integration 100.00% <100.00%> (ø)
unittest 100.00% <100.00%> (ø)

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.

@Josh-McFarlin
Copy link
Contributor

Is the plan to replace T extends Record<string, any> with a type omitting prototype names?

@wschurman
Copy link
Member Author

Is the plan to replace T extends Record<string, any> with a type omitting prototype names?

Nope, I just noticed the any cast at the callsite where I was planning to add validation and decided that it'd be easy enough to get rid of the any cast (which is a code smell).

That being said, your idea is interesting and I wonder if it's possible. I think the typescript Record type extends Object which has those properties.

Copy link
Contributor

@Josh-McFarlin Josh-McFarlin left a comment

Choose a reason for hiding this comment

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

lgtm

@wschurman wschurman merged commit 7e2cea1 into main Jun 4, 2024
3 checks passed
@wschurman wschurman deleted the @wschurman/constrain-tfields branch June 4, 2024 22:35
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.

3 participants