You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generic arguments gets casted as "unknown" when used as function argument #53695
The "params" argument of the "dataWithArg" sub-property of "fields" is being typed as InferSharedStoreData, which means the "store" property type of the schema passed as argument of buildSchema is unavailable in the context of the function argument.
the StoreData type is being properly inferred for every other property it's assigned to, except on the case where it is used as a function argument.
🙂 Expected behavior
The function argument "params" should be inferred as StoreData, which itself is InferSharedStoreData<schema['store']>. A complete example is set-up on the playground link above.
One issue I see is that there's no inference site for the StoreKey type parameter; it is never mentioned in a place that would enable it to be inferred. Constraints like extends FormSchema<StoreKey, StoreData> do not serve as inference sites, see #7234. There might be other issues but you'll need to resolve this in order to make progress. Exactly how you resolve that is probably out of scope for this forum, though. And without a more minimal example of what you think is a TypeScript bug, I'm guessing this will be closed as some flavor of "working as intended".
There's a heck of a lot going on in this example. If you can simplify it down to an exact representation of what the problem is, that'd be helpful. Absent that, this looks like a manifestation of #47599
Activity
jcalz commentedon Apr 7, 2023
I don't see a TypeScript bug here.
One issue I see is that there's no inference site for the
StoreKeytype parameter; it is never mentioned in a place that would enable it to be inferred. Constraints likeextends FormSchema<StoreKey, StoreData>do not serve as inference sites, see #7234. There might be other issues but you'll need to resolve this in order to make progress. Exactly how you resolve that is probably out of scope for this forum, though. And without a more minimal example of what you think is a TypeScript bug, I'm guessing this will be closed as some flavor of "working as intended".RyanCavanaugh commentedon Apr 7, 2023
There's a heck of a lot going on in this example. If you can simplify it down to an exact representation of what the problem is, that'd be helpful. Absent that, this looks like a manifestation of #47599