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

Use TS generics to improve random_element return type #115

Open
TSMMark opened this issue Nov 10, 2022 · 0 comments
Open

Use TS generics to improve random_element return type #115

TSMMark opened this issue Nov 10, 2022 · 0 comments

Comments

@TSMMark
Copy link

TSMMark commented Nov 10, 2022

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Some of the functions could easily have their TS types improved by using generics.

Here is the diff that solved my problem:

diff --git a/node_modules/casual/index.d.ts b/node_modules/casual/index.d.ts
index b556860..b0098e5 100644
--- a/node_modules/casual/index.d.ts
+++ b/node_modules/casual/index.d.ts
@@ -282,7 +282,7 @@ declare namespace Casual {
     define(type: string, cb: (...args: any[]) => any): void;
 
     // HELPERS
-    random_element(elements: Array<any>): any;
+    random_element<T>(elements: Array<T>): T;
     random_value(obj: Object): any;
     random_key(obj: Object): any;
     populate(str: string): string;

This issue body was partially generated by patch-package.

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

No branches or pull requests

1 participant