Skip to content

refactor: Improve debounce type safety using generics #280

@yceffort-naver

Description

@yceffort-naver

This is not related to the changes in this PR, but I have a question regarding the debounce implementation, especially about the return type of func.

Currently, the func argument is typed to return unknown. Is this considered type-safe in TypeScript?
For example, if I pass an async function that returns a Promise<boolean> to debounce, the resulting debounced function’s return type becomes unknown, which requires type assertions or runtime checks when using the return value.
Would it be possible or preferable to type the debounced function so that it preserves the original return type of func, instead of returning unknown?

Originally posted by @yujeong-jeon in #275 (comment)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions