Skip to content

Commit

Permalink
remove assert type
Browse files Browse the repository at this point in the history
  • Loading branch information
KurtGokhan committed Jan 20, 2024
1 parent 1363974 commit fa34c04
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/helpers/typing.ts

This file was deleted.

5 changes: 2 additions & 3 deletions src/lib/track-callback.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { cloneElement, DOMAttributes, ReactElement, useCallback } from 'react';
import { cloneElement, DOMAttributes, useCallback } from 'react';
import { isElement } from 'react-is';
import { assertType } from '../helpers/typing';
import { useStableCallback } from '../hooks/use-stable-callback';
import { ReactOn, ReactOnBase, TrackCallbackProps, TrackFn } from '../types';

Expand All @@ -13,7 +12,7 @@ export function createTrackCallback<TBase extends ReactOnBase = ReactOn>(useTrac
ComponentType = DOMAttributes<any>,
CallbackName extends PropertyKey = CallbackNames<ComponentType> | (string & {}),
>({ children, callback, name, disabled, ...props }: TProps & { callback: CallbackName }) {
if (!isElement(children) && !assertType<ReactElement>(children)) {
if (!isElement(children)) {
throw new Error('Children passed to track directive must be an element with ref');
}

Expand Down
5 changes: 2 additions & 3 deletions src/lib/track-event.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { cloneElement, ReactElement, useCallback, useRef } from 'react';
import { cloneElement, useCallback, useRef } from 'react';
import { isElement } from 'react-is';
import { assertType } from '../helpers/typing';
import { useCombinedRefs } from '../hooks/use-combined-refs';
import { useStableCallback } from '../hooks/use-stable-callback';
import { ReactOn, ReactOnBase, TrackEventProps, TrackFn } from '../types';
Expand All @@ -19,7 +18,7 @@ export function createTrackEvent<TBase extends ReactOnBase = ReactOn>(useTrack:
preventDefault,
values,
}: TProps & { event: EventName }) {
if (!isElement(children) && !assertType<ReactElement>(children)) {
if (!isElement(children)) {
throw new Error('Children passed to track directive must be an element with ref');
}

Expand Down

0 comments on commit fa34c04

Please sign in to comment.