https://www.ory.sh/ logo
i

important-fall-74969

03/01/2022, 11:29 AM
Hello ory-team, when we use the SelfService*SettingsFlow* or SelfService*LoginFlow* in our app we’re getting ts errors when trying to pass in a
SubmitSelfServiceSettingsFlowWithLookupMethodBody
to
submitSelfServiceSettingsFlow
and similarly for
submitSelfServiceLoginFlow
. It looks like
SubmitSelfServiceSettingsFlowWithLookupMethodBody
is missing from the types
SubmitSelfServiceSettingsFlowBody
and
SubmitSelfServiceLoginFlowBody
. Can I do a PR for this and fix it by updating
internal/httpclient/api/openapi.yaml
?
b

bored-fountain-61952

03/01/2022, 12:59 PM
I circumvented this for now by adding a custom union type that extends the existing one with the missing fields/overriding fields. I think this is also true for any custom identity traits you gonna add eventually...
i

important-fall-74969

03/01/2022, 3:04 PM
Thanks! Would you mind sharing your solution as an example please? Were you able to override the signature on the functions to use your custom type?
b

bored-fountain-61952

03/01/2022, 3:06 PM
Sure 🙂 I only did it for the custom trait
name
but it should be applicable to the other types as well...
Copy code
export type CustomSubmitSelfServiceRegistrationFlowBody =
  SubmitSelfServiceRegistrationFlowBody & {
    traits: {
      email: string
      name: string
    }
  }
This will also give you type safety on the input fields
i

important-fall-74969

03/01/2022, 3:13 PM
Thanks! But doesn't the
submitSelfServiceSettingsFlow
still expect the
SubmitSelfServiceRegistrationFlowBody
as an argument and not the custom type? We're calling
kratos.submitSelfServiceSettingsFlow(this.flowId, undefined, {
 
csrf_token: _this_.csrfToken,
 
method: 'lookup',
 
lookup_secret_disable: true,
})
b

bored-fountain-61952

03/01/2022, 3:21 PM
I guess so. 😅 You could always do a typecasting
as expectedType
or even
as unknown as expectedType
. Where do you type the values that you get from the form? (I do it in the
onSubmit = (values: myType)
i

important-fall-74969

03/01/2022, 5:17 PM
Yes the typecasting might help us here for now. In this situation we have a button where you can disable the 2FA using recovery codes so
submitSelfServiceSettingsFlow
is called when you click that button.
4 Views