Reputation: 160
I'm using Braintree Sandbox in my ReactJs project with typescript.
According to Braintree Docs for focus, a field can be focused using the .focus()
method.
hostedFieldsInstance.focus('number', function (focusErr) {
if (focusErr) {
console.error(focusErr);
}
});
Issue: In my typeScript file, hostedFieldsInstance is not showing the.focus()
method as a valid method. Im getting the following error:
Property 'focus' does not exist on type 'HostedFields'.ts(2339)
VS Code is also suggesting only few existing braintree methods but not .focus()
:
Upvotes: 3
Views: 311
Reputation: 1865
The TS definitions from DefinitelyTyped don't include that function, but that doesn't mean that you cannot call it regardless. Your options include:
(hostedFields as any).focus(...)
)Upvotes: 3