Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type definition for onError callback #68

Merged
merged 1 commit into from
May 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/lib/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ interface RenderOptions {
callback?: (token: string) => void

/**
* 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).
* 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).
*/
'error-callback'?: () => void
'error-callback'?: (errorCode: number) => void

/**
* 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.
Expand Down Expand Up @@ -301,7 +301,7 @@ interface ScriptOptions {
}

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

/**
* Callback invoked when there is an error (e.g. network error or the challenge failed).
* 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).
*/
onError?: RenderOptions['error-callback']

Expand Down
Loading