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

Function overloading is is wrong order #241

Closed
captain-yossarian opened this issue Jun 20, 2021 · 5 comments
Closed

Function overloading is is wrong order #241

captain-yossarian opened this issue Jun 20, 2021 · 5 comments

Comments

@captain-yossarian
Copy link
Collaborator

captain-yossarian commented Jun 20, 2021

According to TS docs less specific overload should be at the end.

In order for the compiler to pick the correct type check, it follows a similar process to the underlying JavaScript. It looks at the overload list and, proceeding with the first overload, attempts to call the function with the provided parameters. If it finds a match, it picks this overload as the correct overload. For this reason, it’s customary to order overloads from most specific to least specific.

Please see this file

Problem is in mock function.

Untitled
Third argument should be infered as a function but instead it has been infered to any

@nelsonic
Copy link
Member

Hi @captain-yossarian thanks for opening this issue and including a screenshot from VSCode. 🏅
The page you've linked to to: https://www.typescriptlang.org/docs/handbook/functions.html has a deprecation notice:
typscript-functions-page-deprecated

Thankfully the new handbook page that replaces it has even more detail: 🎉
https://www.typescriptlang.org/docs/handbook/2/functions.html#function-overloads

image

image

image

Thanks that was a good morning read; I learned how Typescript handles overloading:
https://stackoverflow.com/questions/13212625/typescript-function-overloading

🙂

@nelsonic
Copy link
Member

Fixed by #242. Published to NPM: aws-sdk-mock@5.2.1 📦 :shipit:
Thanks again @captain-yossarian

@captain-yossarian
Copy link
Collaborator Author

@nelsonic btw, this issue comes from SO question

@nelsonic
Copy link
Member

FYI: https://github.com/dwyl/aws-sdk-mock/invitations
Up-voted your SO answer. Very detailed. 👍

@captain-yossarian
Copy link
Collaborator Author

@nelsonic thanks a lot!

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