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

Make KeyPaths not require @ts-ignore #1842

Merged
merged 6 commits into from
Feb 7, 2022
Merged

Make KeyPaths not require @ts-ignore #1842

merged 6 commits into from
Feb 7, 2022

Conversation

jclem
Copy link
Contributor

@jclem jclem commented Feb 4, 2022

Currently, KeyPaths requires a @ts-ignore line, because TypeScript can't verify that O[K] is a Record<string, unknown>.

In order to fix this, we can change KeyPaths<O extends Record<string, unknown>> to just KeyPaths<O>, but internally still verify that when recursing through O, we only recurse when O[K] extends Record<string, unknown>.

This makes it so that KeyPaths can be called on any value and I'm not sure if the repercussions of that are relevant. However, we should avoid @ts-ignore in types that are potentially consumed by projects using @primer/react, otherwise we essentially require that they have skipLibCheck: true in their TS config files.

There may be some better way of solving this, but my TypeScript knowledge isn't strong enough to figure it out 😄

@jclem jclem requested review from a team and rezrah February 4, 2022 20:52
@changeset-bot
Copy link

changeset-bot bot commented Feb 4, 2022

🦋 Changeset detected

Latest commit: 8701588

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 61.64 KB (0%)
dist/browser.umd.js 62 KB (0%)

Copy link
Contributor

@colebemis colebemis left a comment

Choose a reason for hiding this comment

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

LGTM ✨

Copy link
Contributor

@rezrah rezrah left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @jclem!

@jclem jclem enabled auto-merge (squash) February 7, 2022 17:36
@jclem jclem merged commit 11011f5 into main Feb 7, 2022
@jclem jclem deleted the fix-keypaths-type branch February 7, 2022 17:38
@primer-css primer-css mentioned this pull request Feb 7, 2022
@jclem jclem restored the fix-keypaths-type branch February 8, 2022 23:32
@joshblack joshblack deleted the fix-keypaths-type branch January 19, 2023 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants