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
This confuses users as they have to use an unusual API. In addition, it is awkward to have to add one more argument.
Solution
I want defineTypeFactory to allow Transient Fields. The user specifies the type of Transient Fields using the type argument. Also, the default value of Transient Fields is specified by the defaultFields option.
As you can see from the sample code, defineTypeFactory currently has a type argument TOptions. This type argument is inferred from the type of the options argument. This allows the user to strictly type the return value of defineTypeFactory without having to specify the type argument.
However, it causes problems when TransientFields is added to the type arguments of defineTypeFactory. The user must explicitly pass the type TransientFields from the function caller, but then the type of the options argument is not inferred.
TypeScript does not support partial inference of type arguments. Therefore, an implementation of this feature is currently not possible. We will probably have to wait for the following issue to be resolved.
Problem
Currently, Transient Fields are only allowed in
defineTypeFactoryWithTransientFields
.This confuses users as they have to use an unusual API. In addition, it is awkward to have to add one more argument.
Solution
I want
defineTypeFactory
to allow Transient Fields. The user specifies the type of Transient Fields using the type argument. Also, the default value of Transient Fields is specified by thedefaultFields
option.Additional context
As you can see from the sample code,
defineTypeFactory
currently has a type argumentTOptions
. This type argument is inferred from the type of theoptions
argument. This allows the user to strictly type the return value ofdefineTypeFactory
without having to specify the type argument.However, it causes problems when
TransientFields
is added to the type arguments ofdefineTypeFactory
. The user must explicitly pass the typeTransientFields
from the function caller, but then the type of theoptions
argument is not inferred.TypeScript does not support partial inference of type arguments. Therefore, an implementation of this feature is currently not possible. We will probably have to wait for the following issue to be resolved.
The text was updated successfully, but these errors were encountered: