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

Core(TypeScript): Augment Settings#get to accept an interface overload #337

Closed
kyranet opened this issue Oct 10, 2019 · 0 comments
Closed

Comments

@kyranet
Copy link
Member

kyranet commented Oct 10, 2019

Technically, it's completely possible to overload it so it takes a special interface, as used by Node.js's util.promisify:

CustomPromisify definition:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3ef1069095013311df0fc6df1cb1ba92c220be19/types/node/util.d.ts#L57-L59

CustomPromisify overload usage:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3ef1069095013311df0fc6df1cb1ba92c220be19/types/node/util.d.ts#L86

Usage examples:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3ef1069095013311df0fc6df1cb1ba92c220be19/types/node/fs.d.ts#L864-L892

This would allow us to do message.guild.settings.get(GuildSettings.Prefix); and get string as return type, likewise message.guild.settings.get(GuildSettings.Roles.Public); would get readonly string[] as return type.

So essentially we can forget about the headache of having to do message.guild.settings.get(GuildSettings.Roles.Public) as GuildSettings.Roles.Public; which I often declare as an argument to improve code readability.

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