Skip to content

Commit 0e28414

Browse files
committed
dont typecheck callback fns
1 parent a4465c9 commit 0e28414

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

packages/feedback/src/widget/Actor.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ interface ActorComponent extends FeedbackComponent<HTMLButtonElement> {
2424
*/
2525
export function Actor({ options, theme, onClick }: Props): ActorComponent {
2626
function _handleClick(e: MouseEvent) {
27-
if (typeof onClick === 'function') {
28-
onClick(e);
29-
}
27+
onClick && onClick(e);
3028
}
29+
3130
const $el = h(
3231
'button',
3332
{

packages/feedback/src/widget/Dialog.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ export function Dialog({
6666

6767
// Only this should trigger `onClose`, we don't want the `close()` method to
6868
// trigger it, otherwise it can cause cycles.
69-
if (typeof onClose === 'function') {
70-
onClose();
71-
}
69+
onClose && onClose();
7270
}
7371

7472
/**

packages/feedback/src/widget/Form.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function Form({ defaultName, defaultEmail, onCancel, onSubmit, options }:
6666
}
6767

6868
try {
69-
if (typeof onSubmit === 'function') {
69+
if (onSubmit) {
7070
const formData = new FormData(e.target as HTMLFormElement);
7171
const feedback = {
7272
name: retrieveStringValue(formData, 'name'),
@@ -144,9 +144,7 @@ export function Form({ defaultName, defaultEmail, onCancel, onSubmit, options }:
144144
type: 'button',
145145
className: 'btn btn--default',
146146
onClick: (e: Event) => {
147-
if (typeof onCancel === 'function') {
148-
onCancel(e);
149-
}
147+
onCancel && onCancel(e);
150148
},
151149
},
152150
options.cancelButtonLabel,

packages/feedback/src/widget/SuccessMessage.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ export function SuccessMessage({ message, theme, onRemove }: SuccessMessageProps
2525
}
2626

2727
$el.remove();
28-
if (typeof onRemove === 'function') {
29-
onRemove();
30-
}
28+
onRemove && onRemove();
3129
}
3230

3331
const $el = h(

0 commit comments

Comments
 (0)