Open NordlingDev opened 2 years ago
There's a couple things that make this difficult.
One is that we have to do some extremely complex type transformations to figure out "the tightest possible acceptable combination of parameters from all input functions".
Another is, what would happen if you had multiple input functions, with the same listed arguments, but you gave them different names? What name should get used for the result?
It might hypothetically be possible to do something that preserves the names - I'm honestly not sure.
But given how complex the types are, this is going to be extremely low priority for us to look at, and I generally doubt that there's a solution that can preserve the names well.
@markerikson I'm not too familiar or experienced with the implementation, but if the incoming parameters were instead provided by one single explicitly typed object, then there is no point to preserve the names as they're declared in the object.
const selectItemById: (state: State, params_0: { itemId: string }) => Item | null
I will have to try this one out. Perhaps there is nothing more to it than this.
The inferred type of a selector instance doesn't preserve the extra parameters' names. Instead they are called
params_0
,params_1
, etc... See example below:The inferred type signature of this selector becomes:
As you can see, parameter
itemId
is now calledparams_0
. From a consumer perspective, this parameter is ambiguous and impossible to understand. How can this be fixed? I honestly don't think I'm doing anything wrong here.Version: 4.1.6