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 generics in type definitions #25

Open
strazto opened this issue May 29, 2024 · 1 comment
Open

Use generics in type definitions #25

strazto opened this issue May 29, 2024 · 1 comment

Comments

@strazto
Copy link

strazto commented May 29, 2024

Currently the type definitions use a tonne of any's for the return values.

db64/src/db64.d.ts

Lines 3 to 25 in 02b79b2

export function create(name: any, storeNames: any): Promise<void | {
create: (name: any, storeNames: any) => Promise<void | any>;
use: (name: any, storeName: any) => {
set: (key: any, value: any) => Promise<any>;
setEntries: (value: any) => Promise<any>;
get: (key: any) => Promise<any>;
getEntries: (keys: any) => Promise<any>;
delete: (keys: any) => Promise<any>;
};
clear: (name: any, storeName: any) => Promise<any>;
delete: (name: any) => Promise<any>;
}>;
export function use(name: any, storeName: any): {
set: (key: any, value: any) => Promise<any>;
setEntries: (value: any) => Promise<any>;
get: (key: any) => Promise<any>;
getEntries: (keys: any) => Promise<any>;
delete: (keys: any) => Promise<any>;
};
export function clear(name: any, storeName: any): Promise<any>;
export function _delete(name: any): Promise<any>;
export { _delete as delete };
}

Looks like that's because you generate them from js, #15

It'd be good to improve these typings to allow user-defined return types (using generics https://www.typescriptlang.org/docs/handbook/2/generics.html ) , and also would be nice to give more solid type-hints on the parameter values (which mainly look like they're strings).

https://medium.com/@antonkrinitsyn/jsdoc-generic-types-typescript-db213cf48640 looks like generics can be used in JSDoc type hints

@julienetie
Copy link
Owner

Thanks Matthew. it's in the pipeline for sure but do feel free to raise an MR.

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

2 participants