Allow withForm components to accept extending properties#1334
Closed
s-hoff wants to merge 2 commits into
Closed
Conversation
added 2 commits
March 11, 2025 22:22
…ric instead of equal to them
Basically, this fails:
```ts
type Test<T> = {
defaultValues: T
fun: (props: { value: T }) => {}
}
const t: Test<{ firstName: string }> =
{} as Test<{ firstName: string, lastName: string }>
```
While this works:
```ts
type Test2<T> = {
defaultValues: T,
fun: <TF extends T = T>(props: { value: TF }) => void
}
// ist fine, the actual type has all that was asked for and then some
const t2: Test2<{ firstName: string }> =
{} as Test2<{ firstName: string, lastName: string }>
```
and still ensures that `firstName` is included on t2.
The main idea is unless `props.value` only extends T, TypeScript checks the equality both ways.
If it does extend T, the checking becomes unidirectional
s-hoff
force-pushed
the
feat/easy-extendable-withForm
branch
from
March 25, 2025 08:16
1be99e8 to
649162d
Compare
Contributor
|
I've mentioned it on Discord previously, but I should list it here in case a maintainer has comments on it: Some methods can create behaviour that may be unintended if Even when providing all values in the |
4 tasks
Contributor
|
This feature will be implemented in #1469 . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces #1268.
This fails:
But this works:
Its probably missing some functions and certainly the other frameworks.