Answer the question
In order to leave comments, you need to log in
How to dynamically pass a generic type?
there is an interface
export interface AuthFormsDataTypes {
login: LogInFormDataType;
registration: RegFormDataType;
}
onSubmit: submitHandlersCreator<AuthFormsDataTypes[commonName]>({
dispatch,
path: `${location.pathname}${location.search}`,
actionName:commonName
}),
Answer the question
In order to leave comments, you need to log in
If commonName is a variable, then its type can be retrieved via typeof
submitHandlersCreator<AuthFormsDataTypes[typeof commonName]>({
dispatch,
path: `${location.pathname}${location.search}`,
actionName:commonName
})
But it must have a literal type or a union of literal types, moreover, from the set of keys AuthFormsDataTypes
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question