Skip to content

Commit

Permalink
fix: make the generic param optional
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Dec 1, 2022
1 parent 59fbe96 commit 1bc73d3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import type {
} from 'compute-scroll-into-view'

/** @public */
export type Options<T> = StandardBehaviorOptions | CustomBehaviorOptions<T>
export type Options<T = unknown> =
| StandardBehaviorOptions
| CustomBehaviorOptions<T>

/** @public */
export interface StandardBehaviorOptions extends BaseOptions {
Expand All @@ -16,7 +18,7 @@ export interface StandardBehaviorOptions extends BaseOptions {
}

/** @public */
export interface CustomBehaviorOptions<T> extends BaseOptions {
export interface CustomBehaviorOptions<T = unknown> extends BaseOptions {
behavior: CustomScrollBehaviorCallback<T>
}

Expand All @@ -30,7 +32,7 @@ let isStandardScrollBehavior = (
): options is StandardBehaviorOptions =>
options === Object(options) && Object.keys(options).length !== 0

let isCustomScrollBehavior = <T>(
let isCustomScrollBehavior = <T = unknown>(
options: any
): options is CustomBehaviorOptions<T> =>
typeof options === 'object' ? typeof options.behavior === 'function' : false
Expand Down Expand Up @@ -64,7 +66,7 @@ export default function scrollIntoView(
options?: StandardBehaviorOptions | boolean
): void
/** @public */
export default function scrollIntoView<T>(
export default function scrollIntoView<T = unknown>(
target: Element,
options?: StandardBehaviorOptions | CustomBehaviorOptions<T> | boolean
): T | void {
Expand Down

0 comments on commit 1bc73d3

Please sign in to comment.