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

Explict callback types in option #398

Open
offich opened this issue Nov 24, 2024 · 0 comments · May be fixed by #397
Open

Explict callback types in option #398

offich opened this issue Nov 24, 2024 · 0 comments · May be fixed by #397

Comments

@offich
Copy link

offich commented Nov 24, 2024

Thank you so much for great library.

When I used it, I did not know at first that I could refer to typeit instance in callbacks like afterComplete since types definition file did not say so. Types for the callbacks are only Function, so I would like to explicit them.

diff --git a/packages/typeit/src/types.ts b/packages/typeit/src/types.ts
index 308657a..e6115cc 100644
--- a/packages/typeit/src/types.ts
+++ b/packages/typeit/src/types.ts
@@ -1,3 +1,5 @@
 export type Character = {
   node: El | null;
   content: string | Node;
@@ -34,11 +36,11 @@ export interface Options {
   startDelete?: boolean;
   strings?: string[] | string;
   waitUntilVisible?: boolean;
-  beforeString?: Function;
-  afterString?: Function;
-  beforeStep?: Function;
-  afterStep?: Function;
-  afterComplete?: Function;
+  beforeString?: (string: String, instance: TypeIt) => void | ((string: String, instance: TypeIt) => Promise<void>);
+  afterString?: (string: String, instance: TypeIt) => void | ((string: String, instance: TypeIt) => Promise<void>);
+  beforeStep?: (instance: TypeIt) => void | ((instance: TypeIt) => Promise<void>);
+  afterStep?: (instance: TypeIt) => void | ((instance: TypeIt) => Promise<void>);
+  afterComplete?: (instance: TypeIt) => void | ((instance: TypeIt) => Promise<void>);
 }
@offich offich linked a pull request Nov 24, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant