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

Replace any with more specific types #157

Closed
mProjectsCode opened this issue Mar 5, 2024 · 1 comment
Closed

Replace any with more specific types #157

mProjectsCode opened this issue Mar 5, 2024 · 1 comment

Comments

@mProjectsCode
Copy link

There are some instances where things in the API are typed as any. E.g. the new onExternalSettingsChange which has its return type typed as any, which according to liam is so that the function can easily be made async.

The same effect can be achieved with something like void | Promise<void> or a generic helper type e.g.

type MaybePromise<T> = T | Promise<T>;

That way the function can be typed as

onExternalSettingsChange?(): MaybePromise<void>;

Which would make it clear that the function can be async and returns nothing.

@lishid
Copy link
Collaborator

lishid commented Mar 5, 2024

This is an unnecessary move that would end up restricting the type and complicating the type compiler. Using any means "our API does not care what you return, whether it's void, number, Promise<something>, it doesn't matter.

Your suggestion makes it impossible to return non-void types, which is not something we care about.

@lishid lishid closed this as completed Mar 5, 2024
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