Skip to content

Commit fc0090e

Browse files
authored
Merge pull request #68 from marsidev/fix/types
Fix type definition for `onError` callback
2 parents 3fa2288 + 3b14032 commit fc0090e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/lib/src/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ interface RenderOptions {
117117
callback?: (token: string) => void
118118

119119
/**
120-
* Callback invoked when there is an error (e.g. network error or the challenge failed). Refer to [Client-side errors](https://developers.cloudflare.com/turnstile/reference/client-side-errors).
120+
* Callback invoked when there is an error (e.g. network error or the challenge failed), it receives the error code as argument. Refer to [Client-side errors](https://developers.cloudflare.com/turnstile/reference/client-side-errors).
121121
*/
122-
'error-callback'?: () => void
122+
'error-callback'?: (errorCode: number) => void
123123

124124
/**
125125
* Execution controls when to obtain the token of the widget and can be on `'render'` (default) or on `'execute'`. See {@link https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/#execution-modes the docs} for more info.
@@ -301,7 +301,7 @@ interface ScriptOptions {
301301
}
302302

303303
/** `<Turnstile />` component props */
304-
interface TurnstileProps extends React.HTMLAttributes<HTMLDivElement> {
304+
interface TurnstileProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onError'> {
305305
/**
306306
* The sitekey of your widget. This sitekey is created upon the widget creation.
307307
*/
@@ -324,7 +324,7 @@ interface TurnstileProps extends React.HTMLAttributes<HTMLDivElement> {
324324
onExpire?: RenderOptions['expired-callback']
325325

326326
/**
327-
* Callback invoked when there is an error (e.g. network error or the challenge failed).
327+
* Callback invoked when there is an error (e.g. network error or the challenge failed), it receives the error code as argument. Refer to [Client-side errors](https://developers.cloudflare.com/turnstile/reference/client-side-errors).
328328
*/
329329
onError?: RenderOptions['error-callback']
330330

0 commit comments

Comments
 (0)