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

ref(types): improve types of exported fields with satisfies #88417

Merged
merged 1 commit into from
Apr 1, 2025

Conversation

TkDodo
Copy link
Contributor

@TkDodo TkDodo commented Apr 1, 2025

satisfies makes sure we adhere to a certain structure (in this case, Record<string, Field>), but it will still infer the type from what we have actually defined.

In this case, this means that it won't be a Record with an index signature, but it will rather know about the names of the defined fields. That makes sure we can access fields without doing a non-null assertion (!)

satisfies makes sure we adhere to a certain structure (in this case, Record<string, Field>), but it will still infer the type from what we have actually defined.

In this case, this means that it won't be a Record with an index signature, but it will rather know about the names of the defined fields. That makes sure we can access fields without doing a non-null assertion (!)
@TkDodo TkDodo marked this pull request as ready for review April 1, 2025 10:26
@TkDodo TkDodo requested a review from a team as a code owner April 1, 2025 10:26
@TkDodo TkDodo requested a review from a team April 1, 2025 10:26
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 1, 2025
@TkDodo TkDodo merged commit c199f9f into master Apr 1, 2025
41 checks passed
@TkDodo TkDodo deleted the tkdodo/ref/field-types branch April 1, 2025 13:08
andrewshie-sentry pushed a commit that referenced this pull request Apr 8, 2025
satisfies makes sure we adhere to a certain structure (in this case,
Record<string, Field>), but it will still infer the type from what we
have actually defined.

In this case, this means that it won't be a Record with an index
signature, but it will rather know about the names of the defined
fields. That makes sure we can access fields without doing a non-null
assertion (!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants